diff options
Diffstat (limited to 'tests/src/cgeo/geocaching/test/mock/GCBase.java')
| -rw-r--r-- | tests/src/cgeo/geocaching/test/mock/GCBase.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/src/cgeo/geocaching/test/mock/GCBase.java b/tests/src/cgeo/geocaching/test/mock/GCBase.java new file mode 100644 index 0000000..328c993 --- /dev/null +++ b/tests/src/cgeo/geocaching/test/mock/GCBase.java @@ -0,0 +1,43 @@ +package cgeo.geocaching.test.mock;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import cgeo.geocaching.ICache;
+import cgeo.geocaching.cgBase;
+
+public abstract class GCBase implements ICache {
+
+ /*
+ * The data for the caches can be generated by entering the url
+ * http://www.geocaching.com/seek/cache_details.aspx?log=y&wp=GCxxxx&numlogs=35&decrypt=y
+ * into a browser and saving the file
+ */
+ @Override
+ public String getData() {
+ try {
+ InputStream is = this.getClass().getResourceAsStream("/cgeo/geocaching/test/mock/"+getGeocode()+".html");
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+
+ int nRead;
+ byte[] data = new byte[16384];
+
+ while ((nRead = is.read(data, 0, data.length)) != -1) {
+ buffer.write(data, 0, nRead);
+ }
+
+ buffer.flush();
+ StringBuffer sb = new StringBuffer(buffer.toString());
+ cgBase.replaceWhitespace(sb);
+ return sb.toString();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+
+ }
+
+
+}
|
