aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/cgeo
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2014-01-12 07:43:18 +0100
committerBananeweizen <bananeweizen@gmx.de>2014-01-12 07:43:18 +0100
commit24813f0bbe3f227b663c5752a5e64d68043608e6 (patch)
treec737f2070b6bbdf0edd81e55b1c11ea5c8539b85 /tests/src/cgeo
parent91bd1f845d4b803c33c6e05df021def81726d8d3 (diff)
downloadcgeo-24813f0bbe3f227b663c5752a5e64d68043608e6.zip
cgeo-24813f0bbe3f227b663c5752a5e64d68043608e6.tar.gz
cgeo-24813f0bbe3f227b663c5752a5e64d68043608e6.tar.bz2
enable eclipse null analysis on test project
Diffstat (limited to 'tests/src/cgeo')
-rw-r--r--tests/src/cgeo/geocaching/CgeoApplicationTest.java6
-rw-r--r--tests/src/cgeo/geocaching/connector/gc/GCParserTest.java6
-rw-r--r--tests/src/cgeo/geocaching/geopoint/ViewportTest.java5
-rw-r--r--tests/src/cgeo/geocaching/network/OAuthTest.java8
-rw-r--r--tests/src/cgeo/test/Compare.java6
5 files changed, 26 insertions, 5 deletions
diff --git a/tests/src/cgeo/geocaching/CgeoApplicationTest.java b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
index 730aff6..edf7862 100644
--- a/tests/src/cgeo/geocaching/CgeoApplicationTest.java
+++ b/tests/src/cgeo/geocaching/CgeoApplicationTest.java
@@ -26,7 +26,6 @@ import cgeo.geocaching.utils.CancellableHandler;
import cgeo.geocaching.utils.Log;
import cgeo.test.Compare;
-import junit.framework.Assert;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -35,6 +34,8 @@ import android.test.suitebuilder.annotation.SmallTest;
import java.util.GregorianCalendar;
+import junit.framework.Assert;
+
/**
* The c:geo application test. It can be used for tests that require an
* application and/or context.
@@ -72,6 +73,7 @@ public class CgeoApplicationTest extends CGeoTestCase {
public static void testSearchTrackable() {
final Trackable tb = GCParser.searchTrackable("TB2J1VZ", null, null);
assertNotNull(tb);
+ assert (tb != null); // eclipse bug
// fix data
assertEquals("aefffb86-099f-444f-b132-605436163aa8", tb.getGuid());
assertEquals("TB2J1VZ", tb.getGeocode());
@@ -169,6 +171,8 @@ public class CgeoApplicationTest extends CGeoTestCase {
assertTrue(search.getGeocodes().contains(cache.getGeocode()));
final Geocache searchedCache = search.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
// coords must be null if the user is not logged in
+ assertNotNull(searchedCache);
+ assert (searchedCache != null); // eclipse bug
assertNull(searchedCache.getCoords());
// premium cache. Not visible to guests
diff --git a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
index 43b6d01..53c393b 100644
--- a/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
+++ b/tests/src/cgeo/geocaching/connector/gc/GCParserTest.java
@@ -56,6 +56,8 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
assertNotNull(result);
assertEquals(1, result.getCount());
final Geocache cache = result.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
+ assertNotNull(cache);
+ assert (cache != null); // eclipse bug
assertEquals(cacheName, cache.getName());
}
@@ -158,6 +160,8 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
cache.drop(new Handler());
final String page = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0");
final Geocache cache2 = GCParser.parseCacheFromText(page, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY);
+ assertNotNull(cache2);
+ assert (cache2 != null); // eclipse bug
assertTrue(cache2.hasUserModifiedCoords());
assertEquals(new Geopoint("N51 21.544", "E07 02.566"), cache2.getCoords());
// delete coordinates
@@ -165,6 +169,8 @@ public class GCParserTest extends AbstractResourceInstrumentationTestCase {
cache2.drop(new Handler());
final String page2 = GCParser.requestHtmlPage(cache.getGeocode(), null, "n", "0");
final Geocache cache3 = GCParser.parseCacheFromText(page2, null).getFirstCacheFromResult(LoadFlags.LOAD_CACHE_ONLY);
+ assertNotNull(cache3);
+ assert (cache3 != null); // eclipse bug
assertFalse(cache3.hasUserModifiedCoords());
}
diff --git a/tests/src/cgeo/geocaching/geopoint/ViewportTest.java b/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
index ed90c45..da7d58f 100644
--- a/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
+++ b/tests/src/cgeo/geocaching/geopoint/ViewportTest.java
@@ -2,6 +2,8 @@ package cgeo.geocaching.geopoint;
import cgeo.geocaching.ICoordinates;
+import org.eclipse.jdt.annotation.NonNull;
+
import android.test.AndroidTestCase;
import java.util.Collections;
@@ -11,7 +13,8 @@ import java.util.Set;
public class ViewportTest extends AndroidTestCase {
- final private static Viewport vpRef = new Viewport(new Geopoint(-1.0, -2.0), new Geopoint(3.0, 4.0));
+ final private static @NonNull
+ Viewport vpRef = new Viewport(new Geopoint(-1.0, -2.0), new Geopoint(3.0, 4.0));
public static void assertBounds(final Viewport vp) {
assertEquals(new Geopoint(1.0, 1.0), vp.center);
diff --git a/tests/src/cgeo/geocaching/network/OAuthTest.java b/tests/src/cgeo/geocaching/network/OAuthTest.java
index fa0104f..6888cec 100644
--- a/tests/src/cgeo/geocaching/network/OAuthTest.java
+++ b/tests/src/cgeo/geocaching/network/OAuthTest.java
@@ -1,5 +1,7 @@
package cgeo.geocaching.network;
+import org.eclipse.jdt.annotation.NonNull;
+
import java.util.ArrayList;
import java.util.List;
@@ -26,7 +28,8 @@ public class OAuthTest extends TestCase {
public static void testUnreservedCharactersMustNotBeEncoded() {
for (Character c : UNRESERVED) {
- final String charAsString = String.valueOf(c);
+ final @NonNull
+ String charAsString = String.valueOf(c);
assertEquals("wrong OAuth encoding for " + c, charAsString, OAuth.percentEncode(charAsString));
}
}
@@ -35,7 +38,8 @@ public class OAuthTest extends TestCase {
for (int i = 32; i < 127; i++) {
final Character c = (char) i;
if (!UNRESERVED.contains(c)) {
- final String charAsString = String.valueOf(c);
+ final @NonNull
+ String charAsString = String.valueOf(c);
final String encoded = OAuth.percentEncode(charAsString);
assertFalse("Character '" + charAsString + "' not encoded", charAsString.equals(encoded));
assertTrue(encoded.startsWith("%"));
diff --git a/tests/src/cgeo/test/Compare.java b/tests/src/cgeo/test/Compare.java
index 4a296bd..2ce8d49 100644
--- a/tests/src/cgeo/test/Compare.java
+++ b/tests/src/cgeo/test/Compare.java
@@ -11,6 +11,8 @@ import cgeo.geocaching.utils.CryptUtils;
import org.apache.commons.lang3.StringUtils;
+import java.util.Date;
+
public abstract class Compare {
public static void assertCompareCaches(ICache expected, Geocache actual, boolean all) {
@@ -27,7 +29,9 @@ public abstract class Compare {
assertEquals("Cache " + geocode + ": name wrong", expected.getName(), actual.getName());
assertEquals("Cache " + geocode + ": guid wrong", expected.getGuid(), actual.getGuid());
assertTrue("Cache " + geocode + ": fav points wrong", expected.getFavoritePoints() <= actual.getFavoritePoints());
- assertEquals("Cache " + geocode + ": hidden date wrong", expected.getHiddenDate().toString(), actual.getHiddenDate().toString());
+ final Date hiddenDate = actual.getHiddenDate();
+ assertNotNull(hiddenDate);
+ assertEquals("Cache " + geocode + ": hidden date wrong", expected.getHiddenDate().toString(), hiddenDate.toString());
assertEquals("Cache " + geocode + ": premium only wrong", expected.isPremiumMembersOnly(), actual.isPremiumMembersOnly());
if (all) {