diff options
author | mtaal | 2008-08-03 19:24:32 +0000 |
---|---|---|
committer | mtaal | 2008-08-03 19:24:32 +0000 |
commit | 5af21438079befe0aeffdc0c406e33ba14af717a (patch) | |
tree | fbfaa9ffa2eaf72bfe7fa133e71a9fe3d785101b /tests/org.eclipse.emf.teneo.hibernate.test/src | |
parent | 3db2d2c6e0a467492e724947ebc6acb446add708 (diff) | |
download | org.eclipse.emf.teneo-5af21438079befe0aeffdc0c406e33ba14af717a.tar.gz org.eclipse.emf.teneo-5af21438079befe0aeffdc0c406e33ba14af717a.tar.xz org.eclipse.emf.teneo-5af21438079befe0aeffdc0c406e33ba14af717a.zip |
[242995]
Diffstat (limited to 'tests/org.eclipse.emf.teneo.hibernate.test/src')
2 files changed, 94 insertions, 1 deletions
diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/AllTests.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/AllTests.java index 4a68563a6..cfe8abb19 100644 --- a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/AllTests.java +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/AllTests.java @@ -37,7 +37,7 @@ import org.eclipse.emf.teneo.test.issues.TopClassesAction; * All tests * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.23 $ + * @version $Revision: 1.24 $ */ public class AllTests { @@ -45,6 +45,7 @@ public class AllTests { TestSuite suite = new MultiCfgTestSuite("Test for org.eclipse.emf.teneo.hibernate.test.issues", HibernateTestbed .instance().getConfigurations()); + suite.addTestSuite(Bz242995Action.class); suite.addTestSuite(BZ237994Action.class); suite.addTestSuite(BZ237790Action.class); suite.addTestSuite(BZ237498Action.class); diff --git a/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/Bz242995Action.java b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/Bz242995Action.java new file mode 100644 index 000000000..728012179 --- /dev/null +++ b/tests/org.eclipse.emf.teneo.hibernate.test/src/org/eclipse/emf/teneo/hibernate/test/issues/Bz242995Action.java @@ -0,0 +1,92 @@ +/** + * <copyright> Copyright (c) 2005, 2006, 2007, 2008 Springsite BV (The Netherlands) and others All rights + * reserved. This program and the accompanying materials are made available under the terms of the + * Eclipse Public License v1.0 which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html Contributors: Martin Taal </copyright> $Id: + * AgilAction.java,v 1.1 2007/03/28 13:58:33 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.hibernate.test.issues; + +import java.util.Properties; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.teneo.PersistenceOptions; +import org.eclipse.emf.teneo.samples.issues.bz242995.Author; +import org.eclipse.emf.teneo.samples.issues.bz242995.Book; +import org.eclipse.emf.teneo.samples.issues.bz242995.BookCategory; +import org.eclipse.emf.teneo.samples.issues.bz242995.Library; +import org.eclipse.emf.teneo.samples.issues.bz242995.OneTimeWonder; +import org.eclipse.emf.teneo.samples.issues.bz242995.Writer; +import org.eclipse.emf.teneo.samples.issues.bz242995.bz242995Factory; +import org.eclipse.emf.teneo.samples.issues.bz242995.bz242995Package; +import org.eclipse.emf.teneo.test.AbstractTestAction; +import org.eclipse.emf.teneo.test.stores.TestStore; +import org.hibernate.proxy.HibernateProxy; + +/** + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.1 $ + */ +public class Bz242995Action extends AbstractTestAction { + + public Bz242995Action() { + super(new EPackage[] { bz242995Package.eINSTANCE }); + } + + @Override + public Properties getExtraConfigurationProperties() { + final Properties props = new Properties(); + props.setProperty(PersistenceOptions.SET_PROXY, "true"); + return props; + } + + @Override + public void doAction(TestStore store) { + { + store.beginTransaction(); + // Create a library. + Library library = bz242995Factory.eINSTANCE.createLibrary(); + library.setName("My Library"); + // Make it persistent. + // session.save(library); + + // Create a writer... + Writer writer = bz242995Factory.eINSTANCE.createWriter(); + writer.setName("JRR Tolkien"); + store.store(writer);// + + // ...and one of his books. + Book book = bz242995Factory.eINSTANCE.createBook(); + book.setAuthor(writer); + book.setPages(305); + book.setTitle("The Hobbit"); + book.setCategory(BookCategory.SCIENCE_FICTION); + store.store(book);// + // Add the Writer and Book to the Library. They are made + // persistent automatically because the Library is already + // persistent. + library.getWriters().add(writer); + library.getBooks().add(book); + store.store(library);// + + Author theAuthor = bz242995Factory.eINSTANCE.createAuthor(); + theAuthor.setName("Arundati Roy"); + + OneTimeWonder wonder = bz242995Factory.eINSTANCE.createOneTimeWonder(); + wonder.setName("God of small things"); + wonder.setTheAuthor(theAuthor); + store.store(wonder); + store.store(theAuthor); + // Commit the changes to the database. + store.commitTransaction(); + } + { + store.beginTransaction(); + OneTimeWonder otw = store.getObject(OneTimeWonder.class); + Author auth = otw.getTheAuthor(); + assertTrue(auth instanceof HibernateProxy); + store.commitTransaction(); + } + } +} |