Skip to content

Commit

Permalink
added indirect test for DefaultConverter falling back to Object
Browse files Browse the repository at this point in the history
Serialization if type not recognized and no custom converter
  • Loading branch information
btoddb committed Oct 28, 2011
1 parent 8353bcc commit f45530b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

import org.junit.Test;

import com.mycompany.furniture.Drawer;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
Expand Down Expand Up @@ -84,6 +86,7 @@ public void testPersistAndFindComplexType() {
entity1.setIntProp1(pkKey.getIntProp1());
entity1.setStrProp1(pkKey.getStrProp1());
entity1.setStrProp2("str-prop-two");
entity1.setDrawer(new Drawer(true, false, "a very nice drawer"));

em.persist(entity1);

Expand All @@ -92,6 +95,7 @@ public void testPersistAndFindComplexType() {
assertEquals( entity1.getIntProp1(), entity2.getIntProp1() );
assertEquals( entity1.getStrProp1(), entity2.getStrProp1() );
assertEquals( entity1.getStrProp2(), entity2.getStrProp2() );
assertEquals( entity1.getDrawer(), entity2.getDrawer() );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,28 @@
import javax.persistence.IdClass;
import javax.persistence.Table;

import com.mycompany.furniture.Drawer;

@Entity
@IdClass( MyCompositePK.class )
@Table(name="ComplexColumnFamily")
@IdClass(MyCompositePK.class)
@Table(name = "ComplexColumnFamily")
public class MyComplexEntity {

@Id
private int intProp1;

@Id
private String strProp1;
@Column( name ="strProp2")

@Column(name = "strProp2")
private String strProp2;
@Column( name ="strProp3")

@Column(name = "strProp3")
private String strProp3;

@Column(name = "drawer")
private Drawer drawer;

public int getIntProp1() {
return intProp1;
}
Expand Down Expand Up @@ -55,4 +60,12 @@ public void setStrProp3(String strProp3) {
this.strProp3 = strProp3;
}

public Drawer getDrawer() {
return drawer;
}

public void setDrawer(Drawer drawer) {
this.drawer = drawer;
}

}

0 comments on commit f45530b

Please sign in to comment.