Commit 561cb73a authored by Rodrigo Carneiro Henrique's avatar Rodrigo Carneiro Henrique
Browse files

[SCS-342]: Melhorar a inicialização e a destruição dos testes unitários


git-svn-id: https://subversion.tecgraf.puc-rio.br/engdist/scs/core/java/trunk@120632 ae0415b3-e90b-0410-900d-d0be9363c56b
parent 86dd7cc1
package scs.core;
import java.util.Collection;
import java.util.Map;
import java.util.Properties;
import junit.framework.Assert;
......@@ -26,17 +26,31 @@ public final class ComponentContextTest {
@BeforeClass
public static void beforeClass() throws UserException {
orb = ORB.init((String[]) null, null);
Properties properties = new Properties();
properties.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
properties.put("org.omg.CORBA.ORBSingletonClass",
"org.jacorb.orb.ORBSingleton");
orb = ORB.init((String[]) null, properties);
org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
poa = POAHelper.narrow(obj);
poa.the_POAManager().activate();
Thread thread = new Thread(new Runnable() {
public void run() {
orb.run();
}
});
thread.start();
componentId =
new ComponentId("componente", (byte) 1, (byte) 0, (byte) 0, "java");
}
@AfterClass
public static void afterClass() {
componentId = null;
poa.destroy(true, true);
orb.shutdown(true);
orb.destroy();
}
......
package scs.core;
import java.util.Properties;
import junit.framework.Assert;
import org.junit.AfterClass;
......@@ -14,7 +16,6 @@ import org.omg.PortableServer.Servant;
import scs.core.exception.SCSException;
public final class FacetTest {
private static ORB orb;
private static ComponentContext context;
private static String name;
private static String interfaceName;
......@@ -22,28 +23,37 @@ public final class FacetTest {
@BeforeClass
public static void beforeClass() throws UserException, SCSException {
orb = ORB.init((String[]) null, null);
Properties properties = new Properties();
properties.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
properties.put("org.omg.CORBA.ORBSingletonClass",
"org.jacorb.orb.ORBSingleton");
ORB orb = ORB.init((String[]) null, properties);
org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
POA poa = POAHelper.narrow(obj);
poa.the_POAManager().activate();
new Thread() {
@Override
public void run() {
orb.run();
}
}.start();
ComponentId componentId =
new ComponentId("componente", (byte) 1, (byte) 0, (byte) 0, "java");
context = new ComponentContext(orb, poa, componentId);
name = "Facet";
interfaceName = IMetaInterfaceHelper.id();
servant = new IMetaInterfaceServant(context);
Thread thread = new Thread(new Runnable() {
public void run() {
context.getORB().run();
}
});
thread.start();
}
@AfterClass
public static void afterClass() {
orb.shutdown(false);
context = null;
ORB orb = context.getORB();
orb.shutdown(true);
orb.destroy();
}
@Test(expected = IllegalArgumentException.class)
......
package scs.core;
import java.util.Properties;
import junit.framework.Assert;
import org.junit.AfterClass;
......@@ -22,7 +24,11 @@ public final class IComponentTest {
@BeforeClass
public static void beforeClass() throws UserException, SCSException {
ORB orb = ORB.init((String[]) null, null);
Properties properties = new Properties();
properties.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
properties.put("org.omg.CORBA.ORBSingletonClass",
"org.jacorb.orb.ORBSingleton");
ORB orb = ORB.init((String[]) null, properties);
org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
POA poa = POAHelper.narrow(obj);
......@@ -44,8 +50,9 @@ public final class IComponentTest {
@AfterClass
public static void afterClass() {
context.getORB().shutdown(true);
context = null;
ORB orb = context.getORB();
orb.shutdown(true);
orb.destroy();
}
@Test
......
package scs.core;
import java.util.Properties;
import junit.framework.Assert;
import org.junit.AfterClass;
......@@ -17,7 +19,11 @@ public final class IMetaInterfaceTest {
@BeforeClass
public static void beforeClass() throws UserException, SCSException {
ORB orb = ORB.init((String[]) null, null);
Properties properties = new Properties();
properties.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
properties.put("org.omg.CORBA.ORBSingletonClass",
"org.jacorb.orb.ORBSingleton");
ORB orb = ORB.init((String[]) null, properties);
org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
POA poa = POAHelper.narrow(obj);
......@@ -37,8 +43,9 @@ public final class IMetaInterfaceTest {
@AfterClass
public static void afterClass() {
context.getORB().shutdown(true);
context = null;
ORB orb = context.getORB();
orb.shutdown(true);
orb.destroy();
}
@Test
......
package scs.core;
import java.util.Properties;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
......@@ -15,7 +17,11 @@ public final class IReceptaclesTest {
@BeforeClass
public static void beforeClass() throws UserException, SCSException {
ORB orb = ORB.init((String[]) null, null);
Properties properties = new Properties();
properties.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
properties.put("org.omg.CORBA.ORBSingletonClass",
"org.jacorb.orb.ORBSingleton");
ORB orb = ORB.init((String[]) null, properties);
org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
POA poa = POAHelper.narrow(obj);
......@@ -35,8 +41,9 @@ public final class IReceptaclesTest {
@AfterClass
public static void afterClass() {
context.getORB().shutdown(true);
context = null;
ORB orb = context.getORB();
orb.shutdown(true);
orb.destroy();
}
@Test(expected = InvalidName.class)
......
package scs.core;
import java.util.List;
import java.util.Properties;
import junit.framework.Assert;
......@@ -22,20 +23,36 @@ public final class ReceptacleTest {
@BeforeClass
public static void beforeClass() throws UserException, SCSException {
ORB orb = ORB.init((String[]) null, null);
Properties properties = new Properties();
properties.put("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB");
properties.put("org.omg.CORBA.ORBSingletonClass",
"org.jacorb.orb.ORBSingleton");
ORB orb = ORB.init((String[]) null, properties);
org.omg.CORBA.Object obj = orb.resolve_initial_references("RootPOA");
POA poa = POAHelper.narrow(obj);
poa.the_POAManager().activate();
ComponentId componentId =
new ComponentId("componente", (byte) 1, (byte) 0, (byte) 0, "java");
context = new ComponentContext(orb, poa, componentId);
name = "Receptculo";
interfaceName = IReceptaclesHelper.id();
multiplex = false;
Thread thread = new Thread(new Runnable() {
public void run() {
context.getORB().run();
}
});
thread.start();
}
@AfterClass
public static void afterClass() {
context = null;
ORB orb = context.getORB();
orb.shutdown(true);
orb.destroy();
}
@Test(expected = IllegalArgumentException.class)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment