You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by kr...@apache.org on 2018/11/26 21:46:19 UTC
knox git commit: KNOX-1627 - Simplify junit assertions
Repository: knox
Updated Branches:
refs/heads/master 8e51af317 -> a60b03296
KNOX-1627 - Simplify junit assertions
Signed-off-by: Kevin Risden <kr...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/a60b0329
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/a60b0329
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/a60b0329
Branch: refs/heads/master
Commit: a60b032963a8aa664981d1f0a502523a8d33376b
Parents: 8e51af3
Author: Kevin Risden <kr...@apache.org>
Authored: Mon Nov 26 16:21:29 2018 -0500
Committer: Kevin Risden <kr...@apache.org>
Committed: Mon Nov 26 16:21:39 2018 -0500
----------------------------------------------------------------------
.../gateway/shirorealm/KnoxPamRealmTest.java | 4 +-
.../gateway/filter/AclsAuthzFilterTest.java | 18 +--
.../gateway/shirorealm/KnoxPamRealmTest.java | 4 +-
.../webappsec/StrictTransportFilterTest.java | 12 +-
.../webappsec/XFrameOptionsFilterTest.java | 12 +-
.../knox/gateway/GatewayGlobalConfigTest.java | 2 +-
.../services/security/CryptoServiceTest.java | 3 +-
.../apache/knox/gateway/util/KnoxCLITest.java | 2 +-
...moteConfigurationRegistryJAASConfigTest.java | 2 +-
.../security/principal/PrincipalMapperTest.java | 127 ++++++++++---------
.../security/impl/CMFKeystoreServiceTest.java | 3 +-
.../security/impl/CMFMasterServiceTest.java | 3 +-
.../security/token/impl/JWTTokenTest.java | 2 +-
.../knox/gateway/topology/VersionTest.java | 3 +-
.../knox/gateway/util/WhitelistUtilsTest.java | 2 +-
.../org/apache/knox/gateway/util/UrlsTest.java | 18 +--
16 files changed, 110 insertions(+), 107 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java
----------------------------------------------------------------------
diff --git a/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java b/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java
index e03051f..1a32ef3 100644
--- a/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java
+++ b/gateway-adapter/src/test/java/org/apache/hadoop/gateway/shirorealm/KnoxPamRealmTest.java
@@ -27,7 +27,7 @@ import org.apache.shiro.authc.UsernamePasswordToken;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
public class KnoxPamRealmTest {
@@ -60,7 +60,7 @@ public class KnoxPamRealmTest {
AuthenticationInfo authInfo = realm.doGetAuthenticationInfo(authToken);
// verify success
- assertTrue(authInfo.getCredentials() != null);
+ assertNotNull(authInfo.getCredentials());
}
public static void main(String[] args) throws Exception {
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java b/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java
index 78f6f58..eba7877 100644
--- a/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java
+++ b/gateway-provider-security-authz-acls/src/test/java/org/apache/knox/gateway/filter/AclsAuthzFilterTest.java
@@ -17,7 +17,9 @@
*/
package org.apache.knox.gateway.filter;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.PrivilegedActionException;
@@ -119,7 +121,7 @@ public class AclsAuthzFilterTest {
throw new ServletException(t);
}
}
- assertEquals(true, accessGranted);
+ assertTrue(accessGranted);
}
@Test
@@ -176,7 +178,7 @@ public class AclsAuthzFilterTest {
throw new ServletException(t);
}
}
- assertEquals(false, accessGranted);
+ assertFalse(accessGranted);
}
@Test
@@ -233,7 +235,7 @@ public class AclsAuthzFilterTest {
throw new ServletException(t);
}
}
- assertEquals(true, accessGranted);
+ assertTrue(accessGranted);
}
@Test
@@ -290,7 +292,7 @@ public class AclsAuthzFilterTest {
throw new ServletException(t);
}
}
- assertEquals(false, accessGranted);
+ assertFalse(accessGranted);
}
@Test
@@ -347,7 +349,7 @@ public class AclsAuthzFilterTest {
throw new ServletException(t);
}
}
- assertEquals(true, accessGranted);
+ assertTrue(accessGranted);
}
@Test
@@ -404,7 +406,7 @@ public class AclsAuthzFilterTest {
throw new ServletException(t);
}
}
- assertEquals(true, accessGranted);
+ assertTrue(accessGranted);
}
@Test
@@ -461,6 +463,6 @@ public class AclsAuthzFilterTest {
throw new ServletException(t);
}
}
- assertEquals(true, accessGranted);
+ assertTrue(accessGranted);
}
}
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-provider-security-shiro/src/test/java/org/apache/knox/gateway/shirorealm/KnoxPamRealmTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-shiro/src/test/java/org/apache/knox/gateway/shirorealm/KnoxPamRealmTest.java b/gateway-provider-security-shiro/src/test/java/org/apache/knox/gateway/shirorealm/KnoxPamRealmTest.java
index 3cf317a..deca48c 100644
--- a/gateway-provider-security-shiro/src/test/java/org/apache/knox/gateway/shirorealm/KnoxPamRealmTest.java
+++ b/gateway-provider-security-shiro/src/test/java/org/apache/knox/gateway/shirorealm/KnoxPamRealmTest.java
@@ -26,7 +26,7 @@ import org.junit.Test;
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.replay;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
public class KnoxPamRealmTest {
@@ -59,7 +59,7 @@ public class KnoxPamRealmTest {
AuthenticationInfo authInfo = realm.doGetAuthenticationInfo(authToken);
// verify success
- assertTrue(authInfo.getCredentials() != null);
+ assertNotNull(authInfo.getCredentials());
}
public static void main(String[] args) throws Exception {
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java
index 1217405..675d19b 100644
--- a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java
+++ b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/StrictTransportFilterTest.java
@@ -62,10 +62,10 @@ public class StrictTransportFilterTest {
filter.doFilter(request, response, chain);
Assert.assertTrue("doFilterCalled should not be false.",
chain.doFilterCalled );
- Assert.assertTrue("Options value incorrect should be max-age=31536000 but is: "
- + options, "max-age=31536000".equals(options));
+ Assert.assertEquals("Options value incorrect should be max-age=31536000 but is: "
+ + options, "max-age=31536000", options);
- Assert.assertTrue("Strict-Transport-Security count not equal to 1.", headers.size() == 1);
+ Assert.assertEquals("Strict-Transport-Security count not equal to 1.", 1, headers.size());
} catch (ServletException se) {
fail("Should NOT have thrown a ServletException.");
}
@@ -91,10 +91,10 @@ public class StrictTransportFilterTest {
filter.doFilter(request, response, chain);
Assert.assertTrue("doFilterCalled should not be false.",
chain.doFilterCalled );
- Assert.assertTrue("Options value incorrect should be max-age=31536010; includeSubDomains but is: "
- + options, "max-age=31536010; includeSubDomains".equals(options));
+ Assert.assertEquals("Options value incorrect should be max-age=31536010; includeSubDomains but is: "
+ + options, "max-age=31536010; includeSubDomains", options);
- Assert.assertTrue("Strict-Transport-Security count not equal to 1.", headers.size() == 1);
+ Assert.assertEquals("Strict-Transport-Security count not equal to 1.", 1, headers.size());
} catch (ServletException se) {
fail("Should NOT have thrown a ServletException.");
}
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java
index 252e1ca..3b9ca7d 100644
--- a/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java
+++ b/gateway-provider-security-webappsec/src/test/java/org/apache/knox/gateway/webappsec/XFrameOptionsFilterTest.java
@@ -65,10 +65,10 @@ public class XFrameOptionsFilterTest {
filter.doFilter(request, response, chain);
Assert.assertTrue("doFilterCalled should not be false.",
chain.doFilterCalled );
- Assert.assertTrue("Options value incorrect should be DENY but is: "
- + options, "DENY".equals(options));
+ Assert.assertEquals("Options value incorrect should be DENY but is: "
+ + options, "DENY", options);
- Assert.assertTrue("X-Frame-Options count not equal to 1.", headers.size() == 1);
+ Assert.assertEquals("X-Frame-Options count not equal to 1.", 1, headers.size());
} catch (ServletException se) {
fail("Should NOT have thrown a ServletException.");
}
@@ -94,10 +94,10 @@ public class XFrameOptionsFilterTest {
filter.doFilter(request, response, chain);
Assert.assertTrue("doFilterCalled should not be false.",
chain.doFilterCalled );
- Assert.assertTrue("Options value incorrect should be SAMEORIGIN but is: "
- + options, "SAMEORIGIN".equals(options));
+ Assert.assertEquals("Options value incorrect should be SAMEORIGIN but is: "
+ + options, "SAMEORIGIN", options);
- Assert.assertTrue("X-Frame-Options count not equal to 1.", headers.size() == 1);
+ Assert.assertEquals("X-Frame-Options count not equal to 1.", 1, headers.size());
} catch (ServletException se) {
fail("Should NOT have thrown a ServletException.");
}
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-server/src/test/java/org/apache/knox/gateway/GatewayGlobalConfigTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/GatewayGlobalConfigTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/GatewayGlobalConfigTest.java
index 62891a2..24b2755 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/GatewayGlobalConfigTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/GatewayGlobalConfigTest.java
@@ -58,7 +58,7 @@ public class GatewayGlobalConfigTest {
System.setProperty( GatewayConfigImpl.GATEWAY_HOME_VAR, getHomeDirName( "conf-demo/conf/gateway-default.xml" ) );
GatewayConfig config = new GatewayConfigImpl();
assertThat(config.getGatewayPort(), is( 8888 ) );
- assertTrue( config.getExcludedSSLProtocols().get(0).equals("SSLv3"));
+ assertEquals("SSLv3", config.getExcludedSSLProtocols().get(0));
//assertThat( config.getShiroConfigFile(), is( "full-shiro.ini") );
}
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java
index 141c7d2..4d8511d 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/services/security/CryptoServiceTest.java
@@ -34,7 +34,6 @@ import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
@Category( { ManualTests.class, MediumTests.class } )
public class CryptoServiceTest {
@@ -201,7 +200,7 @@ public class CryptoServiceTest {
String queryString = "url=http://localhost:50070/api/v1/blahblah";
EncryptionResult result = cs.encryptForCluster("Test", alias, queryString.getBytes("UTF8"));
- assertTrue("Resulted cipertext length should be a multiple of 16", (result.cipher.length % 16) == 0);
+ assertEquals("Resulted cipertext length should be a multiple of 16", 0, (result.cipher.length % 16));
byte[] decryptedQueryString = cs.decryptForCluster("Test", alias, result.cipher, result.iv, result.salt);
assertEquals(queryString.getBytes("UTF8").length, decryptedQueryString.length);
}
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java b/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java
index c4b47e7..e40125e 100644
--- a/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java
+++ b/gateway-server/src/test/java/org/apache/knox/gateway/util/KnoxCLITest.java
@@ -754,7 +754,7 @@ public class KnoxCLITest {
assertEquals(0, rc);
MasterService ms = cli.getGatewayServices().getService("MasterService");
// assertTrue(ms.getClass().getName(), ms.getClass().getName().equals("kjdfhgjkhfdgjkh"));
- assertTrue( new String( ms.getMasterSecret() ), "master".equals( new String( ms.getMasterSecret() ) ) );
+ assertEquals(new String(ms.getMasterSecret()), "master", new String(ms.getMasterSecret()));
assertTrue(outContent.toString(StandardCharsets.UTF_8.name()), outContent.toString(StandardCharsets.UTF_8.name()).contains("Master secret has been persisted to disk."));
}
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfigTest.java
----------------------------------------------------------------------
diff --git a/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfigTest.java b/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfigTest.java
index e49e342..8ce2eca 100644
--- a/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfigTest.java
+++ b/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryJAASConfigTest.java
@@ -228,7 +228,7 @@ public class RemoteConfigurationRegistryJAASConfigTest {
assertNotNull(myContextEntries);
assertEquals(1, myContextEntries.length);
AppConfigurationEntry entry = myContextEntries[0];
- assertTrue(entry.getLoginModuleName().equals(loginModule));
+ assertEquals(entry.getLoginModuleName(), loginModule);
Map<String, ?> entryOpts = entry.getOptions();
assertEquals(principal, entryOpts.get("username"));
assertEquals(password, entryOpts.get("password"));
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-spi/src/test/java/org/apache/knox/gateway/security/principal/PrincipalMapperTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/security/principal/PrincipalMapperTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/security/principal/PrincipalMapperTest.java
index e9ea34d..a4aed1c 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/security/principal/PrincipalMapperTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/security/principal/PrincipalMapperTest.java
@@ -23,6 +23,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -49,10 +50,10 @@ public class PrincipalMapperTest {
pme.printStackTrace();
fail();
}
-
- assertTrue(mapper.mapUserPrincipal("lmccay").equals("lmccay"));
- assertTrue(mapper.mapGroupPrincipal("hdfs")[0].equals("users"));
- assertTrue(mapper.mapGroupPrincipal("lmccay")[0].equals("users"));
+
+ assertEquals("lmccay", mapper.mapUserPrincipal("lmccay"));
+ assertEquals("users", mapper.mapGroupPrincipal("hdfs")[0]);
+ assertEquals("users", mapper.mapGroupPrincipal("lmccay")[0]);
}
@Test
@@ -66,9 +67,9 @@ public class PrincipalMapperTest {
pme.printStackTrace();
fail();
}
-
- assertTrue(mapper.mapUserPrincipal("lmccay").equals("lmccay"));
- assertTrue(mapper.mapGroupPrincipal("hdfs")[0].equals("users"));
+
+ assertEquals("lmccay", mapper.mapUserPrincipal("lmccay"));
+ assertEquals("users", mapper.mapGroupPrincipal("hdfs")[0]);
String group = mapper.mapGroupPrincipal("lmccay")[0];
assertTrue("users".equals(group) || "mrgroup".equals(group));
group = mapper.mapGroupPrincipal("lmccay")[1];
@@ -86,11 +87,11 @@ public class PrincipalMapperTest {
pme.printStackTrace();
fail();
}
-
- assertTrue(mapper.mapUserPrincipal("guest").equals("lmccay"));
- assertTrue(mapper.mapGroupPrincipal("hdfs").length == 1);
- assertTrue(mapper.mapGroupPrincipal("hdfs")[0].equals("users"));
- assertTrue(mapper.mapGroupPrincipal("lmccay").length == 2);
+
+ assertEquals("lmccay", mapper.mapUserPrincipal("guest"));
+ assertEquals(1, mapper.mapGroupPrincipal("hdfs").length);
+ assertEquals("users", mapper.mapGroupPrincipal("hdfs")[0]);
+ assertEquals(2, mapper.mapGroupPrincipal("lmccay").length);
String group = mapper.mapGroupPrincipal("lmccay")[0];
assertTrue("users".equals(group) || "mrgroup".equals(group));
group = mapper.mapGroupPrincipal("lmccay")[1];
@@ -108,20 +109,20 @@ public class PrincipalMapperTest {
pme.printStackTrace();
fail();
}
-
- assertTrue(mapper.mapUserPrincipal("lmccay").equals("hdfs"));
- assertTrue(mapper.mapGroupPrincipal("hdfs")[0].equals("group1"));
- assertTrue(mapper.mapUserPrincipal("kminder").equals("hdfs"));
-
- assertTrue(mapper.mapUserPrincipal("newuser").equals("mapred"));
- assertTrue(mapper.mapGroupPrincipal("mapred")[0].equals("mrgroup"));
- assertTrue(mapper.mapGroupPrincipal("mapred")[1].equals("mrducks"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("lmccay"));
+ assertEquals("group1", mapper.mapGroupPrincipal("hdfs")[0]);
+
+ assertEquals("hdfs", mapper.mapUserPrincipal("kminder"));
- assertTrue(mapper.mapUserPrincipal("hdfs").equals("hdfs"));
- assertTrue(mapper.mapUserPrincipal("mapred").equals("mapred"));
+ assertEquals("mapred", mapper.mapUserPrincipal("newuser"));
+ assertEquals("mrgroup", mapper.mapGroupPrincipal("mapred")[0]);
+ assertEquals("mrducks", mapper.mapGroupPrincipal("mapred")[1]);
- assertTrue(mapper.mapUserPrincipal("stink").equals("stink"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("hdfs"));
+ assertEquals("mapred", mapper.mapUserPrincipal("mapred"));
+
+ assertEquals("stink", mapper.mapUserPrincipal("stink"));
}
@Test
@@ -134,16 +135,16 @@ public class PrincipalMapperTest {
pme.printStackTrace();
fail();
}
-
- assertTrue(mapper.mapUserPrincipal("lmccay").equals("hdfs"));
- assertTrue(mapper.mapUserPrincipal("kminder").equals("hdfs"));
-
- assertTrue(mapper.mapUserPrincipal("newuser").equals("mapred"));
- assertTrue(mapper.mapUserPrincipal("hdfs").equals("hdfs"));
- assertTrue(mapper.mapUserPrincipal("mapred").equals("mapred"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("lmccay"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("kminder"));
+
+ assertEquals("mapred", mapper.mapUserPrincipal("newuser"));
- assertTrue(mapper.mapUserPrincipal("stink").equals("stink"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("hdfs"));
+ assertEquals("mapred", mapper.mapUserPrincipal("mapred"));
+
+ assertEquals("stink", mapper.mapUserPrincipal("stink"));
}
@Test
@@ -155,16 +156,16 @@ public class PrincipalMapperTest {
catch (PrincipalMappingException pme) {
fail();
}
-
- assertTrue(mapper.mapUserPrincipal("lmccay").equals("hdfs"));
- assertTrue(mapper.mapUserPrincipal("kminder").equals("hdfs"));
-
- assertTrue(mapper.mapUserPrincipal("newuser").equals("mapred"));
- assertTrue(mapper.mapUserPrincipal("hdfs").equals("hdfs"));
- assertTrue(mapper.mapUserPrincipal("mapred").equals("mapred"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("lmccay"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("kminder"));
+
+ assertEquals("mapred", mapper.mapUserPrincipal("newuser"));
- assertTrue(mapper.mapUserPrincipal("stink").equals("stink"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("hdfs"));
+ assertEquals("mapred", mapper.mapUserPrincipal("mapred"));
+
+ assertEquals("stink", mapper.mapUserPrincipal("stink"));
}
@Test
@@ -176,16 +177,16 @@ public class PrincipalMapperTest {
catch (PrincipalMappingException pme) {
fail();
}
-
- assertTrue(mapper.mapUserPrincipal("lmccay").equals("lmccay"));
- assertTrue(mapper.mapUserPrincipal("kminder").equals("kminder"));
-
- assertTrue(mapper.mapUserPrincipal("newuser").equals("newuser"));
- assertTrue(mapper.mapUserPrincipal("hdfs").equals("hdfs"));
- assertTrue(mapper.mapUserPrincipal("mapred").equals("mapred"));
+ assertEquals("lmccay", mapper.mapUserPrincipal("lmccay"));
+ assertEquals("kminder", mapper.mapUserPrincipal("kminder"));
+
+ assertEquals("newuser", mapper.mapUserPrincipal("newuser"));
- assertTrue(mapper.mapUserPrincipal("stink").equals("stink"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("hdfs"));
+ assertEquals("mapred", mapper.mapUserPrincipal("mapred"));
+
+ assertEquals("stink", mapper.mapUserPrincipal("stink"));
}
@Test
@@ -197,16 +198,16 @@ public class PrincipalMapperTest {
catch (PrincipalMappingException pme) {
// expected
}
-
- assertTrue(mapper.mapUserPrincipal("lmccay").equals("lmccay"));
- assertTrue(mapper.mapUserPrincipal("kminder").equals("kminder"));
-
- assertTrue(mapper.mapUserPrincipal("newuser").equals("newuser"));
- assertTrue(mapper.mapUserPrincipal("hdfs").equals("hdfs"));
- assertTrue(mapper.mapUserPrincipal("mapred").equals("mapred"));
+ assertEquals("lmccay", mapper.mapUserPrincipal("lmccay"));
+ assertEquals("kminder", mapper.mapUserPrincipal("kminder"));
+
+ assertEquals("newuser", mapper.mapUserPrincipal("newuser"));
- assertTrue(mapper.mapUserPrincipal("stink").equals("stink"));
+ assertEquals("hdfs", mapper.mapUserPrincipal("hdfs"));
+ assertEquals("mapred", mapper.mapUserPrincipal("mapred"));
+
+ assertEquals("stink", mapper.mapUserPrincipal("stink"));
}
@Test
@@ -218,15 +219,15 @@ public class PrincipalMapperTest {
catch (PrincipalMappingException pme) {
// expected
}
-
- assertTrue(mapper.mapUserPrincipal("lmccay").equals("lmccay"));
- assertTrue(mapper.mapUserPrincipal("kminder").equals("kminder"));
-
- assertTrue(mapper.mapUserPrincipal("newuser").equals("newuser"));
- assertTrue(mapper.mapUserPrincipal("hdfs").equals("hdfs"));
- assertTrue(mapper.mapUserPrincipal("mapred").equals("mapred"));
+ assertEquals("lmccay", mapper.mapUserPrincipal("lmccay"));
+ assertEquals("kminder", mapper.mapUserPrincipal("kminder"));
+
+ assertEquals("newuser", mapper.mapUserPrincipal("newuser"));
+
+ assertEquals("hdfs", mapper.mapUserPrincipal("hdfs"));
+ assertEquals("mapred", mapper.mapUserPrincipal("mapred"));
- assertTrue(mapper.mapUserPrincipal("stink").equals("stink"));
+ assertEquals("stink", mapper.mapUserPrincipal("stink"));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreServiceTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreServiceTest.java
index dd0584b..358dfe9 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreServiceTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFKeystoreServiceTest.java
@@ -32,6 +32,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/**
@@ -109,7 +110,7 @@ public class CMFKeystoreServiceTest {
ks.createCredentialStore();
ks.addCredential(aliasName, "secretValue");
char[] secret = ks.getCredential(aliasName);
- assertTrue("Addition of Credentials failed", new String(secret).equals("secretValue"));
+ assertEquals("Addition of Credentials failed", "secretValue", new String(secret));
} finally {
credentialsStoreFile.deleteOnExit();
keyStoreFile.deleteOnExit();
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java
index c4a17da..bd17ceb 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/impl/CMFMasterServiceTest.java
@@ -26,6 +26,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -46,7 +47,7 @@ public class CMFMasterServiceTest {
try {
ms.setupMasterSecret(".", true);
//System.out.println("MASTER: " + new String(ms.getMasterSecret()));
- assertTrue(new String(ms.getMasterSecret()).equals("testmastersecret"));
+ assertEquals("testmastersecret", new String(ms.getMasterSecret()));
File file = new File("ambari-master");
assertTrue(file.exists());
file.delete();
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/token/impl/JWTTokenTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/token/impl/JWTTokenTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/token/impl/JWTTokenTest.java
index cb1c113..296c4a7 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/token/impl/JWTTokenTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/services/security/token/impl/JWTTokenTest.java
@@ -144,7 +144,7 @@ public class JWTTokenTest extends org.junit.Assert {
assertEquals("KNOXSSO", token.getIssuer());
assertEquals("john.doe@example.com", token.getSubject());
- assertEquals(null, token.getAudience());
+ assertNull(token.getAudience());
assertArrayEquals(null, token.getAudienceClaims());
}
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-spi/src/test/java/org/apache/knox/gateway/topology/VersionTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/topology/VersionTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/topology/VersionTest.java
index 2a74b1c..2609fa6 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/topology/VersionTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/topology/VersionTest.java
@@ -20,7 +20,6 @@ package org.apache.knox.gateway.topology;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
public class VersionTest {
@@ -46,6 +45,6 @@ public class VersionTest {
assertEquals(6, version.getPatch());
assertEquals("4.5.6", version.toString());
Version other = new Version("4.5.6");
- assertTrue(version.equals(other));
+ assertEquals(version, other);
}
}
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java
----------------------------------------------------------------------
diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java
index dc50588..af51587 100644
--- a/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java
+++ b/gateway-spi/src/test/java/org/apache/knox/gateway/util/WhitelistUtilsTest.java
@@ -129,7 +129,7 @@ public class WhitelistUtilsTest {
doTestGetDispatchWhitelist(createMockGatewayConfig(Collections.singletonList(serviceRole), WHITELIST),
serviceRole);
assertNotNull(whitelist);
- assertTrue(whitelist.equals(WHITELIST));
+ assertEquals(whitelist, WHITELIST);
}
@Test
http://git-wip-us.apache.org/repos/asf/knox/blob/a60b0329/gateway-util-common/src/test/java/org/apache/knox/gateway/util/UrlsTest.java
----------------------------------------------------------------------
diff --git a/gateway-util-common/src/test/java/org/apache/knox/gateway/util/UrlsTest.java b/gateway-util-common/src/test/java/org/apache/knox/gateway/util/UrlsTest.java
index ad76d09..ec1e331 100644
--- a/gateway-util-common/src/test/java/org/apache/knox/gateway/util/UrlsTest.java
+++ b/gateway-util-common/src/test/java/org/apache/knox/gateway/util/UrlsTest.java
@@ -34,17 +34,17 @@ public class UrlsTest {
@Test
public void testDomainNameCreation() throws Exception {
// determine parent domain and wildcard the cookie domain with a dot prefix
- Assert.assertTrue(Urls.getDomainName("http://www.local.com", null).equals(".local.com"));
- Assert.assertTrue(Urls.getDomainName("http://ljm.local.com", null).equals(".local.com"));
+ assertEquals(".local.com", Urls.getDomainName("http://www.local.com", null));
+ assertEquals(".local.com", Urls.getDomainName("http://ljm.local.com", null));
// test scenarios that will leverage the default cookie domain
- Assert.assertEquals(Urls.getDomainName("http://local.home", null), null);
- Assert.assertEquals(Urls.getDomainName("http://localhost", null), null); // chrome may not allow this
+ Assert.assertNull(Urls.getDomainName("http://local.home", null));
+ Assert.assertNull(Urls.getDomainName("http://localhost", null)); // chrome may not allow this
- Assert.assertTrue(Urls.getDomainName("http://local.home.test.com", null).equals(".home.test.com"));
+ assertEquals(".home.test.com", Urls.getDomainName("http://local.home.test.com", null));
// check the suffix config feature
- Assert.assertTrue(Urls.getDomainName("http://local.home.test.com", ".test.com").equals(".test.com"));
+ assertEquals(".test.com", Urls.getDomainName("http://local.home.test.com", ".test.com"));
Assert.assertEquals(".novalocal", Urls.getDomainName("http://34526yewt.novalocal", ".novalocal"));
// make sure that even if the suffix doesn't start with a dot that the domain does
@@ -53,12 +53,12 @@ public class UrlsTest {
Assert.assertEquals(".novalocal", Urls.getDomainName("http://34526yewt.novalocal", "novalocal"));
// ip addresses can not be wildcarded - may be a completely different domain
- Assert.assertEquals(Urls.getDomainName("http://127.0.0.1", null), null);
+ Assert.assertNull(Urls.getDomainName("http://127.0.0.1", null));
/* Make sure we handle encoded characters properly here */
- Assert.assertTrue(Urls.getDomainName("https://www.local.com:8443/gateway/manager/admin-ui?limit=25&query=hive_table+where+name%3D%22table_1%22", null).equals(".local.com"));
+ assertEquals(".local.com", Urls.getDomainName("https://www.local.com:8443/gateway/manager/admin-ui?limit=25&query=hive_table+where+name%3D%22table_1%22", null));
/* Make sure we handle un-encoded characters safely */
- Assert.assertTrue(Urls.getDomainName("https://www.local.com:8443/gateway/manager/admin-ui/?limit=25&query=\"table_1\"", null).equals(".local.com"));
+ assertEquals(".local.com", Urls.getDomainName("https://www.local.com:8443/gateway/manager/admin-ui/?limit=25&query=\"table_1\"", null));
}