diff options
Diffstat (limited to 'tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryResourceVisitTreeAction.java')
-rwxr-xr-x | tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryResourceVisitTreeAction.java | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryResourceVisitTreeAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryResourceVisitTreeAction.java new file mode 100755 index 000000000..4d211d09f --- /dev/null +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryResourceVisitTreeAction.java @@ -0,0 +1,99 @@ +/** + * <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: LibraryResourceVisitTreeAction.java,v 1.3 2010/02/06 20:50:51 mtaal Exp $ + */ + +package org.eclipse.emf.teneo.test.emf.sample; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.teneo.TeneoException; +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.samples.emf.sample.library.impl.LibraryImpl; +import org.eclipse.emf.teneo.test.AbstractTestAction; +import org.eclipse.emf.teneo.test.stores.TestStore; + +/** + * Tests how children are added to a resource. + * + * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> + * @version $Revision: 1.3 $ + */ +public class LibraryResourceVisitTreeAction extends AbstractTestAction { + public LibraryResourceVisitTreeAction() { + super(LibraryPackage.eINSTANCE); + } + + /** Creates an item, an address and links them to a po. */ + @Override + public void doAction(TestStore store) { + final LibraryFactory factory = LibraryFactory.eINSTANCE; + + // create a book, writer and library + try { + { + Resource res = store.getResource(); + res.load(null); + + final Writer writer = factory.createWriter(); + writer.setName("JRR_Tolkien"); + + final Book book = factory.createBook(); + book.setAuthor(writer); + book.setPages(510); + book.setTitle("Fellowship_of_the_Ring"); + book.setCategory(BookCategory.SCIENCE_FICTION_LITERAL); + final Book book2 = factory.createBook(); + book2.setAuthor(writer); + book2.setPages(500); + book2.setTitle("The_Hobbit"); + book2.setCategory(BookCategory.SCIENCE_FICTION_LITERAL); + + // sorry george making a mistake here, will correct this below + final Book book3 = factory.createBook(); + book3.setAuthor(writer); + book3.setPages(500); + book3.setTitle("nineteeneightyfour"); + book3.setCategory(BookCategory.SCIENCE_FICTION_LITERAL); + final Library library = factory.createLibrary(); + library.setName("Science_Fiction"); + library.getBooks().add(book); + library.getBooks().add(book2); + library.getBooks().add(book3); + library.getWriters().add(writer); + + res.getContents().add(library); + res.save(null); + res.unload(); + } + + { + Resource res = store.getResource("query1=From " + LibraryImpl.class.getName()); + + // res.setTrackingModification(true); + res.load(null); + + Library lib = (Library) res.getContents().get(0); + assertTrue(lib != null); + res.unload(); + } + } catch (Exception e) { + throw new TeneoException(e.getMessage(), e); + } + } +} |