0

This is my xml:

    <bean class="java.lang.String" id="mongoDbTest">
        <constructor-arg value="Test" />
    </bean>

    <bean class="com.mongodb.MongoClient" id="mongo" />
    <bean class="org.mongodb.morphia.Morphia" id="morphia" />

My DAOs bean is getting mongo and morphia in the constructors. I would like to have a test class that using the DAO to save and assert some entities in the DB. After each test i would like to clean the DB from records.

Is there any xml attribute that i would be able to use?

1 Answer 1

1

I guess you can change name of the database for tests, and on the end of the test drop it.

But I can recommend you to use Embedded MongoDB. "Embedded MongoDB will provide a platform neutral way for running mongodb in unittests."

It's very simple to use. It creates mongoDB database in-memory. You can find tutorial here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.