use of com.sun.xml.ws.api.pipe.TransportTubeFactory in project metro-jax-ws by eclipse-ee4j.
the class SDODatabindingTestBase method invmSetup.
protected WebServiceFeature[] invmSetup(final URL wsdlURL, final Class sei, final Class seb, final QName serviceName, final QName portName) {
DatabindingModeFeature dbmf = new DatabindingModeFeature("eclipselink.sdo");
Class implementorClass = seb;
boolean handlersSetInDD = false;
Container container = Container.NONE;
Map<String, SDDocumentSource> docs = new HashMap<String, SDDocumentSource>();
SDDocumentSource primaryWSDL = SDDocumentSource.create(wsdlURL);
docs.put(wsdlURL.toString(), primaryWSDL);
ExternalMetadataFeature exm = ExternalMetadataFeature.builder().setReader(new com.sun.xml.ws.model.ReflectAnnotationReader() {
public <A extends Annotation> A getAnnotation(final Class<A> annType, final Class<?> cls) {
if (WebService.class.equals(annType)) {
final WebService ws = cls.getAnnotation(WebService.class);
return (A) new jakarta.jws.WebService() {
public Class<? extends Annotation> annotationType() {
return WebService.class;
}
@Override
public String endpointInterface() {
return sei.getName();
}
@Override
public String name() {
return (ws != null) ? ws.name() : null;
}
@Override
public String portName() {
return (ws != null) ? ws.portName() : null;
}
@Override
public String serviceName() {
return (ws != null) ? ws.serviceName() : null;
}
@Override
public String targetNamespace() {
return (ws != null) ? ws.targetNamespace() : null;
}
@Override
public String wsdlLocation() {
return (ws != null) ? ws.wsdlLocation() : null;
}
};
}
return cls.getAnnotation(annType);
}
}).build();
BindingID bindingID = BindingID.parse(implementorClass);
WSBinding binding = bindingID.createBinding(dbmf, exm);
final WSEndpoint<?> endpoint = WSEndpoint.create(implementorClass, !handlersSetInDD, null, serviceName, portName, container, binding, primaryWSDL, docs.values(), XmlUtil.createEntityResolver(null), false);
ComponentFeature cf = new ComponentFeature(new com.sun.xml.ws.api.Component() {
public <S> S getSPI(Class<S> spiType) {
if (TransportTubeFactory.class.equals(spiType))
return (S) new TransportTubeFactory() {
public Tube doCreate(ClientTubeAssemblerContext context) {
return new InVmTransportTube(context.getCodec(), context.getBinding(), wsdlURL, endpoint);
}
};
return null;
}
});
WebServiceFeature[] f = { dbmf, cf };
return f;
}
use of com.sun.xml.ws.api.pipe.TransportTubeFactory in project metro-jax-ws by eclipse-ee4j.
the class ClientProxyTest method testNullResponseFromTube.
@SuppressWarnings("unchecked")
public void testNullResponseFromTube() throws Exception {
URL wsdlURL = Thread.currentThread().getContextClassLoader().getResource("etc/EchoService.wsdl");
EchoService srv = new EchoService(wsdlURL, new ComponentFeature(new com.sun.xml.ws.api.Component() {
public <S> S getSPI(Class<S> spiType) {
if (TransportTubeFactory.class.equals(spiType))
return (S) new TransportTubeFactory() {
public Tube doCreate(ClientTubeAssemblerContext context) {
return new EchoTube();
}
};
if (TubelineAssemblerFactory.class.equals(spiType))
return (S) new TubelineAssemblerFactory() {
public TubelineAssembler doCreate(BindingID bindingId) {
return new TubelineAssembler() {
public Tube createClient(ClientTubeAssemblerContext context) {
final Tube head = context.createTransportTube();
return new EchoTube() {
public NextAction processRequest(Packet request) {
NextAction na = new NextAction();
na.invoke(head, request);
return na;
}
public NextAction processResponse(Packet response) {
NextAction na = new NextAction();
na.returnWith(new Packet());
return na;
}
};
}
public Tube createServer(ServerTubeAssemblerContext context) {
return null;
}
};
}
};
return null;
}
}));
Echo echo = srv.getEchoPort();
try {
int res = echo.add(new NumbersRequest());
fail();
} catch (Exception e) {
assertFalse(e instanceof NullPointerException);
assertTrue(e instanceof WebServiceException);
}
try {
echo.echoString(new Holder(wsdlURL.toString()));
fail();
} catch (Exception e) {
assertFalse(e instanceof NullPointerException);
assertTrue(e instanceof WebServiceException);
}
}
use of com.sun.xml.ws.api.pipe.TransportTubeFactory in project metro-jax-ws by eclipse-ee4j.
the class ClientProxyTest method testNullResponseFromTransprt.
@SuppressWarnings("unchecked")
public void testNullResponseFromTransprt() throws Exception {
URL wsdlURL = Thread.currentThread().getContextClassLoader().getResource("etc/EchoService.wsdl");
EchoService srv = new EchoService(wsdlURL, new ComponentFeature(new com.sun.xml.ws.api.Component() {
public <S> S getSPI(Class<S> spiType) {
if (TransportTubeFactory.class.equals(spiType))
return (S) new TransportTubeFactory() {
public Tube doCreate(ClientTubeAssemblerContext context) {
return new EchoTube() {
public NextAction processRequest(Packet request) {
NextAction na = new NextAction();
na.returnWith(new Packet());
return na;
}
};
}
};
return null;
}
}));
Echo echo = srv.getEchoPort();
try {
int res = echo.add(new NumbersRequest());
fail();
} catch (Exception e) {
assertFalse(e instanceof NullPointerException);
assertTrue(e instanceof WebServiceException);
}
try {
echo.echoString(new Holder<String>(wsdlURL.toString()));
fail();
} catch (Exception e) {
assertFalse(e instanceof NullPointerException);
assertTrue(e instanceof WebServiceException);
}
}
Aggregations