public void testAddWs() throws IOException, ParsingException
{
Document muleDoc = XmlUtil.loadDocument(MuleConfig.class.getResource("/test/resources/mule/mule-1.xml"));
Document expectedDoc = XmlUtil.loadDocument(MuleConfig.class.getResource("/test/resources/mule/mule-expected-1.xml"));
MuleConfig mc1 = new MuleConfig(muleDoc);
// Add a ws with a Mule name that already exists
try
{
mc1.addWs(WS_1);
fail(EXPECT_ILLEGAL_ARGUMENT_EXCEPTION);
}
catch (IllegalStateException e)
{
}
// Add a ws with a Mule Endpoint that already exists
try
{
mc1.addWs(WS_2);
fail(EXPECT_ILLEGAL_ARGUMENT_EXCEPTION);
}
catch (IllegalStateException e)
{
}
// Add a good ws with a description
mc1.addWs(WS_3);
assertEquals(mc1.getMuleNames(), NAMES_1_2);
assertDocumentEquals(expectedDoc ,muleDoc);
//add a WS with a description to an empty document
Document doc = XmlUtil.loadDocument(MuleConfig.class.getResource("/main/resources/mule/mule-empty.xml"));
MuleConfig mc2 = new MuleConfig(doc);
mc2.addWs(WS_1);
mc2.addWs(WS_2);
Document expectedDoc2 = XmlUtil.loadDocument(MuleConfig.class.getResource("/test/resources/mule/mule-expected-3.xml"));
assertDocumentEquals(expectedDoc2, mc2.getDocument());
assertEquals(NAMES_1_2, mc2.getMuleNames());
//add a WS without a description to an empty document
Document doc2 = XmlUtil.loadDocument(MuleConfig.class.getResource("/main/resources/mule/mule-empty.xml"));
MuleConfig mc3 = new MuleConfig(doc2);
mc3.addWs(WS_4);
mc3.addWs(WS_1);
Document expectedDoc3 = XmlUtil.loadDocument(MuleConfig.class.getResource("/test/resources/mule/mule-expected-4.xml"));
assertDocumentEquals(expectedDoc3, mc3.getDocument());
}