use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class AddPropertyTest method transactionEvents.
@Test
public void transactionEvents() throws TransactionFailure {
final Domain domain = getHabitat().getService(Domain.class);
final TransactionListener listener = new TransactionListener() {
public void transactionCommited(List<PropertyChangeEvent> changes) {
events = changes;
}
public void unprocessedTransactedEvents(List<UnprocessedChangeEvents> changes) {
}
};
Transactions transactions = getHabitat().getService(Transactions.class);
try {
transactions.addTransactionsListener(listener);
assertTrue(domain != null);
ConfigSupport.apply(new SingleConfigCode<Domain>() {
public Object run(Domain domain) throws PropertyVetoException, TransactionFailure {
Property prop = domain.createChild(Property.class);
domain.getProperty().add(prop);
prop.setName("Jerome");
prop.setValue("was here");
return prop;
}
}, domain);
transactions.waitForDrain();
assertTrue(events != null);
logger.fine("Number of events " + events.size());
assertTrue(events.size() == 3);
for (PropertyChangeEvent event : events) {
logger.fine(event.toString());
}
Map<String, String> configChanges = new HashMap<String, String>();
configChanges.put("name", "julien");
configChanges.put("value", "petit clown");
ConfigBean domainBean = (ConfigBean) Dom.unwrap(domain);
ConfigSupport.createAndSet(domainBean, Property.class, configChanges);
transactions.waitForDrain();
assertTrue(events != null);
logger.fine("Number of events " + events.size());
assertTrue(events.size() == 3);
for (PropertyChangeEvent event : events) {
logger.fine(event.toString());
}
final UnprocessedChangeEvents unprocessed = ConfigSupport.sortAndDispatch(events.toArray(new PropertyChangeEvent[0]), new Changed() {
/**
* Notification of a change on a configuration object
*
* @param type type of change : ADD mean the changedInstance was added to the parent
* REMOVE means the changedInstance was removed from the parent, CHANGE means the
* changedInstance has mutated.
* @param changedType type of the configuration object
* @param changedInstance changed instance.
*/
public <T extends ConfigBeanProxy> NotProcessed changed(TYPE type, Class<T> changedType, T changedInstance) {
return new NotProcessed("unimplemented by AddPropertyTest");
}
}, logger);
} finally {
transactions.removeTransactionsListener(listener);
}
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class DGTest method getNamedDeploymentGroup.
@Test
public void getNamedDeploymentGroup() {
Domain d = habitat.getService(Domain.class);
DeploymentGroups dgs = d.getDeploymentGroups();
assertNotNull("Deployment Groups should not be null", dgs);
DeploymentGroup dg = dgs.getDeploymentGroup("dg1");
assertNotNull("Deployment Group should not be null", dg);
assertEquals("Deployment Group Name should be dg1", "dg1", dg.getName());
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class DGTest method testGetNamedDeploymentGroup.
@Test
public void testGetNamedDeploymentGroup() {
Domain d = habitat.getService(Domain.class);
assertNotNull("dg1 should be found by name from the domain", d.getDeploymentGroupNamed("dg1"));
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class DGTest method testGetServersFromDG.
@Test
public void testGetServersFromDG() {
Domain d = habitat.getService(Domain.class);
DeploymentGroups dgs = d.getDeploymentGroups();
assertNotNull("Deployment Groups should not be null", dgs);
List<DeploymentGroup> ldg = dgs.getDeploymentGroup();
assertNotNull("Deployment Groups List should not be null", ldg);
assertEquals("List should have 2 deployment groups", 2L, ldg.size());
// get first named group
DeploymentGroup dg = dgs.getDeploymentGroup("dg1");
assertNotNull("Deployment Group dg1 should not be null", dg);
List<Server> servers = dg.getInstances();
assertNotNull("Servers List for dg1 should not be null", servers);
assertEquals("List should have 1 Server", 1L, servers.size());
Server server = servers.get(0);
assertNotNull("Server for dg1 should not be null", server);
assertEquals("Server should be called server", "server", server.getName());
// get second named group
dg = dgs.getDeploymentGroup("dg2");
assertNotNull("Deployment Group dg2 should not be null", dg);
servers = dg.getInstances();
assertNotNull("Servers List for dg2 should not be null", servers);
assertEquals("List should have 2 Servers", 2L, servers.size());
server = servers.get(0);
assertNotNull("First Server for dg2 should not be null", server);
assertEquals("First Server should be called server", "server", server.getName());
server = servers.get(1);
assertNotNull("Second Server for dg2 should not be null", server);
assertEquals("Second Server should be called server2", "server2", server.getName());
}
use of com.sun.enterprise.config.serverbeans.Domain in project Payara by payara.
the class DGTest method testGetDeploymentGroupsForServer.
@Test
public void testGetDeploymentGroupsForServer() {
Domain d = habitat.getService(Domain.class);
DeploymentGroup dg1 = d.getDeploymentGroupNamed("dg1");
List<DeploymentGroup> dgs = d.getDeploymentGroupsForInstance("server");
assertEquals("List should have 2 Deployment Groups", 2L, dgs.size());
}
Aggregations