DATADOC-48 added more complexity to test
This commit is contained in:
@@ -8,6 +8,7 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.document.mongodb.MongoTemplate;
|
import org.springframework.data.document.mongodb.MongoTemplate;
|
||||||
|
import org.springframework.data.document.persistence.test.Address;
|
||||||
import org.springframework.data.document.persistence.test.Person;
|
import org.springframework.data.document.persistence.test.Person;
|
||||||
import org.springframework.data.document.persistence.test.Resume;
|
import org.springframework.data.document.persistence.test.Resume;
|
||||||
import org.springframework.test.annotation.Rollback;
|
import org.springframework.test.annotation.Rollback;
|
||||||
@@ -52,6 +53,8 @@ public class CrossStoreMongoTests {
|
|||||||
public void testCreateJpaToMongoEntityRelationship() {
|
public void testCreateJpaToMongoEntityRelationship() {
|
||||||
clearData(Person.class.getName());
|
clearData(Person.class.getName());
|
||||||
Person p = new Person("Thomas", 20);
|
Person p = new Person("Thomas", 20);
|
||||||
|
Address a = new Address(12, "MAin St.", "Boston", "MA", "02101");
|
||||||
|
p.setAddress(a);
|
||||||
Resume r = new Resume();
|
Resume r = new Resume();
|
||||||
r.addEducation("Skanstulls High School, 1975");
|
r.addEducation("Skanstulls High School, 1975");
|
||||||
r.addEducation("Univ. of Stockholm, 1980");
|
r.addEducation("Univ. of Stockholm, 1980");
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ public class Person {
|
|||||||
private java.util.Date birthDate;
|
private java.util.Date birthDate;
|
||||||
|
|
||||||
@RelatedDocument
|
@RelatedDocument
|
||||||
public Resume resume;
|
private Address address;
|
||||||
|
|
||||||
|
@RelatedDocument
|
||||||
|
private Resume resume;
|
||||||
|
|
||||||
public Person() {
|
public Person() {
|
||||||
}
|
}
|
||||||
@@ -73,4 +76,12 @@ public class Person {
|
|||||||
this.resume = resume;
|
this.resume = resume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Address getAddress() {
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAddress(Address address) {
|
||||||
|
this.address = address;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,26 @@ package org.springframework.data.document.persistence.test;
|
|||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.bson.types.ObjectId;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.document.mongodb.mapping.Document;
|
||||||
|
|
||||||
//@DocumentEntity
|
@Document
|
||||||
public class Resume {
|
public class Resume {
|
||||||
|
|
||||||
private static final Log LOGGER = LogFactory.getLog(Resume.class);
|
private static final Log LOGGER = LogFactory.getLog(Resume.class);
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private ObjectId id;
|
||||||
|
|
||||||
private String education = "";
|
private String education = "";
|
||||||
|
|
||||||
private String jobs = "";
|
private String jobs = "";
|
||||||
|
|
||||||
|
public String getId() {
|
||||||
|
return id.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public String getEducation() {
|
public String getEducation() {
|
||||||
return education;
|
return education;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:tx="http://www.springframework.org/schema/tx"
|
xmlns:tx="http://www.springframework.org/schema/tx"
|
||||||
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
|
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
|
||||||
|
xsi:schemaLocation="http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd
|
||||||
|
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||||||
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||||
|
|
||||||
<context:spring-configured/>
|
<context:spring-configured/>
|
||||||
|
|
||||||
@@ -15,6 +17,8 @@
|
|||||||
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
|
<context:exclude-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
|
||||||
</context:component-scan>
|
</context:component-scan>
|
||||||
|
|
||||||
|
<mongo:mapping-converter/>
|
||||||
|
|
||||||
<!-- Mongo config -->
|
<!-- Mongo config -->
|
||||||
<bean id="mongo" class="org.springframework.data.document.mongodb.MongoFactoryBean">
|
<bean id="mongo" class="org.springframework.data.document.mongodb.MongoFactoryBean">
|
||||||
<property name="host" value="localhost"/>
|
<property name="host" value="localhost"/>
|
||||||
@@ -24,6 +28,8 @@
|
|||||||
<bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
|
<bean id="mongoTemplate" class="org.springframework.data.document.mongodb.MongoTemplate">
|
||||||
<constructor-arg name="mongo" ref="mongo"/>
|
<constructor-arg name="mongo" ref="mongo"/>
|
||||||
<constructor-arg name="databaseName" value="test"/>
|
<constructor-arg name="databaseName" value="test"/>
|
||||||
|
<constructor-arg name="defaultCollectionName" value="cross-store"/>
|
||||||
|
<constructor-arg name="mongoConverter" ref="mappingConverter"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean class="org.springframework.data.document.mongodb.MongoExceptionTranslator"/>
|
<bean class="org.springframework.data.document.mongodb.MongoExceptionTranslator"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user