public void testSchemaXMLWSchemaWithAll() throws Exception { Configuration config = SupportConfigFactory.getConfiguration(); ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.setRootElementName("event-page-visit"); String schemaUri = TestSchemaXMLEvent.class .getClassLoader() .getResource(CLASSLOADER_SCHEMA_WITH_ALL_URI) .toString(); eventTypeMeta.setSchemaResource(schemaUri); eventTypeMeta.addNamespacePrefix("ss", "samples:schemas:simpleSchemaWithAll"); eventTypeMeta.addXPathProperty("url", "/ss:event-page-visit/ss:url", XPathConstants.STRING); config.addEventType("PageVisitEvent", eventTypeMeta); epService = EPServiceProviderManager.getProvider("TestSchemaXML", config); epService.initialize(); updateListener = new SupportUpdateListener(); // url='page4' String text = "select a.url as sesja from pattern [ every a=PageVisitEvent(url='page1') ]"; EPStatement stmt = epService.getEPAdministrator().createEPL(text); stmt.addListener(updateListener); SupportXML.sendEvent( epService.getEPRuntime(), "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n" + "<url>page1</url>" + "</event-page-visit>"); EventBean theEvent = updateListener.getLastNewData()[0]; assertEquals("page1", theEvent.get("sesja")); updateListener.reset(); SupportXML.sendEvent( epService.getEPRuntime(), "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<event-page-visit xmlns=\"samples:schemas:simpleSchemaWithAll\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"samples:schemas:simpleSchemaWithAll simpleSchemaWithAll.xsd\">\n" + "<url>page2</url>" + "</event-page-visit>"); assertFalse(updateListener.isInvoked()); EventType type = epService.getEPAdministrator().createEPL("select * from PageVisitEvent").getEventType(); EPAssertionUtil.assertEqualsAnyOrder( new Object[] { new EventPropertyDescriptor( "sessionId", Node.class, null, false, false, false, false, true), new EventPropertyDescriptor( "customerId", Node.class, null, false, false, false, false, true), new EventPropertyDescriptor("url", String.class, null, false, false, false, false, false), new EventPropertyDescriptor("method", Node.class, null, false, false, false, false, true), }, type.getPropertyDescriptors()); }
private ConfigurationEventTypeXMLDOM getConfigTestType( String additionalXPathProperty, boolean isUseXPathPropertyExpression) { ConfigurationEventTypeXMLDOM eventTypeMeta = new ConfigurationEventTypeXMLDOM(); eventTypeMeta.setRootElementName("simpleEvent"); String schemaUri = TestSchemaXMLEvent.class.getClassLoader().getResource(CLASSLOADER_SCHEMA_URI).toString(); eventTypeMeta.setSchemaResource(schemaUri); eventTypeMeta.addNamespacePrefix("ss", "samples:schemas:simpleSchema"); eventTypeMeta.addXPathProperty( "customProp", "count(/ss:simpleEvent/ss:nested3/ss:nested4)", XPathConstants.NUMBER); eventTypeMeta.setXPathPropertyExpr(isUseXPathPropertyExpression); if (additionalXPathProperty != null) { eventTypeMeta.addXPathProperty( additionalXPathProperty, "count(/ss:simpleEvent/ss:nested3/ss:nested4)", XPathConstants.NUMBER); } return eventTypeMeta; }