@Test
public void testSipXml10() throws Exception
{
//System.setProperty("org.eclipse.jetty.xml.XmlParser.Validating", "false");
SipAppContext context = new SipAppContext();
SipMetaData metaData = context.getSipMetaData();
metaData.setSipXml(getResource("/org/cipango/xml/sip-sample-1.0.xml"));
metaData.addDescriptorProcessor(new StandardDescriptorProcessor());
metaData.resolve(context);
SipServletHandler servletHandler = (SipServletHandler) context.getServletHandler();
assertEquals(SipAppContext.VERSION_10, context.getSpecVersion());
assertEquals("SIP Servlet based Registrar", context.getDisplayName());
Enumeration<String> e = context.getInitParameterNames();
String name = (String) e.nextElement();
assertEquals("contextConfigLocation", name);
assertEquals("/WEB-INF/kaleo.xml", context.getInitParameter(name));
assertFalse(e.hasMoreElements());
assertEquals(TestListener.class, context.getTimerListeners()[0].getClass());
// servlets
SipServletHolder[] holders = servletHandler.getSipServlets();
assertEquals(2, holders.length);
assertEquals("main", holders[0].getName());
// TODO assertEquals("PBX Servlet", holders[0].getDisplayName());
assertEquals("org.cipango.kaleo.PbxServlet", holders[0].getClassName());
e = holders[0].getInitParameterNames();
name = (String) e.nextElement();
assertEquals("value", holders[0].getInitParameter(name));
assertFalse(e.hasMoreElements());
assertEquals(10, holders[0].getInitOrder());
assertEquals("presence", holders[1].getName());
assertEquals("org.cipango.kaleo.presence.PresenceServlet", holders[1].getClassName());
assertFalse(holders[1].getInitParameterNames().hasMoreElements());
assertEquals(0, holders[1].getInitOrder());
// servlet-mapping
SipServletMapping[] mappings = servletHandler.getSipServletMappings();
assertEquals(1, mappings.length);
assertEquals("main", mappings[0].getServletName());
assertEquals("((request.method == REGISTER) or (request.method == PUBLISH) or (request.method == SUBSCRIBE) or (request.method == INVITE))",
mappings[0].getMatchingRuleExpression());
assertEquals(60, context.getSessionTimeout());
assertNull(servletHandler.getMainServlet());
}