use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class SubscriptionEndTest method doTest.
@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 ObjectFactory().createNotifyTo(eventSinkERT));
JAXBElement<String> idqn = new JAXBElement<String>(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());
}
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentPutAddTest method addSiblingTest.
@Test
public void addSiblingTest() throws XMLStreamException {
String content = "<a><b/></a>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
expression.getContent().add("/a");
Element addedElement = DOMUtils.getEmptyDocument().createElement("c");
ValueType value = new ValueType();
value.getContent().add(addedElement);
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Element child0 = (Element) rootEl.getChildNodes().item(0);
Element child1 = (Element) rootEl.getChildNodes().item(1);
Assert.assertEquals("a", rootEl.getNodeName());
Assert.assertEquals("b", child0.getNodeName());
Assert.assertEquals("c", child1.getNodeName());
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentPutAddTest method addToEmptyDocumentTest.
@Test
public void addToEmptyDocumentTest() {
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(new Representation());
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
expression.getContent().add("/");
Element addedElement = DOMUtils.getEmptyDocument().createElement("a");
ValueType value = new ValueType();
value.getContent().add(addedElement);
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals("a", rootEl.getNodeName());
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentPutAddTest method addToNonEmptyDocumentTest.
@Test(expected = SOAPFaultException.class)
public void addToNonEmptyDocumentTest() throws XMLStreamException {
String content = "<a/>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
expression.getContent().add("/");
Element addedElement = DOMUtils.getEmptyDocument().createElement("b");
ValueType value = new ValueType();
value.getContent().add(addedElement);
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
client.put(request);
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentPutAddTest method addTextElementTest.
@Test
public void addTextElementTest() throws XMLStreamException {
String content = "<a>f</a>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
Put request = new Put();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
Fragment fragment = new Fragment();
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.setMode(FragmentDialectConstants.FRAGMENT_MODE_ADD);
expression.getContent().add("/a");
ValueType value = new ValueType();
value.getContent().add("oo");
fragment.setExpression(expression);
fragment.setValue(value);
request.getAny().add(fragment);
PutResponse response = client.put(request);
Element rootEl = (Element) response.getRepresentation().getAny();
Assert.assertEquals("foo", rootEl.getTextContent());
resource.destroy();
}
Aggregations