* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Map;
import java.util.Properties;
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSinkFactory;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
this.fetchTimeout = busTopicParams.getFetchTimeout();
- if (busTopicParams.isTopicNullOrEmpty()) {
+ if (busTopicParams.isTopicInvalid()) {
throw new IllegalArgumentException("No topic for DMaaP");
}
super(busTopicParams);
// super constructor sets servers = {""} if empty to avoid errors when using DME2
- if (busTopicParams.isServersNullOrEmpty()) {
+ if (busTopicParams.isServersInvalid()) {
throw new IllegalArgumentException("Must provide at least one host for HTTP AAF");
}
final String dme2RouteOffer = busTopicParams.getAdditionalProps()
.get(DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY);
- if (busTopicParams.isEnvironmentNullOrEmpty()) {
+ if (busTopicParams.isEnvironmentInvalid()) {
throw parmException(busTopicParams.getTopic(),
PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX);
}
- if (busTopicParams.isAftEnvironmentNullOrEmpty()) {
+ if (busTopicParams.isAftEnvironmentInvalid()) {
throw parmException(busTopicParams.getTopic(),
PolicyEndPointProperties.PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX);
}
- if (busTopicParams.isLatitudeNullOrEmpty()) {
+ if (busTopicParams.isLatitudeInvalid()) {
throw parmException(busTopicParams.getTopic(),
PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX);
}
- if (busTopicParams.isLongitudeNullOrEmpty()) {
+ if (busTopicParams.isLongitudeInvalid()) {
throw parmException(busTopicParams.getTopic(),
PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX);
}
- if ((busTopicParams.isPartnerNullOrEmpty())
- && (dme2RouteOffer == null || dme2RouteOffer.isEmpty())) {
+ if ((busTopicParams.isPartnerInvalid())
+ && StringUtils.isBlank(dme2RouteOffer)) {
throw new IllegalArgumentException(
"Must provide at least " + PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS
+ "." + busTopicParams.getTopic()
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Properties;
import java.util.concurrent.TimeUnit;
+import org.apache.commons.lang3.StringUtils;
import org.onap.policy.common.endpoints.event.comm.bus.DmaapTopicSinkFactory;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
String username, String password, boolean useHttps) {
- if (topic == null || topic.isEmpty()) {
+ if (StringUtils.isBlank(topic)) {
throw new IllegalArgumentException("No topic for DMaaP");
}
DmaapTopicSinkFactory.DME2_ROUTE_OFFER_PROPERTY);
}
- if (busTopicParams.isEnvironmentNullOrEmpty()) {
+ if (busTopicParams.isEnvironmentInvalid()) {
throw parmException(busTopicParams.getTopic(),
PolicyEndPointProperties.PROPERTY_DMAAP_DME2_ENVIRONMENT_SUFFIX);
}
- if (busTopicParams.isAftEnvironmentNullOrEmpty()) {
+ if (busTopicParams.isAftEnvironmentInvalid()) {
throw parmException(busTopicParams.getTopic(),
PolicyEndPointProperties.PROPERTY_DMAAP_DME2_AFT_ENVIRONMENT_SUFFIX);
}
- if (busTopicParams.isLatitudeNullOrEmpty()) {
+ if (busTopicParams.isLatitudeInvalid()) {
throw parmException(busTopicParams.getTopic(),
PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LATITUDE_SUFFIX);
}
- if (busTopicParams.isLongitudeNullOrEmpty()) {
+ if (busTopicParams.isLongitudeInvalid()) {
throw parmException(busTopicParams.getTopic(),
PolicyEndPointProperties.PROPERTY_DMAAP_DME2_LONGITUDE_SUFFIX);
}
- if ((busTopicParams.isPartnerNullOrEmpty())
- && (dme2RouteOffer == null || dme2RouteOffer.trim().isEmpty())) {
+ if ((busTopicParams.isPartnerInvalid())
+ && StringUtils.isBlank(dme2RouteOffer)) {
throw new IllegalArgumentException(
"Must provide at least " + PolicyEndPointProperties.PROPERTY_DMAAP_SOURCE_TOPICS + "."
+ busTopicParams.getTopic()
package org.onap.policy.common.endpoints.event.comm.bus.internal;
+import org.apache.commons.lang3.StringUtils;
+
import java.util.List;
import java.util.Map;
/**
* Member variables of this Params class are as follows.
- *
+ *
* <p>servers DMaaP servers
* topic DMaaP Topic to be monitored
* apiKey DMaaP API Key (optional)
*/
public class BusTopicParams {
- public static TopicParamsBuilder builder() {
- return new TopicParamsBuilder();
- }
-
+ private int port;
private List<String> servers;
+ private Map<String, String> additionalProps;
private String topic;
private String apiKey;
private String apiSecret;
private int fetchLimit;
private boolean useHttps;
private boolean allowSelfSignedCerts;
+ private boolean managed;
private String userName;
private String password;
private String partner;
private String latitude;
private String longitude;
- private Map<String, String> additionalProps;
private String partitionId;
- private boolean managed;
+ private String clientName;
+ private String hostname;
+ private String basePath;
+
+ public static TopicParamsBuilder builder() {
+ return new TopicParamsBuilder();
+ }
public String getPartitionId() {
return partitionId;
return fetchLimit;
}
+ public String getClientName() {
+ return clientName;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public String getBasePath() {
+ return basePath;
+ }
+
+ public boolean isManaged() {
+ return managed;
+ }
+
public boolean isUseHttps() {
return useHttps;
}
return allowSelfSignedCerts;
}
- boolean isEnvironmentNullOrEmpty() {
- return (environment == null || environment.trim().isEmpty());
+ /**
+ * Methods to Check if the property is INVALID
+ */
+
+ boolean isEnvironmentInvalid() {
+ return StringUtils.isBlank(environment);
}
- boolean isAftEnvironmentNullOrEmpty() {
- return (aftEnvironment == null || aftEnvironment.trim().isEmpty());
+ boolean isAftEnvironmentInvalid() {
+ return StringUtils.isBlank(aftEnvironment);
}
- boolean isLatitudeNullOrEmpty() {
- return (latitude == null || latitude.trim().isEmpty());
+ boolean isLatitudeInvalid() {
+ return StringUtils.isBlank(latitude);
}
- boolean isLongitudeNullOrEmpty() {
- return (longitude == null || longitude.trim().isEmpty());
+ boolean isLongitudeInvalid() {
+ return StringUtils.isBlank(longitude);
}
- boolean isConsumerInstanceNullOrEmpty() {
- return (consumerInstance == null || consumerInstance.trim().isEmpty());
+ boolean isConsumerInstanceInvalid() {
+ return StringUtils.isBlank(consumerInstance);
}
- boolean isConsumerGroupNullOrEmpty() {
- return (consumerGroup == null || consumerGroup.trim().isEmpty());
+ boolean isConsumerGroupInvalid() {
+ return StringUtils.isBlank(consumerGroup);
}
- boolean isApiKeyValid() {
- return !(apiKey == null || apiKey.trim().isEmpty());
+ public boolean isClientNameInvalid() {
+ return StringUtils.isBlank(clientName);
}
- boolean isApiSecretValid() {
- return !(apiSecret == null || apiSecret.trim().isEmpty());
+ boolean isPartnerInvalid() {
+ return StringUtils.isBlank(partner);
}
- boolean isUserNameValid() {
- return !(userName == null || userName.trim().isEmpty());
+ boolean isServersInvalid() {
+ return (servers == null || servers.isEmpty()
+ || (servers.size() == 1 && ("".equals(servers.get(0)))));
}
- boolean isPasswordValid() {
- return !(password == null || password.trim().isEmpty());
+ boolean isTopicInvalid() {
+ return StringUtils.isBlank(topic);
}
- boolean isPartnerNullOrEmpty() {
- return (partner == null || partner.trim().isEmpty());
+ boolean isPartitionIdInvalid() {
+ return StringUtils.isBlank(partitionId);
}
- boolean isServersNullOrEmpty() {
- return (servers == null || servers.isEmpty()
- || (servers.size() == 1 && ("".equals(servers.get(0)))));
+ public boolean isHostnameInvalid() {
+ return StringUtils.isBlank(hostname);
}
- boolean isAdditionalPropsValid() {
- return additionalProps != null;
+ public boolean isPortInvalid() {
+ return (getPort() <= 0 || getPort() >= 65535);
+ }
+
+ /**
+ * Methods to Check if the property is Valid
+ */
+
+ boolean isApiKeyValid() {
+ return StringUtils.isNotBlank(apiKey);
}
- boolean isTopicNullOrEmpty() {
- return (topic == null || topic.trim().isEmpty());
+ boolean isApiSecretValid() {
+ return StringUtils.isNotBlank(apiSecret);
}
- boolean isPartitionIdNullOrEmpty() {
- return (partitionId == null || partitionId.trim().isEmpty());
+ boolean isUserNameValid() {
+ return StringUtils.isNotBlank(userName);
}
- public boolean isManaged() {
- return managed;
+ boolean isPasswordValid() {
+ return StringUtils.isNotBlank(password);
+ }
+
+ boolean isAdditionalPropsValid() {
+ return additionalProps != null;
}
public static class TopicParamsBuilder {
-
- BusTopicParams params = new BusTopicParams();
+
+ final BusTopicParams params = new BusTopicParams();
private TopicParamsBuilder() {
}
this.params.managed = managed;
return this;
}
+
+ public TopicParamsBuilder hostname(String hostname) {
+ this.params.hostname = hostname;
+ return this;
+ }
+
+ public TopicParamsBuilder clientName(String clientName) {
+ this.params.clientName = clientName;
+ return this;
+ }
+
+ public TopicParamsBuilder port(int port) {
+ this.params.port = port;
+ return this;
+ }
+
+ public TopicParamsBuilder basePath(String basePath) {
+ this.params.basePath = basePath;
+ return this;
+ }
+
}
}
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
super(busTopicParams);
- if (busTopicParams.isPartitionIdNullOrEmpty()) {
+ if (busTopicParams.isPartitionIdInvalid()) {
this.partitionId = UUID.randomUUID().toString();
} else {
this.partitionId = busTopicParams.getPartitionId();
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
+ * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
super(busTopicParams);
- if (busTopicParams.isConsumerGroupNullOrEmpty()) {
+ if (busTopicParams.isConsumerGroupInvalid()) {
this.consumerGroup = UUID.randomUUID().toString();
} else {
this.consumerGroup = busTopicParams.getConsumerGroup();
}
- if (busTopicParams.isConsumerInstanceNullOrEmpty()) {
+ if (busTopicParams.isConsumerInstanceInvalid()) {
this.consumerInstance = NetworkUtil.getHostname();
} else {
this.consumerInstance = busTopicParams.getConsumerInstance();
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.List;
import java.util.Properties;
+import org.apache.commons.lang3.StringUtils;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.internal.JerseyClient;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
import org.slf4j.Logger;
/**
* Build and http client with the following parameters.
*/
- public HttpClient build(String name, boolean https, boolean selfSignedCerts, String hostname, int port,
- String baseUrl, String userName, String password, boolean managed)
+ public HttpClient build(BusTopicParams busTopicParams)
throws KeyManagementException, NoSuchAlgorithmException;
/**
protected HashMap<String, HttpClient> clients = new HashMap<>();
@Override
- public synchronized HttpClient build(String name, boolean https, boolean selfSignedCerts, String hostname, int port,
- String baseUrl, String userName, String password, boolean managed)
+ public synchronized HttpClient build(BusTopicParams busTopicParams)
throws KeyManagementException, NoSuchAlgorithmException {
- if (clients.containsKey(name)) {
- return clients.get(name);
+ if (clients.containsKey(busTopicParams.getClientName())) {
+ return clients.get(busTopicParams.getClientName());
}
JerseyClient client =
- new JerseyClient(name, https, selfSignedCerts, hostname, port, baseUrl, userName, password);
+ new JerseyClient(busTopicParams);
- if (managed) {
- clients.put(name, client);
+ if (busTopicParams.isManaged()) {
+ clients.put(busTopicParams.getClientName(), client);
}
return client;
String httpsString = properties.getProperty(PolicyEndPointProperties.PROPERTY_HTTP_CLIENT_SERVICES + "."
+ clientName + PolicyEndPointProperties.PROPERTY_HTTP_HTTPS_SUFFIX);
boolean https = false;
- if (httpsString != null && !httpsString.isEmpty()) {
+ if (StringUtils.isNotBlank(httpsString)) {
https = Boolean.parseBoolean(httpsString);
}
try {
HttpClient client =
- this.build(clientName, https, https, hostName, port, baseUrl, userName, password, managed);
+ this.build(BusTopicParams.builder()
+ .clientName(clientName)
+ .useHttps(https)
+ .allowSelfSignedCerts(https)
+ .hostname(hostName)
+ .port(port)
+ .basePath(baseUrl)
+ .userName(userName)
+ .password(password)
+ .managed(managed)
+ .build());
clientList.add(client);
} catch (Exception e) {
logger.error("http-client-factory: cannot build client {}", clientName, e);
* policy-endpoints
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Constructor.
*
- * @param name the name
- * @param https is it https or not
- * @param selfSignedCerts are there self signed certs
- * @param hostname the hostname
- * @param port port being used
- * @param basePath base context
- * @param userName user
- * @param password password
- *
+ * name the name
+ * https is it https or not
+ * selfSignedCerts are there self signed certs
+ * hostname the hostname
+ * port port being used
+ * basePath base context
+ * userName user
+ * password password
+ * @param busTopicParams Input parameters object
* @throws KeyManagementException key exception
* @throws NoSuchAlgorithmException no algorithm exception
*/
- public JerseyClient(String name, boolean https, boolean selfSignedCerts, String hostname, int port, String basePath,
- String userName, String password) throws KeyManagementException, NoSuchAlgorithmException {
+ public JerseyClient(BusTopicParams busTopicParams) throws KeyManagementException, NoSuchAlgorithmException {
super();
- if (name == null || name.isEmpty()) {
+ if (busTopicParams.isClientNameInvalid()) {
throw new IllegalArgumentException("Name must be provided");
}
- if (hostname == null || hostname.isEmpty()) {
+ if (busTopicParams.isHostnameInvalid()) {
throw new IllegalArgumentException("Hostname must be provided");
}
- if (port <= 0 && port >= 65535) {
- throw new IllegalArgumentException("Invalid Port provided: " + port);
+ if (busTopicParams.isPortInvalid()) {
+ throw new IllegalArgumentException("Invalid Port provided: " + busTopicParams.getPort());
}
- this.name = name;
- this.https = https;
- this.hostname = hostname;
- this.port = port;
- this.basePath = basePath;
- this.userName = userName;
- this.password = password;
- this.selfSignedCerts = selfSignedCerts;
+ this.name = busTopicParams.getClientName();
+ this.https = busTopicParams.isUseHttps();
+ this.hostname = busTopicParams.getHostname();
+ this.port = busTopicParams.getPort();
+ this.basePath = busTopicParams.getBasePath();
+ this.userName = busTopicParams.getUserName();
+ this.password = busTopicParams.getPassword();
+ this.selfSignedCerts = busTopicParams.isAllowSelfSignedCerts();
StringBuilder tmpBaseUrl = new StringBuilder();
if (this.https) {
* ONAP
* ================================================================================
* Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 Samsung Electronics Co., Ltd.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.onap.policy.common.endpoints.event.comm.bus.internal.BusTopicParams;
import org.onap.policy.common.endpoints.http.client.HttpClient;
import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.common.endpoints.http.server.internal.JettyJerseyServer;
/**
* Setup before class method.
- *
+ *
* @throws InterruptedException can be interrupted
- * @throws IOException can have an IO exception
+ * @throws IOException can have an IO exception
*/
@BeforeClass
public static void setUp() throws InterruptedException, IOException {
savedValuesMap.put(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, keyStoreSystemProperty);
}
- String keyStorePasswordSystemProperty =
- System.getProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
+ String keyStorePasswordSystemProperty =
+ System.getProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
if (keyStorePasswordSystemProperty != null) {
savedValuesMap.put(
- JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME, keyStorePasswordSystemProperty);
+ JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME, keyStorePasswordSystemProperty);
}
String trustStoreSystemProperty = System.getProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
if (trustStoreSystemProperty != null) {
savedValuesMap
- .put(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME, trustStoreSystemProperty);
+ .put(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME, trustStoreSystemProperty);
}
- String trustStorePasswordSystemProperty =
- System.getProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
+ String trustStorePasswordSystemProperty =
+ System.getProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
if (trustStorePasswordSystemProperty != null) {
savedValuesMap
- .put(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME, trustStorePasswordSystemProperty);
+ .put(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME, trustStorePasswordSystemProperty);
}
System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME, "src/test/resources/keystore-test");
/**
* After the class is created method.
- *
*/
@AfterClass
public static void tearDown() {
HttpClient.factory.destroy();
if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME)) {
- System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME,
- savedValuesMap.get(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME));
+ System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME,
+ savedValuesMap.get(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME));
savedValuesMap.remove(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME);
} else {
System.clearProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PROPERTY_NAME);
}
if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME)) {
- System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME,
- savedValuesMap.get(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME));
+ System.setProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME,
+ savedValuesMap.get(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME));
savedValuesMap.remove(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
} else {
System.clearProperty(JettyJerseyServer.SYSTEM_KEYSTORE_PASSWORD_PROPERTY_NAME);
}
if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME)) {
- System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME,
- savedValuesMap.get(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME));
+ System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME,
+ savedValuesMap.get(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME));
savedValuesMap.remove(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
} else {
System.clearProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PROPERTY_NAME);
}
if (savedValuesMap.containsKey(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME)) {
- System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME,
- savedValuesMap.get(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME));
+ System.setProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME,
+ savedValuesMap.get(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME));
savedValuesMap.remove(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
} else {
System.clearProperty(JettyJerseyServer.SYSTEM_TRUSTSTORE_PASSWORD_PROPERTY_NAME);
public void testHttpNoAuthClient() throws Exception {
logger.info("-- testHttpNoAuthClient() --");
- final HttpClient client = HttpClient.factory.build("testHttpNoAuthClient", false, false, "localhost", 6666,
- "junit/echo", null, null, true);
+ final HttpClient client = HttpClient.factory.build(BusTopicParams.builder().clientName("testHttpNoAuthClient")
+ .useHttps(false)
+ .allowSelfSignedCerts(false)
+ .hostname("localhost")
+ .port(6666).basePath("junit/echo").userName(null).password(null).managed(true).build());
final Response response = client.get("hello");
final String body = HttpClient.getBody(response, String.class);
public void testHttpAuthClient() throws Exception {
logger.info("-- testHttpAuthClient() --");
- final HttpClient client = HttpClient.factory.build("testHttpAuthClient", true, true,"localhost", 6667,
- "junit/echo", "x", "y", true);
+ final HttpClient client = HttpClient.factory.build(BusTopicParams.builder().clientName("testHttpAuthClient")
+ .useHttps(true)
+ .allowSelfSignedCerts(true)
+ .hostname("localhost")
+ .port(6667)
+ .basePath("junit/echo")
+ .userName("x")
+ .password("y")
+ .managed(true).build());
+
final Response response = client.get("hello");
final String body = HttpClient.getBody(response, String.class);
public void testHttpAuthClient401() throws Exception {
logger.info("-- testHttpAuthClient401() --");
- final HttpClient client = HttpClient.factory.build("testHttpAuthClient401", true, true, "localhost", 6667,
- "junit/echo", null, null, true);
+ final HttpClient client = HttpClient.factory.build(BusTopicParams.builder().clientName("testHttpAuthClient401")
+ .useHttps(true)
+ .allowSelfSignedCerts(true)
+ .hostname("localhost")
+ .port(6667)
+ .basePath("junit/echo")
+ .userName(null)
+ .password(null)
+ .managed(true).build());
final Response response = client.get("hello");
assertTrue(response.getStatus() == 401);
}