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 en...@apache.org on 2006/12/07 18:11:28 UTC
svn commit: r483586 [1/4] - in /incubator/yoko/trunk/bindings/src/test:
java/org/apache/yoko/bindings/corba/
java/org/apache/yoko/bindings/corba/interceptors/
java/org/apache/yoko/bindings/corba/types/ resources/wsdl/
Author: enolan
Date: Thu Dec 7 10:11:27 2006
New Revision: 483586
URL: http://svn.apache.org/viewvc?view=rev&rev=483586
Log:
yoko-225 - porting yoko from celtix to use cxf.
Added:
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/ContextUtilsTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDSIServantTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStaxObjectTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaTypeMapTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/CorbaInInterceptorTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/CorbaOutInterceptorTest.java (with props)
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/interceptors/TestBase
incubator/yoko/trunk/bindings/src/test/resources/wsdl/exceptions.wsdl (with props)
Removed:
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingImplMarshalTest.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/CorbaBindingImplUnmarshalTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaNestedTypeTest.java
Modified:
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/CorbaMessageTest.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/CorbaObjectWriterTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaStreamableTest.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
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaAnyHandlerTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaArrayHandlerTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaEnumHandlerTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaFixedHandlerTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaHandlerUtilsTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaObjectHandlerTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaPrimitiveHandlerTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaSequenceHandlerTest.java
incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/types/CorbaStructHandlerTest.java
Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/ContextUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/ContextUtilsTest.java?view=auto&rev=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/ContextUtilsTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/ContextUtilsTest.java Thu Dec 7 10:11:27 2006
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+package org.apache.yoko.bindings.corba;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+
+/**
+ * Holder for utility methods relating to contexts.
+ */
+public final class ContextUtilsTest extends TestCase {
+
+ public ContextUtilsTest(String arg0) {
+ super(arg0);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(ContextUtilsTest.class);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ protected void tearDown() throws Exception {
+ }
+
+
+ public void testIsRequestor() throws Exception {
+ Message message = new MessageImpl();
+ message.put("org.apache.cxf.client", "org.apache.cxf.client");
+ assertEquals(ContextUtils.isRequestor(message), true);
+ }
+
+ public void testIsOutbound() throws Exception {
+ Message message = new MessageImpl();
+ Exchange exchange = new ExchangeImpl();
+ exchange.setOutMessage(message);
+ message.setExchange(exchange);
+
+ assertEquals(ContextUtils.isOutbound(message), true);
+ }
+
+}
+
\ No newline at end of file
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/ContextUtilsTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/ContextUtilsTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
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?view=diff&rev=483586&r1=483585&r2=483586
==============================================================================
--- 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 Dec 7 10:11:27 2006
@@ -18,22 +18,44 @@
*/
package org.apache.yoko.bindings.corba;
-import javax.xml.ws.Binding;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
import junit.framework.TestCase;
-import org.apache.yoko.wsdl.CorbaConstants;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactoryHelper;
+import org.apache.cxf.binding.BindingFactory;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.BindingFactoryManagerImpl;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl11.WSDLServiceFactory;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
-import org.objectweb.celtix.Bus;
-import org.objectweb.celtix.bindings.BindingFactory;
-import org.objectweb.celtix.bindings.BindingManager;
-import org.objectweb.celtix.bindings.ClientBinding;
-import org.objectweb.celtix.bindings.ServerBinding;
-import org.objectweb.celtix.ws.addressing.EndpointReferenceType;
+import org.apache.yoko.wsdl.CorbaConstants;
public class CorbaBindingFactoryTest extends TestCase {
-
- private TestUtils testUtils;
+
+ protected Bus bus;
+ protected EndpointInfo endpointInfo;
+ protected EndpointReferenceType target;
+ protected MessageObserver observer;
+ protected Message inMessage;
+ CorbaBindingFactory factory;
public CorbaBindingFactoryTest(String arg0) {
super(arg0);
@@ -45,55 +67,107 @@
protected void setUp() throws Exception {
super.setUp();
-
- testUtils = new TestUtils();
+ System.setProperty("cxf.config.file", "cxf-extension-corba.xml");
+ bus = BusFactoryHelper.newInstance().getDefaultBus();
+ BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
+ factory = (CorbaBindingFactory)bfm.getBindingFactory("http://schemas.apache.org/yoko/bindings/corba");
+ bfm.registerBindingFactory(CorbaConstants.NU_WSDL_CORBA, factory);
+ }
+
+ public void tearDown() {
+ bus.shutdown(true);
+ }
+
+ protected void setupServiceInfo(String ns, String wsdl, String serviceName, String portName) {
+ URL wsdlUrl = getClass().getResource(wsdl);
+ assertNotNull(wsdlUrl);
+ WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlUrl, new QName(ns, serviceName));
+
+ Service service = factory.create();
+ endpointInfo = service.getServiceInfo().getEndpoint(new QName(ns, portName));
+
}
+
+ public void testCreateBinding() throws Exception {
+ IMocksControl control = EasyMock.createNiceControl();
+ BindingInfo bindingInfo = control.createMock(BindingInfo.class);
- public void testCreateClientBinding() 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);
-
- BindingFactory factory =
- bus.getBindingManager().getBindingFactory("http://schemas.apache.org/yoko/bindings/corba");
-
- EndpointReferenceType address = testUtils.getSimpleTestEndpointReference();
-
- ClientBinding cb = factory.createClientBinding(address);
- assertNotNull(cb);
- assertTrue(CorbaClientBinding.class.isInstance(cb));
-
- CorbaClientBinding clientBinding = (CorbaClientBinding)cb;
- Binding binding = clientBinding.getBinding();
+ CorbaBinding binding = (CorbaBinding)factory.createBinding(bindingInfo);
assertNotNull(binding);
- assertTrue(CorbaBindingImpl.class.isInstance(binding));
+ assertTrue(CorbaBinding.class.isInstance(binding));
+ List<Interceptor> inInterceptors = binding.getInInterceptors();
+ assertNotNull(inInterceptors);
+ List<Interceptor> outInterceptors = binding.getOutInterceptors();
+ assertNotNull(outInterceptors);
+ assertEquals(1, inInterceptors.size());
+ assertEquals(1, outInterceptors.size());
+ }
+
+ public void testGetCorbaConduit() throws Exception {
+ setupServiceInfo("http://yoko.apache.org/simple",
+ "/wsdl/simpleIdl.wsdl",
+ "SimpleCORBAService",
+ "SimpleCORBAPort");
+
+ Conduit conduit = factory.getConduit(endpointInfo);
+ assertNotNull(conduit);
+ target = EasyMock.createMock(EndpointReferenceType.class);
+ conduit = factory.getConduit(endpointInfo, target);
+ assertNotNull(conduit);
+ }
+
+ public void testGetDestination() throws Exception {
+ setupServiceInfo("http://yoko.apache.org/simple",
+ "/wsdl/simpleIdl.wsdl",
+ "SimpleCORBAService",
+ "SimpleCORBAPort");
+
+ Destination destination = factory.getDestination(endpointInfo);
+ assertNotNull(destination);
+ target = destination.getAddress();
+ assertNotNull(target);
}
- public void testCreateServerBinding() 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);
-
- BindingFactory factory =
- bus.getBindingManager().getBindingFactory("http://schemas.apache.org/yoko/bindings/corba");
-
- EndpointReferenceType address = testUtils.getSimpleTestEndpointReference();
-
- ServerBinding sb = factory.createServerBinding(address, null);
- assertNotNull(sb);
- assertTrue(CorbaServerBinding.class.isInstance(sb));
+ public void testTransportIds() throws Exception {
+ setupServiceInfo("http://yoko.apache.org/simple",
+ "/wsdl/simpleIdl.wsdl",
+ "SimpleCORBAService",
+ "SimpleCORBAPort");
+
+ List<String> strs = new ArrayList<String>();
+ strs.add("one");
+ strs.add("two");
+ factory.setTransportIds(strs);
+ List<String> retStrs = factory.getTransportIds();
+ assertNotNull(retStrs);
+ String str = retStrs.get(0);
+ assertEquals("one", str.toString());
+ str = retStrs.get(1);
+ assertEquals("two", str.toString());
+ }
+
+ public void testGetUriPrefixes() throws Exception {
+ Set<String> prefixes = factory.getUriPrefixes();
+ assertNotNull("Prefixes should not be null", prefixes != null);
+ }
+
+ // check this
+ public void testSetBus() throws Exception {
+ factory.setBus(bus);
+ }
+
+ // check this
+ public void testSetActivationNamespaces() throws Exception {
+ Collection<String> strs = new ArrayList<String>();
+ strs.add("http://schemas.apache.org/yoko/bindings/corba");
+ }
+
+ public void testRegisterSelf() throws Exception {
- CorbaServerBinding serverBinding = (CorbaServerBinding)sb;
- Binding binding = serverBinding.getBinding();
- assertNotNull(binding);
- assertTrue(CorbaBindingImpl.class.isInstance(binding));
}
+
+ public void testRegisterWithBindingManager() throws Exception {
+
+ }
+
}
Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingTest.java?view=auto&rev=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingTest.java Thu Dec 7 10:11:27 2006
@@ -0,0 +1,112 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.yoko.bindings.corba;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Binding;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactoryHelper;
+import org.apache.cxf.binding.BindingFactory;
+import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.binding.BindingFactoryManagerImpl;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.Conduit;
+import org.apache.cxf.transport.Destination;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl11.WSDLServiceFactory;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.apache.cxf.wsdl.EndpointReferenceUtils;
+import org.omg.CORBA.ORB;
+
+import org.apache.yoko.wsdl.CorbaConstants;
+
+public class CorbaBindingTest extends TestCase {
+
+ private ORB orb;
+
+ public CorbaBindingTest(String arg0) {
+ super(arg0);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(CorbaBindingFactoryTest.class);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ java.util.Properties props = System.getProperties();
+ props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.id", "Yoko-Server-Binding");
+ orb = ORB.init(new String[0], props);
+ }
+
+ public void tearDown() {
+ if (orb != null) {
+ try {
+ orb.destroy();
+ } catch (Exception ex) {
+ // Do nothing. Throw an Exception?
+ }
+ }
+ }
+
+ public void testCorbaBinding() {
+ CorbaBinding binding = new CorbaBinding();
+ List<Interceptor> in = binding.getInInterceptors();
+ assertNotNull(in);
+ List<Interceptor> out = binding.getOutInterceptors();
+ assertNotNull(out);
+ List<Interceptor> infault = binding.getFaultInInterceptors();
+ assertNotNull(infault);
+ List<Interceptor> outfault = binding.getFaultOutInterceptors();
+ assertNotNull(outfault);
+ Message message = binding.createMessage();
+ message.put(ORB.class, orb);
+ assertNotNull(message);
+ ORB corbaORB = message.get(ORB.class);
+ assertNotNull(corbaORB);
+ MessageImpl mesage = new MessageImpl();
+ mesage.put(ORB.class, orb);
+ Message msg = binding.createMessage(mesage);
+ assertNotNull(msg);
+ ORB corbaOrb = msg.get(ORB.class);
+ assertNotNull(corbaOrb);
+ /*List<Interceptor> infault = binding.getInFaultInterceptors();
+ assertEquals(1, infault.size());
+ List<Interceptor> outfault = binding.getOutFaultInterceptors();
+ assertEquals(1, fault.size());*/
+ }
+
+}
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaBindingTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java?view=auto&rev=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java Thu Dec 7 10:11:27 2006
@@ -0,0 +1,395 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.yoko.bindings.corba;
+
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.xml.namespace.QName;
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactoryHelper;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.message.Exchange;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.model.BindingOperationInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.service.model.ServiceInfo;
+
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.apache.cxf.wsdl11.WSDLServiceFactory;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.Context;
+import org.omg.CORBA.ContextList;
+import org.omg.CORBA.ExceptionList;
+import org.omg.CORBA.NamedValue;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Request;
+import org.omg.CORBA.TCKind;
+import org.omg.CORBA.TypeCode;
+
+import org.apache.schemas.yoko.bindings.corba.OperationType;
+import org.apache.schemas.yoko.bindings.corba.RaisesType;
+import org.apache.schemas.yoko.bindings.corba.TypeMappingType;
+import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
+import org.apache.yoko.orb.CORBA.NVList;
+import org.apache.yoko.wsdl.CorbaConstants;
+
+public class CorbaConduitTest extends TestCase {
+
+ private static IMocksControl control;
+ private static ORB orb;
+ private static Bus bus;
+ protected EndpointInfo endpointInfo;
+ protected EndpointReferenceType target;
+ protected MessageObserver observer;
+ Message inMessage;
+ CorbaBindingFactory factory;
+ TestUtils testUtils;
+
+ public CorbaConduitTest(String arg0) {
+ super(arg0);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(CorbaBindingFactoryTest.class);
+ }
+
+ public void setUp() throws Exception {
+ control = EasyMock.createNiceControl();
+
+ bus = BusFactoryHelper.newInstance().getDefaultBus();
+
+ java.util.Properties props = System.getProperties();
+ props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.id", "Yoko-Server-Binding");
+ orb = ORB.init(new String[0], props);
+ }
+
+ public void tearDown() {
+ if (orb != null) {
+ try {
+ orb.destroy();
+ } catch (Exception ex) {
+ // Do nothing. Throw an Exception?
+ }
+ }
+ }
+
+ public void testCorbaConduit() throws Exception {
+ CorbaConduit conduit = setupCorbaConduit(false);
+ assertTrue("conduit should not be null", conduit != null);
+ }
+
+ public void testSend() throws Exception {
+ setupServiceInfo("http://yoko.apache.org/simple",
+ "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
+ "SimpleCORBAPort");
+
+ CorbaDestination destination = new CorbaDestination(endpointInfo);
+ CorbaConduit conduit = new CorbaConduit(endpointInfo, destination.getAddress());
+ Message message = new MessageImpl();
+ try {
+ conduit.send(message);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ OutputStream os = message.getContent(OutputStream.class);
+ assertTrue("OutputStream should not be null", os != null);
+ ORB orb = (ORB)message.get("orb");
+ assertTrue("Orb should not be null", orb != null);
+ Object obj = message.get("endpoint");
+ assertTrue("EndpointReferenceType should not be null", obj != null);
+ }
+
+
+ public void testGetTargetReference() throws Exception {
+ setupServiceInfo("http://yoko.apache.org/simple",
+ "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
+ "SimpleCORBAPort");
+
+ CorbaDestination destination = new CorbaDestination(endpointInfo);
+ CorbaConduit conduit = new CorbaConduit(endpointInfo, destination.getAddress());
+
+ EndpointReferenceType t = null;
+ EndpointReferenceType ref = conduit.getTargetReference(t);
+ assertTrue("ref should not be null", ref != null);
+ }
+
+ public void testGetAddress() throws Exception {
+ setupServiceInfo("http://yoko.apache.org/simple",
+ "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
+ "SimpleCORBAPort");
+
+ CorbaDestination destination = new CorbaDestination(endpointInfo);
+ endpointInfo.setAddress("corbaloc::localhost:40000/Simple");
+ CorbaConduit conduit = new CorbaConduit(endpointInfo, destination.getAddress());
+ String address = conduit.getAddress();
+ assertTrue("address should not be null", address != null);
+ assertEquals(address, "corbaloc::localhost:40000/Simple");
+ }
+
+ public void testClose() throws Exception {
+ Method m = CorbaConduit.class.getDeclaredMethod("buildRequest",
+ new Class[] {CorbaMessage.class, OperationType.class});
+ CorbaConduit conduit = EasyMock.createMock(CorbaConduit.class, new Method[] {m});
+
+ CorbaMessage msg = control.createMock(CorbaMessage.class);
+ Exchange exg = control.createMock(Exchange.class);
+ EasyMock.expect(msg.getExchange()).andReturn(exg);
+ BindingOperationInfo bopInfo = control.createMock(BindingOperationInfo.class);
+ EasyMock.expect(exg.get(BindingOperationInfo.class)).andReturn(bopInfo);
+ OperationType opType = control.createMock(OperationType.class);
+ bopInfo.getExtensor(OperationType.class);
+ EasyMock.expectLastCall().andReturn(opType);
+ conduit.buildRequest(msg, opType);
+ EasyMock.expectLastCall();
+ OutputStream os =control.createMock(OutputStream.class);
+ EasyMock.expect(msg.getContent(OutputStream.class)).andReturn(os);
+ os.close();
+ EasyMock.expectLastCall();
+
+ control.replay();
+ conduit.close(msg);
+ control.verify();
+ }
+
+ public void testGetTarget() throws Exception {
+ CorbaConduit conduit = setupCorbaConduit(false);
+ EndpointReferenceType endpoint = conduit.getTarget();
+ assertTrue("EndpointReferenceType should not be null", endpoint != null);
+ }
+
+ public void testGetOperationExceptions() {
+ CorbaConduit conduit = control.createMock(CorbaConduit.class);
+ OperationType opType = control.createMock(OperationType.class);
+ List<CorbaTypeMap> typeMaps = control.createMock(List.class);
+
+ Map<TypeCode, RaisesType> exceptions = control.createMock(HashMap.class);
+ List<RaisesType> exlist = control.createMock(ArrayList.class);
+ opType.getRaises();
+ EasyMock.expectLastCall().andReturn(exlist);
+ int i = 0;
+ EasyMock.expect(exlist.size()).andReturn(i);
+ RaisesType rType = control.createMock(RaisesType.class);
+ EasyMock.expect(exlist.get(0)).andReturn(rType);
+
+ control.replay();
+ conduit.getOperationExceptions(opType, typeMaps);
+ assertEquals(exlist.size(),0);
+ }
+
+ public void testBuildRequest() throws Exception {
+ CorbaConduit conduit = setupCorbaConduit(false);
+ CorbaMessage message = control.createMock(CorbaMessage.class);
+ Exchange exchange = control.createMock(Exchange.class);
+ EasyMock.expect(message.getExchange());
+ EasyMock.expectLastCall().andReturn(exchange);
+ ServiceInfo service = control.createMock(ServiceInfo.class);
+ EasyMock.expect(exchange.get(ServiceInfo.class)).andReturn(service);
+ List<CorbaTypeMap> list = control.createMock(List.class);
+ EasyMock.expect(service.getExtensors(CorbaTypeMap.class)).andReturn(list);
+
+ OperationType opType = control.createMock(OperationType.class);
+ conduit.getArguments(message);
+ EasyMock.expectLastCall().andReturn(null);
+ conduit.getReturn(message);
+ EasyMock.expectLastCall().andReturn(null);
+ conduit.getExceptionList(message, opType, list);
+ EasyMock.expectLastCall().andReturn(null);
+
+ conduit.invokeRequest(message, "Hello", null, null, null);
+ EasyMock.expectLastCall();
+ }
+
+ public void testBuildArguments() throws Exception {
+ CorbaStreamable[] arguments = new CorbaStreamable[1];
+ QName objName = new QName("object");
+ QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
+ TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
+ CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
+ CorbaStreamable arg = new CorbaStreamable(obj1, objName);
+ arguments[0] = arg;
+ arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
+
+ CorbaConduit conduit = setupCorbaConduit(false);
+ Message msg = new MessageImpl();
+ CorbaMessage message = new CorbaMessage(msg);
+ NVList list = (NVList)conduit.getArguments(message);
+ assertNotNull("list should not be null", list != null);
+
+ message.setStreamableArguments(arguments);
+ NVList listArgs = (NVList)conduit.getArguments(message);
+ assertNotNull("listArgs should not be null", listArgs != null);
+ assertNotNull("listArgs Item should not be null", listArgs.item(0) != null);
+ assertEquals("Name should be equal", listArgs.item(0).name(), "object");
+ assertEquals("flags should be 2", listArgs.item(0).flags(), 2);
+ assertNotNull("Any Value should not be null", listArgs.item(0).value() != null);
+ }
+
+ public void testBuildReturn() throws Exception {
+ QName objName = new QName("returnName");
+ QName objIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
+ TypeCode objTypeCode = orb.get_primitive_tc(TCKind.tk_short);
+ CorbaPrimitiveHandler obj1 = new CorbaPrimitiveHandler(objName, objIdlType, objTypeCode, null);
+ CorbaStreamable arg = new CorbaStreamable(obj1, objName);
+
+ CorbaConduit conduit = setupCorbaConduit(false);
+ Message msg = new MessageImpl();
+ CorbaMessage message = new CorbaMessage(msg);
+ NamedValue ret = (NamedValue)conduit.getReturn(message);
+ assertNotNull("Return should not be null", ret != null);
+ assertEquals("name should be equal", ret.name(), "return");
+
+ message.setStreamableReturn(arg);
+ NamedValue ret2 = (NamedValue)conduit.getReturn(message);
+ assertNotNull("Return2 should not be null", ret2 != null);
+ assertEquals("name should be equal", ret2.name(), "returnName");
+ }
+
+ public void testBuildExceptionListEmpty() throws Exception {
+ CorbaConduit conduit = setupCorbaConduit(false);
+ Message msg = new MessageImpl();
+ CorbaMessage message = new CorbaMessage(msg);
+ List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
+ OperationType opType = new OperationType();
+ opType.setName("review_data");
+ ExceptionList exList = conduit.getExceptionList(message, opType, typeMaps);
+ assertNotNull("ExcepitonList is not null", exList != null);
+ assertEquals("The list should be empty", exList.count(), 0);
+ }
+
+ public void testBuildExceptionListWithExceptions() throws Exception {
+ CorbaConduit conduit = setupCorbaConduit(false);
+ Message msg = new MessageImpl();
+ CorbaMessage message = new CorbaMessage(msg);
+ List<CorbaTypeMap> typeMaps = new ArrayList<CorbaTypeMap>();
+ TestUtils testUtils = new TestUtils();
+ CorbaDestination destination = testUtils.getExceptionTypesTestDestination();
+ EndpointInfo endpointInfo = destination.getEndPointInfo();
+ QName name = new QName("http://schemas.apache.org/idl/except", "review_data", "");
+ BindingOperationInfo bInfo = destination.getBindingInfo().getOperation(name);
+ OperationType opType = bInfo.getExtensor(OperationType.class);
+
+ List<TypeMappingType> corbaTypes = endpointInfo.getService().getExtensors(TypeMappingType.class);
+ if (corbaTypes != null) {
+ CorbaUtils.createCorbaTypeMap(typeMaps, corbaTypes);
+ }
+
+ ExceptionList exList = conduit.getExceptionList(message, opType, typeMaps);
+
+ assertNotNull("ExcepitonList is not null", exList != null);
+ assertNotNull("TypeCode is not null", exList.item(0) != null);
+ assertEquals("ID should be equal", exList.item(0).id(), "IDL:BadRecord:1.0");
+ assertEquals("ID should be equal", exList.item(0).name(), "BadRecord");
+ assertEquals("ID should be equal", exList.item(0).member_count(), 2);
+ assertEquals("ID should be equal", exList.item(0).member_name(0), "reason");
+ assertNotNull("Member type is not null", exList.item(0).member_type(0) != null);
+ }
+
+ public void testInvoke() throws Exception {
+ CorbaConduit conduit = setupCorbaConduit(false);
+ Message msg = new MessageImpl();
+ //CorbaMessage message = new CorbaMessage(msg);
+ CorbaMessage message= control.createMock(CorbaMessage.class);
+ /*String opName = "GreetMe";
+ NVList nvlist = (NVList)orb.create_list(0);
+
+ conduit.invokeRequest(message, "GreetMe", nvlist, null, null);*/
+
+ org.omg.CORBA.Object obj = control.createMock(org.omg.CORBA.Object.class);
+ EasyMock.expect(message.get(CorbaConstants.CORBA_ENDPOINT_OBJECT)).andReturn(obj);
+ //msg.put(CorbaConstants.CORBA_ENDPOINT_OBJECT, obj);
+ Request r = control.createMock(Request.class);
+ NVList nvList = (NVList)orb.create_list(0);
+ NamedValue ret = control.createMock(NamedValue.class);
+ ExceptionList exList = control.createMock(ExceptionList.class);
+
+ EasyMock.expect(obj._create_request(EasyMock.isA(Context.class),
+ EasyMock.eq("greetMe"),
+ EasyMock.isA(NVList.class),
+ EasyMock.isA(NamedValue.class),
+ EasyMock.isA(ExceptionList.class),
+ EasyMock.isA(ContextList.class)));
+ EasyMock.expectLastCall().andReturn(r);
+ r.invoke();
+ EasyMock.expectLastCall();
+
+ control.replay();
+ conduit.invokeRequest(message, "greetMe", nvList, ret, exList);
+ control.verify();
+
+ /* try {
+ ContextList ctxList = orb.create_context_list();
+ Context ctx = orb.get_default_context();
+ org.omg.CORBA.Object targetObj = (org.omg.CORBA.Object)message
+ .get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
+ Request request = targetObj._create_request(ctx, opName, list, ret, exList, ctxList);
+ request.invoke();
+
+ } catch (java.lang.Exception ex) {
+ ex.printStackTrace();
+ }*/
+ }
+
+ protected CorbaConduit setupCorbaConduit(boolean send) {
+ target = EasyMock.createMock(EndpointReferenceType.class);
+ endpointInfo = EasyMock.createMock(EndpointInfo.class);
+ CorbaConduit corbaConduit = new CorbaConduit(endpointInfo, target);
+
+ if (send) {
+ // setMessageObserver
+ observer = new MessageObserver() {
+ public void onMessage(Message m) {
+ inMessage = m;
+ }
+ };
+ corbaConduit.setMessageObserver(observer);
+ }
+
+ return corbaConduit;
+ }
+
+ protected void setupServiceInfo(String ns, String wsdl, String serviceName, String portName) {
+ URL wsdlUrl = getClass().getResource(wsdl);
+ assertNotNull(wsdlUrl);
+ WSDLServiceFactory factory = new WSDLServiceFactory(bus, wsdlUrl, new QName(ns, serviceName));
+
+ Service service = factory.create();
+ endpointInfo = service.getServiceInfo().getEndpoint(new QName(ns, portName));
+
+ }
+
+
+
+
+}
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDSIServantTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDSIServantTest.java?view=auto&rev=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDSIServantTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDSIServantTest.java Thu Dec 7 10:11:27 2006
@@ -0,0 +1,133 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.yoko.bindings.corba;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactoryHelper;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.ServiceImpl;
+import org.apache.cxf.transport.ChainInitiationObserver;
+import org.apache.cxf.transport.MessageObserver;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.ServerRequest;
+import org.omg.PortableServer.POA;
+
+public class CorbaDSIServantTest extends TestCase {
+ protected static ORB orb;
+ protected static Bus bus;
+ private static TestUtils testUtils;
+
+ public CorbaDSIServantTest() {
+ super();
+ }
+
+ public CorbaDSIServantTest(String arg0) {
+ super(arg0);
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(CorbaDSIServantTest.class);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ bus = BusFactoryHelper.newInstance().getDefaultBus();
+ java.util.Properties props = System.getProperties();
+ props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
+ props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
+ props.put("yoko.orb.id", "Yoko-Server-Binding");
+ orb = ORB.init(new String[0], props);
+ testUtils = new TestUtils();
+
+ }
+
+ public void tearDown() throws Exception {
+ super.tearDown();
+ if (orb != null) {
+ try {
+ orb.destroy();
+ } catch (Exception ex) {
+ // Do nothing. Throw an Exception?
+ }
+ }
+ }
+
+ /*public void testCorbaDSIServant() throws Exception {
+
+ CorbaDestination destination = testUtils.getSimpleTypesTestDestination();
+ Service service = new ServiceImpl();
+ Endpoint endpoint = new EndpointImpl(bus, service, destination.getEndPointInfo());
+ MessageObserver observer = new ChainInitiationObserver(endpoint, bus);
+ destination.setMessageObserver(observer);
+ POA rootPOA = null;
+ CorbaDSIServant dsiServant = new CorbaDSIServant();
+ dsiServant.init(orb,
+ rootPOA,
+ destination,
+ observer);
+
+ assertNotNull("DSIServant should not be null", dsiServant != null);
+ assertNotNull("POA should not be null", dsiServant._default_POA() != null);
+ assertNotNull("Destination should not be null", dsiServant.getDestination() != null);
+ assertNotNull("ORB should not be null", dsiServant.getOrb() != null);
+ assertNotNull("MessageObserver should not be null", dsiServant.getObserver() != null);
+
+ byte[] objectId = new byte[10];
+ String[] interfaces = dsiServant._all_interfaces(rootPOA, objectId);
+ assertNotNull("Interfaces should not be null", interfaces != null);
+ assertEquals("Interface ID should be equal", interfaces[0], "IDL:Simple:1.0");
+
+ }*/
+
+ public void testInvoke() throws Exception {
+ CorbaDSIServant dsiServant = new CorbaDSIServant();
+ IMocksControl control = EasyMock.createNiceControl();
+ ServerRequest request = EasyMock.createMock(ServerRequest.class);
+ Message msg = EasyMock.createMock(Message.class);
+ String opName = "greetMe";
+ EasyMock.expect(request.operation()).andReturn(opName);
+ MessageObserver incomingObserver = new TestObserver();
+ dsiServant.setObserver(incomingObserver);
+
+ control.replay();
+ dsiServant.invoke(request);
+ control.verify();
+ }
+
+ class TestObserver implements MessageObserver {
+
+ TestObserver() {
+ super();
+ }
+
+ public void onMessage(Message msg) {
+ System.out.println("Test OnMessage in TestObserver");
+ }
+ }
+}
+
+
+
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDSIServantTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDSIServantTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java?view=auto&rev=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java (added)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java Thu Dec 7 10:11:27 2006
@@ -0,0 +1,106 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.yoko.bindings.corba;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactoryHelper;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.EndpointImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.Service;
+import org.apache.cxf.service.ServiceImpl;
+import org.apache.cxf.service.model.BindingInfo;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.ChainInitiationObserver;
+import org.apache.cxf.transport.MessageObserver;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+
+public class CorbaDestinationTest extends TestCase {
+
+ protected static TestUtils testUtils;
+ EndpointInfo endpointInfo;
+
+ public CorbaDestinationTest() {
+ super();
+ }
+
+ public static void main(String[] args) {
+ junit.textui.TestRunner.run(CorbaDestinationTest.class);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ testUtils = new TestUtils();
+ }
+
+ public void tearDown() {
+ }
+
+ public void testDestination() throws Exception {
+ endpointInfo = testUtils.setupServiceInfo("http://yoko.apache.org/simple",
+ "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
+ "SimpleCORBAPort");
+ CorbaDestination destination = new CorbaDestination(endpointInfo);
+
+ EndpointReferenceType rtype = destination.getAddress();
+ assertTrue("EndpointReferenceType should not be null", rtype != null);
+ BindingInfo bindingInfo = destination.getBindingInfo();
+ assertTrue("BindingInfo should not be null", bindingInfo != null);
+ EndpointInfo endpointInfo = destination.getEndPointInfo();
+ assertTrue("EndpointInfo should not be null", endpointInfo != null);
+
+ Message m = new MessageImpl();
+ CorbaServerConduit serverConduit = (CorbaServerConduit)destination.getBackChannel(m, m, rtype);
+ assertTrue("CorbaServerConduit should not be null", serverConduit != null);
+ }
+
+ /*public void testSetMessageObserverActivate() throws Exception {
+ endpointInfo = testUtils.setupServiceInfo("http://yoko.apache.org/simple",
+ "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
+ "SimpleCORBAPort");
+ CorbaDestination destination = new CorbaDestination(endpointInfo);
+ String addr = destination.getAddressType().getLocation();
+ assertEquals(addr, "corbaloc::localhost:40000/Simple");
+
+ Bus bus = BusFactoryHelper.newInstance().getDefaultBus();
+ Service service = new ServiceImpl();
+ Endpoint endpoint = new EndpointImpl(bus, service, endpointInfo);
+ MessageObserver observer = new ChainInitiationObserver(endpoint, bus);
+ destination.setMessageObserver(observer);
+ assertTrue("orb should not be null", destination.getOrb() != null);
+
+ try {
+ File file = new File("endpoint.ior");
+ assertEquals(true,file.exists());
+ } finally {
+ new File("endpoint.ior").deleteOnExit();
+ }
+
+ addr = destination.getAddressType().getLocation();
+ addr = addr.substring(0,4);
+ assertEquals(addr, "IOR:");
+ destination.shutdown();
+ }*/
+
+}
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaMessageTest.java?view=diff&rev=483586&r1=483585&r2=483586
==============================================================================
--- incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaMessageTest.java (original)
+++ incubator/yoko/trunk/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaMessageTest.java Thu Dec 7 10:11:27 2006
@@ -18,97 +18,126 @@
*/
package org.apache.yoko.bindings.corba;
-import java.util.Properties;
import javax.xml.namespace.QName;
import junit.framework.TestCase;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.service.model.BindingInfo;
import org.apache.yoko.bindings.corba.types.CorbaPrimitiveHandler;
import org.apache.yoko.wsdl.CorbaConstants;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.NVList;
import org.omg.CORBA.ORB;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
public class CorbaMessageTest extends TestCase {
- private ORB orb;
-
+ private static ORB orb;
+ private Message message;
+
public CorbaMessageTest(String arg0) {
super(arg0);
}
-
+
public static void main(String[] args) {
junit.textui.TestRunner.run(CorbaMessageTest.class);
}
-
+
protected void setUp() throws Exception {
super.setUp();
-
- java.util.Properties props = new Properties();
- props.putAll(System.getProperties());
+
+ java.util.Properties props = System.getProperties();
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
props.put("yoko.orb.id", "Yoko-Server-Binding");
orb = ORB.init(new String[0], props);
+ IMocksControl control = EasyMock.createNiceControl();
+ message = control.createMock(Message.class);
}
-
- protected void tearDown() throws Exception {
- if (orb != null) {
- try {
- orb.destroy();
- } catch (Exception ex) {
- // Do nothing. Throw an Exception?
- }
- }
- }
-
- public void testCreateCorbaMessage() {
- CorbaMessage msg = new CorbaMessage();
+
+ public void testCreateCorbaMessage(Message message) {
+ CorbaMessage msg = new CorbaMessage(message);
assertNotNull(msg);
}
-
+
public void testGetCorbaMessageAttributes() {
- CorbaMessage msg = new CorbaMessage();
-
- msg.setOperationName("TestOperationName");
- String opName = msg.getOperationName();
- assertTrue(opName.equals("TestOperationName"));
-
+ CorbaMessage msg = new CorbaMessage(message);
+
QName param1Name = new QName("param1");
QName param1IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
TypeCode param1TypeCode = orb.get_primitive_tc(TCKind.tk_long);
CorbaPrimitiveHandler param1 = new CorbaPrimitiveHandler(param1Name, param1IdlType, param1TypeCode, null);
CorbaStreamable p1 = new CorbaStreamable(param1, param1Name);
-
+
QName param2Name = new QName("param2");
QName param2IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
TypeCode param2TypeCode = orb.get_primitive_tc(TCKind.tk_string);
CorbaPrimitiveHandler param2 = new CorbaPrimitiveHandler(param2Name, param2IdlType, param2TypeCode, null);
CorbaStreamable p2 = new CorbaStreamable(param2, param2Name);
-
+
msg.addStreamableArgument(p1);
msg.addStreamableArgument(p2);
-
+
CorbaStreamable[] arguments = msg.getStreamableArguments();
assertTrue(arguments.length == 2);
assertNotNull(arguments[0]);
assertNotNull(arguments[1]);
-
+
+ QName param3Name = new QName("param3");
+ QName param3IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
+ TypeCode param3TypeCode = orb.get_primitive_tc(TCKind.tk_short);
+ CorbaPrimitiveHandler param3 = new CorbaPrimitiveHandler(param3Name, param3IdlType, param3TypeCode, null);
+ CorbaStreamable p3 = new CorbaStreamable(param3, param3Name);
+
+ QName param4Name = new QName("param4");
+ QName param4IdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "float", CorbaConstants.NP_WSDL_CORBA);
+ TypeCode param4TypeCode = orb.get_primitive_tc(TCKind.tk_float);
+ CorbaPrimitiveHandler param4 = new CorbaPrimitiveHandler(param4Name, param4IdlType, param4TypeCode, null);
+ CorbaStreamable p4 = new CorbaStreamable(param4, param4Name);
+
+ CorbaStreamable[] args = new CorbaStreamable[2];
+ args[0] = p3;
+ args[1] = p4;
+ msg.setStreamableArguments(args);
+
+ arguments = msg.getStreamableArguments();
+ assertTrue(arguments.length == 4);
+ assertNotNull(arguments[0]);
+ assertNotNull(arguments[1]);
+ assertNotNull(arguments[2]);
+ assertNotNull(arguments[3]);
+
+ NVList list = orb.create_list(2);
+ Any value = orb.create_any();
+ value.insert_Streamable(p1);
+ list.add_value(p1.getName(), value, p1.getMode());
+ value.insert_Streamable(p2);
+ list.add_value(p2.getName(), value, p2.getMode());
+
+ msg.setList(list);
+ NVList resultList = msg.getList();
+ assertTrue(resultList.count() == 2);
+
QName returnName = new QName("param2");
QName returnIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
TypeCode returnTypeCode = orb.get_primitive_tc(TCKind.tk_boolean);
CorbaPrimitiveHandler returnValue = new CorbaPrimitiveHandler(returnName, returnIdlType, returnTypeCode, null);
CorbaStreamable ret = new CorbaStreamable(returnValue, returnName);
-
+
msg.setStreamableReturn(ret);
CorbaStreamable retVal = msg.getStreamableReturn();
assertNotNull(retVal);
-
- Exception ex = new CorbaBindingException("TestException");
- msg.setException(ex);
+
+ // NEED TO DO TEST FOR EXCEPTIONS
+ /*Exception ex = new CorbaBindingException("TestException");
+ msg.s.setException(ex);
Exception msgEx = msg.getException();
assertNotNull(msgEx);
- assertTrue(msgEx.getMessage().equals(ex.getMessage()));
+ assertTrue(msgEx.getMessage().equals(ex.getMessage()));*/
}
}
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?view=diff&rev=483586&r1=483585&r2=483586
==============================================================================
--- 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 Dec 7 10:11:27 2006
@@ -20,7 +20,6 @@
import java.math.BigInteger;
import java.util.List;
-import java.util.Properties;
import javax.xml.namespace.QName;
@@ -50,31 +49,31 @@
import org.apache.yoko.bindings.corba.types.CorbaStructHandler;
import org.apache.yoko.orb.CORBA.OutputStream;
import org.apache.yoko.orb.OCI.Buffer;
+
import org.apache.yoko.wsdl.CorbaConstants;
public class CorbaObjectReaderTest extends TestCase {
- private ORB orb;
-
+ private static ORB orb;
+
public CorbaObjectReaderTest(String arg0) {
super(arg0);
}
-
+
public static void main(String[] args) {
junit.textui.TestRunner.run(CorbaObjectReaderTest.class);
}
-
+
protected void setUp() throws java.lang.Exception {
super.setUp();
- java.util.Properties props = new Properties();
- props.putAll(System.getProperties());
+ java.util.Properties props = System.getProperties();
props.put("org.omg.CORBA.ORBClass", "org.apache.yoko.orb.CORBA.ORB");
props.put("org.omg.CORBA.ORBSingletonClass", "org.apache.yoko.orb.CORBA.ORBSingleton");
props.put("yoko.orb.id", "Yoko-Binding");
orb = ORB.init(new String[0], props);
}
-
+
protected void tearDown() throws java.lang.Exception {
if (orb != null) {
try {
@@ -89,175 +88,175 @@
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_boolean(true);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Boolean boolValue = reader.readBoolean();
assertTrue(boolValue.booleanValue() == true);
}
-
+
public void testReadChar() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_char('c');
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Character charValue = reader.readChar();
assertTrue(charValue.charValue() == 'c');
}
-
+
public void testReadWChar() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_wchar('w');
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Character wcharValue = reader.readWChar();
assertTrue(wcharValue.charValue() == 'w');
}
-
+
public void testReadOctet() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_octet((byte)27);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Byte octetValue = reader.readOctet();
assertTrue(octetValue.byteValue() == (byte)27);
}
-
+
public void testReadShort() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_short((short)-100);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Short shortValue = reader.readShort();
assertTrue(shortValue.shortValue() == (short)-100);
}
-
+
public void testReadUShort() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_ushort((short)100);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Short ushortValue = reader.readUShort();
assertTrue(ushortValue.shortValue() == (short)100);
}
-
+
public void testReadLong() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_long(-100000);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Long longValue = reader.readLong();
assertTrue(longValue.longValue() == -100000);
}
-
+
public void testReadULong() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_ulong(100000);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
BigInteger ulongValue = reader.readULong();
assertTrue(ulongValue.longValue() == 100000);
}
-
+
public void testReadLongLong() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_longlong(1000000000);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
BigInteger longlongValue = reader.readLongLong();
assertTrue(longlongValue.longValue() == 1000000000);
}
-
+
public void testReadULongLong() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_ulonglong(-1000000000);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
BigInteger ulonglongValue = reader.readULongLong();
assertTrue(ulonglongValue.longValue() == -1000000000);
}
-
+
public void testReadFloat() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_float((float)1234.56);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Float floatValue = reader.readFloat();
assertTrue(floatValue.floatValue() == (float)1234.56);
}
-
+
public void testReadDouble() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_double(6543.21);
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
Double doubleValue = reader.readDouble();
assertTrue(doubleValue.doubleValue() == 6543.21);
}
-
+
public void testReadString() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_string("String");
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
String stringValue = reader.readString();
assertTrue(stringValue.equals("String"));
}
-
+
public void testReadWString() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_wstring("WString");
-
+
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
String wstringValue = reader.readWString();
assertTrue(wstringValue.equals("WString"));
}
-
+
// need to add tests for arrays, sequences, struct, exceptions
public void testReadArray() {
-
+
int data[] = { 1, 1, 2, 3, 5, 8, 13, 21 };
-
+
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_long_array(data, 0, data.length);
@@ -278,22 +277,22 @@
CorbaArrayHandler obj = new CorbaArrayHandler(new QName("Array"), arrayIdlType, arrayTC, arrayType);
for (int i = 0; i < data.length; ++i) {
CorbaObjectHandler nestedObj =
- new CorbaPrimitiveHandler(new QName("item"), longIdlType,
+ new CorbaPrimitiveHandler(new QName("item"), longIdlType,
orb.get_primitive_tc(TCKind.tk_long), null);
obj.addElement(nestedObj);
}
-
+
reader.readArray(obj);
int length = obj.getElements().size();
for (int i = 0; i < length; ++i) {
- assertTrue(new Long(((CorbaPrimitiveHandler)obj.getElement(i)).getValueData()).intValue()
- == data[i]);
+ assertTrue(new Long(((CorbaPrimitiveHandler)obj.getElement(i)).getValueData()).intValue()
+ == data[i]);
}
}
-
+
public void testReadSequence() {
String data[] = { "one", "one", "two", "three", "five", "eight", "thirteen", "twenty-one" };
-
+
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
oStream.write_long(data.length);
@@ -310,7 +309,7 @@
Sequence seqType = new Sequence();
seqType.setBound(data.length);
- seqType.setElemtype(stringIdlType);
+ seqType.setElemtype(stringIdlType);
// name and respoitory ID of the sequence are not needed for this test
// build the object holder for a sequence.
@@ -318,19 +317,19 @@
CorbaSequenceHandler obj = new CorbaSequenceHandler(new QName("Seq"), seqIdlType, seqTC, seqType);
for (int i = 0; i < data.length; ++i) {
CorbaPrimitiveHandler nestedObj =
- new CorbaPrimitiveHandler(new QName("item"), stringIdlType,
+ new CorbaPrimitiveHandler(new QName("item"), stringIdlType,
orb.get_primitive_tc(TCKind.tk_string), null);
obj.addElement(nestedObj);
}
-
+
reader.readSequence(obj);
int length = obj.getElements().size();
for (int i = 0; i < length; ++i) {
assertTrue(((CorbaPrimitiveHandler)obj.getElement(i)).getValueData().equals(data[i]));
}
}
-
- public void testReadStruct() {
+
+ public void testReadStruct() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
@@ -343,19 +342,19 @@
int member1 = 12345;
String member2 = "54321";
boolean member3 = true;
-
+
oStream.write_long(member1);
oStream.write_string(member2);
oStream.write_boolean(member3);
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
QName structIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "struct", CorbaConstants.NP_WSDL_CORBA);
QName longIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "long", CorbaConstants.NP_WSDL_CORBA);
QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
QName boolIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "boolean", CorbaConstants.NP_WSDL_CORBA);
-
+
Struct structType = new Struct();
structType.setName("TestStruct");
MemberType m1 = new MemberType();
@@ -376,9 +375,9 @@
structMembers[0] = new StructMember("member1", orb.get_primitive_tc(TCKind.tk_long), null);
structMembers[1] = new StructMember("member2", orb.get_primitive_tc(TCKind.tk_string), null);
structMembers[2] = new StructMember("member3", orb.get_primitive_tc(TCKind.tk_boolean), null);
- TypeCode structTC = orb.create_struct_tc("IDL:org.apache.yoko.TestStruct/1.0", "TestStruct",
+ TypeCode structTC = orb.create_struct_tc("IDL:org.apache.yoko.TestStruct/1.0", "TestStruct",
structMembers);
- CorbaStructHandler obj = new CorbaStructHandler(new QName("TestStruct"), structIdlType,
+ CorbaStructHandler obj = new CorbaStructHandler(new QName("TestStruct"), structIdlType,
structTC, structType);
obj.addMember(
new CorbaPrimitiveHandler(new QName("member1"), longIdlType, structMembers[0].type, null));
@@ -386,17 +385,17 @@
new CorbaPrimitiveHandler(new QName("member2"), stringIdlType, structMembers[1].type, null));
obj.addMember(
new CorbaPrimitiveHandler(new QName("member3"), boolIdlType, structMembers[2].type, null));
-
+
reader.readStruct(obj);
-
+
List<CorbaObjectHandler> nestedObjs = obj.getMembers();
- assertTrue(new Integer(((CorbaPrimitiveHandler)nestedObjs.get(0)).getValueData()).intValue()
+ assertTrue(new Integer(((CorbaPrimitiveHandler)nestedObjs.get(0)).getValueData()).intValue()
== member1);
assertTrue(((CorbaPrimitiveHandler)nestedObjs.get(1)).getValueData().equals(member2));
assertTrue(new Boolean(((CorbaPrimitiveHandler)nestedObjs.get(2)).getValueData()).booleanValue()
== member3);
}
-
+
public void testReadException() {
Buffer buf = new Buffer();
OutputStream oStream = new OutputStream(buf);
@@ -408,18 +407,18 @@
// }
short code = 12345;
String message = "54321";
-
+
oStream.write_string("IDL:org.apache.yoko.TestException/1.0");
oStream.write_short(code);
oStream.write_string(message);
InputStream iStream = oStream.create_input_stream();
CorbaObjectReader reader = new CorbaObjectReader(iStream);
-
+
QName exceptIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "exception", CorbaConstants.NP_WSDL_CORBA);
QName shortIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "short", CorbaConstants.NP_WSDL_CORBA);
QName stringIdlType = new QName(CorbaConstants.NU_WSDL_CORBA, "string", CorbaConstants.NP_WSDL_CORBA);
-
+
Exception exceptType = new Exception();
exceptType.setName("TestException");
MemberType m1 = new MemberType();
@@ -435,32 +434,32 @@
StructMember[] exceptMembers = new StructMember[2];
exceptMembers[0] = new StructMember("code", orb.get_primitive_tc(TCKind.tk_short), null);
exceptMembers[1] = new StructMember("message", orb.get_primitive_tc(TCKind.tk_string), null);
- TypeCode exceptTC = orb.create_exception_tc("IDL:org.apache.yoko.TestException/1.0", "TestException",
+ TypeCode exceptTC = orb.create_exception_tc("IDL:org.apache.yoko.TestException/1.0", "TestException",
exceptMembers);
- CorbaExceptionHandler obj = new CorbaExceptionHandler(new QName("TestException"), exceptIdlType,
+ CorbaExceptionHandler obj = new CorbaExceptionHandler(new QName("TestException"), exceptIdlType,
exceptTC, exceptType);
obj.addMember(
new CorbaPrimitiveHandler(new QName("code"), shortIdlType, exceptMembers[0].type, null));
obj.addMember(
new CorbaPrimitiveHandler(new QName("message"), stringIdlType, exceptMembers[1].type, null));
-
+
reader.readException(obj);
-
+
List<CorbaObjectHandler> nestedObjs = obj.getMembers();
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();
@@ -472,39 +471,39 @@
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")));
}
}