Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to write a test ? #251

Open
nitinsurana opened this issue Nov 13, 2014 · 2 comments
Open

How to write a test ? #251

nitinsurana opened this issue Nov 13, 2014 · 2 comments

Comments

@nitinsurana
Copy link

import com.nitinsurana.model.DataBean;
import com.nitinsurana.repository.DataBeanRepository;
import org.resthub.test.AbstractTest;
import org.testng.annotations.Test;
import javax.inject.Inject;
import javax.inject.Named;

/**
 * Created by nitin on 13-11-2014.
 */
public class RepositoryTest extends AbstractTest {

    @Inject
    private DataBeanRepository dataBeanRepository;

    @Test
    public void  testRepositorySave(){
        System.out.println("Does it work");
        System.out.println(dataBeanRepository);
//        DataBean bean = new DataBean();
//        bean.setPrice(123.23);
//        dataBeanRepository.save(bean);
    }
}

Above threw the following exception :

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mongoTemplate' is defined
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:660) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1157) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:280) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328) ~[spring-beans-4.1.1.RELEASE.jar:4.1.1.RELEASE]
... 79 common frames omitted
Wrapped by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataBeanRepository': Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'mongoTemplate' is defined

@nitinsurana
Copy link
Author

Tried

public class RepositoryTest extends AbstractTransactionalTest {

still didn't worked, same error.

@bmeurant
Copy link
Member

Really not convinced that this is a Resthub issue.

Thank you to provide a complete reproducible test case if you are sure this is related to Resthub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants