E aê galera.
O problema é o seguinte:
Eu estou querendo rodar TestCases, onde no testCase eu tenho uma chamada a um metodo de um SessionBean. O deploy da minha aplicação foi feito no weblogic.
A Questão é:
Como faço para rodar estes testes?
Eu preciso settar algum usuário via java para entrar no weblogic?
Alguem tem um testCase rodando um HelloWorld nestas condições?
desde já agradeço.
Meu codigo é o seguinte:
/**
* Session Bean de TesteEJB.
*
* @author evandro g. coelho <egcoelho@zipmail.com.br>
* @ejb.bean
* name = "TesteEJB"
* type = "Stateless"
* view-type = "remote"
*/
public class TesteEJBBean implements SessionBean {
/**
* @ejb.interface-method
* view-type = "both"
*/
public void hello() {
System.out.println("oi");
}
// métodos da interface SessionBean
public void ejbCreate() throws CreateException {
ejbActivate();
}
public void ejbActivate() throws EJBException {
}
public void ejbPassivate() throws EJBException {
}
public void ejbRemove() throws EJBException {
}
public void setSessionContext(SessionContext arg0) throws EJBException {
}
}
e o testCase é:
public class TestComEJB extends TestCase {
private TesteEJB ejb;
/**
* @param arg0
*/
public TestComEJB(String arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
protected void setUp() throws Exception {
super.setUp();
ejb = (TesteEJB) criaSessionBean("TesteEJB", TesteEJBHome.class);
}
private TesteEJB criaSessionBean(String string, Class class1)
throws Exception {
TesteEJB ejb = null;
try {
Context ctx = new InitialContext();
Object ref = ctx.lookup("TesteEJB");
TesteEJBHome home =
(TesteEJBHome) PortableRemoteObject.narrow(
ref,
TesteEJBHome.class);
ejb = home.create();
}
catch (NamingException e) {
throw new Exception("Ocorreu um erro ", e);
}
return ejb;
}
public void testEJB() {
System.out.println("Rodei sem erro.");
}
}
Talvez ajude:
o erro que dá quando eu rodo o JUnit é:
java.io.FileNotFoundException: C:fenasegSCBRNS-WEB-R1RNSW-API-R1javaconfigsecurity.properties (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at com.sun.enterprise.util.Utility.getPropertiesFromFile(Utility.java:42)
at com.sun.enterprise.iiop.POAEJBORB.<clinit>(POAEJBORB.java:78)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:219)
at org.omg.CORBA.ORB.create_impl(ORB.java:295)
at org.omg.CORBA.ORB.init(ORB.java:336)
at com.sun.enterprise.util.ORBManager.createORB(ORBManager.java:138)
at com.sun.enterprise.util.ORBManager.init(ORBManager.java:65)
at com.sun.enterprise.naming.SerialInitContextFactory.<init>(SerialInitContextFactory.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at fenaseg.rns.comum.testes.TestBookComEJB.criaSessionBean(TestBookComEJB.java:33)
at fenaseg.rns.comum.testes.TestBookComEJB.setUp(TestBookComEJB.java:26)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:396)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:280)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:172)
java.io.FileNotFoundException: C:fenasegSCBRNS-WEB-R1RNSW-API-R1javaconfigejb.properties (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at com.sun.enterprise.util.Utility.getPropertiesFromFile(Utility.java:42)
at com.sun.enterprise.iiop.J2EEInitializer.<init>(J2EEInitializer.java:54)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at com.sun.corba.ee.internal.Interceptors.PIORB.registerORBInitializers(PIORB.java:377)
at com.sun.corba.ee.internal.Interceptors.PIORB.parseProperties(PIORB.java:347)
at com.sun.corba.ee.internal.TxPOA.TxPIORB.parseProperties(TxPIORB.java:116)
at com.sun.corba.ee.internal.corba.ORB.set_parameters(ORB.java:461)
at com.sun.corba.ee.internal.POA.POAORB.set_parameters(POAORB.java:156)
at com.sun.corba.ee.internal.Interceptors.PIORB.set_parameters(PIORB.java:336)
at org.omg.CORBA.ORB.init(ORB.java:337)
at com.sun.enterprise.util.ORBManager.createORB(ORBManager.java:138)
at com.sun.enterprise.util.ORBManager.init(ORBManager.java:65)
at com.sun.enterprise.naming.SerialInitContextFactory.<init>(SerialInitContextFactory.java:31)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at java.lang.Class.newInstance0(Class.java:308)
at java.lang.Class.newInstance(Class.java:261)
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:649)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.init(InitialContext.java:219)
at javax.naming.InitialContext.<init>(InitialContext.java:175)
at fenaseg.rns.comum.testes.TestBookComEJB.criaSessionBean(TestBookComEJB.java:33)
at fenaseg.rns.comum.testes.TestBookComEJB.setUp(TestBookComEJB.java:26)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:396)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:280)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:172)
Warning: unable to read transaction.interoperability config property
java.io.FileNotFoundException: C:fenasegSCBRNS-WEB-R1RNSW-API-R1javaconfigsecurity.properties (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at com.sun.enterprise.util.Utility.getPropertiesFromFile(Utility.java:42)
at com.sun.enterprise.iiop.security.SecurityMechanismSelector.<clinit>(SecurityMechanismSelector.java:102)
at com.sun.enterprise.iiop.IIOPSSLSocketFactory.getEndPointInfo(IIOPSSLSocketFactory.java:211)
at com.sun.corba.ee.internal.iiop.ConnectionTable.getConnection(ConnectionTable.java:73)
at com.sun.corba.ee.internal.iiop.ConnectionTable.getConnection(ConnectionTable.java:68)
at com.sun.corba.ee.internal.iiop.GIOPImpl.getConnection(GIOPImpl.java:70)
at com.sun.corba.ee.internal.corba.InitialNamingClient.locateObject(InitialNamingClient.java:769)
at com.sun.corba.ee.internal.corba.InitialNamingClient.getIORUsingHostInfo(InitialNamingClient.java:597)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveCorbaloc(InitialNamingClient.java:573)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolveUsingORBInitRef(InitialNamingClient.java:544)
at com.sun.corba.ee.internal.corba.InitialNamingClient.cachedInitialReferences(InitialNamingClient.java:1080)
at com.sun.corba.ee.internal.corba.InitialNamingClient.resolve_initial_references(InitialNamingClient.java:981)
at com.sun.corba.ee.internal.corba.ORB.resolve_initial_references(ORB.java:2425)
at com.sun.enterprise.naming.SerialContext.getProvider(SerialContext.java:52)
at com.sun.enterprise.naming.SerialContext.lookup(SerialContext.java:120)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at fenaseg.rns.comum.testes.TestBookComEJB.criaSessionBean(TestBookComEJB.java:34)
at fenaseg.rns.comum.testes.TestBookComEJB.setUp(TestBookComEJB.java:26)
at junit.framework.TestCase.runBare(TestCase.java:125)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:396)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:280)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:172)