[14/16] knox git commit: Merge branch 'master' into KNOX-998-Package_Restructuring

2018-01-09 Thread more
http://git-wip-us.apache.org/repos/asf/knox/blob/e5fd0622/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java
--
diff --cc 
gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java
index f015dd5,000..c0b1de8
mode 100644,00..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
@@@ -1,876 -1,0 +1,920 @@@
 +/**
 + * 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.topology.discovery.ambari;
 +
 +import org.apache.commons.io.FileUtils;
 +import org.easymock.EasyMock;
 +import org.junit.Test;
 +
 +import java.io.File;
 +import java.net.MalformedURLException;
 +import java.net.URI;
 +import java.net.URISyntaxException;
 +import java.util.Arrays;
 +import java.util.Collections;
 +import java.util.HashMap;
 +import java.util.LinkedList;
 +import java.util.List;
 +import java.util.Map;
 +
 +import static junit.framework.TestCase.assertTrue;
 +import static junit.framework.TestCase.fail;
 +import static org.junit.Assert.assertEquals;
++import static org.junit.Assert.assertFalse;
 +import static org.junit.Assert.assertNotNull;
 +
 +
 +public class AmbariDynamicServiceURLCreatorTest {
 +
 +@Test
 +public void testHiveURLFromInternalMapping() throws Exception {
 +testHiveURL(null);
 +}
 +
 +@Test
 +public void testHiveURLFromExternalMapping() throws Exception {
 +testHiveURL(TEST_MAPPING_CONFIG);
 +}
 +
 +private void testHiveURL(Object mappingConfiguration) throws Exception {
 +
 +final String   SERVICE_NAME = "HIVE";
 +final String[] HOSTNAMES= {"host3", "host2", "host4"};
 +final String   HTTP_PATH= "cliservice";
 +final String   HTTP_PORT= "10001";
 +final String   BINARY_PORT  = "1";
 +
 +String expectedScheme = "http";
 +
 +final List hiveServerHosts = Arrays.asList(HOSTNAMES);
 +
 +AmbariComponent hiveServer = 
EasyMock.createNiceMock(AmbariComponent.class);
 +
 +AmbariCluster cluster = EasyMock.createNiceMock(AmbariCluster.class);
 +
EasyMock.expect(cluster.getComponent("HIVE_SERVER")).andReturn(hiveServer).anyTimes();
 +EasyMock.replay(cluster);
 +
 +// Configure HTTP Transport
 +
EasyMock.expect(hiveServer.getHostNames()).andReturn(hiveServerHosts).anyTimes();
 +
EasyMock.expect(hiveServer.getConfigProperty("hive.server2.use.SSL")).andReturn("false").anyTimes();
 +
EasyMock.expect(hiveServer.getConfigProperty("hive.server2.thrift.http.path")).andReturn(HTTP_PATH).anyTimes();
 +
EasyMock.expect(hiveServer.getConfigProperty("hive.server2.thrift.http.port")).andReturn(HTTP_PORT).anyTimes();
 +
EasyMock.expect(hiveServer.getConfigProperty("hive.server2.transport.mode")).andReturn("http").anyTimes();
 +EasyMock.replay(hiveServer);
 +
 +// Run the test
 +AmbariDynamicServiceURLCreator builder = newURLCreator(cluster, 
mappingConfiguration);
 +List urls = builder.create(SERVICE_NAME);
 +assertEquals(HOSTNAMES.length, urls.size());
 +validateServiceURLs(urls, HOSTNAMES, expectedScheme, HTTP_PORT, 
HTTP_PATH);
 +
 +// Configure BINARY Transport
 +EasyMock.reset(hiveServer);
 +
EasyMock.expect(hiveServer.getHostNames()).andReturn(hiveServerHosts).anyTimes();
 +
EasyMock.expect(hiveServer.getConfigProperty("hive.server2.use.SSL")).andReturn("false").anyTimes();
 +
EasyMock.expect(hiveServer.getConfigProperty("hive.server2.thrift.http.path")).andReturn("").anyTimes();
 +
EasyMock.expect(hiveServer.getConfigProperty("hive.server2.thrift.http.port")).andReturn(HTTP_PORT).anyTimes();
 +
EasyMock.expect(hiveServer.getConfigProperty("hive.server2.thrift.port")).andReturn(BINARY_PORT).anyTimes();
 +

[14/16] knox git commit: Merge branch 'master' into KNOX-998-Package_Restructuring

2017-11-13 Thread more
http://git-wip-us.apache.org/repos/asf/knox/blob/2c69152f/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
--
diff --cc 
gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
index 4eb1954,000..f3288fd
mode 100644,00..100644
--- 
a/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
+++ 
b/gateway-server/src/main/java/org/apache/knox/gateway/topology/simple/SimpleDescriptorImpl.java
@@@ -1,123 -1,0 +1,163 @@@
 +/**
 + * 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.topology.simple;
 +
 +import com.fasterxml.jackson.annotation.JsonProperty;
 +
 +import java.util.ArrayList;
 +import java.util.List;
 +import java.util.Map;
 +
 +class SimpleDescriptorImpl implements SimpleDescriptor {
 +
 +@JsonProperty("discovery-type")
 +private String discoveryType;
 +
 +@JsonProperty("discovery-address")
 +private String discoveryAddress;
 +
 +@JsonProperty("discovery-user")
 +private String discoveryUser;
 +
 +@JsonProperty("discovery-pwd-alias")
 +private String discoveryPasswordAlias;
 +
 +@JsonProperty("provider-config-ref")
 +private String providerConfig;
 +
 +@JsonProperty("cluster")
 +private String cluster;
 +
 +@JsonProperty("services")
 +private List services;
 +
++@JsonProperty("applications")
++private List applications;
++
 +private String name = null;
 +
 +void setName(String name) {
 +this.name = name;
 +}
 +
 +@Override
 +public String getName() {
 +return name;
 +}
 +
 +@Override
 +public String getDiscoveryType() {
 +return discoveryType;
 +}
 +
 +@Override
 +public String getDiscoveryAddress() {
 +return discoveryAddress;
 +}
 +
 +@Override
 +public String getDiscoveryUser() {
 +return discoveryUser;
 +}
 +
 +@Override
 +public String getDiscoveryPasswordAlias() {
 +return discoveryPasswordAlias;
 +}
 +
 +@Override
 +public String getClusterName() {
 +return cluster;
 +}
 +
 +@Override
 +public String getProviderConfig() {
 +return providerConfig;
 +}
 +
 +@Override
 +public List getServices() {
 +List result = new ArrayList<>();
- result.addAll(services);
++if (services != null) {
++result.addAll(services);
++}
++return result;
++}
++
++@Override
++public List getApplications() {
++List result = new ArrayList<>();
++if (applications != null) {
++result.addAll(applications);
++}
 +return result;
 +}
 +
 +public static class ServiceImpl implements Service {
 +@JsonProperty("name")
 +private String name;
 +
 +@JsonProperty("params")
 +private Map params;
 +
 +@JsonProperty("urls")
 +private List urls;
 +
 +@Override
 +public String getName() {
 +return name;
 +}
 +
 +@Override
 +public Map getParams() {
 +return params;
 +}
 +
 +@Override
 +public List getURLs() {
 +return urls;
 +}
 +}
 +
++public static class ApplicationImpl implements Application {
++@JsonProperty("name")
++private String name;
++
++@JsonProperty("params")
++private Map params;
++
++@JsonProperty("urls")
++private List urls;
++
++@Override
++public String getName() {
++return name;
++}
++
++@Override
++public Map getParams() {
++return params;
++}
++
++@Override
++public List getURLs() {
++return urls;
++}
++}
++
 +}

http://git-wip-us.apache.org/repos/asf/knox/blob/2c69152f/gateway-server/src/main/java/org/apache/knox/gateway/topology/xml/KnoxFormatXmlTopologyRules.java
--
diff --cc 
gateway-server/src/ma