Search in sources :

Example 1 with ROstringSeq

use of alma.ACS.ROstringSeq in project ACS by ACS-Community.

the class SimpleMasterComponentTest method test.

/**
	 * Main test routine.
	 */
public void test() {
    initializeCORBA();
    Manager manager = resolveManager();
    if (manager != null) {
        ClientInfo clientInfo = login(manager);
        if (clientInfo != null) {
            System.out.println("All initialization done.");
            //
            // get component
            //
            final String COMPONENT_NAME = "SIMPLEMASTERCOMPONENT1";
            org.omg.CORBA.Object obj;
            try {
                obj = manager.get_component(clientInfo.h, COMPONENT_NAME, true);
                SimpleMasterComponent simpleMasterComponent = SimpleMasterComponentHelper.narrow(obj);
                ROstringSeq currentStateHierarchy = simpleMasterComponent.currentStateHierarchy();
                // syncvalue retrival
                System.out.println("Current state hierarchy: " + getStringArray(currentStateHierarchy.get_sync(new CompletionHolder())));
                System.out.println("Monitoring - 1s interval...");
                // create a monitor
                MonitorstringSeq monitor = currentStateHierarchy.create_monitor(new CBstringSeqImpl()._this(orb), new CBDescIn());
                // sleep for a while
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException ie) {
                }
                ;
                monitor.set_timer_trigger(0);
                monitor.set_value_trigger(new String[0], true);
                System.out.println("On-change monitoring...");
                // sleep for a while
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException ie) {
                }
                ;
                monitor.destroy();
            } catch (Exception e) {
                // CannotGetComponentEx, ComponentConfigurationNotFoundEx
                System.err.println("Failed to obtain component: " + COMPONENT_NAME);
            }
            // release now
            try {
                manager.release_component(clientInfo.h, COMPONENT_NAME);
            } catch (NoPermissionEx ex) {
                ex.printStackTrace();
            }
            logout(manager, clientInfo);
        }
    }
    finalizeCORBA();
}
Also used : SimpleMasterComponent(test.jbaci.SimpleMasterComponent) POAManager(org.omg.PortableServer.POAManager) Manager(si.ijs.maci.Manager) CBDescIn(alma.ACS.CBDescIn) ROstringSeq(alma.ACS.ROstringSeq) MonitorstringSeq(alma.ACS.MonitorstringSeq) NoPermissionEx(alma.maciErrType.NoPermissionEx) CompletionHolder(alma.ACSErr.CompletionHolder) ClientInfo(si.ijs.maci.ClientInfo)

Example 2 with ROstringSeq

use of alma.ACS.ROstringSeq in project ACS by ACS-Community.

the class MasterComponentTest method testInitPass1.

public void testInitPass1() throws Exception {
    ROstringSeq statesProperty = m_masterComp.currentStateHierarchy();
    assertNotNull(statesProperty);
    // verify initial state
    String[] expectedHierarchy = new String[] { SUBSYSSTATE_AVAILABLE.value, SUBSYSSTATE_OFFLINE.value, SUBSYSSTATE_SHUTDOWN.value };
    verifyCurrentState(statesProperty, expectedHierarchy);
    // send event
    m_masterComp.doTransition(SubsystemStateEvent.SUBSYSEVENT_INITPASS1);
    // verify transient state (available for 1 second thanks to a sleepy test component action)
    expectedHierarchy[2] = SUBSYSSTATE_INITIALIZING_PASS1.value;
    verifyCurrentState(statesProperty, expectedHierarchy);
    // verify new state 
    Thread.sleep(3000);
    expectedHierarchy[2] = SUBSYSSTATE_PREINITIALIZED.value;
    verifyCurrentState(statesProperty, expectedHierarchy);
    // verify correct error for illegal event
    try {
        m_masterComp.doTransition(SubsystemStateEvent.SUBSYSEVENT_STOP);
        fail("expected IllegalStateEventEx");
    } catch (IllegalStateEventEx e) {
        //			assertEquals("xyz", e.errorTrace.shortDescription);
        m_logger.info("got IllegalStateEventEx as expected.");
    } catch (Exception e) {
        fail("expected IllegalStateEventEx, but not this one: " + e.toString());
    }
}
Also used : IllegalStateEventEx(alma.ACSErrTypeCommon.IllegalStateEventEx) ROstringSeq(alma.ACS.ROstringSeq)

Example 3 with ROstringSeq

use of alma.ACS.ROstringSeq in project ACS by ACS-Community.

the class MasterComponentTest method testFullLifecycle.

public void testFullLifecycle() throws Exception {
    ROstringSeq statesProperty = m_masterComp.currentStateHierarchy();
    assertNotNull(statesProperty);
    // verify initial state
    String[] expectedHierarchy = new String[] { SUBSYSSTATE_AVAILABLE.value, SUBSYSSTATE_OFFLINE.value, SUBSYSSTATE_SHUTDOWN.value };
    verifyCurrentState(statesProperty, expectedHierarchy);
    m_masterComp.doTransition(SubsystemStateEvent.SUBSYSEVENT_INITPASS1);
    // component-side action method initSubsysPass1 will sleep 1000 ms, during which component is in state SUBSYSSTATE_INITIALIZING_PASS1
    // thus after 1500 ms we should have reached SUBSYSSTATE_PREINITIALIZED and can send the next event
    Thread.sleep(1500);
    m_masterComp.doTransition(SubsystemStateEvent.SUBSYSEVENT_INITPASS2);
    // the action method initSubsysPass2 does not do anything, so we should rather quickly go via SUBSYSSTATE_INITIALIZING_PASS2 to SUBSYSSTATE_ONLINE
    Thread.sleep(500);
    expectedHierarchy = new String[] { SUBSYSSTATE_AVAILABLE.value, SUBSYSSTATE_ONLINE.value };
    verifyCurrentState(statesProperty, expectedHierarchy);
// todo: send more events
}
Also used : ROstringSeq(alma.ACS.ROstringSeq)

Example 4 with ROstringSeq

use of alma.ACS.ROstringSeq in project ACS by ACS-Community.

the class MastercompBundle method attachListener.

/**
     * @param mcomp
     * @throws Exception
     */
private StateChangeListener attachListener(MasterComponentReadOnly mcomp) throws Exception {
    ROstringSeq statesProperty = mcomp.currentStateHierarchy();
    StateChangeListener listener = new MyStateChangeListener(m_logger);
    listener.createMonitor(statesProperty, getContainerServices());
    return listener;
}
Also used : ROstringSeq(alma.ACS.ROstringSeq) StateChangeListener(alma.ACS.MasterComponentImpl.StateChangeListener)

Example 5 with ROstringSeq

use of alma.ACS.ROstringSeq in project ACS by ACS-Community.

the class MasterComponentTest method testEventSyncMultipleRuns.

/**
	 * Test method for multiple runs of {@link #_testEventSync()}.
	 */
public void testEventSyncMultipleRuns() throws Exception {
    ROstringSeq statesProperty = m_masterComp.currentStateHierarchy();
    assertNotNull(statesProperty);
    StateChangeListener listener = new StateChangeListener(m_logger);
    listener.createMonitor(statesProperty, getContainerServices());
    for (int i = 0; i < 100; i++) {
        m_logger.info("\n*** testEventSyncMultipleRuns(" + i + ") ***");
        _testEventSync(listener);
    }
    listener.destroyMonitor();
}
Also used : ROstringSeq(alma.ACS.ROstringSeq)

Aggregations

ROstringSeq (alma.ACS.ROstringSeq)6 StateChangeListener (alma.ACS.MasterComponentImpl.StateChangeListener)2 CBDescIn (alma.ACS.CBDescIn)1 StateChangeSemaphore (alma.ACS.MasterComponentImpl.StateChangeSemaphore)1 MonitorstringSeq (alma.ACS.MonitorstringSeq)1 CompletionHolder (alma.ACSErr.CompletionHolder)1 IllegalStateEventEx (alma.ACSErrTypeCommon.IllegalStateEventEx)1 NoPermissionEx (alma.maciErrType.NoPermissionEx)1 POAManager (org.omg.PortableServer.POAManager)1 ClientInfo (si.ijs.maci.ClientInfo)1 Manager (si.ijs.maci.Manager)1 SimpleMasterComponent (test.jbaci.SimpleMasterComponent)1