aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/cgeo/geocaching/ParametersTest.java4
-rw-r--r--tests/src/cgeo/geocaching/files/GPXImporterTest.java34
-rw-r--r--tests/src/cgeo/geocaching/test/WhitespaceTest.java2
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java2
-rw-r--r--tests/src/cgeo/geocaching/test/mock/GC2CJPF.java2
-rw-r--r--tests/src/cgeo/geocaching/test/mock/MockedCache.java2
6 files changed, 24 insertions, 22 deletions
diff --git a/tests/src/cgeo/geocaching/ParametersTest.java b/tests/src/cgeo/geocaching/ParametersTest.java
index 1855946..6ed8a65 100644
--- a/tests/src/cgeo/geocaching/ParametersTest.java
+++ b/tests/src/cgeo/geocaching/ParametersTest.java
@@ -1,7 +1,5 @@
package cgeo.geocaching;
-import cgeo.geocaching.Parameters;
-
import android.test.AndroidTestCase;
import java.security.InvalidParameterException;
@@ -12,8 +10,8 @@ public class ParametersTest extends AndroidTestCase {
public static void testException() {
try {
- @SuppressWarnings("unused")
final Parameters params = new Parameters("aaa", "AAA", "bbb");
+ params.clear(); // this will never be invoked, but suppresses warnings about unused objects
Assert.fail("Exception not raised");
} catch (InvalidParameterException e) {
// Ok
diff --git a/tests/src/cgeo/geocaching/files/GPXImporterTest.java b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
index 55db7b0..e80e254 100644
--- a/tests/src/cgeo/geocaching/files/GPXImporterTest.java
+++ b/tests/src/cgeo/geocaching/files/GPXImporterTest.java
@@ -56,8 +56,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
copyResourceToFile(R.raw.gc31j2h, gc31j2h);
GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler);
- importThread.run();
- importStepHandler.waitForCompletion();
+ runImportThread(importThread);
assertEquals(3, importStepHandler.messages.size());
assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what);
@@ -73,14 +72,24 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
// assertNull(cache.waypoints);
}
+ private void runImportThread(GPXImporter.ImportThread importThread) {
+ importThread.start();
+ try {
+ importThread.join();
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ importStepHandler.waitForCompletion();
+ }
+
public void testImportGpxWithWaypoints() throws IOException {
File gc31j2h = new File(tempDir, "gc31j2h.gpx");
copyResourceToFile(R.raw.gc31j2h, gc31j2h);
copyResourceToFile(R.raw.gc31j2h_wpts, new File(tempDir, "gc31j2h-wpts.gpx"));
GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler);
- importThread.run();
- importStepHandler.waitForCompletion();
+ runImportThread(importThread);
assertEquals(4, importStepHandler.messages.size());
assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what);
@@ -100,8 +109,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
copyResourceToFile(R.raw.oc5952_loc, oc5952);
GPXImporter.ImportLocFileThread importThread = new GPXImporter.ImportLocFileThread(oc5952, listId, importStepHandler, progressHandler);
- importThread.run();
- importStepHandler.waitForCompletion();
+ runImportThread(importThread);
assertEquals(3, importStepHandler.messages.size());
assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what);
@@ -124,8 +132,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
copyResourceToFile(R.raw.gc31j2h_err, gc31j2h);
GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler);
- importThread.run();
- importStepHandler.waitForCompletion();
+ runImportThread(importThread);
assertEquals(2, importStepHandler.messages.size());
assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what);
@@ -138,8 +145,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
progressHandler.cancel();
GPXImporter.ImportGpxFileThread importThread = new GPXImporter.ImportGpxFileThread(gc31j2h, listId, importStepHandler, progressHandler);
- importThread.run();
- importStepHandler.waitForCompletion();
+ runImportThread(importThread);
assertEquals(2, importStepHandler.messages.size());
assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what);
@@ -151,8 +157,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
copyResourceToFile(R.raw.pq7545915, pq7545915);
GPXImporter.ImportGpxZipFileThread importThread = new GPXImporter.ImportGpxZipFileThread(pq7545915, listId, importStepHandler, progressHandler);
- importThread.run();
- importStepHandler.waitForCompletion();
+ runImportThread(importThread);
assertEquals(4, importStepHandler.messages.size());
assertEquals(GPXImporter.IMPORT_STEP_READ_FILE, importStepHandler.messages.get(0).what);
@@ -173,8 +178,7 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
copyResourceToFile(R.raw.pq7545915, pq1);
GPXImporter.ImportGpxZipFileThread importThread = new GPXImporter.ImportGpxZipFileThread(pq1, listId, importStepHandler, progressHandler);
- importThread.run();
- importStepHandler.waitForCompletion();
+ runImportThread(importThread);
assertEquals(1, importStepHandler.messages.size());
assertEquals(GPXImporter.IMPORT_STEP_FINISHED_WITH_ERROR, importStepHandler.messages.get(0).what);
@@ -240,4 +244,4 @@ public class GPXImporterTest extends AbstractResourceInstrumentationTestCase {
dir.delete();
}
-}
+} \ No newline at end of file
diff --git a/tests/src/cgeo/geocaching/test/WhitespaceTest.java b/tests/src/cgeo/geocaching/test/WhitespaceTest.java
index 6fab7fd..f67940a 100644
--- a/tests/src/cgeo/geocaching/test/WhitespaceTest.java
+++ b/tests/src/cgeo/geocaching/test/WhitespaceTest.java
@@ -22,7 +22,7 @@ import java.util.regex.Pattern;
*/
public class WhitespaceTest extends AndroidTestCase {
- private final int EXPECTED_SIZE = 119418;
+ private final static int EXPECTED_SIZE = 119418;
private String data;
@Override
diff --git a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
index f36f3cb..168b7e7 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC1ZXX2.java
@@ -134,7 +134,7 @@ public class GC1ZXX2 extends MockedCache {
@Override
public Integer getFavoritePoints() {
- return new Integer(47);
+ return 47;
}
@Override
diff --git a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
index e5b443f..b07d62c 100644
--- a/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
+++ b/tests/src/cgeo/geocaching/test/mock/GC2CJPF.java
@@ -147,7 +147,7 @@ public class GC2CJPF extends MockedCache {
@Override
public Integer getFavoritePoints() {
- return new Integer(7);
+ return 7;
}
}
diff --git a/tests/src/cgeo/geocaching/test/mock/MockedCache.java b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
index d79510b..04320a2 100644
--- a/tests/src/cgeo/geocaching/test/mock/MockedCache.java
+++ b/tests/src/cgeo/geocaching/test/mock/MockedCache.java
@@ -115,7 +115,7 @@ public abstract class MockedCache implements ICache {
@Override
public Integer getFavoritePoints() {
- return new Integer(0);
+ return 0;
}
@Override