mil.dod.th.ose.datastream/test/mil/dod/th/ose/datastream/TestDataStreamServiceImpl.java
@SuppressWarnings("unchecked")
    @Test
    public void testCreateStreamProfileException() throws FactoryObjectInformationException,
        FactoryException, IllegalArgumentException, InvalidSyntaxException
    {
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(DataStreamServiceConfig.CONFIG_PROP_MULTICAST_HOST, "225.1.2.3");
        props.put(DataStreamServiceConfig.CONFIG_PROP_START_PORT, 5004);
        
        m_SUT.activate(Collections.unmodifiableMap(props), m_BundleContext);
        
        when(m_Registry.createNewObject(eq(m_StreamProfileFactory), Mockito.any(String.class),
                Mockito.any(Map.class))).thenThrow(new IllegalArgumentException("test error"));
  
        try
        {
            m_SUT.createStreamProfile(PRODUCT_TYPE, m_ProductName, new HashMap<String, Object>());
            fail("Expected exception from createStreamProfile");
        }
        catch (StreamProfileException e)
        {
            verify(m_WakeLock).activate();
            verify(m_WakeLock).cancel();
        }
    }
/**
     * Test handling of exception when trying to create a stream profile.
     */
Test handling of exception when trying to create a stream profile.
Test handling of exception when trying to create a stream profile .
@SuppressWarnings("unchecked")
    @Test
    public void testCreateStreamProfileException() throws FactoryObjectInformationException,
        FactoryException, IllegalArgumentException, InvalidSyntaxException
    {
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(DataStreamServiceConfig.CONFIG_PROP_MULTICAST_HOST, "225.1.2.3");
        props.put(DataStreamServiceConfig.CONFIG_PROP_START_PORT, 5004);
        m_SUT.activate(Collections.unmodifiableMap(props), m_BundleContext);
        when(m_Registry.createNewObject(eq(m_StreamProfileFactory), Mockito.any(String.class),
                Mockito.any(Map.class))).thenThrow(new IllegalArgumentException("test error"));
        try
        {
            m_SUT.createStreamProfile(PRODUCT_TYPE, m_ProductName, new HashMap<String, Object>());
            fail("Expected exception from createStreamProfile");
        }
        catch (StreamProfileException e)
        {
            verify(m_WakeLock).activate();
            verify(m_WakeLock).cancel();
        }
    }
@ SuppressWarnings ( "unchecked" ) @ Test public void testCreateStreamProfileException ( ) throws FactoryObjectInformationException , FactoryException , IllegalArgumentException , InvalidSyntaxException { Map < String , Object > props = new HashMap < String , Object > ( ) ; props . put ( DataStreamServiceConfig . CONFIG_PROP_MULTICAST_HOST , "225.1.2.3" ) ; props . put ( DataStreamServiceConfig . CONFIG_PROP_START_PORT , 5004 ) ; m_SUT . activate ( Collections . unmodifiableMap ( props ) , m_BundleContext ) ; when ( m_Registry . createNewObject ( eq ( m_StreamProfileFactory ) , Mockito . any ( String . class ) , Mockito . any ( Map . class ) ) ) . thenThrow ( new IllegalArgumentException ( "test error" ) ) ; try { m_SUT . createStreamProfile ( PRODUCT_TYPE , m_ProductName , new HashMap < String , Object > ( ) ) ; fail ( "Expected exception from createStreamProfile" ) ; } catch ( StreamProfileException e ) { verify ( m_WakeLock ) . activate ( ) ; verify ( m_WakeLock ) . cancel ( ) ; } }
Test handling of exception when trying to create a stream profile.
Test handling of exception when trying to create a stream profile .