[josm] 01/04: Imported Upstream version 0.0.svn9229+dfsg

Sebastiaan Couwenberg sebastic at moszumanska.debian.org
Thu Dec 31 17:42:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

sebastic pushed a commit to branch master
in repository josm.

commit 9f1f6c49da3200ab552a7c3c9861584ebd8bc137
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Thu Dec 31 18:21:33 2015 +0100

    Imported Upstream version 0.0.svn9229+dfsg
---
 REVISION                                           |  6 +--
 .../josm/actions/DistributeAction.java             |  4 +-
 .../josm/data/cache/JCSCachedTileLoaderJob.java    | 12 +++---
 .../josm/gui/oauth/OsmLoginFailedException.java    | 24 +++++------
 .../gui/oauth/OsmOAuthAuthorizationClient.java     | 14 ++-----
 .../gui/oauth/OsmOAuthAuthorizationException.java  | 28 +++++++------
 .../openstreetmap/josm/io/ProgressInputStream.java |  5 ++-
 src/org/openstreetmap/josm/tools/ColorHelper.java  |  5 ++-
 src/org/openstreetmap/josm/tools/HttpClient.java   | 33 +++++++++-------
 .../josm/actions/CombineWayActionTest.java         | 13 ++++++
 .../josm/actions/ExtensionFileFilterTest.java      | 21 ++++++++++
 .../command/conflict/ConflictAddCommandTest.java   | 17 ++++++++
 .../conflict/ConflictResolveCommandTest.java       | 27 +++++++++++++
 .../CoordinateConflictResolveCommandTest.java      | 17 ++++++++
 .../josm/data/oauth/OAuthParametersTest.java       |  2 +
 .../gui/oauth/OsmOAuthAuthorizationClientTest.java | 46 ++++++++++++++++++++++
 .../openstreetmap/josm/tools/ColorHelperTest.java  | 28 +++++++++++++
 17 files changed, 235 insertions(+), 67 deletions(-)

diff --git a/REVISION b/REVISION
index c7f970b..a1a45b4 100644
--- a/REVISION
+++ b/REVISION
@@ -3,7 +3,7 @@
 <entry
    kind="dir"
    path="trunk"
-   revision="9224">
+   revision="9229">
 <url>https://josm.openstreetmap.de/svn/trunk</url>
 <relative-url>^/trunk</relative-url>
 <repository>
@@ -11,9 +11,9 @@
 <uuid>0c6e7542-c601-0410-84e7-c038aed88b3b</uuid>
 </repository>
 <commit
-   revision="9224">
+   revision="9229">
 <author>Don-vip</author>
-<date>2015-12-30T21:58:48.780244Z</date>
+<date>2015-12-31T12:54:58.747487Z</date>
 </commit>
 </entry>
 </info>
diff --git a/src/org/openstreetmap/josm/actions/DistributeAction.java b/src/org/openstreetmap/josm/actions/DistributeAction.java
index 70ecb6e..0a9303a 100644
--- a/src/org/openstreetmap/josm/actions/DistributeAction.java
+++ b/src/org/openstreetmap/josm/actions/DistributeAction.java
@@ -41,9 +41,7 @@ public final class DistributeAction extends JosmAction {
     public DistributeAction() {
         super(tr(ACTION_SHORT_NAME), "distribute",
               tr("Distribute the selected nodes to equal distances along a line."),
-              Shortcut.registerShortcut("tools:distribute",
-                                        tr("Tool: {0}", tr(ACTION_SHORT_NAME)),
-                                        KeyEvent.VK_B, Shortcut.SHIFT),
+              Shortcut.registerShortcut("tools:distribute", tr("Tool: {0}", tr(ACTION_SHORT_NAME)), KeyEvent.VK_B, Shortcut.SHIFT),
               true);
         putValue("help", ht("/Action/DistributeNodes"));
     }
diff --git a/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java b/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
index 386b350..f107e18 100644
--- a/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
+++ b/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
@@ -310,7 +310,7 @@ public abstract class JCSCachedTileLoaderJob<K, V extends CacheEntry> implements
                 return true;
             }
 
-            HttpURLConnection urlConn = getURLConnection(getUrl());
+            HttpURLConnection urlConn = getURLConnection(getUrl(), true);
 
             if (isObjectLoadable()  &&
                     (now - attributes.getLastModification()) <= ABSOLUTE_EXPIRE_TIME_LIMIT) {
@@ -325,7 +325,7 @@ public abstract class JCSCachedTileLoaderJob<K, V extends CacheEntry> implements
             // follow redirects
             for (int i = 0; i < 5; i++) {
                 if (urlConn.getResponseCode() == 302) {
-                    urlConn = getURLConnection(new URL(urlConn.getHeaderField("Location")));
+                    urlConn = getURLConnection(new URL(urlConn.getHeaderField("Location")), true);
                 } else {
                     break;
                 }
@@ -469,7 +469,7 @@ public abstract class JCSCachedTileLoaderJob<K, V extends CacheEntry> implements
         return ret;
     }
 
-    private HttpURLConnection getURLConnection(URL url) throws IOException {
+    private HttpURLConnection getURLConnection(URL url, boolean noCache) throws IOException {
         HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
         urlConn.setRequestProperty("Accept", "text/html, image/png, image/jpeg, image/gif, */*");
         urlConn.setReadTimeout(readTimeout); // 30 seconds read timeout
@@ -480,18 +480,18 @@ public abstract class JCSCachedTileLoaderJob<K, V extends CacheEntry> implements
             }
         }
 
-        if (force) {
+        if (force || noCache) {
             urlConn.setUseCaches(false);
         }
         return urlConn;
     }
 
     private boolean isCacheValidUsingHead() throws IOException {
-        HttpURLConnection urlConn = getURLConnection(getUrl());
+        HttpURLConnection urlConn = getURLConnection(getUrl(), false);
         urlConn.setRequestMethod("HEAD");
         for (int i = 0; i < 5; i++) {
             if (urlConn.getResponseCode() == 302) {
-                urlConn = getURLConnection(new URL(urlConn.getHeaderField("Location")));
+                urlConn = getURLConnection(new URL(urlConn.getHeaderField("Location")), false);
             } else {
                 break;
             }
diff --git a/src/org/openstreetmap/josm/gui/oauth/OsmLoginFailedException.java b/src/org/openstreetmap/josm/gui/oauth/OsmLoginFailedException.java
index 966a3ac..454dde7 100644
--- a/src/org/openstreetmap/josm/gui/oauth/OsmLoginFailedException.java
+++ b/src/org/openstreetmap/josm/gui/oauth/OsmLoginFailedException.java
@@ -1,21 +1,17 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.gui.oauth;
 
+/**
+ * OSM login failure exception.
+ * @since 2746
+ */
 public class OsmLoginFailedException extends OsmOAuthAuthorizationException {
 
-    public OsmLoginFailedException() {
-        super();
-    }
-
-    public OsmLoginFailedException(String arg0, Throwable arg1) {
-        super(arg0, arg1);
-    }
-
-    public OsmLoginFailedException(String arg0) {
-        super(arg0);
-    }
-
-    public OsmLoginFailedException(Throwable arg0) {
-        super(arg0);
+    /**
+     * Constructs a new {@code OsmLoginFailedException} with the specified cause.
+     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
+     */
+    public OsmLoginFailedException(Throwable cause) {
+        super(cause);
     }
 }
diff --git a/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java b/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
index 2d4b2ff..74f26a2 100644
--- a/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
+++ b/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClient.java
@@ -52,16 +52,6 @@ public class OsmOAuthAuthorizationClient {
     }
 
     /**
-     * Creates a new authorisation client with default OAuth parameters
-     *
-     */
-    public OsmOAuthAuthorizationClient() {
-        oauthProviderParameters = OAuthParameters.createDefault(Main.pref.get("osm-server.url"));
-        consumer = oauthProviderParameters.buildConsumer();
-        provider = oauthProviderParameters.buildProvider(consumer);
-    }
-
-    /**
      * Creates a new authorisation client with the parameters <code>parameters</code>.
      *
      * @param parameters the OAuth parameters. Must not be null.
@@ -240,7 +230,7 @@ public class OsmOAuthAuthorizationClient {
         return null;
     }
 
-    protected String buildPostRequest(Map<String, String> parameters) throws OsmOAuthAuthorizationException {
+    protected static String buildPostRequest(Map<String, String> parameters) {
         StringBuilder sb = new StringBuilder(32);
 
         for (Iterator<Entry<String, String>> it = parameters.entrySet().iterator(); it.hasNext();) {
@@ -321,6 +311,8 @@ public class OsmOAuthAuthorizationClient {
     /**
      * Submits a request to the OSM website for a OAuth form. The OSM website replies a session token in
      * a hidden parameter.
+     * @param sessionId session id
+     * @param requestToken request token
      *
      * @throws OsmOAuthAuthorizationException if something went wrong
      */
diff --git a/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationException.java b/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationException.java
index aee39f3..a80c39b 100644
--- a/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationException.java
+++ b/src/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationException.java
@@ -1,21 +1,25 @@
 // License: GPL. For details, see LICENSE file.
 package org.openstreetmap.josm.gui.oauth;
 
+/**
+ * OSM OAuth authorization exception.
+ * @since 2746
+ */
 public class OsmOAuthAuthorizationException extends Exception {
 
-    public OsmOAuthAuthorizationException() {
-        super();
+    /**
+     * Constructs a new {@code OsmLoginFailedException} with the specified detail message.
+     * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
+     */
+    public OsmOAuthAuthorizationException(String message) {
+        super(message);
     }
 
-    public OsmOAuthAuthorizationException(String arg0, Throwable arg1) {
-        super(arg0, arg1);
-    }
-
-    public OsmOAuthAuthorizationException(String arg0) {
-        super(arg0);
-    }
-
-    public OsmOAuthAuthorizationException(Throwable arg0) {
-        super(arg0);
+    /**
+     * Constructs a new {@code OsmLoginFailedException} with the specified cause.
+     * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
+     */
+    public OsmOAuthAuthorizationException(Throwable cause) {
+        super(cause);
     }
 }
diff --git a/src/org/openstreetmap/josm/io/ProgressInputStream.java b/src/org/openstreetmap/josm/io/ProgressInputStream.java
index 4113e2a..0312053 100644
--- a/src/org/openstreetmap/josm/io/ProgressInputStream.java
+++ b/src/org/openstreetmap/josm/io/ProgressInputStream.java
@@ -9,6 +9,7 @@ import java.net.URLConnection;
 
 import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
 import org.openstreetmap.josm.gui.progress.ProgressMonitor;
+import org.openstreetmap.josm.tools.CheckParameterUtil;
 
 /**
  * Read from an other reader and increment an progress counter while on the way.
@@ -22,12 +23,13 @@ public class ProgressInputStream extends InputStream {
     /**
      * Constructs a new {@code ProgressInputStream}.
      *
-     * @param in the stream to monitor
+     * @param in the stream to monitor. Must not be null
      * @param size the total size which will be sent
      * @param progressMonitor the monitor to report to
      * @since 9172
      */
     public ProgressInputStream(InputStream in, long size, ProgressMonitor progressMonitor) {
+        CheckParameterUtil.ensureParameterNotNull(in, "in");
         if (progressMonitor == null) {
             progressMonitor = NullProgressMonitor.INSTANCE;
         }
@@ -42,6 +44,7 @@ public class ProgressInputStream extends InputStream {
      *
      * @param con the connection to monitor
      * @param progressMonitor the monitor to report to
+     * @throws OsmTransferException if any I/O error occurs
      */
     public ProgressInputStream(URLConnection con, ProgressMonitor progressMonitor) throws OsmTransferException {
         if (progressMonitor == null) {
diff --git a/src/org/openstreetmap/josm/tools/ColorHelper.java b/src/org/openstreetmap/josm/tools/ColorHelper.java
index 547b131..ac824a4 100644
--- a/src/org/openstreetmap/josm/tools/ColorHelper.java
+++ b/src/org/openstreetmap/josm/tools/ColorHelper.java
@@ -81,7 +81,8 @@ public final class ColorHelper {
      */
     public static Color getForegroundColor(Color bg) {
         // http://stackoverflow.com/a/3943023/2257172
-        return (bg.getRed()*0.299 + bg.getGreen()*0.587 + bg.getBlue()*0.114) > 186 ?
-                Color.BLACK : Color.WHITE;
+        return bg == null ? null :
+              (bg.getRed()*0.299 + bg.getGreen()*0.587 + bg.getBlue()*0.114) > 186 ?
+                  Color.BLACK : Color.WHITE;
     }
 }
diff --git a/src/org/openstreetmap/josm/tools/HttpClient.java b/src/org/openstreetmap/josm/tools/HttpClient.java
index 8339289..c9008e6 100644
--- a/src/org/openstreetmap/josm/tools/HttpClient.java
+++ b/src/org/openstreetmap/josm/tools/HttpClient.java
@@ -230,6 +230,7 @@ public final class HttpClient {
          * @see HttpURLConnection#getInputStream()
          * @see HttpURLConnection#getErrorStream()
          */
+        @SuppressWarnings("resource")
         public InputStream getContent() throws IOException {
             InputStream in;
             try {
@@ -237,23 +238,25 @@ public final class HttpClient {
             } catch (IOException ioe) {
                 in = connection.getErrorStream();
             }
-            in = new ProgressInputStream(in, getContentLength(), monitor);
-            in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in;
-            Compression compression = Compression.NONE;
-            if (uncompress) {
-                final String contentType = getContentType();
-                Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType);
-                compression = Compression.forContentType(contentType);
-            }
-            if (uncompressAccordingToContentDisposition && Compression.NONE.equals(compression)) {
-                final String contentDisposition = getHeaderField("Content-Disposition");
-                final Matcher matcher = Pattern.compile("filename=\"([^\"]+)\"").matcher(contentDisposition);
-                if (matcher.find()) {
-                    Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition);
-                    compression = Compression.byExtension(matcher.group(1));
+            if (in != null) {
+                in = new ProgressInputStream(in, getContentLength(), monitor);
+                in = "gzip".equalsIgnoreCase(getContentEncoding()) ? new GZIPInputStream(in) : in;
+                Compression compression = Compression.NONE;
+                if (uncompress) {
+                    final String contentType = getContentType();
+                    Main.debug("Uncompressing input stream according to Content-Type header: {0}", contentType);
+                    compression = Compression.forContentType(contentType);
+                }
+                if (uncompressAccordingToContentDisposition && Compression.NONE.equals(compression)) {
+                    final String contentDisposition = getHeaderField("Content-Disposition");
+                    final Matcher matcher = Pattern.compile("filename=\"([^\"]+)\"").matcher(contentDisposition);
+                    if (matcher.find()) {
+                        Main.debug("Uncompressing input stream according to Content-Disposition header: {0}", contentDisposition);
+                        compression = Compression.byExtension(matcher.group(1));
+                    }
                 }
+                in = compression.getUncompressedInputStream(in);
             }
-            in = compression.getUncompressedInputStream(in);
             return in;
         }
 
diff --git a/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java
index 1e5b391..dac803d 100644
--- a/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java
+++ b/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java
@@ -10,11 +10,14 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import nl.jqno.equalsverifier.EqualsVerifier;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.openstreetmap.josm.JOSMFixture;
 import org.openstreetmap.josm.TestUtils;
 import org.openstreetmap.josm.actions.CombineWayAction.NodeGraph;
+import org.openstreetmap.josm.actions.CombineWayAction.NodePair;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
 import org.openstreetmap.josm.io.IllegalDataException;
@@ -54,4 +57,14 @@ public class CombineWayActionTest {
             assertEquals(firstAndLastExpected, firstAndLastObtained);
         }
     }
+
+    /**
+     * Unit test of methods {@link NodePair#equals} and {@link NodePair#hashCode}.
+     */
+    @Test
+    public void equalsContract() {
+        EqualsVerifier.forClass(NodePair.class).usingGetClass()
+            .withPrefabValues(Node.class, new Node(1), new Node(2))
+            .verify();
+    }
 }
diff --git a/test/unit/org/openstreetmap/josm/actions/ExtensionFileFilterTest.java b/test/unit/org/openstreetmap/josm/actions/ExtensionFileFilterTest.java
new file mode 100644
index 0000000..19a4b9b
--- /dev/null
+++ b/test/unit/org/openstreetmap/josm/actions/ExtensionFileFilterTest.java
@@ -0,0 +1,21 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+
+import org.junit.Test;
+
+/**
+ * Unit tests for class {@link ExtensionFileFilter}.
+ */
+public class ExtensionFileFilterTest {
+
+    /**
+     * Unit test of methods {@link ExtensionFileFilter#equals} and {@link ExtensionFileFilter#hashCode}.
+     */
+    @Test
+    public void equalsContract() {
+        EqualsVerifier.forClass(ExtensionFileFilter.class).usingGetClass()
+            .verify();
+    }
+}
diff --git a/test/unit/org/openstreetmap/josm/command/conflict/ConflictAddCommandTest.java b/test/unit/org/openstreetmap/josm/command/conflict/ConflictAddCommandTest.java
index 10c7ce9..b4d0e6e 100644
--- a/test/unit/org/openstreetmap/josm/command/conflict/ConflictAddCommandTest.java
+++ b/test/unit/org/openstreetmap/josm/command/conflict/ConflictAddCommandTest.java
@@ -4,6 +4,8 @@ package org.openstreetmap.josm.command.conflict;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import nl.jqno.equalsverifier.EqualsVerifier;
+import nl.jqno.equalsverifier.Warning;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -12,6 +14,7 @@ import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
 /**
@@ -53,4 +56,18 @@ public class ConflictAddCommandTest {
         Conflict<Node> conflict = new Conflict<>(new Node(), new Node());
         assertNotNull(new ConflictAddCommand(layer, conflict).getDescriptionIcon());
     }
+
+    /**
+     * Unit test of methods {@link ConflictAddCommand#equals} and {@link ConflictAddCommand#hashCode}.
+     */
+    @Test
+    public void equalsContract() {
+        EqualsVerifier.forClass(ConflictAddCommand.class).usingGetClass()
+            .withPrefabValues(Conflict.class,
+                    new Conflict<>(new Node(), new Node()), new Conflict<>(new Way(), new Way()))
+            .withPrefabValues(OsmDataLayer.class,
+                    new OsmDataLayer(new DataSet(), "1", null), new OsmDataLayer(new DataSet(), "2", null))
+            .suppress(Warning.NONFINAL_FIELDS)
+            .verify();
+    }
 }
diff --git a/test/unit/org/openstreetmap/josm/command/conflict/ConflictResolveCommandTest.java b/test/unit/org/openstreetmap/josm/command/conflict/ConflictResolveCommandTest.java
new file mode 100644
index 0000000..e9abf56
--- /dev/null
+++ b/test/unit/org/openstreetmap/josm/command/conflict/ConflictResolveCommandTest.java
@@ -0,0 +1,27 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.command.conflict;
+
+import nl.jqno.equalsverifier.EqualsVerifier;
+import nl.jqno.equalsverifier.Warning;
+
+import org.junit.Test;
+import org.openstreetmap.josm.data.osm.DataSet;
+import org.openstreetmap.josm.gui.layer.OsmDataLayer;
+
+/**
+ * Unit tests of {@link ConflictResolveCommand} class.
+ */
+public class ConflictResolveCommandTest {
+
+    /**
+     * Unit test of methods {@link ConflictResolveCommand#equals} and {@link ConflictResolveCommand#hashCode}.
+     */
+    @Test
+    public void equalsContract() {
+        EqualsVerifier.forClass(ConflictResolveCommand.class).usingGetClass()
+            .withPrefabValues(OsmDataLayer.class,
+                    new OsmDataLayer(new DataSet(), "1", null), new OsmDataLayer(new DataSet(), "2", null))
+            .suppress(Warning.NONFINAL_FIELDS)
+            .verify();
+    }
+}
diff --git a/test/unit/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommandTest.java b/test/unit/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommandTest.java
index 98ecc1b..f1af386 100644
--- a/test/unit/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommandTest.java
+++ b/test/unit/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommandTest.java
@@ -4,6 +4,8 @@ package org.openstreetmap.josm.command.conflict;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
+import nl.jqno.equalsverifier.EqualsVerifier;
+import nl.jqno.equalsverifier.Warning;
 
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -13,6 +15,7 @@ import org.openstreetmap.josm.data.conflict.Conflict;
 import org.openstreetmap.josm.data.coor.LatLon;
 import org.openstreetmap.josm.data.osm.DataSet;
 import org.openstreetmap.josm.data.osm.Node;
+import org.openstreetmap.josm.data.osm.Way;
 import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
 
@@ -68,4 +71,18 @@ public class CoordinateConflictResolveCommandTest {
         Conflict<Node> conflict = createConflict();
         assertNotNull(new CoordinateConflictResolveCommand(conflict, null).getDescriptionIcon());
     }
+
+    /**
+     * Unit test of methods {@link CoordinateConflictResolveCommand#equals} and {@link CoordinateConflictResolveCommand#hashCode}.
+     */
+    @Test
+    public void equalsContract() {
+        EqualsVerifier.forClass(CoordinateConflictResolveCommand.class).usingGetClass()
+            .withPrefabValues(Conflict.class,
+                    new Conflict<>(new Node(), new Node()), new Conflict<>(new Way(), new Way()))
+            .withPrefabValues(OsmDataLayer.class,
+                    new OsmDataLayer(new DataSet(), "1", null), new OsmDataLayer(new DataSet(), "2", null))
+            .suppress(Warning.NONFINAL_FIELDS)
+            .verify();
+    }
 }
diff --git a/test/unit/org/openstreetmap/josm/data/oauth/OAuthParametersTest.java b/test/unit/org/openstreetmap/josm/data/oauth/OAuthParametersTest.java
index a681291..8418a31 100644
--- a/test/unit/org/openstreetmap/josm/data/oauth/OAuthParametersTest.java
+++ b/test/unit/org/openstreetmap/josm/data/oauth/OAuthParametersTest.java
@@ -28,6 +28,8 @@ public class OAuthParametersTest {
         assertNotEquals(def, dev);
         Main.logLevel = 5; // enable trace for line coverage
         assertEquals(def, OAuthParameters.createDefault("wrong_url"));
+        OAuthParameters dev2 = new OAuthParameters(dev);
+        assertEquals(dev, dev2);
     }
 
     /**
diff --git a/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java b/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java
new file mode 100644
index 0000000..8868ecf
--- /dev/null
+++ b/test/unit/org/openstreetmap/josm/gui/oauth/OsmOAuthAuthorizationClientTest.java
@@ -0,0 +1,46 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.oauth;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openstreetmap.josm.JOSMFixture;
+import org.openstreetmap.josm.data.oauth.OAuthParameters;
+import org.openstreetmap.josm.data.oauth.OAuthToken;
+import org.openstreetmap.josm.io.OsmTransferCanceledException;
+
+/**
+ * Unit tests of {@link OsmOAuthAuthorizationClient} class.
+ */
+public class OsmOAuthAuthorizationClientTest {
+
+    /**
+     * Setup tests
+     */
+    @BeforeClass
+    public static void setUpBeforeClass() {
+        JOSMFixture.createUnitTestFixture().init();
+    }
+
+    /**
+     * Unit test of {@link OsmOAuthAuthorizationClient}.
+     * @throws OsmOAuthAuthorizationException if OAuth authorization error occurs
+     * @throws OsmTransferCanceledException  if OSM transfer error occurs
+     * @throws MalformedURLException in case of invalid URL
+     */
+    @Test
+    public void testOsmOAuthAuthorizationClient() throws OsmTransferCanceledException, OsmOAuthAuthorizationException, MalformedURLException {
+        OsmOAuthAuthorizationClient client = new OsmOAuthAuthorizationClient(OAuthParameters.createDefault());
+        OAuthToken requestToken = client.getRequestToken(null);
+        assertNotNull(requestToken);
+        String url = client.getAuthoriseUrl(requestToken);
+        assertNotNull(url);
+        System.out.println(new URL(url));
+        //OAuthToken accessToken = client.getAccessToken(null);
+        //assertNotNull(accessToken);
+    }
+}
diff --git a/test/unit/org/openstreetmap/josm/tools/ColorHelperTest.java b/test/unit/org/openstreetmap/josm/tools/ColorHelperTest.java
new file mode 100644
index 0000000..bc4c939
--- /dev/null
+++ b/test/unit/org/openstreetmap/josm/tools/ColorHelperTest.java
@@ -0,0 +1,28 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.tools;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import java.awt.Color;
+
+import org.junit.Test;
+
+/**
+ * Unit tests for class {@link ColorHelper}.
+ */
+public class ColorHelperTest {
+
+    /**
+     * Unit test of method {@link ColorHelper#getForegroundColor}.
+     */
+    @Test
+    public void testGetForegroundColor() {
+        assertNull(ColorHelper.getForegroundColor(null));
+        assertEquals(Color.WHITE, ColorHelper.getForegroundColor(Color.BLACK));
+        assertEquals(Color.WHITE, ColorHelper.getForegroundColor(Color.DARK_GRAY));
+        assertEquals(Color.BLACK, ColorHelper.getForegroundColor(Color.LIGHT_GRAY));
+        assertEquals(Color.BLACK, ColorHelper.getForegroundColor(Color.YELLOW));
+        assertEquals(Color.BLACK, ColorHelper.getForegroundColor(Color.WHITE));
+    }
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/josm.git



More information about the Pkg-grass-devel mailing list