junit4

How to wait for @JMSListener annotated method to complete in JUnit

社会主义新天地 提交于 2019-12-11 04:57:32
问题 So I am trying to get some integration testing of JMS processing, Spring (v4.1.6) based code. It's a very standard Spring setup with @JmsListener annotated method and a DefaultMessageListenerContainer with concurrency set to 1 and therefore allowing only 1 listening thread. Now, I leveraged ActiveMQ's embedded broker not to rely on any external jms broker for the tests to run anywhere anytime (I should work in marketing). So it all wires fine and then I have my JUnit test: @Test public void

Running JUnit 4 from command line on Eclipse project

好久不见. 提交于 2019-12-11 04:48:57
问题 I currently have ClasspathSuite set up to run all of my JUnit tests. I'm working on trying to get the ClasspathSuite class to run from the command line. When I am in the bin directory and run this command: java -cp /usr/share/java/junit.jar org.junit.runner.JUnitCore MySuite.class I get: JUnit version 4.10 Could not find class: MySuite.class Time: 0.002 OK (0 tests) I also tried running the same command with the absolute path to the file, resulting in the same error message. What am I doing

JUnit with Glassfish and JPA

点点圈 提交于 2019-12-11 04:47:17
问题 I've a web application that runs in Glassfish v3. It's realized with JSF v2 and JPA (so there's a persistence.xml where is declared a JTA-data-source). If i try to test my repositories with JUnit, it fails the lookup and gives me this error: javax.naming.NamingException: Lookup failed for 'java:comp/env/persistence/em' in SerialContext[myEnv= java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.url.pkgs=com.sun.enterprise.naming, java.naming

How to run JUnit test from within jar while JUnit cannot find the test class

不羁的心 提交于 2019-12-11 04:38:14
问题 I have a project structure: ├── main │ ├── java │ │ └── qbs │ │ ├── QbsApplication.java │ └── resources │ ├── application.properties | └── test └── java └── qbs └── QbsApplicationTests.java I have build it with mvn clean:install and created jar file. Now I want to run the QbsApplicationTests using the command line. To do it I have put two jars into one dir: -rw-rw-r--. 1 a a 29M 04-05 10:30 fi.qbs-0.0.1-SNAPSHOT.jar -rw-rw-r--. 1 a a 1M 2014-12-04 junit-4.12.jar and executed the following

Why doesn't Junit test throw javax.persistence.PersistenceException?

久未见 提交于 2019-12-11 03:43:55
问题 I run my JUnit4 test to test my JPA repository. But when I try to run this test, which have to throw javax.persistence.PersistenceException my test fails - it doesn't get needed exception. I've tried it on H2, HSQL, Derby and MySQL. Here it is: @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "classpath:testContext.xml" }) @Transactional @FixMethodOrder(MethodSorters.JVM) public class RepositoryTestTemplate extends AbstractTransactionalJUnit4SpringContextTests { }

Using Jmockit with Eclemma

谁说我不能喝 提交于 2019-12-11 03:19:30
问题 I am using Jmockit to junit my code and Eclemma plugin in Eclipse for code coverage. For some reason I am not abe to get the coverage. Other project which uses PowerMock, Eclemma shows code coverage fine. But with Jmockit there seems to be some problem. The following is the exception: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

JUnit test cases for Spring Service Layer

别等时光非礼了梦想. 提交于 2019-12-11 02:48:12
问题 I am trying to configure JUnit and write test cases for Service layer of Spring 3.2 MVC application. I couldnt find much information on how to configure the JUnit from scratch and make it work for Spring service layer. here is my problem I dont really know what version of junit to be used so i just grabbed the latest version Maven junit dependancy <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <scope>test</scope> </dependency> My service Class

Running a Test Suite of the same class but with different initial conditions

白昼怎懂夜的黑 提交于 2019-12-11 02:41:25
问题 In JUnit 4, I am looking to write a test suite that is made up of multiple flavors of the same test case, just with different initial conditions on each one. Here is an example: import java.io.File; import org.junit.runner.RunWith; import org.junit.runners.Suite; import org.junit.runners.Suite.SuiteClasses; @RunWith(Suite.class) @SuiteClasses({MultiInputClientServerIntegrationTest.NormalInput.class, MultiInputClientServerIntegrationTest.SimulationHashIssue.class}) public class

Is there a recommended way for Solr 3.6 JUnit testing?

爷,独闯天下 提交于 2019-12-11 02:20:44
问题 I wonder if there is any best practice for junit testing of Solr 3.6. I want to automate testing of the Solr schema. Earlier posts mentioned the EmbeddedSolrServer. This class seems to have been abandoned from any version between 1.4 an 3.6. I use Spring 3.0.x and Maven for the project. The options I considered are: writing a Junit Test Runner put the jetty startup code in the @Before or @BeforeClass method start a solr server in maven (probably not a good option) put some code in the spring

Hibernate is not deleting my objects. Why?

谁都会走 提交于 2019-12-11 00:33:14
问题 I have just set up a test that checks that I am able to insert entries into my database using Hibernate. The thing that drives me crazy is that Hibernate does not actually delete the entries, although it reports that they are gone! The test below runs successfully, but when I check my DB afterwards the entries that were inserted are still there! I even try to check it using assert (yes I have -ea as vm parameter). Does anyone have a clue why the entries are not deleted? public class