You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by as...@apache.org on 2013/05/18 14:17:42 UTC
svn commit: r1484099 [4/4] - in /cxf/trunk:
distribution/src/main/release/samples/
distribution/src/main/release/samples/ws_eventing/
distribution/src/main/release/samples/ws_eventing/src/
distribution/src/main/release/samples/ws_eventing/src/main/ dis...
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/NotificationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/NotificationTest.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/NotificationTest.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/NotificationTest.java Sat May 18 12:17:39 2013
@@ -0,0 +1,467 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration;
+
+import java.io.IOException;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.ws.eventing.AttributedURIType;
+import org.apache.cxf.ws.eventing.DeliveryType;
+import org.apache.cxf.ws.eventing.EndpointReferenceType;
+import org.apache.cxf.ws.eventing.ExpirationType;
+import org.apache.cxf.ws.eventing.FilterType;
+import org.apache.cxf.ws.eventing.FormatType;
+import org.apache.cxf.ws.eventing.NotifyTo;
+import org.apache.cxf.ws.eventing.ReferenceParametersType;
+import org.apache.cxf.ws.eventing.Subscribe;
+import org.apache.cxf.ws.eventing.backend.notification.NotificatorService;
+import org.apache.cxf.ws.eventing.backend.notification.emitters.Emitter;
+import org.apache.cxf.ws.eventing.backend.notification.emitters.EmitterImpl;
+import org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest;
+import org.apache.cxf.ws.eventing.base.TestUtil;
+import org.apache.cxf.ws.eventing.integration.eventsink.TestingEventSinkImpl;
+import org.apache.cxf.ws.eventing.integration.eventsink.TestingWrappedEventSinkImpl;
+import org.apache.cxf.ws.eventing.integration.notificationapi.EarthquakeEvent;
+import org.apache.cxf.ws.eventing.integration.notificationapi.FireEvent;
+import org.apache.cxf.ws.eventing.shared.EventingConstants;
+import org.apache.cxf.ws.eventing.shared.utils.DurationAndDateUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NotificationTest extends SimpleEventingIntegrationTest {
+
+ static final String NOTIFICATION_TEST_PORT = allocatePort(NotificationTest.class);
+
+ @Test
+ public void basicReceptionOfEvents() throws IOException {
+ NotificatorService service = createNotificatorService();
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
+ eventSinkAddr.setValue(url);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+
+ eventSourceClient.subscribeOp(subscribe);
+ eventSourceClient.subscribeOp(subscribe);
+ eventSourceClient.subscribeOp(subscribe);
+
+ Server eventSinkServer = createEventSink(url);
+ TestingEventSinkImpl.RECEIVED_FIRES.set(0);
+
+ service.start();
+ Emitter emitter = new EmitterImpl(service);
+ emitter.dispatch(new FireEvent("Canada", 8));
+ for (int i = 0; i < 10; i++) {
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() == 3) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ eventSinkServer.stop();
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() != 3) {
+ Assert.fail("TestingEventSinkImpl should have received 3 events but received "
+ + TestingEventSinkImpl.RECEIVED_FIRES.get());
+ }
+ }
+
+ @Test
+ public void basicReceptionOfWrappedEvents() throws IOException {
+ NotificatorService service = createNotificatorService();
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
+ eventSinkAddr.setValue(url);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ FormatType formatType = new FormatType();
+ formatType.setName(EventingConstants.DELIVERY_FORMAT_WRAPPED);
+ subscribe.setFormat(formatType);
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+
+ eventSourceClient.subscribeOp(subscribe);
+ eventSourceClient.subscribeOp(subscribe);
+ eventSourceClient.subscribeOp(subscribe);
+
+ Server eventSinkServer = createWrappedEventSink(url);
+ TestingWrappedEventSinkImpl.RECEIVED_FIRES.set(0);
+
+ service.start();
+ Emitter emitter = new EmitterImpl(service);
+ emitter.dispatch(new FireEvent("Canada", 8));
+ for (int i = 0; i < 10; i++) {
+ if (TestingWrappedEventSinkImpl.RECEIVED_FIRES.get() == 3) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ eventSinkServer.stop();
+ if (TestingWrappedEventSinkImpl.RECEIVED_FIRES.get() != 3) {
+ Assert.fail("TestingWrappedEventSinkImpl should have received 3 events but received "
+ + TestingWrappedEventSinkImpl.RECEIVED_FIRES.get());
+ }
+ }
+
+ @Test
+ public void withWSAAction() throws Exception {
+ NotificatorService service = createNotificatorService();
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
+ eventSinkAddr.setValue(url);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+
+ eventSourceClient.subscribeOp(subscribe);
+
+ Server eventSinkServer = createEventSinkWithWSAActionAssertion(url, "http://www.fire.com");
+ TestingEventSinkImpl.RECEIVED_FIRES.set(0);
+ service.start();
+ Emitter emitter = new EmitterImpl(service);
+ emitter.dispatch(new FireEvent("Canada", 8));
+ for (int i = 0; i < 10; i++) {
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() == 1) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ eventSinkServer.stop();
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() != 1) {
+ Assert.fail("TestingEventSinkImpl should have received 1 events but received "
+ + TestingEventSinkImpl.RECEIVED_FIRES.get());
+ }
+ }
+
+ @Test
+ public void withReferenceParameters() throws Exception {
+ NotificatorService service = createNotificatorService();
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+
+ JAXBElement idqn = new JAXBElement(new QName("http://www.example.org", "MyReferenceParameter"),
+ String.class,
+ "380");
+ JAXBElement idqn2 = new JAXBElement(new QName("http://www.example.org", "MyReferenceParameter2"),
+ String.class,
+ "381");
+ eventSinkERT.setReferenceParameters(new ReferenceParametersType());
+ eventSinkERT.getReferenceParameters().getAny().add(idqn);
+ eventSinkERT.getReferenceParameters().getAny().add(idqn2);
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
+ eventSinkAddr.setValue(url);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+
+ eventSourceClient.subscribeOp(subscribe);
+
+ Server eventSinkServer = createEventSinkWithReferenceParametersAssertion(url,
+ eventSinkERT.getReferenceParameters());
+ TestingEventSinkImpl.RECEIVED_FIRES.set(0);
+ service.start();
+ Emitter emitter = new EmitterImpl(service);
+ emitter.dispatch(new FireEvent("Canada", 8));
+ for (int i = 0; i < 10; i++) {
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() == 1) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ eventSinkServer.stop();
+ int received = TestingEventSinkImpl.RECEIVED_FIRES.get();
+ if (received != 1) {
+ Assert.fail("TestingEventSinkImpl should have received 1 events but received "
+ + received);
+ }
+ }
+
+ /**
+ * We request only to receive notifications about fires in Canada
+ * and there will be a fire in Canada. We should receive
+ * this notification.
+ */
+ @Test
+ public void withFilter() throws IOException {
+ NotificatorService service = createNotificatorService();
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
+ eventSinkAddr.setValue(url);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+ subscribe.setFilter(new FilterType());
+ subscribe.getFilter().getContent().add("//*[local-name()='fire' and "
+ + "namespace-uri()='http://www.events.com']/location[text()='Canada']");
+
+
+ eventSourceClient.subscribeOp(subscribe);
+
+ Server eventSinkServer = createEventSink(url);
+ TestingEventSinkImpl.RECEIVED_FIRES.set(0);
+
+ service.start();
+ Emitter emitter = new EmitterImpl(service);
+ emitter.dispatch(new FireEvent("Canada", 8));
+ for (int i = 0; i < 10; i++) {
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() == 1) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ eventSinkServer.stop();
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() != 1) {
+ Assert.fail("TestingEventSinkImpl should have received 1 events but received "
+ + TestingEventSinkImpl.RECEIVED_FIRES.get());
+ }
+ }
+
+ /**
+ * We request only to receive notifications about fires in Russia
+ * and there will be only a fire in Canada. We should not receive
+ * this notification.
+ */
+ @Test
+ public void withFilterNegative() throws IOException {
+ NotificatorService service = createNotificatorService();
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
+ eventSinkAddr.setValue(url);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+ subscribe.setFilter(new FilterType());
+ subscribe.getFilter().getContent().add("/*[local-name()='fire']/location[text()='Russia']");
+
+
+ eventSourceClient.subscribeOp(subscribe);
+
+ Server eventSinkServer = createEventSink(url);
+ TestingEventSinkImpl.RECEIVED_FIRES.set(0);
+
+ service.start();
+ Emitter emitter = new EmitterImpl(service);
+ emitter.dispatch(new FireEvent("Canada", 8));
+
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+
+ eventSinkServer.stop();
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() != 0) {
+ Assert.fail("TestingEventSinkImpl should have received 0 events but received "
+ + TestingEventSinkImpl.RECEIVED_FIRES.get());
+ }
+ }
+
+
+ /**
+ * We request only to receive notifications about earthquakes in Russia with Richter scale equal to 3.5
+ * and there will be one fire in Canada and one earthquake in Russia. We should
+ * receive only one notification.
+ */
+ @Test
+ public void withFilter2() throws IOException {
+ NotificatorService service = createNotificatorService();
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
+ eventSinkAddr.setValue(url);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+ subscribe.setFilter(new FilterType());
+ subscribe.getFilter().getContent()
+ .add("//*[local-name()='earthquake']/location[text()='Russia']/"
+ + "../richterScale[contains(text(),'3.5')]");
+
+ eventSourceClient.subscribeOp(subscribe);
+
+ Server eventSinkServer = createEventSink(url);
+ TestingEventSinkImpl.RECEIVED_FIRES.set(0);
+ TestingEventSinkImpl.RECEIVED_EARTHQUAKES.set(0);
+
+ service.start();
+ Emitter emitter = new EmitterImpl(service);
+ emitter.dispatch(new FireEvent("Canada", 8));
+ emitter.dispatch(new EarthquakeEvent(3.5f, "Russia"));
+ for (int i = 0; i < 10; i++) {
+ if (TestingEventSinkImpl.RECEIVED_EARTHQUAKES.get() == 1) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ eventSinkServer.stop();
+ if (TestingEventSinkImpl.RECEIVED_EARTHQUAKES.get() != 1) {
+ Assert.fail("TestingEventSinkImpl should have received 1 earthquake event but received "
+ + TestingEventSinkImpl.RECEIVED_EARTHQUAKES.get());
+ }
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() != 0) {
+ Assert.fail("TestingEventSinkImpl should have not received a fire event"
+ + TestingEventSinkImpl.RECEIVED_FIRES.get());
+ }
+ }
+
+ /**
+ * request a subscription that expires soon
+ * an event will be emitted after the expiration
+ * we should not receive notification about the event
+ * @throws IOException
+ */
+ @Test
+ public void expiration() throws IOException {
+ NotificatorService service = createNotificatorService();
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT1S")));
+ subscribe.setExpires(exp);
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String url = TestUtil.generateRandomURLWithHttpTransport(NOTIFICATION_TEST_PORT);
+ eventSinkAddr.setValue(url);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+
+ eventSourceClient.subscribeOp(subscribe);
+
+ Server eventSinkServer = createEventSink(url);
+ TestingEventSinkImpl.RECEIVED_FIRES.set(0);
+
+ service.start();
+ Emitter emitter = new EmitterImpl(service);
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ emitter.dispatch(new FireEvent("Canada", 8));
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ eventSinkServer.stop();
+ if (TestingEventSinkImpl.RECEIVED_FIRES.get() != 0) {
+ Assert.fail("TestingEventSinkImpl should not have received any events but received "
+ + TestingEventSinkImpl.RECEIVED_FIRES.get());
+ }
+ }
+
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionEndTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionEndTest.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionEndTest.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionEndTest.java Sat May 18 12:17:39 2013
@@ -0,0 +1,109 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration;
+
+
+import java.io.IOException;
+import java.util.UUID;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.ws.eventing.AttributedURIType;
+import org.apache.cxf.ws.eventing.DeliveryType;
+import org.apache.cxf.ws.eventing.EndpointReferenceType;
+import org.apache.cxf.ws.eventing.NotifyTo;
+import org.apache.cxf.ws.eventing.ReferenceParametersType;
+import org.apache.cxf.ws.eventing.Subscribe;
+import org.apache.cxf.ws.eventing.SubscribeResponse;
+import org.apache.cxf.ws.eventing.backend.notification.NotificatorService;
+import org.apache.cxf.ws.eventing.backend.notification.SubscriptionEndStatus;
+import org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest;
+import org.apache.cxf.ws.eventing.base.TestUtil;
+import org.apache.cxf.ws.eventing.base.aux.SingletonSubscriptionManagerContainer;
+import org.apache.cxf.ws.eventing.integration.eventsink.TestingEndToEndpointImpl;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SubscriptionEndTest extends SimpleEventingIntegrationTest {
+
+ @Test
+ public void doTest() throws IOException {
+ NotificatorService service = createNotificatorService();
+ service.start();
+
+ Subscribe subscribe = new Subscribe();
+
+ EndpointReferenceType eventSinkERT = new EndpointReferenceType();
+ AttributedURIType eventSinkAddr = new AttributedURIType();
+ String eventSinkURL = TestUtil.generateRandomURLWithLocalTransport();
+ eventSinkAddr.setValue(eventSinkURL);
+ eventSinkERT.setAddress(eventSinkAddr);
+ subscribe.setDelivery(new DeliveryType());
+ subscribe.getDelivery().getContent().add(new NotifyTo());
+ ((NotifyTo)subscribe.getDelivery().getContent().get(0)).setValue(eventSinkERT);
+
+ JAXBElement idqn = new JAXBElement(new QName("http://www.example.org", "MyReferenceParameter"),
+ String.class,
+ "380");
+ ReferenceParametersType myParams = new ReferenceParametersType();
+ myParams.getAny().add(idqn);
+ eventSinkERT.setReferenceParameters(myParams);
+
+ EndpointReferenceType endToERT = new EndpointReferenceType();
+ AttributedURIType endToAddr = new AttributedURIType();
+ String endToURL = TestUtil.generateRandomURLWithLocalTransport();
+ endToAddr.setValue(endToURL);
+ endToERT.setAddress(endToAddr);
+ subscribe.setEndTo(endToERT);
+
+ SubscribeResponse response = eventSourceClient.subscribeOp(subscribe);
+ Element referenceParams = (Element)response.getSubscriptionManager()
+ .getReferenceParameters().getAny().get(0);
+
+ Server endToEndpoint = createEndToEndpointWithReferenceParametersAssertion(endToURL, myParams);
+
+ TestingEndToEndpointImpl.RECEIVED_ENDS.set(0);
+
+ SingletonSubscriptionManagerContainer.getInstance()
+ .subscriptionEnd(UUID.fromString(referenceParams.getTextContent()), "Sorry, "
+ + "but we don't like you anymore",
+ SubscriptionEndStatus.SOURCE_CANCELLING);
+
+ for (int i = 0; i < 10; i++) {
+ if (TestingEndToEndpointImpl.RECEIVED_ENDS.get() == 1) {
+ break;
+ }
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException ex) {
+ ex.printStackTrace();
+ }
+ }
+ endToEndpoint.stop();
+ if (TestingEndToEndpointImpl.RECEIVED_ENDS.get() != 1) {
+ Assert.fail("TestingEndToEndpointImpl should have received 1 subscription end notification but received "
+ + TestingEndToEndpointImpl.RECEIVED_ENDS.get());
+ }
+ }
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionGrantingTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionGrantingTest.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionGrantingTest.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionGrantingTest.java Sat May 18 12:17:39 2013
@@ -0,0 +1,172 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration;
+
+import java.io.IOException;
+import javax.xml.datatype.XMLGregorianCalendar;
+import javax.xml.ws.soap.SOAPFaultException;
+
+import org.apache.cxf.ws.eventing.DeliveryType;
+import org.apache.cxf.ws.eventing.ExpirationType;
+import org.apache.cxf.ws.eventing.FilterType;
+import org.apache.cxf.ws.eventing.Subscribe;
+import org.apache.cxf.ws.eventing.SubscribeResponse;
+import org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest;
+import org.apache.cxf.ws.eventing.shared.faults.CannotProcessFilter;
+import org.apache.cxf.ws.eventing.shared.faults.NoDeliveryMechanismEstablished;
+import org.apache.cxf.ws.eventing.shared.utils.DurationAndDateUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class SubscriptionGrantingTest extends SimpleEventingIntegrationTest {
+
+/* *//**
+ * specification:
+ * The expiration time MAY be either a specific time or a duration but MUST
+ * be of the same type as the wse:Expires element of the corresponding request.
+ * If the corresponding request did not contain a wse:Expires element, this
+ * element MUST be a duration (xs:duration).
+ *
+ * @throws IOException
+ */
+ @Test
+ public void testExpirationGrantingWithoutBestEffort() throws IOException {
+ // we specify a xs:duration
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+ DeliveryType delivery = new DeliveryType();
+ subscribe.setDelivery(delivery);
+
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+
+ SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
+ Assert.assertTrue(
+ "Specification requires that EventSource return a xs:duration "
+ + "expirationType if a xs:duration was requested by client",
+ DurationAndDateUtil.isDuration(resp.getGrantedExpires().getValue()));
+
+ // we specify a xs:dateTime
+ subscribe = new Subscribe();
+ exp = new ExpirationType();
+ XMLGregorianCalendar dateRequest =
+ (XMLGregorianCalendar)DurationAndDateUtil.parseDurationOrTimestamp("2138-06-26T12:23:12.000-01:00");
+ exp.setValue(DurationAndDateUtil.convertToXMLString(dateRequest));
+ subscribe.setExpires(exp);
+ delivery = new DeliveryType();
+ subscribe.setDelivery(delivery);
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+ resp = eventSourceClient.subscribeOp(subscribe);
+ Assert.assertTrue(
+ "Specification requires that EventSource return a "
+ + "xs:dateTime expirationType if a xs:dateTime was requested by client",
+ DurationAndDateUtil.isXMLGregorianCalendar(resp.getGrantedExpires().getValue()));
+ XMLGregorianCalendar returned = DurationAndDateUtil.parseXMLGregorianCalendar(
+ resp.getGrantedExpires().getValue());
+ System.out.println("granted expiration: " + returned.normalize().toXMLFormat());
+ System.out.println("requested expiration: " + dateRequest.normalize().toXMLFormat());
+ Assert.assertTrue("Server should have returned exactly the same date as we requested",
+ returned.equals(dateRequest));
+
+ // we don't specify anything
+ subscribe = new Subscribe();
+ delivery = new DeliveryType();
+ subscribe.setDelivery(delivery);
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+ resp = eventSourceClient.subscribeOp(subscribe);
+ Assert.assertTrue(
+ "Specification requires that EventSource return a xs:duration "
+ + "expirationType if no specific expirationType was requested by client",
+ DurationAndDateUtil.isDuration(resp.getGrantedExpires().getValue()));
+ }
+
+ /**
+ * When BestEffort=true, the server doesn't have to grant exactly the date as we requested
+ * @throws IOException
+ */
+ @Test
+ public void testExpirationGrantingWithBestEffort() throws IOException {
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ DeliveryType delivery = new DeliveryType();
+ XMLGregorianCalendar dateRequest =
+ (XMLGregorianCalendar)DurationAndDateUtil.parseDurationOrTimestamp("2138-06-26T12:23:12.000-01:00");
+ exp.setValue(DurationAndDateUtil.convertToXMLString(dateRequest));
+ exp.setBestEffort(true);
+ subscribe.setExpires(exp);
+ subscribe.setDelivery(delivery);
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+ SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
+ Assert.assertTrue(
+ "Specification requires that EventSource return a "
+ + "xs:dateTime expirationType if a xs:dateTime was requested by client",
+ DurationAndDateUtil.isXMLGregorianCalendar(resp.getGrantedExpires().getValue()));
+ }
+
+ @Test
+ public void noDeliveryMechanismSpecified() throws IOException {
+ // we specify a xs:duration
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+ try {
+ eventSourceClient.subscribeOp(subscribe);
+ } catch (SOAPFaultException ex) {
+ Assert.assertTrue(ex.getFault().getFaultCode().contains(NoDeliveryMechanismEstablished.LOCAL_PART));
+ Assert.assertTrue(ex.getFault().getTextContent().contains(NoDeliveryMechanismEstablished.REASON));
+ return;
+ }
+ Assert.fail("Event source should have sent a NoDeliveryMechanismEstablished fault");
+ }
+
+ @Test
+ public void cannotProcessFilter() throws IOException {
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ DeliveryType delivery = new DeliveryType();
+ XMLGregorianCalendar dateRequest =
+ (XMLGregorianCalendar)DurationAndDateUtil.parseDurationOrTimestamp("2138-06-26T12:23:12.000-01:00");
+ exp.setValue(DurationAndDateUtil.convertToXMLString(dateRequest));
+ exp.setBestEffort(true);
+ subscribe.setExpires(exp);
+ subscribe.setDelivery(delivery);
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+
+
+ subscribe.setFilter(new FilterType());
+ subscribe.getFilter().getContent()
+ .add("@^5this-is-not-a-valid-xpath-expression!!!*-/");
+
+ try {
+ eventSourceClient.subscribeOp(subscribe);
+ } catch (SOAPFaultException ex) {
+ Assert.assertTrue(ex.getFault().getFaultCode().contains(CannotProcessFilter.LOCAL_PART));
+ Assert.assertTrue(ex.getFault().getTextContent().contains(CannotProcessFilter.REASON));
+ return;
+ }
+ Assert.fail("Event source should have sent a CannotProcessFilter fault");
+ }
+
+}
+
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionManagementTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionManagementTest.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionManagementTest.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/SubscriptionManagementTest.java Sat May 18 12:17:39 2013
@@ -0,0 +1,182 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration;
+
+import java.io.IOException;
+
+import org.apache.cxf.ws.eventing.DeliveryType;
+import org.apache.cxf.ws.eventing.ExpirationType;
+import org.apache.cxf.ws.eventing.GetStatus;
+import org.apache.cxf.ws.eventing.GetStatusResponse;
+import org.apache.cxf.ws.eventing.Renew;
+import org.apache.cxf.ws.eventing.Subscribe;
+import org.apache.cxf.ws.eventing.SubscribeResponse;
+import org.apache.cxf.ws.eventing.Unsubscribe;
+import org.apache.cxf.ws.eventing.UnsubscribeResponse;
+import org.apache.cxf.ws.eventing.base.SimpleEventingIntegrationTest;
+import org.apache.cxf.ws.eventing.manager.SubscriptionManagerEndpoint;
+import org.apache.cxf.ws.eventing.shared.faults.UnknownSubscription;
+import org.apache.cxf.ws.eventing.shared.utils.DurationAndDateUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+
+/**
+ * Tests to verify that a Subscription Manager can be properly used to manage existing subscriptions.
+ * Typically, such test will create a subscription using the Event Source and then invoke
+ * possible operations on the Subscription Manager to manage it.
+ */
+public class SubscriptionManagementTest extends SimpleEventingIntegrationTest {
+
+ /**
+ * Creates a subscription and then retrieves its status from the Subscription Manager.
+ */
+ @Test
+ public void getStatus() throws Exception {
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+ DeliveryType delivery = new DeliveryType();
+ subscribe.setDelivery(delivery);
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+ SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
+
+ SubscriptionManagerEndpoint client = createSubscriptionManagerClient(
+ resp.getSubscriptionManager().getReferenceParameters());
+ GetStatusResponse response = client.getStatusOp(new GetStatus());
+ System.out.println("EXPIRES: " + response.getGrantedExpires().getValue());
+ Assert.assertTrue("GetStatus operation should return a XMLGregorianCalendar",
+ DurationAndDateUtil.isXMLGregorianCalendar(response.getGrantedExpires().getValue()));
+ }
+
+ /**
+ * Tries to create a subscription, then cancel it, then obtain its status.
+ * The last mentioned operation should fail.
+ */
+ @Test
+ public void unsubscribeAndThenGetStatus() throws Exception {
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(
+ DurationAndDateUtil.convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT0S")));
+ subscribe.setExpires(exp);
+ DeliveryType delivery = new DeliveryType();
+ subscribe.setDelivery(delivery);
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+ SubscribeResponse subscribeResponse = eventSourceClient.subscribeOp(subscribe);
+
+ SubscriptionManagerEndpoint client = createSubscriptionManagerClient(
+ subscribeResponse.getSubscriptionManager().getReferenceParameters());
+ UnsubscribeResponse unsubscribeResponse = client.unsubscribeOp(new Unsubscribe());
+ Assert.assertNotNull(unsubscribeResponse);
+
+ try {
+ client.getStatusOp(new GetStatus());
+ } catch (javax.xml.ws.soap.SOAPFaultException ex) {
+ Assert.assertTrue(ex.getFault().getFaultCode().contains(UnknownSubscription.LOCAL_PART));
+ Assert.assertTrue(ex.getFault().getTextContent().contains(UnknownSubscription.REASON));
+ return;
+ }
+ Assert.fail(
+ "The subscription manager should have refused to send status of a cancelled subscription");
+ }
+
+
+ /**
+ * Tests the Renew operation, while specifying an xs:dateTime in the renew request,
+ * eg. the subscriber requests to set the subscription expiration to a specific date/time.
+ */
+ @Test
+ public void renewWithDateTime() throws IOException {
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(DurationAndDateUtil
+ .convertToXMLString(DurationAndDateUtil
+ .parseDurationOrTimestamp("2018-10-21T14:52:46.826+02:00"))); // 5 minutes
+ subscribe.setExpires(exp);
+ DeliveryType delivery = new DeliveryType();
+ subscribe.setDelivery(delivery);
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+ SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
+
+ SubscriptionManagerEndpoint client = createSubscriptionManagerClient(
+ resp.getSubscriptionManager().getReferenceParameters());
+ GetStatusResponse response = client.getStatusOp(new GetStatus());
+ String expirationBefore = response.getGrantedExpires().getValue();
+ System.out.println("EXPIRES before renew: " + expirationBefore);
+ Assert.assertTrue(expirationBefore.length() > 0);
+
+ Renew renewRequest = new Renew();
+ ExpirationType renewExp = new ExpirationType();
+ renewExp.setValue(DurationAndDateUtil
+ .convertToXMLString(DurationAndDateUtil.
+ parseDurationOrTimestamp("2056-10-21T14:54:46.826+02:00"))); // 10 minutes
+ renewRequest.setExpires(renewExp);
+ client.renewOp(renewRequest);
+ response = client.getStatusOp(new GetStatus());
+ String expirationAfter = response.getGrantedExpires().getValue();
+ System.out.println("EXPIRES after renew: " + expirationAfter);
+
+ Assert.assertFalse("Renew request should change the expiration time at least a bit",
+ expirationAfter.equals(expirationBefore));
+ }
+
+ /**
+ * Tests the Renew operation, while specifying an xs:duration in the renew request,
+ * eg. the subscriber requests to prolong the subscription by a specific amount of time.
+ */
+ @Test
+ public void renewWithDuration() throws IOException {
+ Subscribe subscribe = new Subscribe();
+ ExpirationType exp = new ExpirationType();
+ exp.setValue(DurationAndDateUtil
+ .convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT5M0S"))); // 5 minutes
+ subscribe.setExpires(exp);
+ DeliveryType delivery = new DeliveryType();
+ subscribe.setDelivery(delivery);
+ subscribe.getDelivery().getContent().add(createDummyNotifyTo());
+ SubscribeResponse resp = eventSourceClient.subscribeOp(subscribe);
+
+ SubscriptionManagerEndpoint client = createSubscriptionManagerClient(
+ resp.getSubscriptionManager().getReferenceParameters());
+ GetStatusResponse response = client.getStatusOp(new GetStatus());
+ String expirationBefore = response.getGrantedExpires().getValue();
+ System.out.println("EXPIRES before renew: " + expirationBefore);
+ Assert.assertTrue(expirationBefore.length() > 0);
+
+ Renew renewRequest = new Renew();
+ ExpirationType renewExp = new ExpirationType();
+ renewExp.setValue(DurationAndDateUtil
+ .convertToXMLString(DurationAndDateUtil.parseDurationOrTimestamp("PT10M0S"))); // 10 minutes
+ renewRequest.setExpires(renewExp);
+ client.renewOp(renewRequest);
+ response = client.getStatusOp(new GetStatus());
+ String expirationAfter = response.getGrantedExpires().getValue();
+ System.out.println("EXPIRES after renew: " + expirationAfter);
+
+ Assert.assertFalse("Renew request should change the expiration time at least a bit",
+ expirationAfter.equals(expirationBefore));
+ }
+
+
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingEndToEndpointImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingEndToEndpointImpl.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingEndToEndpointImpl.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingEndToEndpointImpl.java Sat May 18 12:17:39 2013
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.eventsink;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Logger;
+import javax.jws.WebParam;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.ws.eventing.SubscriptionEnd;
+import org.apache.cxf.ws.eventing.client.EndToEndpoint;
+
+public class TestingEndToEndpointImpl implements EndToEndpoint {
+
+ public static final AtomicInteger RECEIVED_ENDS = new AtomicInteger(0);
+
+ protected static final Logger LOG = LogUtils.getLogger(TestingEndToEndpointImpl.class);
+
+
+ @Override
+ public void subscriptionEnd(@WebParam SubscriptionEnd subscriptionEnd) {
+ LOG.info("Received subscription end: " + subscriptionEnd.getStatus());
+ RECEIVED_ENDS.incrementAndGet();
+ }
+
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingEventSinkImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingEventSinkImpl.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingEventSinkImpl.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingEventSinkImpl.java Sat May 18 12:17:39 2013
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.eventsink;
+
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.logging.Logger;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.ws.eventing.integration.notificationapi.CatastrophicEventSink;
+import org.apache.cxf.ws.eventing.integration.notificationapi.EarthquakeEvent;
+import org.apache.cxf.ws.eventing.integration.notificationapi.FireEvent;
+
+public class TestingEventSinkImpl implements CatastrophicEventSink {
+
+ public static final AtomicInteger RECEIVED_EARTHQUAKES = new AtomicInteger(0);
+ public static final AtomicInteger RECEIVED_FIRES = new AtomicInteger(0);
+
+ protected static final Logger LOG = LogUtils.getLogger(TestingEventSinkImpl.class);
+
+
+ @Override
+ public void earthquake(EarthquakeEvent ev) {
+ LOG.info("Event sink received an event: " + ev.toString());
+ RECEIVED_EARTHQUAKES.incrementAndGet();
+ }
+
+ @Override
+ public void fire(FireEvent ev) {
+ LOG.info("Event sink received an event: " + ev.toString());
+ RECEIVED_FIRES.incrementAndGet();
+ }
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingWrappedEventSinkImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingWrappedEventSinkImpl.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingWrappedEventSinkImpl.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/eventsink/TestingWrappedEventSinkImpl.java Sat May 18 12:17:39 2013
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.eventsink;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+
+import org.w3c.dom.Node;
+
+import org.apache.cxf.ws.eventing.EventType;
+import org.apache.cxf.ws.eventing.backend.notification.WrappedSink;
+import org.apache.cxf.ws.eventing.integration.notificationapi.EarthquakeEvent;
+import org.apache.cxf.ws.eventing.integration.notificationapi.FireEvent;
+
+public class TestingWrappedEventSinkImpl implements WrappedSink {
+
+ public static final AtomicInteger RECEIVED_EARTHQUAKES = new AtomicInteger(0);
+ public static final AtomicInteger RECEIVED_FIRES = new AtomicInteger(0);
+
+ private static JAXBContext jaxbContext;
+ static {
+ try {
+ jaxbContext = JAXBContext.newInstance(FireEvent.class, EarthquakeEvent.class);
+ } catch (Exception e) {
+ //ignore
+ }
+ }
+
+ @Override
+ public void notifyEvent(EventType parameter) {
+ if (parameter != null) {
+ for (Object obj : parameter.getContent()) {
+ try {
+ Object event = jaxbContext.createUnmarshaller().unmarshal((Node)obj);
+ if (event instanceof FireEvent) {
+ RECEIVED_FIRES.incrementAndGet();
+ } else if (event instanceof EarthquakeEvent) {
+ RECEIVED_EARTHQUAKES.incrementAndGet();
+ }
+ } catch (JAXBException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ }
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/CatastrophicEventSink.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/CatastrophicEventSink.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/CatastrophicEventSink.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/CatastrophicEventSink.java Sat May 18 12:17:39 2013
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.notificationapi;
+
+import javax.jws.Oneway;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.Action;
+import javax.xml.ws.soap.Addressing;
+
+
+@WebService(targetNamespace = "http://www.events.com")
+@Addressing(enabled = true, required = true)
+@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
+public interface CatastrophicEventSink {
+
+ @Oneway
+ @Action(input = "http://www.earthquake.com")
+ void earthquake(@WebParam(name = "earthquake") EarthquakeEvent ev);
+
+ @Oneway
+ @Action(input = "http://www.fire.com")
+ void fire(@WebParam(name = "fire") FireEvent ev);
+
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/CatastrophicEventSinkWrapped.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/CatastrophicEventSinkWrapped.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/CatastrophicEventSinkWrapped.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/CatastrophicEventSinkWrapped.java Sat May 18 12:17:39 2013
@@ -0,0 +1,44 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.notificationapi;
+
+import javax.jws.WebParam;
+import javax.jws.WebService;
+import javax.jws.soap.SOAPBinding;
+import javax.xml.ws.Action;
+import javax.xml.ws.RequestWrapper;
+import javax.xml.ws.soap.Addressing;
+
+import org.apache.cxf.ws.eventing.shared.EventingConstants;
+
+@WebService
+@Addressing(enabled = true, required = true)
+@SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
+public interface CatastrophicEventSinkWrapped {
+
+ @Action(input = "http://www.earthquake.com")
+ @RequestWrapper(localName = "NotifyEvent", targetNamespace = EventingConstants.EVENTING_2011_03_NAMESPACE)
+ void earthquake(@WebParam(name = "earthquake") EarthquakeEvent ev);
+
+ @Action(input = "http://www.fire.com")
+ @RequestWrapper(localName = "NotifyEvent2", targetNamespace = EventingConstants.EVENTING_2011_03_NAMESPACE)
+ void fire(@WebParam(name = "fire") FireEvent ev);
+
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/EarthquakeEvent.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/EarthquakeEvent.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/EarthquakeEvent.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/EarthquakeEvent.java Sat May 18 12:17:39 2013
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.notificationapi;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "earthquakeEvent", namespace = "http://www.example.com/earthquake/event")
+public class EarthquakeEvent {
+
+ private String location;
+ private float richterScale;
+
+ public EarthquakeEvent() {
+
+ }
+
+ public EarthquakeEvent(float richterScale, String location) {
+ this.richterScale = richterScale;
+ this.location = location;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public float getRichterScale() {
+ return richterScale;
+ }
+
+ public void setRichterScale(float richterScale) {
+ this.richterScale = richterScale;
+ }
+
+ @Override
+ public String toString() {
+ return "EarthquakeEvent{"
+ + "location='" + location + '\''
+ + ", richterScale=" + richterScale
+ + '}';
+ }
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/FireEvent.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/FireEvent.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/FireEvent.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/FireEvent.java Sat May 18 12:17:39 2013
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.notificationapi;
+
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "fireEvent", namespace = "http://www.example.com/fire/event")
+public class FireEvent {
+
+ private String location;
+ private int severity;
+
+
+ public FireEvent() {
+ }
+
+ public FireEvent(String location, int severity) {
+ this.location = location;
+ this.severity = severity;
+ }
+
+ public String getLocation() {
+ return location;
+ }
+
+ public void setLocation(String location) {
+ this.location = location;
+ }
+
+ public int getSeverity() {
+ return severity;
+ }
+
+ public void setSeverity(int severity) {
+ this.severity = severity;
+ }
+
+ @Override
+ public String toString() {
+ return "FireEvent{"
+ + "location='" + location + '\''
+ + ", severity=" + severity
+ + '}';
+ }
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/assertions/ReferenceParametersAssertingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/assertions/ReferenceParametersAssertingHandler.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/assertions/ReferenceParametersAssertingHandler.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/assertions/ReferenceParametersAssertingHandler.java Sat May 18 12:17:39 2013
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.notificationapi.assertions;
+
+import java.util.Iterator;
+import java.util.Set;
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.w3c.dom.Element;
+
+import org.apache.cxf.ws.eventing.ReferenceParametersType;
+
+public class ReferenceParametersAssertingHandler implements SOAPHandler<SOAPMessageContext> {
+
+ private ReferenceParametersType params;
+
+ public ReferenceParametersAssertingHandler(ReferenceParametersType params) {
+ this.params = params;
+ }
+
+ @Override
+ public Set<QName> getHeaders() {
+ return null;
+ }
+
+ @Override
+ public boolean handleMessage(SOAPMessageContext context) {
+ if ((Boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
+ return true;
+ }
+ if (params == null) {
+ return true;
+ }
+ try {
+ // every element in the ReferenceParametersType should be present somewhere in the headers
+ for (Object exp : params.getAny()) {
+ JAXBElement expectedElement = (JAXBElement)exp;
+ boolean found = false;
+ Iterator i = context.getMessage().getSOAPHeader().examineAllHeaderElements();
+ while (i.hasNext()) {
+ Element actualHeaderelement = (Element)i.next();
+ if (expectedElement.getName().getLocalPart().equals(actualHeaderelement.getLocalName())
+ && expectedElement.getName().getNamespaceURI()
+ .equals(actualHeaderelement.getNamespaceURI())) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw new RuntimeException("Event sink should have received Reference parameter: "
+ + expectedElement.getName());
+ }
+ }
+ } catch (SOAPException e) {
+ throw new RuntimeException(e);
+ }
+ return true;
+ }
+
+ @Override
+ public boolean handleFault(SOAPMessageContext context) {
+ return true;
+ }
+
+ @Override
+ public void close(MessageContext context) {
+ }
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/assertions/WSAActionAssertingHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/assertions/WSAActionAssertingHandler.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/assertions/WSAActionAssertingHandler.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/integration/notificationapi/assertions/WSAActionAssertingHandler.java Sat May 18 12:17:39 2013
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.integration.notificationapi.assertions;
+
+import java.util.Iterator;
+import java.util.Set;
+import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPException;
+import javax.xml.ws.handler.MessageContext;
+import javax.xml.ws.handler.soap.SOAPHandler;
+import javax.xml.ws.handler.soap.SOAPMessageContext;
+
+import org.w3c.dom.Element;
+
+/**
+ * Handler that asserts a particular value of WS-Addressing Action in the headers
+ * of an incoming message. Used only for testing.
+ */
+public class WSAActionAssertingHandler implements SOAPHandler<SOAPMessageContext> {
+
+ /**
+ * The action which we expect to be set for incoming events into an event sink
+ * which uses this handler.
+ */
+ private String action;
+
+ public WSAActionAssertingHandler(String action) {
+ this.action = action;
+ }
+
+ @Override
+ public Set<QName> getHeaders() {
+ return null;
+ }
+
+ @Override
+ public boolean handleMessage(SOAPMessageContext context) {
+ // only inbound messages are of use
+ if ((Boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) {
+ return true;
+ }
+ try {
+ Iterator i = context.getMessage().getSOAPHeader().examineAllHeaderElements();
+ Object header;
+ while (i.hasNext()) {
+ header = i.next();
+ Element elm = (Element)header;
+ if (elm.getTagName().equals("Action") && elm.getNamespaceURI().contains("addressing")) {
+ if (!elm.getTextContent().equals(action)) {
+ throw new RuntimeException("The event sink should have received "
+ + "WSA-Action: " + action + " but received: "
+ + elm.getTextContent());
+ }
+ return true;
+ }
+ }
+ } catch (SOAPException e) {
+ throw new RuntimeException(e);
+ }
+ throw new RuntimeException("The event sink should have received a WSA-Action associated with"
+ + "the notification");
+ }
+
+ @Override
+ public boolean handleFault(SOAPMessageContext context) {
+ return true;
+ }
+
+ @Override
+ public void close(MessageContext context) {
+ }
+
+}
Added: cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/misc/FilterEvaluationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/misc/FilterEvaluationTest.java?rev=1484099&view=auto
==============================================================================
--- cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/misc/FilterEvaluationTest.java (added)
+++ cxf/trunk/rt/ws/eventing/src/test/java/org/apache/cxf/ws/eventing/misc/FilterEvaluationTest.java Sat May 18 12:17:39 2013
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.ws.eventing.misc;
+
+import java.io.CharArrayReader;
+import java.io.Reader;
+
+import org.w3c.dom.Document;
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.ws.eventing.FilterType;
+import org.apache.cxf.ws.eventing.shared.utils.FilteringUtil;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class FilterEvaluationTest {
+
+ @Test
+ public void simpleFilterEvaluationPositive() throws Exception {
+ Reader reader = new CharArrayReader("<tt><in>1</in></tt>".toCharArray());
+ Document doc = DOMUtils.readXml(reader);
+ FilterType filter = new FilterType();
+ filter.getContent().add("//tt");
+ Assert.assertTrue(FilteringUtil.doesConformToFilter(doc.getDocumentElement(), filter));
+ }
+
+ @Test
+ public void simpleFilterEvaluationNegative() throws Exception {
+ Reader reader = new CharArrayReader("<tt><in>1</in></tt>".toCharArray());
+ Document doc = DOMUtils.readXml(reader);
+ FilterType filter = new FilterType();
+ filter.getContent().add("//ttx");
+ Assert.assertFalse(FilteringUtil.doesConformToFilter(doc.getDocumentElement(), filter));
+ }
+
+ @Test
+ public void validFilter() throws Exception {
+ Assert.assertTrue(FilteringUtil.isValidFilter("//filter"));
+ }
+
+ @Test
+ public void invalidFilter() throws Exception {
+ Assert.assertFalse(FilteringUtil.isValidFilter("@/$"));
+ }
+
+}