Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJuergen Haug2018-07-18 11:34:51 -0400
committerJuergen Haug2018-07-18 12:39:32 -0400
commitc33073c10865923d47f00981b04169929f32bcd9 (patch)
tree672a5a5d32df975bb385a78d558b992a13fb76c5 /tests
parent5dfd44073e44459aef3c3c1edc7bc1b6e1f9957e (diff)
downloadorg.eclipse.etrice-c33073c10865923d47f00981b04169929f32bcd9.tar.gz
org.eclipse.etrice-c33073c10865923d47f00981b04169929f32bcd9.tar.xz
org.eclipse.etrice-c33073c10865923d47f00981b04169929f32bcd9.zip
[etunit] added support for in-memory conversion + fixed tests
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/.gitignore1
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/META-INF/MANIFEST.MF4
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/expects/report1.xml24
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/reports/combined.xml27
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/reports/only_combined.xml27
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/reports/report1.xml24
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/reports/report2.xml6
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/reports/report3.xml24
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/reports/report4.xml6
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/reports/report5.xml6
-rw-r--r--tests/org.eclipse.etrice.etunit.converter.tests/src/org/eclipse/etrice/etunit/converter/ConverterTest.java45
11 files changed, 66 insertions, 128 deletions
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/.gitignore b/tests/org.eclipse.etrice.etunit.converter.tests/.gitignore
index fe99505dc..c5188a7a8 100644
--- a/tests/org.eclipse.etrice.etunit.converter.tests/.gitignore
+++ b/tests/org.eclipse.etrice.etunit.converter.tests/.gitignore
@@ -1,2 +1,3 @@
bin
+reports/*.xml
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.etrice.etunit.converter.tests/META-INF/MANIFEST.MF
index 90506c039..8b854973c 100644
--- a/tests/org.eclipse.etrice.etunit.converter.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.etrice.etunit.converter.tests/META-INF/MANIFEST.MF
@@ -7,6 +7,8 @@ Bundle-Activator: org.eclipse.etrice.etunit.converter.tests.Activator
Bundle-Vendor: Eclipse eTrice
Require-Bundle: org.eclipse.etrice.etunit.converter;bundle-version="2.0.0",
org.eclipse.core.runtime,
- org.junit;bundle-version="4.8.2"
+ org.junit;bundle-version="4.8.2",
+ com.google.guava
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
+Import-Package: com.google.common.io
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/expects/report1.xml b/tests/org.eclipse.etrice.etunit.converter.tests/expects/report1.xml
new file mode 100644
index 000000000..6aa431430
--- /dev/null
+++ b/tests/org.eclipse.etrice.etunit.converter.tests/expects/report1.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ASCII"?>
+<testsuites>
+ <testsuite failures="0" name="TestMessage" tests="1" time="0.0">
+ <testcase name="TestEtMessage_testBasicMessage" time="0.0"/>
+ </testsuite>
+ <testsuite failures="1" name="TestEtMessageQueue" tests="2" time="0.187">
+ <testcase name="TestEtMessageQueue_testPushPop" time="0.0">
+ <failure><expected>334</expected><actual>333</actual>rcvMsg2->evtID: expected=334, actual=333
+ at ..\src\runtime\TestEtMessageQueue.c:42</failure>
+ </testcase>
+ <testcase name="TestEtMessageQueue_testMassiveMessaging" time="0.187"/>
+ </testsuite>
+ <testsuite failures="0" name="TestEtMessageService" tests="5" time="0.016">
+ <testcase name="TestEtMessageService_init" time="0.0"/>
+ <testcase name="TestEtMessageService_GetPushPopReturn" time="0.0"/>
+ <testcase name="TestEtMessageService_GetReturn" time="0.016"/>
+ <testcase name="TestEtMessageService_execute" time="0.0"/>
+ <testcase name="TestEtMessageService_getMessagePoolLowWaterMark" time="0.0"/>
+ </testsuite>
+ <testsuite failures="0" name="TestEtUnit" tests="2" time="0.0">
+ <testcase name="TestEtUnit_Expect_Order" time="0.0"/>
+ <testcase name="TestEtUnit_Expect" time="0.0"/>
+ </testsuite>
+</testsuites> \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/reports/combined.xml b/tests/org.eclipse.etrice.etunit.converter.tests/reports/combined.xml
deleted file mode 100644
index 1a21e9248..000000000
--- a/tests/org.eclipse.etrice.etunit.converter.tests/reports/combined.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<testsuites>
- <testsuite failures="0" name="TestMessage" tests="1" time="0">
- <testcase name="TestEtMessage_testBasicMessage" time="0"/>
- </testsuite>
- <testsuite failures="1" name="TestEtMessageQueue" tests="2" time="187">
- <testcase name="TestEtMessageQueue_testPushPop" time="0">
- <failure><expected>334</expected><actual>333</actual>rcvMsg2->evtID: expected=334, actual=333
- at ..\src\runtime\TestEtMessageQueue.c:42</failure>
- </testcase>
- <testcase name="TestEtMessageQueue_testMassiveMessaging" time="187"/>
- </testsuite>
- <testsuite failures="0" name="TestEtMessageService" tests="5" time="16">
- <testcase name="TestEtMessageService_init" time="0"/>
- <testcase name="TestEtMessageService_GetPushPopReturn" time="0"/>
- <testcase name="TestEtMessageService_GetReturn" time="16"/>
- <testcase name="TestEtMessageService_execute" time="0"/>
- <testcase name="TestEtMessageService_getMessagePoolLowWaterMark" time="0"/>
- </testsuite>
- <testsuite failures="0" name="TestEtUnit" tests="2" time="0">
- <testcase name="TestEtUnit_Expect_Order" time="0"/>
- <testcase name="TestEtUnit_Expect" time="0"/>
- </testsuite>
- <testsuite failures="0" name="etUnit" tests="1" time="0">
- <testcase name="openAll and closeAll" time="0"/>
- </testsuite>
-</testsuites> \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/reports/only_combined.xml b/tests/org.eclipse.etrice.etunit.converter.tests/reports/only_combined.xml
deleted file mode 100644
index 1a21e9248..000000000
--- a/tests/org.eclipse.etrice.etunit.converter.tests/reports/only_combined.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<testsuites>
- <testsuite failures="0" name="TestMessage" tests="1" time="0">
- <testcase name="TestEtMessage_testBasicMessage" time="0"/>
- </testsuite>
- <testsuite failures="1" name="TestEtMessageQueue" tests="2" time="187">
- <testcase name="TestEtMessageQueue_testPushPop" time="0">
- <failure><expected>334</expected><actual>333</actual>rcvMsg2->evtID: expected=334, actual=333
- at ..\src\runtime\TestEtMessageQueue.c:42</failure>
- </testcase>
- <testcase name="TestEtMessageQueue_testMassiveMessaging" time="187"/>
- </testsuite>
- <testsuite failures="0" name="TestEtMessageService" tests="5" time="16">
- <testcase name="TestEtMessageService_init" time="0"/>
- <testcase name="TestEtMessageService_GetPushPopReturn" time="0"/>
- <testcase name="TestEtMessageService_GetReturn" time="16"/>
- <testcase name="TestEtMessageService_execute" time="0"/>
- <testcase name="TestEtMessageService_getMessagePoolLowWaterMark" time="0"/>
- </testsuite>
- <testsuite failures="0" name="TestEtUnit" tests="2" time="0">
- <testcase name="TestEtUnit_Expect_Order" time="0"/>
- <testcase name="TestEtUnit_Expect" time="0"/>
- </testsuite>
- <testsuite failures="0" name="etUnit" tests="1" time="0">
- <testcase name="openAll and closeAll" time="0"/>
- </testsuite>
-</testsuites> \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report1.xml b/tests/org.eclipse.etrice.etunit.converter.tests/reports/report1.xml
deleted file mode 100644
index c99b92aa1..000000000
--- a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report1.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<testsuites>
- <testsuite failures="0" name="TestMessage" tests="1" time="0">
- <testcase name="TestEtMessage_testBasicMessage" time="0"/>
- </testsuite>
- <testsuite failures="1" name="TestEtMessageQueue" tests="2" time="187">
- <testcase name="TestEtMessageQueue_testPushPop" time="0">
- <failure><expected>334</expected><actual>333</actual>rcvMsg2->evtID: expected=334, actual=333
- at ..\src\runtime\TestEtMessageQueue.c:42</failure>
- </testcase>
- <testcase name="TestEtMessageQueue_testMassiveMessaging" time="187"/>
- </testsuite>
- <testsuite failures="0" name="TestEtMessageService" tests="5" time="16">
- <testcase name="TestEtMessageService_init" time="0"/>
- <testcase name="TestEtMessageService_GetPushPopReturn" time="0"/>
- <testcase name="TestEtMessageService_GetReturn" time="16"/>
- <testcase name="TestEtMessageService_execute" time="0"/>
- <testcase name="TestEtMessageService_getMessagePoolLowWaterMark" time="0"/>
- </testsuite>
- <testsuite failures="0" name="TestEtUnit" tests="2" time="0">
- <testcase name="TestEtUnit_Expect_Order" time="0"/>
- <testcase name="TestEtUnit_Expect" time="0"/>
- </testsuite>
-</testsuites> \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report2.xml b/tests/org.eclipse.etrice.etunit.converter.tests/reports/report2.xml
deleted file mode 100644
index 87d8c645c..000000000
--- a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report2.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<testsuites>
- <testsuite failures="0" name="etUnit" tests="1" time="0">
- <testcase name="openAll and closeAll" time="0"/>
- </testsuite>
-</testsuites> \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report3.xml b/tests/org.eclipse.etrice.etunit.converter.tests/reports/report3.xml
deleted file mode 100644
index c99b92aa1..000000000
--- a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report3.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<testsuites>
- <testsuite failures="0" name="TestMessage" tests="1" time="0">
- <testcase name="TestEtMessage_testBasicMessage" time="0"/>
- </testsuite>
- <testsuite failures="1" name="TestEtMessageQueue" tests="2" time="187">
- <testcase name="TestEtMessageQueue_testPushPop" time="0">
- <failure><expected>334</expected><actual>333</actual>rcvMsg2->evtID: expected=334, actual=333
- at ..\src\runtime\TestEtMessageQueue.c:42</failure>
- </testcase>
- <testcase name="TestEtMessageQueue_testMassiveMessaging" time="187"/>
- </testsuite>
- <testsuite failures="0" name="TestEtMessageService" tests="5" time="16">
- <testcase name="TestEtMessageService_init" time="0"/>
- <testcase name="TestEtMessageService_GetPushPopReturn" time="0"/>
- <testcase name="TestEtMessageService_GetReturn" time="16"/>
- <testcase name="TestEtMessageService_execute" time="0"/>
- <testcase name="TestEtMessageService_getMessagePoolLowWaterMark" time="0"/>
- </testsuite>
- <testsuite failures="0" name="TestEtUnit" tests="2" time="0">
- <testcase name="TestEtUnit_Expect_Order" time="0"/>
- <testcase name="TestEtUnit_Expect" time="0"/>
- </testsuite>
-</testsuites> \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report4.xml b/tests/org.eclipse.etrice.etunit.converter.tests/reports/report4.xml
deleted file mode 100644
index 87d8c645c..000000000
--- a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report4.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<testsuites>
- <testsuite failures="0" name="etUnit" tests="1" time="0">
- <testcase name="openAll and closeAll" time="0"/>
- </testsuite>
-</testsuites> \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report5.xml b/tests/org.eclipse.etrice.etunit.converter.tests/reports/report5.xml
deleted file mode 100644
index cf37f05ad..000000000
--- a/tests/org.eclipse.etrice.etunit.converter.tests/reports/report5.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="ASCII"?>
-<testsuites>
- <testsuite failures="0" name="new.suite.name" tests="1" time="0">
- <testcase name="openAll and closeAll" time="0"/>
- </testsuite>
-</testsuites> \ No newline at end of file
diff --git a/tests/org.eclipse.etrice.etunit.converter.tests/src/org/eclipse/etrice/etunit/converter/ConverterTest.java b/tests/org.eclipse.etrice.etunit.converter.tests/src/org/eclipse/etrice/etunit/converter/ConverterTest.java
index 48aa82a7c..2c0a5e4b4 100644
--- a/tests/org.eclipse.etrice.etunit.converter.tests/src/org/eclipse/etrice/etunit/converter/ConverterTest.java
+++ b/tests/org.eclipse.etrice.etunit.converter.tests/src/org/eclipse/etrice/etunit/converter/ConverterTest.java
@@ -12,15 +12,25 @@
package org.eclipse.etrice.etunit.converter;
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
+import java.util.List;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.etrice.etunit.converter.EtUnitReportConverter.BaseOptions;
import org.eclipse.etrice.etunit.converter.tests.Activator;
import org.junit.Before;
import org.junit.Test;
+import com.google.common.base.Charsets;
+import com.google.common.io.Files;
+
/**
* @author Henrik Rentz-Reichert
*
@@ -28,6 +38,7 @@ import org.junit.Test;
public class ConverterTest {
private String basePath;
+ private String expectsPath;
@Before
public void prepare() {
@@ -38,16 +49,26 @@ public class ConverterTest {
} catch (IOException e) {
e.printStackTrace();
}
+ try {
+ URL modelsDir = Activator.getInstance().getBundle().getEntry("expects");
+ URL fileURL = FileLocator.toFileURL(modelsDir);
+ expectsPath = fileURL.getFile();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
@Test
- public void testConversion() {
+ public void testConversion() throws IOException {
ArrayList<String> args = new ArrayList<String>();
args.add(basePath+"report1.etu");
String[] arguments = new String[args.size()];
- EtUnitReportConverter.main(args.toArray(arguments));
+ new EtUnitReportConverter().run(args.toArray(arguments));
+
+ assertEquals(Files.toString(new File(expectsPath+"report1.xml"), Charsets.UTF_8), Files.toString(new File(basePath+"report1.xml"), Charsets.UTF_8));
}
+
@Test
public void testDoubleConversion() {
@@ -56,7 +77,7 @@ public class ConverterTest {
args.add(basePath+"report2.etu");
String[] arguments = new String[args.size()];
- EtUnitReportConverter.main(args.toArray(arguments));
+ new EtUnitReportConverter().run(args.toArray(arguments));
}
@Test
@@ -68,7 +89,7 @@ public class ConverterTest {
args.add(basePath+"combined.xml");
String[] arguments = new String[args.size()];
- EtUnitReportConverter.main(args.toArray(arguments));
+ new EtUnitReportConverter().run(args.toArray(arguments));
}
@Test
@@ -80,7 +101,7 @@ public class ConverterTest {
args.add(basePath+"only_combined.xml");
String[] arguments = new String[args.size()];
- EtUnitReportConverter.main(args.toArray(arguments));
+ new EtUnitReportConverter().run(args.toArray(arguments));
}
@Test
@@ -91,7 +112,7 @@ public class ConverterTest {
args.add("new.suite.name");
String[] arguments = new String[args.size()];
- EtUnitReportConverter.main(args.toArray(arguments));
+ new EtUnitReportConverter().run(args.toArray(arguments));
}
@Test
@@ -100,6 +121,16 @@ public class ConverterTest {
args.add(basePath+"report6.etu");
String[] arguments = new String[args.size()];
- EtUnitReportConverter.main(args.toArray(arguments));
+ new EtUnitReportConverter().run(args.toArray(arguments));
+ }
+
+ @Test
+ public void testInMemory() throws IOException {
+ List<InputStream> streams = new ArrayList<InputStream>();
+ streams.add(new FileInputStream(new File(basePath+"report1.etu")));
+
+ List<String> results = new EtUnitReportConverter().convert(new BaseOptions(), streams);
+ assertEquals(1, results.size());
+ assertEquals(Files.toString(new File(expectsPath+"report1.xml"), Charsets.UTF_8), results.get(0));
}
}

Back to the top