2011-01-31 8 views
0

EJB 2を使用して最初に作成したプロジェクトをSpringに移行した後、すべてJBoss Seam 2.2.0に移行しました(これは、私が扱っている)。これはTomcat上で動作しますが、現在はJBoss 4.2上で実行されています(この事実は無関係ですが)。私の仕事は、最後の移行の前に書かれたすべてのテストを実行することです。SeamプロジェクトでSeamプロジェクトでテストを実行する

グーグルの多くの後、私はこのような何かを書いた:

:私はCustomUserDAOBeanとその依存関係のインスタンスを取得するために管理が、私は、テストを実行したときに、私は別の問題を得るため

public class CustomUserDAOTest extends SeamTest { 
    @Test 
    public void f() throws Exception { 
     new ComponentTest() { 
      @Override 
      protected void testComponents() throws Exception { 
       CustomUserDAO customUserDAO = (CustomUserDAO) Component.getInstance(CustomUserDAOBean.class); 
       List<CustomUser> users = customUserDAO.getAll(); 
       assertNotNull(users); 
      } 
     }.run(); 
    } 
} 

良いです

java.lang.RuntimeException: exception invoking: getTransaction 
    at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:154) 
    at org.jboss.seam.Component.callComponentMethod(Component.java:2249) 
    at org.jboss.seam.Component.unwrap(Component.java:2275) 
    at org.jboss.seam.Component.getInstance(Component.java:2041) 
    [OMITTED] 
    at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103) 
    at br.com.visent.sicorp.server.dao.impl.CustomUserDAOBean_$$_javassist_seam_1.listAll(CustomUserDAOBean_$$_javassist_seam_1.java) 
    at br.com.visent.sicorp.server.dao.test.CustomUserDAOTest$1.testComponents(CustomUserDAOTest.java:24) 
    at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162) 
    [OMITTED] 
    at org.testng.TestNG.run(TestNG.java:856) 
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110) 
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205) 
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174) 
Caused by: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial 
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645) 
    [OMITTED] 
    at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:144) 
    ... 45 more 

私はWeb上でいくつかのコメントを見つけましたが、解決策は見つかりませんでした。私は何をすべきか?誰かにアイデアはありますか?

ありがとうございます!

+1

seam-genプロジェクトを作成してプロジェクトに対してdiffを実行して、設定やその他のことが間違っていないかどうかを確認するのはなぜですか? –

+0

Shervin、あなたの提案は素晴らしかった!私は以下の自分の質問に答えます。ありがとうございました! – brandizzi

答えて

0

私は上記のShervinの提案に従って解決策を得ました。私はボタンから行うことができ、テスト(「ランの「実行構成」を開設

If you want to run tests using the Eclipse TestNG plugin, you'll need to add 
these jars to the top of your TestNG classpath. Using the Run Dialog, select the 
XML suite to run, and select these entries from the project tree: 

/lib/test/jboss-embedded-all.jar 
/lib/test/hibernate-all.jar 
/lib/test/thirdparty-all.jar 
/lib/jboss-embedded-api.jar 
/lib/jboss-deployers-client-spi.jar 
/lib/jboss-deployers-core-spi.jar 

You also need to add the Embedded JBoss bootstrap folder, which you can do by 
clicking on the Advanced... button. 

/bootstrap 

Seam uses JBoss Embedded in its unit and integration testing. This has an 
additional requirement when using JDK 6. Add the following VM argument to the VM 
args tab in the TestNG launch configuration for your suite. 

-Dsun.lang.ClassLoader.allowArraySyntax=true 

Please be sure to use JDK 6 Update 4 or better (>= 1.6.0_04) if you are using 
JDK 6. The Update 4 release upgraded to JAXB 2.1 which removes a problem with 
earlier versions of Sun's JDK 6 which required overriding the JAXB libraries 
using the endorsed directory. 

To add tests to your project create a TestNG xml descriptor called *Test.xml 
(e.g. FooTest.xml) next to your test classes and run ant test. 

:私たちが作成したときに、実際に、継ぎ目-genを使ってプロジェクトがsrc/testディレクトリには、次の内容のreadme.txtが含まれていますツールバーの小さな黒い下矢印をクリックして "Run Configurations"を選択)、上記のjarファイルを "Classpath"タブに追加し(問題のあるjboss-deployers-client-spi.jarを除く)、-Dsun.lang.ClassLoader.allowArraySyntax=trueを "VM引数"に追加しました。私はJava 6を使用しているので、「引数」タブをクリックしてください。

私はまだいくつかの問題がありますが、この特定の問題は解決されています。