aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2015-02-13 23:10:47 +0100
committerBananeweizen <bananeweizen@gmx.de>2015-02-13 23:10:47 +0100
commit0b77441d721dbd444c0a4675978fecf753ad79f6 (patch)
tree281dc5950ab800412e36c23f619d09554d59c5ab /tests
parent1d9a1922ca9ab563d686150ca20a153b20a378d7 (diff)
downloadcgeo-0b77441d721dbd444c0a4675978fecf753ad79f6.zip
cgeo-0b77441d721dbd444c0a4675978fecf753ad79f6.tar.gz
cgeo-0b77441d721dbd444c0a4675978fecf753ad79f6.tar.bz2
some more connector tests
Diffstat (limited to 'tests')
-rw-r--r--tests/src/cgeo/geocaching/connector/WaymarkingConnectorTest.java21
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java3
-rw-r--r--tests/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnectorTest.java44
3 files changed, 67 insertions, 1 deletions
diff --git a/tests/src/cgeo/geocaching/connector/WaymarkingConnectorTest.java b/tests/src/cgeo/geocaching/connector/WaymarkingConnectorTest.java
new file mode 100644
index 0000000..c4eacc5
--- /dev/null
+++ b/tests/src/cgeo/geocaching/connector/WaymarkingConnectorTest.java
@@ -0,0 +1,21 @@
+package cgeo.geocaching.connector;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import junit.framework.TestCase;
+
+public class WaymarkingConnectorTest extends TestCase {
+
+ public static void testGetGeocodeFromUrl() {
+ assertThat(ConnectorFactory.getGeocodeFromURL("http://coord.info/WM1234")).isEqualTo("WM1234");
+ assertThat(ConnectorFactory.getGeocodeFromURL("http://www.waymarking.com/waymarks/WMNCDT_American_Legion_Flagpole_1983_University_of_Oregon")).isEqualTo("WMNCDT");
+
+ final IConnector wmConnector = ConnectorFactory.getConnector("WM1234");
+ assertThat(wmConnector).isNotNull();
+
+ assertThat(wmConnector.getGeocodeFromUrl("http://coord.info/WM1234")).isEqualTo("WM1234");
+ assertThat(wmConnector.getGeocodeFromUrl("http://www.waymarking.com/waymarks/WMNCDT_American_Legion_Flagpole_1983_University_of_Oregon")).isEqualTo("WMNCDT");
+
+ assertThat(wmConnector.getGeocodeFromUrl("http://coord.info/GC12ABC")).isNull();
+ assertThat(wmConnector.getGeocodeFromUrl("http://coord.info/TB1234")).isNull();
+ }
+}
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
index 24f65fd..30a9af9 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCConnectorTest.java
@@ -82,7 +82,7 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
assertTileAt(7536, 4915, new Tile(new Geopoint("S 33° 50.326 E 151° 12.426"), 13));
}
- private static void assertTileAt(int x, int y, final Tile tile) {
+ private static void assertTileAt(final int x, final int y, final Tile tile) {
assertThat(tile.getX()).isEqualTo(x);
assertThat(tile.getY()).isEqualTo(y);
}
@@ -96,5 +96,6 @@ public class GCConnectorTest extends AbstractResourceInstrumentationTestCase {
assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://coord.info/TB1234")).isNull();
assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/TB1234")).isNull();
+ assertThat(GCConnector.getInstance().getGeocodeFromUrl("http://www.coord.info/WM1234")).isNull();
}
}
diff --git a/tests/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnectorTest.java b/tests/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnectorTest.java
new file mode 100644
index 0000000..ded0a1a
--- /dev/null
+++ b/tests/src/cgeo/geocaching/connector/trackable/UnknownTrackableConnectorTest.java
@@ -0,0 +1,44 @@
+package cgeo.geocaching.connector.trackable;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import cgeo.geocaching.Trackable;
+
+import junit.framework.TestCase;
+
+public class UnknownTrackableConnectorTest extends TestCase {
+
+ private static UnknownTrackableConnector getConnector() {
+ return new UnknownTrackableConnector();
+ }
+
+ public static void testCanHandleTrackable() throws Exception {
+ assertThat(getConnector().canHandleTrackable("TB1234")).isFalse();
+ }
+
+ public static void testGetUrl() throws Exception {
+ try {
+ getConnector().getUrl(new Trackable());
+ fail("IllegalStateException expected");
+ } catch (final IllegalStateException e) {
+ // empty
+ }
+ }
+
+ public static void testSearchTrackable() throws Exception {
+ assertThat(getConnector().searchTrackable("TB1234", null, null)).isNull();
+ }
+
+ public static void testIsLoggable() throws Exception {
+ assertThat(getConnector().isLoggable()).isFalse();
+ }
+
+ public static void testGetTrackableCodeFromUrl() throws Exception {
+ assertThat(getConnector().getTrackableCodeFromUrl("http://www.sometrackable.com/1234")).isNull();
+ }
+
+ public static void testGetUserActions() throws Exception {
+ assertThat(getConnector().getUserActions()).isEmpty();
+ }
+
+}