Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryListAsBagAction.java')
-rwxr-xr-xtests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryListAsBagAction.java105
1 files changed, 105 insertions, 0 deletions
diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryListAsBagAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryListAsBagAction.java
new file mode 100755
index 000000000..8ebb2c7c0
--- /dev/null
+++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryListAsBagAction.java
@@ -0,0 +1,105 @@
+/**
+ * <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: LibraryListAsBagAction.java,v 1.5 2009/04/03 06:15:39 mtaal Exp $
+ */
+
+package org.eclipse.emf.teneo.test.emf.sample;
+
+import java.util.Properties;
+
+import org.eclipse.emf.teneo.PersistenceOptions;
+import org.eclipse.emf.teneo.samples.emf.sample.library.Book;
+import org.eclipse.emf.teneo.samples.emf.sample.library.BookCategory;
+import org.eclipse.emf.teneo.samples.emf.sample.library.Library;
+import org.eclipse.emf.teneo.samples.emf.sample.library.LibraryFactory;
+import org.eclipse.emf.teneo.samples.emf.sample.library.LibraryPackage;
+import org.eclipse.emf.teneo.samples.emf.sample.library.Writer;
+import org.eclipse.emf.teneo.test.AbstractTestAction;
+import org.eclipse.emf.teneo.test.stores.TestStore;
+
+/**
+ * Tests the library example of emf/xsd.
+ *
+ * @author <a href="mailto:mtaal@elver.org">Martin Taal</a>
+ * @version $Revision: 1.5 $
+ */
+public class LibraryListAsBagAction extends AbstractTestAction {
+
+ public LibraryListAsBagAction() {
+ super(LibraryPackage.eINSTANCE);
+ }
+
+ @Override
+ public Properties getExtraConfigurationProperties() {
+ final Properties props = new Properties();
+ props.setProperty(PersistenceOptions.ALWAYS_MAP_LIST_AS_BAG, "true");
+ return props;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void doAction(TestStore store) {
+ final LibraryFactory factory = LibraryFactory.eINSTANCE;
+ // create a book, writer and library
+ {
+ store.beginTransaction();
+
+ final Writer writer = factory.createWriter();
+ writer.setName("writer");
+
+ final Book book = factory.createBook();
+
+ book.setAuthor(writer);
+ book.setPages(1);
+ book.setTitle("The Hobbit");
+ book.setCategory(BookCategory.SCIENCE_FICTION_LITERAL);
+
+ final Book book2 = factory.createBook();
+ book2.setAuthor(writer);
+ book2.setPages(2);
+ book2.setTitle("The fellowship of the ring");
+ book2.setCategory(BookCategory.SCIENCE_FICTION_LITERAL);
+
+ final Library library = factory.createLibrary();
+ library.getBooks().add(book);
+ library.setName("Science Fiction Library");
+ library.getBooks().add(book2);
+ library.getWriters().add(writer);
+ store.store(library);
+
+ store.commitTransaction();
+ }
+
+ // move the books arround
+ int page0 = 0;
+ int page1 = 1;
+ {
+ store.beginTransaction();
+ final Library lib = store.getObject(Library.class);
+ page0 = lib.getBooks().get(0).getPages();
+ page1 = lib.getBooks().get(1).getPages();
+ lib.getBooks().move(0, 1); // moved second book to first location
+ store.commitTransaction();
+ }
+
+ // check if it succeeded, should not
+ {
+ store.beginTransaction();
+ final Library lib = store.getObject(Library.class);
+ assertEquals(page0, (lib.getBooks().get(0)).getPages());
+ assertEquals(page1, (lib.getBooks().get(1)).getPages());
+ store.commitTransaction();
+ }
+ }
+}

Back to the top