Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 100784 Details for
Bug 232669
Regression - bug in OCLAbstractAnalyzer
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Fix with different test approach
clipboard.txt (text/plain), 12.24 KB, created by
Christian Damus
on 2008-05-17 16:39:50 EDT
(
hide
)
Description:
Fix with different test approach
Filename:
MIME Type:
Creator:
Christian Damus
Created:
2008-05-17 16:39:50 EDT
Size:
12.24 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ocl.ecore.tests >Index: src/org/eclipse/ocl/ecore/tests/IteratorsTest.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/tests/org.eclipse.ocl.ecore.tests/src/org/eclipse/ocl/ecore/tests/IteratorsTest.java,v >retrieving revision 1.5 >diff -u -r1.5 IteratorsTest.java >--- src/org/eclipse/ocl/ecore/tests/IteratorsTest.java 26 Mar 2008 21:17:23 -0000 1.5 >+++ src/org/eclipse/ocl/ecore/tests/IteratorsTest.java 17 May 2008 20:37:32 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2006, 2008 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation, Zeligsoft Inc. 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 >@@ -309,6 +309,46 @@ > } > > /** >+ * Tests that parsing fails, in the case of an unknown property in a >+ * collection navigation, with an appropriate parse failure, not a >+ * <code>ClassCastException</code>. >+ */ >+ public void test_implicitCollect_unknownAttribute_232669() { >+ helper.setContext(EcorePackage.Literals.EPACKAGE); >+ >+ try { >+ // this shouldn't parse, anyway >+ helper.createInvariant("eSubpackages.unknownAttribute"); //$NON-NLS-1$ >+ >+ fail("Should not have parsed"); //$NON-NLS-1$ >+ } catch (ParserException e) { >+ // should have a diagnostic describing the problem if it is a >+ // "normal" parse failure >+ assertNoException(getDiagnostic(), ClassCastException.class); >+ } >+ } >+ >+ /** >+ * Tests that parsing fails, in the case of an unknown operation in a >+ * collection navigation, with an appropriate parse failure, not a >+ * <code>ClassCastException</code>. >+ */ >+ public void test_implicitCollect_unknownOperation_232669() { >+ helper.setContext(EcorePackage.Literals.EPACKAGE); >+ >+ try { >+ // this shouldn't parse, anyway >+ helper.createInvariant("eSubpackages.unknownOperation(self)"); //$NON-NLS-1$ >+ >+ fail("Should not have parsed"); //$NON-NLS-1$ >+ } catch (ParserException e) { >+ // should have a diagnostic describing the problem if it is a >+ // "normal" parse failure >+ assertNoException(getDiagnostic(), ClassCastException.class); >+ } >+ } >+ >+ /** > * Tests that the collect() iterator correctly flattens its result. > */ > public void test_collect_flattens_217461() { >Index: src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/tests/org.eclipse.ocl.ecore.tests/src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java,v >retrieving revision 1.11 >diff -u -r1.11 AbstractTestSuite.java >--- src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java 5 May 2008 16:47:30 -0000 1.11 >+++ src/org/eclipse/ocl/ecore/tests/AbstractTestSuite.java 17 May 2008 20:37:31 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc. 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 >@@ -28,6 +28,7 @@ > import junit.framework.TestCase; > import junit.framework.TestSuite; > >+import org.eclipse.emf.common.util.Diagnostic; > import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.EAttribute; > import org.eclipse.emf.ecore.EClass; >@@ -61,7 +62,10 @@ > import org.eclipse.ocl.helper.Choice; > import org.eclipse.ocl.helper.ChoiceKind; > import org.eclipse.ocl.helper.OCLHelper; >+import org.eclipse.ocl.lpg.ProblemHandler; >+import org.eclipse.ocl.parser.OCLProblemHandler; > import org.eclipse.ocl.types.OCLStandardLibrary; >+import org.eclipse.ocl.util.OCLUtil; > import org.eclipse.ocl.utilities.OCLFactory; > import org.eclipse.ocl.utilities.Visitable; > >@@ -602,6 +606,45 @@ > assertNull("Choice found: " + name + ", " + kind, //$NON-NLS-1$ //$NON-NLS-2$ > findChoice(choices, kind, name)); > } >+ >+ /** >+ * Asserts that a exception of the specified kind is not signalled by >+ * the a given diagnostic or (recursively) its children. >+ * >+ * @param diagnostic a diagnostic >+ * @param excType an exception that must not be indicated by the diagnostic >+ * >+ * @since 1.2 >+ */ >+ protected void assertNoException(Diagnostic diagnostic, java.lang.Class<? extends Throwable> excType) { >+ if (excType.isInstance(diagnostic.getException())) { >+ fail("Diagnostic signals a(n) " + excType.getSimpleName()); //$NON-NLS-1$ >+ } >+ >+ for (Diagnostic nested : diagnostic.getChildren()) { >+ assertNoException(nested, excType); >+ } >+ } >+ >+ /** >+ * Obtains the diagnostic describing the problem in the last failed parse, >+ * asserting that it is not <code>null</code>. >+ * >+ * @return the diagnostic >+ */ >+ protected Diagnostic getDiagnostic() { >+ OCLProblemHandler handler = (OCLProblemHandler) OCLUtil.getAdapter( >+ ocl.getEnvironment(), ProblemHandler.class); >+ >+ Diagnostic result = handler.getDiagnostic(); >+ if (result == null) { >+ result = helper.getProblems(); >+ } >+ >+ assertNotNull("No diagnostic", result); //$NON-NLS-1$ >+ >+ return result; >+ } > > protected OCLStandardLibrary<EClassifier> getOCLStandardLibrary() { > return ocl.getEnvironment().getOCLStandardLibrary(); >#P org.eclipse.ocl.uml.tests >Index: src/org/eclipse/ocl/uml/tests/AbstractTestSuite.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/tests/org.eclipse.ocl.uml.tests/src/org/eclipse/ocl/uml/tests/AbstractTestSuite.java,v >retrieving revision 1.10 >diff -u -r1.10 AbstractTestSuite.java >--- src/org/eclipse/ocl/uml/tests/AbstractTestSuite.java 5 May 2008 16:47:39 -0000 1.10 >+++ src/org/eclipse/ocl/uml/tests/AbstractTestSuite.java 17 May 2008 20:37:34 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc. 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 >@@ -31,6 +31,7 @@ > import junit.framework.TestSuite; > > import org.eclipse.emf.common.util.BasicEList; >+import org.eclipse.emf.common.util.Diagnostic; > import org.eclipse.emf.common.util.EList; > import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.EFactory; >@@ -48,10 +49,13 @@ > import org.eclipse.ocl.helper.Choice; > import org.eclipse.ocl.helper.ChoiceKind; > import org.eclipse.ocl.helper.OCLHelper; >+import org.eclipse.ocl.lpg.ProblemHandler; >+import org.eclipse.ocl.parser.OCLProblemHandler; > import org.eclipse.ocl.types.OCLStandardLibrary; > import org.eclipse.ocl.uml.ExpressionInOCL; > import org.eclipse.ocl.uml.OCL; > import org.eclipse.ocl.uml.util.OCLUMLUtil; >+import org.eclipse.ocl.util.OCLUtil; > import org.eclipse.ocl.utilities.Visitable; > import org.eclipse.uml2.uml.Association; > import org.eclipse.uml2.uml.AssociationClass; >@@ -660,6 +664,45 @@ > assertNull("Choice found: " + name + ", " + kind, //$NON-NLS-1$ //$NON-NLS-2$ > findChoice(choices, kind, name)); > } >+ >+ /** >+ * Asserts that a exception of the specified kind is not signalled by >+ * the a given diagnostic or (recursively) its children. >+ * >+ * @param diagnostic a diagnostic >+ * @param excType an exception that must not be indicated by the diagnostic >+ * >+ * @since 1.2 >+ */ >+ protected void assertNoException(Diagnostic diagnostic, java.lang.Class<? extends Throwable> excType) { >+ if (excType.isInstance(diagnostic.getException())) { >+ fail("Diagnostic signals a(n) " + excType.getSimpleName()); //$NON-NLS-1$ >+ } >+ >+ for (Diagnostic nested : diagnostic.getChildren()) { >+ assertNoException(nested, excType); >+ } >+ } >+ >+ /** >+ * Obtains the diagnostic describing the problem in the last failed parse, >+ * asserting that it is not <code>null</code>. >+ * >+ * @return the diagnostic >+ */ >+ protected Diagnostic getDiagnostic() { >+ OCLProblemHandler handler = (OCLProblemHandler) OCLUtil.getAdapter( >+ ocl.getEnvironment(), ProblemHandler.class); >+ >+ Diagnostic result = handler.getDiagnostic(); >+ if (result == null) { >+ result = helper.getProblems(); >+ } >+ >+ assertNotNull("No diagnostic", result); //$NON-NLS-1$ >+ >+ return result; >+ } > > protected OCLStandardLibrary<Classifier> getOCLStandardLibrary() { > return ocl.getEnvironment().getOCLStandardLibrary(); >Index: src/org/eclipse/ocl/uml/tests/IteratorsTest.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/tests/org.eclipse.ocl.uml.tests/src/org/eclipse/ocl/uml/tests/IteratorsTest.java,v >retrieving revision 1.4 >diff -u -r1.4 IteratorsTest.java >--- src/org/eclipse/ocl/uml/tests/IteratorsTest.java 23 Apr 2007 21:16:24 -0000 1.4 >+++ src/org/eclipse/ocl/uml/tests/IteratorsTest.java 17 May 2008 20:37:34 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2008 IBM Corporation, Zeligsoft Inc. 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 >@@ -335,6 +335,26 @@ > } > > /** >+ * Tests that parsing fails, in the case of an unknown property in a >+ * collection navigation, with an appropriate parse failure, not a >+ * <code>ClassCastException</code>. >+ */ >+ public void test_implicitCollect_unknownAttribute_232669() { >+ helper.setContext(getMetaclass("Package")); //$NON-NLS-1$ >+ >+ try { >+ // this shouldn't parse, anyway >+ helper.createInvariant("nestedPackage.unknownAttribute"); //$NON-NLS-1$ >+ >+ fail("Should not have parsed"); //$NON-NLS-1$ >+ } catch (ParserException e) { >+ // should have a diagnostic describing the problem if it is a >+ // "normal" parse failure >+ assertNoException(getDiagnostic(), ClassCastException.class); >+ } >+ } >+ >+ /** > * Tests the collectNested() iterator. > */ > public void test_collectNested() { >@@ -882,7 +902,7 @@ > fail("Failed to parse or evaluate: " + e.getLocalizedMessage()); //$NON-NLS-1$ > } > } >- >+ > // > // Framework methods > // >#P org.eclipse.ocl >Index: src/org/eclipse/ocl/parser/AbstractOCLAnalyzer.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.mdt/org.eclipse.ocl/plugins/org.eclipse.ocl/src/org/eclipse/ocl/parser/AbstractOCLAnalyzer.java,v >retrieving revision 1.11 >diff -u -r1.11 AbstractOCLAnalyzer.java >--- src/org/eclipse/ocl/parser/AbstractOCLAnalyzer.java 4 May 2008 01:17:02 -0000 1.11 >+++ src/org/eclipse/ocl/parser/AbstractOCLAnalyzer.java 17 May 2008 20:37:39 -0000 >@@ -1,7 +1,7 @@ > /** > * <copyright> > * >- * Copyright (c) 2005, 2008 IBM Corporation and others. >+ * Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc. 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 >@@ -2285,9 +2285,11 @@ > > /* > * If the source type is a collection, then need there is an implicit COLLECT operator. >- * Note that this rule is not called after "->". >+ * Note that this rule is not called after "->". Check for FeatureCallExp >+ * in case we created a dummy InvalidLiteralExp. > */ >- if ((source != null) && source.getType() instanceof CollectionType) { >+ if ((source != null) && (source.getType() instanceof CollectionType) >+ && (astNode instanceof FeatureCallExp)) { > astNode = createImplicitCollect( > source, > (FeatureCallExp<C>) astNode,
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 232669
:
100781
| 100784