mil.dod.th.ose.core/test/mil/dod/th/ose/core/impl/validator/TestValidatorImpl.java
@Test
    public void testIllegalStateBadSource() throws JAXBException, ValidationFailedException
    {
        //setup mocking
        XmlService xmlService = mock(XmlService.class);
        m_SUT.setXmlService(xmlService);
        when(xmlService.createJAXBSource(Matchers.any(JAXBContext.class), anyObject()))
            .thenThrow(new JAXBException("blah"));
        
        final TestClass data = new TestClass();
        
        try
        {
            m_SUT.validate(data);
            fail("Expected exception because of mocking above");
        }
        catch (ValidationFailedException e)
        {
            //expected
        }
    }
/**
     * Verify illegal state exception if unable to create jaxb source.
     */
Verify illegal state exception if unable to create jaxb source.
Verify illegal state exception if unable to create jaxb source .
@Test
    public void testIllegalStateBadSource() throws JAXBException, ValidationFailedException
    {
        XmlService xmlService = mock(XmlService.class);
        m_SUT.setXmlService(xmlService);
        when(xmlService.createJAXBSource(Matchers.any(JAXBContext.class), anyObject()))
            .thenThrow(new JAXBException("blah"));
        final TestClass data = new TestClass();
        try
        {
            m_SUT.validate(data);
            fail("Expected exception because of mocking above");
        }
        catch (ValidationFailedException e)
        {
        }
    }
@ Test public void testIllegalStateBadSource ( ) throws JAXBException , ValidationFailedException { XmlService xmlService = mock ( XmlService . class ) ; m_SUT . setXmlService ( xmlService ) ; when ( xmlService . createJAXBSource ( Matchers . any ( JAXBContext . class ) , anyObject ( ) ) ) . thenThrow ( new JAXBException ( "blah" ) ) ; final TestClass data = new TestClass ( ) ; try { m_SUT . validate ( data ) ; fail ( "Expected exception because of mocking above" ) ; } catch ( ValidationFailedException e ) { } }
Verify illegal state exception if unable to create jaxb source.
Verify illegal state exception if unable to create jaxb source .
//setup mocking //expected