Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 16 additions & 17 deletions org.omg.kerml.xtext/src/org/omg/kerml/xtext/util/KerML2JSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,24 +165,23 @@ public void run(String[] args) {
args = this.processArgs(args);

if (args != null) {

System.out.println("Saving " + args[0] + "...");

this.initialize(args);
this.read(args);

System.out.println("Transforming" +
(this.isAddImplicitElements? " (adding implicit elements)... ": "..."));
this.transformAll(this.isAddImplicitElements);

if (!this.isVerbose()) {
System.out.print("Processing");
}
this.process();
System.out.println();

System.out.println("Writing " + this.outputPath + "...");
try {
System.out.println("Saving " + args[0] + "...");

this.initialize(args);
this.read(args);

System.out.println("Transforming" +
(this.isAddImplicitElements? " (adding implicit elements)... ": "..."));
this.transformAll(this.isAddImplicitElements);

if (!this.isVerbose()) {
System.out.print("Processing");
}
this.process();
System.out.println();

System.out.println("Writing " + this.outputPath + "...");
this.write();
} catch (IOException e) {
throw new RuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*****************************************************************************/
package org.omg.kerml.xtext.util;

import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;

Expand Down Expand Up @@ -237,26 +238,30 @@ public void run(String[] args) {
args = this.processArgs(args);

if (args != null) {
System.out.println("Saving " + args[0] + "...");

this.initialize(args);
this.read(args);

System.out.println("Transforming" +
(this.isAddImplicitElements? " (adding implicit generalizations)... ": "..."));
this.transformAll(this.isAddImplicitElements);

System.out.println("\nBase path is " + this.getBasePath());
System.out.println();

this.process();

if (isCommitted()) {
System.out.println("Saved to Project (" + this.getProjectName() + ") " + this.getProjectId());
} else {
System.out.println("Failed to save Project (" + this.getProjectName() + ") ");
try {
System.out.println("Saving " + args[0] + "...");

this.initialize(args);
this.read(args);

System.out.println("Transforming" +
(this.isAddImplicitElements? " (adding implicit generalizations)... ": "..."));
this.transformAll(this.isAddImplicitElements);

System.out.println("\nBase path is " + this.getBasePath());
System.out.println();

this.process();

if (isCommitted()) {
System.out.println("Saved to Project (" + this.getProjectName() + ") " + this.getProjectId());
} else {
System.out.println("Failed to save Project (" + this.getProjectName() + ") ");
}
System.out.println();
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println();
}
}

Expand Down
24 changes: 24 additions & 0 deletions org.omg.sysml.interactive.tests/.launch/SysML Access Test.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
<stringAttribute key="bad_container_name" value="/org.omg.sysml.interactive.tests/.lau"/>
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/org.omg.sysml.interactive.tests/src/org/omg/sysml/SysMLAccessTest.java"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="1"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value=""/>
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_ATTR_USE_ARGFILE" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_SHOW_CODEDETAILS_IN_EXCEPTION_MESSAGES" value="true"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_CLASSPATH_ONLY_JAR" value="false"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.omg.sysml.SysMLAccessTest"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.omg.sysml.interactive.tests"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -DlibraryPath=${workspace_loc:/SysML-v2-Pilot-Implementation/sysml.library}"/>
</launchConfiguration>
3 changes: 2 additions & 1 deletion org.omg.sysml.interactive.tests/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ Bundle-ActivationPolicy: lazy
Require-Bundle: org.omg.sysml.interactive;bundle-version="0.3.2",
org.junit;bundle-version="4.12.0",
org.omg.sysml,
org.eclipse.xtext;bundle-version="2.22.0"
org.eclipse.xtext;bundle-version="2.22.0",
org.omg.sysml.xtext
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package P {
part def a {
part b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package P {
part def a {
part b;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
package org.omg.sysml;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Set;

import org.eclipse.emf.ecore.resource.Resource;
import org.junit.Test;
import org.omg.sysml.lang.sysml.Element;
import org.omg.sysml.xtext.util.SysMLAccess;
import org.omg.sysml.xtext.util.SysMLParseResult;

public class SysMLAccessTest {

private final static String SYSML_LIBRARY_PATH_KEY = "libraryPath";

public String getLibraryPath() {
return System.getProperty(SYSML_LIBRARY_PATH_KEY);
}

@Test
public void testReadLibrary() throws IOException {
SysMLAccess sysmlAccess = SysMLAccess.createFullyFeatured(getLibraryPath());
sysmlAccess.setVerbose(false);
sysmlAccess.loadLibrary();
Set<Resource> libraryResources = sysmlAccess.getLibraryResources();
assertTrue("Libray was not loaded", !libraryResources.isEmpty());
}

@Test
public void testResolution() throws IOException {
SysMLAccess sysmlAccess = SysMLAccess.createFullyFeatured(getLibraryPath());
sysmlAccess.setVerbose(false);
sysmlAccess.loadLibrary();

Element element = sysmlAccess.resolve("$::Parts::parts");
assertNotNull(element);
assertEquals("Parts::parts", element.getQualifiedName());
}

@Test
public void testParsing() throws IOException {
SysMLAccess sysmlAccess = SysMLAccess.createFullyFeatured(getLibraryPath());
sysmlAccess.setVerbose(false);
sysmlAccess.loadLibrary();

SysMLParseResult result = sysmlAccess.parse("myres.sysml", "package P { part b; }");
assertTrue(result.getIssues().isEmpty());
}

@Test
public void testParsingWithError() throws IOException {
SysMLAccess sysmlAccess = SysMLAccess.createFullyFeatured(getLibraryPath());
sysmlAccess.setVerbose(false);
sysmlAccess.loadLibrary();

SysMLParseResult result = sysmlAccess.parse("myres.sysml", "package P { part b; ");
assertFalse(result.getSyntaxErrors().isEmpty());
}

@Test
public void testParseFile() throws IOException, URISyntaxException {
SysMLAccess sysmlAccess = SysMLAccess.createFullyFeatured(getLibraryPath());
sysmlAccess.setVerbose(false);
sysmlAccess.loadLibrary();

URL testFileURL = getClass().getResource("parseTest.sysml");
File testFile = new File(testFileURL.toURI());
List<SysMLParseResult> results = sysmlAccess.parseFiles(testFile, true);

assertTrue(results.getFirst().getSyntaxErrors().isEmpty());
}

@Test
public void testParseFileWithError() throws IOException, URISyntaxException {
SysMLAccess sysmlAccess = SysMLAccess.createFullyFeatured(getLibraryPath());
sysmlAccess.setVerbose(false);
sysmlAccess.loadLibrary();

URL testFileURL = getClass().getResource("parseTestWithError.sysml");
File testFile = new File(testFileURL.toURI());
List<SysMLParseResult> results = sysmlAccess.parseFiles(testFile, true);

assertFalse(results.getFirst().getSyntaxErrors().isEmpty());
}
}
Loading