Repository: knox Updated Branches: refs/heads/master 488e4445c -> 15b471ee9
KNOX-1546 - Fix javadoc errors and warnings Fix test javadoc warnings Signed-off-by: Kevin Risden <kris...@apache.org> Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/15b471ee Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/15b471ee Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/15b471ee Branch: refs/heads/master Commit: 15b471ee941c0cf1c84fc8dc5cb30566ec163dad Parents: 488e444 Author: Kevin Risden <kris...@apache.org> Authored: Fri Nov 2 17:16:02 2018 -0400 Committer: Kevin Risden <kris...@apache.org> Committed: Fri Nov 2 17:24:29 2018 -0400 ---------------------------------------------------------------------- .../discovery/ambari/AmbariClusterTest.java | 25 ++++------ .../AmbariDynamicServiceURLCreatorTest.java | 48 ++++---------------- .../HaProviderDeploymentContributorTest.java | 16 +++---- .../impl/HBaseZookeeperURLManagerTest.java | 5 +- .../hadoop/groups/filter/HadoopGroupsTest.java | 2 +- .../UrlRewriteServletContextListenerTest.java | 7 --- .../websockets/MessageEventCallback.java | 9 ++++ .../gateway/GatewayPortMappingConfigTest.java | 25 ++-------- ...viceDefinitionDeploymentContributorTest.java | 5 +- .../topology/DefaultTopologyServiceTest.java | 23 ++-------- .../simple/SimpleDescriptorHandlerTest.java | 14 ++---- .../gateway/websockets/MessageFailureTest.java | 11 ++--- .../gateway/websockets/WebsocketEchoTest.java | 13 ++++-- .../WebsocketMultipleConnectionTest.java | 5 +- ...efaultRemoteConfigurationRegistriesTest.java | 31 +++++++------ ...eConfigurationRegistryClientServiceTest.java | 15 +++--- .../dispatch/GatewayDispatchFilterTest.java | 24 +++++----- .../knox/gateway/util/WhitelistUtilsTest.java | 3 +- .../apache/knox/gateway/GatewayTestDriver.java | 10 ++++ .../gateway/GatewayAdminTopologyFuncTest.java | 43 +++--------------- .../GatewayPortMappingDisableFeatureTest.java | 9 +--- .../gateway/GatewayPortMappingFuncTest.java | 9 ++-- .../monitor/RemoteConfigurationMonitorTest.java | 2 +- 23 files changed, 126 insertions(+), 228 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClusterTest.java ---------------------------------------------------------------------- diff --git a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClusterTest.java b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClusterTest.java index 6276054..95df086 100644 --- a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClusterTest.java +++ b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariClusterTest.java @@ -30,7 +30,7 @@ import static org.junit.Assert.assertNull; public class AmbariClusterTest { @Test - public void testHiveZooKeeperConfiguration() throws Exception { + public void testHiveZooKeeperConfiguration() { final boolean isEnabled = true; final String ensemble = "host1:2181,host2:2181,host3:2181"; @@ -49,7 +49,7 @@ public class AmbariClusterTest { } @Test - public void testWebHBaseZooKeeperConfiguration() throws Exception { + public void testWebHBaseZooKeeperConfiguration() { final boolean isEnabled = true; final String ensemble = "host1:2181,host2:2181,host3:2181"; @@ -66,9 +66,8 @@ public class AmbariClusterTest { assertEquals(namespace, config.getNamespace()); } - @Test - public void testKafkaZooKeeperConfiguration() throws Exception { + public void testKafkaZooKeeperConfiguration() { final boolean isEnabled = true; final String ensemble = "host1:2181,host2:2181,host3:2181"; @@ -84,7 +83,7 @@ public class AmbariClusterTest { } @Test - public void testWebHDFSZooKeeperConfiguration() throws Exception { + public void testWebHDFSZooKeeperConfiguration() { final boolean isEnabled = true; final String ensemble = "host3:2181,host2:2181,host1:2181"; @@ -99,9 +98,8 @@ public class AmbariClusterTest { assertNull(config.getNamespace()); } - @Test - public void testOozieZooKeeperConfiguration() throws Exception { + public void testOozieZooKeeperConfiguration() { final boolean isEnabled = true; final String ensemble = "host1:2181,host2:2181,host3:2181"; @@ -119,7 +117,7 @@ public class AmbariClusterTest { } @Test - public void testHBaseZooKeeperConfiguration() throws Exception { + public void testHBaseZooKeeperConfiguration() { final boolean isEnabled = true; final String ensemble = "host1:2181,host2:2181,host3:2181"; @@ -137,13 +135,12 @@ public class AmbariClusterTest { assertEquals(namespace, config.getNamespace()); } - /** * The Atlas ZooKeeper ensemble determination is based on multiple properties with a prioritized search order. * This test verifies that the default property is used when the primary property value is undefined. */ @Test - public void testAtlasZooKeeperEnsemblePropsConfigurationSecondary() throws Exception { + public void testAtlasZooKeeperEnsemblePropsConfigurationSecondary() { final boolean isEnabled = true; final String ensemble = "host1:2181,host2:2181,host3:2181"; @@ -165,13 +162,12 @@ public class AmbariClusterTest { assertEquals(namespace, config.getNamespace()); } - /** * The Atlas ZooKeeper ensemble determination is based on multiple properties with a prioritized search order. * This test verifies that the primary property value is used when it's defined. */ @Test - public void testAtlasZooKeeperEnsemblePropsConfigurationPrimary() throws Exception { + public void testAtlasZooKeeperEnsemblePropsConfigurationPrimary() { final boolean isEnabled = true; final String ensemble = "host1:2181,host2:2181,host3:2181"; @@ -193,15 +189,12 @@ public class AmbariClusterTest { assertEquals(namespace, config.getNamespace()); } - - private ServiceDiscovery.Cluster.ZooKeeperConfig getZooKeeperConfiguration(final String serviceName, final String configType, final Map<String, String> serviceConfigProps) { return getZooKeeperConfiguration(serviceName, serviceName, configType, serviceConfigProps); } - private ServiceDiscovery.Cluster.ZooKeeperConfig getZooKeeperConfiguration(final String serviceName, final String componentName, final String configType, @@ -216,6 +209,4 @@ public class AmbariClusterTest { return cluster.getZooKeeperConfiguration(serviceName); } - - } http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java ---------------------------------------------------------------------- diff --git a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java index 51f4af2..86b744e 100644 --- a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java +++ b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java @@ -350,35 +350,30 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(urls, HOSTNAMES, "http", hbaseMasterConfig.get(HBASE_REST_PORT_PROPERTY), null); } - @Test public void testWebHdfsURLHttp() throws Exception { final String ADDRESS = "host3:1357"; assertEquals(("http://" + ADDRESS + "/webhdfs"), getTestHdfsURL("WEBHDFS", ADDRESS, false)); } - @Test public void testWebHdfsURLHttps() throws Exception { final String ADDRESS = "host3:1357"; assertEquals(("https://" + ADDRESS + "/webhdfs"), getTestHdfsURL("WEBHDFS", ADDRESS, true)); } - @Test public void testHdfsUIURLHttp() throws Exception { final String ADDRESS = "host3:1357"; assertEquals(("http://" + ADDRESS), getTestHdfsURL("HDFSUI", ADDRESS, false)); } - @Test public void testHdfsUIURLHttps() throws Exception { final String ADDRESS = "host3:1357"; assertEquals(("https://" + ADDRESS), getTestHdfsURL("HDFSUI", ADDRESS, true)); } - private String getTestHdfsURL(String serviceName, String address, boolean isHttps) throws Exception { AmbariCluster.ServiceConfiguration hdfsSC = EasyMock.createNiceMock(AmbariCluster.ServiceConfiguration.class); Map<String, String> hdfsProps = new HashMap<>(); @@ -399,7 +394,6 @@ public class AmbariDynamicServiceURLCreatorTest { return urls.get(0); } - @Test public void testWebHdfsURLHASingleNameService() throws Exception { final String NAMESERVICES = "myNameServicesCluster"; @@ -428,7 +422,6 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); } - @Test public void testHdfsUIURLHASingleNameService() throws Exception { final String NAMESERVICES = "myNameServicesCluster"; @@ -458,7 +451,7 @@ public class AmbariDynamicServiceURLCreatorTest { } - /** + /* * Test federated NameNode scenario, which chooses the "first" nameservice because there is no information from * which one can be selected from among the set. */ @@ -497,7 +490,7 @@ public class AmbariDynamicServiceURLCreatorTest { } - /** + /* * Test federated NameNode scenario, which chooses the "first" nameservice because there is no information from * which one can be selected from among the set. */ @@ -535,8 +528,7 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); } - - /** + /* * Test federated NameNode scenario, relying on the core-site property for identifying the default nameservice. */ @Test @@ -580,8 +572,7 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); } - - /** + /* * Test federated NameNode scenario, relying on the core-site property for identifying the default nameservice. */ @Test @@ -625,8 +616,7 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); } - - /** + /* * Recent version of HDFS config include properties for mapping NN nodes to nameservices (e.g., dfs.ha.namenode.ns1). * This test verifies that discovery works correctly in those cases, when no nameservice is explicitly declared in * a descriptor. @@ -674,8 +664,7 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); } - - /** + /* * Recent version of HDFS config include properties for mapping NN nodes to nameservices (e.g., dfs.ha.namenode.ns1). * This test verifies that discovery works correctly in those cases, when no nameservice is explicitly declared in * a descriptor. @@ -723,8 +712,7 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); } - - /** + /* * Recent version of HDFS config include properties for mapping NN nodes to nameservices (e.g., dfs.ha.namenode.ns1). * This test verifies that discovery works correctly in those cases, when a nameservice is declared in descriptor. */ @@ -779,8 +767,7 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); } - - /** + /* * Previous version of HDFS config DO NOT include properties for mapping NN nodes to nameservices. * This test verifies that discovery works correctly in those cases, when a nameservice is declared in descriptor. */ @@ -833,7 +820,6 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(webhdfsURLs.contains(EXPECTED_ADDR_2)); } - @Test public void testAtlasApiURL() throws Exception { final String ATLAS_REST_ADDRESS = "http://host2:21000"; @@ -853,7 +839,6 @@ public class AmbariDynamicServiceURLCreatorTest { assertEquals(ATLAS_REST_ADDRESS, urls.get(0)); } - @Test public void testAtlasURL() throws Exception { final String HTTP_PORT = "8787"; @@ -890,19 +875,16 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(urls, HOSTNAMES, "https", HTTPS_PORT, null); } - @Test public void testRangerURL() throws Exception { doTestRangerURLs("RANGER"); } - @Test public void testRangerUIURL() throws Exception { doTestRangerURLs("RANGERUI"); } - private void doTestRangerURLs(String serviceName) throws Exception { final String HTTP_PORT = "6080"; final String HTTPS_PORT = "6182"; @@ -946,7 +928,6 @@ public class AmbariDynamicServiceURLCreatorTest { assertEquals(EXT_URL, urls.get(0)); } - @Test public void testZeppelinURL() throws Exception { final String HTTP_PORT = "8787"; @@ -982,7 +963,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(builder.create("ZEPPELIN", null), HOSTNAMES, "https", HTTPS_PORT, null); } - @Test public void testZeppelinUiURL() throws Exception { final String HTTP_PORT = "8787"; @@ -1018,7 +998,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(builder.create("ZEPPELINUI", null), HOSTNAMES, "https", HTTPS_PORT, null); } - @Test public void testZeppelinWsURL() throws Exception { final String HTTP_PORT = "8787"; @@ -1054,7 +1033,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(builder.create("ZEPPELINWS", null), HOSTNAMES, "wss", HTTPS_PORT, null); } - @Test public void testDruidCoordinatorURL() throws Exception { final String PORT = "8787"; @@ -1077,7 +1055,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(urls, HOSTNAMES, "http", PORT, null); } - @Test public void testDruidBrokerURL() throws Exception { final String PORT = "8181"; @@ -1100,7 +1077,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(urls, HOSTNAMES, "http", PORT, null); } - @Test public void testDruidRouterURL() throws Exception { final String PORT = "8282"; @@ -1123,7 +1099,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(urls, HOSTNAMES, "http", PORT, null); } - @Test public void testDruidOverlordURL() throws Exception { final String PORT = "8383"; @@ -1146,7 +1121,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(urls, HOSTNAMES, "http", PORT, null); } - @Test public void testDruidSupersetURL() throws Exception { final String PORT = "8484"; @@ -1169,7 +1143,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(urls, HOSTNAMES, "http", PORT, null); } - @Test public void testFalconURL() throws Exception { final String PORT = "8998"; @@ -1192,7 +1165,6 @@ public class AmbariDynamicServiceURLCreatorTest { validateServiceURLs(urls, HOSTNAMES, "http", PORT, null); } - @Test public void testMissingServiceComponentURL() throws Exception { AmbariCluster cluster = EasyMock.createNiceMock(AmbariCluster.class); @@ -1249,7 +1221,6 @@ public class AmbariDynamicServiceURLCreatorTest { } } - /** * Convenience method for creating AmbariDynamicServiceURLCreator instances from different mapping configuration * input sources. @@ -1276,7 +1247,6 @@ public class AmbariDynamicServiceURLCreatorTest { return result; } - /** * Validate the specifed HIVE URLs. * @@ -1320,7 +1290,6 @@ public class AmbariDynamicServiceURLCreatorTest { assertTrue(hostNamesToTest.isEmpty()); } - private static final String TEST_MAPPING_CONFIG = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<service-discovery-url-mappings>\n" + @@ -1454,7 +1423,6 @@ public class AmbariDynamicServiceURLCreatorTest { " </service>\n" + "</service-discovery-url-mappings>\n"; - private static final String OOZIE_OVERRIDE_MAPPING_FILE_CONTENTS = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<service-discovery-url-mappings>\n" + http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java ---------------------------------------------------------------------- diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java index 4403891..4410020 100644 --- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java +++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/deploy/HaProviderDeploymentContributorTest.java @@ -49,7 +49,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; - public class HaProviderDeploymentContributorTest { @Test @@ -66,7 +65,7 @@ public class HaProviderDeploymentContributorTest { fail( "Failed to find " + HaProviderDeploymentContributor.class.getName() + " via service loader." ); } - /** + /* * Basically, a backward-compatibility test to ensure that HaProvider service params specified ONLY at the provider * level still work. */ @@ -112,7 +111,7 @@ public class HaProviderDeploymentContributorTest { false, 40, 4, 50, 5, "testRoleOne", "http://host1:2181,http://host2:2181"); } - /** + /* * Simple test verifying that HaProvider service params specified ONLY at the service level works. */ @Test @@ -167,7 +166,7 @@ public class HaProviderDeploymentContributorTest { true, 80, 8, 60, 6, "testRoleOneOverride", "http://host3:2181,http://host4:2181"); } - /** + /* * Verify a mixture of provider-level params and service-level params. */ @Test @@ -219,7 +218,6 @@ public class HaProviderDeploymentContributorTest { true, 40, 4, 60, 5, "testRoleOneOverride", "http://host3:2181,http://host4:2181"); } - @Test public void testServiceLevelParamOverrides_MultipleMixed() throws Exception { @@ -289,7 +287,6 @@ public class HaProviderDeploymentContributorTest { true, 80, 8, 60, 6, "testRoleTwoOverride", "http://host3:2181,http://host4:2181"); } - private static String getHaProviderParamValue(boolean enabled, long failoverSleep, int maxFailoverAttempts, @@ -298,7 +295,6 @@ public class HaProviderDeploymentContributorTest { return getHaProviderParamValue(enabled, failoverSleep, maxFailoverAttempts, retrySleep, maxRetryAttempts, null, null); } - private static String getHaProviderParamValue(boolean enabled, long failoverSleep, int maxFailoverAttempts, @@ -358,7 +354,8 @@ public class HaProviderDeploymentContributorTest { } /** - * + * Validate the service ha config. + * * @param config The HaServiceConfig to validate * @param isEnabled The expected enabled param value * @param failoverSleep The expected failoverSleep param value @@ -375,7 +372,7 @@ public class HaProviderDeploymentContributorTest { int retrySleep, int maxRetryAttempts, String zookeeperNamespace, - String zookeeperEnsemble) throws Exception { + String zookeeperEnsemble) { assertNotNull(config); assertEquals(isEnabled, config.isEnabled()); assertEquals(failoverSleep, config.getFailoverSleep()); @@ -405,7 +402,6 @@ public class HaProviderDeploymentContributorTest { return provider; } - private static class DescriptorCaptureDeploymentContext implements DeploymentContext { private Topology topology; http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManagerTest.java ---------------------------------------------------------------------- diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManagerTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManagerTest.java index dfda14f..5e02f68 100644 --- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManagerTest.java +++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HBaseZookeeperURLManagerTest.java @@ -72,7 +72,7 @@ public class HBaseZookeeperURLManagerTest { doTest(SECURE_NS); } - /** + /* * KNOX-1149 */ @Test @@ -82,7 +82,7 @@ public class HBaseZookeeperURLManagerTest { doTest(null); } - /** + /* * KNOX-1149 */ @Test @@ -113,7 +113,6 @@ public class HBaseZookeeperURLManagerTest { Assert.assertTrue(manager instanceof HBaseZookeeperURLManager); } - private void createZNodes(String namespace) throws Exception { try (CuratorFramework zooKeeperClient = CuratorFrameworkFactory.builder().connectString(cluster.getConnectString()) http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-provider-identity-assertion-hadoop-groups/src/test/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupsTest.java ---------------------------------------------------------------------- diff --git a/gateway-provider-identity-assertion-hadoop-groups/src/test/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupsTest.java b/gateway-provider-identity-assertion-hadoop-groups/src/test/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupsTest.java index e12d8bc..70d00e6 100644 --- a/gateway-provider-identity-assertion-hadoop-groups/src/test/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupsTest.java +++ b/gateway-provider-identity-assertion-hadoop-groups/src/test/java/org/apache/knox/gateway/identityasserter/hadoop/groups/filter/HadoopGroupsTest.java @@ -71,7 +71,7 @@ public class HadoopGroupsTest { } - /** + /* * Test Groups on the machine running the unit test. */ @Test http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java ---------------------------------------------------------------------- diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java index 4f475b1..4223a46 100644 --- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java +++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteServletContextListenerTest.java @@ -77,11 +77,4 @@ public class UrlRewriteServletContextListenerTest { public void tearDown() throws Exception { server.stop(); } - -// @Test -// @Ignore("TODO") -// public void testProvider() throws Exception { -// fail( "TODO" ); -// } - } http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-server/src/main/java/org/apache/knox/gateway/websockets/MessageEventCallback.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/main/java/org/apache/knox/gateway/websockets/MessageEventCallback.java b/gateway-server/src/main/java/org/apache/knox/gateway/websockets/MessageEventCallback.java index 801d198..a91eaef 100644 --- a/gateway-server/src/main/java/org/apache/knox/gateway/websockets/MessageEventCallback.java +++ b/gateway-server/src/main/java/org/apache/knox/gateway/websockets/MessageEventCallback.java @@ -27,31 +27,40 @@ public interface MessageEventCallback { /** * A generic callback, can be left un-implemented + * @param message message */ void doCallback(final String message); /** * Callback when connection is established. + * @param session session */ void onConnectionOpen(final Object session); /** * Callback when connection is closed. + * @param reason Reason for the connection close */ void onConnectionClose(final CloseReason reason); /** * Callback when there is an error in connection. + * @param cause cause to throw on error */ void onError(final Throwable cause); /** * Callback when a text message is received. + * @param message message + * @param session session */ void onMessageText(final String message, final Object session); /** * Callback when a binary message is received. + * @param message message + * @param last last + * @param session session */ void onMessageBinary(final byte[] message, final boolean last, final Object session); http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java index 6db10d2..68280e9 100644 --- a/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java +++ b/gateway-server/src/test/java/org/apache/knox/gateway/GatewayPortMappingConfigTest.java @@ -17,10 +17,6 @@ package org.apache.knox.gateway; import org.apache.knox.gateway.config.GatewayConfig; -import org.apache.knox.gateway.services.DefaultGatewayServices; -import org.apache.knox.gateway.services.topology.TopologyService; -import org.apache.velocity.VelocityContext; -import org.apache.velocity.app.VelocityEngine; import org.easymock.EasyMock; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.ServerConnector; @@ -36,7 +32,6 @@ import java.io.IOException; import java.lang.reflect.Field; import java.util.Locale; import java.util.Map; -import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import static org.hamcrest.MatcherAssert.assertThat; @@ -59,16 +54,8 @@ public class GatewayPortMappingConfigTest { private static int defaultPort; - private static DefaultGatewayServices services; - private static TopologyService topos; - - private static VelocityEngine velocity; - private static VelocityContext context; - private static Server gatewayServer; - private static Properties params; - @Rule public ExpectedException exception = ExpectedException.none(); @@ -103,7 +90,6 @@ public class GatewayPortMappingConfigTest { // Start gateway to check port conflicts startGatewayServer(); - } @AfterClass @@ -118,7 +104,8 @@ public class GatewayPortMappingConfigTest { /** * This utility method will return the next available port * that can be used. - * + * @param min min port to check + * @param max max port to check * @return Port that is available. */ public static int getAvailablePort(final int min, final int max) { @@ -133,9 +120,7 @@ public class GatewayPortMappingConfigTest { return -1; } - - - /** + /* * This method simply tests the configs */ @Test @@ -148,7 +133,7 @@ public class GatewayPortMappingConfigTest { greaterThan(-1)); } - /** + /* * Test case where topologies "eerie" and "huron" use same ports. */ @Test @@ -179,7 +164,6 @@ public class GatewayPortMappingConfigTest { field.set(gatewayServer, mockedJetty); gatewayServer.checkPortConflict(huronPort, "eerie", gatewayConfig); - } /* @@ -195,7 +179,6 @@ public class GatewayPortMappingConfigTest { final GatewayServer gatewayServer = new GatewayServer(gatewayConfig); gatewayServer.checkPortConflict(defaultPort, null, gatewayConfig); - } private static void startGatewayServer() throws Exception { http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java index 26733c0..16f0c55 100644 --- a/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java +++ b/gateway-server/src/test/java/org/apache/knox/gateway/deploy/impl/ServiceDefinitionDeploymentContributorTest.java @@ -62,7 +62,7 @@ public class ServiceDefinitionDeploymentContributorTest { } } - /** + /* * Test that service param useTwoWaySsl in topologies overrides the corresponding custom dispatch property. */ @Test @@ -163,7 +163,7 @@ public class ServiceDefinitionDeploymentContributorTest { "true", useTwoWaySslFilterParamValues.get(0)); } - /** + /* * Test for a feature that sets dispatch the services defined in a * topology. The dispatch is defined per service in a topology. * @since 1.2.0 @@ -278,7 +278,6 @@ public class ServiceDefinitionDeploymentContributorTest { } - private static class TestGatewayDescriptor extends GatewayDescriptorImpl { } http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java index cb7437f..1eeb148 100644 --- a/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java +++ b/gateway-server/src/test/java/org/apache/knox/gateway/services/topology/DefaultTopologyServiceTest.java @@ -33,8 +33,6 @@ import org.apache.knox.gateway.topology.Topology; import org.apache.knox.gateway.topology.TopologyEvent; import org.apache.knox.gateway.topology.TopologyListener; import org.easymock.EasyMock; -import org.junit.After; -import org.junit.Before; import org.junit.Test; import java.io.File; @@ -65,14 +63,6 @@ import static org.junit.Assert.assertTrue; public class DefaultTopologyServiceTest { - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - private File createDir() throws IOException { return TestUtils.createTempDir(this.getClass().getSimpleName() + "-"); } @@ -191,7 +181,7 @@ public class DefaultTopologyServiceTest { } } - /** + /* * KNOX-1014 * * Test the lifecycle relationship between simple descriptors and topology files. @@ -311,7 +301,7 @@ public class DefaultTopologyServiceTest { } } - /** + /* * KNOX-1014 * * Test the lifecycle relationship between provider configuration files, simple descriptors, and topology files. @@ -409,7 +399,7 @@ public class DefaultTopologyServiceTest { } } - /** + /* * KNOX-1039 */ @Test @@ -561,7 +551,6 @@ public class DefaultTopologyServiceTest { } } - @Test public void testProviderParamsOrderIsPreserved() { @@ -587,9 +576,8 @@ public class DefaultTopologyServiceTest { Iterator<String> iter = keySet.iterator(); int i = 0; while (iter.hasNext()) { - assertTrue(iter.next().equals(names[i++])); + assertEquals(iter.next(), names[i++]); } - } private class TestTopologyListener implements TopologyListener { @@ -603,7 +591,6 @@ public class DefaultTopologyServiceTest { } - private class TestTopologyDeleteListener implements TopologyListener { FileAlterationListener delegate; @@ -620,7 +607,5 @@ public class DefaultTopologyServiceTest { } } } - } - } http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java index ad3e0e6..89fd866 100644 --- a/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java +++ b/gateway-server/src/test/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorHandlerTest.java @@ -127,7 +127,7 @@ public class SimpleDescriptorHandlerTest { " </provider>\n" + " </gateway>\n"; - /** + /* * KNOX-1006 * * N.B. This test depends on the PropertiesFileServiceDiscovery extension being configured: @@ -311,7 +311,7 @@ public class SimpleDescriptorHandlerTest { } - /** + /* * KNOX-1006 * * Verify the behavior of the SimpleDescriptorHandler when service discovery fails to produce a valid URL for @@ -458,7 +458,7 @@ public class SimpleDescriptorHandlerTest { } - /** + /* * KNOX-1216 */ @Test @@ -513,7 +513,7 @@ public class SimpleDescriptorHandlerTest { } - /** + /* * KNOX-1153 * * N.B. This test depends on the PropertiesFileServiceDiscovery extension being configured: @@ -765,14 +765,12 @@ public class SimpleDescriptorHandlerTest { } } - private File writeProviderConfig(String path, String content) throws IOException { File f = new File(path); FileUtils.write(f, content, StandardCharsets.UTF_8); return f; } - private void validateGeneratedProviderConfiguration(ProviderConfiguration expected, Node generatedGatewayNode) throws Exception { assertNotNull(expected); @@ -795,7 +793,7 @@ public class SimpleDescriptorHandlerTest { } } - /** + /* * Verify that the expected provider is included in the specified set of actual providers. * * @param expected A Provider that should be among the specified actual providers @@ -830,6 +828,4 @@ public class SimpleDescriptorHandlerTest { return foundMatch; } - - } http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java index 1e74d11..6b38ca0 100644 --- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java +++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/MessageFailureTest.java @@ -35,7 +35,6 @@ import org.junit.Test; import javax.websocket.CloseReason; import javax.websocket.ContainerProvider; import javax.websocket.WebSocketContainer; -import java.io.IOException; import java.net.URI; import java.util.Locale; import java.util.concurrent.Executors; @@ -73,11 +72,11 @@ public class MessageFailureTest { backend.stop(); } - /** + /* * Test for a message that bigger than configured value */ @Test(timeout = 8000) - public void testMessageTooBig() throws IOException, Exception { + public void testMessageTooBig() throws Exception { final String bigMessage = "Echooooooooooooo"; WebSocketContainer container = ContainerProvider.getWebSocketContainer(); @@ -93,11 +92,11 @@ public class MessageFailureTest { Assert.assertThat(client.close.getCloseCode().getCode(), CoreMatchers.is(CloseReason.CloseCodes.TOO_BIG.getCode())); } - /** + /* * Test for a message within limit. */ @Test(timeout = 8000) - public void testMessageOk() throws IOException, Exception { + public void testMessageOk() throws Exception { final String message = "Echo"; WebSocketContainer container = ContainerProvider.getWebSocketContainer(); @@ -113,7 +112,6 @@ public class MessageFailureTest { } - private static void startBackend() throws Exception { backend = new Server(); connector = new ServerConnector(backend); @@ -170,7 +168,6 @@ public class MessageFailureTest { /** * A Mock websocket handler that just Echos messages - * */ class BigEchoSocketHandler extends WebSocketHandler implements WebSocketCreator { http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java index 1eda4ee..a15b70c 100644 --- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java +++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketEchoTest.java @@ -132,7 +132,7 @@ public class WebsocketEchoTest { FileUtils.deleteQuietly(topoDir); } - /** + /* * Test direct connection to websocket server without gateway */ @Test @@ -147,7 +147,7 @@ public class WebsocketEchoTest { client.messageQueue.awaitMessages(1, 1000, TimeUnit.MILLISECONDS); } - /** + /* * Test websocket proxying through gateway. */ @Test @@ -164,7 +164,7 @@ public class WebsocketEchoTest { assertThat(client.messageQueue.get(0), is("Echo")); } - /** + /* * Test websocket rewrite rules proxying through gateway. */ @Test @@ -183,6 +183,7 @@ public class WebsocketEchoTest { /** * Start Mock Websocket server that acts as backend. + * @throws Exception exception on websocket server start */ private static void startWebsocketServer() throws Exception { @@ -210,6 +211,7 @@ public class WebsocketEchoTest { /** * Start Gateway Server. + * @throws Exception exception on server start */ private static void startGatewayServer() throws Exception { gatewayServer = new Server(); @@ -247,9 +249,10 @@ public class WebsocketEchoTest { /** * Initialize the configs and components required for this test. + * @param backend topology to use + * @throws IOException exception on setting up the gateway */ - private static void setupGatewayConfig(final String backend) - throws IOException { + private static void setupGatewayConfig(final String backend) throws IOException { services = new DefaultGatewayServices(); topoDir = createDir(); http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java ---------------------------------------------------------------------- diff --git a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java index bd8439b..2d25d82 100644 --- a/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java +++ b/gateway-server/src/test/java/org/apache/knox/gateway/websockets/WebsocketMultipleConnectionTest.java @@ -125,7 +125,7 @@ public class WebsocketMultipleConnectionTest { FileUtils.deleteQuietly(topoDir); } - /** + /* * Test websocket proxying through gateway. */ @Test @@ -183,6 +183,7 @@ public class WebsocketMultipleConnectionTest { /** * Start Mock Websocket server that acts as backend. + * @throws Exception exception on websocket server start */ private static void startWebsocketServer() throws Exception { @@ -206,7 +207,6 @@ public class WebsocketMultipleConnectionTest { } int port = connector.getLocalPort(); backendServerUri = new URI(String.format(Locale.ROOT, "ws://%s:%d/ws", host, port)); - } private static void startGatewayServer() throws Exception { @@ -246,6 +246,7 @@ public class WebsocketMultipleConnectionTest { /** * Initialize the configs and components required for this test. + * @param backend name of topology */ private static void setupGatewayConfig(final String backend) throws IOException { http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/config/DefaultRemoteConfigurationRegistriesTest.java ---------------------------------------------------------------------- diff --git a/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/config/DefaultRemoteConfigurationRegistriesTest.java b/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/config/DefaultRemoteConfigurationRegistriesTest.java index 3123e21..363b12a 100644 --- a/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/config/DefaultRemoteConfigurationRegistriesTest.java +++ b/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/config/DefaultRemoteConfigurationRegistriesTest.java @@ -32,11 +32,11 @@ import static org.junit.Assert.assertNotNull; public class DefaultRemoteConfigurationRegistriesTest { - /** + /* * Test a single registry configuration with digest auth configuration. */ @Test - public void testPropertiesRemoteConfigurationRegistriesSingleDigest() throws Exception { + public void testPropertiesRemoteConfigurationRegistriesSingleDigest() { Map<String, Properties> testProperties = new HashMap<>(); Properties p = new Properties(); p.setProperty(GatewayConfig.REMOTE_CONFIG_REGISTRY_TYPE, "ZooKeeper"); @@ -50,11 +50,11 @@ public class DefaultRemoteConfigurationRegistriesTest { } - /** + /* * Test a single registry configuration with kerberos auth configuration. */ @Test - public void testPropertiesRemoteConfigurationRegistriesSingleKerberos() throws Exception { + public void testPropertiesRemoteConfigurationRegistriesSingleKerberos() { Map<String, Properties> testProperties = new HashMap<>(); Properties p = new Properties(); p.setProperty(GatewayConfig.REMOTE_CONFIG_REGISTRY_TYPE, "ZooKeeper"); @@ -69,11 +69,11 @@ public class DefaultRemoteConfigurationRegistriesTest { doTestPropertiesRemoteConfigurationRegistries(testProperties); } - /** + /* * Test multiple registry configuration with varying auth configurations. */ @Test - public void testPropertiesRemoteConfigurationRegistriesMultipleMixed() throws Exception { + public void testPropertiesRemoteConfigurationRegistriesMultipleMixed() { Map<String, Properties> testProperties = new HashMap<>(); Properties kerb = new Properties(); @@ -103,13 +103,12 @@ public class DefaultRemoteConfigurationRegistriesTest { doTestPropertiesRemoteConfigurationRegistries(testProperties); } - /** * Perform the actual test. * * @param testProperties The test properties */ - private void doTestPropertiesRemoteConfigurationRegistries(Map<String, Properties> testProperties) throws Exception { + private void doTestPropertiesRemoteConfigurationRegistries(Map<String, Properties> testProperties) { // Mock gateway config GatewayConfig gc = mockGatewayConfig(testProperties); @@ -128,7 +127,6 @@ public class DefaultRemoteConfigurationRegistriesTest { } } - /** * Create a mock GatewayConfig based on the specified test properties. * @@ -141,18 +139,18 @@ public class DefaultRemoteConfigurationRegistriesTest { for (String registryName : testProperties.keySet()) { configNames.add(registryName); - String propertyValueString = ""; + StringBuilder propertyValueString = new StringBuilder(); Properties props = testProperties.get(registryName); Enumeration names = props.propertyNames(); while (names.hasMoreElements()) { String propertyName = (String) names.nextElement(); - propertyValueString += propertyName + "=" + props.get(propertyName); + propertyValueString.append(propertyName).append("=").append(props.get(propertyName)); if (names.hasMoreElements()) { - propertyValueString += ";"; + propertyValueString.append(";"); } } EasyMock.expect(gc.getRemoteRegistryConfiguration(registryName)) - .andReturn(propertyValueString) + .andReturn(propertyValueString.toString()) .anyTimes(); } EasyMock.expect(gc.getRemoteRegistryConfigurationNames()).andReturn(configNames).anyTimes(); @@ -161,13 +159,16 @@ public class DefaultRemoteConfigurationRegistriesTest { return gc; } - /** * Validate the specified RemoteConfigurationRegistry based on the expected test properties. + * + * @param configName config name to validate + * @param expected expected properties + * @param registryConfig registryConfig to validate */ private void validateRemoteRegistryConfig(String configName, Properties expected, - RemoteConfigurationRegistry registryConfig) throws Exception { + RemoteConfigurationRegistry registryConfig) { assertEquals(configName, registryConfig.getName()); assertEquals(expected.get(GatewayConfig.REMOTE_CONFIG_REGISTRY_TYPE), registryConfig.getRegistryType()); assertEquals(expected.get(GatewayConfig.REMOTE_CONFIG_REGISTRY_ADDRESS), registryConfig.getConnectionString()); http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java ---------------------------------------------------------------------- diff --git a/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java b/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java index ba4d213..a335f15 100644 --- a/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java +++ b/gateway-service-remoteconfig/src/test/java/org/apache/knox/gateway/service/config/remote/zk/RemoteConfigurationRegistryClientServiceTest.java @@ -54,7 +54,7 @@ import static org.junit.Assert.assertTrue; public class RemoteConfigurationRegistryClientServiceTest { - /** + /* * Test a configuration for an unsecured remote registry, included in the gateway configuration. */ @Test @@ -85,7 +85,7 @@ public class RemoteConfigurationRegistryClientServiceTest { } } - /** + /* * Test multiple configurations for an unsecured remote registry. */ @Test @@ -136,7 +136,7 @@ public class RemoteConfigurationRegistryClientServiceTest { } } - /** + /* * Test a configuration for a secure remote registry, included in the gateway configuration. */ @Test @@ -171,7 +171,7 @@ public class RemoteConfigurationRegistryClientServiceTest { } } - /** + /* * Test the remote registry configuration external to, and referenced from, the gateway configuration, for a secure * client. */ @@ -217,7 +217,7 @@ public class RemoteConfigurationRegistryClientServiceTest { } } - /** + /* * Setup and start a secure test ZooKeeper cluster. */ private TestingCluster setupAndStartSecureTestZooKeeper(String principal, String digestPassword) throws Exception { @@ -263,6 +263,9 @@ public class RemoteConfigurationRegistryClientServiceTest { /** * Create a ZooKeeper client with SASL digest auth configured, and initialize the test znodes. + * @param zkCluster zkCluster to initialize + * @param principal principal for SASL digrest auth + * @throws Exception exception on failure */ private CuratorFramework initializeTestClientAndZNodes(TestingCluster zkCluster, String principal) throws Exception { // Create the client for the test cluster @@ -327,6 +330,7 @@ public class RemoteConfigurationRegistryClientServiceTest { * @param testClientName The name of the client to use from the registry client service. * @param clientService The RemoteConfigurationRegistryClientService * @param isSecureTest Flag to indicate whether this is a secure interaction test + * @throws Exception exception on failure */ private void doTestZooKeeperClient(final CuratorFramework setupClient, final String testClientName, @@ -407,5 +411,4 @@ public class RemoteConfigurationRegistryClientServiceTest { assertFalse(listenerLog.isEmpty()); } - } http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java ---------------------------------------------------------------------- diff --git a/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java b/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java index 89afd0d..6340182 100644 --- a/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java +++ b/gateway-spi/src/test/java/org/apache/knox/gateway/dispatch/GatewayDispatchFilterTest.java @@ -37,7 +37,7 @@ import static org.junit.Assert.assertEquals; public class GatewayDispatchFilterTest { - /** + /* * Verify that a whitelist violation results in a HTTP 400 response. */ @Test @@ -67,7 +67,7 @@ public class GatewayDispatchFilterTest { } - /** + /* * If the dispatch service is not configured to honor the whitelist, the dispatching should be permitted. */ @Test @@ -79,7 +79,7 @@ public class GatewayDispatchFilterTest { "http://www.notonmylist.org:9999", true); } - /** + /* * If the dispatch service is configured to honor the whitelist, but no whitelist is configured, then the default * whitelist should be applied. If the dispatch URL does not match the default whitelist, then the dispatch should be * disallowed. @@ -94,7 +94,7 @@ public class GatewayDispatchFilterTest { false); } - /** + /* * If the dispatch service is configured to honor the whitelist, but no whitelist is configured, then the default * whitelist should be applied. If the dispatch URL does not match the default whitelist, then the dispatch should be * disallowed. @@ -109,7 +109,7 @@ public class GatewayDispatchFilterTest { "http://www.notonmylist.org:9999", false); } - /** + /* * If the dispatch service is configured to honor the whitelist, but no whitelist is configured, then the default * whitelist should be applied. If the dispatch URL does not match the default domain-based whitelist, then the * dispatch should be disallowed. @@ -125,7 +125,7 @@ public class GatewayDispatchFilterTest { false); } - /** + /* * If the dispatch service is configured to honor the whitelist, but no whitelist is configured, then the default * whitelist should be applied. If the dispatch URL does match the default whitelist, then the dispatch should be * allowed. @@ -140,7 +140,7 @@ public class GatewayDispatchFilterTest { true); } - /** + /* * If the dispatch service is configured to honor the whitelist, but no whitelist is configured, then the default * whitelist should be applied. If the dispatch URL does match the default whitelist, then the dispatch should be * allowed. @@ -156,7 +156,7 @@ public class GatewayDispatchFilterTest { } - /** + /* * If the dispatch service is configured to honor the whitelist, but DEFAULT whitelist is configured, then the default * whitelist should be applied. If the dispatch URL does match the default whitelist, then the dispatch should be * allowed. @@ -172,7 +172,7 @@ public class GatewayDispatchFilterTest { } - /** + /* * An empty whitelist should be treated as the default whitelist. */ @Test @@ -186,7 +186,7 @@ public class GatewayDispatchFilterTest { } - /** + /* * If a custom whitelist is configured, and the requested service role is among those configured to honor that * whitelist, the request should be disallowed if the URL does NOT match the whitelist. */ @@ -201,7 +201,7 @@ public class GatewayDispatchFilterTest { } - /** + /* * If a custom whitelist is configured, and the requested service role is among those configured to honor that * whitelist, the request should be permitted if the URL matches the whitelist. */ @@ -215,7 +215,7 @@ public class GatewayDispatchFilterTest { true); } - /** + /* * The configured whitelist should be ignored for services which are NOT configured to honor the whitelist, and those * dispatches should be permitted. */ http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/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 2ee8ae8..de95fa8 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 @@ -44,7 +44,7 @@ public class WhitelistUtilsTest { whitelist); } - /** + /* * KNOXSSO is implicitly included in the set of service roles for which the whitelist will be applied. */ @Test @@ -159,7 +159,6 @@ public class WhitelistUtilsTest { return doTestGetDispatchWhitelist(config, "localhost", serviceRole); } - private String doTestGetDispatchWhitelist(GatewayConfig config, String serverName, String serviceRole) { http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java ---------------------------------------------------------------------- diff --git a/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java b/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java index f011cbf..1a1f784 100644 --- a/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java +++ b/gateway-test-release-utils/src/main/java/org/apache/knox/gateway/GatewayTestDriver.java @@ -106,6 +106,11 @@ public class GatewayTestDriver { /** * Adds a mock service to the registry. + * @param role role to create service for + * @param realUrl real url for the service + * @param gatewayPath gateway path to respond on + * @param mock whether to mock or use real service from realUrl + * @throws Exception Thrown if new service fails. */ public void setupService( String role, String realUrl, String gatewayPath, boolean mock ) throws Exception { Service service = new Service( role, realUrl, gatewayPath, mock ); @@ -115,6 +120,11 @@ public class GatewayTestDriver { /** * Creates a GATEWAY_HOME, starts a gateway instance and deploys a test topology. + * @param config config for setting up the gateway + * @param cluster cluster name to setup + * @param topology topology to setup + * @param use whether to use the gateway or real service + * @throws Exception Thrown if failure during setup. */ public void setupGateway( GatewayTestConfig config, String cluster, XMLTag topology, boolean use ) throws Exception { this.useGateway = use; http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java ---------------------------------------------------------------------- diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java index 40822c3..82952fd 100644 --- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java +++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayAdminTopologyFuncTest.java @@ -75,6 +75,7 @@ import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.xml.HasXPath.hasXPath; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; @@ -285,12 +286,10 @@ public class GatewayAdminTopologyFuncTest { return xml; } - private static String createDescriptor(String clusterName) { return createDescriptor(clusterName, null); } - private static String createDescriptor(String clusterName, String providerConfigRef) { return createDescriptor(clusterName, providerConfigRef, true); } @@ -330,7 +329,6 @@ public class GatewayAdminTopologyFuncTest { return sb.toString(); } - //@Test public void waitForManualTesting() throws IOException { System.in.read(); @@ -371,7 +369,6 @@ public class GatewayAdminTopologyFuncTest { .statusCode(HttpStatus.SC_OK) .when().get(serviceUrl); - given() //.log().all() .auth().preemptive().basic(username, password) @@ -381,7 +378,6 @@ public class GatewayAdminTopologyFuncTest { .contentType(MediaType.APPLICATION_XML) .when().get(serviceUrl); - given().auth().preemptive().basic(username, password) .header("Accept", MediaType.APPLICATION_JSON) .then() @@ -433,7 +429,6 @@ public class GatewayAdminTopologyFuncTest { .when() .get(hrefJson); - String hrefXml = given() //.log().all() .auth().preemptive().basic(username, password) @@ -456,8 +451,7 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - - /** + /* * KNOX-1322 */ @Test( timeout = TestUtils.LONG_TIMEOUT ) @@ -492,12 +486,12 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - /** * Access the specified topology, and validate the value of the generated element therein. * * @param topologyName The name of the topology to validate * @param expectedValue The expected value of the generated element. + * @throws Exception exception on failure */ private void validateGeneratedElement(String topologyName, String expectedValue) throws Exception { String testClusterTopology = given().auth().preemptive().basic("admin", "admin-password") @@ -512,7 +506,6 @@ public class GatewayAdminTopologyFuncTest { assertThat(doc, hasXPath("/topology/generated", is(expectedValue))); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPositiveAuthorization() throws ClassNotFoundException{ LOG_ENTER(); @@ -792,7 +785,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutTopologyWithInvalidName() throws Exception { LOG_ENTER() ; @@ -817,7 +809,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutTopologyWithEntityInjection() throws Exception { LOG_ENTER() ; @@ -899,7 +890,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutTopologyWithEntityExpansion() throws Exception { LOG_ENTER() ; @@ -981,7 +971,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testXForwardedHeaders() { LOG_ENTER(); @@ -1015,7 +1004,6 @@ public class GatewayAdminTopologyFuncTest { .body(containsString("admin")) .when().get(url); - // Case 2: add in x-forward headers (host, server, proto, context) given() .auth().preemptive().basic(username, password) @@ -1114,7 +1102,6 @@ public class GatewayAdminTopologyFuncTest { .body(containsString(url + "/test-cluster")) .when().get(url); - // Case 2: Change gateway.path to another String. Ensure HTTP OK resp + valid URL. try { gateway.stop(); @@ -1144,7 +1131,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testProviderConfigurationCollection() throws Exception { LOG_ENTER(); @@ -1243,7 +1229,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutProviderConfiguration() throws Exception { LOG_ENTER(); @@ -1303,7 +1288,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutProviderConfigurationWithInvalidName() throws Exception { LOG_ENTER(); @@ -1333,7 +1317,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testDeleteProviderConfiguration() throws Exception { LOG_ENTER(); @@ -1408,8 +1391,7 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - - /** + /* * KNOX-1176 */ @Test( timeout = TestUtils.LONG_TIMEOUT ) @@ -1542,8 +1524,7 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - - /** + /* * KNOX-1331 */ @Test( timeout = TestUtils.LONG_TIMEOUT ) @@ -1660,7 +1641,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testDescriptorCollection() throws Exception { LOG_ENTER(); @@ -1763,7 +1743,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutDescriptor() throws Exception { LOG_ENTER(); @@ -1879,7 +1858,6 @@ public class GatewayAdminTopologyFuncTest { newDescriptorFile.delete(); } - @Test public void testPutDescriptorWithFileExtension() throws Exception { @@ -1927,7 +1905,6 @@ public class GatewayAdminTopologyFuncTest { newDescriptorFile.delete(); } - @Test public void testPutDescriptorWithInvalidEncodedName() throws Exception { @@ -1956,7 +1933,6 @@ public class GatewayAdminTopologyFuncTest { assertFalse(newDescriptorFile.exists()); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutDescriptorWithInvalidNameEncodedElement() throws Exception { LOG_ENTER(); @@ -1966,7 +1942,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutDescriptorWithInvalidNamePercent() throws Exception { LOG_ENTER(); @@ -1976,7 +1951,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutDescriptorWithInvalidNameXMLElement() throws Exception { LOG_ENTER(); @@ -1986,7 +1960,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testPutDescriptorWithInvalidNameTooLong() throws Exception { LOG_ENTER(); @@ -2001,7 +1974,6 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - private void doTestPutDescriptorWithInvalidName(final String newDescriptorName) throws Exception { assertNotNull(newDescriptorName); @@ -2037,11 +2009,10 @@ public class GatewayAdminTopologyFuncTest { assertNotNull(responseBody); List<Map<String, String>> items = responseBody.path("items"); for (Map<String, String> item : items) { - assertFalse(item.get("name").equals(newDescriptorName)); + assertNotEquals(item.get("name"), newDescriptorName); } } - @Test( timeout = TestUtils.LONG_TIMEOUT ) public void testDeleteDescriptor() throws Exception { LOG_ENTER(); @@ -2111,6 +2082,4 @@ public class GatewayAdminTopologyFuncTest { LOG_EXIT(); } - - } http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java ---------------------------------------------------------------------- diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java index ab7cab7..5f202c0 100644 --- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java +++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingDisableFeatureTest.java @@ -62,7 +62,6 @@ public class GatewayPortMappingDisableFeatureTest { @Rule public ExpectedException exception = ExpectedException.none(); - public GatewayPortMappingDisableFeatureTest() { super(); } @@ -136,7 +135,6 @@ public class GatewayPortMappingDisableFeatureTest { LOG_EXIT(); } - private void test (final String url) throws IOException { String password = "hdfs-password"; String username = "hdfs"; @@ -163,7 +161,6 @@ public class GatewayPortMappingDisableFeatureTest { masterServer.isEmpty(); } - /** * Creates a topology that is deployed to the gateway instance for the test suite. * Note that this topology is shared by all of the test methods in this suite. @@ -229,13 +226,12 @@ public class GatewayPortMappingDisableFeatureTest { /** * This utility method will return the next available port * that can be used. - * + * @param min min port to check + * @param max max port to check * @return Port that is available. */ public static int getAvailablePort(final int min, final int max) { - for (int i = min; i <= max; i++) { - if (!GatewayServer.isPortInUse(i)) { return i; } @@ -243,5 +239,4 @@ public class GatewayPortMappingDisableFeatureTest { // too bad return -1; } - } http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java ---------------------------------------------------------------------- diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java index 7f8ce7a..81dda51 100644 --- a/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java +++ b/gateway-test/src/test/java/org/apache/knox/gateway/GatewayPortMappingFuncTest.java @@ -155,7 +155,6 @@ public class GatewayPortMappingFuncTest { LOG_EXIT(); } - private void test (final String url) throws IOException { String password = "hdfs-password"; String username = "hdfs"; @@ -182,11 +181,12 @@ public class GatewayPortMappingFuncTest { masterServer.isEmpty(); } - /** * Creates a topology that is deployed to the gateway instance for the test suite. * Note that this topology is shared by all of the test methods in this suite. - * + * @param role role name + * @param ldapURL ldap url + * @param gatewayPort port for the gateway * @return A populated XML structure for a topology file. */ public static XMLTag createTopology(final String role, final String ldapURL, final int gatewayPort ) { @@ -248,7 +248,8 @@ public class GatewayPortMappingFuncTest { /** * This utility method will return the next available port * that can be used. - * + * @param min min port to check + * @param max max port to check * @return Port that is available. */ public static int getAvailablePort(final int min, final int max) { http://git-wip-us.apache.org/repos/asf/knox/blob/15b471ee/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java ---------------------------------------------------------------------- diff --git a/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java b/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java index 3641fd4..ef53de2 100644 --- a/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java +++ b/gateway-test/src/test/java/org/apache/knox/gateway/topology/monitor/RemoteConfigurationMonitorTest.java @@ -287,7 +287,7 @@ public class RemoteConfigurationMonitorTest { } - /** + /* * KNOX-1135 */ @Test