diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-09-16 15:09:50 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-09-16 15:09:50 +0200 |
| commit | 6af958993f6214f0dcadffb84205a9e27819fa9e (patch) | |
| tree | 5e36191baaa3e26223094224c8af79e9676076ca /tests/src/cgeo/geocaching/test | |
| parent | 1fb09aed66eea5b7cd317e95569081097dcdde64 (diff) | |
| download | cgeo-6af958993f6214f0dcadffb84205a9e27819fa9e.zip cgeo-6af958993f6214f0dcadffb84205a9e27819fa9e.tar.gz cgeo-6af958993f6214f0dcadffb84205a9e27819fa9e.tar.bz2 | |
Apply the same style settings to tests as to main sources
Diffstat (limited to 'tests/src/cgeo/geocaching/test')
| -rw-r--r-- | tests/src/cgeo/geocaching/test/GeoPointParserTest.java | 90 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/cgDestinationTest.java | 46 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/cgSettingsTest.java | 60 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/cgeoApplicationTest.java | 142 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/cgeoTestSuite.java | 38 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java | 187 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/mock/GC2CJPF.java | 186 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/test/mock/MockedCache.java | 84 |
8 files changed, 416 insertions, 417 deletions
diff --git a/tests/src/cgeo/geocaching/test/GeoPointParserTest.java b/tests/src/cgeo/geocaching/test/GeoPointParserTest.java index 37a9cf7..673aac2 100644 --- a/tests/src/cgeo/geocaching/test/GeoPointParserTest.java +++ b/tests/src/cgeo/geocaching/test/GeoPointParserTest.java @@ -1,45 +1,45 @@ -package cgeo.geocaching.test;
-
-import cgeo.geocaching.geopoint.Geopoint;
-import cgeo.geocaching.geopoint.GeopointParser;
-import junit.framework.Assert;
-import android.test.AndroidTestCase;
-
-public class GeoPointParserTest extends AndroidTestCase {
-
- private static final double refLongitude = 8.0 + 38.564 / 60.0;
- private static final double refLatitude = 49.0 + 56.031 / 60.0;
-
- public void testParseLatitude() throws Throwable {
-
- Assert.assertEquals(refLatitude, GeopointParser.parseLatitude("N 49° 56.031"), 1e-8);
- }
-
- public void testParseLongitude() throws Throwable {
-
- Assert.assertEquals(refLongitude, GeopointParser.parseLongitude("E 8° 38.564"), 1e-8);
- }
-
- public void testFullCoordinates() throws Throwable {
- final Geopoint goal = new Geopoint(refLatitude, refLongitude);
- Assert.assertTrue(goal.isEqualTo(GeopointParser.parse("N 49° 56.031 | E 8° 38.564"), 1e-6));
- }
-
- public void testSouth() throws Throwable {
- Assert.assertEquals(-refLatitude, GeopointParser.parseLatitude("S 49° 56.031"), 1e-8);
- }
-
- public void testWest() throws Throwable {
- Assert.assertEquals(-refLongitude, GeopointParser.parseLongitude("W 8° 38.564"), 1e-8);
- }
-
- public void testLowerCase() throws Throwable {
- Assert.assertEquals(refLongitude, GeopointParser.parseLongitude("e 8° 38.564"), 1e-8);
- }
-
- public void testVariousFormats() throws Throwable {
- final Geopoint goal1 = GeopointParser.parse("N 49° 43' 57\" | E 2 12' 35");
- final Geopoint goal2 = GeopointParser.parse("N 49 43.95 E2°12.5833333333");
- Assert.assertTrue(goal1.isEqualTo(goal2, 1e-6));
- }
-}
+package cgeo.geocaching.test; + +import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.geopoint.GeopointParser; +import junit.framework.Assert; +import android.test.AndroidTestCase; + +public class GeoPointParserTest extends AndroidTestCase { + + private static final double refLongitude = 8.0 + 38.564 / 60.0; + private static final double refLatitude = 49.0 + 56.031 / 60.0; + + public void testParseLatitude() throws Throwable { + + Assert.assertEquals(refLatitude, GeopointParser.parseLatitude("N 49° 56.031"), 1e-8); + } + + public void testParseLongitude() throws Throwable { + + Assert.assertEquals(refLongitude, GeopointParser.parseLongitude("E 8° 38.564"), 1e-8); + } + + public void testFullCoordinates() throws Throwable { + final Geopoint goal = new Geopoint(refLatitude, refLongitude); + Assert.assertTrue(goal.isEqualTo(GeopointParser.parse("N 49° 56.031 | E 8° 38.564"), 1e-6)); + } + + public void testSouth() throws Throwable { + Assert.assertEquals(-refLatitude, GeopointParser.parseLatitude("S 49° 56.031"), 1e-8); + } + + public void testWest() throws Throwable { + Assert.assertEquals(-refLongitude, GeopointParser.parseLongitude("W 8° 38.564"), 1e-8); + } + + public void testLowerCase() throws Throwable { + Assert.assertEquals(refLongitude, GeopointParser.parseLongitude("e 8° 38.564"), 1e-8); + } + + public void testVariousFormats() throws Throwable { + final Geopoint goal1 = GeopointParser.parse("N 49° 43' 57\" | E 2 12' 35"); + final Geopoint goal2 = GeopointParser.parse("N 49 43.95 E2°12.5833333333"); + Assert.assertTrue(goal1.isEqualTo(goal2, 1e-6)); + } +} diff --git a/tests/src/cgeo/geocaching/test/cgDestinationTest.java b/tests/src/cgeo/geocaching/test/cgDestinationTest.java index e869e52..d4864d6 100644 --- a/tests/src/cgeo/geocaching/test/cgDestinationTest.java +++ b/tests/src/cgeo/geocaching/test/cgDestinationTest.java @@ -1,24 +1,24 @@ -package cgeo.geocaching.test;
-
-import junit.framework.Assert;
-import android.test.AndroidTestCase;
-import cgeo.geocaching.cgDestination;
-import cgeo.geocaching.geopoint.Geopoint;
-
-public class cgDestinationTest extends AndroidTestCase {
-
- cgDestination dest = null;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- dest = new cgDestination(1, 10000, new Geopoint(52.5, 9.33));
- }
-
- public void testSomething() throws Throwable {
- Assert.assertEquals(1, dest.getId());
- Assert.assertEquals(10000, dest.getDate());
- Assert.assertEquals(52.5, dest.getCoords().getLatitude());
- Assert.assertEquals(9.33, dest.getCoords().getLongitude());
- }
+package cgeo.geocaching.test; + +import junit.framework.Assert; +import android.test.AndroidTestCase; +import cgeo.geocaching.cgDestination; +import cgeo.geocaching.geopoint.Geopoint; + +public class cgDestinationTest extends AndroidTestCase { + + cgDestination dest = null; + + @Override + protected void setUp() throws Exception { + super.setUp(); + dest = new cgDestination(1, 10000, new Geopoint(52.5, 9.33)); + } + + public void testSomething() throws Throwable { + Assert.assertEquals(1, dest.getId()); + Assert.assertEquals(10000, dest.getDate()); + Assert.assertEquals(52.5, dest.getCoords().getLatitude()); + Assert.assertEquals(9.33, dest.getCoords().getLongitude()); + } }
\ No newline at end of file diff --git a/tests/src/cgeo/geocaching/test/cgSettingsTest.java b/tests/src/cgeo/geocaching/test/cgSettingsTest.java index 459c7ff..ad3dc16 100644 --- a/tests/src/cgeo/geocaching/test/cgSettingsTest.java +++ b/tests/src/cgeo/geocaching/test/cgSettingsTest.java @@ -1,30 +1,30 @@ -package cgeo.geocaching.test;
-
-import android.test.ActivityInstrumentationTestCase2;
-import cgeo.geocaching.cgSettings;
-import cgeo.geocaching.cgeo;
-
-public class cgSettingsTest extends ActivityInstrumentationTestCase2<cgeo> {
-
- private cgeo activity;
-
- public cgSettingsTest() {
- super("cgeo.geocaching", cgeo.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- activity = getActivity();
- }
-
- /**
- * loads new empty settings, this should work fine without an exception (once there was an exception because of the empty map file string)
- */
- public void testSettingsException() {
- cgSettings settings = new cgSettings(activity, activity.getSharedPreferences("not existing preferences", 0));
-
- // assert that we really created new settings
- assertNull(settings.getMapFile());
- }
-}
+package cgeo.geocaching.test; + +import android.test.ActivityInstrumentationTestCase2; +import cgeo.geocaching.cgSettings; +import cgeo.geocaching.cgeo; + +public class cgSettingsTest extends ActivityInstrumentationTestCase2<cgeo> { + + private cgeo activity; + + public cgSettingsTest() { + super("cgeo.geocaching", cgeo.class); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + activity = getActivity(); + } + + /** + * loads new empty settings, this should work fine without an exception (once there was an exception because of the empty map file string) + */ + public void testSettingsException() { + cgSettings settings = new cgSettings(activity, activity.getSharedPreferences("not existing preferences", 0)); + + // assert that we really created new settings + assertNull(settings.getMapFile()); + } +} diff --git a/tests/src/cgeo/geocaching/test/cgeoApplicationTest.java b/tests/src/cgeo/geocaching/test/cgeoApplicationTest.java index bc9585a..43463bc 100644 --- a/tests/src/cgeo/geocaching/test/cgeoApplicationTest.java +++ b/tests/src/cgeo/geocaching/test/cgeoApplicationTest.java @@ -27,89 +27,89 @@ import cgeo.geocaching.test.mock.MockedCache; public class cgeoApplicationTest extends ApplicationTestCase<cgeoapplication> { - private cgSettings settings = null; - private cgBase base = null; + private cgSettings settings = null; + private cgBase base = null; - public cgeoApplicationTest() { - super(cgeoapplication.class); - } + public cgeoApplicationTest() { + super(cgeoapplication.class); + } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Override + protected void setUp() throws Exception { + super.setUp(); - // init environment - createApplication(); - Context context = this.getContext(); - SharedPreferences prefs = context.getSharedPreferences( - cgSettings.preferences, Context.MODE_PRIVATE); + // init environment + createApplication(); + Context context = this.getContext(); + SharedPreferences prefs = context.getSharedPreferences( + cgSettings.preferences, Context.MODE_PRIVATE); - // create required c:geo objects - settings = new cgSettings(context, prefs); - base = new cgBase(this.getApplication(), settings, prefs); - } + // create required c:geo objects + settings = new cgSettings(context, prefs); + base = new cgBase(this.getApplication(), settings, prefs); + } - /** - * The name 'test preconditions' is a convention to signal that if this test - * doesn't pass, the test case was not set up properly and it might explain - * any and all failures in other tests. This is not guaranteed to run before - * other tests, as junit uses reflection to find the tests. - */ - @SmallTest - public void testPreconditions() { - } + /** + * The name 'test preconditions' is a convention to signal that if this test + * doesn't pass, the test case was not set up properly and it might explain + * any and all failures in other tests. This is not guaranteed to run before + * other tests, as junit uses reflection to find the tests. + */ + @SmallTest + public void testPreconditions() { + } - /** - * Test {@link cgBase#searchByGeocode(HashMap, int, boolean)} - * - * @param base - */ - @MediumTest - public void testSearchByGeocode() { - HashMap<String, String> params = new HashMap<String, String>(); - params.put("geocode", "GC1RMM2"); + /** + * Test {@link cgBase#searchByGeocode(HashMap, int, boolean)} + * + * @param base + */ + @MediumTest + public void testSearchByGeocode() { + HashMap<String, String> params = new HashMap<String, String>(); + params.put("geocode", "GC1RMM2"); - final UUID id = base.searchByGeocode(params, 0, true); - Assert.assertNotNull(id); - } + final UUID id = base.searchByGeocode(params, 0, true); + Assert.assertNotNull(id); + } /** * Test {@link cgBase#parseCache(String, int) with "mocked" data * @param base */ - @MediumTest - public void testParseCache() { - List<MockedCache> cachesToTest = new ArrayList<MockedCache>(); - cachesToTest.add(new GC2CJPF()); - cachesToTest.add(new GC1ZXX2()); + @MediumTest + public void testParseCache() { + List<MockedCache> cachesToTest = new ArrayList<MockedCache>(); + cachesToTest.add(new GC2CJPF()); + cachesToTest.add(new GC1ZXX2()); - for (MockedCache cache : cachesToTest) { - cgCacheWrap caches = base.parseCache(cache.getData(), 0); - cgCache cacheParsed = caches.cacheList.get(0); - Assert.assertEquals(cacheParsed.getGeocode(), cache.getGeocode()); - Assert.assertEquals(cacheParsed.getType(), cache.getType()); - Assert.assertEquals(cacheParsed.getOwner(), cache.getOwner()); - Assert.assertEquals(cacheParsed.getDifficulty(), cache - .getDifficulty()); - Assert.assertEquals(cacheParsed.getTerrain(), cache.getTerrain()); - Assert.assertEquals(cacheParsed.getLatitude(), cache.getLatitude()); - Assert.assertEquals(cacheParsed.getLongitude(), cache - .getLongitude()); - Assert.assertEquals(cacheParsed.isDisabled(), cache.isDisabled()); - Assert.assertEquals(cacheParsed.isOwn(), cache.isOwn()); - Assert.assertEquals(cacheParsed.isArchived(), cache.isArchived()); - Assert.assertEquals(cacheParsed.isMembersOnly(), cache - .isMembersOnly()); - Assert.assertEquals(cacheParsed.getOwnerReal(), cache - .getOwnerReal()); - Assert.assertEquals(cacheParsed.getSize(), cache.getSize()); - Assert.assertEquals(cacheParsed.getHint(), cache.getHint()); - Assert.assertTrue(cacheParsed.getDescription().startsWith( - cache.getDescription())); - Assert.assertEquals(cacheParsed.getShortDescription(), cache - .getShortDescription()); - Assert.assertEquals(cacheParsed.getName(), cache.getName()); - } - } + for (MockedCache cache : cachesToTest) { + cgCacheWrap caches = base.parseCache(cache.getData(), 0); + cgCache cacheParsed = caches.cacheList.get(0); + Assert.assertEquals(cacheParsed.getGeocode(), cache.getGeocode()); + Assert.assertEquals(cacheParsed.getType(), cache.getType()); + Assert.assertEquals(cacheParsed.getOwner(), cache.getOwner()); + Assert.assertEquals(cacheParsed.getDifficulty(), cache + .getDifficulty()); + Assert.assertEquals(cacheParsed.getTerrain(), cache.getTerrain()); + Assert.assertEquals(cacheParsed.getLatitude(), cache.getLatitude()); + Assert.assertEquals(cacheParsed.getLongitude(), cache + .getLongitude()); + Assert.assertEquals(cacheParsed.isDisabled(), cache.isDisabled()); + Assert.assertEquals(cacheParsed.isOwn(), cache.isOwn()); + Assert.assertEquals(cacheParsed.isArchived(), cache.isArchived()); + Assert.assertEquals(cacheParsed.isMembersOnly(), cache + .isMembersOnly()); + Assert.assertEquals(cacheParsed.getOwnerReal(), cache + .getOwnerReal()); + Assert.assertEquals(cacheParsed.getSize(), cache.getSize()); + Assert.assertEquals(cacheParsed.getHint(), cache.getHint()); + Assert.assertTrue(cacheParsed.getDescription().startsWith( + cache.getDescription())); + Assert.assertEquals(cacheParsed.getShortDescription(), cache + .getShortDescription()); + Assert.assertEquals(cacheParsed.getName(), cache.getName()); + } + } } diff --git a/tests/src/cgeo/geocaching/test/cgeoTestSuite.java b/tests/src/cgeo/geocaching/test/cgeoTestSuite.java index 998bfc4..31a469e 100644 --- a/tests/src/cgeo/geocaching/test/cgeoTestSuite.java +++ b/tests/src/cgeo/geocaching/test/cgeoTestSuite.java @@ -1,19 +1,19 @@ -package cgeo.geocaching.test;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import android.test.suitebuilder.TestSuiteBuilder;
-
-/**
- * The c:geo unit test suite. Based on http://marakana.com/tutorials/android/junit-test-example.html
- * All tests below this package will get executed
- * It can be used for unit testing which requires no application and/or context.
- * For further informations have a look at http://developer.android.com/guide/topics/testing/testing_android.html
- */
-
-public class cgeoTestSuite extends TestSuite {
-
- public static Test suite() {
- return new TestSuiteBuilder(cgeoTestSuite.class).includeAllPackagesUnderHere().build();
- }
-}
+package cgeo.geocaching.test; + +import junit.framework.Test; +import junit.framework.TestSuite; +import android.test.suitebuilder.TestSuiteBuilder; + +/** + * The c:geo unit test suite. Based on http://marakana.com/tutorials/android/junit-test-example.html + * All tests below this package will get executed + * It can be used for unit testing which requires no application and/or context. + * For further informations have a look at http://developer.android.com/guide/topics/testing/testing_android.html + */ + +public class cgeoTestSuite extends TestSuite { + + public static Test suite() { + return new TestSuiteBuilder(cgeoTestSuite.class).includeAllPackagesUnderHere().build(); + } +} diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java index 3c43cf0..9cd653a 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java +++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java @@ -1,94 +1,93 @@ -package cgeo.geocaching.test.mock;
-
-import cgeo.geocaching.enumerations.CacheSize;
-
-
-public class GC1ZXX2 extends MockedCache {
-
- @Override
- public Float getDifficulty() {
- return 3.0f;
- }
-
- @Override
- public String getGeocode() {
- return "GC1ZXX2";
- }
-
- @Override
- public String getLatitude() {
- return "N 52° 22.393";
- }
-
- @Override
- public String getLongitude() {
- return "E 009° 42.648";
- }
-
- @Override
- public String getOwner() {
- return "Rich Uncle Pennybags ";
- }
-
- @Override
- public CacheSize getSize() {
- return CacheSize.OTHER;
- }
-
- @Override
- public Float getTerrain() {
- return 1.5f;
- }
-
- @Override
- public String getType() {
- return "traditional";
- }
-
- @Override
- public boolean isArchived() {
- return false;
- }
-
- @Override
- public boolean isDisabled() {
- return true;
- }
-
- @Override
- public boolean isMembersOnly() {
- return false;
- }
-
- @Override
- public boolean isOwn() {
- return false;
- }
-
- @Override
- public String getOwnerReal() {
- return "daniel354";
- }
-
- @Override
- public String getHint() {
- return "";
- }
-
- @Override
- public String getDescription() {
- return "<center><img width=\"500\"";
- }
-
- @Override
- public String getShortDescription() {
- return "";
- }
-
- @Override
- public String getName() {
- return "Hannopoly: Eislisenstrasse ";
- }
-
-}
-
\ No newline at end of file +package cgeo.geocaching.test.mock; + +import cgeo.geocaching.enumerations.CacheSize; + + +public class GC1ZXX2 extends MockedCache { + + @Override + public Float getDifficulty() { + return 3.0f; + } + + @Override + public String getGeocode() { + return "GC1ZXX2"; + } + + @Override + public String getLatitude() { + return "N 52° 22.393"; + } + + @Override + public String getLongitude() { + return "E 009° 42.648"; + } + + @Override + public String getOwner() { + return "Rich Uncle Pennybags "; + } + + @Override + public CacheSize getSize() { + return CacheSize.OTHER; + } + + @Override + public Float getTerrain() { + return 1.5f; + } + + @Override + public String getType() { + return "traditional"; + } + + @Override + public boolean isArchived() { + return false; + } + + @Override + public boolean isDisabled() { + return true; + } + + @Override + public boolean isMembersOnly() { + return false; + } + + @Override + public boolean isOwn() { + return false; + } + + @Override + public String getOwnerReal() { + return "daniel354"; + } + + @Override + public String getHint() { + return ""; + } + + @Override + public String getDescription() { + return "<center><img width=\"500\""; + } + + @Override + public String getShortDescription() { + return ""; + } + + @Override + public String getName() { + return "Hannopoly: Eislisenstrasse "; + } + +} diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java index 62b2616..8029f93 100644 --- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java +++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java @@ -1,93 +1,93 @@ -package cgeo.geocaching.test.mock;
-
-import cgeo.geocaching.enumerations.CacheSize;
-
-
-public class GC2CJPF extends MockedCache {
-
- @Override
- public Float getDifficulty() {
- return 2.5f;
- }
-
- @Override
- public String getGeocode() {
- return "GC2CJPF";
- }
-
- @Override
- public String getLatitude() {
- return "N 52° 25.504";
- }
-
- @Override
- public String getLongitude() {
- return "E 009° 39.852";
- }
-
- @Override
- public String getOwner() {
- return "Tom03";
- }
- @Override
- public String getOwnerReal() {
- return getOwner();
- }
-
- @Override
- public CacheSize getSize() {
- return CacheSize.SMALL;
- }
-
- @Override
- public Float getTerrain() {
- return 2.0f;
- }
-
- @Override
- public String getType() {
- return "multi";
- }
-
- @Override
- public boolean isArchived() {
- return false;
- }
-
- @Override
- public boolean isDisabled() {
- return false;
- }
-
- @Override
- public boolean isMembersOnly() {
- return false;
- }
-
- @Override
- public boolean isOwn() {
- return false;
- }
-
-
- @Override
- public String getHint() {
- return "Das Final (unter Steinen) ist mit GC gekennzeichnet.";
- }
-
- @Override
- public String getDescription() {
- return "Kleiner Multi über 7 Stationen";
- }
-
- @Override
- public String getShortDescription() {
- return "Von Nachwuchs-Cachern für Nachwuchs-Cacher.";
- }
-
- @Override
- public String getName() {
- return "Kinderwald KiC";
- }
-
-}
+package cgeo.geocaching.test.mock; + +import cgeo.geocaching.enumerations.CacheSize; + + +public class GC2CJPF extends MockedCache { + + @Override + public Float getDifficulty() { + return 2.5f; + } + + @Override + public String getGeocode() { + return "GC2CJPF"; + } + + @Override + public String getLatitude() { + return "N 52° 25.504"; + } + + @Override + public String getLongitude() { + return "E 009° 39.852"; + } + + @Override + public String getOwner() { + return "Tom03"; + } + @Override + public String getOwnerReal() { + return getOwner(); + } + + @Override + public CacheSize getSize() { + return CacheSize.SMALL; + } + + @Override + public Float getTerrain() { + return 2.0f; + } + + @Override + public String getType() { + return "multi"; + } + + @Override + public boolean isArchived() { + return false; + } + + @Override + public boolean isDisabled() { + return false; + } + + @Override + public boolean isMembersOnly() { + return false; + } + + @Override + public boolean isOwn() { + return false; + } + + + @Override + public String getHint() { + return "Das Final (unter Steinen) ist mit GC gekennzeichnet."; + } + + @Override + public String getDescription() { + return "Kleiner Multi über 7 Stationen"; + } + + @Override + public String getShortDescription() { + return "Von Nachwuchs-Cachern für Nachwuchs-Cacher."; + } + + @Override + public String getName() { + return "Kinderwald KiC"; + } + +} diff --git a/tests/src/cgeo/geocaching/test/mock/MockedCache.java b/tests/src/cgeo/geocaching/test/mock/MockedCache.java index 12daca5..9fba5cc 100644 --- a/tests/src/cgeo/geocaching/test/mock/MockedCache.java +++ b/tests/src/cgeo/geocaching/test/mock/MockedCache.java @@ -1,42 +1,42 @@ -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 MockedCache 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
- */
- 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;
-
- }
-
-
-}
+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 MockedCache 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 + */ + 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; + + } + + +} |
