1 Reply Latest reply on Oct 3, 2007 7:21 PM by Pete Muir

    SeamTest with TestNG, embeddable jboss

    John Smith Newbie

      Hi

      I'm using seam1.2.1, jboss 4.2.1. I have managed to boot the embedded EJB3 container for testing purposes, but on trying to obtain a reference to a component, it fails on the @Create method. Anybody got any ideas? Please find relevant code below:

      Test class

      package com.ricall.test;
      
      import java.util.StringTokenizer;
      
      import javax.naming.InitialContext;
      
      import org.testng.annotations.Configuration;
      import org.testng.annotations.Test;
      import org.jboss.ejb3.embedded.*;
      import org.jboss.seam.core.Conversation;
      import org.jboss.seam.mock.SeamTest;
      
      import com.ricall.domain.company.Company;
      import com.ricall.services.user.AddUserService;
      
      public class CreateUserTest extends SeamTest {
       private String firstName = "Jack";
       private String lastName = "Beaken";
       private String password = "welcome";
       private String emailAddress = "jack.beaken@ricall.com";
       private Company company = new Company();
      
       @Test(groups="user")
       @Configuration(groups="user")
       public void testAddUser() throws Exception {
       try {
       new FacesRequest() {
      
       protected void updateModelValues() throws Exception {
       setValue("#{userToAdd.firstName}", firstName);
       setValue("#{userToAdd.lastName}", lastName);
       setValue("#{userToAdd.password}", password);
       setValue("#{userToAdd.emailAddress}", emailAddress);
       company.setId(1l);
       setValue("#{userToAdd.company}", company);
       }
      
      
      
       protected void invokeApplication() {
       AddUserService addUserService = (AddUserService) getInstance("addUserService");
       System.err.println("Add user service = " + addUserService);
      // invokeMethod("#{addUserService.add}");
       addUserService.add();
       }
      
       protected void renderResponse() {
      
       assert getValue("#{userToAdd.firstName}").equals(firstName);
       assert getValue("#{userToAdd.lastName}").equals(lastName);
       assert getValue("#{userToAdd.password}").equals(password);
       assert getValue("#{userToAdd.emailAddress}").equals(emailAddress);
       }
       }.run();
       }catch(Exception e) {
       System.err.println(e.getMessage());
       e.printStackTrace();
       }
       }
      //Added to initalise SeamTest, will be moved to separate class later
      
       @Configuration(groups = "user", beforeTestMethod=true)
       public void begin() {
       System.err.println("In begin");
       super.begin();
       }
      
       @Configuration(groups = "user", afterTestMethod=true)
       public void end() {
       System.err.println("In end");
       super.end();
       }
      
       @Configuration(groups = "user", beforeTestClass=true)
       public void init() throws Exception {
       System.err.println("In init");
       super.init();
       }
      
       @Configuration(groups = "user", afterTestClass=true)
       public void cleanup() throws Exception
       {
       System.err.println("In cleanup");
       super.cleanup();
       }
      
      }


      Exception:

      [testng] exception invoking: create
       [testng] java.lang.RuntimeException: exception invoking: create
       [testng] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:133)
       [testng] at org.jboss.seam.Component.callComponentMethod(Component.java:1834)
       [testng] at org.jboss.seam.Component.callCreateMethod(Component.java:1757)
       [testng] at org.jboss.seam.Component.newInstance(Component.java:1746)
       [testng] at org.jboss.seam.Component.getInstance(Component.java:1643)
       [testng] at org.jboss.seam.Component.getInstance(Component.java:1610)
       [testng] at org.jboss.seam.Component.getInstance(Component.java:1604)
       [testng] at org.jboss.seam.mock.SeamTest.getInstance(SeamTest.java:118)
       [testng] at com.ricall.test.CreateUserTest.access$5(CreateUserTest.java:1)
       [testng] at com.ricall.test.CreateUserTest$1.invokeApplication(CreateUserTest.java:41)
       [testng] at org.jboss.seam.mock.SeamTest$Request.run(SeamTest.java:489)
       [testng] at org.jboss.seam.mock.SeamTest$FacesRequest.run(SeamTest.java:632)
       [testng] at com.ricall.test.CreateUserTest.testAddUser(CreateUserTest.java:54)
       [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:597)
       [testng] at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
       [testng] at org.testng.internal.Invoker.invokeMethod(Invoker.java:398)
       [testng] at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:625)
       [testng] at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:88)
       [testng] at org.testng.TestRunner.privateRun(TestRunner.java:614)
       [testng] at org.testng.TestRunner.run(TestRunner.java:505)
       [testng] at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
       [testng] at org.testng.SuiteRunner.run(SuiteRunner.java:147)
       [testng] at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
       [testng] at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
       [testng] at org.testng.TestNG.run(TestNG.java:316)
       [testng] at org.testng.TestNG.privateMain(TestNG.java:666)
       [testng] at org.testng.TestNG.main(TestNG.java:608)
       [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:597)
       [testng] at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       [testng] at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
       [testng] at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:72)
       [testng] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:57)
       [testng] at org.jboss.seam.interceptors.RemoveInterceptor.aroundInvoke(RemoveInterceptor.java:40)
       [testng] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       [testng] at org.jboss.seam.interceptors.SynchronizationInterceptor.aroundInvoke(SynchronizationInterceptor.java:31)
       [testng] at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:69)
       [testng] at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:103)
       [testng] at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:50)
       [testng] at org.javassist.tmp.java.lang.Object_$$_javassist_0.create(Object_$$_javassist_0.java)
       [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:597)
       [testng] at org.jboss.seam.util.Reflections.invoke(Reflections.java:20)
       [testng] at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:123)
       [testng] ... 29 more
       [testng] Caused by: java.lang.NoSuchMethodError: org.jboss.aop.MethodInfo.getUnadvisedMethod()Ljava/lang/reflect/Method;
       [testng] at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:181)
       [testng] at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:98)
       [testng] at $Proxy117.create(Unknown Source)
       [testng] ... 50 more


      So root cause:
      Caused by: java.lang.NoSuchMethodError: org.jboss.aop.MethodInfo.getUnadvisedMethod()Lja
      va/lang/reflect/Method;

      thanks in advance