diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java | 31 | ||||
-rw-r--r-- | plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java | 251 |
2 files changed, 157 insertions, 125 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java new file mode 100644 index 0000000000..a4a355e026 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/AllModel1Tests.java @@ -0,0 +1,31 @@ +/*************************************************************************** + * Copyright (c) 2004, 2005, 2006 Eike Stepper, Fuggerstr. 39, 10777 Berlin, Germany. + * 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: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.tests.model1; + + +import junit.framework.Test; +import junit.framework.TestSuite; + + +public class AllModel1Tests +{ + public static Test suite() + { + TestSuite suite = new TestSuite("Test for org.eclipse.emf.cdo.tests.model1"); + suite.addTestSuite(BasicTest.class); + suite.addTestSuite(Bugzilla154389Test.class); + suite.addTestSuite(ExtentTest.class); + suite.addTestSuite(NotificationTest.class); + suite.addTestSuite(OCLTest.class); + suite.addTestSuite(SerializationTest.class); + return suite; + } +} diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java index 5cb0a9bf01..740b54b0c1 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/model1/OCLTest.java @@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.tests.model1; import org.eclipse.emf.cdo.client.ocl.CDOHelperUtil; +import org.eclipse.emf.ocl.helper.HelperUtil; import org.eclipse.emf.ocl.helper.IOCLHelper; import testmodel1.TreeNode; @@ -22,131 +23,131 @@ import java.util.Set; public class OCLTest extends AbstractModel1Test { - // public void testNotEmpty() throws Exception - // { - // final String RESOURCE = "/test/res"; - // final String ROOT = "root"; - // final String[] CHILDREN = { "a", "b", "c"}; - // final String EXPR = "self.children->isEmpty()"; - // - // { // Create CDO resource - // TreeNode root = createNode(ROOT); - // createChildren(CHILDREN, root); - // saveRoot(root, RESOURCE); - // } - // - // TreeNode root = (TreeNode) loadRoot(RESOURCE); - // IOCLHelper helper = HelperUtil.createOCLHelper(); - // helper.setContext(root); - // - // try - // { - // Object result = helper.evaluate(root, EXPR); - // assertFalse(result); - // } - // catch (Exception ex) - // { - // ex.printStackTrace(); - // fail("Parse failed: " + ex.getLocalizedMessage()); - // } - // } - // - // public void testEmpty() throws Exception - // { - // final String RESOURCE = "/test/res"; - // final String ROOT = "root"; - // final String EXPR = "self.children->isEmpty()"; - // - // { // Create CDO resource - // TreeNode root = createNode(ROOT); - // saveRoot(root, RESOURCE); - // } - // - // TreeNode root = (TreeNode) loadRoot(RESOURCE); - // IOCLHelper helper = HelperUtil.createOCLHelper(); - // helper.setContext(root); - // - // try - // { - // Object result = helper.evaluate(root, EXPR); - // assertTrue(result); - // } - // catch (Exception ex) - // { - // ex.printStackTrace(); - // fail("Parse failed: " + ex.getLocalizedMessage()); - // } - // } - // - // public void testExtendedNodeExtent() throws Exception - // { - // final String RESOURCE = "/test/res"; - // - // { // Create CDO resource - // TreeNode root = createNode("root"); - // TreeNode a = createNode("a", root); - // TreeNode b = createNode("b", root); - // TreeNode c = createNode("c", root); - // createNode("a1", a); - // createNode("b1", b); - // createNode("c1", c); - // createExtended("a2", a); - // createExtended("b2", b); - // createExtended("c2", c); - // saveRoot(root, RESOURCE); - // } - // - // TreeNode root = (TreeNode) loadRoot(RESOURCE); - // // CDOResource resource = root.cdoGetResource(); - // IOCLHelper helper = CDOHelperUtil.createOCLHelper(); - // helper.setContext(root); - // - // try - // { - // Set result = (Set) helper.evaluate(root, "ExtendedNode.allInstances()"); - // assertEquals(3, result.size()); - // } - // catch (Exception ex) - // { - // ex.printStackTrace(); - // fail("Parse failed: " + ex.getLocalizedMessage()); - // } - // } - // - // public void testTreeNodeExtent() throws Exception - // { - // final String RESOURCE = "/test/res"; - // - // { // Create CDO resource - // TreeNode root = createNode("root"); - // TreeNode a = createNode("a", root); - // TreeNode b = createNode("b", root); - // TreeNode c = createNode("c", root); - // createNode("a1", a); - // createNode("b1", b); - // createNode("c1", c); - // createExtended("a2", a); - // createExtended("b2", b); - // createExtended("c2", c); - // saveRoot(root, RESOURCE); - // } - // - // TreeNode root = (TreeNode) loadRoot(RESOURCE); - // // CDOResource resource = root.cdoGetResource(); - // IOCLHelper helper = CDOHelperUtil.createOCLHelper(); - // helper.setContext(root); - // - // try - // { - // Set result = (Set) helper.evaluate(root, "TreeNode.allInstances()"); - // assertEquals(10, result.size()); - // } - // catch (Exception ex) - // { - // ex.printStackTrace(); - // fail("Parse failed: " + ex.getLocalizedMessage()); - // } - // } + public void testNotEmpty() throws Exception + { + final String RESOURCE = "/test/res"; + final String ROOT = "root"; + final String[] CHILDREN = { "a", "b", "c"}; + final String EXPR = "self.children->isEmpty()"; + + { // Create CDO resource + TreeNode root = createNode(ROOT); + createChildren(CHILDREN, root); + saveRoot(root, RESOURCE); + } + + TreeNode root = (TreeNode) loadRoot(RESOURCE); + IOCLHelper helper = HelperUtil.createOCLHelper(); + helper.setContext(root); + + try + { + Object result = helper.evaluate(root, EXPR); + assertFalse(result); + } + catch (Exception ex) + { + ex.printStackTrace(); + fail("Parse failed: " + ex.getLocalizedMessage()); + } + } + + public void testEmpty() throws Exception + { + final String RESOURCE = "/test/res"; + final String ROOT = "root"; + final String EXPR = "self.children->isEmpty()"; + + { // Create CDO resource + TreeNode root = createNode(ROOT); + saveRoot(root, RESOURCE); + } + + TreeNode root = (TreeNode) loadRoot(RESOURCE); + IOCLHelper helper = HelperUtil.createOCLHelper(); + helper.setContext(root); + + try + { + Object result = helper.evaluate(root, EXPR); + assertTrue(result); + } + catch (Exception ex) + { + ex.printStackTrace(); + fail("Parse failed: " + ex.getLocalizedMessage()); + } + } + + public void testExtendedNodeExtent() throws Exception + { + final String RESOURCE = "/test/res"; + + { // Create CDO resource + TreeNode root = createNode("root"); + TreeNode a = createNode("a", root); + TreeNode b = createNode("b", root); + TreeNode c = createNode("c", root); + createNode("a1", a); + createNode("b1", b); + createNode("c1", c); + createExtended("a2", a); + createExtended("b2", b); + createExtended("c2", c); + saveRoot(root, RESOURCE); + } + + TreeNode root = (TreeNode) loadRoot(RESOURCE); + // CDOResource resource = root.cdoGetResource(); + IOCLHelper helper = CDOHelperUtil.createOCLHelper(); + helper.setContext(root); + + try + { + Set result = (Set) helper.evaluate(root, "ExtendedNode.allInstances()"); + assertEquals(3, result.size()); + } + catch (Exception ex) + { + ex.printStackTrace(); + fail("Parse failed: " + ex.getLocalizedMessage()); + } + } + + public void testTreeNodeExtent() throws Exception + { + final String RESOURCE = "/test/res"; + + { // Create CDO resource + TreeNode root = createNode("root"); + TreeNode a = createNode("a", root); + TreeNode b = createNode("b", root); + TreeNode c = createNode("c", root); + createNode("a1", a); + createNode("b1", b); + createNode("c1", c); + createExtended("a2", a); + createExtended("b2", b); + createExtended("c2", c); + saveRoot(root, RESOURCE); + } + + TreeNode root = (TreeNode) loadRoot(RESOURCE); + // CDOResource resource = root.cdoGetResource(); + IOCLHelper helper = CDOHelperUtil.createOCLHelper(); + helper.setContext(root); + + try + { + Set result = (Set) helper.evaluate(root, "TreeNode.allInstances()"); + assertEquals(10, result.size()); + } + catch (Exception ex) + { + ex.printStackTrace(); + fail("Parse failed: " + ex.getLocalizedMessage()); + } + } public void testExtentTwoResources() throws Exception { |