Class SnapshotServerSetupTask
- java.lang.Object
-
- org.jboss.as.arquillian.setup.SnapshotServerSetupTask
-
- All Implemented Interfaces:
ServerSetupTask
public class SnapshotServerSetupTask extends Object implements ServerSetupTask
A setup task which takes a snapshot of the current configuration. It then invokes thedoSetup(ManagementClient, String)which allows configuration of the running server. OntearDown(ManagementClient, String)the snapshot server configuration is used to reload the server and overwrite the current configuration.This setup tasks should be the first setup tasks if used with other setup tasks. Otherwise, the snapshot will have changes from the previous setup tasks.
Note that if during the setup the server gets in a state of
reload-required, then the after thedoSetup(ManagementClient, String)is executed a reload will happen automatically.If the
doSetup(ManagementClient, String)fails, thetearDown(ManagementClient, String)method will be invoked.- Author:
- James R. Perkins
-
-
Constructor Summary
Constructors Constructor Description SnapshotServerSetupTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbeforeRestore(ManagementClient managementClient, String containerId)Execute any necessary work required before the restore is completed.protected voiddoSetup(ManagementClient managementClient, String containerId)Execute any necessary setup work that needs to happen before the first deployment to the given container.protected voidnonManagementCleanUp()Allows for cleaning up resources that may have been created during the setup.voidsetup(ManagementClient managementClient, String containerId)Execute any necessary setup work that needs to happen before the first deployment to the given container.voidtearDown(ManagementClient managementClient, String containerId)Execute any tear down work that needs to happen after the last deployment associated with the given container has been undeployed.protected longtimeout()The number seconds to wait for the server to reload after the server configuration has been restored or if a reload was required in thedoSetup(ManagementClient, String).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.as.arquillian.api.ServerSetupTask
executeOperation, executeOperation, executeOperation, executeOperation
-
-
-
-
Method Detail
-
setup
public final void setup(ManagementClient managementClient, String containerId) throws Exception
Description copied from interface:ServerSetupTaskExecute any necessary setup work that needs to happen before the first deployment to the given container.Note on exception handling: If an implementation of this method throws any exception, the implementation can assume the following:
- Any subsequent
ServerSetupTasksassociated with test classwill not be executed. - The deployment event that triggered the call to this method will be skipped.
- The
tearDownmethod of the instance that threw the exception will not be invoked. Therefore, implementations that throwAssumptionViolatedException, or any other exception, should do so before altering any system state. - The
tearDownmethod for any previously executedServerSetupTasksassociated with test classwill be invoked.
If any other exception is thrown, the
ServerSetupTask.tearDown(ManagementClient, String)will be executed, including this implementationstearDown(), re-throwing the original exception. The original exception will have any other exceptions thrown in thetearDown()methods add as suppressed messages.- Specified by:
setupin interfaceServerSetupTask- Parameters:
managementClient- management client to use to interact with the containercontainerId- id of the container to which the deployment will be deployed- Throws:
Exception- if a failure occurs
- Any subsequent
-
tearDown
public final void tearDown(ManagementClient managementClient, String containerId) throws Exception
Description copied from interface:ServerSetupTaskExecute any tear down work that needs to happen after the last deployment associated with the given container has been undeployed.- Specified by:
tearDownin interfaceServerSetupTask- Parameters:
managementClient- management client to use to interact with the containercontainerId- id of the container to which the deployment will be deployed- Throws:
Exception- if a failure occurs
-
doSetup
protected void doSetup(ManagementClient managementClient, String containerId) throws Exception
Execute any necessary setup work that needs to happen before the first deployment to the given container.If this method throws an exception, the
tearDown(ManagementClient, String)method will be invoked.- Parameters:
managementClient- management client to use to interact with the containercontainerId- id of the container to which the deployment will be deployed- Throws:
Exception- if a failure occurs- See Also:
setup(ManagementClient, String)
-
beforeRestore
protected void beforeRestore(ManagementClient managementClient, String containerId) throws Exception
Execute any necessary work required before the restore is completed. As an example removing a messaging queue which triggers removing the queue from a remote server.- Parameters:
managementClient- management client to use to interact with the containercontainerId- id of the container to which the deployment will be deployed- Throws:
Exception- if a failure occurs- See Also:
tearDown(ManagementClient, String)
-
nonManagementCleanUp
protected void nonManagementCleanUp() throws ExceptionAllows for cleaning up resources that may have been created during the setup. This is always executed even if thedoSetup(ManagementClient, String)fails for some reason.- Throws:
Exception- if a failure occurs
-
timeout
protected long timeout()
The number seconds to wait for the server to reload after the server configuration has been restored or if a reload was required in thedoSetup(ManagementClient, String).- Returns:
- the number of seconds to wait for a reload, the default is 10 seconds
-
-