Search code examples
javaspringjunitspring-webflow

Getting error trying to test service on Spring project with junit


I am trying to run my first test with junit on a Spring Web Flow Project from within Eclipse and also from the console with mvn test and but give me the same error.

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [WEB-INF/spring/root-config.xml]; nested exception is java.io.FileNotFoundException: class path resource [WEB-INF/spring/root-config.xml] cannot be opened because it does not exist

I checked and I do have this file in the location so I dont know why Eclipse and Maven is not finding it. Can someone please help me out... below is my test classs

package org.uftwf.memberinquiry.text;

import junit.framework.Assert;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.uftwf.memberinquiry.model.MemberInquiryInformation;
import org.uftwf.memberinquiry.model.MemberRequest;
import org.uftwf.memberinquiry.service.MemberInquiryService;


@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/WEB-INF/spring/root-config.xml")
public class TestApp {

    @Autowired
    private MemberInquiryService service;

    @Test
    public void testgetMemeberRequestInformation() {

        MemberRequest inMemberRequest = new MemberRequest();

        MemberInquiryInformation testInfo = service.getMemeberRequestInformation(inMemberRequest);

        inMemberRequest.setRequestor("[email protected]");


        Assert.assertEquals(testInfo.getFirst_Name(), "Christine");
        Assert.assertEquals(testInfo.getLast_Name(), "Pillings");
    }

}

Solution

  • I updated to the up to date spring-test and junit and now everything is find