use of com.sun.xml.ws.api.databinding.DatabindingConfig in project metro-jax-ws by eclipse-ee4j.
the class SDORuntimeBasicTest method testEchoSDO_DocLitWrapNoWrapper.
public void testEchoSDO_DocLitWrapNoWrapper() throws Exception {
Class<HelloSDO_DocLitWrap> sei = HelloSDO_DocLitWrap.class;
Class<HelloSDO_DocLitWrapImpl> seb = HelloSDO_DocLitWrapImpl.class;
DatabindingConfig srvConfig = new DatabindingConfig();
final HelperContext shc = SDOHelperContext.getHelperContext("server");
HelperContextResolver shcr = new HelperContextResolver() {
public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
return shc;
}
};
File f = getSchema("MySDO.xsd");
Set<SchemaInfo> schemas = SDOUtils.getSchemas(f);
srvConfig.setEndpointClass(seb);
DatabindingModeFeature dbm = databindingMode();
WebServiceFeature[] features = { dbm };
srvConfig.setFeatures(features);
srvConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
srvConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, shcr);
srvConfig.properties().put("com.sun.xml.ws.api.model.SuppressDocLitWrapperGeneration", true);
DatabindingConfig cliConfig = new DatabindingConfig();
// SDODatabindingContext.getLocalHelperContext();
final HelperContext chc = SDOHelperContext.getHelperContext("client");
HelperContextResolver chcr = new HelperContextResolver() {
public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
return chc;
}
};
cliConfig.setContractClass(sei);
cliConfig.setFeatures(features);
cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
cliConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, chcr);
cliConfig.properties().put("com.sun.xml.ws.api.model.SuppressDocLitWrapperGeneration", true);
HelloSDO_DocLitWrap proxy = createProxy(sei, srvConfig, cliConfig, false);
SDOUtils.defineSchema(chc, f);
String s = "Gigi";
int i = 20;
MySDO mySDO = createMySDO(chc, s, i);
assertEquals(s, proxy.returnS(mySDO));
assertEquals(i, proxy.returnI(mySDO));
Object obj = proxy.echoSDO(mySDO);
assertTrue(obj instanceof MySDO);
mySDO = (MySDO) obj;
assertEquals(21, mySDO.getIntPart());
assertEquals("Gary", mySDO.getStringPart());
String wrapperName = srvConfig.properties().get(BindingContext.class.getName()).getClass().getName();
assertTrue(wrapperName != null && wrapperName.endsWith("SDOContextWrapper"));
{
MySDO[] a = { createMySDO(chc, "a", 1), createMySDO(chc, "b", 2), createMySDO(chc, "c", 3) };
List<MySDO> lreq = Arrays.asList(a);
List<String> lres = proxy.testList1(lreq);
assertEquals(lres.size(), lreq.size());
}
{
MySDO[] a = { createMySDO(chc, "a", 1), createMySDO(chc, "b", 2), createMySDO(chc, "c", 3) };
List<String> l1 = Arrays.asList(new String[] { "w", "x", "y", "z" });
List<MySDO> l2 = Arrays.asList(a);
List<String> lres = proxy.testList2(l1, l2);
assertEquals(lres.size(), l1.size() + l2.size());
}
{
MySDO[] a = { createMySDO(chc, "g", 5), createMySDO(chc, "j", 6), createMySDO(chc, "k", 7), createMySDO(chc, "l", 8), createMySDO(chc, "h", 9) };
String[] res = proxy.arrayList01(a);
assertEquals(res.length, a.length);
}
}
use of com.sun.xml.ws.api.databinding.DatabindingConfig in project metro-jax-ws by eclipse-ee4j.
the class WrapperNSTest method testGenerateWsdl.
public void testGenerateWsdl() throws Exception {
Class<?> sei = MyHelloRPC.class;
DatabindingFactory fac = DatabindingFactory.newInstance();
Databinding.Builder b = fac.createBuilder(sei, null);
DatabindingModeFeature dbf = new DatabindingModeFeature("eclipselink.jaxb");
WebServiceFeature[] f = { dbf };
DatabindingConfig config = new DatabindingConfig();
config.setFeatures(f);
config.setEndpointClass(MyHelloClass.class);
MappingInfo mi = new MappingInfo();
mi.setServiceName(new QName("http://echo.org/", "helloService"));
mi.setPortName(new QName("http://echo.org/", "helloPort"));
config.setMappingInfo(mi);
config.setClassLoader(this.getClass().getClassLoader());
RuntimeModeler rtModeler = new RuntimeModeler(config);
rtModeler.buildRuntimeModel();
}
use of com.sun.xml.ws.api.databinding.DatabindingConfig in project metro-jax-ws by eclipse-ee4j.
the class JAXBRIBasicTest method testHelloEchoNoMode.
public void testHelloEchoNoMode() throws Exception {
Class endpointClass = HelloImpl.class;
Class proxySEIClass = HelloPort.class;
DatabindingConfig srvConfig = new DatabindingConfig();
srvConfig.setEndpointClass(endpointClass);
srvConfig.setMetadataReader(new DummyAnnotations());
WebServiceFeature[] f = {};
srvConfig.setFeatures(f);
DatabindingConfig cliConfig = new DatabindingConfig();
cliConfig.setMetadataReader(new DummyAnnotations());
cliConfig.setContractClass(proxySEIClass);
cliConfig.setFeatures(f);
HelloPort hp = createProxy(HelloPort.class, srvConfig, cliConfig, false);
String req = "testInVM " + databindingMode().getMode();
String res = hp.echoS(req);
assertEquals(req, res);
String wrapperName = srvConfig.properties().get(BindingContext.class.getName()).getClass().getName();
assertTrue("Wrapper: " + wrapperName, wrapperName != null && wrapperName.endsWith("JAXBRIContextWrapper"));
}
use of com.sun.xml.ws.api.databinding.DatabindingConfig in project metro-jax-ws by eclipse-ee4j.
the class JAXBRIBasicTest method testHelloEchoInvalidDB.
public void testHelloEchoInvalidDB() throws Exception {
Class endpointClass = HelloImpl.class;
Class proxySEIClass = HelloPort.class;
DatabindingConfig srvConfig = new DatabindingConfig();
srvConfig.setEndpointClass(endpointClass);
srvConfig.setMetadataReader(new DummyAnnotations());
WebServiceFeature[] f = { new DatabindingModeFeature("invalid.db") };
srvConfig.setFeatures(f);
DatabindingConfig cliConfig = new DatabindingConfig();
cliConfig.setMetadataReader(new DummyAnnotations());
cliConfig.setContractClass(proxySEIClass);
cliConfig.setFeatures(f);
try {
HelloPort hp = createProxy(HelloPort.class, srvConfig, cliConfig, false);
fail("Expected DatabindingException not thrown");
} catch (DatabindingException e) {
// expected exception.
}
}
use of com.sun.xml.ws.api.databinding.DatabindingConfig in project metro-jax-ws by eclipse-ee4j.
the class BasicDatabindingTestBase method _testHelloEcho.
protected String _testHelloEcho() throws Exception {
Class<?> endpointClass = HelloImpl.class;
Class<?> proxySEIClass = HelloPort.class;
DatabindingConfig srvConfig = new DatabindingConfig();
srvConfig.setEndpointClass(endpointClass);
srvConfig.setMetadataReader(new DummyAnnotations());
DatabindingModeFeature dbm = databindingMode();
DatabindingConfig cliConfig = new DatabindingConfig();
cliConfig.setMetadataReader(new DummyAnnotations());
cliConfig.setContractClass(proxySEIClass);
// Honor system property if present, otherwise set feature.
WebServiceFeature[] f = null;
String dbProperty = System.getProperty(BindingContextFactory.JAXB_CONTEXT_FACTORY_PROPERTY);
if (dbProperty == null)
f = new WebServiceFeature[] { dbm };
else
f = new WebServiceFeature[0];
srvConfig.setFeatures(f);
cliConfig.setFeatures(f);
HelloPort hp = createProxy(HelloPort.class, srvConfig, cliConfig, false);
String req = "testInVM " + dbm.getMode();
String res = hp.echoS(req);
assertEquals(req, res);
return srvConfig.properties().get(BindingContext.class.getName()).getClass().getName();
}
Aggregations