-
1. Re: Testing Seam Apps, SeamTest, Testng
dhinojosa Oct 3, 2007 1:07 PM (in response to joeyxxx)What is the problem?
-
2. Re: Testing Seam Apps, SeamTest, Testng
joeyxxx Oct 3, 2007 3:02 PM (in response to joeyxxx)I had an issue with drools and jndi, resolved those. http://www.jboss.com/index.html?module=bb&op=viewtopic&t=119796
and then this No method found/transaction issue showed up. http://www.jboss.com/index.html?module=bb&op=viewtopic&t=120106
I've tried multiple versions of JBoss embedded, verified that the method exists, tried using the build.xml that came with the example etc and yet no luck. I also looked at the SeamTest and BaseSeamTest api docs but wasn't able to gather enough from those to successfully set up my own tests. I kept getting no active context errors. -
3. Re: Testing Seam Apps, SeamTest, Testng
dhinojosa Oct 3, 2007 6:07 PM (in response to joeyxxx)Can you post the test so we can look at it? Or have something similar?
-
4. Re: Testing Seam Apps, SeamTest, Testng
joeyxxx Oct 3, 2007 7:05 PM (in response to joeyxxx)I couldn't even get the seam-gen generated skeleton tests to work. I also tried a simple logintest which was avery slight modification of the example in the reference PDF. I'll post the exact code when I get back to my desk. Thanks again for responding.
-
5. Re: Testing Seam Apps, SeamTest, Testng
joeyxxx Oct 4, 2007 2:02 AM (in response to joeyxxx)Here is the code for one of my failing tests. I've also included snippets from the tesng log.
package com.goldfinger.test; import com.goldfinger.action.GFIdentity; import org.jboss.seam.annotations.*; import org.jboss.seam.core.Manager; import org.jboss.seam.web.Session; import org.jboss.seam.mock.SeamTest; import org.testng.annotations.Test; import static org.jboss.seam.ScopeType.CONVERSATION; public class LoginTest extends SeamTest{ @Test public void testLogin() throws Exception{ new ComponentTest() { @Override protected void testComponents() throws Exception{ assert getValue("#{identity.loggedIn}").equals(false); setValue("#{identity.username}", "goldfinger"); setValue("#{identity.password}", "xxx"); setValue("#{identity.destination}", "PREFERENCES"); invokeMethod("#{identity.login}"); assert getValue("#{user.firstName}").equals("Gold"); assert getValue("#{user.lastName}").equals("Finger"); assert getValue("#{identity.loggedIn}").equals(true); invokeMethod("#{identity.logout}"); assert getValue("#{identity.loggedIn}").equals(false); setValue("#{identity.username}", "goldfinger"); setValue("#{identity.password}", "xyz"); invokeMethod("#{identity.login}"); assert getValue("#{identity.loggedIn}").equals(false); } }.run(); } @Test public void testLoginComponent() throws Exception { new ComponentTest() { @Override protected void testComponents() throws Exception { assert getValue("#{identity.loggedIn}").equals(false); setValue("#{identity.username}", "goldfinger"); setValue("#{identity.password}", "xxx"); setValue("#{identity.destination}", "PREFERENCES"); invokeMethod("#{identity.login}"); assert getValue("#{user.firstName}").equals("Gold"); assert getValue("#{user.lastName}").equals("Finger"); assert getValue("#{identity.loggedIn}").equals(true); invokeMethod("#{identity.logout}"); assert getValue("#{identity.loggedIn}").equals(false); setValue("#{identity.username}", "goldfinger"); setValue("#{identity.password}", "xyz"); invokeMethod("#{identity.login}"); assert getValue("#{identity.loggedIn}").equals(false); } }.run(); } @Test public void testLogin() throws Exception { new FacesRequest() { @Override protected void invokeApplication() { assert !isSessionInvalid(); assert getValue("#{identity.loggedIn}").equals(false); } }.run(); new FacesRequest() { @Override protected void updateModelValues() throws Exception { assert !isSessionInvalid(); setValue("#{identity.username}", "goldfinger"); setValue("#{identity.password}", "xxx"); } @Override protected void invokeApplication() { invokeAction("#{identity.login}"); } @Override protected void renderResponse() { assert getValue("#{user.firstName}").equals("Gold"); assert getValue("#{user.userName}").equals("mrbond"); assert getValue("#{user.lastName}").equals("Finger"); assert !Manager.instance().isLongRunningConversation(); assert getValue("#{identity.loggedIn}").equals(true); } }.run(); new FacesRequest() { @Override protected void invokeApplication() { assert !isSessionInvalid(); assert getValue("#{identity.loggedIn}").equals(true); } }.run(); new FacesRequest() { @Override protected void invokeApplication() { assert !Manager.instance().isLongRunningConversation(); assert !isSessionInvalid(); invokeMethod("#{identity.logout}"); assert Session.instance().isInvalid(); } @Override protected void renderResponse() { assert getValue("#{identity.loggedIn}").equals(false); assert Session.instance().isInvalid(); } }.run(); } }
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" > <suite name="Login Tests" verbose="2" parallel="false"> <test name="Login Test"> <classes> <class name="com.goldfinger.test.LoginTest"/> </classes> </test> </suite>
[testng] 2007-10-02 23:18:04.102 java[16627] CFLog (0): CFMessagePort: bootstrap_register(): failed 1103 (0x44f), port = 0x21303, name = 'java.ServiceProvider' [testng] See /usr/include/servers/bootstrap_defs.h for the error codes. [testng] 2007-10-02 23:18:04.103 java[16627] CFLog (99): CFMessagePortCreateLocal(): failed to name Mach port (java.ServiceProvider) [testng] 2007-10-02 23:18:04.135 java[16627] Trouble registering connection CPNoteBook java Channel. [testng] ERROR 02-10 23:18:09,698 (Contexts.java:flushAndDestroyContexts:335) -could not discover transaction status [testng] ERROR 02-10 23:18:09,725 (SeamPhaseListener.java:beforePhase:122) -uncaught exception [testng] java.lang.RuntimeException: exception invoking: getTransaction .... [testng] Caused by: java.lang.reflect.InvocationTargetException [testng] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [testng] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [testng] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [testng] at java.lang.reflect.Method.invoke(Method.java:585) [testng] at org.jboss.seam.util.Reflections.invoke(Reflections.java:21) [testng] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125) [testng] ... 54 more [testng] Caused by: java.lang.NoSuchMethodError: org.jboss.aspects.remoting.Remoting.createPojiProxy(Ljava/lang/Object;[Ljava/lang/Class;Ljava/lang/String;[Lorg/jboss/aop/advice/Interceptor;)Ljava/lang/Object; [testng] at org.jboss.naming.JBossRemotingContextFactory.getInitialContext(JBossRemotingContextFactory.java:166) [testng] at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667) [testng] at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247) [testng] at javax.naming.InitialContext.init(InitialContext.java:223) [testng] at javax.naming.InitialContext.<init>(InitialContext.java:197) [testng] at org.jboss.seam.util.Naming.getInitialContext(Naming.java:37) [testng] at org.jboss.seam.util.Naming.getInitialContext(Naming.java:50) [testng] at org.jboss.seam.transaction.Transaction.getUserTransaction(Transaction.java:76) [testng] at org.jboss.seam.transaction.Transaction.createUTTransaction(Transaction.java:71) [testng] at org.jboss.seam.transaction.Transaction.getTransaction(Transaction.java:44) [testng] ... 60 more [testng] ERROR 02-10 23:18:09,755 (SeamPhaseListener.java:beforePhase:129) -swallowing exception [testng] java.lang.RuntimeException: exception invoking: getTransaction [testng] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:135) .....
-
6. Re: Testing Seam Apps, SeamTest, Testng
pmuir Oct 4, 2007 10:29 AM (in response to joeyxxx)What versions of Seam/JBoss Embedded are you using?
-
7. Re: Testing Seam Apps, SeamTest, Testng
joeyxxx Oct 4, 2007 10:39 AM (in response to joeyxxx)Thanks for your time. I'm using the 09/24/07 cvs build of Seam. I tried the embedded that came with seam and also tried the April 17, 2007 Beta 2 that is on sourceforge.
-
8. Re: Testing Seam Apps, SeamTest, Testng
joeyxxx Oct 4, 2007 10:43 AM (in response to joeyxxx)I also tried the bootstrap configuration that came with seam as well as the one that came with beta2 and added
java.naming.provider.url=jnp://localhost:1099
to jndi.properties. That got rid of some issues only to reveal what I'm currently facing. -
9. Re: Testing Seam Apps, SeamTest, Testng
joeyxxx Oct 4, 2007 10:45 AM (in response to joeyxxx)I also verified that the embedded jar had a createPoji method.
-
10. Re: Testing Seam Apps, SeamTest, Testng
pmuir Oct 4, 2007 10:50 AM (in response to joeyxxx)I would suggest trying either current CVS or CR1
-
11. Re: Testing Seam Apps, SeamTest, Testng
joeyxxx Oct 4, 2007 10:56 AM (in response to joeyxxx)current cvs of Seam or embedded? I'm thinking seam but just to be sure.
-
12. Re: Testing Seam Apps, SeamTest, Testng
pmuir Oct 4, 2007 10:59 AM (in response to joeyxxx)Seam
-
13. Re: Testing Seam Apps, SeamTest, Testng
joeyxxx Oct 4, 2007 2:32 PM (in response to joeyxxx)I updated my seam revision and it all works now. Thanks for your time. didn't expect to find a solution in revision that was just a week newer. For restricted actions, do I have to authenticate a user and create a session for each action I need to test or is it possible to sequence the tests so that a session created by the first test, is maintained and used by subsequent tests?
-
14. Re: Testing Seam Apps, SeamTest, Testng
dhinojosa Oct 4, 2007 2:57 PM (in response to joeyxxx)Sorry Joey, I just got back from a customer meeting. I tried it on mine but ended up with the java.lang.ClassNotFoundException: [Ljava.lang.String; thing that has been plaguing testing. I am glad it works for you.