Search in sources :

Example 51 with Domain

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);
    }
}
Also used : TransactionListener(org.jvnet.hk2.config.TransactionListener) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) UnprocessedChangeEvents(org.jvnet.hk2.config.UnprocessedChangeEvents) PropertyChangeEvent(java.beans.PropertyChangeEvent) HashMap(java.util.HashMap) ConfigBean(org.jvnet.hk2.config.ConfigBean) PropertyVetoException(java.beans.PropertyVetoException) Transactions(org.jvnet.hk2.config.Transactions) Changed(org.jvnet.hk2.config.Changed) NotProcessed(org.jvnet.hk2.config.NotProcessed) List(java.util.List) Domain(com.sun.enterprise.config.serverbeans.Domain) Property(org.jvnet.hk2.config.types.Property) Test(org.junit.Test)

Example 52 with Domain

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());
}
Also used : DeploymentGroups(fish.payara.enterprise.config.serverbeans.DeploymentGroups) Domain(com.sun.enterprise.config.serverbeans.Domain) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 53 with Domain

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"));
}
Also used : Domain(com.sun.enterprise.config.serverbeans.Domain) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 54 with Domain

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());
}
Also used : DeploymentGroups(fish.payara.enterprise.config.serverbeans.DeploymentGroups) Server(com.sun.enterprise.config.serverbeans.Server) Domain(com.sun.enterprise.config.serverbeans.Domain) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Example 55 with Domain

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());
}
Also used : Domain(com.sun.enterprise.config.serverbeans.Domain) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup) ConfigApiTest(com.sun.enterprise.configapi.tests.ConfigApiTest) Test(org.junit.Test)

Aggregations

Domain (com.sun.enterprise.config.serverbeans.Domain)70 Test (org.junit.Test)21 Server (com.sun.enterprise.config.serverbeans.Server)15 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)12 Dom (org.jvnet.hk2.config.Dom)11 PropertyVetoException (java.beans.PropertyVetoException)10 Cluster (com.sun.enterprise.config.serverbeans.Cluster)7 Resources (com.sun.enterprise.config.serverbeans.Resources)7 ServiceLocator (org.glassfish.hk2.api.ServiceLocator)7 ServerContext (org.glassfish.internal.api.ServerContext)7 Config (com.sun.enterprise.config.serverbeans.Config)6 Resource (com.sun.enterprise.config.serverbeans.Resource)6 ParameterMap (org.glassfish.api.admin.ParameterMap)6 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)6 DeploymentGroup (fish.payara.enterprise.config.serverbeans.DeploymentGroup)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Before (org.junit.Before)5 ConfigModel (org.jvnet.hk2.config.ConfigModel)5 PropsFileActionReporter (com.sun.enterprise.admin.report.PropsFileActionReporter)4