草庐IT

junit-ee

全部标签

spring - 在测试类弄脏 Spring JUnit 应用程序上下文后如何重置它?

我正在使用Spring3.1.1.RELEASE、JUnit4.8.1和HSQL2.7.7内存数据库。我有一个测试类注释为@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration({"classpath:test-trainingSessionServiceContext.xml"})@DirtiesContext(classMode=ClassMode.AFTER_EACH_TEST_METHOD)publicclassTrainingSessionServiceTest{问题是,当我运行“mvncleantest”时,

jakarta-ee - 运行 hadoop pi 示例时出现 java.lang.runtimeexception java.net.connectexception

我已经在两台机器上配置了hadoop。我可以使用ssh在没有密码的情况下访问两台机器。我已经使用以下命令成功格式化了namenode:--bin/hadoopnamenode-format然后我尝试运行hadoop.tar附带的pi示例sandip@master:~/hadoop-1.0.4$bin/hadoopjarhadoop-examples-1.0.4.jarpi5500NumberofMaps=5SamplesperMap=50013/04/1404:13:04INFOipc.Client:Retryingconnecttoserver:master/192.168.188.

Spring 3.0 与 Java EE 6.0

就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter寻求指导。关闭10年前.我遇到了一个情况……有人要求我就Spring3.0和JavaEE6.0之间的JavaEE开发提供有关采用哪种方法的建议。我曾经是,现在仍然是Spring2.5的插入者,而不是经典的JavaEE5开发,特别是JBoss,我什至将旧应用程序迁移到Spring,并影响了这里对开发策略的重新定义,以包括Spring特定的API,并帮助制定战略计划以培养更轻量

Spring 3.0 与 Java EE 6.0

就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter寻求指导。关闭10年前.我遇到了一个情况……有人要求我就Spring3.0和JavaEE6.0之间的JavaEE开发提供有关采用哪种方法的建议。我曾经是,现在仍然是Spring2.5的插入者,而不是经典的JavaEE5开发,特别是JBoss,我什至将旧应用程序迁移到Spring,并影响了这里对开发策略的重新定义,以包括Spring特定的API,并帮助制定战略计划以培养更轻量

java - Spring JUnit : How to Mock autowired component in autowired component

我有一个我想测试的Spring组件,并且这个组件有一个Autowiring的属性,我需要更改它以进行单元测试。问题是,该类在post-construct方法中使用Autowiring组件,因此在实际使用之前我无法替换它(即通过ReflectionTestUtils)。我该怎么做?这是我要测试的类:@ComponentpublicfinalclassTestedClass{@AutowiredprivateResourceresource;@PostConstructprivatevoidinit(){//Ineedthistoreturndifferentresultresource.

java - Spring JUnit : How to Mock autowired component in autowired component

我有一个我想测试的Spring组件,并且这个组件有一个Autowiring的属性,我需要更改它以进行单元测试。问题是,该类在post-construct方法中使用Autowiring组件,因此在实际使用之前我无法替换它(即通过ReflectionTestUtils)。我该怎么做?这是我要测试的类:@ComponentpublicfinalclassTestedClass{@AutowiredprivateResourceresource;@PostConstructprivatevoidinit(){//Ineedthistoreturndifferentresultresource.

spring - 如何在使用 @RunWith 和 @ContextConfiguration 注释的 jUnit 测试中访问 Spring 上下文?

我有以下测试类@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations={"/services-test-config.xml"})publicclassMySericeTest{@AutowiredMyServiceservice;...}是否可以通过其中一种方法以编程方式访问services-test-config.xml?喜欢:ApplicationContextctx=somehowGetContext(); 最佳答案 这也很好用:@Auto

spring - 如何在使用 @RunWith 和 @ContextConfiguration 注释的 jUnit 测试中访问 Spring 上下文?

我有以下测试类@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations={"/services-test-config.xml"})publicclassMySericeTest{@AutowiredMyServiceservice;...}是否可以通过其中一种方法以编程方式访问services-test-config.xml?喜欢:ApplicationContextctx=somehowGetContext(); 最佳答案 这也很好用:@Auto

hadoop - 单元测试 MapReduce - Junit Mockito

我是为MapReduce编写测试用例的新手,当我用谷歌搜索时,我了解到MRUnit已被弃用,必须使用Mockito。有人可以提供有关使用Junitmockito测试mapreduce的灵感,因为我找不到。我只能看到用于mapreduce的MRUnit测试用例。 最佳答案 我在这里为映射器提供了一个示例测试类。reducer的测试也可以用同样的方式编写。@RunWith(MockitoJUnitRunner.class)publicclassSampleMapperTest{@MockprivateMapper.Contextmock

jakarta-ee - Hadoop Jersey 与 Wildfly resteasy 冲突

在J2EE项目中,我们使用Wildfly来部署项目。我们在外部服务器上运行hadoop。我们想连接这个服务器并读取HDFS数据。但问题是,我们使用的任何hadoop库(hadoop-common、hadoop-hdfs、hadoop-client)都需要Jersey,但wildfly使用Resteasy。由于这个冲突,Wildfly没有部署成功。我的问题是,是否有任何不依赖于Jersey的hadoop库,我们可以用于此操作,或者,我们是否需要用Jersey替换Wildfly上的Resteasy。如果这是解决方案,我们该怎么做。我们找不到此解决方案的来源。感谢您的帮助。