resthub / resthub-spring-stack

RESThub Spring stack
http://resthub.org/spring-stack.html
Other
121 stars 66 forks source link

AbstractTransactionalTest with mongodb fails with No qualifying bean error #256

Open nitinsurana opened 9 years ago

nitinsurana commented 9 years ago
@ActiveProfiles({"resthub-mongodb"})
public class TestVideoExistsInMongo extends AbstractTransactionalTest {

    @Inject
    VideoRepository videoRepository;

    @Test
    public void videoExists() {
        String videoId = "3u1fu6f8Hto";
        Integer size = videoRepository.findByVideoId(videoId, new PageRequest(0, 1)).size();
        System.out.println("Found : " + size);
    }
}

As per the documentation (http://resthub.org/docs/spring/testing/) the above code should work, but instead throws


19:49:20 [main] ERROR o.s.t.c.TestContextManager - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@15f9a2a4] to prepare test instance [com.nitinsurana.TestVideoExistsInMongo@17073812]
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [javax.sql.DataSource] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
bcecchinato commented 9 years ago

Didn't you forgot the profile "resthub-jpa" ?

nitinsurana commented 9 years ago

I'm using mongodb, isn't that supposed to be in resthub-mongodb which I've already added to the test.

bcecchinato commented 9 years ago

Reading briefly the resthubContext.xml in mongodb, no datasource bean is defined. It is in the hikariCp or boneCp profiles. I've never used mongo so I don't really know how datasource are working with it :(

nitinsurana commented 9 years ago

I believe this is related - http://stackoverflow.com/questions/25991395/mongodb-configuration-in-spring-boot-and-spring-data-rest