Concordion Klasse aufrufen können Service-Bean NullPointerExeption nennen:Concordion Klasse kann nicht Service bean NullPointerExeption
ConcordionFixtureclass ist:
@RunWith(ConcordionRunner.class)
@ContextConfiguration(locations = "file:src/main/webapp/WEB-INF/spring/root-context.xml")
@ContextConfiguration(locations = "/test-config.xml")
public class SplittingNamesFixtureTest {
@Autowired
UserController service;
public UserController user = new UserController();
@Test
public void testDisplayAddress() {
String res = "Hajar";
String pren = service.getPrenom();
assertTrue(pren.compareTo(res) == 0);
}
@Before
public String giveNom(){
String pren = service.getPrenom();
return pren;
}
public Result split(String fullName) {
Result result = new Result();
String[] words = fullName.split(" ");
result.firstName = words[0];
String pren = service.getPrenom();
result.lastName = pren;
return result;
}
class Result {
public String firstName;
public String lastName;
}
public String getGreeting() {
return "Hello World!";
}
}
und: Test-config.xml
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="IgnoreUnresolvablePlaceholders" value="True"></property>
<property name="locations">
<list>
<!-- <value>classpath:test.properties</value> -->
<!-- List other property files here -->
<!-- value>mail.properties</value -->
</list>
</property>
</bean>
<bean class="fr.teamnet.spec.UserController"></bean>
<bean class="fr.teamnet.service.UserServiceImpl"></bean>
</beans>
und UserController.java ist:
@ContextConfiguration(locations = "/test-config.xml")
public class UserController {
@Autowired
UserService userservice;
public String getPrenom(){
return userservice.findByUserName();
}
}
Problem ist: Concordion-Klasse kann Servicebohne NullPointerExeption nicht die ganze Zeit in SplittingNamesFixtureTest-Klassenzeile aufrufen: String pren = service.getPrenom(); Rückgabe NullPointerExeption plzz Hilfe
Es ist Arbeit, wenn ich SpringifiedConcordionRunner von https://github.com/chiknrice/concordion-spring-runner verwenden, aber ich habe nullPointerExeption, wenn ich Service Bohne von meinem Controller aufrufen: public String getPrenom() { return Userservice. findByUserName(); } Die Benutzer-Service-Bean ist null – HMI
Ich weiß nicht, wo ist das Problem .. Haben Sie eine Idee plz? – HMI
Ich habe das Problem gelöst, indem ich seviceBean in meiner test-config.xml deklariert habe – HMI