use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetQNameTest method qetEmptyResultTest.
@Test
public void qetEmptyResultTest() throws XMLStreamException {
String content = "<root><a><b>Text</b></a></root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.QNAME_LANGUAGE_IRI);
expression.getContent().add("c");
request.getAny().add(objectFactory.createExpression(expression));
GetResponse response = client.get(request);
ValueType value = getValue(response);
Assert.assertEquals(0, value.getContent().size());
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetXPath10Test method getTest.
@Test
public void getTest() throws XMLStreamException {
String content = "<root><a><b>Text</b></a></root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.getContent().add("/root/a/b");
request.getAny().add(objectFactory.createExpression(expression));
GetResponse response = client.get(request);
ValueType value = getValue(response);
Assert.assertEquals(1, value.getContent().size());
Assert.assertEquals("b", ((Element) value.getContent().get(0)).getLocalName());
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class FragmentGetXPath10Test method getNumberTest.
@Test
public void getNumberTest() throws XMLStreamException {
String content = "<root><a><b>Text</b><b>Text2</b></a></root>";
ResourceManager resourceManager = new MemoryResourceManager();
ReferenceParametersType refParams = resourceManager.create(getRepresentation(content));
Server resource = createLocalResource(resourceManager);
Resource client = createClient(refParams);
ObjectFactory objectFactory = new ObjectFactory();
Get request = new Get();
request.setDialect(FragmentDialectConstants.FRAGMENT_2011_03_IRI);
ExpressionType expression = new ExpressionType();
expression.setLanguage(FragmentDialectConstants.XPATH10_LANGUAGE_IRI);
expression.getContent().add("count(//b)");
request.getAny().add(objectFactory.createExpression(expression));
GetResponse response = client.get(request);
ValueType value = getValue(response);
Assert.assertEquals(1, value.getContent().size());
Assert.assertEquals("2", value.getContent().get(0));
resource.destroy();
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class MAPTestBase method setUp.
@Before
public void setUp() throws Exception {
if (staticBus == null) {
SpringBusFactory bf = new SpringBusFactory();
staticBus = bf.createBus(getConfigFileName());
BusFactory.setDefaultBus(staticBus);
}
messageIDs.clear();
mapVerifier = new MAPVerifier();
headerVerifier = new HeaderVerifier();
Interceptor<?>[] interceptors = { mapVerifier, headerVerifier };
addInterceptors(staticBus.getInInterceptors(), interceptors);
addInterceptors(staticBus.getOutInterceptors(), interceptors);
addInterceptors(staticBus.getOutFaultInterceptors(), interceptors);
addInterceptors(staticBus.getInFaultInterceptors(), interceptors);
EndpointReferenceType target = EndpointReferenceUtils.getEndpointReference(getAddress());
ReferenceParametersType params = ContextUtils.WSA_OBJECT_FACTORY.createReferenceParametersType();
JAXBElement<String> param = new JAXBElement<String>(CUSTOMER_NAME, String.class, CUSTOMER_KEY);
params.getAny().add(param);
target.setReferenceParameters(params);
greeter = createGreeter(target);
mapVerifier.verificationCache = this;
headerVerifier.verificationCache = this;
}
use of org.apache.cxf.ws.addressing.ReferenceParametersType in project cxf by apache.
the class NotificationTest method withReferenceParameters.
@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<String> idqn = new JAXBElement<String>(new QName("http://www.example.org", "MyReferenceParameter"), String.class, "380");
JAXBElement<String> idqn2 = new JAXBElement<String>(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 ObjectFactory().createNotifyTo(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);
}
}
Aggregations