Questions tagged [spring-junit]
67 questions
1
vote
1 answer
Expected single matching bean but found 3: objectMapper,halObjectMapper,_halObjectMapper in junitTest
I'm having a problem with my testing. I'm using java spring and trying to run junit test to check if my server is alive.
This the test I'm trying:
@RunWith(SpringJUnit4ClassRunner::class)
@ContextConfiguration(classes =…
user8906123
1
vote
1 answer
JUnit for Spring WebServiceTemplate not working
I am consuming a SOAP Webservice using Spring WebServiceTemplate. While executing the JUnit I am facing an issue.
My Client class:
@Service
public class MyWsClient extends WebServiceGatewaySupport {
@Autowired
private WebServiceTemplate…

rupesh
- 413
- 9
- 19
1
vote
1 answer
How to Mock Datasource in spring JdbcTemplate
Please help me to mock below code .Not able to mock getDataSource() which is calling upon JdbcTemplate object.
@Override
public List getThresholdsRangeForXHS(QueryThresholdsRequest queryThresholdsRequest) {
…

Gaurav
- 33
- 2
- 11
1
vote
1 answer
How to write unit test case with mockito for this controller class
This is my controller class. Now that i want to write unit test cases for the below controller class using mockito
can anyone help me out from this?
@Controller
public class LoginController {
@Autowired
@Qualifier("skillService")
…

Ven
- 11
- 2
1
vote
0 answers
JSF with Spring Test Environment
I'm using JSF 2.2 and (as a lot of people) I've some difficulties while testing.
In the back-end I'm using Spring, so I've available some annotations that helps me in order to be more effective with tests.
A class that tests something related to…

Gavi
- 1,300
- 1
- 19
- 39
1
vote
1 answer
Why can't I use @Before annotation in my project? "Before cannot be resolved to a type"
I am experiencing a strange behavior into a Spring application.
I am trying to create a JUnit test class like this:
public class AppTest {
@Before
public void setUp() {
// Create the application from the configuration
ApplicationContext…

AndreaNobili
- 40,955
- 107
- 324
- 596
1
vote
1 answer
How to check list of objects one property value count using AssertJ?
class Test{
private Boolean isChange;
}
Assume that tests list contains 1000 objets.
List tests = new ArrayList();
Test t = new Test();
t.setIschange(true);
tests.add(t);
like that I have added 200 objects as true i.e isChanges…

Venkata Rama Raju
- 1,325
- 2
- 10
- 15
1
vote
1 answer
Spring Junit with session object - not visible in Controller
Simple Test class have the following:
@Autowired
private WebApplicationContext wac;
@Autowired
MockHttpSession session;
private MockMvc mockMvc;
@Before
public void before() {
this.mockMvc =…

Anand Rockzz
- 6,072
- 5
- 64
- 71
1
vote
2 answers
dependency inject Selenium WebDriver with Spring?
Is it possible to use Spring to inject the WebDriver? I've read it can't be a singleton and should normally be instantiated during an @Before block. I'm ok with it being created at that point but I'd like to have it provided "magically" to some…

xenoterracide
- 16,274
- 24
- 118
- 243
1
vote
1 answer
Spring junit exception
This is my test class.When I try to run the test method am getting following exception.
I am using parmeterized for testing for various inputs.Am using maven.not using ant build.
Exception:
java.lang.Exception: Test class should have exactly one…

Renganathan V
- 413
- 1
- 9
- 27
1
vote
2 answers
How to use RunNotifier or RunListener using SpringJUnit4ClassRunner
I want to get notified when a test fails. Ideally, I want to know if the test is passed or failed in my @After annotated method. I understand that their is a RunListener which can be used for this purpose but it works only if we run the test with…

Arunav
- 33
- 1
- 4
1
vote
2 answers
How do I use Spring/JUnit to verify a controller is not sending me to a non-existent view?
I'm using Spring 3.1.1.RELEASE and JUnit 4.11. I setup my JUnit tests like so
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration({ "classpath:test-context.xml" })
public class MySpringTest
{
protected MockHttpServletRequest…

Dave
- 15,639
- 133
- 442
- 830
1
vote
0 answers
When to use @Transactional annotation in unit testing?
i have a junit test class which its configuration is as follows:
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({ WebContextTestExecutionListener.class,
DependencyInjectionTestExecutionListener.class,
…

Mahmoud Saleh
- 33,303
- 119
- 337
- 498
0
votes
1 answer
TypeNotPresentExceptionProxy when adding lombok dependency to my project
I have this error when I add lombok dependency to my project:
java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(AnnotationParser.java:724)
at…

Nuñito Calzada
- 4,394
- 47
- 174
- 301
0
votes
1 answer
How to print response object content in JUnit test case
I am writing a Junit test case which is running successfully. I want a assert to check if response content is not null.
I am able to see the content in response object, but not getting how to print this content or put a assert on this to check for…

CoderBeginner
- 717
- 1
- 12
- 39