summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/binding-corba-runtime
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-06-27 06:21:10 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2008-06-27 06:21:10 +0000
commit585ffe4d37666babae11c0df447f8bf01bd0a8e3 (patch)
treec4df782733488001a5be40148dba980cf5528127 /java/sca/modules/binding-corba-runtime
parentf85434a29c399b8325a6268163711f916806da66 (diff)
Apply the patch from Wojtek for TUSCANY-2397. Thanks.
I also did some refactoring for the test case to only start the tnameserv once git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@672122 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/binding-corba-runtime')
-rw-r--r--java/sca/modules/binding-corba-runtime/pom.xml6
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java14
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java64
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java29
-rw-r--r--java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java69
-rw-r--r--java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java37
-rw-r--r--java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java64
7 files changed, 140 insertions, 143 deletions
diff --git a/java/sca/modules/binding-corba-runtime/pom.xml b/java/sca/modules/binding-corba-runtime/pom.xml
index c715dfe202..5bdeb4d9c2 100644
--- a/java/sca/modules/binding-corba-runtime/pom.xml
+++ b/java/sca/modules/binding-corba-runtime/pom.xml
@@ -36,6 +36,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-corba</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>cglib</groupId>
<artifactId>cglib-nodep</artifactId>
<version>2.1_3</version>
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java
index fe70b22953..99c9d7736e 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaBindingProviderFactory.java
@@ -20,6 +20,9 @@
package org.apache.tuscany.sca.binding.corba.impl;
import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.host.corba.CorbaHostExtensionPoint;
+import org.apache.tuscany.sca.host.corba.ExtensibleCorbaHost;
import org.apache.tuscany.sca.provider.BindingProviderFactory;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
@@ -32,13 +35,20 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
*/
public class CorbaBindingProviderFactory implements BindingProviderFactory<CorbaBinding> {
+ private CorbaHostExtensionPoint chep;
+ private ExtensibleCorbaHost host;
+
+ public CorbaBindingProviderFactory(ExtensionPointRegistry registry) {
+ chep = registry.getExtensionPoint(CorbaHostExtensionPoint.class);
+ host = new ExtensibleCorbaHost(chep);
+ }
/**
* @see org.apache.tuscany.sca.provider.BindingProviderFactory#createReferenceBindingProvider(org.apache.tuscany.sca.runtime.RuntimeComponent, org.apache.tuscany.sca.runtime.RuntimeComponentReference, org.apache.tuscany.sca.assembly.Binding)
*/
public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
RuntimeComponentReference reference,
CorbaBinding binding) {
- return null;
+ return new CorbaReferenceBindingProvider(binding, host, reference);
}
/**
@@ -47,7 +57,7 @@ public class CorbaBindingProviderFactory implements BindingProviderFactory<Corba
public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
RuntimeComponentService service,
CorbaBinding binding) {
- return null;
+ return new CorbaServiceBindingProvider(binding, host, service);
}
/**
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java
index 87fd6ce00c..dd06fdfdad 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaInvoker.java
@@ -19,27 +19,23 @@
package org.apache.tuscany.sca.binding.corba.impl;
-import org.apache.tuscany.sca.binding.corba.CorbaBinding;
-import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.binding.corba.impl.reference.DynaCorbaRequest;
+import org.apache.tuscany.sca.binding.corba.impl.reference.DynaCorbaResponse;
+import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
-import org.omg.CORBA.Any;
-import org.omg.CORBA.Request;
-import org.omg.CosNaming.NamingContextExt;
-import org.omg.CosNaming.NamingContextExtHelper;
+import org.omg.CORBA.Object;
import org.osoa.sca.ServiceRuntimeException;
/**
* @version $Rev$ $Date$
*/
public class CorbaInvoker implements Invoker {
- private Operation operation;
- private CorbaBinding binding;
- public CorbaInvoker(CorbaBinding binding, Operation operation) {
- super();
- this.binding = binding;
- this.operation = operation;
+ private Object remoteObject;
+
+ public CorbaInvoker(Object remoteObject) {
+ this.remoteObject = remoteObject;
}
/**
@@ -47,35 +43,27 @@ public class CorbaInvoker implements Invoker {
*/
public Message invoke(Message msg) {
try {
- org.omg.CORBA.ORB orb = initORB(binding.getHost(), String.valueOf(binding.getPort()));
-
- org.omg.CORBA.Object service = orb.string_to_object(binding.getURI());
-
- // get the root naming context
- org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
-
- // Use NamingContextExt instead of NamingContext. This is
- // part of the Interoperable Naming Service.
- NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
-
- // resolve the Object Reference in Naming
- org.omg.CORBA.Object impl = ncRef.resolve_str(binding.getURI());
-
- String op = operation.getName();
- Request req = impl._request(op);
- Any any = req.add_in_arg();
- return null;
+ DynaCorbaRequest request = new DynaCorbaRequest(remoteObject, msg.getOperation().getName());
+ if (msg.getOperation().getOutputType() != null) {
+ request.setOutputType(msg.getOperation().getOutputType().getPhysical());
+ }
+ java.lang.Object[] args = msg.getBody();
+ if (args != null) {
+ for (int i = 0; i < args.length; i++) {
+ request.addArgument(args[i]);
+ }
+ }
+ if (msg.getOperation().getFaultTypes() != null) {
+ for (DataType type : msg.getOperation().getFaultTypes()) {
+ request.addExceptionType(type.getPhysical());
+ }
+ }
+ DynaCorbaResponse response = request.invoke();
+ msg.setBody(response.getContent());
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
- }
-
- private org.omg.CORBA.ORB initORB(String host, String port) {
- java.util.Properties props = new java.util.Properties();
- props.put("org.omg.CORBA.ORBInitialHost", host);
- props.put("org.omg.CORBA.ORBInitialPort", port);
- org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(new String[0], props);
- return orb;
+ return msg;
}
}
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java
index a79abd94a5..d251ce0d01 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaReferenceBindingProvider.java
@@ -20,46 +20,61 @@
package org.apache.tuscany.sca.binding.corba.impl;
import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.host.corba.CorbaHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.omg.CORBA.Object;
/**
* @version $Rev$ $Date$
*/
public class CorbaReferenceBindingProvider implements ReferenceBindingProvider {
+
private CorbaBinding binding;
+ private CorbaHost host;
+ private RuntimeComponentReference reference;
+ private Object remoteObject;
+
+ public CorbaReferenceBindingProvider(CorbaBinding binding, CorbaHost host, RuntimeComponentReference reference) {
+ this.binding = binding;
+ this.host = host;
+ this.reference = reference;
+ }
/**
* @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#createInvoker(org.apache.tuscany.sca.interfacedef.Operation)
*/
public Invoker createInvoker(Operation operation) {
- return new CorbaInvoker(binding, operation);
+ try {
+ if (remoteObject == null) {
+ remoteObject = host.getReference(binding.getName(), binding.getHost(), binding.getPort());
+ }
+ return new CorbaInvoker(remoteObject);
+ } catch (Exception e) {
+ }
+ return null;
}
/**
* @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#getBindingInterfaceContract()
*/
public InterfaceContract getBindingInterfaceContract() {
- // TODO Auto-generated method stub
- return null;
+ return reference.getInterfaceContract();
}
/**
* @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#start()
*/
public void start() {
- // TODO Auto-generated method stub
-
}
/**
* @see org.apache.tuscany.sca.provider.ReferenceBindingProvider#stop()
*/
public void stop() {
- // TODO Auto-generated method stub
-
}
/**
diff --git a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java
index a48bd730ee..bf1b5ffc47 100644
--- a/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java
+++ b/java/sca/modules/binding-corba-runtime/src/main/java/org/apache/tuscany/sca/binding/corba/impl/CorbaServiceBindingProvider.java
@@ -20,71 +20,43 @@
package org.apache.tuscany.sca.binding.corba.impl;
import org.apache.tuscany.sca.binding.corba.CorbaBinding;
+import org.apache.tuscany.sca.binding.corba.impl.service.DynaCorbaServant;
+import org.apache.tuscany.sca.host.corba.CorbaHost;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
-import org.omg.CosNaming.NameComponent;
-import org.omg.CosNaming.NamingContextExt;
-import org.omg.CosNaming.NamingContextExtHelper;
-import org.omg.PortableServer.POA;
-import org.omg.PortableServer.POAHelper;
-import org.omg.PortableServer.Servant;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.osoa.sca.ServiceRuntimeException;
/**
* @version $Rev$ $Date$
*/
public class CorbaServiceBindingProvider implements ServiceBindingProvider {
+
private CorbaBinding binding;
+ private CorbaHost host;
+ private RuntimeComponentService service;
+ private DynaCorbaServant servant;
+
+ public CorbaServiceBindingProvider(CorbaBinding binding, CorbaHost host, RuntimeComponentService service) {
+ this.binding = binding;
+ this.host = host;
+ this.service = service;
+ }
/**
* @see org.apache.tuscany.sca.provider.ServiceBindingProvider#getBindingInterfaceContract()
*/
public InterfaceContract getBindingInterfaceContract() {
- // TODO Auto-generated method stub
- return null;
- }
-
- protected Servant createServant() {
- return null;
+ return service.getInterfaceContract();
}
- private NameComponent[] nameComponents;
-
/**
* @see org.apache.tuscany.sca.provider.ServiceBindingProvider#start()
*/
public void start() {
try {
- java.util.Properties props = new java.util.Properties();
- props.put("org.omg.CORBA.ORBInitialHost", binding.getHost());
- props.put("org.omg.CORBA.ORBInitialPort", String.valueOf(binding.getPort()));
- org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(new String[0], props);
-
- Servant servant = createServant();
-
- // get reference to rootpoa & activate the POAManager
- POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
- rootpoa.the_POAManager().activate();
-
- // get object reference from the servant
- org.omg.CORBA.Object ref = rootpoa.servant_to_reference(servant);
-
- org.omg.CORBA.Object href = null; // AddHelper.narrow(ref);
-
- // get the root naming context
- // NameService invokes the name service
- org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService");
- // Use NamingContextExt which is part of the Interoperable
- // Naming Service (INS) specification.
- NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
-
- // bind the Object Reference in Naming
- NameComponent path[] = ncRef.to_name(binding.getURI());
- ncRef.rebind(path, href);
-
- // wait for invocations from clients
- orb.run();
-
+ servant = new DynaCorbaServant(service, binding);
+ host.registerServant(binding.getName(), binding.getHost(), binding.getPort(), servant);
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
@@ -96,14 +68,7 @@ public class CorbaServiceBindingProvider implements ServiceBindingProvider {
*/
public void stop() {
try {
- java.util.Properties props = new java.util.Properties();
- props.put("org.omg.CORBA.ORBInitialHost", binding.getHost());
- props.put("org.omg.CORBA.ORBInitialPort", String.valueOf(binding.getPort()));
- org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(new String[0], props);
-
- org.omg.CORBA.Object object = orb.resolve_initial_references("NameService");
- org.omg.CosNaming.NamingContextExt root = org.omg.CosNaming.NamingContextExtHelper.narrow(object);
- root.unbind(nameComponents);
+ host.unregisterServant(binding.getName(), binding.getHost(), binding.getPort());
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java
index dfbaa329a1..2b269c94e9 100644
--- a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java
+++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaServantTestCase.java
@@ -19,11 +19,12 @@
package org.apache.tuscany.sca.binding.corba.testing;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import java.io.IOException;
import java.lang.reflect.Array;
-import junit.framework.TestCase;
-
import org.apache.tuscany.sca.binding.corba.impl.exceptions.CorbaException;
import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException;
import org.apache.tuscany.sca.binding.corba.impl.reference.DynaCorbaRequest;
@@ -54,6 +55,8 @@ import org.apache.tuscany.sca.binding.corba.testing.servants.NonCorbaServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.PrimitivesSetterServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.TestObjectServant;
import org.apache.tuscany.sca.binding.corba.testing.service.mocks.TestRuntimeComponentService;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
@@ -61,15 +64,16 @@ import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContext;
import org.omg.CosNaming.NamingContextHelper;
-public class CorbaServantTestCase extends TestCase {
+public class CorbaServantTestCase {
- private Process process;
- private ORB orb;
+ private static Process process;
+ private static ORB orb;
/**
* Spawns tnamserv an initiates ORB
*/
- public void setUp() throws IOException {
+ @BeforeClass
+ public static void setUp() throws IOException {
String[] args = {"-ORBInitialPort", "" + TestConstants.ORB_INITIAL_PORT};
process = Runtime.getRuntime().exec("tnameserv " + args[0] + " " + args[1]);
try {
@@ -84,7 +88,8 @@ public class CorbaServantTestCase extends TestCase {
/**
* Kills tnameserv
*/
- public void tearDown() {
+ @BeforeClass
+ public static void tearDown() {
try {
if (process != null) {
process.destroy();
@@ -134,7 +139,7 @@ public class CorbaServantTestCase extends TestCase {
/**
* Tests primitives (arguments, return types)
*/
- public void test_primitivesSetter() {
+ @Test public void test_primitivesSetter() {
try {
PrimitivesSetter primitivesSetter = new PrimitivesSetterServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(primitivesSetter);
@@ -182,7 +187,7 @@ public class CorbaServantTestCase extends TestCase {
/**
* Tests arrays (arguments, return types)
*/
- public void test_arraysSetter() {
+ @Test public void test_arraysSetter() {
try {
ArraysSetter arraysSetter = new ArraysSetterServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(arraysSetter);
@@ -238,7 +243,7 @@ public class CorbaServantTestCase extends TestCase {
/**
* Tests structures (arguments, return types)
*/
- public void test_TestObject_setStruct() {
+ @Test public void test_TestObject_setStruct() {
try {
TestObject to = new TestObjectServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(to);
@@ -272,7 +277,7 @@ public class CorbaServantTestCase extends TestCase {
/**
* Tests handling BAD_OPERATION system exception
*/
- public void test_systemException_BAD_OPERATION() {
+ @Test public void test_systemException_BAD_OPERATION() {
try {
TestObjectServant tos = new TestObjectServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(tos);
@@ -319,7 +324,7 @@ public class CorbaServantTestCase extends TestCase {
/**
* Tests handling user exceptions
*/
- public void test_userExceptions() {
+ @Test public void test_userExceptions() {
try {
CalcServant calc = new CalcServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
@@ -362,7 +367,7 @@ public class CorbaServantTestCase extends TestCase {
/**
* Tests enums (arguments, return types)
*/
- public void test_enums() {
+ @Test public void test_enums() {
try {
EnumManagerServant ems = new EnumManagerServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(ems);
@@ -379,7 +384,7 @@ public class CorbaServantTestCase extends TestCase {
}
}
- public void test_nonCorbaServants() {
+ @Test public void test_nonCorbaServants() {
try {
NonCorbaServant ncs = new NonCorbaServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(ncs);
@@ -419,7 +424,7 @@ public class CorbaServantTestCase extends TestCase {
/**
* Tests handling BAD_PARAM system exception
*/
- public void test_systemException_BAD_PARAM() {
+ @Test public void test_systemException_BAD_PARAM() {
try {
CalcServant calc = new CalcServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(calc);
@@ -445,7 +450,7 @@ public class CorbaServantTestCase extends TestCase {
/**
* Tests handling BAD_PARAM system exception
*/
- public void test_invalidServantConfiguraion() {
+ @Test public void test_invalidServantConfiguraion() {
try {
InvalidTypesServant its = new InvalidTypesServant();
TestRuntimeComponentService service = new TestRuntimeComponentService(its);
diff --git a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java
index 85012158fd..150115517b 100644
--- a/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java
+++ b/java/sca/modules/binding-corba-runtime/src/test/java/org/apache/tuscany/sca/binding/corba/testing/CorbaTypesTestCase.java
@@ -19,9 +19,12 @@
package org.apache.tuscany.sca.binding.corba.testing;
-import java.lang.reflect.Array;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import junit.framework.TestCase;
+import java.lang.reflect.Array;
import org.apache.tuscany.sca.binding.corba.impl.exceptions.CorbaException;
import org.apache.tuscany.sca.binding.corba.impl.exceptions.RequestConfigurationException;
@@ -45,6 +48,9 @@ import org.apache.tuscany.sca.binding.corba.testing.servants.EnumManagerServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.ObjectManagerServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.PrimitivesSetterServant;
import org.apache.tuscany.sca.binding.corba.testing.servants.TestObjectServant;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
import org.omg.CosNaming.NameComponent;
@@ -56,21 +62,22 @@ import org.omg.CosNaming.NamingContextHelper;
/**
* @version $Rev$ $Date$
*/
-public class CorbaTypesTestCase extends TestCase {
+public class CorbaTypesTestCase {
- private Process tnameservProcess;
- private Object refPrimitivesSetter;
- private Object refArraysSetter;
- private Object refTestObject;
- private Object refCalcObject;
- private Object refObjectManager;
- private Object refEnumManager;
+ private static Process tnameservProcess;
+ private static Object refPrimitivesSetter;
+ private static Object refArraysSetter;
+ private static Object refTestObject;
+ private static Object refCalcObject;
+ private static Object refObjectManager;
+ private static Object refEnumManager;
/**
* Spawns tnameserv process (must be in PATH). Initializes test servants and
* stores it's references so tests can use it.
*/
- public void setUp() {
+ @BeforeClass
+ public static void setUp() {
try {
String[] args = {"-ORBInitialPort", "11100"};
@@ -141,7 +148,8 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Kills previously spawned tnameserv process.
*/
- public void tearDown() {
+ @AfterClass
+ public static void tearDown() {
tnameservProcess.destroy();
try {
// let the tnameserv have time to die
@@ -198,7 +206,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests passing (and getting as result) varied primitives
*/
- public void test_setPrimitives() {
+ @Test public void test_setPrimitives() {
dynaTestInvoker(refPrimitivesSetter, "setBoolean", Boolean.class, new Boolean[] {true}, true);
dynaTestInvoker(refPrimitivesSetter, "setOctet", Byte.class, new Byte[] {1}, (byte)1);
@@ -215,7 +223,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests passing (and getting as result) varied types sequences
*/
- public void test_setArrays() {
+ @Test public void test_setArrays() {
dynaTestInvoker(refArraysSetter,
"setBoolean",
@@ -269,7 +277,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests passing (and getting as result) complex structure
*/
- public void test_TestObject_setStruct() {
+ @Test public void test_TestObject_setStruct() {
DynaCorbaRequest request = new DynaCorbaRequest(refTestObject, "setStruct");
SomeStruct struct = new SomeStruct();
@@ -303,7 +311,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Test passing (and getting as result) simple two-field structure
*/
- public void test_TestObject_setSimpleStruct() {
+ @Test public void test_TestObject_setSimpleStruct() {
SimpleStruct struct = new SimpleStruct();
struct.field1 = TestConstants.STR_1;
struct.field2 = TestConstants.INT_1;
@@ -323,7 +331,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests passing (and getting as result) two dim. sequence of long.
*/
- public void test_TestObject_setLongSeq2() {
+ @Test public void test_TestObject_setLongSeq2() {
int[][] arr1 = new int[2][2];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
@@ -350,7 +358,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests passing multiple complex attributes.
*/
- public void test_TestObject_pickStructFromArgs() {
+ @Test public void test_TestObject_pickStructFromArgs() {
SomeStruct arg1 = new SomeStruct();
SomeStruct arg2 = new SomeStruct();
SomeStruct arg3 = new SomeStruct();
@@ -402,7 +410,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests handling user defined remote exception (single declared)
*/
- public void test_singleException() {
+ @Test public void test_singleException() {
DynaCorbaRequest request1 = new DynaCorbaRequest(refCalcObject, "div");
try {
request1.addArgument(2d);
@@ -432,7 +440,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests handling user defined multiple exceptions
*/
- public void test_multipleExceptions() {
+ @Test public void test_multipleExceptions() {
DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "divForSmallArgs");
try {
request.addArgument(101d);
@@ -449,7 +457,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests handling exceptions while user defined no exceptions
*/
- public void test_noExceptionsDeclared() {
+ @Test public void test_noExceptionsDeclared() {
DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div");
try {
request.addArgument(1d);
@@ -465,7 +473,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests handling exceptions while user defined no such exception
*/
- public void test_noSuchExceptionDeclared() {
+ @Test public void test_noSuchExceptionDeclared() {
DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div");
try {
request.addArgument(1d);
@@ -482,7 +490,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests handling non existing operation situation
*/
- public void test_systemException_BAD_OPERATION() {
+ @Test public void test_systemException_BAD_OPERATION() {
DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "thisOperationSurelyDoesNotExist");
try {
request.invoke();
@@ -496,7 +504,7 @@ public class CorbaTypesTestCase extends TestCase {
* Tests obtaining references to other objects and using them with specified
* user interface
*/
- public void test_enchancedReferences() {
+ @Test public void test_enchancedReferences() {
try {
DynaCorbaRequest request = new DynaCorbaRequest(refObjectManager, "getDummyObject");
request.setOutputType(DummyObject.class);
@@ -513,7 +521,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Test passing enums as arguments and retrieving them as a result
*/
- public void test_enums() {
+ @Test public void test_enums() {
try {
DynaCorbaRequest request = new DynaCorbaRequest(refEnumManager, "getColor");
Color color = Color.green;
@@ -531,7 +539,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests recognizing structures
*/
- public void test_structValidation() {
+ @Test public void test_structValidation() {
try {
DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever");
request.setOutputType(InvalidStruct1.class);
@@ -564,7 +572,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests recognizing enums
*/
- public void test_enumValidation() {
+ @Test public void test_enumValidation() {
try {
DynaCorbaRequest request = new DynaCorbaRequest(refArraysSetter, "whatever");
request.setOutputType(InvalidEnum1.class);
@@ -597,7 +605,7 @@ public class CorbaTypesTestCase extends TestCase {
/**
* Tests hanlding passing wrong params
*/
- public void test_systemException_BAD_PARAM() {
+ @Test public void test_systemException_BAD_PARAM() {
try {
DynaCorbaRequest request = new DynaCorbaRequest(refCalcObject, "div");
request.setOutputType(Double.class);