Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2009-01-14 13:54:26 -0500
committerashatalin2009-01-14 13:54:26 -0500
commit03f3b173cd7455cda66122829acc7d3ead090927 (patch)
tree6be8542f2cd6f30d1f298e16475d524442cd4553
parentcafd45f82c971415f83f84bdf576856476ce64c1 (diff)
downloadorg.eclipse.gmf-tooling-03f3b173cd7455cda66122829acc7d3ead090927.tar.gz
org.eclipse.gmf-tooling-03f3b173cd7455cda66122829acc7d3ead090927.tar.xz
org.eclipse.gmf-tooling-03f3b173cd7455cda66122829acc7d3ead090927.zip
Throwing specific exception in case of ambiguous xpand definitions to report this problem as compilation error (to the ProblemsView) instead of runtime .log file.
-rw-r--r--tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/AopFeatureTest.java15
-rw-r--r--tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/CompositeResourcesTest.java14
-rw-r--r--tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/PolymorphismTest.java9
-rw-r--r--tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/QvtExtensions.java33
-rw-r--r--tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/TestsResourceManager.java9
5 files changed, 49 insertions, 31 deletions
diff --git a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/AopFeatureTest.java b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/AopFeatureTest.java
index 066b2f561..90adc3793 100644
--- a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/AopFeatureTest.java
+++ b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/AopFeatureTest.java
@@ -15,6 +15,7 @@ import junit.framework.TestCase;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.gmf.internal.xpand.BufferOutput;
+import org.eclipse.gmf.internal.xpand.model.AmbiguousDefinitionException;
import org.eclipse.gmf.internal.xpand.model.ExecutionContextImpl;
import org.eclipse.gmf.internal.xpand.model.Scope;
import org.eclipse.gmf.internal.xpand.model.XpandDefinition;
@@ -43,43 +44,43 @@ public class AopFeatureTest extends TestCase {
oclStringType = execCtx.getOCLEnvironment().getOCLStandardLibrary().getString();
}
- public final void test_test1_Object() {
+ public final void test_test1_Object() throws AmbiguousDefinitionException {
final XpandDefinition def = execCtx.findDefinition(prefix() + "Adviced::advtest1", oclAnyType, null);
def.evaluate(execCtx);
assertEquals("12", buffer.toString());
}
- public final void test_test2_Object() {
+ public final void test_test2_Object() throws AmbiguousDefinitionException {
final XpandDefinition def = execCtx.findDefinition(prefix() + "Adviced::advtest2", oclAnyType, null);
def.evaluate(execCtx);
assertEquals("13", buffer.toString());
}
- public final void test_te2st_Object() {
+ public final void test_te2st_Object() throws AmbiguousDefinitionException {
final XpandDefinition def = execCtx.findDefinition(prefix() + "Adviced::te2st", oclAnyType, null);
def.evaluate(execCtx);
assertEquals("4", buffer.toString());
}
- public final void test_test1_String() {
+ public final void test_test1_String() throws AmbiguousDefinitionException {
final XpandDefinition def = execCtx.findDefinition(prefix() + "Adviced::advtest1", oclStringType, null);
def.evaluate(execCtx);
assertEquals("1258", buffer.toString());
}
- public final void test_test1_StringParam_String() {
+ public final void test_test1_StringParam_String() throws AmbiguousDefinitionException {
final XpandDefinition def = execCtx.findDefinition(prefix() + "Adviced::advtest1", oclStringType, new EClassifier[] { oclStringType });
def.evaluate(execCtx);
assertEquals("678", buffer.toString());
}
- public final void test_test1_StringParams_String() {
+ public final void test_test1_StringParams_String() throws AmbiguousDefinitionException {
final XpandDefinition def = execCtx.findDefinition(prefix() + "Adviced::advtest1", oclStringType, new EClassifier[] { oclStringType, oclStringType });
def.evaluate(execCtx);
assertEquals("78", buffer.toString());
}
- public final void testQualifiedAspect() {
+ public final void testQualifiedAspect() throws AmbiguousDefinitionException {
final XpandDefinition def = execCtx.findDefinition(prefix() + "Adviced::advtest3", oclStringType, null);
def.evaluate(execCtx);
assertEquals("15qualified-test3", buffer.toString());
diff --git a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/CompositeResourcesTest.java b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/CompositeResourcesTest.java
index b614fb64b..da6f26d32 100644
--- a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/CompositeResourcesTest.java
+++ b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/CompositeResourcesTest.java
@@ -17,12 +17,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.nio.charset.Charset;
import java.util.ArrayList;
import junit.framework.TestCase;
import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.gmf.internal.xpand.BufferOutput;
+import org.eclipse.gmf.internal.xpand.model.AmbiguousDefinitionException;
import org.eclipse.gmf.internal.xpand.model.ExecutionContext;
import org.eclipse.gmf.internal.xpand.model.ExecutionContextImpl;
import org.eclipse.gmf.internal.xpand.model.Scope;
@@ -50,8 +52,9 @@ public class CompositeResourcesTest extends TestCase {
/**
* Tests that DEFINE statements are effectively the same as AROUND without targetDef.proceed()
+ * @throws AmbiguousDefinitionException
*/
- public void testRedefineInAspect() {
+ public void testRedefineInAspect() throws AmbiguousDefinitionException {
myResourceManager.setPrefixes((String) null);
XpandDefinition definition = myContext.findDefinition(qualify("Overridable::testRedefineInAspect"), oclStringType, new EClassifier[0]);
definition.evaluate(myContext);
@@ -63,7 +66,7 @@ public class CompositeResourcesTest extends TestCase {
assertEquals("testRedefineRedefined", myBuffer.toString());
}
- public void testOverrideXpand() {
+ public void testOverrideXpand() throws AmbiguousDefinitionException {
myResourceManager.setPrefixes((String) null);
XpandDefinition definition = myContext.findDefinition(qualify("Overridable::test2"), oclStringType, new EClassifier[0]);
definition.evaluate(myContext);
@@ -118,11 +121,16 @@ public class CompositeResourcesTest extends TestCase {
if (resourceAsStream == null) {
return null;
}
- return new InputStreamReader(resourceAsStream);
+ return new InputStreamReader(resourceAsStream, Charset.forName("ISO-8859-1"));
}
@Override
protected void handleParserException(ParserException ex) {
fail(ex.getClass().getName());
}
+
+ @Override
+ protected String resolveCFileFullPath(String fullyQualifiedName, String fileExtension) {
+ return fullyQualifiedName + "." + fileExtension;
+ }
}
}
diff --git a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/PolymorphismTest.java b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/PolymorphismTest.java
index c9fb12fad..8d62fe59c 100644
--- a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/PolymorphismTest.java
+++ b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/PolymorphismTest.java
@@ -15,6 +15,7 @@ import junit.framework.TestCase;
import org.eclipse.gmf.internal.xpand.BufferOutput;
import org.eclipse.gmf.internal.xpand.XpandFacade;
+import org.eclipse.gmf.internal.xpand.model.AmbiguousDefinitionException;
import org.eclipse.gmf.internal.xpand.model.ExecutionContextImpl;
import org.eclipse.gmf.internal.xpand.model.Scope;
@@ -35,22 +36,22 @@ public class PolymorphismTest extends TestCase {
xpandFacade = new XpandFacade(new ExecutionContextImpl(new Scope(new TestsResourceManager(), null, new BufferOutput(buffer))));
}
- public void testContextualPolymorphysm() {
+ public void testContextualPolymorphysm() throws AmbiguousDefinitionException {
checkDefinition("contextualPolymorphysm", "myString", "StringDefine");
checkDefinition("contextualPolymorphysm", new Object(), "OclAnyDefine");
}
- public void testParameterPolymorphysm() {
+ public void testParameterPolymorphysm() throws AmbiguousDefinitionException {
checkDefinition("parameterPolymorphysm", "myString", "StringDefine");
checkDefinition("parameterPolymorphysm", new Object(), "OclAnyDefine");
}
- public void testSecondParameterPolymorphysm() {
+ public void testSecondParameterPolymorphysm() throws AmbiguousDefinitionException {
checkDefinition("secondParameterPolymorphysm", "myString", "StringDefine");
checkDefinition("secondParameterPolymorphysm", new Object(), "OclAnyDefine");
}
- public void checkDefinition(String definitionName, Object targetObject, String expectedResult) {
+ public void checkDefinition(String definitionName, Object targetObject, String expectedResult) throws AmbiguousDefinitionException {
xpandFacade.evaluate(TEMPLATE_FILE_PREFIX + definitionName, targetObject, NO_PARAMS);
assertEquals(expectedResult, buffer.toString());
buffer.delete(0, buffer.length());
diff --git a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/QvtExtensions.java b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/QvtExtensions.java
index 8b30b54ae..837d88060 100644
--- a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/QvtExtensions.java
+++ b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/QvtExtensions.java
@@ -22,6 +22,7 @@ import junit.framework.TestCase;
import org.eclipse.emf.ecore.EcoreFactory;
import org.eclipse.gmf.internal.xpand.BufferOutput;
import org.eclipse.gmf.internal.xpand.XpandFacade;
+import org.eclipse.gmf.internal.xpand.model.AmbiguousDefinitionException;
import org.eclipse.gmf.internal.xpand.model.AnalysationIssue;
import org.eclipse.gmf.internal.xpand.model.ExecutionContextImpl;
import org.eclipse.gmf.internal.xpand.model.Scope;
@@ -74,7 +75,7 @@ public class QvtExtensions extends TestCase {
fail(sb.toString());
}
- public void testContextInvocationContextualQuery() {
+ public void testContextInvocationContextualQuery() throws AmbiguousDefinitionException {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkStringContextInvocation", "ContextString1");
}
@@ -91,40 +92,40 @@ public class QvtExtensions extends TestCase {
*/
// test if QVTO is capable of Collection() context operations (Bug #243684)
- public void testQvtoIsCapableToDefineContextOpsToCollections() {
+ public void testQvtoIsCapableToDefineContextOpsToCollections() throws AmbiguousDefinitionException {
String arg = "Str";
xpandFacade.evaluate("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::collectionContextOp", arg, null);
System.err.println(buffer.toString());
assertEquals(arg, buffer.toString().trim());
}
- public void testStaticInvocationStaticQuery() {
+ public void testStaticInvocationStaticQuery() throws AmbiguousDefinitionException {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkIntStaticInvocation", 20);
}
- public void testBooleanTypeQuery() {
+ public void testBooleanTypeQuery() throws AmbiguousDefinitionException {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkBoolean", false);
}
// TODO: Plugin test configuration required to execute this kind of test.
- public void _testDeployedMetaType() {
+ public void _testDeployedMetaType() throws AmbiguousDefinitionException {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkDeployedMetaType", EcoreFactory.eINSTANCE.createEAttribute());
}
- public void testCollectionOfStrings() {
+ public void testCollectionOfStrings() throws AmbiguousDefinitionException {
List<String> sequence = CollectionUtil.<String>createNewSequence();
sequence.add("SampleString1");
sequence.add("SampleString2");
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkCollection", sequence);
}
- public void testSetOfBooleans() {
+ public void testSetOfBooleans() throws AmbiguousDefinitionException {
Set<Boolean> collection = new HashSet<Boolean>();
collection.add(true);
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkSet", collection);
}
- public void testSequenceOfBooleans() {
+ public void testSequenceOfBooleans() throws AmbiguousDefinitionException {
List<Boolean> collection = new ArrayList<Boolean>();
collection.add(true);
collection.add(false);
@@ -133,7 +134,7 @@ public class QvtExtensions extends TestCase {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkSequence", collection);
}
- public void testBagOfBooleans() {
+ public void testBagOfBooleans() throws AmbiguousDefinitionException {
List<Boolean> collection = new ArrayList<Boolean>();
collection.add(true);
collection.add(false);
@@ -142,7 +143,7 @@ public class QvtExtensions extends TestCase {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkBag", collection);
}
- public void testOrderedSetOfIntegers() {
+ public void testOrderedSetOfIntegers() throws AmbiguousDefinitionException {
Set<Integer> collection = new HashSet<Integer>();
collection.add(1);
collection.add(2);
@@ -151,29 +152,29 @@ public class QvtExtensions extends TestCase {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkOrderedSet", collection);
}
- public void testQueryParametersNotPolymorphycForSelf() {
+ public void testQueryParametersNotPolymorphycForSelf() throws AmbiguousDefinitionException {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkQueryParametersNotPolymorphycForSelf", "ContextString1");
}
- public void testQueryParametersNotPolymorphycForParameter() {
+ public void testQueryParametersNotPolymorphycForParameter() throws AmbiguousDefinitionException {
Object[] yes_no_string = new Object[] {YES_NO[0], YES_NO[1], "OneMoreString"};
xpandFacade.evaluate("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkQueryParametersNotPolymorphycForParameter", "ContextString1", yes_no_string);
assertEquals(yes_no_string[0], buffer.toString());
}
- public void testQueryParametersNotPolymorphycForLet() {
+ public void testQueryParametersNotPolymorphycForLet() throws AmbiguousDefinitionException {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkQueryParametersNotPolymorphycForLet", "ContextString1");
}
- public void testQueryContextPolymorphycForSelf() {
+ public void testQueryContextPolymorphycForSelf() throws AmbiguousDefinitionException {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkQueryContextPolymorphycForSelf", "ContextString1");
}
- public void testQueryParametersNotPolymorphycForForeach() {
+ public void testQueryParametersNotPolymorphycForForeach() throws AmbiguousDefinitionException {
checkQueryCall("org::eclipse::gmf::tests::xpand::evaluate::QvtExtension::checkQueryParametersNotPolymorphycForForeach", "ContextString1");
}
- private void checkQueryCall(String queryName, Object selfObject) {
+ private void checkQueryCall(String queryName, Object selfObject) throws AmbiguousDefinitionException {
xpandFacade.evaluate(queryName, selfObject, YES_NO);
assertEquals(YES_NO[0], buffer.toString());
}
diff --git a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/TestsResourceManager.java b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/TestsResourceManager.java
index c56aaa0b9..c1ac7a3ac 100644
--- a/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/TestsResourceManager.java
+++ b/tests/org.eclipse.gmf.tests.xpand/src/org/eclipse/gmf/tests/xpand/TestsResourceManager.java
@@ -13,6 +13,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.nio.charset.Charset;
import org.eclipse.gmf.internal.xpand.ResourceManager;
import org.eclipse.gmf.internal.xpand.util.ParserException;
@@ -42,11 +43,17 @@ public class TestsResourceManager extends ResourceManagerImpl implements Resourc
if (inputStream == null) {
throw new FileNotFoundException(fullyQualifiedName);
}
- return new Reader[] { new InputStreamReader(inputStream) };
+ return new Reader[] { new InputStreamReader(inputStream, Charset.forName("ISO-8859-1")) };
}
@Override
protected boolean shouldCache() {
return false;
}
+
+ @Override
+ protected String resolveCFileFullPath(String fullyQualifiedName, String fileExtension) {
+ return fullyQualifiedName + "." + fileExtension;
+ }
+
}

Back to the top