Skip to content

Latest commit

 

History

History
39 lines (24 loc) · 2.51 KB

README.md

File metadata and controls

39 lines (24 loc) · 2.51 KB

#Mongo + Morphia + CDI + Maven + Arquillian Example

This is a best practice crud application that combines and integrates several technologies around MongoDB and the JEE stack, namely dependency injection, persistence and integration tests. It can be used as a template project or just to study the interplay of different technologies.

Use mvn verify to run it.

##Mongo MongoDB is arguably the most popular choice of NoSQL databases. It is mature and has a rich ecosystem.

##Embedmongo Embedmongo is a Maven plugin wrapper for an embedded MongoDB. It spins up a disposable MongoDB instance automatically during the build. If you want to spin up MongoDB instance manually just type: mvn embedmongo:start -Dembedmongo.wait which will start the Mongo via the embedmongo plugin and make sure it continues to run. You can access this Mongo instance like usual, for example using the excellent RoboMongo tool. This is good for debugging tests.

##Morphia Morphia is a persistence mapping framework for Mongo DB, similar to Hibernate in the relational world. It is one of several avaiable mappers and currently lives in the official MongoDB Github repo. Other serious contenders are: Spring Data and Jongo.

##CDI CDI is the JEE approach to dependency injection. CDI is used to create and inject instances of Morphia Datastore and parametrized DAOs.

Take a look at the CDI eager extension which is used to make the deployment fail if no Mongo is available. Also checkout out how the Instance<T> trick can be used to configure Morphia.

##Maven Maven compiles the code and executes tests. It also uses the embedmongo Maven plugin to start an embedded throwaway MongoDB during integration testing.

##Arquillian Arquillian starts the CDI container and executes all integration tests. Take a look at the Shrinkwrap configuration.

##NoSQL-Unit NoSQL-Unit is a JUnit extension that helps write NoSQL unit tests that emphasize the FIRST (fast, isolated repeatable,self-validated and timely) rule. It is extremely helpful in defining data sets for seeding the database and expectations of test outcomes. NoSQL-Unit was extended a bit in order to filter out volatile, db-related properties like version and lastUpdated.

License: [Apache 2] ([http://www.apache.org/licenses/LICENSE-2.0)

Kai Sternad, 2014