Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [qvto-dev] Fwd: Re: Eclipse QVTo: saving QVTo resource

Hi Christopher, hi Ed,

thanks for your responses.

My understanding of the QVTo import syntax and semantics were wrong, so I apologize for asking probably to early.

Yes, QVTo transformations can already be created in qvtox Format, e.g. a qvto transformation that generates
another qvto transformation and is run with a "*.qvtox"-target-URI in the launch config will happily do so.

But qvtox is not very human readable. Even for a use case were a generated QVTo transformation is
intended to only be consumed by the compiler, I assume that the development process for it will
benefit from the human readable qvto-Version.

Saving to qvtox can programmatically be done by ExeXMISerializer.saveUnitXMI().

I attach UnparserTests.java and TestQvtUnparser.java, which are work in progress (!!!), as you asked for it.
ExeXMISerializer is called in TestQvtUnparser.saveCompiledUnitsAsXMI().
General approach of the current testing is:
1. compile and check on errors for test transformations
2. unparse
3. recompile and check on errors for unparsed transformation copies
4. EMFCompare compile and recompile

Currently I am still wading thru 3.

Yes, there are issues in the ASTNodes. I will bug report them as soon as I have collected them all and am at least thru step 3 of the tests.

Sankt Augustin Alaaf,

Uwe


Am 26.01.2016 um 14:38 schrieb Christopher Gerking:

Hi everybody

 

Regardless of the OMG compliance, I wonder how beneficial it really is to save a transformation back to the textual *.qvto syntax.

Instead, why not using *.qvtox as an exchange format once a transformation has been compiled? Some details below:

 

·         Today, the QVTo builder has a hidden argument to store the compiled AST to *.qvtox.

 

·         In my branch http://git.eclipse.org/c/mmt/org.eclipse.qvto.git/log/?h=cgerking/478006, I prepared the TransformationExecutor API for loading a transformation from a given *.qvtox URI.

 

·         What is missing is an intuitive way to compile and save a transformation to *.qvtox. The above builder argument is very unintuitive. Any ideas?

 

Additionally, I’m not sure about the limitations of the serialized AST. I remember some insufficiencies with respect to Java blackboxes.

 

 

Uwe, your launch configuration refers to a class org.eclipse.m2m.tests.qvt.oml.UnparserTests. In order to reproduce the problems, can you share it somehow?

 

 

Kind regards

Christopher

 

Von: qvto-dev-bounces@xxxxxxxxxxx [mailto:qvto-dev-bounces@xxxxxxxxxxx] Im Auftrag von Uwe Ritzmann
Gesendet: Freitag, 22. Ja
nuar 2016 18:39
An: qvto-dev@xxxxxxxxxxx
Betreff: [qvto-dev] Fwd: Re: Eclipse QVTo: saving QVTo resource

 

Dear QVTo team,

unfortunately my budget of available time since my last email
did not allow me to proceed with my work from 2012 until recently.

As QvtOperationalResourceImpl.save() is still unimplemented,
I have continued the work. Thanks a lot for the now available oomph
setup for QVTo, which decreases the necessary up front time
investment tremendously.

For the first set of tests I shamelessly copied/adapted from TestQvtParser
and its associated testdata.

The problem I currently do not understand and would appreciate your advise for
is that the qvto-files that I generate during the test run and then try to compile
are not able to resolve e.g. TestBlackboxLibrary, which should be provided by
org.eclipse.m2m.tests.qvt.oml (via extension org.eclipse.m2m.qvt.oml.ocl.libraries, right?).
The test launch is with "all workspace and enabled target plugins".

My JUnit launch configuration for UnparserTests is attached.

Any hint is appreciated.

Best Regards

Uwe


package org.eclipse.m2m.tests.qvt.oml;

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({TestQvtUnparser.class})
public class UnparserTests {
    
    static class TestData {
        public TestData(String dir, int errCount) { 
        	this(dir, errCount, -1);
        }
        
        public TestData(String dir, int errCount, int warnCount) {
            myDir = dir; 
            myErrCount = errCount; 
            myWarnCount = warnCount;
            usesSourceAnnotations = false;
        }
        
        public String getDir() { return myDir; }
        public int getErrCount() { return myErrCount; }
        public int getWarnCount() { return myWarnCount; }
        
        public int getAllProblemsCount() {
			return myErrCount + myWarnCount;
		}
        
        public boolean usesSourceAnnotations() {
        	return usesSourceAnnotations;
		}
        
        private final String myDir;
        private final int myErrCount;
        private final int myWarnCount;
        private boolean usesSourceAnnotations;

        /**
         * Creates that should be check for match of compilation problems with expected problem 
         * annotation in the test QVT sources 
         */
        public static TestData createSourceChecked(String dir, int errCount, int warnCount) {
        	TestData data = new TestData(dir, errCount, warnCount);
        	data.usesSourceAnnotations = true; 
        	return data;
        }

        public String toString() { return "TestData " + this.myDir + " --> " + this.myErrCount + "/" + this.myWarnCount; }
    }    
}
package org.eclipse.m2m.tests.qvt.oml;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.emf.common.util.BasicMonitor;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.compare.AttributeChange;
import org.eclipse.emf.compare.Comparison;
import org.eclipse.emf.compare.Diff;
import org.eclipse.emf.compare.EMFCompare;
import org.eclipse.emf.compare.FeatureMapChange;
import org.eclipse.emf.compare.Match;
import org.eclipse.emf.compare.ReferenceChange;
import org.eclipse.emf.compare.ResourceAttachmentChange;
import org.eclipse.emf.compare.ResourceLocationChange;
import org.eclipse.emf.compare.diff.DefaultDiffEngine;
import org.eclipse.emf.compare.diff.FeatureFilter;
import org.eclipse.emf.compare.scope.DefaultComparisonScope;
import org.eclipse.emf.compare.scope.IComparisonScope;
import org.eclipse.emf.compare.utils.EMFComparePrettyPrinter;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.m2m.internal.qvt.oml.QvtMessage;
import org.eclipse.m2m.internal.qvt.oml.common.MDAConstants;
import org.eclipse.m2m.internal.qvt.oml.common.io.FileUtil;
import org.eclipse.m2m.internal.qvt.oml.compiler.CompiledUnit;
import org.eclipse.m2m.internal.qvt.oml.compiler.CompilerUtils;
import org.eclipse.m2m.internal.qvt.oml.compiler.ExeXMISerializer;
import org.eclipse.m2m.internal.qvt.oml.compiler.QVTOCompiler;
import org.eclipse.m2m.internal.qvt.oml.compiler.QvtCompilerOptions;
import org.eclipse.m2m.internal.qvt.oml.compiler.UnitProxy;
import org.eclipse.m2m.internal.qvt.oml.emf.util.EmfException;
import org.eclipse.m2m.internal.qvt.oml.emf.util.EmfUtil;
import org.eclipse.m2m.internal.qvt.oml.emf.util.urimap.MetamodelURIMappingHelper;
import org.eclipse.m2m.internal.qvt.oml.expressions.EntryOperation;
import org.eclipse.m2m.internal.qvt.oml.expressions.Module;
import org.eclipse.m2m.internal.qvt.oml.expressions.OperationBody;
import org.eclipse.m2m.internal.qvt.oml.project.builder.WorkspaceUnitResolver;
import org.eclipse.m2m.internal.qvt.oml.runtime.project.TransformationUtil;
import org.eclipse.m2m.tests.qvt.oml.UnparserTests.TestData;
import org.eclipse.m2m.tests.qvt.oml.util.TestUtil;
import org.eclipse.ocl.ecore.EcorePackage;
import org.eclipse.ocl.expressions.OCLExpression;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import junit.framework.TestCase;

/**
 * @author Uwe Ritzmann
 */
@RunWith(Parameterized.class)
public class TestQvtUnparser extends TestCase {
		
	public TestQvtUnparser(TestData data) {
        super(data.getDir());
        myData = data;        
    }
	
	@Parameters(name="{0}")
	public static Iterable<TestData> data() {
		return Arrays.asList(
			new TestData[] {
		        new TestData("A",0,0),  //$NONXXX
		        new TestData("A_minimal",0,0),  //$NONXXX
//		        new TestData("AA",0,0),  //$NONXXX
//		        new TestData("abstractout",0,0),  //$NONXXX
		        new TestData("abstractresult",0,0),  //$NONXXX
		        new TestData("accessbooleans",0,0),  //$NONXXX
		        new TestData("addclass",0,0),  //$NONXXX
		        new TestData("addclassviamodificationininit",0,0),  //$NONXXX
		        new TestData("addclassviaoutinocl",0,0),  //$NONXXX
		        new TestData("addclassviasequence",0,0),  //$NONXXX
		        new TestData("addrealtostring",0,0),  //$NONXXX
		        new TestData("addundefined",0,0),  //$NONXXX
		        new TestData("allinstances",0,0),  //$NONXXX
		        new TestData("AnotherTransformation",0,0),  //$NONXXX
		        new TestData("AnyExtension",0,0),  //$NONXXX
		        new TestData("assert_log",0,0),  //$NONXXX
//		        new TestData("assignereadonlyprop",0,0),  //$NONXXX
//		        new TestData("assign_inoutParam",0,0),  //$NONXXX
//		        new TestData("assign_inParam",0,0),  //$NONXXX
		        new TestData("assignresultininit",0,0),  //$NONXXX
		        new TestData("assigntonullowner",0,0),  //$NONXXX
		        new TestData("assigntoprimfeature",0,0),  //$NONXXX
//		        new TestData("assign_varThis",0,0),  //$NONXXX
		        new TestData("auxtransf",0,0),  //$NONXXX
//		        new TestData("B",0,0),  //$NONXXX
		        new TestData("b1",0,0),  //$NONXXX
//		        new TestData("b2",0,0),  //$NONXXX
//		        new TestData("badtype",0,0),  //$NONXXX
		        new TestData("bagorderedsetintersection",0,0),  //$NONXXX
//		        new TestData("Bar",0,0),  //$NONXXX
		        new TestData("Base",0,0),  //$NONXXX
	        	new TestData("blackboxlib_237781",0,0),  //$NONXXX
				new TestData("blackboxlib_uri",0,0),  //$NONXXX
				new TestData("blackboxlib_annotation_java",0,0),  //$NONXXX
		        new TestData("blackboxlibASTmodel",0,0),  //$NONXXX
		        new TestData("blackboxlib_context",0,0),  //$NONXXX
		        new TestData("bodywithsemicolon",0,0),  //$NONXXX
		        new TestData("boxing",0,0),  //$NONXXX
		        new TestData("bug204126_1",0,0),  //$NONXXX
		        new TestData("bug204126_2",0,0),  //$NONXXX
		        new TestData("bug204126_3",0,0),  //$NONXXX
		        new TestData("bug204126_4",0,0),  //$NONXXX
		        new TestData("bug204126_5",0,0),  //$NONXXX
		        new TestData("bug204126_6",0,0),  //$NONXXX
		        new TestData("bug204126_7",0,0),  //$NONXXX
		        new TestData("bug205303_1",0,0),  //$NONXXX
		        new TestData("bug205303_2",0,0),  //$NONXXX
		        new TestData("bug_214938",0,0),  //$NONXXX
		        new TestData("bug216317",0,0),  //$NONXXX
		        new TestData("bug219075_1",0,0),  //$NONXXX
		        new TestData("bug224094_minimal",0,0),  //$NONXXX
/*		        new TestData("bug224094",0,0),  //$NONXXX
		        new TestData("bug233984",0,0),  //$NONXXX
		        new TestData("bug2437_1",0,0),  //$NONXXX
		        new TestData("bug2437_2",0,0),  //$NONXXX
		        new TestData("bug2437_3",0,0),  //$NONXXX
		        new TestData("bug2437_4",0,0),  //$NONXXX
		        new TestData("bug2437_5",0,0),  //$NONXXX
		        new TestData("bug244701",0,0),  //$NONXXX
//		        new TestData("bug254962",0,0),  //$NONXXX
		        new TestData("bug267917",0,0),  //$NONXXX
//		        new TestData("bug268636",0,0),  //$NONXXX
		        new TestData("bug268636lib",0,0),  //$NONXXX
//		        new TestData("bug272869",0,0),  //$NONXXX
		        new TestData("bug272869lib",0,0),  //$NONXXX
		        new TestData("bug2732",0,0),  //$NONXXX
//		        new TestData("bug2732_wrongcondition",0,0),  //$NONXXX
		        new TestData("bug2741",0,0),  //$NONXXX
		        new TestData("bug274105_274505",0,0),  //$NONXXX
		        new TestData("bug2787",0,0),  //$NONXXX
		        new TestData("bug2839",0,0),  //$NONXXX
//		        new TestData("bug289982",0,0),  //$NONXXX
		        new TestData("bug289982_ambiguousLib",0,0),  //$NONXXX
//		        new TestData("bug289982_failed",0,0),  //$NONXXX
//		        new TestData("bug289982_importless",0,0),  //$NONXXX
		        new TestData("bug289982_lib",0,0),  //$NONXXX
		        new TestData("bug289982_lib_failed",0,0),  //$NONXXX
//		        new TestData("bug289982_lib_importless",0,0),  //$NONXXX
		        new TestData("bug289982_undefinedLib",0,0),  //$NONXXX
//		        new TestData("bug289982_validation",0,0),  //$NONXXX
		        new TestData("bug294127",0,0),  //$NONXXX
		        new TestData("bug301134",0,0),  //$NONXXX
//		        new TestData("bug302594",0,0),  //$NONXXX
//		        new TestData("bug309762",0,0),  //$NONXXX
		        new TestData("bug314443",0,0),  //$NONXXX
		        new TestData("bug323915",0,0),  //$NONXXX
		        new TestData("bug325192",0,0),  //$NONXXX
		        new TestData("bug326871",0,0),  //$NONXXX
//		        new TestData("bug326871a",0,0),  //$NONXXX
//		        new TestData("bug326871a_standalone",0,0),  //$NONXXX
		        new TestData("bug326871_lib",0,0),  //$NONXXX
		        new TestData("bug326871_standalone",0,0),  //$NONXXX
//		        new TestData("bug329971",0,0),  //$NONXXX
//		        new TestData("bug358709",0,0),  //$NONXXX
		        new TestData("bug370098",0,0),  //$NONXXX
		        new TestData("bug377882",0,0),  //$NONXXX
//		        new TestData("bug386115",0,0),  //$NONXXX
		        new TestData("bug388325",0,0),  //$NONXXX
		        new TestData("bug388801",0,0),  //$NONXXX
//		        new TestData("bug390088",0,0),  //$NONXXX
//		        new TestData("bug392080",0,0),  //$NONXXX
//		        new TestData("bug392153",0,0),  //$NONXXX
		        new TestData("bug392156",0,0),  //$NONXXX
		        new TestData("bug392429",0,0),  //$NONXXX
		        new TestData("bug397215",0,0),  //$NONXXX
		        new TestData("bug397398",0,0),  //$NONXXX
//		        new TestData("bug397959",0,0),  //$NONXXX
//		        new TestData("bug400233",0,0),  //$NONXXX
		        new TestData("bug400233_lib",0,0),  //$NONXXX
		        new TestData("bug400720",0,0),  //$NONXXX
//		        new TestData("bug401521",0,0),  //$NONXXX
//		        new TestData("bug403440",0,0),  //$NONXXX
		        new TestData("bug404647",0,0),  //$NONXXX
//		        new TestData("bug404647_2",0,0),  //$NONXXX
		        new TestData("bug410470",0,0),  //$NONXXX
		        new TestData("bug413130",0,0),  //$NONXXX
		        new TestData("bug413131",0,0),  //$NONXXX
//		        new TestData("bug413391",0,0),  //$NONXXX
		        new TestData("bug414363",0,0),  //$NONXXX
		        new TestData("bug414472",0,0),  //$NONXXX
//		        new TestData("bug414555",0,0),  //$NONXXX
//		        new TestData("bug414616",0,0),  //$NONXXX
		        new TestData("bug414619",0,0),  //$NONXXX
		        new TestData("bug414642",0,0),  //$NONXXX
		        new TestData("bug415024",0,0),  //$NONXXX
		        new TestData("bug415029",0,0),  //$NONXXX
		        new TestData("bug415209",0,0),  //$NONXXX
		        new TestData("bug415310",0,0),  //$NONXXX
		        new TestData("bug415315",0,0),  //$NONXXX
		        new TestData("bug415661",0,0),  //$NONXXX
//		        new TestData("bug416584",0,0),  //$NONXXX
		        new TestData("bug416584lib",0,0),  //$NONXXX
		        new TestData("bug417751",0,0),  //$NONXXX
		        new TestData("bug417779",0,0),  //$NONXXX
		        new TestData("bug417996",0,0),  //$NONXXX
		        new TestData("bug418512",0,0),  //$NONXXX
//		        new TestData("bug418961",0,0),  //$NONXXX
		        new TestData("bug418961_lib",0,0),  //$NONXXX
		        new TestData("bug419299",0,0),  //$NONXXX
//		        new TestData("bug420970",0,0),  //$NONXXX
		        new TestData("bug422315",0,0),  //$NONXXX
		        new TestData("bug424086",0,0),  //$NONXXX
		        new TestData("bug424584",0,0),  //$NONXXX
		        new TestData("bug424740",0,0),  //$NONXXX
		        new TestData("bug424896",0,0),  //$NONXXX
		        new TestData("bug424912",0,0),  //$NONXXX
		        new TestData("bug424979",0,0),  //$NONXXX
//		        new TestData("bug425069",0,0),  //$NONXXX
		        new TestData("bug425069a",0,0),  //$NONXXX
		        new TestData("bug425634",0,0),  //$NONXXX
		        new TestData("bug427237",0,0),  //$NONXXX
//		        new TestData("bug427237a",0,0),  //$NONXXX
		        new TestData("bug427348",0,0),  //$NONXXX
		        new TestData("bug428028",0,0),  //$NONXXX
		        new TestData("bug428316",0,0),  //$NONXXX
		        new TestData("bug428618",0,0),  //$NONXXX
		        new TestData("bug432786",0,0),  //$NONXXX
		        new TestData("bug433292",0,0),  //$NONXXX
		        new TestData("bug433585",0,0),  //$NONXXX
//		        new TestData("bug433937",0,0),  //$NONXXX
//		        new TestData("bug433937_referenced",0,0),  //$NONXXX
//		        new TestData("bug433937_wrongImport",0,0),  //$NONXXX
//		        new TestData("bug438038",0,0),  //$NONXXX
		        new TestData("bug440514",0,0),  //$NONXXX
//		        new TestData("bug446375",0,0),  //$NONXXX
		        new TestData("bug449445",0,0),  //$NONXXX
		        new TestData("bug449912",0,0),  //$NONXXX
		        new TestData("bug457433",0,0),  //$NONXXX
		        new TestData("bug463395",0,0),  //$NONXXX
		        new TestData("bug463396",0,0),  //$NONXXX
//		        new TestData("bug463410",0,0),  //$NONXXX
//		        new TestData("bug463416",0,0),  //$NONXXX
//		        new TestData("bug463572",0,0),  //$NONXXX
		        new TestData("bug463572_lib",0,0),  //$NONXXX
		        new TestData("bug466705",0,0),  //$NONXXX
		        new TestData("bug467325",0,0),  //$NONXXX
		        new TestData("bug467600",0,0),  //$NONXXX
		        new TestData("bug467600_Bag",0,0),  //$NONXXX
		        new TestData("bug467600_Collection",0,0),  //$NONXXX
		        new TestData("bug467600_List",0,0),  //$NONXXX
		        new TestData("bug467600_OrderedSet",0,0),  //$NONXXX
		        new TestData("bug467600_Sequence",0,0),  //$NONXXX
		        new TestData("bug467600_Set",0,0),  //$NONXXX
//		        new TestData("bug468303",0,0),  //$NONXXX
//		        new TestData("bug475123",0,0),  //$NONXXX
		        new TestData("bugzilla443",0,0),  //$NONXXX
		        new TestData("C",0,0),  //$NONXXX
		        new TestData("calldump",0,0),  //$NONXXX
		        new TestData("calloclIsUndefinedforundefined",0,0),  //$NONXXX
		        new TestData("callvirtforundefined",0,0),  //$NONXXX
		        new TestData("castinttodouble",0,0),  //$NONXXX
		        new TestData("chainedAssignments_261024",0,0),  //$NONXXX
		        new TestData("CheckMemoryLeak",0,0),  //$NONXXX
		        new TestData("ChildInTreeInput",0,0),  //$NONXXX
//		        new TestData("collectionAssignment",0,0),  //$NONXXX
		        new TestData("collectionMappingResult",0,0),  //$NONXXX
//		        new TestData("collectionOperationNotFound_224093",0,0),  //$NONXXX
		        new TestData("collectreturntype",0,0),  //$NONXXX
		        new TestData("ColorSettingPreviewCode",0,0),  //$NONXXX
		        new TestData("compatible",0,0),  //$NONXXX
//		        new TestData("CompilationErrors",0,0),  //$NONXXX
//		        new TestData("composite",0,0),  //$NONXXX
//		        new TestData("compositetransf",0,0),  //$NONXXX
		        new TestData("computeExp_250403",0,0),  //$NONXXX
//		        new TestData("computeExp_252269",0,0),  //$NONXXX
		        new TestData("configpropstype",0,0),  //$NONXXX
		        new TestData("constructors",0,0),  //$NONXXX
		        new TestData("Constructors",0,0),  //$NONXXX
		        new TestData("contextlesscall",0,0),  //$NONXXX
		        new TestData("continue_break",0,0),  //$NONXXX
		        new TestData("continue_perf",0,0),  //$NONXXX
		        new TestData("copynameviacontextmapping",0,0),  //$NONXXX
		        new TestData("customop",0,0),  //$NONXXX
//		        new TestData("DeployedTransformation",0,0),  //$NONXXX
		        new TestData("deprecated_importLocation",0,0),  //$NONXXX
		        new TestData("deprecated_rename",0,0),  //$NONXXX
		        new TestData("dicttype",0,0),  //$NONXXX
		        new TestData("doubleQuoteStrings_262734",0,0),  //$NONXXX
//		        new TestData("dupImportFileUnit",0,0),  //$NONXXX
		        new TestData("dupImportLibrary",0,0),  //$NONXXX
		        new TestData("DuplicatedNamesDetection",0,0),  //$NONXXX
//		        new TestData("duplicateinitvariable",0,0),  //$NONXXX
//		        new TestData("duplicatelocalproperty",0,0),  //$NONXXX
//		        new TestData("duplicateModelTypeDef",0,0),  //$NONXXX
		        new TestData("dynamicpackage",0,0),  //$NONXXX
		        new TestData("Ecore2Ecore",0,0),  //$NONXXX
		        new TestData("Ecore2EcoreExt",0,0),  //$NONXXX
		        new TestData("ecore2uml",0,0),  //$NONXXX
		        new TestData("Ecore2UML",0,0),  //$NONXXX
		        new TestData("emptyExtents",0,0),  //$NONXXX
		        new TestData("emptyinit",0,0),  //$NONXXX
		        new TestData("emptymodule",0,0),  //$NONXXX
		        new TestData("emptyout",0,0),  //$NONXXX
		        new TestData("endsectfull",0,0),  //$NONXXX
		        new TestData("endsectimplicitpopulation",0,0),  //$NONXXX
		        new TestData("endsectimplicitpopulationnoinit",0,0),  //$NONXXX
		        new TestData("endsectinitnopopulation",0,0),  //$NONXXX
		        new TestData("endsectonly",0,0),  //$NONXXX
		        new TestData("endsectpopulationnoinit",0,0),  //$NONXXX
		        new TestData("endsectresultpatch",0,0),  //$NONXXX
		        new TestData("entryOp",0,0),  //$NONXXX
//		        new TestData("entryOpDupl",0,0),  //$NONXXX
		        new TestData("equndefined",0,0),  //$NONXXX
//		        new TestData("errorinexpressionlist",0,0),  //$NONXXX
//		        new TestData("errorsLib",0,0),  //$NONXXX
		        new TestData("escape_sequences_250630",0,0),  //$NONXXX
		        new TestData("exec1",0,0),  //$NONXXX
		        new TestData("exec2",0,0),  //$NONXXX
		        new TestData("exec3",0,0),  //$NONXXX
		        new TestData("exec3_lib",0,0),  //$NONXXX
//		        new TestData("exec3_withImport",0,0),  //$NONXXX
//		        new TestData("exec_erroneous",0,0),  //$NONXXX
		        new TestData("exists",0,0),  //$NONXXX
		        new TestData("ExtendedLibrary",0,0),  //$NONXXX
//		        new TestData("FamilyXForm",0,0),  //$NONXXX
//		        new TestData("featuretypemismatch",0,0),  //$NONXXX
		        new TestData("firstlast",0,0),  //$NONXXX
		        new TestData("firstunparsertest",0,0),  //$NONXXX
//		        new TestData("Foo",0,0),  //$NONXXX
//		        new TestData("FooLib",0,0),  //$NONXXX
		        new TestData("FooLibImport",0,0),  //$NONXXX
		        new TestData("forExp_245275",0,0),  //$NONXXX
//		        new TestData("fqnMainCalls_271987",0,0),  //$NONXXX
//		        new TestData("fqnMainCalls_272937",0,0),  //$NONXXX
//		        new TestData("fqn_noncontextual",0,0),  //$NONXXX
//		        new TestData("fqnOperationCalls_271789",0,0),  //$NONXXX
//		        new TestData("fqntraces",0,0),  //$NONXXX
//		        new TestData("full",0,0),  //$NONXXX
		        new TestData("getpropfromundefined",0,0),  //$NONXXX
		        new TestData("HelpersAndQueries",0,0),  //$NONXXX
		        new TestData("helperSimpleDef_252173",0,0),  //$NONXXX
		        new TestData("imp",0,0),  //$NONXXX
//		        new TestData("imp2",0,0),  //$NONXXX
//		        new TestData("imp3",0,0),  //$NONXXX
//		        new TestData("impError",0,0),  //$NONXXX
//		        new TestData("implicitCallSrc",0,0),  //$NONXXX
		        new TestData("implicitpopulation",0,0),  //$NONXXX
		        new TestData("implicitpopulationwithinit",0,0),  //$NONXXX
//		        new TestData("implicitsource_ocl_234354",0,0),  //$NONXXX
		        new TestData("implicitSrcImport",0,0),  //$NONXXX
//		        new TestData("import_access_extends",0,0),  //$NONXXX
//		        new TestData("import_access_extends_cfgprop",0,0),  //$NONXXX
		        new TestData("imported",0,0),  //$NONXXX
//		        new TestData("Imported",0,0),  //$NONXXX
		        new TestData("imported2",0,0),  //$NONXXX
//		        new TestData("Imported2",0,0),  //$NONXXX
//		        new TestData("importedExtents",0,0),  //$NONXXX
		        new TestData("importedFileUnit",0,0),  //$NONXXX
//		        new TestData("importedInstances",0,0),  //$NONXXX
		        new TestData("ImportedLib",0,0),  //$NONXXX
		        new TestData("ImportedMappingTest",0,0),  //$NONXXX
//		        new TestData("importedprops",0,0),  //$NONXXX
		        new TestData("ImportedTransf1",0,0),  //$NONXXX
		        new TestData("ImportedTransf2",0,0),  //$NONXXX
//		        new TestData("ImportedTransf3",0,0),  //$NONXXX
		        new TestData("ImportedTransf4",0,0),  //$NONXXX
//		        new TestData("importedvirtuals",0,0),  //$NONXXX
//		        new TestData("imports",0,0),  //$NONXXX
//		        new TestData("imports_transformations",0,0),  //$NONXXX
		        new TestData("incompatible",0,0),  //$NONXXX
		        new TestData("initsectresultpatch",0,0),  //$NONXXX
//		        new TestData("initvariable",0,0),  //$NONXXX
		        new TestData("inoutcontextparam",0,0),  //$NONXXX
		        new TestData("inoutcontextparamnoresult",0,0),  //$NONXXX
		        new TestData("inoutMapping",0,0),  //$NONXXX
		        new TestData("InplaceEcore",0,0),  //$NONXXX
		        new TestData("IntermediateData",0,0),  //$NONXXX
//		        new TestData("intermediateprop_import",0,0),  //$NONXXX
		        new TestData("intermediateprop_imported",0,0),  //$NONXXX
		        new TestData("intermediateprop_resolve",0,0),  //$NONXXX
		        new TestData("intermediateprop_trace",0,0),  //$NONXXX
//		        new TestData("intermPropClash",0,0),  //$NONXXX
		        new TestData("intermProperties",0,0),  //$NONXXX
		        new TestData("intermSimple",0,0),  //$NONXXX
		        new TestData("intermWithCrossRefs",0,0),  //$NONXXX
		        new TestData("intermWithExtends",0,0),  //$NONXXX
		        new TestData("intermWithoutExtent",0,0),  //$NONXXX
		        new TestData("invalidcollectioncast",0,0),  //$NONXXX
		        new TestData("invalidConfigProp",0,0),  //$NONXXX
		        new TestData("invresolve_",0,0),  //$NONXXX
		        new TestData("invresolvebyrule",0,0),  //$NONXXX
		        new TestData("isunique",0,0),  //$NONXXX
		        new TestData("iterateoverintset",0,0),  //$NONXXX
		        new TestData("iteratetest",0,0),  //$NONXXX
		        new TestData("javakeywords",0,0),  //$NONXXX
		        new TestData("largefile",0,0),  //$NONXXX
		        new TestData("lateresolve",0,0),  //$NONXXX
		        new TestData("LateResolveBase",0,0),  //$NONXXX
		        new TestData("lateresolvebyrule",0,0),  //$NONXXX
		        new TestData("lateresolve_many",0,0),  //$NONXXX
		        new TestData("Lib",0,0),  //$NONXXX
		        new TestData("Lib1",0,0),  //$NONXXX
		        new TestData("Lib2",0,0),  //$NONXXX
		        new TestData("LibForAccess",0,0),  //$NONXXX
		        new TestData("LibForExtends",0,0),  //$NONXXX
//		        new TestData("libraryHeaderWithSignature_257575",0,0),  //$NONXXX
//		        new TestData("libraryWithModuleElements",0,0),  //$NONXXX
//		        new TestData("libraryWithModuleElements_257184",0,0),  //$NONXXX
		        new TestData("listLiteral_259754",0,0),  //$NONXXX
//		        new TestData("listtype",0,0),  //$NONXXX
//		        new TestData("listtype2",0,0),  //$NONXXX
		        new TestData("localstrings",0,0),  //$NONXXX
//		        new TestData("m1",0,0),  //$NONXXX
//		        new TestData("m2",0,0),  //$NONXXX
		        new TestData("m3",0,0),  //$NONXXX
//		        new TestData("mainInLibrary",0,0),  //$NONXXX
		        new TestData("mapDisjuncts",0,0),  //$NONXXX
		        new TestData("mapInherits",0,0),  //$NONXXX
		        new TestData("mapkeyword",0,0),  //$NONXXX
		        new TestData("mapMerges",0,0),  //$NONXXX
		        new TestData("mapMultipleInherits",0,0),  //$NONXXX
		        new TestData("MappingBody",0,0),  //$NONXXX
		        new TestData("mappingBodyExpressions_252358",0,0),  //$NONXXX
		        new TestData("MappingExtensionDisjuncts",0,0),  //$NONXXX
		        new TestData("MappingExtensionInherits",0,0),  //$NONXXX
		        new TestData("MappingExtensionMerges",0,0),  //$NONXXX
		        new TestData("Mappings",0,0),  //$NONXXX
		        new TestData("MappingsWhenClause",0,0),  //$NONXXX
		        new TestData("mappingWithNoResultTrace_266854",0,0),  //$NONXXX
		        new TestData("markedTest",0,0),  //$NONXXX
//		        new TestData("Middle",0,0),  //$NONXXX
		        new TestData("misplacedTopElements",0,0),  //$NONXXX
//		        new TestData("missingfeature",0,0),  //$NONXXX
//		        new TestData("missinglibmmimport",0,0),  //$NONXXX
//		        new TestData("missingmappingcall",0,0),  //$NONXXX
//		        new TestData("missingObjectType",0,0),  //$NONXXX
//		        new TestData("missingout",0,0),  //$NONXXX
//		        new TestData("missingparamname",0,0),  //$NONXXX
//		        new TestData("missingvariablereference",0,0),  //$NONXXX
		        new TestData("mm_header1",0,0),  //$NONXXX
		        new TestData("mm_header2",0,0),  //$NONXXX
		        new TestData("mm_header3",0,0),  //$NONXXX
		        new TestData("mm_header4",0,0),  //$NONXXX
//		        new TestData("mm_header5",0,0),  //$NONXXX
//		        new TestData("mm_header6",0,0),  //$NONXXX
//		        new TestData("mm_header7",0,0),  //$NONXXX
		        new TestData("mm_modifyvar",0,0),  //$NONXXX
		        new TestData("ModelExtents",0,0),  //$NONXXX
		        new TestData("modifyfeature",0,0),  //$NONXXX
//		        new TestData("modifyfeatureerror",0,0),  //$NONXXX
//		        new TestData("modifyfeatureininiterror",0,0),  //$NONXXX
//		        new TestData("modifyinparam",0,0),  //$NONXXX
		        new TestData("modifyparam",0,0),  //$NONXXX
		        new TestData("modifyresult",0,0),  //$NONXXX
		        new TestData("modifyvar",0,0),  //$NONXXX
//		        new TestData("moduleElementErrorRecovery_265452",0,0),  //$NONXXX
		        new TestData("moduleProperty",0,0),  //$NONXXX
//		        new TestData("multiline_strings_262733",0,0),  //$NONXXX
		        new TestData("multilineStrings_262733",0,0),  //$NONXXX
		        new TestData("multipletracerecords",0,0),  //$NONXXX
		        new TestData("multiresultpars",0,0),  //$NONXXX
//		        new TestData("nameclash",0,0),  //$NONXXX
		        new TestData("nested",0,0),  //$NONXXX
		        new TestData("nestednativeops",0,0),  //$NONXXX
		        new TestData("nestedPropertiesAssignment_262757",0,0),  //$NONXXX
		        new TestData("NestedTransformation",0,0),  //$NONXXX
		        new TestData("NewLibrary",0,0),  //$NONXXX
		        new TestData("NewTransformation",0,0),  //$NONXXX
//		        new TestData("noClassInImplicitPopulate",0,0),  //$NONXXX
		        new TestData("nocollectoncollection",0,0),  //$NONXXX
		        new TestData("noglobalallinstances",0,0),  //$NONXXX
//		        new TestData("nonassignableout",0,0),  //$NONXXX
//		        new TestData("nonbooleanguard",0,0),  //$NONXXX
		        new TestData("NonExecutable",0,0),  //$NONXXX
//		        new TestData("nonregisteredDynamic",0,0),  //$NONXXX
//		        new TestData("nonstaticcallinstaticcontext",0,0),  //$NONXXX
//		        new TestData("normalimport",0,0),  //$NONXXX
//		        new TestData("nullableEnum",0,0),  //$NONXXX
		        new TestData("nullsource",0,0),  //$NONXXX
//		        new TestData("numconversion",0,0),  //$NONXXX
		        new TestData("objectExp",0,0),  //$NONXXX
		        new TestData("objectExpBodyExpressions_253051",0,0),  //$NONXXX
		        new TestData("oclAllInstances",0,0),  //$NONXXX
//		        new TestData("oclannotation",0,0),  //$NONXXX
//		        new TestData("oclany",0,0),  //$NONXXX
		        new TestData("oclastype",0,0),  //$NONXXX
		        new TestData("ocl_test",0,0),  //$NONXXX
		        new TestData("omittedobject",0,0),  //$NONXXX
		        new TestData("omittedobjectwithinit",0,0),  //$NONXXX
		        new TestData("OperationalTransformation1",0,0),  //$NONXXX
//		        new TestData("operation_override",0,0),  //$NONXXX
//		        new TestData("opersignatureparamclash",0,0),  //$NONXXX
		        new TestData("optionalout",0,0),  //$NONXXX
		        new TestData("orderedsetdoesnotconformtoset",0,0),  //$NONXXX
		        new TestData("OtherTransformation",0,0),  //$NONXXX
		        new TestData("outininitvar",0,0),  //$NONXXX
		        new TestData("overload",0,0),  //$NONXXX
		        new TestData("overload_205062",0,0),  //$NONXXX
		        new TestData("overload_multipleParams",0,0),  //$NONXXX
		        new TestData("overload_singleParam",0,0),  //$NONXXX
		        new TestData("OverridingMappings",0,0),  //$NONXXX
//		        new TestData("parmnamesclash",0,0),  //$NONXXX
		        new TestData("populationSection",0,0),  //$NONXXX
		        new TestData("primtypesecore",0,0),  //$NONXXX
		        new TestData("propertycollect",0,0),  //$NONXXX
//		        new TestData("propinit",0,0),  //$NONXXX
		        new TestData("props",0,0),  //$NONXXX
//		        new TestData("propuseprop",0,0),  //$NONXXX
		        new TestData("q1",0,0),  //$NONXXX
//		        new TestData("q2",0,0),  //$NONXXX
//		        new TestData("q3",0,0),  //$NONXXX
//		        new TestData("q4",0,0),  //$NONXXX
		        new TestData("queries",0,0),  //$NONXXX
//		        new TestData("QVToASDuplicatedNamesDetection",0,0),  //$NONXXX
//		        new TestData("QVToCSDuplicatedNamesDetection",0,0),  //$NONXXX
//		        new TestData("Read",0,0),  //$NONXXX
		        new TestData("referencedLib",0,0),  //$NONXXX
		        new TestData("ReferencedTransformation",0,0),  //$NONXXX
		        new TestData("registeredDynamic",0,0),  //$NONXXX
		        new TestData("removeclassesinwhile",0,0),  //$NONXXX
		        new TestData("resolveall",0,0),  //$NONXXX
		        new TestData("resolvebeforeoutcompletion",0,0),  //$NONXXX
		        new TestData("resolvebyrule",0,0),  //$NONXXX
//		        new TestData("resolvecond",0,0),  //$NONXXX
		        new TestData("ResolveExpressions",0,0),  //$NONXXX
//		        new TestData("resolveIn_ambiguity",0,0),  //$NONXXX
		        new TestData("resolve_invresolveoneIn",0,0),  //$NONXXX
		        new TestData("resolve_lateresolveoneIn",0,0),  //$NONXXX
		        new TestData("resolve_lateresolveoneInaccess",0,0),  //$NONXXX
		        new TestData("resolvenoinput",0,0),  //$NONXXX
		        new TestData("resolve_notype",0,0),  //$NONXXX
		        new TestData("resolve_resolveIn",0,0),  //$NONXXX
		        new TestData("resolve_resolveone",0,0),  //$NONXXX
		        new TestData("resolve_resolveoneIn",0,0),  //$NONXXX
		        new TestData("resolve_type",0,0),  //$NONXXX
		        new TestData("resolve_vardecl",0,0),  //$NONXXX
		        new TestData("resolve_vardeclcond",0,0),  //$NONXXX
		        new TestData("resolve_vardeclcondwithvar",0,0),  //$NONXXX
		        new TestData("returnundefinedfromquery",0,0),  //$NONXXX
		        new TestData("RootTransfForExtends",0,0),  //$NONXXX
//		        new TestData("RootTransformation",0,0),  //$NONXXX
//		        new TestData("sameparamname",0,0),  //$NONXXX
		        new TestData("scr17812",0,0),  //$NONXXX
		        new TestData("scr18514",0,0),  //$NONXXX
		        new TestData("scr18572",0,0),  //$NONXXX
		        new TestData("scr18739",0,0),  //$NONXXX
		        new TestData("scr18783",0,0),  //$NONXXX
		        new TestData("scr19364",0,0),  //$NONXXX
		        new TestData("scr20038",0,0),  //$NONXXX
		        new TestData("scr20041",0,0),  //$NONXXX
		        new TestData("scr20469",0,0),  //$NONXXX
		        new TestData("scr20471",0,0),  //$NONXXX
		        new TestData("scr20667",0,0),  //$NONXXX
		        new TestData("scr20811",0,0),  //$NONXXX
		        new TestData("scr21121",0,0),  //$NONXXX
		        new TestData("scr21329",0,0),  //$NONXXX
		        new TestData("scr23070",0,0),  //$NONXXX
		        new TestData("scr878",0,0),  //$NONXXX
//		        new TestData("selfimport",0,0),  //$NONXXX
		        new TestData("setundefinedtoprimitive",0,0),  //$NONXXX
		        new TestData("simple",0,0),  //$NONXXX
		        new TestData("simpleconfigproperty",0,0),  //$NONXXX
		        new TestData("simpleproperty",0,0),  //$NONXXX
		        new TestData("simplerename",0,0),  //$NONXXX
		        new TestData("simpleresolve",0,0),  //$NONXXX
		        new TestData("simplestXCollectShorthand",0,0),  //$NONXXX
		        new TestData("simpletag",0,0),  //$NONXXX
		        new TestData("Simpleuml_To_Rdb",0,0),  //$NONXXX
		        new TestData("skippopulation",0,0),  //$NONXXX
		        new TestData("slashSingleLineComments_266478",0,0),  //$NONXXX
		        new TestData("somelib",0,0),  //$NONXXX
//		        new TestData("stacktrace",0,0),  //$NONXXX
//		        new TestData("stdlibDict",0,0),  //$NONXXX
		        new TestData("stdlibelement",0,0),  //$NONXXX
//		        new TestData("stdlibElementAsOut",0,0),  //$NONXXX
		        new TestData("stdlibList",0,0),  //$NONXXX
		        new TestData("stdlibModel",0,0),  //$NONXXX
		        new TestData("stdlibString",0,0),  //$NONXXX
		        new TestData("stringescaping",0,0),  //$NONXXX
		        new TestData("subobjects",0,0),  //$NONXXX
		        new TestData("successLib",0,0),  //$NONXXX
//		        new TestData("T1",0,0),  //$NONXXX
		        new TestData("T2",0,0),  //$NONXXX
//		        new TestData("testhyperlinks",0,0),  //$NONXXX
		        new TestData("TestLib",0,0),  //$NONXXX
		        new TestData("testlibrary",0,0),  //$NONXXX
//		        new TestData("testmodelparamtype",0,0),  //$NONXXX
//		        new TestData("testProblemAnnotations",0,0),  //$NONXXX
		        new TestData("traceLookup_287589",0,0),  //$NONXXX
		        new TestData("transf2",0,0),  //$NONXXX
		        new TestData("transf3",0,0),  //$NONXXX
		        new TestData("TransfForAccess",0,0),  //$NONXXX
//		        new TestData("TransfForExtends",0,0),  //$NONXXX
//		        new TestData("TransfForExtends2",0,0),  //$NONXXX
//		        new TestData("transf_inheritance",0,0),  //$NONXXX
		        new TestData("transformationWithModuleElements_257055",0,0),  //$NONXXX
		        new TestData("tuples",0,0),  //$NONXXX
		        new TestData("twoInputs",0,0),  //$NONXXX
		        new TestData("uml2rdb",0,0),  //$NONXXX
		        new TestData("uml2_stereotypeApplication",0,0),  //$NONXXX
//		        new TestData("Uml2Xhtml_v1",0,0),  //$NONXXX
//		        new TestData("Uml2Xhtml_v2",0,0),  //$NONXXX
//		        new TestData("Uml2Xhtml_v3",0,0),  //$NONXXX
//		        new TestData("Uml2Xhtml_vfinal",0,0),  //$NONXXX
		        new TestData("UMLFoo",0,0),  //$NONXXX
//		        new TestData("unitElementErrorRecovery_264517_1",0,0),  //$NONXXX
//		        new TestData("unitElementErrorRecovery_264517_2",0,0),  //$NONXXX
//		        new TestData("unitElementErrorRecovery_264675",0,0),  //$NONXXX
//		        new TestData("unspecified_multiplicity",0,0),  //$NONXXX
		        new TestData("urilessModeltype",0,0),  //$NONXXX
		        new TestData("usebooleanprop",0,0),  //$NONXXX
		        new TestData("useresultinsameout",0,0),  //$NONXXX
		        new TestData("util",0,0),  //$NONXXX
		        new TestData("Utils",0,0),  //$NONXXX
		        new TestData("varassign",0,0),  //$NONXXX
		        new TestData("varInitExpWithResult_260985",0,0),  //$NONXXX
//		        new TestData("varInitExpWithResult_261623",0,0),  //$NONXXX
		        new TestData("varInitGroup_261841",0,0),  //$NONXXX
//		        new TestData("varscope",0,0),  //$NONXXX
//		        new TestData("virt",0,0),  //$NONXXX
//		        new TestData("virtrettypemismatch",0,0),  //$NONXXX
		        new TestData("virtscr20707",0,0),  //$NONXXX
//		        new TestData("virtual_contextVsOverride",0,0),  //$NONXXX
		        new TestData("virtualPredefinedTypeOpers",0,0),  //$NONXXX
//		        new TestData("voidout",0,0),  //$NONXXX
		        new TestData("voidreturn",0,0),  //$NONXXX
		        new TestData("vutil",0,0),  //$NONXXX
		        new TestData("WarmUp",0,0),  //$NONXXX
		        new TestData("_while",0,0),  //$NONXXX
		        new TestData("_while_261024",0,0),  //$NONXXX
//		        new TestData("Write",0,0),  //$NONXXX
//		        new TestData("wrongorderininit",0,0),  //$NONXXX
//		        new TestData("wrongorderinproperty",0,0),  //$NONXXX
//		        new TestData("wrongout",0,0),  //$NONXXX
//		        new TestData("wrongparamnameinout",0,0)  //$NONXXX
/**/
			}
		);
	}
	
//	protected CompiledUnit[] getCompiledResults() {
//		return myCompiled;
//	}
	    
	@Override
	@Before
	public void setUp() throws Exception {
		TestUtil.turnOffAutoBuilding();		
		
		String name = "UnparserTest"; //$NON-NLS-1$
        myProject = TestProject.getExistingProject(name);
        if(myProject == null) {
            myProject = new TestProject(name, new String[] {}, 0); 
        }
        File destinationFolder = getDestinationFolder();
        if (destinationFolder.exists()) {
            FileUtil.delete(destinationFolder);
        }		
	}
	
	@Override
	@After
	public void tearDown() throws Exception {
//		myCompiled = null;
        File destinationFolder = getDestinationFolder();
        if (destinationFolder.exists()) {
//            FileUtil.delete(destinationFolder);
        }		
	}
	    
    public TestProject getTestProject() {
        return myProject;
    }
    
	@Override
	@Test
	public void runTest() throws Exception
	{
		File testdataFolder = copyTestdataIntoJunitWorkspace();
		
		CompiledUnit[] testdataCompiledUnit = compileAndCheckErrors(testdataFolder);

		File unparseFolder = createUnparseFolder();

		Module testdataModule = testdataCompiledUnit[0].getModules().get(0);
		
		unparseIntoFolder(testdataModule, unparseFolder, testdataFolder.getName() + UNPARSED_SUFFIX);

		CompiledUnit[] unparseCompiledUnit = compileAndCheckErrors(unparseFolder);
/*		
		Module unparseModule = unparseCompiledUnit[0].getModules().get(0);
				
		unparseIntoFolder(unparseModule, unparseFolder, testdataFolder.getName() + UNPARSED_SUFFIX + UNPARSED_SUFFIX);
		
		assertErrorCountEquality(testdataCompiledUnit, unparseCompiledUnit);
		
		assertEmfCompareEquals(testdataModule, unparseModule);
/**/
	}

	private void assertEmfCompareEquals(Module testdataModule, Module unparseModule) {
		Comparison comparison = compare(testdataModule,unparseModule);
		List<Diff> differences = comparison.getDifferences();
		
//		inspectEntryOperation(module, copyModule);
		
		String assertCopyEqualityMessage = "\nOriginal and copy expression differ at " + differences.size() + " places";
		if ( differences.size() > 0 )
		{
			assertCopyEqualityMessage += "\n" + prettyPrintComparison(comparison);	
			
			PrettyPrinter prettyPrinter = new PrettyPrinter();
			assertCopyEqualityMessage += "\n" + "================= original ======================";
			assertCopyEqualityMessage += "\n" + prettyPrinter.prettyPrint(testdataModule);
			assertCopyEqualityMessage += "\n" + "=================   copy   ======================";
			assertCopyEqualityMessage += "\n" + prettyPrinter.prettyPrint(unparseModule);
			assertCopyEqualityMessage += "\n" + "========================== ======================";

//			for (Iterator<Diff> diffIterator = differences.iterator(); diffIterator.hasNext();)
//			{
//				Diff difference = diffIterator.next();
//				assertionMessage += "\n" + printDiff(difference);
//			}
		}
		
		assertTrue(assertCopyEqualityMessage,differences.size()==0);
	}

	private File copyTestdataIntoJunitWorkspace() throws Exception
	{
		this.copyData(getOriginalPathSegment(), "unparserTestData/" + getOriginalPathSegment()); //$NON-NLS-1$
		
        File folder = getDestinationFolder(); //$NON-NLS-1$

        assertTrue("Invalid folder " + folder, folder.exists() && folder.isDirectory()); //$NON-NLS-1$

        return folder;
	}

	private CompiledUnit[] compileAndCheckErrors(File folder) throws Exception
	{
		CompiledUnit[] compiledUnits = compile(folder);
		
		assertTrue("No results", compiledUnits.length > 0); //$NON-NLS-1$
		
		List<QvtMessage> allErrors = getAllErrors(compiledUnits, myData.usesSourceAnnotations());
		
//		if ( allErrors.size() > 0 ) throw new RuntimeException("Compiled QVTo units in " + folder.getName() + " are not error free.");

		String assertErrorCountEqualityMessage = "Compiled QVTo units in " + folder.getName() + " are not error free:"; 
		if ( allErrors.size() > 0 )
		{
			assertErrorCountEqualityMessage += "\n--- errors: ---";
			for (Iterator<QvtMessage> iterator = allErrors.iterator(); iterator.hasNext();)
			{
				QvtMessage qvtMessage = (QvtMessage) iterator.next();
				assertErrorCountEqualityMessage += "\n" + qvtMessage.getLineNum() + ":" + qvtMessage.getMessage();
			}
		}		
		
		assertTrue(assertErrorCountEqualityMessage,allErrors.size()==0);

		return compiledUnits;
	}

	private CompiledUnit[] compile(File folder) throws Exception
	{
		final String topName = folder.getName() + MDAConstants.QVTO_FILE_EXTENSION_WITH_DOT;
		getFile(folder, topName);
		WorkspaceUnitResolver resolver = new WorkspaceUnitResolver(Collections.singletonList(getIFolder(folder)));
		QVTOCompiler compiler = CompilerUtils.createCompiler();
		
	    QvtCompilerOptions options = new QvtCompilerOptions();
	    options.setGenerateCompletionData(false);
	    
	    UnitProxy unit = resolver.resolveUnit(folder.getName());
		CompiledUnit[] compiledUnits = new CompiledUnit[] { compiler.compile(unit, options, new BasicMonitor()) };
		
		saveCompiledUnitsAsXMI(compiler, compiledUnits);
	
		return compiledUnits;		
	}

	private void saveCompiledUnitsAsXMI(QVTOCompiler compiler, CompiledUnit[] compiledUnits) throws IOException
	{
		ResourceSet metamodelResourceSet = compiler.getResourceSet();
		Registry registry = MetamodelURIMappingHelper.mappingsToEPackageRegistry(myProject.project, metamodelResourceSet);
		ExeXMISerializer.saveUnitXMI(compiledUnits, registry != null ? registry : EPackage.Registry.INSTANCE);
	}

	private File createUnparseFolder() throws Exception
	{
		this.createFolder(getUnparsePathSegment());
        File copyFolder = getUnparseFolder(); //$NON-NLS-1$
		assertTrue("Invalid folder " + copyFolder, copyFolder.exists() && copyFolder.isDirectory()); //$NON-NLS-1$
		return copyFolder;
	}

	private void unparseIntoFolder(Module module, File unparseFolder, String fileName) throws Exception, EmfException
	{
		String copyPath =
				"/" + myProject.getProject().getName() +
				"/" + getUnparsePathSegment() +
				"/" + fileName + MDAConstants.QVTO_FILE_EXTENSION_WITH_DOT;
		URI copyURI = URI.createPlatformResourceURI(copyPath,true);
		
		EmfUtil.saveModel(module, copyURI, new HashMap<Object,Object>());
		
		myProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
	}

	private void assertErrorCountEquality(CompiledUnit[] testdataCompiledUnit, CompiledUnit[] unparseCompiledUnit) {
			String assertErrorCountEqualityMessage = "Errors in original and copy: "; 
			if ( getAllErrors(unparseCompiledUnit, myData.usesSourceAnnotations()).size() != getAllErrors(testdataCompiledUnit, myData.usesSourceAnnotations()).size() )
			{
				assertErrorCountEqualityMessage += "\n--- original errors: ---";
				for (Iterator<QvtMessage> iterator = getAllErrors(testdataCompiledUnit, myData.usesSourceAnnotations()).iterator(); iterator.hasNext();)
				{
					QvtMessage qvtMessage = (QvtMessage) iterator.next();
					assertErrorCountEqualityMessage += "\n" + qvtMessage.getLineNum() + ":" + qvtMessage.getMessage();
				}
				assertErrorCountEqualityMessage += "\n--- errors in copy: ---";
				for (Iterator<QvtMessage> iterator = getAllErrors(unparseCompiledUnit, myData.usesSourceAnnotations()).iterator(); iterator.hasNext();)
				{
					QvtMessage qvtMessage = (QvtMessage) iterator.next();
					assertErrorCountEqualityMessage += "\n" + qvtMessage.getLineNum() + ":" + qvtMessage.getMessage();
				}
			}
			
			
			if ( getAllErrors(testdataCompiledUnit, myData.usesSourceAnnotations()).size() != getAllErrors(unparseCompiledUnit, myData.usesSourceAnnotations()).size())
			{
	//			throw new RuntimeException("wrong number of errors: expected " + allErrors.size() + ", got " + allCopyErrors.size());
			}
			assertErrorCountEqualityMessage += "\nError count of copy mismatches: "; 
			assertEquals(assertErrorCountEqualityMessage, getAllErrors(testdataCompiledUnit, myData.usesSourceAnnotations()).size(),getAllErrors(unparseCompiledUnit, myData.usesSourceAnnotations()).size()); //$NON-NLS-1$	
		}

	private String prettyPrintComparison(Comparison comparison)
	{
		String prettyMessage = "";
		OutputStream os = null;
		PrintStream ps = null;
		try
		{
			os = new ByteArrayOutputStream();
			ps = new PrintStream(os);

			EMFComparePrettyPrinter.printDifferences(comparison,ps);
		     
			prettyMessage = os.toString();
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			if( ps != null ) ps.close();
		}
		return prettyMessage;
	}

	private void inspectEntryOperation(Module module, Module copyModule) {
		EntryOperation entryOperation = module.getEntry();
		EntryOperation copyEntryOperation = copyModule.getEntry();
		OperationBody entryBody = entryOperation.getBody();
		OperationBody copyEntryBody = copyEntryOperation.getBody();
		
		OCLExpression<?> expression0 = entryBody.getContent().get(0);
		OCLExpression<?> expression1 = entryBody.getContent().get(1);
		OCLExpression<?> copyExpression0 = copyEntryBody.getContent().get(0);
		OCLExpression<?> copyExpression1 = copyEntryBody.getContent().get(1);
		
		Comparison comparison0 = compare(expression0,copyExpression0);
		List<Diff> differences0 = comparison0.getDifferences();
		Comparison comparison1 = compare(expression1,copyExpression1);
		List<Diff> differences1 = comparison1.getDifferences();
	}
	
	private Comparison compare(EObject original, EObject copy)
	{
		IComparisonScope scope = new DefaultComparisonScope(original,copy,null);
		Comparison comparison = EMFCompare.builder().setDiffEngine(new UnparserDiffEngine()).build().compare(scope);
		
		return comparison;
	}	

	private class UnparserDiffEngine extends DefaultDiffEngine
	{
		@Override
		protected FeatureFilter createFeatureFilter()
		{
			return new FeatureFilter()
			{
				@Override
				protected boolean isIgnoredAttribute(EAttribute attribute)
				{
					return
							attribute == org.eclipse.ocl.utilities.UtilitiesPackage.Literals.AST_NODE__START_POSITION ||
							attribute == org.eclipse.ocl.utilities.UtilitiesPackage.Literals.AST_NODE__END_POSITION ||
							super.isIgnoredAttribute(attribute);
				}
			};
		}
	};	
	
	private String getOriginalPathSegment()
	{
		return "sources/" + myData.getDir();
	}
	
	private static final String UNPARSED_SUFFIX = "-unparsed"; 

	private String getUnparsePathSegment() {
		return getOriginalPathSegment() + UNPARSED_SUFFIX;
	}

	private File getDestinationFolder()
	{
		return new File(myProject.getProject().getLocation().toString() + "/" + getOriginalPathSegment());
	}
	
	private File getUnparseFolder()
	{
		return new File(myProject.getProject().getLocation().toString() + "/" + getUnparsePathSegment());
	}
	
	private String printDiff(Diff diff)
	{
		String message = "";
		message += diff.getKind() +": ";
		Match parentMatch = diff.getMatch();
		message += parentMatch.getLeft() + " <--> " + parentMatch.getRight() + "\n\t";
		
		if ( diff instanceof AttributeChange )
		{
			AttributeChange attributeChange = (AttributeChange) diff;
			message += "attribute " + attributeChange.getAttribute().getName() + " is " + attributeChange.getValue();
		}
		else if ( diff instanceof FeatureMapChange )
		{
			FeatureMapChange featureMapChange = (FeatureMapChange) diff;
			message += "feature map attribute " + featureMapChange.getAttribute().getName() + " is " + featureMapChange.getValue();
		}
		else if ( diff instanceof ReferenceChange )
		{
			ReferenceChange referenceChange = (ReferenceChange) diff;
			message += "reference " + referenceChange.getReference().getName();
			message += " is " + referenceChange.getValue();
		}
		else if ( diff instanceof ResourceAttachmentChange )
		{
			ResourceAttachmentChange resourceAttachmentChange = (ResourceAttachmentChange) diff;
			message += "resource attachement " + resourceAttachmentChange.getResourceURI() + " changed";
		}
		else if ( diff instanceof ResourceLocationChange )
		{
			ResourceLocationChange resourceLocationChange = (ResourceLocationChange) diff;
			message += "resource location " + resourceLocationChange.getChangedLocation() + " from " + resourceLocationChange.getBaseLocation();
		}
		
		return message;
	}

	private class PrettyPrinter
	{
		private Set<String> allowedNames =
				new HashSet<String>(Arrays.asList(
						new String[] {
								"argument",
								"body",
								"content",
								"entry",
								"eParameters",
								"eOperations",
								"isBlackbox",
								"kind",
								"metamodel",
								"moduleImport",
								"name",
								"nsURI",
								"nsPrefix",
								"usedModelType",
								"intermediateClass",
								"intermediateProperty",
								"modelParameter",
								"isQuery"
						}));
		
		private Set<String> ignoredNames =
				new HashSet<String>(Arrays.asList(
						new String[] {
								"abstract",
								"context",
								"eAnnotations",
								"eContainingClass",
								"instanceClass",
								"instanceClassName",
								"defaultValue",
								"instanceTypeName",
								"ePackage",
								"eTypeParameters",
								"interface", 
								"eSuperTypes",
								"eOperations",
								"eAllAttributes",
								"eAllReferences",
								"eReferences",
								"eAttributes",
								"eAllContainments",
								"eAllOperations",
								"eAllStructuralFeatures",
								"eAllSuperTypes",
								"eIDAttribute",
								"eStructuralFeatures",
								"eGenericSuperTypes",
								"eAllGenericSuperTypes",
								"eFactoryInstance",
								"eClassifiers",
								"eSubpackages",
								"eSuperPackage",
								"startPosition",
								"endPosition",
								"configProperty",
								"ownedTag",
								"ownedVariable",
								"ordered",
								"unique",
								"many",
								"overridden",
								"result",
								"lowerBound",
								"upperBound",
								"required",
								"eType",
								"eGenericType",
								"eExceptions",
								"eGenericExceptions",
								"operation",
								"variable",
								"additionalCondition",
								"conformanceKind",
								"typeStartPosition",
								"typeEndPosition",
								"ctxOwner",
								"resOwner"
						}));
		

		
		private static final String INDENT = "    "; //$NON-NLS-1$
		
		private Set<EObject> doneObjects = null;

		public String prettyPrint(EObject object)
		{
			this.doneObjects = new HashSet<EObject>();
			List<String> lines = prettyPrintAny(object, ""); //$NON-NLS-1$
			this.doneObjects = null;
			StringBuilder sb = new StringBuilder();
			for (String line : lines)
			{
				sb.append(line).append('\n');
			}
			return sb.toString();
		}

		private List<String> prettyPrintAny(Object o, String indent)
		{
			List<String> lines = new ArrayList<String>();
			if (o instanceof EObject)
			{
				EObject object = (EObject) o;
				EClass eClass = object.eClass();
				lines.add(eClass.getName() + " [" + o.getClass().getCanonicalName() + "] {"); //$NON-NLS-1$ //$NON-NLS-2$
				if ( !this.doneObjects.contains(object) )
				{
					this.doneObjects.add(object);
					lines.addAll(prettyPrintRecursive(object, INDENT));
				}
				else
				{
					lines.add("<<already printed>>");
				}
				lines.add("}"); //$NON-NLS-1$
			}
			else if (o instanceof Iterable)
			{
				Iterable iterable = (Iterable<?>) o;
				if ( iterable.iterator().hasNext() )
				{
					lines.add("["); //$NON-NLS-1$
					for (Object obj : iterable)
					{
						lines.addAll(prettyPrintAny(obj, INDENT));
					}
					lines.add("]"); //$NON-NLS-1$
				}
				else
				{
					lines.add("[]");
				}
			}
			else
			{
				String line = String.valueOf(o) + ' ';
				if (o != null)
				{
					line += '[' + o.getClass().getCanonicalName() + ']';
				}
				lines.add(line);
			}
			return indentLines(lines, indent);
		}

		private List<String> indentLines(List<String> lines, String indent)
		{
			List<String> result = new ArrayList<String>();
			for (String l : lines)
			{
				result.add(indent + l);
			}
			return result;
		}

		private List<String> prettyPrintRecursive(EObject o, String indent)
		{
			EClass eClass = o.eClass();
			List<String> result = new ArrayList<String>();
			for (EStructuralFeature feature : eClass.getEAllStructuralFeatures())
			{
				String featureName = feature.getName();
				if ( allowedNames.contains(featureName) )
				{
					Object value = o.eGet(feature);
					String line = featureName + " = "; //$NON-NLS-1$
					List<String> list = prettyPrintAny(value, INDENT);
					list.set(0, list.get(0).trim());
					result.add(line + list.get(0));
					list.remove(0);
					result.addAll(list);
				}
				else if ( !ignoredNames.contains(featureName) )
				{
					result.add("<<" + featureName + " not allowed >>");
				}
			}
			return indentLines(result, indent);
		}
	}

    static class CompositeException extends Exception
    {
		private static final long serialVersionUID = -1045874581781288741L;

		public CompositeException(String message, List<Throwable> exceptions) {
            super(message);
            myExceptions = exceptions;
        }
        
        @Override
		public String toString() {
            StringBuffer s = new StringBuffer();
            s.append(super.toString());
            for(Throwable t : myExceptions) {
                StringWriter trace = new StringWriter();
                t.printStackTrace(new PrintWriter(trace));
                s.append("\n" + trace.toString()); //$NON-NLS-1$
            }
            
            return s.toString();
        }
        
        private final List<Throwable> myExceptions;
    }
    
    private List<QvtMessage> getAllErrors(CompiledUnit[] compiled, boolean concreteSyntaxOnly) {
        List<QvtMessage> errors = new ArrayList<QvtMessage>();
        for (CompiledUnit compilationResult : compiled) {        	
            TransformationUtil.getErrors(compilationResult, errors, concreteSyntaxOnly);
        }

        return errors;
    }
    
    private List<QvtMessage> getAllWarnings(CompiledUnit[] compiled, boolean concreteSyntaxOnly) {
        List<QvtMessage> warnings = new ArrayList<QvtMessage>();
        for (CompiledUnit compilationResult : compiled) {
            TransformationUtil.getWarnings(compilationResult, warnings, concreteSyntaxOnly);
        }

        return warnings;
    }
    
	private static File getFile(File folder, final String expectedName) {
		File file = new File(folder, expectedName);
        assertTrue("Inexistent file: " + file, file.exists()); //$NON-NLS-1$
        assertTrue("Non-File file: " + file, file.isFile()); //$NON-NLS-1$
        return file;
	}
    
	private IContainer getIFolder(File folderUnderWorkspace) throws MalformedURLException, URISyntaxException {
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		IPath location = new Path(folderUnderWorkspace.getAbsolutePath());
		IContainer[] containers = workspace.getRoot().findContainersForLocationURI(URIUtil.toURI(location.makeAbsolute().toFile().toURI().toURL()));
		if(containers == null || containers.length != 1 || containers[0] instanceof IFolder == false) {
			throw new RuntimeException("Folder not found: " + folderUnderWorkspace); //$NON-NLS-1$
		}
		
		return (IFolder)containers[0];
	}
	
	private void copyData(String destPath, String srcPath) throws Exception
	{
		File sourceFolder = TestUtil.getPluginRelativeFolder(srcPath);
		File destFolder = createFolder(destPath);
		FileUtil.copyFolder(sourceFolder, destFolder);
		myProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
	}	
	
	private File createFolder(String destPath) throws Exception
	{
		File destFolder = new File(myProject.getProject().getLocation().toString() + "/" + destPath); //$NON-NLS-1$
		destFolder.mkdirs();
		myProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
		return destFolder;
	}	
	
    private final TestData myData;
	private TestProject myProject;
}

Back to the top