Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Keppler2019-10-27 07:39:58 +0000
committerMichael Keppler2019-11-13 08:11:59 +0000
commited7a20c1d1c35806ec94f8a11b9587ff3481783e (patch)
tree17211bb2daa543a22a287b109d2270ae4c7faf2e
parent4d9e3d26d7c6ebe30afed2540cc8d8da8a356279 (diff)
downloadegit-github-ed7a20c1d1c35806ec94f8a11b9587ff3481783e.tar.gz
egit-github-ed7a20c1d1c35806ec94f8a11b9587ff3481783e.tar.xz
egit-github-ed7a20c1d1c35806ec94f8a11b9587ff3481783e.zip
Forbid instantiation of utility classes
The github repo uses abstract utility classes, and actually instantiates anonymous sub classes during tests. Forbid instantiation by using final classes with private constructor. Change-Id: I5a7d6b30bc690829be728c15ea885416bde1a0f0 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java2
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DateUtilsTest.java (renamed from org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DateUtilTest.java)12
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EncodingUtilsTest.java9
-rw-r--r--org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/UrlUtilsTest.java15
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/DateUtils.java6
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/EncodingUtils.java6
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/MultiPartUtils.java6
-rw-r--r--org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/UrlUtils.java6
8 files changed, 25 insertions, 37 deletions
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
index 0df5e00e..76ba02d5 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/AllHeadlessTests.java
@@ -40,7 +40,7 @@ import org.junit.runners.Suite.SuiteClasses;
CreatePayloadTest.class, //
DataServiceTest.class, //
DateFormatterTest.class, //
- DateUtilTest.class, //
+ DateUtilsTest.class, //
DeletePayloadTest.class, //
DeployKeyServiceTest.class, //
DownloadPayloadTest.class, //
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DateUtilTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DateUtilsTest.java
index 1a94b979..cee15883 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DateUtilTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/DateUtilsTest.java
@@ -13,7 +13,6 @@
package org.eclipse.egit.github.core.tests;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
@@ -25,16 +24,7 @@ import org.junit.Test;
/**
* Unit tests of {@link DateUtils}
*/
-public class DateUtilTest {
-
- /**
- * Test default constructor through anonymous sub-class
- */
- @Test
- public void constructor() {
- assertNotNull(new DateUtils() {
- });
- }
+public class DateUtilsTest {
/**
* Test cloning date
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EncodingUtilsTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EncodingUtilsTest.java
index 47e99ecc..a3d88d64 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EncodingUtilsTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/EncodingUtilsTest.java
@@ -25,15 +25,6 @@ import org.junit.Test;
public class EncodingUtilsTest {
/**
- * Test default constructor through anonymous sub-class
- */
- @Test
- public void constructor() {
- assertNotNull(new EncodingUtils() {
- });
- }
-
- /**
* Encode and decode content
*/
@Test
diff --git a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/UrlUtilsTest.java b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/UrlUtilsTest.java
index b82ed618..d7dbe202 100644
--- a/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/UrlUtilsTest.java
+++ b/org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/UrlUtilsTest.java
@@ -25,15 +25,6 @@ import org.junit.Test;
public class UrlUtilsTest {
/**
- * Test default constructor through anonymous sub-class
- */
- @Test
- public void constructor() {
- assertNotNull(new UrlUtils() {
- });
- }
-
- /**
* Encode url
*/
@Test
@@ -48,7 +39,7 @@ public class UrlUtilsTest {
* Verify generation of HTTPS URL
*/
@Test
- public void gererateHttpsUrl() {
+ public void generateHttpsUrl() {
RepositoryId repo = new RepositoryId("person", "project");
assertEquals("https://me@github.com/person/project.git",
UrlUtils.createRemoteHttpsUrl(repo, "me"));
@@ -58,7 +49,7 @@ public class UrlUtilsTest {
* Verify generation of SSH URL
*/
@Test
- public void gererateSshUrl() {
+ public void generateSshUrl() {
RepositoryId repo = new RepositoryId("person", "project");
assertEquals("git@github.com:person/project.git",
UrlUtils.createRemoteSshUrl(repo));
@@ -68,7 +59,7 @@ public class UrlUtilsTest {
* Verify generation of read only URL
*/
@Test
- public void gererateReadOnlyUrl() {
+ public void generateReadOnlyUrl() {
RepositoryId repo = new RepositoryId("person", "project");
assertEquals("git://github.com/person/project.git",
UrlUtils.createRemoteReadOnlyUrl(repo));
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/DateUtils.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/DateUtils.java
index 5c41ce0a..c4fa28ec 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/DateUtils.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/DateUtils.java
@@ -17,7 +17,11 @@ import java.util.Date;
/**
* Date utilities
*/
-public abstract class DateUtils {
+public final class DateUtils {
+
+ private DateUtils() {
+ // utility class
+ }
/**
* Clone date if non-null
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/EncodingUtils.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/EncodingUtils.java
index b6417d5f..8e34ea28 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/EncodingUtils.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/EncodingUtils.java
@@ -19,7 +19,11 @@ import java.io.UnsupportedEncodingException;
/**
* Encoding utilities
*/
-public abstract class EncodingUtils {
+public final class EncodingUtils {
+
+ private EncodingUtils() {
+ // utility class
+ }
/**
* Decode base64 encoded string
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/MultiPartUtils.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/MultiPartUtils.java
index 1ad0c054..a9cfb377 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/MultiPartUtils.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/MultiPartUtils.java
@@ -25,7 +25,11 @@ import java.util.Map.Entry;
/**
* Utilities for writing multiple HTTP requests
*/
-public class MultiPartUtils {
+public final class MultiPartUtils {
+
+ private MultiPartUtils() {
+ // utility class
+ }
/**
* Post parts to URL
diff --git a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/UrlUtils.java b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/UrlUtils.java
index 73446de1..64f70c5b 100644
--- a/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/UrlUtils.java
+++ b/org.eclipse.egit.github.core/src/org/eclipse/egit/github/core/util/UrlUtils.java
@@ -28,7 +28,11 @@ import org.eclipse.egit.github.core.IRepositoryIdProvider;
/**
* URL utilities
*/
-public abstract class UrlUtils {
+public final class UrlUtils {
+
+ private UrlUtils() {
+ // utility class
+ }
/**
* Create SSH URL used for repository remote configs

Back to the top