Skip to content

Commit 183a91c

Browse files
committed
Update Tests
1 parent 57c43c4 commit 183a91c

File tree

10 files changed

+662
-7
lines changed

10 files changed

+662
-7
lines changed

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ sourceSets {
5050
}
5151

5252
test {
53+
jvmArgs '-ea', '-Xbootclasspath/p:../out/classes/production/boot', '-XX:+HeapDumpOnOutOfMemoryError', '-Xmx512m', '-XX:MaxPermSize=320m', '-Didea.system.path=../test-system', '-Didea.home.path=../', '-Didea.config.path=../test-config', '-Didea.test.group=ALL_EXCLUDE_DEFINED'
54+
5355
testLogging {
5456
events 'skipped', 'failed'
5557
exceptionFormat = 'full'
@@ -108,6 +110,14 @@ jacocoTestReport {
108110
xml.enabled true
109111
html.enabled false
110112
}
113+
afterEvaluate {
114+
classDirectories = files(classDirectories.files.collect {
115+
fileTree(dir: it,
116+
exclude: ['gen/**',
117+
'graphdatabase/**',
118+
'grammars/**'])
119+
})
120+
}
111121
}
112122

113123
check.dependsOn jacocoTestReport

testData/AnnotatorTestData.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright 2017 thomasbuning
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
object AnnotatorTestData {
18+
@JvmStatic fun main(args: Array<String>) {
19+
System.out.println("Instance a;");
20+
System.out.println("<error descr=\"Unresolved property\">Instance</error> a;");
21+
}
22+
}

testData/CashDeskSystem.secarc

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package secarc.seccds;
2+
3+
import secarc.seccds.fe.*;
4+
import secarc.seccds.msg.*;
5+
6+
@SuppressPolicy(UnusedPort)
7+
component CashDeskSystem extends Store {
8+
9+
trustlevel +0 "potentielle interne Angreifer";
10+
11+
//@SuppressPolicy(UnusedPort)
12+
trustlevelrelation cashDesk < store;
13+
14+
trustlevelrelation bank < target;
15+
16+
@SuppressPolicy(UnusedPort)
17+
identity weak store -> bank;
18+
19+
//autoconnect encrypted port;
20+
//autoinstantiate on;
21+
accesscontrol on;
22+
23+
port @SuppressPolicy(UnusedPort)
24+
in Image barcode,
25+
@SuppressPolicy(UnusedPort)
26+
in Event endSale,
27+
out ProductData outProductData;
28+
29+
CashDesk cashDesk[encrypted bdOut -> bank.bankData; encrypted saleInformation -> store.saleInformation];
30+
31+
component Bank bank {
32+
33+
trustlevel -1;
34+
35+
port in BankData bankData;
36+
port out PaymentAck paymentAck;
37+
38+
component Teller teller {
39+
40+
port in BankData bTellerIn;
41+
}
42+
}
43+
44+
connect bank.bankData -> barcode;
45+
46+
connect store.outPData -> bank.teller.bTellerIn;
47+
48+
Store store[storeServer.productData -> outPData];
49+
50+
connect encrypted bank.paymentAck -> cashDesk.paIn;
51+
52+
connect encrypted store.outPData -> cashDesk.inProductData;
53+
54+
}

testData/CashDeskSystem.txt

Lines changed: 441 additions & 0 deletions
Large diffs are not rendered by default.

testData/CompleteTestData.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2017 thomasbuning
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
object Test {
18+
@JvmStatic fun main(args: Array<String>) {
19+
println("co<caret>")
20+
}
21+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package secarc.seccds;
2+
3+
import secarc.seccds.fe.*;
4+
import secarc.seccds.msg.*;
5+
6+
@SuppressPolicy(UnusedPort)
7+
component CashDeskSystem extends Store {
8+
9+
co<caret>
10+
11+
trustlevel +0 "potentielle interne Angreifer";
12+
13+
//@SuppressPolicy(UnusedPort)
14+
trustlevelrelation cashDesk < store;
15+
16+
17+
18+
trustlevelrelation bank < target;
19+
20+
@SuppressPolicy(UnusedPort)
21+
identity weak store -> bank;
22+
23+
//autoconnect encrypted port;
24+
//autoinstantiate on;
25+
accesscontrol on;
26+
27+
port @SuppressPolicy(UnusedPort)
28+
in Image barcode,
29+
@SuppressPolicy(UnusedPort)
30+
in Event endSale,
31+
out ProductData outProductData;
32+
33+
CashDesk cashDesk[encrypted bdOut -> bank.bankData; encrypted saleInformation -> store.saleInformation];
34+
35+
component Bank bank {
36+
37+
trustlevel -1;
38+
39+
port in BankData bankData;
40+
port out PaymentAck paymentAck;
41+
42+
component Teller teller {
43+
44+
port in BankData bTellerIn;
45+
}
46+
}
47+
48+
connect bank.bankData -> barcode;
49+
50+
connect store.outPData -> bank.teller.bTellerIn;
51+
52+
Store store[storeServer.productData -> outPData];
53+
54+
connect encrypted bank.paymentAck -> cashDesk.paIn;
55+
56+
connect encrypted store.outPData -> cashDesk.inProductData;
57+
58+
}

testData/ParsingTestData.secarc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ package de.test;
22

33
component ParsingTestData {
44

5-
65
}

testData/ParsingTestData.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FILE(0,49)
1+
FILE(0,48)
22
MSAPackageClauseImpl(PACKAGE_CLAUSE)(0,16)
33
PsiElement(MSATokenType.package)('package')(0,7)
44
PsiWhiteSpace(' ')(7,8)
@@ -7,15 +7,15 @@ FILE(0,49)
77
PsiElement(MSATokenType.ID)('test')(11,15)
88
PsiElement(MSATokenType.;)(';')(15,16)
99
PsiWhiteSpace('\n\n')(16,18)
10-
MSAComponentDeclarationImpl(COMPONENT_DECLARATION)(18,49)
10+
MSAComponentDeclarationImpl(COMPONENT_DECLARATION)(18,48)
1111
PsiElement(MSATokenType.component)('component')(18,27)
1212
PsiWhiteSpace(' ')(27,28)
1313
MSAComponentSignatureImpl(COMPONENT_SIGNATURE)(28,43)
1414
MSAComponentNameWithTypeImpl(COMPONENT_NAME_WITH_TYPE)(28,43)
1515
MSAComponentNameImpl(COMPONENT_NAME)(28,43)
1616
PsiElement(MSATokenType.ID)('ParsingTestData')(28,43)
1717
PsiWhiteSpace(' ')(43,44)
18-
MSAComponentBodyImpl(COMPONENT_BODY)(44,49)
18+
MSAComponentBodyImpl(COMPONENT_BODY)(44,48)
1919
PsiElement(MSATokenType.{)('{')(44,45)
20-
PsiWhiteSpace('\n\n\n')(45,48)
21-
PsiElement(MSATokenType.})('}')(48,49)
20+
PsiWhiteSpace('\n\n')(45,47)
21+
PsiElement(MSATokenType.})('}')(47,48)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package de.monticore.lang.montisecarc.codeinsight
2+
3+
import com.intellij.codeInsight.completion.CompletionType
4+
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
5+
6+
/**
7+
* Copyright 2017 thomasbuning
8+
*
9+
* Licensed under the Apache License, Version 2.0 (the "License");
10+
* you may not use this file except in compliance with the License.
11+
* You may obtain a copy of the License at
12+
*
13+
* http://www.apache.org/licenses/LICENSE-2.0
14+
*
15+
*
16+
* Unless required by applicable law or agreed to in writing, software
17+
* distributed under the License is distributed on an "AS IS" BASIS,
18+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19+
* See the License for the specific language governing permissions and
20+
* limitations under the License.
21+
*/
22+
class CodeInsightTests: LightCodeInsightFixtureTestCase() {
23+
24+
override fun getTestDataPath(): String = "testData"
25+
26+
fun testCompletion() {
27+
28+
myFixture.configureByFile("DefaultCashDeskSystem.secarc")
29+
myFixture.complete(CompletionType.BASIC, 1);
30+
val strings = myFixture.lookupElementStrings;
31+
32+
if (strings == null) {
33+
34+
} else {
35+
assertTrue(strings.containsAll(listOf("component", "connect", "accesscontrol", "autoconnect", "barcode")));
36+
assertEquals(5, strings.size);
37+
}
38+
}
39+
40+
fun testAnnotator() {
41+
myFixture.configureByFiles("AnnotatorTestData.kt", "CashDeskSystem.secarc")
42+
myFixture.checkHighlighting(false, false, true, true)
43+
}
44+
45+
}

tests/de/monticore/lang/montisecarc/ParserTests.kt renamed to tests/de/monticore/lang/montisecarc/parser/ParserTests.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
package de.monticore.lang.montisecarc
1+
package de.monticore.lang.montisecarc.parser
22

33
import com.intellij.testFramework.ParsingTestCase
4+
import de.monticore.lang.montisecarc.MSAParserDefinition
45

56
/**
67
* Copyright 2017 thomasbuning
@@ -26,6 +27,10 @@ class ParserTests : ParsingTestCase("", "secarc", MSAParserDefinition()) {
2627
doTest(true)
2728
}
2829

30+
fun testCashDeskSystem() {
31+
doTest(true)
32+
}
33+
2934
override fun getTestDataPath(): String {
3035
return "testData"
3136
}

0 commit comments

Comments
 (0)