Search in sources :

Example 1 with ContainerServices

use of alma.acs.container.ContainerServices in project ACS by ACS-Community.

the class MessageTest method testTextMessage.

/**
	 * Test the ACSJMSTextMessage
	 * 
	 * @throws Exception
	 */
public void testTextMessage() throws Exception {
    ContainerServices cs = getContainerServices();
    assertNotNull("ContainerServices is null!", cs);
    ACSJMSTextMessage txtMsg = new ACSJMSTextMessage(cs);
    assertNotNull("Error building the ACSJMSTextMessage", txtMsg);
    String text = "The test of the message";
    txtMsg.setText(text);
    assertEquals("Wrong test returned by the message", text, txtMsg.getText());
}
Also used : ACSJMSTextMessage(com.cosylab.acs.jms.ACSJMSTextMessage) ContainerServices(alma.acs.container.ContainerServices)

Example 2 with ContainerServices

use of alma.acs.container.ContainerServices in project ACS by ACS-Community.

the class MessageTest method testEntity.

public void testEntity() throws Exception {
    ContainerServices cs = getContainerServices();
    assertNotNull("ContainerServices is null!", cs);
    ACSJMSMessageEntity entity = new ACSJMSMessageEntity();
    String entityTxt = "Text for the entity";
    Integer priority = 100;
    entity.priority = priority;
    entity.text = entityTxt;
    ACSJMSMessage msg = new ACSJMSMessage(entity, cs);
    assertNotNull("Error building ACSJMSMessage", msg);
    ACSJMSMessageEntity entityReturned = msg.getEntity();
    assertNotNull("Enitity is null!", entityReturned);
    assertEquals("Wrong text in the returned entity", entityTxt, entityReturned.text);
    assertEquals("Wrong priority in the returned entity", priority, (Integer) entityReturned.priority);
}
Also used : ACSJMSMessageEntity(com.cosylab.acs.jms.ACSJMSMessageEntity) ACSJMSMessage(com.cosylab.acs.jms.ACSJMSMessage) ContainerServices(alma.acs.container.ContainerServices)

Example 3 with ContainerServices

use of alma.acs.container.ContainerServices in project ACS by ACS-Community.

the class MessageTest method testObjectMessage.

/**
	 * Test the ACSJMSObjectMessage
	 * 
	 * @throws Exception
	 */
public void testObjectMessage() throws Exception {
    ContainerServices cs = getContainerServices();
    assertNotNull("ContainerServices is null!", cs);
    ACSJMSObjectMessage objMsg = new ACSJMSObjectMessage(cs);
    assertNotNull("Error building the ACSJMSObjectMessage", objMsg);
    Integer intVal = new Integer(1099);
    objMsg.setObject(intVal);
    Object obj = objMsg.getObject();
    assertTrue("Wrong class type", obj instanceof Integer);
    assertEquals("The object differs", intVal, (Integer) obj);
}
Also used : ContainerServices(alma.acs.container.ContainerServices) ACSJMSObjectMessage(com.cosylab.acs.jms.ACSJMSObjectMessage)

Example 4 with ContainerServices

use of alma.acs.container.ContainerServices in project ACS by ACS-Community.

the class MountSupplier method main.

// //////////////////////////////////////////////////////////////////////////
/**
	 * In this example, the main function is all that is used.
	 * 
	 * @param args
	 *            Not used!
	 */
public static void main(String[] args) {
    try {
        // Setup an ACS Java client. This has little to do with the NC API
        String managerLoc = System.getProperty("ACS.manager");
        if (managerLoc == null) {
            System.out.println("Java property 'ACS.manager' must be set to the corbaloc of the ACS manager!");
            System.exit(-1);
        }
        String clientName = "MountSupplierClient";
        ComponentClient myClient = new ComponentClient(null, managerLoc, clientName);
        ContainerServices cs = myClient.getContainerServices();
        // Create and initialize the supplier
        AcsEventPublisher<MountEventData> joe = cs.createNotificationChannelPublisher(// the channel's name
        MOUNT_CHANNEL.value, MountEventData.class);
        // Create the event that will be published
        MountEventData t_block = new MountEventData(3.14F, 43.0F);
        // Publish the event 50 times int 50 seconds
        System.out.println("Now sending events...");
        for (int i = 0; i < 50; i++) {
            joe.publishEvent(t_block);
            sleep(1000);
        }
        // Must cleanly disconnect the supplier
        joe.disconnect();
        // Must cleanly disconnect the client
        myClient.tearDown();
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}
Also used : ComponentClient(alma.acs.component.client.ComponentClient) ContainerServices(alma.acs.container.ContainerServices)

Example 5 with ContainerServices

use of alma.acs.container.ContainerServices in project ACS by ACS-Community.

the class AdvancedComponentClientTest method testCreateContainerServices.

public void testCreateContainerServices() throws Exception {
    String localClientName = "sillyLocalClient";
    ContainerServices newCS = client.createContainerServices(localClientName, logger);
    assertEquals(newCS.getName(), localClientName);
    try {
        newCS.getComponentStateManager();
        fail("NPE expected in getComponentStateManager call!");
    } catch (NullPointerException ex) {
        // that's good
        ;
    }
    // get references to the same component through two different CS instances
    final String compInstance = "CONT_SERVICES_TESTER";
    ContainerServicesTester compRef1 = ContainerServicesTesterHelper.narrow(client.getContainerServices().getComponent(compInstance));
    assertNotNull(compRef1);
    ContainerServicesTester compRef2 = ContainerServicesTesterHelper.narrow(newCS.getComponent(compInstance));
    assertNotNull(compRef2);
    assertNotSame("Should have gotten a new CORBA proxy for the same component.", compRef1, compRef2);
    assertEquals(compRef1.name(), compRef2.name());
}
Also used : ContainerServicesTester(alma.jconttest.ContainerServicesTester) ContainerServices(alma.acs.container.ContainerServices)

Aggregations

ContainerServices (alma.acs.container.ContainerServices)7 ACSJMSMessageEntity (com.cosylab.acs.jms.ACSJMSMessageEntity)3 ACSJMSMessage (com.cosylab.acs.jms.ACSJMSMessage)2 ComponentClient (alma.acs.component.client.ComponentClient)1 ContainerServicesTester (alma.jconttest.ContainerServicesTester)1 ACSJMSObjectMessage (com.cosylab.acs.jms.ACSJMSObjectMessage)1 ACSJMSTextMessage (com.cosylab.acs.jms.ACSJMSTextMessage)1