junit « Core « Spring Q&A





1. How can I easily mock out a static method in Java (jUnit4)    stackoverflow.com

How do I easily mock out a static method in Java? I'm using Spring 2.5 and JUnit 4.4

@Service
public class SomeServiceImpl implements SomeService {

    public Object doSomething() {
   ...

2. Using JMockit to mock autowired interface implementations    stackoverflow.com

We are writing JUnit tests for a class that uses Spring autowiring to inject a dependency which is some instance of an interface. Since the class under test never explicitly instantiates ...

3. Add Spring 3.0.0 java based IOC to JUnit 4.7 tests    stackoverflow.com

There is a doc http://static.springsource.org/spring/docs/2.5.6/reference/testing.html how to add IoC support to junit tests using xml-configuration, but I can not find example for java-based configuration... For example, I have java-based bean:

public ...

4. Spring Dependency Injection with TestNG    stackoverflow.com

Spring support JUnit quite well on that: With the RunWith and ContextConfiguration annotation, things look very intuitive

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:dao-context.xml")
This test will be able to run both in Eclipse & Maven in correctly. I ...

5. How can I use the Parameterized JUnit test runner with a field that's injected using Spring?    stackoverflow.com

I'm using Spring to inject the path to a directory into my unit tests. Inside this directory are a number of files that should be used to generate test data for ...

6. spring 3 autowiring and junit testing    stackoverflow.com

My code:

@Component
public class A {
    @Autowired
    private B b;

    public void method() {}
}

public interface X {...}

@Component
public class B implements X {
  ...

7. Spring JUnit4 manual-/auto-wiring dilemma    stackoverflow.com

I ran into an issue that can only be explained with my fundamental lack of understanding of Spring's IoC container facilities and context setup, so I would ask for clarification regarding ...

8. Autowire not working in junit test    stackoverflow.com

I'm sure I'm missing something simple. bar gets autowired in the junit test, but why doesn't bar inside foo get autowired?

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({"beans.xml"})
public class BarTest {  

    ...

9. Dependency injection in a Junit test for a factory implementation    stackoverflow.com

I have some API code upon which I have to provide a solution. I am looking into using spring with this code. There is a factory interface, lets call it ABCFactory. It ...





10. Spring/JUnit serialization of double brace initialized ArrayList in Java    stackoverflow.com

While writing a simple remoting test I've come up against a suprising situation involving DBI (double braces initialization) which I've been unable to fully understand, so I would ask for some ...

11. Create JUnit TestSuite in a non-static way    stackoverflow.com

I am seeking for a way to create and let run a JUnit TestSuite in a non-static fashion. Currently I am doing something like this:

public class MyTestSuite {
    public ...

12. Can I use @Import in Spring JUnit tests?    stackoverflow.com

I have mutual exclusive config configuration classes in my project: Config1 and Config2, I want to select one in the unit test, like:

public class Config1 {
    @Bean
  ...

13. Mocking config values when testing a class using spring    stackoverflow.com

I am trying to test a class like

@Controller
public class FailureController {

    @Value("#{configValues.defaultRedirectUrl}")
    private String defaultRedirectUrl;
public FailureController (String defaultRedirectUrl) {
this.defaultRedirectUrl = defaultRedirectUrl;
}
...
The problem is that ...

14. Spring Test Configurations    stackoverflow.com

I'm fairly new to Spring and my understanding is a bit scratchy so bear with me and word answers for an idiot. I've started working on a relatively large, maven based project ...

15. How to test for errors in Spring Configuration?    stackoverflow.com

In recent years I have been working on web applications written in Java using the Spring MVC framework. The projects have good test coverage with JUnit & Selenium. However on two ...

16. Load Time Weaving with JUnit in Spring Source    forum.springsource.org

Load Time Weaving with JUnit in Spring Source Hi, we have load time weaving configured for Tomcat. It runs in standalone tomcat and inside Spring Source. However it does not run ...





17. Problem config spring and Junit    forum.springsource.org

Problem config spring and Junit i dont how to wotk Junit and spring o dp it before but its not working for my new project i use spring 2.5 core and ...

18. @Configurable, junit help    forum.springsource.org

@Configurable, junit help Hi, I have Order and OrderLineItem domain classes. However, the OrderLineItem class is not public to users of the Order class. ie it is instantiated within the Order ...

19. How to junit test classes that implement ApplicationContextAware?    forum.springsource.org

How to junit test classes that implement ApplicationContextAware? Does anyone know how to use junit to test a class that implements ApplicationContextAware? When I run the following test, I get the ...

20. Using IOC Container with JUnit    forum.springsource.org

Using IOC Container with JUnit I'm using Junit to write unit tests. My main exe has its own spring config, but i want to obviously want to override some of those ...

21. junit 4 and dependency injection    forum.springsource.org

I'd love to post a question on the above, but keep getting this nonsensical error: 1. You are only allowed to post URLs to other sites after you have made 1 ...

22. Junit and my beanwiring.. @autowired not being setup.    forum.springsource.org

Junit and my beanwiring.. @autowired not being setup. Hi I am running a junit test (one of my first) and I have an issue. When running my application in Tomcat as ...

23. Singletons being destroyed immediately after creation while running JUnit tests    forum.springsource.org

Singletons being destroyed immediately after creation while running JUnit tests I find the following in my logs while running JUnit tests via maven. ------------------------------------------------- 2009-04-10 02:21:24,250 INFO [org.springframework.context.support.ClassPathXmlAp plicationContext] - Refreshing ...

24. JUnit test - dependency injection doesn't work    forum.springsource.org

Jun 3rd, 2009, 03:15 PM #1 leszekgruchala View Profile View Forum Posts Private Message Junior Member Join Date Jun 2009 Posts 14 JUnit test - dependency injection doesn't work Hi, this ...

25. @Autowired breaks using junit 4.7 from spring repo    forum.springsource.org

I assume your tests are not running as expected via the Maven build, since Maven is not finding the correct version of JUnit. See the following JIRA issue for details: https://issuetracker.springsource.com/browse/EBR-220 ...

26. Junit and SimpleAsyncTaskExecutor    forum.springsource.org

I am using Junit (within Eclipse) to invoke Spring Batch. My problem is that within Junit I never get any result using the xml configuration shown below. However, everything works perfectly ...

27. Problem with Junit and @Autowired    forum.springsource.org

Jan 16th, 2010, 11:53 AM #1 gfalco77 View Profile View Forum Posts Private Message Junior Member Join Date Aug 2009 Posts 10 Problem with Junit and @Autowired Hello everyone, this is ...

28. Junit 4 tests stopped working - dependency problem?    forum.springsource.org

Mar 16th, 2010, 01:39 PM #1 tomasc View Profile View Forum Posts Private Message Junior Member Join Date Mar 2010 Posts 12 Junit 4 tests stopped working - dependency problem? I ...

29. Autowiring not working using Junit 4, Spring 2.5.6    forum.springsource.org

PHP Code:

30. Autowiring / DI seems to be not working for me with JUnit4.4    forum.springsource.org

Autowiring / DI seems to be not working for me with JUnit4.4 Hi, I want to have both Parameterized & SpringJUnit4ClassRunner but it seems to be not possible. So I thought ...

31. Injection problem trying to do a test with JUnit    forum.springsource.org

Nov 13th, 2010, 10:45 AM #1 AndreaNobili View Profile View Forum Posts Private Message Member Join Date Jun 2010 Posts 92 Injection problem trying to do a test with JUnit Hello, ...