Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/moka/org.eclipse.papyrus.moka.fuml.assertionlibrary/src/org/eclipse/papyrus/moka/fuml/assertionlibrary/reporting/GenerateTestReport.java')
-rw-r--r--extraplugins/moka/org.eclipse.papyrus.moka.fuml.assertionlibrary/src/org/eclipse/papyrus/moka/fuml/assertionlibrary/reporting/GenerateTestReport.java84
1 files changed, 84 insertions, 0 deletions
diff --git a/extraplugins/moka/org.eclipse.papyrus.moka.fuml.assertionlibrary/src/org/eclipse/papyrus/moka/fuml/assertionlibrary/reporting/GenerateTestReport.java b/extraplugins/moka/org.eclipse.papyrus.moka.fuml.assertionlibrary/src/org/eclipse/papyrus/moka/fuml/assertionlibrary/reporting/GenerateTestReport.java
new file mode 100644
index 00000000000..b152bdeba80
--- /dev/null
+++ b/extraplugins/moka/org.eclipse.papyrus.moka.fuml.assertionlibrary/src/org/eclipse/papyrus/moka/fuml/assertionlibrary/reporting/GenerateTestReport.java
@@ -0,0 +1,84 @@
+/*****************************************************************************
+ * Copyright (c) 2014 CEA LIST.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.moka.fuml.assertionlibrary.reporting;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.net.URL;
+import java.util.List;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.OpaqueBehaviorExecution;
+import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
+import org.w3c.dom.Document;
+
+
+public class GenerateTestReport extends OpaqueBehaviorExecution {
+
+ @Override
+ public void doBody(List<ParameterValue> inputParameters, List<ParameterValue> outputParameters) {
+ Document report = null;
+ Transformer transformer = null;
+ TransformerFactory factory = TransformerFactory.newInstance();
+ try {
+ report = Reporter.INSTANCE.getReport();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ }
+ if(report != null) {
+
+ }
+ try {
+ transformer = factory.newTransformer();
+ } catch (TransformerConfigurationException e) {
+ e.printStackTrace();
+ }
+ if(transformer != null) {
+ this.writeReport(transformer, report, Platform.getInstanceLocation().getURL());
+ System.out.println(Platform.getInstanceLocation().getURL());
+ }
+ }
+
+ protected boolean writeReport(Transformer transformer, Document report, URL location) {
+ File file = new File(location.getPath() + "/mokatests.xml");
+ FileOutputStream out = null;
+ try {
+ out = new FileOutputStream(file, false);
+ } catch (FileNotFoundException e1) {
+ e1.printStackTrace();
+ return false;
+ }
+ try {
+ transformer.transform(new DOMSource(report), new StreamResult(out));
+ } catch (TransformerException e) {
+ e.printStackTrace();
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public Value new_() {
+ return new GenerateTestReport();
+ }
+
+}

Back to the top