Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在非Seam gen生成的Seam项目中运行测试_Java_Seam_Integration Testing_Testng - Fatal编程技术网

Java 在非Seam gen生成的Seam项目中运行测试

Java 在非Seam gen生成的Seam项目中运行测试,java,seam,integration-testing,testng,Java,Seam,Integration Testing,Testng,我有一个项目,首先使用EJB2编写,然后迁移到Spring,最后迁移到JBossSeam2.2.0,这就是我正在处理的情况。它将在Tomcat上运行,但目前它是在JBoss4.2上执行的,尽管我认为这一事实无关紧要。我的任务是运行上次迁移之前编写的所有测试 在谷歌搜索了很多之后,我写了这样的东西: public class CustomUserDAOTest extends SeamTest { @Test public void f() throws Exception {

我有一个项目,首先使用EJB2编写,然后迁移到Spring,最后迁移到JBossSeam2.2.0,这就是我正在处理的情况。它将在Tomcat上运行,但目前它是在JBoss4.2上执行的,尽管我认为这一事实无关紧要。我的任务是运行上次迁移之前编写的所有测试

在谷歌搜索了很多之后,我写了这样的东西:

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();
    }
}
我在网上找到了一些关于它的评论,但没有解决办法。我该怎么办?有人有什么想法吗


提前谢谢

我按照上面Shervin的建议找到了一个解决方案。实际上,当我们使用seam gen创建项目时,src/test目录将包含一个readme.txt,其中包含以下内容:

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.
我打开了测试的运行配置,可以通过工具栏上的Run按钮来完成,点击小的黑色向下箭头并选择Run Configuration,在Classpath选项卡中添加了上面列出的jar,除了jboss-deployers-client-spi.jar,这是有问题的,并且在Arguments选项卡中的VM参数中添加了-Dsun.lang.ClassLoader.AllowaraySyntax=true,因为我使用的是Java 6


我仍然有一些问题,但这个问题已经解决。

为什么不创建一个seam gen项目,并与您的项目进行比较,看看是否有任何设置或其他错误?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.