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/11/30 16:07:11 UTC
svn commit: r480984 - in
/incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba:
CorbaConduitTest.java CorbaDestinationTest.java CorbaServerConduitTest.java
TestUtils.java
Author: enolan
Date: Thu Nov 30 08:07:08 2006
New Revision: 480984
URL: http://svn.apache.org/viewvc?view=rev&rev=480984
Log:
yoko-125 - adding new unit tests.
Modified:
incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java
incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java
incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java
incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java
Modified: incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java?view=diff&rev=480984&r1=480983&r2=480984
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaConduitTest.java Thu Nov 30 08:07:08 2006
@@ -52,6 +52,7 @@
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;
@@ -92,7 +93,7 @@
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);
+ orb = ORB.init(new String[0], props);
}
public void tearDown() {
@@ -208,8 +209,30 @@
assertEquals(exlist.size(),0);
}
- public void testBuildRequest() {
+ 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);
@@ -217,48 +240,100 @@
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);
-
+ arguments[0].setMode(org.omg.CORBA.ARG_OUT.value);
- CorbaConduit conduit = setupCorbaConduit(false);
- //Message msg = new MessageImpl();
- Message msg = control.createMock(MessageImpl.class);
- CorbaMessage cm = control.createMock(CorbaMessage.class);
- Exchange exchange = control.createMock(Exchange.class);
- EasyMock.expect(cm.getExchange()).andReturn(exchange);
- ServiceInfo service = control.createMock(ServiceInfo.class);
- EasyMock.expect(exchange.get(ServiceInfo.class)).andReturn(service);
- List<TypeMappingType> list = control.createMock(List.class);
- EasyMock.expect(service.getExtensors(TypeMappingType.class)).andReturn(list);
+ 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);
- EasyMock.expect(cm.getStreamableArguments()).andReturn(null);
- EasyMock.expect(cm.getStreamableReturn()).andReturn(null);
-
- //OperationType opType = control.createMock(OperationType.class);
+ 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("GreetMe");
- List<CorbaTypeMap> typeMaps = control.createMock(List.class);
- //Map<TypeCode, RaisesType> exceptions = control.createMock(HashMap.class);
- conduit.getOperationExceptions(opType, typeMaps);
- EasyMock.expectLastCall().andReturn(null);
-
- Endpoint endpoint = null;
- Service s = null;
- try {
- endpoint = new EndpointImpl(bus, s, endpointInfo);
- }catch (Exception ex) {
-
+ 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);
}
- msg.put("endpoint", endpoint);
- cm.put("endpoint", endpoint);
- msg.get(CorbaConstants.CORBA_ENDPOINT_OBJECT);
- EasyMock.expectLastCall().andReturn(endpoint);
- /*org.omg.CORBA.Object obj = control.createMock(org.omg.CORBA.Object.class);
- msg.put(CorbaConstants.CORBA_ENDPOINT_OBJECT, obj);
- Request r = control.createMock(Request.class);
+ ExceptionList exList = conduit.getExceptionList(message, opType, typeMaps);
- EasyMock.expect(msg.get(CorbaConstants.CORBA_ENDPOINT_OBJECT)).andReturn(obj);
+ 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"),
@@ -268,69 +343,24 @@
EasyMock.isA(ContextList.class)));
EasyMock.expectLastCall().andReturn(r);
r.invoke();
- EasyMock.expectLastCall();*/
+ EasyMock.expectLastCall();
control.replay();
- conduit.buildRequest(cm, opType);
+ conduit.invokeRequest(message, "greetMe", nvList, ret, exList);
control.verify();
- }
-
- public void testBuildRequest2() {
- setupServiceInfo("http://yoko.apache.org/simple",
- "/wsdl/simpleIdl.wsdl", "SimpleCORBAService",
- "SimpleCORBAPort");
- CorbaDestination destination = new CorbaDestination(endpointInfo);
- CorbaConduit conduit = new CorbaConduit(endpointInfo, destination.getAddress());
- Message m = new MessageImpl();
- CorbaMessage cm = new CorbaMessage(m);
- Exchange exchange = new ExchangeImpl();
- exchange.setDestination(destination);
- ServiceInfo serviceInfo = endpointInfo.getService();
- exchange.put(ServiceInfo.class, serviceInfo);
- exchange.put(EndpointInfo.class, endpointInfo);
- exchange.put(EndpointReferenceType.class, destination.getAddress());
- cm.setExchange(exchange);
- cm.put(EndpointInfo.class, endpointInfo);
-
- List list = new ArrayList();
- list.add(control.createMock(TypeMappingType.class));
- list.add(control.createMock(TypeMappingType.class));
- serviceInfo.addExtensor(list);
+ /* 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();
- QName paramName = new QName("param1");
- QName paramIdlType = CORBAConstants.NT_CORBA_STRING;
- TypeCode paramTC = CorbaUtils.getPrimitiveTypeCode(orb, paramIdlType);
- CorbaPrimitiveHandler objP = new CorbaPrimitiveHandler(paramName, paramIdlType, paramTC, null);
- objP.setValueFromData("TestString");
- CorbaStreamable streamable = new CorbaStreamable(objP, paramName);
- cm.addStreamableArgument(streamable);
- cm.setStreamableReturn(streamable);
-
- NVList nvlist = (NVList)orb.create_list(1);
- ExceptionList exList = orb.create_exception_list();
- ContextList ctxList = orb.create_context_list();
- Context ctx = orb.get_default_context();
-
- NamedValue ret = null;
- Any returnAny = orb.create_any();
- returnAny.insert_Streamable(streamable);
- ret = orb.create_named_value(streamable.getName(), returnAny, org.omg.CORBA.ARG_OUT.value);
-
- OperationType ot = new OperationType();
- ot.setName("greetMe");
-
- Map<TypeCode, RaisesType> exceptions = new HashMap<TypeCode, RaisesType>();
- conduit.getOperationExceptions(ot, list);
-
- //org.omg.CORBA.Object obj = (org.omg.CORBA.Object)cm.get("endpoint");
- //Request request = obj._create_request(ctx, ot.getName(), nvlist, ret, exList, ctxList);
- //request.invoke();
-
+ } catch (java.lang.Exception ex) {
+ ex.printStackTrace();
+ }*/
}
-
-
-
protected CorbaConduit setupCorbaConduit(boolean send) {
target = EasyMock.createMock(EndpointReferenceType.class);
Modified: incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java?view=diff&rev=480984&r1=480983&r2=480984
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaDestinationTest.java Thu Nov 30 08:07:08 2006
@@ -99,7 +99,8 @@
addr = destination.getAddressType().getLocation();
addr = addr.substring(0,4);
- assertEquals(addr, "IOR:");
+ assertEquals(addr, "IOR:");
+ destination.shutdown();
}
}
Modified: incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java?view=diff&rev=480984&r1=480983&r2=480984
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/CorbaServerConduitTest.java Thu Nov 30 08:07:08 2006
@@ -111,7 +111,8 @@
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);
+ assertTrue("EndpointReferenceType should not be null", obj != null);
+ destination.shutdown();
}
@@ -126,6 +127,7 @@
EndpointReferenceType t = null;
EndpointReferenceType ref = conduit.getTargetReference(t);
assertTrue("ref should not be null", ref != null);
+ destination.shutdown();
}
public void testGetAddress() throws Exception {
@@ -138,7 +140,7 @@
CorbaServerConduit conduit = new CorbaServerConduit(endpointInfo, destination.getAddress());
String address = conduit.getAddress();
assertTrue("address should not be null", address != null);
- assertEquals(address, "corbaloc::localhost:40000/Simple");
+ assertEquals(address, "corbaloc::localhost:40000/Simple");
}
public void testClose() throws Exception {
Modified: incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java?view=diff&rev=480984&r1=480983&r2=480984
==============================================================================
--- incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java (original)
+++ incubator/yoko/branches/cxf_port/bindings/src/test/java/org/apache/yoko/bindings/corba/TestUtils.java Thu Nov 30 08:07:08 2006
@@ -64,6 +64,15 @@
return (CorbaDestination)corbaBF.getDestination(endpointInfo);
}
+ public CorbaDestination getExceptionTypesTestDestination() throws Exception {
+ endpointInfo = setupServiceInfo("http://schemas.apache.org/idl/except",
+ "/wsdl/exceptions.wsdl",
+ "ExceptionTestCORBAService",
+ "ExceptionTestCORBAPort");
+ CorbaBindingFactory corbaBF = (CorbaBindingFactory)factory;
+ return (CorbaDestination)corbaBF.getDestination(endpointInfo);
+ }
+
public CorbaDestination getStaxTypesTestDestination() throws Exception {
endpointInfo = setupServiceInfo("http://yoko.apache.org/StaxTest",
"/wsdl/StaxTest.wsdl", "StaxTestCORBAService",