diff options
author | mtaal | 2008-06-02 07:15:39 +0000 |
---|---|---|
committer | mtaal | 2008-06-02 07:15:39 +0000 |
commit | a17a662cbbff72bcd699a9d9b7d672b298816637 (patch) | |
tree | 82b9bd6405ba08f9bd16bd60f10e787a665a47c9 /tests/org.eclipse.emf.teneo.commontest | |
parent | 4d39e83e8aeb2fb7c6c01f7ee695e14bd4b48ab9 (diff) | |
download | org.eclipse.emf.teneo-a17a662cbbff72bcd699a9d9b7d672b298816637.tar.gz org.eclipse.emf.teneo-a17a662cbbff72bcd699a9d9b7d672b298816637.tar.xz org.eclipse.emf.teneo-a17a662cbbff72bcd699a9d9b7d672b298816637.zip |
[234530]
[235028]
Diffstat (limited to 'tests/org.eclipse.emf.teneo.commontest')
9 files changed, 54 insertions, 36 deletions
diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/AbstractTestAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/AbstractTestAction.java index 68e73710f..07a7426a1 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/AbstractTestAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/AbstractTestAction.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: AbstractTestAction.java,v 1.6 2008/02/28 07:08:16 mtaal Exp $ + * $Id: AbstractTestAction.java,v 1.7 2008/06/02 07:15:40 mtaal Exp $ */ package org.eclipse.emf.teneo.test; @@ -30,7 +30,7 @@ import org.eclipse.emf.teneo.test.stores.TestStore; * Abstract TestAction used in backend specific test cases. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ */ public abstract class AbstractTestAction extends Assert { // very strange but there was a compile (or runtime) error in one of the ecore packages, had to @@ -113,8 +113,7 @@ public abstract class AbstractTestAction extends Assert { final URL resource = getClass().getClassLoader().getResource(path); if (resource == null) { return null; - } else { - return path; } + return path; } }
\ No newline at end of file diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/annotations/ForcedIdBagAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/annotations/ForcedIdBagAction.java index bb54aba8d..dc5e9b499 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/annotations/ForcedIdBagAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/annotations/ForcedIdBagAction.java @@ -82,7 +82,7 @@ public class ForcedIdBagAction extends AbstractTestAction { // apparently hibernate core creates different tables than running with
// hibernate entitymanager, need to check!
resultSet = metaData.getPrimaryKeys(null, null, "myjoin");
- boolean rsTrue = resultSet.next();
+ resultSet.next();
assertTrue("Primary key column should be named \"idbag_id\"", "idbag_id".equalsIgnoreCase(resultSet
.getString("COLUMN_NAME")));
assertFalse("Found more than one primary key.", resultSet.next());
diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/annotations/SetResourceAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/annotations/SetResourceAction.java index 2fa8edeee..739a1ea8a 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/annotations/SetResourceAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/annotations/SetResourceAction.java @@ -30,7 +30,7 @@ import org.eclipse.emf.teneo.test.stores.TestStore; * using resources. Most other aspects of resources are handled in the Catalog example. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ public class SetResourceAction extends AbstractTestAction { /** The number of testitems created */ @@ -93,6 +93,7 @@ public class SetResourceAction extends AbstractTestAction { } } + assert (list != null); assertEquals(NO_ITEMS, list.getItem().size()); assertEquals(NO_ITEMS, list.getContainedItem().size()); assertEquals(NO_ITEMS, list.getJoinedItem().size()); @@ -142,6 +143,8 @@ public class SetResourceAction extends AbstractTestAction { } } + assert (list != null); + final ArrayList<String> checkNames = new ArrayList<String>(names); for (int i = 0; i < list.getItem().size(); i++) { assertTrue(checkNames.remove(list.getItem().get(i).getName())); @@ -177,6 +180,7 @@ public class SetResourceAction extends AbstractTestAction { list = (ItemList) res.getContents().get(i); } } + assert (list != null); assertEquals(newCount, list.getItem().size()); res.save(null); res.unload(); diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/detach/DetachAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/detach/DetachAction.java index 19441cfc7..ba3e98762 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/detach/DetachAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/detach/DetachAction.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: DetachAction.java,v 1.9 2008/03/07 13:13:53 mtaal Exp $ + * $Id: DetachAction.java,v 1.10 2008/06/02 07:15:40 mtaal Exp $ */ package org.eclipse.emf.teneo.test.emf.detach; @@ -37,7 +37,7 @@ import org.eclipse.emf.teneo.test.stores.TestStore; * Is a test case to test basic detach functionality in the dao resource; Specifically for JPOX/JDO * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ */ public abstract class DetachAction extends AbstractTestAction { @@ -119,6 +119,9 @@ public abstract class DetachAction extends AbstractTestAction { } } + assert (testc != null); + assert (testa != null); + // get testb to force a load if (testc.getTestB().size() != 2 || (testc.getTestB().get(0)).getCode().compareTo("testb2") != 0) { throw new Error("Where is testb?"); @@ -169,6 +172,9 @@ public abstract class DetachAction extends AbstractTestAction { } } + assert (testa != null); + assert (testc != null); + if (testa.getCode().compareTo("detached") != 0) { throw new StoreTestException("The code of testa was not set!"); } diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/CatalogAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/CatalogAction.java index 26e049640..d6dac3ddb 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/CatalogAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/CatalogAction.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: CatalogAction.java,v 1.7 2008/04/04 11:50:30 mtaal Exp $ + * $Id: CatalogAction.java,v 1.8 2008/06/02 07:15:39 mtaal Exp $ */ package org.eclipse.emf.teneo.test.emf.sample; @@ -36,7 +36,7 @@ import org.eclipse.emf.teneo.test.stores.TestStore; * to catalog, delete from catalog. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ public abstract class CatalogAction extends AbstractTestAction { @@ -225,6 +225,7 @@ public abstract class CatalogAction extends AbstractTestAction { CatalogType cat = (CatalogType) store.query(CatalogType.class, "name", "MainCatalog", 1).get(0); assertTrue(cat != null); + assert (cat != null); assertTrue(cat.getName().compareTo("MainCatalog") == 0); assertTrue(cat.getProduct().size() == 2); assertTrue((cat.getProduct().get(0)).getCode().compareTo("product1") == 0); diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/CatalogResourceAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/CatalogResourceAction.java index f31c6e87b..915e66c23 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/CatalogResourceAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/CatalogResourceAction.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: CatalogResourceAction.java,v 1.7 2008/02/28 07:08:16 mtaal Exp $ + * $Id: CatalogResourceAction.java,v 1.8 2008/06/02 07:15:40 mtaal Exp $ */ package org.eclipse.emf.teneo.test.emf.sample; @@ -33,12 +33,13 @@ import org.eclipse.emf.teneo.test.StoreTestException; import org.eclipse.emf.teneo.test.stores.TestStore; /** - * Performs a number of test actions on the catalog example. Create products, link a supplier, add to catalog, delete from catalog. + * Performs a number of test actions on the catalog example. Create products, link a supplier, add + * to catalog, delete from catalog. * * All using a resource, tests add, delete and update of objects in a resource. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ public class CatalogResourceAction extends AbstractTestAction { /** @@ -60,14 +61,16 @@ public class CatalogResourceAction extends AbstractTestAction { } /** - * Creates a supplier, a product, relates then, saves them in a resource and retrieves them again. and does sme + * Creates a supplier, a product, relates then, saves them in a resource and retrieves them + * again. and does sme */ Resource resource; + @Override public void doAction(TestStore store) { final CatalogFactory factory = CatalogFactory.eINSTANCE; try { - double checkPrice = (double) 69.96; // is checked later + double checkPrice = 69.96; // is checked later { resource = store.getResource(); @@ -84,7 +87,7 @@ public class CatalogResourceAction extends AbstractTestAction { price.setQuantityTo(100.0); resource.getContents().add(price); - final ProductType product = (ProductType) factory.createProductType(); + final ProductType product = factory.createProductType(); product.setCode("product1"); product.setDescription("This is a very nice product"); final StringType str1 = factory.createStringType(); @@ -104,8 +107,8 @@ public class CatalogResourceAction extends AbstractTestAction { resource = store.getResource(); resource.load(null); - assertTrue("There should be two top objects in the resource but there are " + resource.getContents().size(), resource - .getContents().size() == 2); + assertTrue("There should be two top objects in the resource but there are " + + resource.getContents().size(), resource.getContents().size() == 2); // get the supplier SupplierType supplier = null; @@ -121,7 +124,7 @@ public class CatalogResourceAction extends AbstractTestAction { price2.setSupplier(supplier); price2.setQuantityTo(100.0); - final ProductType product2 = (ProductType) factory.createProductType(); + final ProductType product2 = factory.createProductType(); product2.setCode("product2"); product2.setDescription("This is a very nice product"); final StringType strfor2 = factory.createStringType(); @@ -140,7 +143,8 @@ public class CatalogResourceAction extends AbstractTestAction { store.checkNumber(StringType.class, 3); store.commitTransaction(); - // directly checks if the following StringTypes are in the database: remarka, remarkb and remarkc + // directly checks if the following StringTypes are in the database: remarka, remarkb + // and remarkc { store.beginTransaction(); final List<?> results = store.getObjects(StringType.class); @@ -200,7 +204,9 @@ public class CatalogResourceAction extends AbstractTestAction { it = resource.getContents().iterator(); while (it.hasNext()) { Object obj = it.next(); - if (obj instanceof ProductType) mainCatalog.getProduct().add((ProductType)obj); + if (obj instanceof ProductType) { + mainCatalog.getProduct().add((ProductType) obj); + } } final CatalogType subCatalog = factory.createCatalogType(); subCatalog.setName("SubCatalog"); @@ -227,8 +233,8 @@ public class CatalogResourceAction extends AbstractTestAction { while (it.hasNext()) { final Object obj = it.next(); - assertTrue("Only top classes should be returned", obj instanceof ProductType || obj instanceof SupplierType - || obj instanceof CatalogType); + assertTrue("Only top classes should be returned", obj instanceof ProductType || + obj instanceof SupplierType || obj instanceof CatalogType); if (obj instanceof CatalogType && ((CatalogType) obj).getName().compareTo("MainCatalog") == 0) { assertTrue("There should only be one MainCatalog", cat == null); @@ -236,12 +242,13 @@ public class CatalogResourceAction extends AbstractTestAction { } } assertTrue(cat != null); + assert (cat != null); assertEquals(0, cat.getName().compareTo("MainCatalog")); assertEquals(2, cat.getProduct().size()); - assertTrue(((ProductType) cat.getProduct().get(0)).getCode().compareTo("product1") == 0); - assertTrue(((ProductType) cat.getProduct().get(1)).getCode().compareTo("product2") == 0); + assertTrue((cat.getProduct().get(0)).getCode().compareTo("product1") == 0); + assertTrue((cat.getProduct().get(1)).getCode().compareTo("product2") == 0); cat.getProduct().remove(1); // this product will not be deleted, only the reference - assertTrue(((CatalogType) cat.getSubCatalog().get(0)).getName().compareTo("SubCatalog") == 0); + assertTrue((cat.getSubCatalog().get(0)).getName().compareTo("SubCatalog") == 0); resource.save(null); resource.unload(); @@ -268,7 +275,7 @@ public class CatalogResourceAction extends AbstractTestAction { // test if the containment is set correctly // there is always at least one remark! - EObject eobj = (EObject) ((ProductType) obj).getRemark().get(0); + EObject eobj = ((ProductType) obj).getRemark().get(0); assertTrue("The remark should be contained in the product", eobj.eContainer() == obj); // delete the product with 1 remark, this is then tested below @@ -312,8 +319,8 @@ public class CatalogResourceAction extends AbstractTestAction { assertTrue(result.getCode().compareTo("product1") == 0); assertTrue(result.getRemark().size() == 2); - assertTrue(((StringType) result.getRemark().get(0)).getValue().compareTo("remarka") == 0); - assertTrue(((StringType) result.getRemark().get(1)).getValue().compareTo("remarkb") == 0); + assertTrue((result.getRemark().get(0)).getValue().compareTo("remarka") == 0); + assertTrue((result.getRemark().get(1)).getValue().compareTo("remarkb") == 0); // then remove one result.getRemark().remove(1); diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/EcoreAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/EcoreAction.java index 5b99e1720..5594a60c3 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/EcoreAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/EcoreAction.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: EcoreAction.java,v 1.14 2008/02/28 07:08:14 mtaal Exp $ + * $Id: EcoreAction.java,v 1.15 2008/06/02 07:15:39 mtaal Exp $ */ package org.eclipse.emf.teneo.test.emf.sample; @@ -38,7 +38,7 @@ import org.eclipse.emf.teneo.test.stores.TestStore; * again. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.14 $ + * @version $Revision: 1.15 $ */ public class EcoreAction extends AbstractTestAction { @@ -119,7 +119,6 @@ public class EcoreAction extends AbstractTestAction { { store.beginTransaction(); final List<?> list = store.getObjects(EPackage.class); - final EPackage epack = (EPackage) list.get(0); for (Object o : list) { store.deleteObject(o); } diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryValidateResourceAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryValidateResourceAction.java index 1cfaef0e1..aade4dff8 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryValidateResourceAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/LibraryValidateResourceAction.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: LibraryValidateResourceAction.java,v 1.7 2008/03/10 06:02:08 mtaal Exp $ + * $Id: LibraryValidateResourceAction.java,v 1.8 2008/06/02 07:15:40 mtaal Exp $ */ package org.eclipse.emf.teneo.test.emf.sample; @@ -38,7 +38,7 @@ import org.eclipse.emf.teneo.test.stores.TestStore; * Tests if simple validation works for the resource implementation. * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ public class LibraryValidateResourceAction extends AbstractTestAction { /** @@ -114,6 +114,7 @@ public class LibraryValidateResourceAction extends AbstractTestAction { } } + assert (lib != null); Writer tolkien = lib.getWriters().get(0); tolkien.setName("Mr. Tolkien"); diff --git a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/ProductAction.java b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/ProductAction.java index 62792838b..c74dca6ba 100644 --- a/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/ProductAction.java +++ b/tests/org.eclipse.emf.teneo.commontest/src/org/eclipse/emf/teneo/test/emf/sample/ProductAction.java @@ -11,7 +11,7 @@ * Martin Taal * </copyright> * - * $Id: ProductAction.java,v 1.9 2008/02/28 07:08:14 mtaal Exp $ + * $Id: ProductAction.java,v 1.10 2008/06/02 07:15:39 mtaal Exp $ */ package org.eclipse.emf.teneo.test.emf.sample; @@ -34,7 +34,7 @@ import org.eclipse.emf.teneo.test.stores.TestStore; * primitive types (double and date). * * @author <a href="mailto:mtaal@elver.org">Martin Taal</a> - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ */ public class ProductAction extends AbstractTestAction { public ProductAction() { @@ -88,6 +88,7 @@ public class ProductAction extends AbstractTestAction { store.beginTransaction(); ProductTypeImpl result = (ProductTypeImpl) store.getObject(ProductType.class); assertTrue(result != null); + assert (result != null); assertTrue(result.getCode().compareTo("product1") == 0); assertTrue(result.getSupplier() != null); assertEquals(199.95, result.getPrice(), 0.01); |