HMI
HMI

Reputation: 3

Concordion class cannot call service bean NullPointerException

Concordion class cannot call service bean NullPointerException:

ConcordionFixtureclass is:

@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!";
    }
   }

and : 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>

and UserController.java is:

@ContextConfiguration(locations = "/test-config.xml")
public class UserController {

@Autowired
UserService userservice;

public String getPrenom(){

    return userservice.findByUserName();
 }

 }

problem is : Concordion class cannot call service bean NullPointerException all the time in SplittingNamesFixtureTest class line : String pren = service.getPrenom(); return NullPointerExeption

Upvotes: -1

Views: 359

Answers (1)

Nigel Charman
Nigel Charman

Reputation: 753

Concordion does not provide native Spring support. You will need a custom Concordion Spring Runner such as https://github.com/chiknrice/concordion-spring-runner.

This may change with when JUnit 5 is supported. See http://concordion.org/integrations/java/markdown/#spring.

Upvotes: 0

Related Questions