Author: csams
Date: 2011-11-30 11:29:42 -0500 (Wed, 30 Nov 2011)
New Revision: 20994
Added:
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/A.java
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/B.java
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/Serializable.hbm.xml
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/SerializableTest.java
Log:
[JBPAPP-7417] First shot at test case.
Added:
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/A.java
===================================================================
---
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/A.java
(rev 0)
+++
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/A.java 2011-11-30
16:29:42 UTC (rev 20994)
@@ -0,0 +1,26 @@
+package org.hibernate.test.serializable;
+
+import java.util.Set;
+
+public class A implements java.io.Serializable {
+
+ private Long id;
+ private Set<B> b;
+
+ public Long getId(){
+ return id;
+ }
+
+ public void setId(Long id){
+ this.id = id;
+ }
+
+ public Set<B> getB(){
+ return b;
+ }
+
+ public void setB(Set<B> b){
+ this.b = b;
+ }
+
+}
Added:
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/B.java
===================================================================
---
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/B.java
(rev 0)
+++
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/B.java 2011-11-30
16:29:42 UTC (rev 20994)
@@ -0,0 +1,27 @@
+package org.hibernate.test.serializable;
+
+import java.util.Collection;
+
+
+public class B implements java.io.Serializable {
+
+ private Long id;
+ private String data;
+
+ public Long getId(){
+ return id;
+ }
+
+ public void setId(Long id){
+ this.id = id;
+ }
+
+ public String getData(){
+ return data;
+ }
+
+ public void setData(String data){
+ this.data = data;
+ }
+
+}
Added:
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/Serializable.hbm.xml
===================================================================
---
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/Serializable.hbm.xml
(rev 0)
+++
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/Serializable.hbm.xml 2011-11-30
16:29:42 UTC (rev 20994)
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<!--
+
+ This mapping demonstrates content-based discrimination for the
+ table-per-hierarchy mapping strategy, using a formula
+ discriminator.
+
+-->
+<hibernate-mapping package="org.hibernate.test.serializable">
+
+ <class name="A" table="Serializable_A">
+ <id name="id" type="long" />
+
+ <set name="b" lazy="true">
+ <key column="serializable_B" />
+ <one-to-many class="B" />
+ </set>
+
+ </class>
+
+ <class name="B" table="serializable_B"
lazy="true">
+ <id name="id" type="long" />
+ <property name="data" type="string" />
+ </class>
+
+</hibernate-mapping>
Property changes on:
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/Serializable.hbm.xml
___________________________________________________________________
Added: svn:executable
+ *
Added:
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/SerializableTest.java
===================================================================
---
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/SerializableTest.java
(rev 0)
+++
core/patches/hibernate-3.3.2_CP03_JBPAPP-7417/testsuite/src/test/java/org/hibernate/test/serializable/SerializableTest.java 2011-11-30
16:29:42 UTC (rev 20994)
@@ -0,0 +1,69 @@
+package org.hibernate.test.serializable;
+
+import junit.framework.Test;
+
+import org.hibernate.Session;
+import org.hibernate.Transaction;
+import org.hibernate.junit.functional.FunctionalTestCase;
+import org.hibernate.junit.functional.FunctionalTestClassTestSuite;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * @author Chris Sams
+ */
+public class SerializableTest extends FunctionalTestCase {
+
+ public SerializableTest(String x) {
+ super(x);
+ }
+
+ public String[] getMappings() {
+ return new String[] { "serializable/Serializable.hbm.xml" };
+ }
+
+ public static Test suite() {
+ return new FunctionalTestClassTestSuite( SerializableTest.class );
+ }
+
+ public void testMarkerObjectSerializable() throws Exception {
+
+ Session s;
+ Transaction tx;
+ s = openSession();
+ tx = s.beginTransaction();
+ //create an A
+ A a = new A();
+ a.setId(1L);
+ s.save(a);
+
+ //Create and save a B
+ B b = new B();
+ b.setId(1L);
+ b.setData("data");
+ s.save(b);
+
+ //add B to a Set
+ Set<B> bs = new HashSet<B>(1);
+ bs.add(b);
+
+ a.setB(bs);
+ s.save(a);
+
+ s.flush();
+
+ b.setData("data2");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+ oos.writeObject(s);
+ s.close();
+
+ }
+
+}
Show replies by date