added JVM/Junit testing to RCApp (and renamed the UI test folder)

This commit is contained in:
Peter Siegmund committed 2015-06-19 12:08:48 +02:00
1 parent c2cce35d7c
commit 78817ac60a
6 files changed
+65 -82

No files matched your search

@@ -29,9 +29,13 @@ android {
}
androidTest {
java.srcDirs = ["tests/src"]
res.srcDirs = ["tests/res"]
assets.srcDirs = ["tests/assets"]
java.srcDirs = ["tests-ui/src"]
res.srcDirs = ["tests-ui/res"]
assets.srcDirs = ["tests-ui/assets"]
}
test {
java.srcDirs = ["tests-jvm/src"]
}
}
@@ -83,14 +87,19 @@ dependencies {
/* all local jar-libs */
compile fileTree(dir: "libs", include: ["*.jar"])
/* JVM tests */
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:1.9.5"
/* UI testing with espresso */
androidTestCompile "com.android.support:support-annotations:22.1.1"
androidTestCompile "com.android.support.test:runner:0.2"
androidTestCompile "com.android.support.test:rules:0.2"
androidTestCompile "com.android.support.test.espresso:espresso-core:2.1"
androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.1') {
exclude group: 'com.android.support', module: 'appcompat'
exclude group: 'com.android.support', module: 'support-v4'
exclude module: 'recyclerview-v7'
androidTestCompile ("com.android.support.test.espresso:espresso-contrib:2.1") {
exclude group: "com.android.support", module: "appcompat"
exclude group: "com.android.support", module: "support-v4"
exclude module: "recyclerview-v7"
}
}
@@ -0,0 +1,48 @@
package com.sap.sailing.racecommittee.app.domain.impl;
import com.sap.sse.common.Util.Triple;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
/**
* This test verifies the algorithm used to escape and unescape SimpleRaceIdentifier components as used in
* <code>FleetIfentifierImpl</code>.
*
* @author Axel Uhl (D043530)
*
*/
public class SimpleRaceIdentifierEscapingTest {
@Test
public void testUnescapingSimpleRaceIdentifier() {
test("Leaderboard with trailing backslash and dot\\.", "empty", "fleet", "raceColumn");
test("Leaderboard\\.with\\.two dots", "empty", "fleet", "raceColumn");
test("Leaderboard with double backslash\\\\", "empty", "fleet", "raceColumn");
test("Leaderboard with double backslash and dot\\\\.", "empty", "fleet", "raceColumn");
test("\\Leaderboard with leading backslash", "empty", "fleet", "raceColumn");
test("\\.Leaderboard with leading backslash and dot", "empty", "fleet", "raceColumn");
test("\\\\.Leaderboard with leading double backslash and dot", "empty", "fleet", "raceColumn");
test("\\\\.Leaderboard with leading double backslash and two dots", "empty", "fleet", "raceColumn");
}
private void test(String leaderboardName, String empty, String fleetName, String raceColumnName) {
final String marshalled = build(leaderboardName, empty, fleetName, raceColumnName);
final Triple<String, String, String> parsed = FleetIdentifierImpl.unescape(marshalled);
assertEquals(leaderboardName, parsed.getA());
assertEquals(raceColumnName, parsed.getB());
assertEquals(fleetName, parsed.getC());
}
private String build(String leaderboardName, String empty, String fleetName, String raceColumnName) {
return String.format("%s.%s.%s.%s",
escape(leaderboardName),
escape(empty),
escape(fleetName),
escape(raceColumnName));
}
private String escape(String s) {
return s.replace("\\", "\\\\");
}
}