Skip to content

Commit

Permalink
Merge pull request #89 from abraxas-labs/#79
Browse files Browse the repository at this point in the history
#79 added tests for mongodb entity
  • Loading branch information
openwms committed Jun 7, 2016
2 parents 3747fe6 + ea4f5a0 commit b4f9f6c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
language: java

jdk:
- oraclejdk8

before_script:
- mongod --version

addons:
apt:
sources:
- mongodb-3.2-precise
packages:
- mongodb-org-server
- mongodb-org-shell
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
* @since 1.0
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = AbstractMongoDBIntegrationTests.TestConfig.class)
//@EnableMongoAuditing
@ContextConfiguration(/*classes = AbstractMongoDBIntegrationTests.TestConfig.class, */locations = "classpath:infrastructure.xml")
public abstract class AbstractMongoDBIntegrationTests {

@Configuration
Expand Down
15 changes: 12 additions & 3 deletions src/test/java/org/ameba/integration/mongodb/BaseEntityTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
*/
package org.ameba.integration.mongodb;

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import org.ameba.app.BaseConfiguration;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
Expand All @@ -35,11 +38,17 @@ public class BaseEntityTest extends AbstractMongoDBIntegrationTests {
@Autowired
private MongoOperations template;

@Ignore("Need to be fiexed to run with Mongo, or have a deeper look at the SDM tests that are provided")
@Test
public void testPk() {
TestDocument td = new TestDocument();
template.save(td);
template.insert(td);

List<TestDocument> all = template.findAll(TestDocument.class);
assertThat(all).hasSize(1);
assertThat(all.get(0).isNew()).isFalse();
assertThat(all.get(0).getPk()).isNotNull();
// assertThat(all.get(0).getCreateDt()).isNotNull();
// assertThat(all.get(0).getLastModifiedDt()).isNotNull();
assertThat(all.get(0)).extracting("ol").contains(0L);
}
}
20 changes: 20 additions & 0 deletions src/test/resources/infrastructure.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

<bean id="mongo" class="org.springframework.data.mongodb.core.MongoFactoryBean">
<property name="host" value="127.0.0.1"/>
<property name="port" value="27017"/>
</bean>

<bean id="mongoDbFactory" class="org.springframework.data.mongodb.core.SimpleMongoDbFactory">
<constructor-arg name="mongo" ref="mongo"/>
<constructor-arg name="databaseName" value="database"/>
</bean>

<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg name="mongoDbFactory" ref="mongoDbFactory"/>
</bean>

</beans>

0 comments on commit b4f9f6c

Please sign in to comment.