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/12/13 16:40:51 UTC
[5/5] knox git commit: KNOX-1676 - Enable PMD for tests
KNOX-1676 - Enable PMD for tests
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/89caa5fe
Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/89caa5fe
Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/89caa5fe
Branch: refs/heads/master
Commit: 89caa5feeed706abc8d7ce1407830ae00d97d405
Parents: 59954fb
Author: Kevin Risden <kr...@apache.org>
Authored: Wed Dec 12 09:58:51 2018 -0500
Committer: Kevin Risden <kr...@apache.org>
Committed: Thu Dec 13 11:38:20 2018 -0500
----------------------------------------------------------------------
.../resources/build-tools/pmd/pmd-ruleset.xml | 3 +
.../gateway/shirorealm/KnoxPamRealmTest.java | 3 +-
.../security/ldap/SimpleLdapServerTest.java | 14 +-
.../ambari/AmbariConfigurationMonitorTest.java | 4 +-
.../ambari/AmbariServiceDiscoveryTest.java | 51 +--
.../gateway/i18n/messages/MessagesSubject.java | 24 ++
.../gateway/i18n/messages/MessagesTest.java | 3 +-
.../i18n/messages/MessagesTestSubject.java | 40 ---
.../resources/ResourcesFormattingSubject.java | 42 +++
.../i18n/resources/ResourcesLocaleSubject.java | 24 ++
.../i18n/resources/ResourcesNamedSubject.java | 24 ++
.../gateway/i18n/resources/ResourcesTest.java | 18 +-
.../ResourcesTestFormattingSubject.java | 44 ---
.../resources/ResourcesTestLocaleSubject.java | 26 --
.../resources/ResourcesTestNamedSubject.java | 26 --
.../resources/ResourcesLocaleSubject.properties | 14 +
.../ResourcesLocaleSubject_en.properties | 19 ++
.../ResourcesLocaleSubject_en_GB.properties | 19 ++
.../ResourcesLocaleSubject_en_US.properties | 19 ++
.../ResourcesTestLocaleSubject.properties | 14 -
.../ResourcesTestLocaleSubject_en.properties | 19 --
.../ResourcesTestLocaleSubject_en_GB.properties | 19 --
.../ResourcesTestLocaleSubject_en_US.properties | 19 --
.../HaProviderDeploymentContributorTest.java | 55 ++--
.../impl/AtlasZookeeperURLManagerTest.java | 4 +-
.../ha/provider/impl/DefaultHaProviderTest.java | 1 +
.../impl/HBaseZookeeperURLManagerTest.java | 4 +-
.../impl/HS2ZookeeperURLManagerTest.java | 7 +-
.../provider/impl/HaDescriptorManagerTest.java | 4 -
.../impl/KafkaZookeeperURLManagerTest.java | 4 +-
.../impl/SOLRZookeeperURLManagerTest.java | 5 +-
.../CommonIdentityAssertionFilterTest.java | 9 +-
...yAssertionHttpServletRequestWrapperTest.java | 5 -
.../function/UsernameFunctionProcessorTest.java | 8 +-
.../DefaultIdentityAssertionFilterTest.java | 4 +-
.../impl/InboundUrlFunctionProcessorTest.java | 6 +-
.../impl/ServiceRegistryFunctionsTest.java | 11 +-
.../UrlRewriteRulesDescriptorFactoryTest.java | 17 +-
.../UrlRewriteServletContextListenerTest.java | 9 -
.../api/UrlRewriteServletFilterTest.java | 51 ++-
.../impl/FrontendFunctionProcessorTest.java | 9 +-
.../rewrite/impl/UrlRewriteResponseTest.java | 35 +--
.../impl/html/HtmlFilterReaderBaseTest.java | 25 --
.../rewrite/impl/json/JsonFilterReaderTest.java | 13 +-
.../rewrite/impl/xml/XmlFilterReaderTest.java | 12 +-
.../xml/XmlUrlRewriteRulesExporterTest.java | 21 +-
.../knox/gateway/filter/AclParserTest.java | 42 ++-
.../gateway/filter/AclsAuthzFilterTest.java | 47 +--
.../federation/AbstractJWTFilterTest.java | 4 +-
.../federation/SSOCookieProviderTest.java | 23 +-
.../gateway/pac4j/MockHttpServletResponse.java | 1 -
.../HeaderPreAuthFederationFilterTest.java | 5 +-
.../provider/federation/PreAuthSSOTest.java | 27 --
.../provider/federation/PreAuthServiceTest.java | 3 +
.../apache/knox/gateway/webappsec/CSRFTest.java | 28 --
.../filter/CompositeEnumerationTest.java | 25 +-
.../knox/gateway/filter/TestFilterChain.java | 4 +-
.../apache/knox/gateway/AuditLoggingTest.java | 14 +-
.../apache/knox/gateway/GatewayFilterTest.java | 4 +-
.../gateway/deploy/DeploymentFactoryTest.java | 39 ++-
...viceDefinitionDeploymentContributorTest.java | 8 +-
.../impl/DefaultTokenAuthorityServiceTest.java | 15 +-
.../topology/DefaultTopologyServiceTest.java | 17 +-
.../builder/PropertyTopologyBuilderTest.java | 4 +-
.../PropertiesFileServiceDiscoveryTest.java | 24 +-
.../PropertiesFileServiceDiscovery.java | 12 +-
.../simple/ProviderConfigurationParserTest.java | 19 +-
.../simple/SimpleDescriptorFactoryTest.java | 50 +--
.../simple/SimpleDescriptorHandlerTest.java | 34 +-
.../apache/knox/gateway/util/KnoxCLITest.java | 13 +-
.../knox/gateway/websockets/BadBackendTest.java | 1 -
.../knox/gateway/websockets/BadSocket.java | 69 ++++
.../knox/gateway/websockets/BadUrlTest.java | 16 +-
.../websockets/BigEchoSocketHandler.java | 49 +++
.../websockets/ConnectionDroppedTest.java | 58 +---
.../knox/gateway/websockets/EchoSocket.java | 12 +-
.../gateway/websockets/MessageFailureTest.java | 41 +--
.../websockets/ProxyInboundClientTest.java | 80 ++---
.../gateway/websockets/WebsocketClient.java | 3 +-
.../gateway/websockets/WebsocketEchoTest.java | 17 +-
.../WebsocketMultipleConnectionTest.java | 16 +-
.../service/knoxsso/WebSSOResourceTest.java | 2 +-
.../knoxtoken/TokenServiceResourceTest.java | 6 +-
...efaultRemoteConfigurationRegistriesTest.java | 6 +-
.../util/RemoteRegistryConfigTestUtils.java | 4 +-
...eConfigurationRegistryClientServiceTest.java | 1 -
...moteConfigurationRegistryJAASConfigTest.java | 1 +
.../dispatch/CappedBufferHttpEntityTest.java | 311 +++++++------------
.../dispatch/HadoopAuthCookieStoreTest.java | 11 +-
.../PartiallyRepeatableHttpEntityTest.java | 101 ++----
.../security/principal/PrincipalMapperTest.java | 2 +-
.../security/impl/CMFKeystoreServiceTest.java | 2 +-
.../security/impl/CMFMasterServiceTest.java | 2 +-
.../security/token/impl/JWTTokenTest.java | 22 +-
.../knox/gateway/util/WhitelistUtilsTest.java | 13 -
.../apache/knox/gateway/SecureClusterTest.java | 40 +--
.../knox/gateway/SecureKnoxShellTest.java | 46 +--
.../java/org/apache/knox/gateway/ShellTest.java | 9 +-
.../knox/gateway/GatewayAdminFuncTest.java | 21 +-
.../gateway/GatewayAdminTopologyFuncTest.java | 129 ++++----
.../apache/knox/gateway/GatewayAppFuncTest.java | 29 +-
.../knox/gateway/GatewayBasicFuncTest.java | 48 +--
.../knox/gateway/GatewayCorrelationIdTest.java | 16 +-
.../knox/gateway/GatewayDeployFuncTest.java | 22 +-
.../knox/gateway/GatewayHealthFuncTest.java | 16 +-
.../gateway/GatewayLocalServiceFuncTest.java | 18 +-
.../knox/gateway/GatewayMultiFuncTest.java | 18 +-
.../knox/gateway/GatewaySampleFuncTest.java | 33 +-
.../apache/knox/gateway/GatewaySslFuncTest.java | 17 +-
.../apache/knox/gateway/GatewayUIFuncTest.java | 28 +-
.../gateway/KnoxCliLdapFuncTestNegative.java | 29 +-
.../gateway/KnoxCliLdapFuncTestPositive.java | 31 +-
.../apache/knox/gateway/KnoxCliSysBindTest.java | 35 +--
.../SimpleDescriptorHandlerFuncTest.java | 6 +-
.../deploy/DeploymentFactoryFuncTest.java | 61 ++--
.../monitor/RemoteConfigurationMonitorTest.java | 31 +-
.../knox/gateway/audit/AuditLayoutTest.java | 6 +-
.../knox/gateway/audit/AuditServiceTest.java | 6 +-
.../knox/gateway/audit/JdbmQueueTest.java | 100 +-----
.../apache/knox/gateway/util/JsonPathTest.java | 13 +-
.../apache/knox/gateway/config/FuncTest.java | 1 +
.../gateway/util/urltemplate/ExpanderTest.java | 3 +
.../gateway/util/urltemplate/MatcherTest.java | 2 -
.../gateway/util/urltemplate/RewriterTest.java | 4 +-
pom.xml | 2 +
125 files changed, 1125 insertions(+), 1810 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/build-tools/src/main/resources/build-tools/pmd/pmd-ruleset.xml
----------------------------------------------------------------------
diff --git a/build-tools/src/main/resources/build-tools/pmd/pmd-ruleset.xml b/build-tools/src/main/resources/build-tools/pmd/pmd-ruleset.xml
index 15c9bc4..2e24c8f 100644
--- a/build-tools/src/main/resources/build-tools/pmd/pmd-ruleset.xml
+++ b/build-tools/src/main/resources/build-tools/pmd/pmd-ruleset.xml
@@ -30,6 +30,9 @@ limitations under the License.
<exclude name="AvoidUsingHardCodedIP" />
<exclude name="ConstantsInInterface" />
<exclude name="GuardLogStatement" />
+ <exclude name="JUnitAssertionsShouldIncludeMessage" />
+ <exclude name="JUnitTestContainsTooManyAsserts" />
+ <exclude name="JUnitTestsShouldIncludeAssert" />
<exclude name="MethodReturnsInternalArray" />
<exclude name="OneDeclarationPerLine" />
<exclude name="PreserveStackTrace" />
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/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 30f9adf..d87e89d 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,6 +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.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assume.assumeTrue;
@@ -36,7 +37,7 @@ public class KnoxPamRealmTest {
public void setService() {
KnoxPamRealm realm = new KnoxPamRealm();
realm.setService("knox-pam-os-service");
- //assertEquals(realm.getService(), "knox-pam-os-service");
+ assertEquals(realm.getService(), "knox-pam-os-service");
}
@Test
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-demo-ldap/src/test/java/org/apache/knox/gateway/security/ldap/SimpleLdapServerTest.java
----------------------------------------------------------------------
diff --git a/gateway-demo-ldap/src/test/java/org/apache/knox/gateway/security/ldap/SimpleLdapServerTest.java b/gateway-demo-ldap/src/test/java/org/apache/knox/gateway/security/ldap/SimpleLdapServerTest.java
index 8f20154..2d1528f 100644
--- a/gateway-demo-ldap/src/test/java/org/apache/knox/gateway/security/ldap/SimpleLdapServerTest.java
+++ b/gateway-demo-ldap/src/test/java/org/apache/knox/gateway/security/ldap/SimpleLdapServerTest.java
@@ -30,17 +30,17 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class SimpleLdapServerTest {
-
private static int port;
private static File ldifFile;
private static TcpTransport ldapTransport;
private static SimpleLdapDirectoryServer ldap;
@BeforeClass
- public static void setup() throws Exception {
+ public static void setUpBeforeClass() throws Exception {
ldifFile = new File( ClassLoader.getSystemResource( "users.ldif" ).toURI() );
ldapTransport = new TcpTransport( 0 );
ldap = new SimpleLdapDirectoryServer( "dc=hadoop,dc=apache,dc=org", ldifFile, ldapTransport );
@@ -49,7 +49,7 @@ public class SimpleLdapServerTest {
}
@AfterClass
- public static void cleanup() throws Exception {
+ public static void tearDownAfterClass() throws Exception {
if( ldap != null ) {
ldap.stop( true );
}
@@ -72,6 +72,9 @@ public class SimpleLdapServerTest {
fail( "Expected LdapAuthenticationException" );
} catch ( LdapAuthenticationException e ) {
// Expected
+ assertEquals("INVALID_CREDENTIALS: Bind failed: ERR_229 " +
+ "Cannot authenticate user uid=nobody,ou=people,dc=hadoop,dc=apache,dc=org",
+ e.getMessage());
} finally {
connection.close();
}
@@ -82,10 +85,11 @@ public class SimpleLdapServerTest {
fail( "Expected LdapAuthenticationException" );
} catch ( LdapAuthenticationException e ) {
// Expected
+ assertEquals("INVALID_CREDENTIALS: Bind failed: ERR_229 " +
+ "Cannot authenticate user uid=guest,ou=people,dc=hadoop,dc=apache,dc=org",
+ e.getMessage());
} finally {
connection.close();
}
-
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java
index ee01e64..0da5a67 100644
--- a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java
+++ b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariConfigurationMonitorTest.java
@@ -39,11 +39,10 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class AmbariConfigurationMonitorTest {
-
private File dataDir;
@Before
- public void setup() throws Exception {
+ public void setUp() throws Exception {
File targetDir = new File( System.getProperty("user.dir"), "target");
File tempDir = new File(targetDir, this.getClass().getName() + "__data__" + UUID.randomUUID());
FileUtils.forceMkdir(tempDir);
@@ -332,5 +331,4 @@ public class AmbariConfigurationMonitorTest {
return null;
}
}
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscoveryTest.java
----------------------------------------------------------------------
diff --git a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscoveryTest.java b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscoveryTest.java
index 6ce77d4..b5b0b1b 100644
--- a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscoveryTest.java
+++ b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariServiceDiscoveryTest.java
@@ -27,9 +27,9 @@ import org.easymock.EasyMock;
import org.junit.Test;
import java.io.File;
-import java.io.FileOutputStream;
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
@@ -68,11 +68,8 @@ public class AmbariServiceDiscoveryTest {
assertEquals(clusterName, cluster.getName());
assertTrue(AmbariCluster.class.isAssignableFrom(cluster.getClass()));
assertEquals(6, ((AmbariCluster) cluster).getComponents().size());
-
-// printServiceURLs(cluster);
}
-
@Test
public void testSingleClusterDiscoveryWithDefaultAddress() throws Exception {
final String discoveryAddress = "http://ambarihost:8080";
@@ -96,7 +93,6 @@ public class AmbariServiceDiscoveryTest {
assertEquals(6, ((AmbariCluster) cluster).getComponents().size());
}
-
@Test
public void testSingleClusterDiscoveryWithDefaultClusterName() throws Exception {
final String discoveryAddress = "http://ambarihost:8080";
@@ -121,7 +117,6 @@ public class AmbariServiceDiscoveryTest {
assertEquals(6, ((AmbariCluster) cluster).getComponents().size());
}
-
@Test
public void testSingleClusterDiscoveryWithDefaultAddressAndClusterName() throws Exception {
final String discoveryAddress = "http://ambarihost:8080";
@@ -145,7 +140,6 @@ public class AmbariServiceDiscoveryTest {
assertEquals(6, ((AmbariCluster) cluster).getComponents().size());
}
-
@Test
public void testSingleClusterDiscoveryWithMissingAddressAndClusterName() throws Exception {
final String clusterName = "testCluster";
@@ -166,7 +160,6 @@ public class AmbariServiceDiscoveryTest {
assertNull(cluster);
}
-
@Test
public void testSingleClusterDiscoveryWithMissingAddress() throws Exception {
final String clusterName = "testCluster";
@@ -184,7 +177,6 @@ public class AmbariServiceDiscoveryTest {
assertNull(cluster);
}
-
@Test
public void testSingleClusterDiscoveryWithMissingClusterName() throws Exception {
final String discoveryAddress = "http://ambarihost:8080";
@@ -204,7 +196,6 @@ public class AmbariServiceDiscoveryTest {
assertNull(cluster);
}
-
@Test
public void testBulkClusterDiscovery() throws Exception {
final String discoveryAddress = "http://ambarihost:8080";
@@ -227,11 +218,8 @@ public class AmbariServiceDiscoveryTest {
assertEquals(clusterName, cluster.getName());
assertTrue(AmbariCluster.class.isAssignableFrom(cluster.getClass()));
assertEquals(6, ((AmbariCluster) cluster).getComponents().size());
-
-// printServiceURLs(cluster, "NAMENODE", "WEBHCAT", "OOZIE", "RESOURCEMANAGER");
}
-
@Test
public void testClusterDiscoveryWithExternalComponentConfigAugmentation() throws Exception {
final String discoveryAddress = "http://ambarihost:8080";
@@ -244,7 +232,7 @@ public class AmbariServiceDiscoveryTest {
Properties compConfOverrideProps = new Properties();
compConfOverrideProps.setProperty("DISCOVERY_TEST", "test-site");
File compConfOverrides = File.createTempFile(getClass().getName()+"component-conf-overrides", ".properties");
- compConfOverrideProps.store(new FileOutputStream(compConfOverrides), "Test Config Overrides");
+ compConfOverrideProps.store(Files.newOutputStream(compConfOverrides.toPath()), "Test Config Overrides");
System.setProperty(AmbariServiceDiscovery.COMPONENT_CONFIG_MAPPING_SYSTEM_PROPERTY,
compConfOverrides.getAbsolutePath());
@@ -301,35 +289,6 @@ public class AmbariServiceDiscoveryTest {
}
}
-
- private static void printServiceURLs(ServiceDiscovery.Cluster cluster) {
- final String[] services = new String[]{"NAMENODE",
- "JOBTRACKER",
- "WEBHDFS",
- "WEBHCAT",
- "OOZIE",
- "WEBHBASE",
- "HIVE",
- "RESOURCEMANAGER"};
- printServiceURLs(cluster, services);
- }
-
-
- private static void printServiceURLs(ServiceDiscovery.Cluster cluster, String...services) {
- for (String name : services) {
- StringBuilder sb = new StringBuilder();
- List<String> urls = cluster.getServiceURLs(name);
- if (urls != null && !urls.isEmpty()) {
- for (String url : urls) {
- sb.append(url);
- sb.append(" ");
- }
- }
- System.out.println(String.format(Locale.ROOT, "%18s: %s", name, sb.toString()));
- }
- }
-
-
/**
* ServiceDiscovery implementation derived from AmbariServiceDiscovery, so the invokeREST method can be overridden
* to eliminate the need to perform actual HTTP interactions with a real Ambari endpoint.
@@ -356,7 +315,6 @@ public class AmbariServiceDiscoveryTest {
//
}
}
-
}
private static final class TestRESTInvoker extends RESTInvoker {
@@ -386,7 +344,6 @@ public class AmbariServiceDiscoveryTest {
}
}
-
////////////////////////////////////////////////////////////////////////
// JSON response templates, based on actual response content excerpts
////////////////////////////////////////////////////////////////////////
@@ -746,7 +703,7 @@ public class AmbariServiceDiscoveryTest {
" },\n" +
" \"components\" : [\n" +
" {\n" +
- " \"href\" : \"http://c6401.ambari.apache.org:8080/api/v1/clusters/"+TestAmbariServiceDiscovery.CLUSTER_PLACEHOLDER+""+TestAmbariServiceDiscovery.CLUSTER_PLACEHOLDER+"/services/ZOOKEEPER/components/ZOOKEEPER_SERVER\",\n" +
+ " \"href\" : \"http://c6401.ambari.apache.org:8080/api/v1/clusters/"+TestAmbariServiceDiscovery.CLUSTER_PLACEHOLDER+TestAmbariServiceDiscovery.CLUSTER_PLACEHOLDER+"/services/ZOOKEEPER/components/ZOOKEEPER_SERVER\",\n" +
" \"ServiceComponentInfo\" : {\n" +
" \"cluster_name\" : \""+TestAmbariServiceDiscovery.CLUSTER_PLACEHOLDER+"\",\n" +
" \"component_name\" : \"ZOOKEEPER_SERVER\",\n" +
@@ -1151,6 +1108,4 @@ public class AmbariServiceDiscoveryTest {
" }\n" +
" ]\n" +
"}";
-
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesSubject.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesSubject.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesSubject.java
new file mode 100644
index 0000000..54bdd16
--- /dev/null
+++ b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesSubject.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.gateway.i18n.messages;
+
+@Messages( bundle="some.bundle.name", logger="some.logger.name", codes="ID:{0}" )
+public interface MessagesSubject {
+ @Message(level= MessageLevel.ERROR, code=3, text="p0={0}" )
+ void withFullAnnotationAndParameter( int x );
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTest.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTest.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTest.java
index dc252b6..bf14cd2 100644
--- a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTest.java
+++ b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTest.java
@@ -31,10 +31,9 @@ import static org.junit.Assert.assertThat;
@Category( { UnitTests.class, FastTests.class } )
public class MessagesTest {
-
@Test
public void testFirst() {
- MessagesTestSubject log = MessagesFactory.get( MessagesTestSubject.class );
+ MessagesSubject log = MessagesFactory.get( MessagesSubject.class );
log.withFullAnnotationAndParameter( 7 );
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTestSubject.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTestSubject.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTestSubject.java
deleted file mode 100644
index 8bb985f..0000000
--- a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/messages/MessagesTestSubject.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.knox.gateway.i18n.messages;
-
-@Messages( bundle="some.bundle.name", logger="some.logger.name", codes="ID:{0}" )
-public interface MessagesTestSubject {
-
- @Message(level= MessageLevel.ERROR, code=3, text="p0={0}" )
- void withFullAnnotationAndParameter( int x );
-
- @Message(level= MessageLevel.INFO, code=42, text="str={0}, t={1}" )
- void withEverything( String str, @StackTrace(level= MessageLevel.INFO) Throwable t );
-
- @Message
- void withoutParams();
-
- void withoutAnnotations( int x );
-
- @Message
- void withoutStackTrace( Throwable t );
-
- @Message
- void withMismatchedText();
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesFormattingSubject.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesFormattingSubject.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesFormattingSubject.java
new file mode 100644
index 0000000..d95382d
--- /dev/null
+++ b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesFormattingSubject.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.gateway.i18n.resources;
+
+@Resources( bundle="some.bundle.name" )
+public interface ResourcesFormattingSubject {
+ @Resource(text="{0}")
+ String withAnnotationWithSimplePatternOneParam( int x );
+
+ @Resource(text="before{0}after")
+ String withAnnotationWithPatternOneParam( int x );
+
+ @Resource
+ String withAnnotationWithoutPatternOneParam( int x );
+
+ String withoutAnnotationsOrParameters();
+
+ String withoutAnnotationsWithOneParam( int x );
+
+ String withoutAnnotationsWithElevenParams( String p1, String p2, String p3, String p4, String p5, String p6, String p7, String p8, String p9, String p10, String p11 );
+
+ @Resource(text="{0},{1}")
+ String withMoreFormatParamsThanMethodParams( int x );
+
+ @Resource(text="{0}")
+ String withLessFormatParamsThanMethodParams( int x, int y );
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject.java
new file mode 100644
index 0000000..5772506
--- /dev/null
+++ b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.gateway.i18n.resources;
+
+@Resources
+public interface ResourcesLocaleSubject {
+ @Resource(text="default=[{0}]")
+ String testResource( String param );
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesNamedSubject.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesNamedSubject.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesNamedSubject.java
new file mode 100644
index 0000000..0fb65fb
--- /dev/null
+++ b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesNamedSubject.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.knox.gateway.i18n.resources;
+
+@Resources( bundle="org.apache.knox.gateway.i18n.resources.NamedBundle" )
+public interface ResourcesNamedSubject {
+ @Resource(text="default=[{0}]")
+ String testResource( String param );
+}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTest.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTest.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTest.java
index 7696266..585b903 100644
--- a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTest.java
+++ b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTest.java
@@ -31,23 +31,21 @@ import static org.junit.Assert.assertThat;
@Category( { UnitTests.class, FastTests.class } )
public class ResourcesTest {
-
private Locale locale;
@Before
- public void setup() {
+ public void setUp() {
locale = Locale.getDefault();
}
@After
- public void cleanup() {
+ public void tearDown() {
Locale.setDefault( locale );
}
@Test
public void testResourceFormatting() {
-
- ResourcesTestFormattingSubject res = ResourcesFactory.get( ResourcesTestFormattingSubject.class );
+ ResourcesFormattingSubject res = ResourcesFactory.get( ResourcesFormattingSubject.class );
assertThat(
res.withoutAnnotationsOrParameters(),
@@ -84,8 +82,7 @@ public class ResourcesTest {
@Test
public void testResourceLocales() {
-
- ResourcesTestLocaleSubject res = ResourcesFactory.get( ResourcesTestLocaleSubject.class );
+ ResourcesLocaleSubject res = ResourcesFactory.get( ResourcesLocaleSubject.class );
Locale.setDefault( Locale.CHINESE ); // Change to something that we won't have test bundles for.
assertThat( res.testResource( "queryParam" ), equalTo( "default=[queryParam]" ) );
@@ -98,21 +95,16 @@ public class ResourcesTest {
Locale.setDefault( Locale.UK );
assertThat( res.testResource( "queryParam" ), equalTo( "uk=[queryParam]" ) );
-
}
@Test
public void testNamedBundle() {
-
- ResourcesTestNamedSubject res = ResourcesFactory.get( ResourcesTestNamedSubject.class );
+ ResourcesNamedSubject res = ResourcesFactory.get( ResourcesNamedSubject.class );
Locale.setDefault( Locale.CHINESE ); // Change to something that we won't have test bundles for.
assertThat( res.testResource( "queryParam" ), equalTo( "default=[queryParam]" ) );
Locale.setDefault( Locale.CANADA );
assertThat( res.testResource( "queryParam" ), equalTo( "ca=[queryParam]" ) );
-
}
-
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestFormattingSubject.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestFormattingSubject.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestFormattingSubject.java
deleted file mode 100644
index 655d847..0000000
--- a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestFormattingSubject.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.knox.gateway.i18n.resources;
-
-@Resources( bundle="some.bundle.name" )
-public interface ResourcesTestFormattingSubject {
-
- @Resource(text="{0}")
- String withAnnotationWithSimplePatternOneParam( int x );
-
- @Resource(text="before{0}after")
- String withAnnotationWithPatternOneParam( int x );
-
- @Resource
- String withAnnotationWithoutPatternOneParam( int x );
-
- String withoutAnnotationsOrParameters();
-
- String withoutAnnotationsWithOneParam( int x );
-
- String withoutAnnotationsWithElevenParams( String p1, String p2, String p3, String p4, String p5, String p6, String p7, String p8, String p9, String p10, String p11 );
-
- @Resource(text="{0},{1}")
- String withMoreFormatParamsThanMethodParams( int x );
-
- @Resource(text="{0}")
- String withLessFormatParamsThanMethodParams( int x, int y );
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject.java
deleted file mode 100644
index 60ed856..0000000
--- a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.knox.gateway.i18n.resources;
-
-@Resources
-public interface ResourcesTestLocaleSubject {
-
- @Resource(text="default=[{0}]")
- String testResource( String param );
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestNamedSubject.java
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestNamedSubject.java b/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestNamedSubject.java
deleted file mode 100644
index c6062c3..0000000
--- a/gateway-i18n/src/test/java/org/apache/knox/gateway/i18n/resources/ResourcesTestNamedSubject.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.knox.gateway.i18n.resources;
-
-@Resources( bundle="org.apache.knox.gateway.i18n.resources.NamedBundle" )
-public interface ResourcesTestNamedSubject {
-
- @Resource(text="default=[{0}]")
- String testResource( String param );
-
-}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject.properties
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject.properties b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject.properties
new file mode 100644
index 0000000..6acb5d1
--- /dev/null
+++ b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject.properties
@@ -0,0 +1,14 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en.properties
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en.properties b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en.properties
new file mode 100644
index 0000000..f5cf5e0
--- /dev/null
+++ b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en.properties
@@ -0,0 +1,19 @@
+##########################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+
+testResource=en=[{0}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en_GB.properties
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en_GB.properties b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en_GB.properties
new file mode 100644
index 0000000..64cc4bf
--- /dev/null
+++ b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en_GB.properties
@@ -0,0 +1,19 @@
+##########################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+
+testResource=uk=[{0}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en_US.properties
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en_US.properties b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en_US.properties
new file mode 100644
index 0000000..d9a3cb7
--- /dev/null
+++ b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesLocaleSubject_en_US.properties
@@ -0,0 +1,19 @@
+##########################################################################
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##########################################################################
+
+testResource=us=[{0}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject.properties
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject.properties b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject.properties
deleted file mode 100644
index 6acb5d1..0000000
--- a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en.properties
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en.properties b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en.properties
deleted file mode 100644
index f5cf5e0..0000000
--- a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-##########################################################################
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##########################################################################
-
-testResource=en=[{0}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en_GB.properties
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en_GB.properties b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en_GB.properties
deleted file mode 100644
index 64cc4bf..0000000
--- a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en_GB.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-##########################################################################
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##########################################################################
-
-testResource=uk=[{0}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en_US.properties
----------------------------------------------------------------------
diff --git a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en_US.properties b/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en_US.properties
deleted file mode 100644
index d9a3cb7..0000000
--- a/gateway-i18n/src/test/resources/org/apache/knox/gateway/i18n/resources/ResourcesTestLocaleSubject_en_US.properties
+++ /dev/null
@@ -1,19 +0,0 @@
-##########################################################################
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-##########################################################################
-
-testResource=us=[{0}]
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/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 e3f3ba4..28a8f14 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
@@ -304,50 +304,50 @@ public class HaProviderDeploymentContributorTest {
String zooKeeperEnsemble) {
StringBuilder builder = new StringBuilder();
- builder.append(HaServiceConfigConstants.CONFIG_PARAM_ENABLED);
- builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
- builder.append(enabled);
+ builder.append(HaServiceConfigConstants.CONFIG_PARAM_ENABLED)
+ .append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER)
+ .append(enabled);
if (maxRetryAttempts > -1) {
- builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
- builder.append(HaServiceConfigConstants.CONFIG_PARAM_MAX_RETRY_ATTEMPTS);
- builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
- builder.append(maxRetryAttempts);
+ builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER)
+ .append(HaServiceConfigConstants.CONFIG_PARAM_MAX_RETRY_ATTEMPTS)
+ .append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER)
+ .append(maxRetryAttempts);
}
if (retrySleep > -1) {
- builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
- builder.append(HaServiceConfigConstants.CONFIG_PARAM_RETRY_SLEEP);
- builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
- builder.append(retrySleep);
+ builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER)
+ .append(HaServiceConfigConstants.CONFIG_PARAM_RETRY_SLEEP)
+ .append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER)
+ .append(retrySleep);
}
if (maxFailoverAttempts > -1) {
- builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
- builder.append(HaServiceConfigConstants.CONFIG_PARAM_MAX_FAILOVER_ATTEMPTS);
- builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
- builder.append(maxFailoverAttempts);
+ builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER)
+ .append(HaServiceConfigConstants.CONFIG_PARAM_MAX_FAILOVER_ATTEMPTS)
+ .append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER)
+ .append(maxFailoverAttempts);
}
if (failoverSleep > -1) {
- builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
- builder.append(HaServiceConfigConstants.CONFIG_PARAM_FAILOVER_SLEEP);
- builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
- builder.append(failoverSleep);
+ builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER)
+ .append(HaServiceConfigConstants.CONFIG_PARAM_FAILOVER_SLEEP)
+ .append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER)
+ .append(failoverSleep);
}
if (zooKeeperNamespace != null) {
- builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
- builder.append(HaServiceConfigConstants.CONFIG_PARAM_ZOOKEEPER_NAMESPACE);
- builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
- builder.append(zooKeeperNamespace);
+ builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER)
+ .append(HaServiceConfigConstants.CONFIG_PARAM_ZOOKEEPER_NAMESPACE)
+ .append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER)
+ .append(zooKeeperNamespace);
}
if (zooKeeperEnsemble != null) {
- builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER);
- builder.append(HaServiceConfigConstants.CONFIG_PARAM_ZOOKEEPER_ENSEMBLE);
- builder.append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER);
- builder.append(zooKeeperEnsemble);
+ builder.append(HaServiceConfigConstants.CONFIG_PAIRS_DELIMITER)
+ .append(HaServiceConfigConstants.CONFIG_PARAM_ZOOKEEPER_ENSEMBLE)
+ .append(HaServiceConfigConstants.CONFIG_PAIR_DELIMITER)
+ .append(zooKeeperEnsemble);
}
return builder.toString();
@@ -451,6 +451,5 @@ public class HaProviderDeploymentContributorTest {
public <T> T getDescriptor(String name) {
return (T)descriptors.get(name);
}
-
}
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
index 1ee54e9..2cb00ce 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/AtlasZookeeperURLManagerTest.java
@@ -46,7 +46,7 @@ public class AtlasZookeeperURLManagerTest {
private static String atlasNode2 = "http://atlas.node2:21000";
@Before
- public void setup() throws Exception {
+ public void setUp() throws Exception {
cluster = new TestingCluster(3);
cluster.start();
@@ -74,7 +74,7 @@ public class AtlasZookeeperURLManagerTest {
}
@After
- public void teardown() throws IOException {
+ public void tearDown() throws IOException {
if(cluster != null) {
cluster.close();
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java
index b5b2a3f..71b3abc 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/DefaultHaProviderTest.java
@@ -40,6 +40,7 @@ public class DefaultHaProviderTest {
fail("provider construction should have failed with null descriptor");
} catch (IllegalArgumentException e) {
// Expected exception
+ assertEquals("Descriptor can not be null", e.getMessage());
}
HaDescriptor descriptor = new DefaultHaDescriptor();
HaProvider provider = new DefaultHaProvider(descriptor);
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/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 8858614..c35f5b6 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
@@ -48,13 +48,13 @@ public class HBaseZookeeperURLManagerTest {
private TestingCluster cluster;
@Before
- public void setup() throws Exception {
+ public void setUp() throws Exception {
cluster = new TestingCluster(3);
cluster.start();
}
@After
- public void teardown() throws IOException {
+ public void tearDown() throws IOException {
if(cluster != null) {
cluster.close();
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManagerTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManagerTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManagerTest.java
index dcdb926..77b17b0 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManagerTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HS2ZookeeperURLManagerTest.java
@@ -38,12 +38,11 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class HS2ZookeeperURLManagerTest {
-
private TestingCluster cluster;
private HS2ZookeeperURLManager manager;
@Before
- public void setup() throws Exception {
+ public void setUp() throws Exception {
cluster = new TestingCluster(3);
cluster.start();
@@ -77,7 +76,7 @@ public class HS2ZookeeperURLManagerTest {
}
@After
- public void teardown() throws IOException {
+ public void tearDown() throws IOException {
if(cluster != null) {
cluster.close();
}
@@ -133,6 +132,4 @@ public class HS2ZookeeperURLManagerTest {
Assert.assertNotNull(manager);
assertTrue(manager instanceof HS2ZookeeperURLManager);
}
-
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManagerTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManagerTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManagerTest.java
index f200217..18c3f3a 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManagerTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/HaDescriptorManagerTest.java
@@ -35,7 +35,6 @@ import static org.xmlmatchers.XmlMatchers.hasXPath;
import static org.xmlmatchers.transform.XmlConverters.the;
public class HaDescriptorManagerTest {
-
@Test
public void testDescriptorLoad() throws IOException {
String xml = "<ha><service name='foo' maxFailoverAttempts='42' failoverSleep='4000' maxRetryAttempts='2' retrySleep='2213' enabled='false'/>" +
@@ -80,7 +79,6 @@ public class HaDescriptorManagerTest {
descriptor.addServiceConfig(HaDescriptorFactory.createServiceConfig("bar", "true", "3", "5000", "5", "8000", null, null));
StringWriter writer = new StringWriter();
HaDescriptorManager.store(descriptor, writer);
- String descriptorXml = writer.toString();
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
"<ha>\n" +
" <service enabled=\"false\" failoverSleep=\"1000\" maxFailoverAttempts=\"42\" maxRetryAttempts=\"3\" name=\"foo\" retrySleep=\"3000\" zookeeperEnsemble=\"foo:2181,bar:2181\" zookeeperNamespace=\"hiveserver2\"/>\n" +
@@ -89,6 +87,4 @@ public class HaDescriptorManagerTest {
assertThat( the( xml ), hasXPath( "/ha/service[@enabled='false' and @failoverSleep='1000' and @maxFailoverAttempts='42' and @maxRetryAttempts='3' and @name='foo' and @retrySleep='3000' and @zookeeperEnsemble='foo:2181,bar:2181' and @zookeeperNamespace='hiveserver2']" ) );
assertThat( the( xml ), hasXPath( "/ha/service[@enabled='true' and @failoverSleep='5000' and @maxFailoverAttempts='3' and @maxRetryAttempts='5' and @name='bar' and @retrySleep='8000']" ) );
}
-
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManagerTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManagerTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManagerTest.java
index 30367c6..50a0f7d 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManagerTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/KafkaZookeeperURLManagerTest.java
@@ -43,7 +43,7 @@ public class KafkaZookeeperURLManagerTest {
private TestingCluster cluster;
@Before
- public void setup() throws Exception {
+ public void setUp() throws Exception {
cluster = new TestingCluster(3);
cluster.start();
@@ -59,7 +59,7 @@ public class KafkaZookeeperURLManagerTest {
}
@After
- public void teardown() throws IOException {
+ public void tearDown() throws IOException {
if(cluster != null) {
cluster.close();
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManagerTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManagerTest.java b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManagerTest.java
index 637fdab..aea7acd 100644
--- a/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManagerTest.java
+++ b/gateway-provider-ha/src/test/java/org/apache/knox/gateway/ha/provider/impl/SOLRZookeeperURLManagerTest.java
@@ -43,12 +43,11 @@ import static org.junit.Assert.assertTrue;
* @see SOLRZookeeperURLManager
*/
public class SOLRZookeeperURLManagerTest {
-
private TestingCluster cluster;
private SOLRZookeeperURLManager manager;
@Before
- public void setup() throws Exception {
+ public void setUp() throws Exception {
cluster = new TestingCluster(3);
cluster.start();
@@ -71,7 +70,7 @@ public class SOLRZookeeperURLManagerTest {
}
@After
- public void teardown() throws IOException {
+ public void tearDown() throws IOException {
if(cluster != null) {
cluster.close();
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/CommonIdentityAssertionFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/CommonIdentityAssertionFilterTest.java b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/CommonIdentityAssertionFilterTest.java
index ccc7936..15f41c0 100644
--- a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/CommonIdentityAssertionFilterTest.java
+++ b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/CommonIdentityAssertionFilterTest.java
@@ -34,7 +34,6 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
-import java.net.URISyntaxException;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.Locale;
@@ -47,13 +46,12 @@ import static org.junit.Assert.assertTrue;
*
*/
public class CommonIdentityAssertionFilterTest {
-
private String username;
private String[] mappedGroups;
private Filter filter;
@Before
- public void setup() {
+ public void setUp() {
filter = new CommonIdentityAssertionFilter() {
@Override
public String mapUserPrincipal(String principalName) {
@@ -76,9 +74,7 @@ public class CommonIdentityAssertionFilterTest {
}
@Test
- public void testSimpleFilter() throws ServletException, IOException,
- URISyntaxException {
-
+ public void testSimpleFilter() throws ServletException, IOException {
FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
EasyMock.replay( config );
@@ -127,5 +123,4 @@ public class CommonIdentityAssertionFilterTest {
assertTrue(mappedGroups[0].equals("USERS") || mappedGroups[0].equals("ADMIN"));
assertTrue(mappedGroups[1], mappedGroups[1].equals("USERS") || mappedGroups[1].equals("ADMIN"));
}
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
index 4ff9efb..4595e85 100644
--- a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
+++ b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/filter/IdentityAssertionHttpServletRequestWrapperTest.java
@@ -62,7 +62,6 @@ public class IdentityAssertionHttpServletRequestWrapperTest {
IdentityAsserterHttpServletRequestWrapper wrapper
= new IdentityAsserterHttpServletRequestWrapper( request, "output-user" );
- String outputBody = IOUtils.toString( wrapper.getInputStream(), wrapper.getCharacterEncoding() );
String output = wrapper.getQueryString();
assertThat( output, containsString( "user.name=output-user" ) );
}
@@ -79,7 +78,6 @@ public class IdentityAssertionHttpServletRequestWrapperTest {
IdentityAsserterHttpServletRequestWrapper wrapper
= new IdentityAsserterHttpServletRequestWrapper( request, "output-user" );
- String outputBody = IOUtils.toString( wrapper.getInputStream(), wrapper.getCharacterEncoding() );
String output = wrapper.getQueryString();
assertThat( output, containsString( "user.name=output-user" ) );
}
@@ -97,7 +95,6 @@ public class IdentityAssertionHttpServletRequestWrapperTest {
IdentityAsserterHttpServletRequestWrapper wrapper
= new IdentityAsserterHttpServletRequestWrapper( request, "output-user" );
- String outputBody = IOUtils.toString( wrapper.getInputStream(), wrapper.getCharacterEncoding() );
String output = wrapper.getQueryString();
assertThat( output, containsString( "user.name=output-user" ) );
}
@@ -115,7 +112,6 @@ public class IdentityAssertionHttpServletRequestWrapperTest {
IdentityAsserterHttpServletRequestWrapper wrapper
= new IdentityAsserterHttpServletRequestWrapper( request, "output-user" );
- String outputBody = IOUtils.toString( wrapper.getInputStream(), wrapper.getCharacterEncoding() );
String output = wrapper.getQueryString();
assertThat( output, containsString( "user.name=output-user" ) );
assertThat( output, not( containsString( "input-user" ) ) );
@@ -275,5 +271,4 @@ public class IdentityAssertionHttpServletRequestWrapperTest {
s = IdentityAsserterHttpServletRequestWrapper.urlEncode( m, StandardCharsets.UTF_8.name() );
assertThat( s, is( "two-values=value1&two-values=value2" ) );
}
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
index 3d9876b..d8e17c4 100644
--- a/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
+++ b/gateway-provider-identity-assertion-common/src/test/java/org/apache/knox/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
@@ -67,7 +67,6 @@ import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.Assert.fail;
public class UsernameFunctionProcessorTest {
-
private ServletTester server;
private HttpTester.Request request;
private HttpTester.Response response;
@@ -79,7 +78,7 @@ public class UsernameFunctionProcessorTest {
return ClassLoader.getSystemResource( name );
}
- public void setUp( String username, Map<String,String> initParams ) throws Exception {
+ private void testSetup(String username, Map<String,String> initParams ) throws Exception {
String descriptorUrl = getTestResource( "rewrite.xml" ).toExternalForm();
Log.setLog( new NoOpLogger() );
@@ -166,7 +165,7 @@ public class UsernameFunctionProcessorTest {
public void testRequestUrlRewriteOfUsernameViaRewriteRule() throws Exception {
Map<String,String> initParams = new HashMap<>();
initParams.put( "request.url", "test-rule-username" );
- setUp( "test-user", initParams );
+ testSetup( "test-user", initParams );
String input = "<root/>";
String expect = "<root/>";
@@ -213,7 +212,7 @@ public class UsernameFunctionProcessorTest {
StringBuffer sourceUrl = httpRequest.getRequestURL();
String queryString = httpRequest.getQueryString();
if( queryString != null ) {
- sourceUrl.append( "?" );
+ sourceUrl.append( '?' );
sourceUrl.append( queryString );
}
try {
@@ -240,5 +239,4 @@ public class UsernameFunctionProcessorTest {
public void destroy() {
}
}
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java b/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java
index 72d4606..ae9faeb 100644
--- a/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java
+++ b/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/knox/gateway/identityasserter/filter/DefaultIdentityAssertionFilterTest.java
@@ -92,7 +92,9 @@ public class DefaultIdentityAssertionFilterTest {
}
private boolean groupFoundIn(String expected, String[] mappedGroups) {
- if (mappedGroups == null) return false;
+ if (mappedGroups == null) {
+ return false;
+ }
for (String mappedGroup : mappedGroups) {
if (mappedGroup.equals(expected)) {
return true;
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java b/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
index f3084c6..0981a0f 100644
--- a/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
+++ b/gateway-provider-rewrite-func-inbound-query-param/src/test/java/org/apache/knox/gateway/inboundurl/impl/InboundUrlFunctionProcessorTest.java
@@ -79,8 +79,9 @@ public class InboundUrlFunctionProcessorTest {
proc = (InboundUrlFunctionProcessor) object ;
}
}
- if( proc == null )
- fail( "Failed to find " + InboundUrlFunctionProcessor.class.getName() + " via service loader." );
+ if( proc == null ) {
+ fail("Failed to find " + InboundUrlFunctionProcessor.class.getName() + " via service loader.");
+ }
Map<String,UrlRewriteFunctionProcessor> functions = new HashMap<>();
UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
@@ -116,7 +117,6 @@ public class InboundUrlFunctionProcessorTest {
return new UrlRewriteResponse( config, request, response );
}
-
@Test
public void testQueryParam() throws Exception {
GatewayServices gatewayServices = EasyMock.createNiceMock( GatewayServices.class );
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
index b014589..ad8be10 100644
--- a/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
+++ b/gateway-provider-rewrite-func-service-registry/src/test/java/org/apache/knox/gateway/svcregfunc/impl/ServiceRegistryFunctionsTest.java
@@ -60,9 +60,7 @@ import java.util.Queue;
import static org.hamcrest.MatcherAssert.assertThat;
-
public class ServiceRegistryFunctionsTest {
-
private ServletTester server;
private HttpTester.Request request;
private HttpTester.Response response;
@@ -74,7 +72,7 @@ public class ServiceRegistryFunctionsTest {
return ClassLoader.getSystemResource( name );
}
- public void setUp( String username, Map<String,String> initParams ) throws Exception {
+ private void testSetup(String username, Map<String,String> initParams ) throws Exception {
ServiceRegistry mockServiceRegistry = EasyMock.createNiceMock( ServiceRegistry.class );
EasyMock.expect( mockServiceRegistry.lookupServiceURL( "test-cluster", "NAMENODE" ) ).andReturn( "test-nn-scheme://test-nn-host:411" ).anyTimes();
EasyMock.expect( mockServiceRegistry.lookupServiceURL( "test-cluster", "JOBTRACKER" ) ).andReturn( "test-jt-scheme://test-jt-host:511" ).anyTimes();
@@ -122,7 +120,7 @@ public class ServiceRegistryFunctionsTest {
public void testServiceRegistryFunctionsOnXmlRequestBody() throws Exception {
Map<String,String> initParams = new HashMap<>();
initParams.put( "request.body", "oozie-conf" );
- setUp( "test-user", initParams );
+ testSetup( "test-user", initParams );
String input = TestUtils.getResourceString( ServiceRegistryFunctionsTest.class, "test-input-body.xml", StandardCharsets.UTF_8 );
String expect = TestUtils.getResourceString( ServiceRegistryFunctionsTest.class, "test-expect-body.xml", StandardCharsets.UTF_8 );
@@ -154,7 +152,7 @@ public class ServiceRegistryFunctionsTest {
public void testServiceRegistryFunctionsOnJsonRequestBody() throws Exception {
Map<String,String> initParams = new HashMap<>();
initParams.put( "request.body", "oozie-conf" );
- setUp( "test-user", initParams );
+ testSetup( "test-user", initParams );
String input = TestUtils.getResourceString( ServiceRegistryFunctionsTest.class, "test-input-body.json", StandardCharsets.UTF_8 );
String expect = TestUtils.getResourceString( ServiceRegistryFunctionsTest.class, "test-expect-body.json", StandardCharsets.UTF_8 );
@@ -200,7 +198,7 @@ public class ServiceRegistryFunctionsTest {
StringBuffer sourceUrl = httpRequest.getRequestURL();
String queryString = httpRequest.getQueryString();
if( queryString != null ) {
- sourceUrl.append( "?" );
+ sourceUrl.append( '?' );
sourceUrl.append( queryString );
}
try {
@@ -227,5 +225,4 @@ public class ServiceRegistryFunctionsTest {
public void destroy() {
}
}
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteRulesDescriptorFactoryTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteRulesDescriptorFactoryTest.java b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteRulesDescriptorFactoryTest.java
index 7692df5..c8669d0 100644
--- a/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteRulesDescriptorFactoryTest.java
+++ b/gateway-provider-rewrite/src/test/java/org/apache/knox/gateway/filter/rewrite/api/UrlRewriteRulesDescriptorFactoryTest.java
@@ -40,6 +40,8 @@ import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.CoreMatchers.sameInstance;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail;
import static org.xmlmatchers.XmlMatchers.hasXPath;
@@ -47,7 +49,7 @@ import static org.xmlmatchers.XmlMatchers.hasXPath;
public class UrlRewriteRulesDescriptorFactoryTest {
@Test
- public void testCreate() throws Exception {
+ public void testCreate() {
UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
assertThat( descriptor, notNullValue() );
assertThat( descriptor.getRules(), notNullValue() );
@@ -62,6 +64,7 @@ public class UrlRewriteRulesDescriptorFactoryTest {
assertThat( descriptor.getRule( "first" ), sameInstance( rule ) );
rule = descriptor.addRule( "second" );
+ assertNotNull(rule);
assertThat( descriptor.getRules().size(), is( 2 ) );
}
@@ -94,7 +97,7 @@ public class UrlRewriteRulesDescriptorFactoryTest {
}
@Test
- public void testLoadEmptyFile() throws IOException {
+ public void testLoadEmptyFile() {
Logger logger = org.apache.log4j.LogManager.getLogger( "org.apache.commons.digester3.Digester" );
Level level = logger.getLevel();
try {
@@ -103,6 +106,9 @@ public class UrlRewriteRulesDescriptorFactoryTest {
fail( "Should have thrown an IOException." );
} catch ( IOException e ) {
// Expected.
+ assertEquals("org.xml.sax.SAXParseException; lineNumber: 16; " +
+ "columnNumber: 4; Premature end of file.",
+ e.getMessage());
} catch ( Throwable t ) {
fail( "Should have thrown an IOException." );
} finally {
@@ -111,7 +117,7 @@ public class UrlRewriteRulesDescriptorFactoryTest {
}
@Test
- public void testLoadInvalidFile() throws IOException {
+ public void testLoadInvalidFile() {
Logger logger = org.apache.log4j.LogManager.getLogger( "org.apache.commons.digester3.Digester" );
Level level = logger.getLevel();
try {
@@ -120,6 +126,9 @@ public class UrlRewriteRulesDescriptorFactoryTest {
fail( "Should have thrown an IOException." );
} catch ( IOException e ) {
// Expected.
+ assertEquals("org.xml.sax.SAXParseException; lineNumber: 18; columnNumber: 2; " +
+ "The markup in the document preceding the root element must be well-formed.",
+ e.getMessage());
} catch ( Throwable t ) {
fail( "Should have thrown an IOException." );
} finally {
@@ -247,7 +256,5 @@ public class UrlRewriteRulesDescriptorFactoryTest {
assertThat( xml, hasXPath( "/rules/filter/content/buffer/detect/apply" ) );
assertThat( xml, hasXPath( "/rules/filter/content/buffer/detect/apply/@path", equalTo( "test-apply-path-4" ) ) );
assertThat( xml, hasXPath( "/rules/filter/content/buffer/detect/apply/@rule", equalTo( "test-apply-rule-4" ) ) );
-
}
-
}
http://git-wip-us.apache.org/repos/asf/knox/blob/89caa5fe/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 2c067bc..8d65d7f 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
@@ -21,7 +21,6 @@ import org.apache.knox.test.mock.MockInteraction;
import org.apache.knox.test.mock.MockServlet;
import org.eclipse.jetty.servlet.FilterHolder;
import org.eclipse.jetty.servlet.ServletHolder;
-import org.eclipse.jetty.http.HttpTester;
import org.eclipse.jetty.servlet.ServletTester;
import org.junit.After;
import org.junit.Before;
@@ -33,12 +32,8 @@ import java.util.EnumSet;
import java.util.Queue;
public class UrlRewriteServletContextListenerTest {
-
private ServletTester server;
- private HttpTester.Request request;
- private HttpTester.Response response;
private Queue<MockInteraction> interactions;
- private MockInteraction interaction;
private static URL getTestResource( String name ) {
name = UrlRewriteServletFilterTest.class.getName().replaceAll( "\\.", "/" ) + "/" + name;
@@ -67,10 +62,6 @@ public class UrlRewriteServletContextListenerTest {
getTestResource( "rewrite.xml" ).toExternalForm() );
server.start();
-
- interaction = new MockInteraction();
- request = HttpTester.newRequest();
- response = null;
}
@After