You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yoko-commits@incubator.apache.org by dm...@apache.org on 2006/08/31 17:48:38 UTC
svn commit: r438997 - in /incubator/yoko/trunk/bindings/src:
main/java/org/apache/yoko/bindings/corba/
main/java/org/apache/yoko/bindings/corba/types/
test/java/org/apache/yoko/bindings/corba/ test/resources/wsdl/
Author: dmiddlem
Date: Thu Aug 31 10:48:37 2006
New Revision: 438997
URL: http://svn.apache.org/viewvc?rev=438997&view=rev
Log:
Adding some missing unit tests (YOKO-158). Also adding fixes discovered
while implementing unit tests.
Added:
incubator/yoko/trunk/bindings/src/test/resources/wsdl/StaxTest.wsdl (with props)
Modified:
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java
incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandler.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingFactoryTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingImplTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaBindingImpl.java Thu Aug 31 10:48:37 2006
@@ -143,7 +143,7 @@
"Received exception [" + ex + "] while reading typemaps. Proceeding anyway.");
}
}
-
+
public Bus getBus() {
return this.bus;
}
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaClientBinding.java Thu Aug 31 10:48:37 2006
@@ -63,8 +63,7 @@
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.UnknownUserException;
-public class CorbaClientBinding extends AbstractBindingBase implements
- ClientBinding {
+public class CorbaClientBinding extends AbstractBindingBase implements ClientBinding {
private static final Logger LOG = LogUtils.getL7dLogger(CorbaClientBinding.class);
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaObjectReader.java Thu Aug 31 10:48:37 2006
@@ -357,8 +357,6 @@
this.read(branchObj);
unionHandler.setValue(defaultBranch.getName(), branchObj);
}
-
-// throw new CorbaBindingException("CorbaObjectReader: readUnion not yet implemented");
}
public void readArray(CorbaObjectHandler obj) throws CorbaBindingException {
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/CorbaUtils.java Thu Aug 31 10:48:37 2006
@@ -336,14 +336,11 @@
return null;
}
-// public static NamedType getCorbaType(QName idlType, List<CorbaTypeMap> typeMaps) {
public static CorbaTypeImpl getCorbaType(QName idlType, List<CorbaTypeMap> typeMaps) {
CorbaTypeMap currentMap = null;
for (int i = 0; i < typeMaps.size(); ++i) {
currentMap = typeMaps.get(i);
if (currentMap.getTargetNamespace().equals(idlType.getNamespaceURI())) {
- // elements in the typemap should also be NamedTypes
-// return (NamedType) currentMap.getType(idlType.getLocalPart());
return (CorbaTypeImpl) currentMap.getType(idlType.getLocalPart());
}
}
Modified: incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandler.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandler.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandler.java (original)
+++ incubator/yoko/trunk/bindings/src/main/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandler.java Thu Aug 31 10:48:37 2006
@@ -90,7 +90,6 @@
public void setValueFromData(String data) {
switch (typeCode.kind().value()) {
-
case TCKind._tk_boolean:
value = new Boolean(data);
break;
Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingFactoryTest.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingFactoryTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingFactoryTest.java Thu Aug 31 10:48:37 2006
@@ -59,7 +59,7 @@
BindingFactory factory =
bus.getBindingManager().getBindingFactory("http://schemas.apache.org/yoko/bindings/corba");
- EndpointReferenceType address = testUtils.getEndpointReference();
+ EndpointReferenceType address = testUtils.getSimpleTestEndpointReference();
ClientBinding cb = factory.createClientBinding(address);
assertNotNull(cb);
@@ -83,7 +83,7 @@
BindingFactory factory =
bus.getBindingManager().getBindingFactory("http://schemas.apache.org/yoko/bindings/corba");
- EndpointReferenceType address = testUtils.getEndpointReference();
+ EndpointReferenceType address = testUtils.getSimpleTestEndpointReference();
ServerBinding sb = factory.createServerBinding(address, null);
assertNotNull(sb);
Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingImplTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingImplTest.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingImplTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingImplTest.java Thu Aug 31 10:48:37 2006
@@ -18,14 +18,45 @@
*/
package org.apache.yoko.bindings.corba;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.xml.namespace.QName;
+import javax.xml.stream.events.EndElement;
+import javax.xml.stream.events.StartElement;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
import junit.framework.TestCase;
+import org.apache.schemas.yoko.bindings.corba.Array;
+import org.apache.schemas.yoko.bindings.corba.Enum;
+import org.apache.schemas.yoko.bindings.corba.Fixed;
+import org.apache.schemas.yoko.bindings.corba.Enumerator;
+import org.apache.schemas.yoko.bindings.corba.MemberType;
+import org.apache.schemas.yoko.bindings.corba.Sequence;
+import org.apache.schemas.yoko.bindings.corba.Struct;
+import org.apache.schemas.yoko.bindings.corba.Union;
+import org.apache.yoko.bindings.corba.types.CorbaArrayHandler;
+import org.apache.yoko.bindings.corba.types.CorbaEnumHandler;
+//import org.apache.yoko.bindings.corba.types.CorbaExceptionHandler;
+import org.apache.yoko.bindings.corba.types.CorbaFixedHandler;
import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
+import org.apache.yoko.bindings.corba.types.CorbaSequenceHandler;
+import org.apache.yoko.bindings.corba.types.CorbaStructHandler;
+import org.apache.yoko.bindings.corba.types.CorbaUnionHandler;
+import org.apache.yoko.wsdl.CorbaTypeImpl;
import org.omg.CORBA.ORB;
+import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.objectweb.celtix.Bus;
@@ -43,6 +74,11 @@
private CorbaMessageContextImpl corbaContext;
private TestUtils testUtils;
private ORB orb;
+ private Bus bus;
+ private EndpointReferenceType endpoint;
+
+ private final String staxTestNamespaceURI = "http://yoko.apache.org/StaxTest/idl_types";
+ private final String staxTestPrefix = "corbatm";
public CorbaBindingImplTest(String arg0) {
super(arg0);
@@ -68,6 +104,16 @@
Class c = Thread.currentThread().getContextClassLoader().loadClass("org.apache.yoko.simple.Simple");
Class[] params = { String.class };
objContext.setMethod(c.getMethod("testSimpleMethod", params));
+
+ bus = Bus.init(new String[0]);
+
+ // programmatically add the corba binding factory
+ BindingManager manager = bus.getBindingManager();
+ CorbaBindingFactory corbaBF = new CorbaBindingFactory();
+ corbaBF.init(bus);
+ manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
+
+ endpoint = testUtils.getSimpleTestEndpointReference();
}
protected void tearDown() throws Exception {
@@ -81,15 +127,6 @@
}
public void testMarshal() throws Exception {
- Bus bus = Bus.init(new String[0]);
-
- // programmatically add the corba binding factory
- BindingManager manager = bus.getBindingManager();
- CorbaBindingFactory corbaBF = new CorbaBindingFactory();
- corbaBF.init(bus);
- manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
-
- EndpointReferenceType endpoint = testUtils.getEndpointReference();
CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, endpoint, orb, false);
corbaContext.put(ObjectMessageContext.MESSAGE_INPUT, true);
@@ -113,15 +150,6 @@
}
public void testUnmarshal() throws Exception {
- Bus bus = Bus.init(new String[0]);
-
- // programmatically add the corba binding factory
- BindingManager manager = bus.getBindingManager();
- CorbaBindingFactory corbaBF = new CorbaBindingFactory();
- corbaBF.init(bus);
- manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
-
- EndpointReferenceType endpoint = testUtils.getEndpointReference();
CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, endpoint, orb, true);
corbaContext.put(ObjectMessageContext.MESSAGE_INPUT, true);
@@ -151,5 +179,573 @@
String param1 = (String)o;
assertTrue(param1.equals("TestString"));
+ }
+
+ public void testReadWriteStaxPrimitive() {
+ CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, endpoint, orb, false);
+ CorbaPrimitiveHandler obj = new CorbaPrimitiveHandler(new QName("BooleanType"),
+ CorbaConstants.NT_CORBA_BOOLEAN,
+ orb.get_primitive_tc(TCKind.tk_boolean),
+ null);
+ obj.setValueFromData("false");
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = null;
+ try {
+ evtWriter = outputFactory.createXMLEventWriter(outStream);
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtWriter);
+
+ try {
+ XMLEventFactory factory = XMLEventFactory.newInstance();
+ StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+ evtWriter.add(startEl);
+ bindingImpl.writePrimitiveToStax(obj, evtWriter, factory);
+ EndElement endEl = factory.createEndElement(obj.getName(), null);
+ evtWriter.add(endEl);
+ evtWriter.flush();
+ } catch (XMLStreamException ex) {
+
+ }
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = null;
+ try {
+ evtReader = inputFactory.createXMLEventReader(inStream);
+ // read the first tag which should be a start document
+ XMLEvent evt = evtReader.nextEvent();
+ assertTrue(evt.isStartDocument());
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtReader);
+
+ CorbaObjectHandler result = bindingImpl.readPrimitiveFromStax(evtReader,
+ obj.getIdlType(),
+ obj.getTypeCode());
+ assertNotNull(result);
+
+ assertTrue(result instanceof CorbaPrimitiveHandler);
+ CorbaPrimitiveHandler resultObj = (CorbaPrimitiveHandler)result;
+
+ assertTrue(resultObj.getName().equals(obj.getName()));
+ assertTrue(resultObj.getIdlType().equals(obj.getIdlType()));
+ assertTrue(resultObj.getTypeCode().equal(obj.getTypeCode()));
+ assertTrue(resultObj.getValueData().equals(obj.getValueData()));
+ }
+
+ public void testReadWriteStaxArray() {
+
+ CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, testUtils.getStaxTestEndpointReference(),
+ orb, false);
+
+ QName objName = new QName("object");
+ QName objIdlType = new QName(staxTestNamespaceURI, "TestArray", staxTestPrefix);
+ TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, bindingImpl.getCorbaTypeMaps());
+ CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, bindingImpl.getCorbaTypeMaps());
+ assertTrue(type instanceof Array);
+
+ Array arrayType = (Array)type;
+ CorbaArrayHandler obj = new CorbaArrayHandler(objName, objIdlType, objTypeCode, arrayType);
+ assertNotNull(obj);
+
+ List<CorbaObjectHandler> objElements = new ArrayList<CorbaObjectHandler>();
+ int arrayData[] = { 2, 4, 6, 8, 10 };
+ for (int i = 0 ; i < arrayData.length; ++i) {
+ QName elName = new QName("item");
+ QName elIdlType = CorbaConstants.NT_CORBA_LONG;
+ TypeCode elTC = orb.get_primitive_tc(TCKind.tk_long);
+ CorbaPrimitiveHandler el = new CorbaPrimitiveHandler(elName, elIdlType, elTC, null);
+ el.setValue(Long.valueOf(arrayData[i]));
+ obj.addElement(el);
+ objElements.add(el);
+ }
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = null;
+ try {
+ evtWriter = outputFactory.createXMLEventWriter(outStream);
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtWriter);
+
+ try {
+ XMLEventFactory factory = XMLEventFactory.newInstance();
+ StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+ evtWriter.add(startEl);
+ bindingImpl.writeArrayToStax(obj, evtWriter, factory);
+ EndElement endEl = factory.createEndElement(obj.getName(), null);
+ evtWriter.add(endEl);
+ evtWriter.flush();
+ } catch (XMLStreamException ex) {
+
+ }
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = null;
+ try {
+ evtReader = inputFactory.createXMLEventReader(inStream);
+ // read the first tag which should be a start document
+ XMLEvent evt = evtReader.nextEvent();
+ assertTrue(evt.isStartDocument());
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtReader);
+
+ CorbaObjectHandler result = bindingImpl.readArrayFromStax(evtReader,
+ obj.getIdlType(),
+ obj.getTypeCode());
+ assertNotNull(result);
+
+ assertTrue(result instanceof CorbaArrayHandler);
+ CorbaArrayHandler resultObj = (CorbaArrayHandler)result;
+
+ assertTrue(resultObj.getName().equals(obj.getName()));
+ assertTrue(resultObj.getIdlType().equals(obj.getIdlType()));
+ assertTrue(resultObj.getTypeCode().equal(obj.getTypeCode()));
+ List<CorbaObjectHandler> resultElements = resultObj.getElements();
+ for (int i = 0; i < resultElements.size(); ++i) {
+ assertTrue(resultElements.get(i) instanceof CorbaPrimitiveHandler);
+ CorbaPrimitiveHandler resultEl = (CorbaPrimitiveHandler)resultElements.get(i);
+ CorbaPrimitiveHandler objEl = (CorbaPrimitiveHandler)objElements.get(i);
+ assertTrue(resultEl.getValueData().equals(objEl.getValueData()));
+ }
+ }
+
+ public void testReadWriteStaxEnum() {
+ CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, testUtils.getStaxTestEndpointReference(),
+ orb, false);
+
+ QName objName = new QName("object");
+ QName objIdlType = new QName(staxTestNamespaceURI, "TestEnum", staxTestPrefix);
+ CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, bindingImpl.getCorbaTypeMaps());
+ assertTrue(type instanceof Enum);
+ Enum enumType = (Enum)type;
+ List<Enumerator> enumerators = enumType.getEnumerator();
+ String[] enums = new String[enumerators.size()];
+ for (int i = 0; i < enumerators.size(); ++i) {
+ Enumerator e = enumerators.get(i);
+ enums[i] = e.getValue();
+ }
+ TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, bindingImpl.getCorbaTypeMaps());
+ CorbaEnumHandler obj = new CorbaEnumHandler(objName, objIdlType, objTypeCode, enumType);
+ assertNotNull(obj);
+
+ obj.setValue(enums[1]);
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = null;
+ try {
+ evtWriter = outputFactory.createXMLEventWriter(outStream);
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtWriter);
+
+ try {
+ XMLEventFactory factory = XMLEventFactory.newInstance();
+ StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+ evtWriter.add(startEl);
+ bindingImpl.writeEnumToStax(obj, evtWriter, factory);
+ EndElement endEl = factory.createEndElement(obj.getName(), null);
+ evtWriter.add(endEl);
+ evtWriter.flush();
+ } catch (XMLStreamException ex) {
+
+ }
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = null;
+ try {
+ evtReader = inputFactory.createXMLEventReader(inStream);
+ // read the first tag which should be a start document
+ XMLEvent evt = evtReader.nextEvent();
+ assertTrue(evt.isStartDocument());
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtReader);
+
+ CorbaObjectHandler resultObj = bindingImpl.readEnumFromStax(evtReader,
+ obj.getIdlType(),
+ obj.getTypeCode());
+ assertNotNull(resultObj);
+
+ assertTrue(resultObj instanceof CorbaEnumHandler);
+ CorbaEnumHandler result = (CorbaEnumHandler)resultObj;
+
+ Object resultValueObj = result.getValue();
+ assertTrue(resultValueObj instanceof String);
+
+ String resultValue = (String)resultValueObj;
+ assertTrue(resultValue.equals(enums[1]));
+ }
+
+ public void testReadWriteStaxFixed() {
+ CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, testUtils.getStaxTestEndpointReference(),
+ orb, false);
+
+ QName objName = new QName("object");
+ QName objIdlType = new QName(staxTestNamespaceURI, "TestFixed", staxTestPrefix);
+ CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, bindingImpl.getCorbaTypeMaps());
+ assertTrue(type instanceof Fixed);
+ Fixed fixedType = (Fixed)type;
+ TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, bindingImpl.getCorbaTypeMaps());
+ CorbaFixedHandler obj = new CorbaFixedHandler(objName, objIdlType, objTypeCode, fixedType);
+ assertNotNull(obj);
+
+ java.math.BigDecimal fixedValue = new java.math.BigDecimal("12345.67");
+ obj.setValue(fixedValue);
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = null;
+ try {
+ evtWriter = outputFactory.createXMLEventWriter(outStream);
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtWriter);
+
+ try {
+ XMLEventFactory factory = XMLEventFactory.newInstance();
+ StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+ evtWriter.add(startEl);
+ bindingImpl.writeFixedToStax(obj, evtWriter, factory);
+ EndElement endEl = factory.createEndElement(obj.getName(), null);
+ evtWriter.add(endEl);
+ evtWriter.flush();
+ } catch (XMLStreamException ex) {
+
+ }
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = null;
+ try {
+ evtReader = inputFactory.createXMLEventReader(inStream);
+ // read the first tag which should be a start document
+ XMLEvent evt = evtReader.nextEvent();
+ assertTrue(evt.isStartDocument());
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtReader);
+
+ CorbaObjectHandler resultObj = bindingImpl.readFixedFromStax(evtReader,
+ obj.getIdlType(),
+ obj.getTypeCode());
+ assertNotNull(resultObj);
+
+ assertTrue(resultObj instanceof CorbaFixedHandler);
+ CorbaFixedHandler result = (CorbaFixedHandler)resultObj;
+
+ Object resultValueObj = result.getValue();
+ assertTrue(resultValueObj instanceof java.math.BigDecimal);
+
+ java.math.BigDecimal resultValue = (java.math.BigDecimal)resultValueObj;
+ assertTrue(resultValue.toString().equals(fixedValue.toString()));
+ }
+
+ public void testReadWriteStaxSequence() {
+
+ CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, testUtils.getStaxTestEndpointReference(),
+ orb, false);
+
+ QName objName = new QName("object");
+ QName objIdlType = new QName(staxTestNamespaceURI, "TestSequence", staxTestPrefix);
+ TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, bindingImpl.getCorbaTypeMaps());
+ CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, bindingImpl.getCorbaTypeMaps());
+ assertTrue(type instanceof Sequence);
+
+ Sequence seqType = (Sequence)type;
+ CorbaSequenceHandler obj = new CorbaSequenceHandler(objName, objIdlType, objTypeCode, seqType);
+ assertNotNull(obj);
+
+ List<CorbaObjectHandler> objElements = new ArrayList<CorbaObjectHandler>();
+ short seqData[] = { 1, 3, 5, 7 };
+ for (int i = 0 ; i < seqData.length; ++i) {
+ QName elName = new QName("item");
+ QName elIdlType = CorbaConstants.NT_CORBA_SHORT;
+ TypeCode elTC = orb.get_primitive_tc(TCKind.tk_short);
+ CorbaPrimitiveHandler el = new CorbaPrimitiveHandler(elName, elIdlType, elTC, null);
+ el.setValue(Short.valueOf(seqData[i]));
+ obj.addElement(el);
+ objElements.add(el);
+ }
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = null;
+ try {
+ evtWriter = outputFactory.createXMLEventWriter(outStream);
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtWriter);
+
+ try {
+ XMLEventFactory factory = XMLEventFactory.newInstance();
+ StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+ evtWriter.add(startEl);
+ bindingImpl.writeSequenceToStax(obj, evtWriter, factory);
+ EndElement endEl = factory.createEndElement(obj.getName(), null);
+ evtWriter.add(endEl);
+ evtWriter.flush();
+ } catch (XMLStreamException ex) {
+
+ }
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = null;
+ try {
+ evtReader = inputFactory.createXMLEventReader(inStream);
+ // read the first tag which should be a start document
+ XMLEvent evt = evtReader.nextEvent();
+ assertTrue(evt.isStartDocument());
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtReader);
+
+ CorbaObjectHandler result = bindingImpl.readSequenceFromStax(evtReader,
+ obj.getIdlType(),
+ obj.getTypeCode());
+ assertNotNull(result);
+
+ assertTrue(result instanceof CorbaSequenceHandler);
+ CorbaSequenceHandler resultObj = (CorbaSequenceHandler)result;
+
+ assertTrue(resultObj.getName().equals(obj.getName()));
+ assertTrue(resultObj.getIdlType().equals(obj.getIdlType()));
+ assertTrue(resultObj.getTypeCode().equal(obj.getTypeCode()));
+ List<CorbaObjectHandler> resultElements = resultObj.getElements();
+ for (int i = 0; i < resultElements.size(); ++i) {
+ assertTrue(resultElements.get(i) instanceof CorbaPrimitiveHandler);
+ CorbaPrimitiveHandler resultEl = (CorbaPrimitiveHandler)resultElements.get(i);
+ CorbaPrimitiveHandler objEl = (CorbaPrimitiveHandler)objElements.get(i);
+ assertTrue(resultEl.getValueData().equals(objEl.getValueData()));
+ }
+ }
+
+ public void testReadWriteStaxStruct() {
+ CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, testUtils.getStaxTestEndpointReference(),
+ orb, false);
+
+ QName objName = new QName("object");
+ QName objIdlType = new QName(staxTestNamespaceURI, "TestStruct", staxTestPrefix);
+ CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, bindingImpl.getCorbaTypeMaps());
+ assertTrue(type instanceof Struct);
+ Struct structType = (Struct)type;
+ TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, bindingImpl.getCorbaTypeMaps());
+ CorbaStructHandler obj = new CorbaStructHandler(objName, objIdlType, objTypeCode, structType);
+ assertNotNull(obj);
+
+ List<MemberType> structMembers = structType.getMember();
+ // For this test, we know what each of the members are. Create the correct handler and assign
+ // each member a value
+ MemberType m1 = structMembers.get(0);
+ TypeCode m1TypeCode = CorbaUtils.getTypeCode(orb, m1.getIdltype(), bindingImpl.getCorbaTypeMaps());
+ CorbaPrimitiveHandler member1 = new CorbaPrimitiveHandler(new QName(m1.getName()),
+ m1.getIdltype(),
+ m1TypeCode,
+ null);
+ Boolean member1Value = new Boolean(false);
+ member1.setValue(member1Value);
+ obj.addMember(member1);
+
+ MemberType m2 = structMembers.get(1);
+ TypeCode m2TypeCode = CorbaUtils.getTypeCode(orb, m2.getIdltype(), bindingImpl.getCorbaTypeMaps());
+ CorbaPrimitiveHandler member2 = new CorbaPrimitiveHandler(new QName(m2.getName()),
+ m2.getIdltype(),
+ m2TypeCode,
+ null);
+ String member2Value = "Member 2 string";
+ member2.setValue(member2Value);
+ obj.addMember(member2);
+
+ MemberType m3 = structMembers.get(2);
+ TypeCode m3TypeCode = CorbaUtils.getTypeCode(orb, m3.getIdltype(), bindingImpl.getCorbaTypeMaps());
+ CorbaPrimitiveHandler member3 = new CorbaPrimitiveHandler(new QName(m3.getName()),
+ m3.getIdltype(),
+ m3TypeCode,
+ null);
+ Float member3Value = new Float(12345.678);
+ member3.setValue(member3Value);
+ obj.addMember(member3);
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = null;
+ try {
+ evtWriter = outputFactory.createXMLEventWriter(outStream);
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtWriter);
+
+ try {
+ XMLEventFactory factory = XMLEventFactory.newInstance();
+ StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+ evtWriter.add(startEl);
+ bindingImpl.writeStructToStax(obj, evtWriter, factory);
+ EndElement endEl = factory.createEndElement(obj.getName(), null);
+ evtWriter.add(endEl);
+ evtWriter.flush();
+ } catch (XMLStreamException ex) {
+
+ }
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = null;
+ try {
+ evtReader = inputFactory.createXMLEventReader(inStream);
+ // read the first tag which should be a start document
+ XMLEvent evt = evtReader.nextEvent();
+ assertTrue(evt.isStartDocument());
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtReader);
+
+ CorbaObjectHandler resultObj = bindingImpl.readStructFromStax(evtReader,
+ obj.getIdlType(),
+ obj.getTypeCode());
+ assertNotNull(resultObj);
+
+ assertTrue(resultObj instanceof CorbaStructHandler);
+ CorbaStructHandler result = (CorbaStructHandler)resultObj;
+
+ List<CorbaObjectHandler> resultMembers = result.getMembers();
+ assertTrue(resultMembers.size() == 3);
+
+ CorbaObjectHandler resultMember1Obj = resultMembers.get(0);
+ assertTrue(resultMember1Obj instanceof CorbaPrimitiveHandler);
+ CorbaPrimitiveHandler resultMember1 = (CorbaPrimitiveHandler)resultMember1Obj;
+ Object resultMember1ValueObj = resultMember1.getValue();
+ assertTrue(resultMember1ValueObj instanceof Boolean);
+ Boolean resultMember1Value = (Boolean)resultMember1ValueObj;
+ assertTrue(resultMember1Value.booleanValue() == member1Value.booleanValue());
+
+ CorbaObjectHandler resultMember2Obj = resultMembers.get(1);
+ assertTrue(resultMember2Obj instanceof CorbaPrimitiveHandler);
+ CorbaPrimitiveHandler resultMember2 = (CorbaPrimitiveHandler)resultMember2Obj;
+ Object resultMember2ValueObj = resultMember2.getValue();
+ assertTrue(resultMember2ValueObj instanceof String);
+ String resultMember2Value = (String)resultMember2ValueObj;
+ assertTrue(resultMember2Value.equals(member2Value));
+
+ CorbaObjectHandler resultMember3Obj = resultMembers.get(2);
+ assertTrue(resultMember3Obj instanceof CorbaPrimitiveHandler);
+ CorbaPrimitiveHandler resultMember3 = (CorbaPrimitiveHandler)resultMember3Obj;
+ Object resultMember3ValueObj = resultMember3.getValue();
+ assertTrue(resultMember3ValueObj instanceof Float);
+ Float resultMember3Value = (Float)resultMember3ValueObj;
+ assertTrue(resultMember3Value.floatValue() == member3Value.floatValue());
+ }
+
+ public void testReadWriteUnionStruct() {
+ CorbaBindingImpl bindingImpl = new CorbaBindingImpl(bus, testUtils.getStaxTestEndpointReference(),
+ orb, false);
+
+ QName objName = new QName("object");
+ QName objIdlType = new QName(staxTestNamespaceURI, "TestUnion", staxTestPrefix);
+ CorbaTypeImpl type = CorbaUtils.getCorbaType(objIdlType, bindingImpl.getCorbaTypeMaps());
+ assertTrue(type instanceof Union);
+ Union unionType = (Union)type;
+ TypeCode objTypeCode = CorbaUtils.getTypeCode(orb, objIdlType, bindingImpl.getCorbaTypeMaps());
+ CorbaUnionHandler obj = new CorbaUnionHandler(objName, objIdlType, objTypeCode, unionType);
+ assertNotNull(obj);
+
+ Character unionValue = new Character('u');
+ TypeCode unionValueTC = CorbaUtils.getTypeCode(orb, CorbaConstants.NT_CORBA_WCHAR,
+ bindingImpl.getCorbaTypeMaps());
+ CorbaPrimitiveHandler unionValueObj = new CorbaPrimitiveHandler(new QName("case12"),
+ CorbaConstants.NT_CORBA_WCHAR,
+ unionValueTC,
+ null);
+ unionValueObj.setValue(unionValue);
+ Short discriminatorValue = new Short((short)1);
+ TypeCode discriminatorTC = CorbaUtils.getTypeCode(orb, unionType.getDiscriminator(),
+ bindingImpl.getCorbaTypeMaps());
+ CorbaPrimitiveHandler discriminator = new CorbaPrimitiveHandler(new QName("discriminator"),
+ unionType.getDiscriminator(),
+ discriminatorTC,
+ null);
+ discriminator.setValue(discriminatorValue);
+
+ obj.setDiscriminator(discriminator);
+ obj.setValue("1", unionValueObj);
+
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
+ outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
+
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ XMLEventWriter evtWriter = null;
+ try {
+ evtWriter = outputFactory.createXMLEventWriter(outStream);
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtWriter);
+
+ try {
+ XMLEventFactory factory = XMLEventFactory.newInstance();
+ StartElement startEl = factory.createStartElement(obj.getName(), null, null);
+ evtWriter.add(startEl);
+ bindingImpl.writeUnionToStax(obj, evtWriter, factory);
+ EndElement endEl = factory.createEndElement(obj.getName(), null);
+ evtWriter.add(endEl);
+ evtWriter.flush();
+ } catch (XMLStreamException ex) {
+
+ }
+
+ ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());
+ XMLEventReader evtReader = null;
+ try {
+ evtReader = inputFactory.createXMLEventReader(inStream);
+ // read the first tag which should be a start document
+ XMLEvent evt = evtReader.nextEvent();
+ assertTrue(evt.isStartDocument());
+ } catch (XMLStreamException ex) {
+ }
+ assertNotNull(evtReader);
+
+ CorbaObjectHandler resultObj = bindingImpl.readUnionFromStax(evtReader,
+ obj.getIdlType(),
+ obj.getTypeCode());
+ assertNotNull(resultObj);
+
+ assertTrue(resultObj instanceof CorbaUnionHandler);
+ CorbaUnionHandler result = (CorbaUnionHandler)resultObj;
+
+ CorbaObjectHandler resultDiscriminatorObj = result.getDiscriminator();
+ assertTrue(resultDiscriminatorObj instanceof CorbaPrimitiveHandler);
+ CorbaPrimitiveHandler resultDiscriminator = (CorbaPrimitiveHandler)resultDiscriminatorObj;
+ Object resultDiscValueObj = resultDiscriminator.getValue();
+ assertTrue(resultDiscValueObj instanceof Short);
+ Short resultDiscValue = (Short)resultDiscValueObj;
+ assertTrue(resultDiscValue.shortValue() == discriminatorValue.shortValue());
+
+ CorbaObjectHandler resultValueObj = result.getValue();
+ assertTrue(resultValueObj instanceof CorbaPrimitiveHandler);
+ CorbaPrimitiveHandler resultValue = (CorbaPrimitiveHandler)resultValueObj;
+ Object unionResultValueObj = resultValue.getValue();
+ assertTrue(unionResultValueObj instanceof Character);
+ Character unionResultValue = (Character)unionResultValueObj;
+ assertTrue(unionResultValue.charValue() == unionValue.charValue());
}
}
Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaObjectReaderTest.java Thu Aug 31 10:48:37 2006
@@ -32,14 +32,17 @@
import org.omg.CORBA.portable.InputStream;
import org.apache.schemas.yoko.bindings.corba.Array;
+import org.apache.schemas.yoko.bindings.corba.Enum;
+import org.apache.schemas.yoko.bindings.corba.Enumerator;
import org.apache.schemas.yoko.bindings.corba.Exception;
+import org.apache.schemas.yoko.bindings.corba.Fixed;
import org.apache.schemas.yoko.bindings.corba.MemberType;
import org.apache.schemas.yoko.bindings.corba.Sequence;
import org.apache.schemas.yoko.bindings.corba.Struct;
import org.apache.yoko.bindings.corba.types.CorbaArrayHandler;
-//import org.apache.yoko.bindings.corba.types.CorbaEnumHandler;
+import org.apache.yoko.bindings.corba.types.CorbaEnumHandler;
import org.apache.yoko.bindings.corba.types.CorbaExceptionHandler;
-//import org.apache.yoko.bindings.corba.types.CorbaFixedHandler;
+import org.apache.yoko.bindings.corba.types.CorbaFixedHandler;
import org.apache.yoko.bindings.corba.types.CorbaObjectHandler;
import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
import org.apache.yoko.bindings.corba.types.CorbaSequenceHandler;
@@ -445,4 +448,61 @@
assertTrue(new Short(((CorbaPrimitiveHandler)nestedObjs.get(0)).getValueData()).shortValue() == code);
assertTrue(((CorbaPrimitiveHandler)nestedObjs.get(1)).getValueData().equals(message));
}
+
+ public void testReadEnum() {
+ Buffer buf = new Buffer();
+ OutputStream oStream = new OutputStream(buf);
+
+ // create the following enum
+ // enum { RED, GREEN, BLUE };
+ oStream.write_long(1);
+ InputStream iStream = oStream.create_input_stream();
+ CorbaObjectReader reader = new CorbaObjectReader(iStream);
+
+ String[] enums = {"RED", "GREEN", "BLUE" };
+ Enum enumType = new Enum();
+ Enumerator enumRed = new Enumerator();
+ enumRed.setValue(enums[0]);
+ Enumerator enumGreen = new Enumerator();
+ enumGreen.setValue(enums[1]);
+ Enumerator enumBlue = new Enumerator();
+ enumBlue.setValue(enums[2]);
+ enumType.getEnumerator().add(enumRed);
+ enumType.getEnumerator().add(enumGreen);
+ enumType.getEnumerator().add(enumBlue);
+
+ // These values don't matter to the outcome of the test but are needed during construction
+ QName enumName = new QName("TestEnum");
+ QName enumIdlType = new QName("corbatm:TestEnum");
+ TypeCode enumTC = orb.create_enum_tc("IDL:TestEnum:1.0", enumName.getLocalPart(), enums);
+ CorbaEnumHandler obj = new CorbaEnumHandler(enumName, enumIdlType, enumTC, enumType);
+
+ reader.readEnum(obj);
+ assertTrue(obj.getValue().equals(enums[1]));
+ }
+
+ public void testReadFixed() {
+ Buffer buf = new Buffer();
+ OutputStream oStream = new OutputStream(buf);
+
+ // create the following fixed
+ // fixed<5,2>
+ oStream.write_fixed(new java.math.BigDecimal("12345.67").movePointRight((int)2));
+ InputStream iStream = oStream.create_input_stream();
+ CorbaObjectReader reader = new CorbaObjectReader(iStream);
+
+ Fixed fixedType = new Fixed();
+ fixedType.setDigits(5);
+ fixedType.setScale(2);
+
+ // These values don't matter to the outcome of the test but are needed during construction
+ QName fixedName = new QName("TestFixed");
+ QName fixedIdlType = new QName("corbatm:TestFixed");
+ TypeCode fixedTC = orb.create_fixed_tc((short)fixedType.getDigits(), (short)fixedType.getScale());
+ CorbaFixedHandler obj = new CorbaFixedHandler(fixedName, fixedIdlType, fixedTC, fixedType);
+
+ reader.readFixed(obj);
+
+ assertTrue(obj.getValue().equals(new java.math.BigDecimal("12345.67")));
+ }
}
Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaUtilsTest.java Thu Aug 31 10:48:37 2006
@@ -189,7 +189,7 @@
corbaBF.init(bus);
manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
- EndpointReferenceType endpoint = testUtils.getEndpointReference();
+ EndpointReferenceType endpoint = testUtils.getSimpleTestEndpointReference();
AddressType address = CorbaUtils.getCorbaAddressType(bus, endpoint);
assertNotNull(address);
}
@@ -203,7 +203,7 @@
corbaBF.init(bus);
manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
- EndpointReferenceType endpoint = testUtils.getEndpointReference();
+ EndpointReferenceType endpoint = testUtils.getSimpleTestEndpointReference();
BindingType binding = CorbaUtils.getCorbaBindingType(bus, endpoint);
assertNotNull(binding);
}
@@ -217,7 +217,7 @@
corbaBF.init(bus);
manager.registerBinding(CorbaConstants.NU_WSDL_CORBA, corbaBF);
- EndpointReferenceType endpoint = testUtils.getEndpointReference();
+ EndpointReferenceType endpoint = testUtils.getSimpleTestEndpointReference();
String opName = "testSimpleMethod";
OperationType operation = CorbaUtils.getCorbaOperationType(opName, bus, endpoint);
assertNotNull(operation);
Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java?rev=438997&r1=438996&r2=438997&view=diff
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java Thu Aug 31 10:48:37 2006
@@ -26,9 +26,15 @@
public final class TestUtils {
- public EndpointReferenceType getEndpointReference() {
+ public EndpointReferenceType getSimpleTestEndpointReference() {
URL wsdlUrl = getClass().getResource("/wsdl/simpleIdl.wsdl");
QName serviceName = new QName("http://yoko.apache.org/simple", "SimpleCORBAService");
return EndpointReferenceUtils.getEndpointReference(wsdlUrl, serviceName, "SimpleCORBAPort");
+ }
+
+ public EndpointReferenceType getStaxTestEndpointReference() {
+ URL wsdlUrl = getClass().getResource("/wsdl/StaxTest.wsdl");
+ QName serviceName = new QName("http://yoko.apache.org/StaxTest", "StaxTestCORBAService");
+ return EndpointReferenceUtils.getEndpointReference(wsdlUrl, serviceName, "StaxTestCORBAPort");
}
}
Added: incubator/yoko/trunk/bindings/src/test/resources/wsdl/StaxTest.wsdl
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/resources/wsdl/StaxTest.wsdl?rev=438997&view=auto
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/resources/wsdl/StaxTest.wsdl (added)
+++ incubator/yoko/trunk/bindings/src/test/resources/wsdl/StaxTest.wsdl Thu Aug 31 10:48:37 2006
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- To be replace by a Yoko generated IDLtoWSDL once types supported -->
+<definitions
+ targetNamespace="http://yoko.apache.org/StaxTest"
+ xmlns="http://schemas.xmlsoap.org/wsdl/"
+ xmlns:tns="http://yoko.apache.org/StaxTest"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:xsd1="http://yoko.apache.org/StaxTest/types"
+ xmlns:corba="http://schemas.apache.org/yoko/bindings/corba"
+ xmlns:corbatm="http://yoko.apache.org/StaxTest/idl_types">
+ <types>
+ <schema targetNamespace="http://yoko.apache.org/StaxTest/types"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+ <xsd:complexType name="TestArray">
+ <xsd:sequence>
+ <xsd:element name="item" type="xsd:int" minOccurs="5" maxOccurs="5"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="TestSequence">
+ <xsd:sequence>
+ <xsd:element name="item" type="xsd:short" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="TestBoundedSequence">
+ <xsd:sequence>
+ <xsd:element name="item" type="xsd:short" minOccurs="0" maxOccurs="5"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:simpleType name="TestEnum">
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="RED"/>
+ <xsd:enumeration value="GREEN"/>
+ <xsd:enumeration value="BLUE"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+ <xsd:complexType name="TestStruct">
+ <xsd:sequence>
+ <xsd:element name="boolMember" type="xsd:boolean"/>
+ <xsd:element name="stringMember" type="xsd:string"/>
+ <xsd:element name="floatMember" type="xsd:float"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:complexType name="TestUnion">
+ <xsd:choice>
+ <xsd:element name="case0" type="xsd:unsignedByte"/>
+ <xsd:element name="case12" type="xsd:string"/>
+ <xsd:element name="caseDef" type="xsd:long"/>
+ </xsd:choice>
+ </xsd:complexType>
+ <xsd:complexType name="_omg_TestUnion">
+ <xsd:sequence>
+ <xsd:element minOccurs="1" maxOccurs="1" name="discriminator" type="xsd:short"/>
+ <xsd:choice minOccurs="0" maxOccurs="1">
+ <xsd:element name="case0" type="xsd:unsignedByte"/>
+ <xsd:element name="case12" type="xsd:string"/>
+ <xsd:element name="caseDef" type="xsd:long"/>
+ </xsd:choice>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="testOp">
+ <xsd:complexType>
+ <xsd:sequence>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="testOpResult">
+ <xsd:complexType>
+ <xsd:sequence>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+ </schema>
+ </types>
+ <message name="testOp">
+ <part name="parameters" element="xsd1:testOp"/>
+ </message>
+ <message name="testOpResponse">
+ <part name="parameters" element="xsd1:testOpResult"/>
+ </message>
+ <portType name="StaxTest">
+ <operation name="testOp">
+ <input message="tns:testOp" name="testOp"/>
+ <output message="tns:testOpResponse" name="testOpResponse"/>
+ </operation>
+ </portType>
+ <binding name="StaxTestCORBABinding" type="tns:StaxTest">
+ <corba:binding repositoryID="IDL:StaxTest:1.0"/>
+ <operation name="testOp">
+ <corba:operation name="testOp"/>
+ <input/>
+ <output/>
+ </operation>
+ </binding>
+ <service name="StaxTestCORBAService">
+ <port name="StaxTestCORBAPort" binding="tns:StaxTestCORBABinding">
+ <corba:address location="corbaloc::localhost:50000/StaxTest"/>
+ </port>
+ </service>
+ <corba:typeMapping targetNamespace="http://yoko.apache.org/StaxTest/idl_types">
+ <corba:array name="TestArray" repositoryID="IDL:TestArray:1.0" type="xsd1:TestArray" elemtype="corba:long" bound="5"/>
+ <corba:sequence name="TestSequence" repositoryID="IDL:TestSequence:1.0" type="xsd1:TestSequence" elemtype="corba:short" bound="0"/>
+ <corba:sequence name="TestBoundedSequence" repositoryID="IDL:TestBoundedSequence:1.0" type="xsd1:TestBoundedSequence" elemtype="corba:short" bound="5"/>
+ <corba:fixed name="TestFixed" repositoryID="IDL:TestFixed:1.0" type="xsd:decimal" digits="5" scale="2"/>
+ <corba:enum name="TestEnum" type="xsd1:TestEnum" repositoryID="IDL:TestEnum:1.0">
+ <corba:enumerator value="RED"/>
+ <corba:enumerator value="GREEN"/>
+ <corba:enumerator value="BLUE"/>
+ </corba:enum>
+ <corba:struct name="TestStruct" type="xsd1:TestStruct" repositoryID="IDL:TestStruct:1.0">
+ <corba:member name="boolMember" idltype="corba:boolean"/>
+ <corba:member name="stringMember" idltype="corba:string"/>
+ <corba:member name="floatMember" idltype="corba:float"/>
+ </corba:struct>
+ <corba:union name="TestUnion" type="xsd1:TestUnion" discriminator="corba:short" repositoryID="IDL:TestUnion:1.0">
+ <corba:unionbranch name="case0" idltype="corba:octet">
+ <corba:case label="0"/>
+ </corba:unionbranch>
+ <corba:unionbranch name="case12" idltype="corba:wchar">
+ <corba:case label="1"/>
+ <corba:case label="2"/>
+ </corba:unionbranch>
+ <corba:unionbranch name="caseDef" idltype="corba:longlong" default="true"/>
+ </corba:union>
+ </corba:typeMapping>
+</definitions>
Propchange: incubator/yoko/trunk/bindings/src/test/resources/wsdl/StaxTest.wsdl
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/bindings/src/test/resources/wsdl/StaxTest.wsdl
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: incubator/yoko/trunk/bindings/src/test/resources/wsdl/StaxTest.wsdl
------------------------------------------------------------------------------
svn:mime-type = text/xml