Package org.apache.sling.testing.junit.rules.instance

## Class AbstractInstance

- java.lang.Object
- - org.apache.sling.testing.junit.rules.instance.AbstractInstance

All Implemented Interfaces:
  `BuilderCustomizer`, `Instance`, `org.junit.rules.TestRule`

Direct Known Subclasses:
  `ExistingInstance`

    public abstract class AbstractInstance
    extends Object
    implements Instance

### Constructor Summary

Constructors
`AbstractInstance()`

### Method Summary

All Methods Instance Methods Concrete Methods
`<T extends org.apache.sling.testing.clients.SlingClient.InternalBuilder> T` `customize​(T builder)` Customizes the builder and returns it.
`org.apache.sling.testing.clients.SlingClient` `getAdminClient()` Return a new client pointing to the instance corresponding to this {{AbstractInstance}}, with the admin user and password, if it was not previously created, or the existing client if it has been created before See `InstanceSetup.INSTANCE_CONFIG_ADMINUSER` and `InstanceSetup.INSTANCE_CONFIG_ADMINPASSWORD`

`<T extends org.apache.sling.testing.clients.SlingClient>
T`

`getAdminClient​(Class<T> clientClass)`

Return a new client pointing to the instance corresponding to this {{AbstractInstance}}, with the admin user and password, if it was not previously created, or the existing client if it has been created before See `InstanceSetup.INSTANCE_CONFIG_ADMINUSER` and `InstanceSetup.INSTANCE_CONFIG_ADMINPASSWORD`

`protected <B extends org.apache.sling.testing.clients.SlingClient.InternalBuilder,​T extends org.apache.sling.testing.clients.SlingClient> B` `getBuilder​(Class<T> clientClass, URI url, String user, String password)`
`<T extends org.apache.sling.testing.clients.SlingClient> T` `getClient​(Class<T> clientClass, String user, String pass)` Return a new client pointing to the instance corresponding to this {{AbstractInstance}} if it was never created with this username and password, or the existing client if it has been created before
`org.apache.sling.testing.clients.SlingClient` `newAdminClient​(BuilderCustomizer... customizers)` Return a new client pointing to the instance corresponding to this {{AbstractInstance}}, replacing the internally-cached client with this username and password See `InstanceSetup.INSTANCE_CONFIG_ADMINUSER` and `InstanceSetup.INSTANCE_CONFIG_ADMINPASSWORD`
`<T extends org.apache.sling.testing.clients.SlingClient> T` `newClient​(Class<T> clientClass, String user, String pass, BuilderCustomizer... customizers)` Return a new client pointing to the instance corresponding to this {{AbstractInstance}}, replacing the internally-cached client with this username and password

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.apache.sling.testing.junit.rules.instance.Instance

`getConfiguration, orDefault, withRunMode`

### Methods inherited from interface org.junit.rules.TestRule

`apply`

### Constructor Detail

#### AbstractInstance

    public AbstractInstance()

### Method Detail

#### customize

    public <T extends org.apache.sling.testing.clients.SlingClient.InternalBuilder> T customize​(T builder)

Customizes the builder and returns it. Default implementation does nothing to the builder. This should be overridden in subclasses, if needed. This method will be called internally before building a client.

Specified by:
  `customize` in interface `BuilderCustomizer`
Parameters:
  `builder` - the builder to customize
Returns:
  the builder after customization.

#### newClient

    public <T extends org.apache.sling.testing.clients.SlingClient> T newClient​(Class<T> clientClass,
                                                                                String user,
                                                                                String pass,
                                                                                BuilderCustomizer... customizers)

Return a new client pointing to the instance corresponding to this {{AbstractInstance}}, replacing the internally-cached client with this username and password

Specified by:
  `newClient` in interface `Instance`
Type Parameters:
  `T` - the type of the returned client
Parameters:
  `clientClass` - the class of the returned client
  `user` - the username used in the client
  `pass` - the password used in the client
  `customizers` - array of customizers for this client
Returns:
  a new client extending {{SlingClient}}

#### getBuilder

    protected <B extends org.apache.sling.testing.clients.SlingClient.InternalBuilder,​T extends org.apache.sling.testing.clients.SlingClient> B getBuilder​(Class<T> clientClass,
                                                                                                                                                                 URI url,
                                                                                                                                                                 String user,
                                                                                                                                                                 String password)

#### newAdminClient

    public org.apache.sling.testing.clients.SlingClient newAdminClient​(BuilderCustomizer... customizers)

Return a new client pointing to the instance corresponding to this {{AbstractInstance}}, replacing the internally-cached client with this username and password See `InstanceSetup.INSTANCE_CONFIG_ADMINUSER` and `InstanceSetup.INSTANCE_CONFIG_ADMINPASSWORD`

Specified by:
  `newAdminClient` in interface `Instance`
Parameters:
  `customizers` - array of customizers for this client
Returns:
  a new {{SlingClient}}

#### getClient

    public <T extends org.apache.sling.testing.clients.SlingClient> T getClient​(Class<T> clientClass,
                                                                                String user,
                                                                                String pass)

Return a new client pointing to the instance corresponding to this {{AbstractInstance}} if it was never created with this username and password, or the existing client if it has been created before

Specified by:
  `getClient` in interface `Instance`
Type Parameters:
  `T` - the type of the returned client
Parameters:
  `clientClass` - the class of the returned client
  `user` - the username used in the client
  `pass` - the password used in the client
Returns:
  a new client extending {{SlingClient}}

#### getAdminClient

    public org.apache.sling.testing.clients.SlingClient getAdminClient()

Return a new client pointing to the instance corresponding to this {{AbstractInstance}}, with the admin user and password, if it was not previously created, or the existing client if it has been created before See `InstanceSetup.INSTANCE_CONFIG_ADMINUSER` and `InstanceSetup.INSTANCE_CONFIG_ADMINPASSWORD`

Specified by:
  `getAdminClient` in interface `Instance`
Returns:
  a new {{SlingClient}}

#### getAdminClient

    public <T extends org.apache.sling.testing.clients.SlingClient> T getAdminClient​(Class<T> clientClass)

Return a new client pointing to the instance corresponding to this {{AbstractInstance}}, with the admin user and password, if it was not previously created, or the existing client if it has been created before See `InstanceSetup.INSTANCE_CONFIG_ADMINUSER` and `InstanceSetup.INSTANCE_CONFIG_ADMINPASSWORD`

Specified by:
  `getAdminClient` in interface `Instance`
Type Parameters:
  `T` - the class of the returned client
Parameters:
  `clientClass` - the class of the returned client
Returns:
  a new client extending on {{SlingClient}}