mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/asset/TestAssetImpl.java
@Test
    public void testDeactivateAsset() throws Exception
    {
        // try to deactivate before the asset is activated
        try
        {
            m_SUT.deactivateAsync();
            fail("Expected exception");
        }
        catch (IllegalStateException e)
        {

        }

        // wait to see if deactivation starts
        Thread.sleep(1000);

        // verify nothing happened, still same amount of events
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin, Asset.TOPIC_WILL_BE_DEACTIVATED, 0);
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin, Asset.TOPIC_DEACTIVATION_COMPLETE, 0);

        // activate asset so it can be deactivated
        EventAdminSyncer actSyncer = new EventAdminSyncer(m_EventAdmin, Asset.TOPIC_ACTIVATION_COMPLETE);
        m_SUT.activateAsync();
        actSyncer.waitFor(5, TimeUnit.SECONDS);

        // deactivate asset
        EventAdminSyncer deactSyncer = new EventAdminSyncer(m_EventAdmin, Asset.TOPIC_DEACTIVATION_COMPLETE);
        m_SUT.deactivateAsync();
        deactSyncer.waitFor(5, TimeUnit.SECONDS);

        assertThat(m_SUT.getActiveStatus(), is(AssetActiveStatus.DEACTIVATED));

        // make sure events fired with correct properties set
        EventAdminVerifier.assertEventByTopicAsset(m_EventAdmin, Asset.TOPIC_WILL_BE_DEACTIVATED, m_SUT);
        EventAdminVerifier.assertEventByTopicAsset(m_EventAdmin, Asset.TOPIC_DEACTIVATION_COMPLETE, m_SUT);

        verify(m_Proxy).onDeactivate();
    }
/**
     * Verify deactivation will update status and invoke proxy.
     */
Verify deactivation will update status and invoke proxy.
Verify deactivation will update status and invoke proxy .
@Test
    public void testDeactivateAsset() throws Exception
    {
        try
        {
            m_SUT.deactivateAsync();
            fail("Expected exception");
        }
        catch (IllegalStateException e)
        {
        }
        Thread.sleep(1000);
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin, Asset.TOPIC_WILL_BE_DEACTIVATED, 0);
        EventAdminVerifier.assertEventByTopicOnly(m_EventAdmin, Asset.TOPIC_DEACTIVATION_COMPLETE, 0);
        EventAdminSyncer actSyncer = new EventAdminSyncer(m_EventAdmin, Asset.TOPIC_ACTIVATION_COMPLETE);
        m_SUT.activateAsync();
        actSyncer.waitFor(5, TimeUnit.SECONDS);
        EventAdminSyncer deactSyncer = new EventAdminSyncer(m_EventAdmin, Asset.TOPIC_DEACTIVATION_COMPLETE);
        m_SUT.deactivateAsync();
        deactSyncer.waitFor(5, TimeUnit.SECONDS);
        assertThat(m_SUT.getActiveStatus(), is(AssetActiveStatus.DEACTIVATED));
        EventAdminVerifier.assertEventByTopicAsset(m_EventAdmin, Asset.TOPIC_WILL_BE_DEACTIVATED, m_SUT);
        EventAdminVerifier.assertEventByTopicAsset(m_EventAdmin, Asset.TOPIC_DEACTIVATION_COMPLETE, m_SUT);
        verify(m_Proxy).onDeactivate();
    }
@ Test public void testDeactivateAsset ( ) throws Exception { try { m_SUT . deactivateAsync ( ) ; fail ( "Expected exception" ) ; } catch ( IllegalStateException e ) { } Thread . sleep ( 1000 ) ; EventAdminVerifier . assertEventByTopicOnly ( m_EventAdmin , Asset . TOPIC_WILL_BE_DEACTIVATED , 0 ) ; EventAdminVerifier . assertEventByTopicOnly ( m_EventAdmin , Asset . TOPIC_DEACTIVATION_COMPLETE , 0 ) ; EventAdminSyncer actSyncer = new EventAdminSyncer ( m_EventAdmin , Asset . TOPIC_ACTIVATION_COMPLETE ) ; m_SUT . activateAsync ( ) ; actSyncer . waitFor ( 5 , TimeUnit . SECONDS ) ; EventAdminSyncer deactSyncer = new EventAdminSyncer ( m_EventAdmin , Asset . TOPIC_DEACTIVATION_COMPLETE ) ; m_SUT . deactivateAsync ( ) ; deactSyncer . waitFor ( 5 , TimeUnit . SECONDS ) ; assertThat ( m_SUT . getActiveStatus ( ) , is ( AssetActiveStatus . DEACTIVATED ) ) ; EventAdminVerifier . assertEventByTopicAsset ( m_EventAdmin , Asset . TOPIC_WILL_BE_DEACTIVATED , m_SUT ) ; EventAdminVerifier . assertEventByTopicAsset ( m_EventAdmin , Asset . TOPIC_DEACTIVATION_COMPLETE , m_SUT ) ; verify ( m_Proxy ) . onDeactivate ( ) ; }
Verify deactivation will update status and invoke proxy.
Verify deactivation will update status and invoke proxy .
// try to deactivate before the asset is activated // wait to see if deactivation starts // verify nothing happened, still same amount of events // activate asset so it can be deactivated // deactivate asset // make sure events fired with correct properties set