use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.
the class SDODatabindingTestBase method sdoConfig.
protected SDOConfig sdoConfig(Set<SchemaInfo> schemas, boolean server) {
final SDOConfig config = new SDOConfig();
config.context = server ? SDOHelperContext.getHelperContext("server") : // SDODatabindingContext.getLocalHelperContext();
SDOHelperContext.getHelperContext();
config.resolver = new HelperContextResolver() {
public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
return config.context;
}
};
for (SchemaInfo xi : schemas) ((SDOXSDHelper) config.context.getXSDHelper()).define(xi.getSchemaSource(), null);
return config;
}
use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.
the class SDOHRAppServiceTest method testSDO_HRAppServiceNoWrapper.
// Bug 14071356
public void testSDO_HRAppServiceNoWrapper() throws Exception {
Set<SchemaInfo> schemas = SDOUtils.getSchemas(getResource("wsdl/HRAppService.wsdl").getFile());
DatabindingConfig srvConfig = new DatabindingConfig();
Class<HRAppServiceNoWrapper> sei = HRAppServiceNoWrapper.class;
Class<HRAppServiceImpl> seb = HRAppServiceImpl.class;
SDOConfig cSdo = sdoConfig(schemas, false);
SDOConfig sSdo = sdoConfig(schemas, true);
srvConfig.setContractClass(sei);
srvConfig.setEndpointClass(seb);
DatabindingModeFeature dbm = new DatabindingModeFeature("eclipselink.sdo");
WebServiceFeature[] features = { dbm };
srvConfig.setFeatures(features);
srvConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
// srvConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_FILE, f);
srvConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, sSdo.resolver);
srvConfig.properties().put("com.sun.xml.ws.api.model.SuppressDocLitWrapperGeneration", true);
DatabindingConfig cliConfig = new DatabindingConfig();
cliConfig.setContractClass(sei);
cliConfig.setFeatures(features);
cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
// cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_FILE, f);
cliConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, cSdo.resolver);
cliConfig.properties().put("com.sun.xml.ws.api.model.SuppressDocLitWrapperGeneration", true);
HRAppServiceNoWrapper proxy = createProxy(sei, srvConfig, cliConfig, debug);
java.math.BigDecimal totalComp = proxy.getTotalComp(new BigInteger("222"));
assertEquals("222", totalComp.toString());
totalComp = proxy.getTotalComp(new BigInteger("333"));
assertEquals("333", totalComp.toString());
doTestGetDeptno("1", proxy);
doTestGetDeptno("2", proxy);
doTestGetDeptno("2000", proxy);
List<Emp> emps = proxy.getManagerAndPeers(new BigInteger("100"));
assertEquals(3, emps.size());
for (int i = 0; i < emps.size(); i++) {
assertEquals("name" + i, emps.get(i).getEname());
assertEquals("job" + i, emps.get(i).getJob());
}
HelperContext context = cSdo.context;
{
Emp emp = (Emp) context.getDataFactory().create(Emp.class);
ProcessControl processControl = (ProcessControl) context.getDataFactory().create(ProcessControl.class);
processControl.setReturnMode("Full");
emp.setEname("name0");
List<Emp> empIn = new Vector<Emp>();
empIn.add(emp);
emp = (Emp) context.getDataFactory().create(Emp.class);
emp.setEname("name1");
empIn.add(emp);
List<Emp> ret = proxy.processEmps("myoperation", empIn, processControl);
for (int i = 0; i < ret.size(); i++) {
assertEquals(ret.get(i).getEname(), empIn.get(i).getEname());
assertEquals("myoperation", ret.get(i).getJob());
}
}
{
Emp emp = createEmployee(200, "1", "name", "1000", "fry cook", context);
Emp ret = proxy.createEmp(emp);
assertEquals(ret.getEname(), emp.getEname());
assertEquals(ret.getEmpno(), emp.getEmpno());
assertEquals(ret.getDeptno(), emp.getDeptno());
assertEquals(ret.getJob(), emp.getJob());
doTestGetDeptno("1", proxy);
doTestGetDeptno("2", proxy);
doTestGetDeptno("2000", proxy);
}
}
use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.
the class SDORuntimeBasicTest method testAddNumbers.
public void testAddNumbers() throws Exception {
DatabindingConfig srvConfig = new DatabindingConfig();
File f = getSchema("AddNumbers.xsd");
Class<AddNumbersPortType> sei = AddNumbersPortType.class;
Class<AddNumbersServiceImpl> seb = AddNumbersServiceImpl.class;
// SDODatabindingContext.getLocalHelperContext();
final HelperContext chc = SDOHelperContext.getHelperContext("client");
HelperContextResolver chcr = new HelperContextResolver() {
// @Override
public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
return chc;
}
};
SDOUtils.defineSchema(chc, f);
Set<SchemaInfo> schemas = SDOUtils.getSchemas(f);
final HelperContext shc = SDOHelperContext.getHelperContext("server");
HelperContextResolver shcr = new HelperContextResolver() {
// @Override
public HelperContext getHelperContext(boolean isClient, QName serviceName, Map<String, Object> properties) {
return shc;
}
};
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_SCHEMA_FILE, f);
srvConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, shcr);
DatabindingConfig cliConfig = new DatabindingConfig();
cliConfig.setContractClass(sei);
cliConfig.setFeatures(features);
cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_INFO, schemas);
// cliConfig.properties().put(SDOContextWrapper.SDO_SCHEMA_FILE, f);
cliConfig.properties().put(SDOContextWrapper.SDO_HELPER_CONTEXT_RESOLVER, chcr);
AddNumbersPortType proxy = createProxy(sei, srvConfig, cliConfig, false);
Object obj = proxy.addNumbers(4, -83);
assertTrue(obj instanceof Integer);
Integer resp = (Integer) obj;
assertEquals(Integer.valueOf(-79), resp);
}
use of commonj.sdo.helper.HelperContext in project metro-jax-ws by eclipse-ee4j.
the class SDORuntimeBasicTest method testEchoSDO.
public void testEchoSDO() throws Exception {
Class<HelloSDO_ProxyInterface> sei = HelloSDO_ProxyInterface.class;
Class<HelloSDO_ProxyInterfaceImpl> seb = HelloSDO_ProxyInterfaceImpl.class;
DatabindingConfig srvConfig = new DatabindingConfig();
final HelperContext shc = SDOHelperContext.getHelperContext("server");
HelperContextResolver shcr = new HelperContextResolver() {
// @Override
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);
DatabindingConfig cliConfig = new DatabindingConfig();
// SDODatabindingContext.getLocalHelperContext();
final HelperContext chc = SDOHelperContext.getHelperContext("client");
HelperContextResolver chcr = new HelperContextResolver() {
// @Override
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);
HelloSDO_ProxyInterface proxy = createProxy(sei, srvConfig, cliConfig, false);
SDOUtils.defineSchema(chc, f);
MySDO mySDO = createMySDO(chc, "Gigi", 20);
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"));
}
use of commonj.sdo.helper.HelperContext 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);
}
}
Aggregations