Class Administration
Administration tools to support unit testing
Administration commands can be run in several ways depending on the requirements for the test case:
Map<String, String> parameters = new HashMap<String, String>(); Administration admin = new Administration(); // example command with no checks // admin.execute("display", "node"); // example command just validating it worked // assertTrue(admin.execute("display", "node").returnCode() == DtmCommand.COMMAND_SUCCEEDED); // example bad command just validating it failed // assertFalse(admin.execute("display", "junk").returnCode() == DtmCommand.COMMAND_SUCCEEDED); // example bad command validating error message // assertTrue(admin.execute("display", "junk").getErrorMessages().get(0).getMessage().contains("Target 'junk' does not exist")); // example command validating data via getCommandResults // parameters.clear(); List<DtmResults> resultsList = admin.execute("display", "node", parameters).getCommandResults(); assertEquals("Node is started", resultsList.get(0).getResultSet().getRow(0).getColumn(3), "Started"); // example command validating data via string // parameters.clear(); String results = admin.execute("display", "node", parameters).toString(); assertTrue("Node is started", results.contains("Started"));
By default, commands are run to the local node ( using the local node serviceName and discovery port). However commands can also be issued to other nodes in the cluster by specifying the serviceName :
// example command with servicename // parameters.clear(); admin.execute("test-framework", "display", "node", parameters);
Parameters are defined with a Map :
// example enable debugging // parameters.clear(); parameters.put("loggername", "ROOT"); parameters.put("level", "DEBUG"); admin.execute("set", "logging", parameters);
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionRun an administration command to particular service name and return resultsRun an administration command to particular service name and return resultsRun an administration command to particular service name and return resultsRun an administration command to particular service name and return results
-
Constructor Details
-
Administration
public Administration()
-
-
Method Details
-
execute
public Results execute(String serviceName, String command, String target, Map<String, String> parameters) Run an administration command to particular service name and return results
This method can be run within or outside a transaction
- Parameters:
serviceName
- Service name, can not be nullcommand
- Command, can not be nulltarget
- Target, can not be nullparameters
- Command parameters, can not be null- Returns:
- results
-
execute
Run an administration command to particular service name and return results
This method can be run within or outside a transaction
- Parameters:
command
- Command, can not be nulltarget
- Target, can not be nullparameters
- Command parameters, can not be null- Returns:
- results
-
execute
Run an administration command to particular service name and return results
This method can be run within or outside a transaction
- Parameters:
serviceName
- Service name, can not be nullcommand
- Command, can not be nulltarget
- Target, can not be null- Returns:
- results
-
execute
Run an administration command to particular service name and return results
This method can be run within or outside a transaction
- Parameters:
command
- Command, can not be nulltarget
- Target, can not be null- Returns:
- results
-