[jboss-user] [JBoss Seam] - Re: Testing Seam Apps, SeamTest, Testng
joeyxxx
do-not-reply at jboss.com
Thu Oct 4 02:02:31 EDT 2007
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)
|
| .....
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4091348#4091348
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4091348
More information about the jboss-user
mailing list