aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo/geocaching/connector
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2015-01-28 21:19:41 +0100
committerBananeweizen <bananeweizen@gmx.de>2015-01-28 21:19:41 +0100
commite779f94d8ea27d7b0e56308738bc358b09380ab6 (patch)
tree8e94daabee6f6ffb0510812d17e167a1b8be0e11 /tests/src/cgeo/geocaching/connector
parent30c44a59c2e9597eafd7978c2fd9b8f727bb39d2 (diff)
downloadcgeo-e779f94d8ea27d7b0e56308738bc358b09380ab6.zip
cgeo-e779f94d8ea27d7b0e56308738bc358b09380ab6.tar.gz
cgeo-e779f94d8ea27d7b0e56308738bc358b09380ab6.tar.bz2
support trackables of geocaching.com.au
Diffstat (limited to 'tests/src/cgeo/geocaching/connector')
-rw-r--r--tests/src/cgeo/geocaching/connector/trackable/SwaggieConnectorTest.java29
-rw-r--r--tests/src/cgeo/geocaching/connector/trackable/SwaggieParserTest.java34
2 files changed, 63 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/connector/trackable/SwaggieConnectorTest.java b/tests/src/cgeo/geocaching/connector/trackable/SwaggieConnectorTest.java
new file mode 100644
index 0000000..54c3319
--- /dev/null
+++ b/tests/src/cgeo/geocaching/connector/trackable/SwaggieConnectorTest.java
@@ -0,0 +1,29 @@
+package cgeo.geocaching.connector.trackable;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import cgeo.geocaching.Trackable;
+
+import junit.framework.TestCase;
+
+public class SwaggieConnectorTest extends TestCase {
+
+ public static void testCanHandleTrackable() {
+ assertThat(new SwaggieConnector().canHandleTrackable("SW0001")).isTrue();
+ assertThat(new SwaggieConnector().canHandleTrackable("SWABCD")).isFalse();
+ assertThat(new SwaggieConnector().canHandleTrackable("GK82A2")).isFalse();
+ assertThat(new SwaggieConnector().canHandleTrackable("TB1234")).isFalse();
+ assertThat(new SwaggieConnector().canHandleTrackable("UNKNOWN")).isFalse();
+ }
+
+ public static void testGetTrackableCodeFromUrl() throws Exception {
+ assertThat(new SwaggieConnector().getTrackableCodeFromUrl("http://geocaching.com.au/swaggie/sw0017")).isEqualTo("SW0017");
+ }
+
+ public static void testGetUrl() throws Exception {
+ final Trackable trackable = new Trackable();
+ trackable.setGeocode("SW0017");
+ assertThat(new SwaggieConnector().getUrl(trackable)).isEqualTo("http://geocaching.com.au/swaggie/SW0017");
+ }
+
+}
diff --git a/tests/src/cgeo/geocaching/connector/trackable/SwaggieParserTest.java b/tests/src/cgeo/geocaching/connector/trackable/SwaggieParserTest.java
new file mode 100644
index 0000000..1e63b1c
--- /dev/null
+++ b/tests/src/cgeo/geocaching/connector/trackable/SwaggieParserTest.java
@@ -0,0 +1,34 @@
+package cgeo.geocaching.connector.trackable;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import cgeo.geocaching.Trackable;
+import cgeo.geocaching.connector.ConnectorFactory;
+import cgeo.geocaching.network.Network;
+
+import junit.framework.TestCase;
+
+public class SwaggieParserTest extends TestCase {
+
+ public static void testParse() {
+ final Trackable trackableIn = new Trackable();
+ trackableIn.setGeocode("SW0017");
+
+ final String cacheUrl = ConnectorFactory.getTrackableConnector(trackableIn.getGeocode()).getUrl(trackableIn);
+ assertThat(cacheUrl).isNotNull();
+
+ final String page = Network.getResponseData(Network.getRequest(cacheUrl));
+ assertThat(page).isNotNull();
+
+ assert page != null;
+ final Trackable trackable = SwaggieParser.parse(page);
+ assertThat(trackable).isNotNull();
+ assert trackable != null;
+
+ assertThat(trackable.getName()).isEqualTo("Law and Order 1");
+ assertThat(trackable.getGeocode()).isEqualTo("SW0017");
+ assertThat(trackable.getDetails()).isEqualTo("A mini CD that may or may not contain a DivX .AVI of the Law and Order: CSI episode that features geocaching as part of the storyline.");
+ assertThat(trackable.getType()).isEqualTo("Swaggie");
+ assertThat(trackable.getOwner()).isEqualTo("Bear_Left");
+ }
+}