Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.jaxrs.client.test')
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/.classpath7
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/.project28
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/META-INF/MANIFEST.MF16
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/build.properties4
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/pom.xml30
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientBuilderTest.java551
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java115
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTestSuite.java24
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientInternalTestSuite.java24
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java409
-rw-r--r--plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/JaxRsClientExtTestSuite.java24
11 files changed, 1232 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/.classpath b/plugins/org.eclipse.osee.jaxrs.client.test/.classpath
new file mode 100644
index 0000000000..ad32c83a78
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/.project b/plugins/org.eclipse.osee.jaxrs.client.test/.project
new file mode 100644
index 0000000000..cbe73a9b58
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.jaxrs.client.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.jaxrs.client.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000000..05ae8553aa
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/META-INF/MANIFEST.MF
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: OSEE JAX-RS ClientTest (Incubation)
+Bundle-SymbolicName: org.eclipse.osee.jaxrs.client.test
+Bundle-Version: 0.18.0.qualifier
+Fragment-Host: org.eclipse.osee.jaxrs.client
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Eclipse Open System Engineering Environment
+Import-Package: org.hamcrest.core,
+ org.junit,
+ org.junit.rules,
+ org.junit.runner,
+ org.junit.runners,
+ org.mockito;bundle-version="1.9.0",
+ org.mockito.invocation,
+ org.mockito.stubbing
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/build.properties b/plugins/org.eclipse.osee.jaxrs.client.test/build.properties
new file mode 100644
index 0000000000..34d2e4d2da
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/build.properties
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/pom.xml b/plugins/org.eclipse.osee.jaxrs.client.test/pom.xml
new file mode 100644
index 0000000000..efdb530006
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/pom.xml
@@ -0,0 +1,30 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.eclipse.osee</groupId>
+ <artifactId>org.eclipse.osee.x.core.parent</artifactId>
+ <version>0.18.0-SNAPSHOT</version>
+ <relativePath>../../plugins/org.eclipse.osee.x.core.parent</relativePath>
+ </parent>
+
+ <artifactId>org.eclipse.osee.jaxrs.client.test</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>OSEE JAX-RS Client Test - (Incubation)</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <testSuite>org.eclipse.osee.jaxrs.client.test</testSuite>
+ <testClass>org.eclipse.osee.jaxrs.client.JaxRsClientTestSuite</testClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientBuilderTest.java b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientBuilderTest.java
new file mode 100644
index 0000000000..e47abd2d7f
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientBuilderTest.java
@@ -0,0 +1,551 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client;
+
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.CHUNK_LENGTH_MIN_LIMIT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.CHUNK_THRESHOLD_MIN_LIMIT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT_REJECTION;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_CHUNKING_ALLOWED;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_CHUNKING_THRESHOLD;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_CHUNK_SIZE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_CONNECTION_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_CONNECTION_TYPE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_CREATE_THREADSAFE_PROXY_CLIENTS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_FOLLOW_REDIRECTS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_MAX_RETRANSMITS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_NON_PROXY_HOSTS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_PROXY_ADDRESS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_PROXY_AUTHORIZATION_TYPE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_PROXY_PASSWORD;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_PROXY_PORT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_PROXY_TYPE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_PROXY_USERNAME;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_RECEIVE_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_SERVER_AUTHORIZATION_TYPE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_SERVER_PASSWORD;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.DEFAULT_JAXRS_CLIENT_SERVER_USERNAME;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT_REJECTION;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_CHUNKING_ALLOWED;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_CHUNKING_THRESHOLD;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_CHUNK_SIZE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_CONNECTION_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_CONNECTION_TYPE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_CREATE_THREADSAFE_PROXY_CLIENTS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_FOLLOW_REDIRECTS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_MAX_RETRANSMITS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_NON_PROXY_HOSTS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_PROXY_ADDRESS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_PROXY_AUTHORIZATION_TYPE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_PROXY_PASSWORD;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_PROXY_TYPE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_PROXY_USERNAME;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_RECEIVE_TIMEOUT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_SERVER_AUTHORIZATION_TYPE;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_SERVER_PASSWORD;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.JAXRS_CLIENT_SERVER_USERNAME;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.RETRANSMIT_MIN_LIMIT;
+import static org.eclipse.osee.jaxrs.client.JaxRsClientConstants.TIMEOUT_MIN_LIMIT;
+import static org.junit.Assert.assertEquals;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import javax.ws.rs.client.WebTarget;
+import org.eclipse.osee.jaxrs.client.JaxRsClient.JaxRsClientBuilder;
+import org.eclipse.osee.jaxrs.client.JaxRsClient.JaxRsClientFactory;
+import org.eclipse.osee.jaxrs.client.JaxRsClientConstants.ConnectionType;
+import org.eclipse.osee.jaxrs.client.JaxRsClientConstants.ProxyType;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link JaxRsClientBuilder}
+ *
+ * @author Roberto E. Escobar
+ */
+public class JaxRsClientBuilderTest {
+
+ private static final long POSITIVE_TIMEOUT = Long.MAX_VALUE;
+ private static final long NEGATIVE_TIMEOUT = Long.MIN_VALUE;
+ private static final int POSITIVE_INT = Integer.MAX_VALUE;
+ private static final int NEGATIVE_INT = Integer.MIN_VALUE;
+
+ private static final String PROXY_ADDRESS = "proxy-address.com";
+ private static final int PROXY_PORT = 78612;
+
+ private static final long ASYNC_EXECUTE_TIMEOUT = 32423L;
+ private static final boolean ASYNC_EXECUTE_TIMEOUT_REJECTION = true;
+ private static final int CHUNK_SIZE = 864;
+ private static final boolean CHUNKING_ALLOWED = true;
+ private static final int CHUNKING_THRESHOLD = 9872394;
+ private static final long CONNECTION_TIMEOUT = 2327L;
+ private static final ConnectionType CONNECTION_TYPE = ConnectionType.CLOSE;
+ private static final boolean CREATE_THREADSAFE_PROXY_CLIENTS = true;
+ private static final boolean FOLLOW_REDIRECTS = false;
+ private static final int MAX_RETRANSMITS = 452;
+ private static final String NON_PROXY_HOSTS = "non-proxy-hosts";
+ private static final String FULL_PROXY_ADDRESS = "http://" + PROXY_ADDRESS + ":" + PROXY_PORT;
+ private static final String PROXY_AUTHORIZATION_TYPE = "proxy-authentication-type";
+ private static final boolean PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS = true;
+ private static final String PROXY_PASSWORD = "proxy-password";
+ private static final ProxyType PROXY_TYPE = ProxyType.SOCKS;
+ private static final String PROXY_USERNAME = "proxy-username";
+ private static final long RECEIVE_TIMEOUT = 87532L;
+ private static final String SERVER_AUTHORIZATION_TYPE = "server-authentication-type";
+ private static final String SERVER_PASSWORD = "server-password";
+ private static final String SERVER_USERNAME = "server-username";
+
+ //@formatter:off
+ @Mock private JaxRsClientFactory factory;
+ @Mock private Map<String, Object> properties;
+ @Mock private WebTarget target;
+ @Captor private ArgumentCaptor<Map<String, Object>> propCaptor;
+ //@formatter:on
+
+ private JaxRsClientBuilder builder;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ builder = new JaxRsClientBuilder(factory);
+ }
+
+ @Test
+ public void testAllowChunking() {
+ builder.allowChunking(true);
+ assertEquals(true, builder.isChunkingAllowed());
+
+ builder.allowChunking(false);
+ assertEquals(false, builder.isChunkingAllowed());
+ }
+
+ @Test
+ public void testAsyncExecTimeout() {
+ builder.asyncExecTimeout(POSITIVE_TIMEOUT);
+ assertEquals(POSITIVE_TIMEOUT, builder.getAsyncExecuteTimeout());
+
+ builder.asyncExecTimeout(NEGATIVE_TIMEOUT);
+ assertEquals(TIMEOUT_MIN_LIMIT, builder.getAsyncExecuteTimeout());
+ }
+
+ @Test
+ public void testAsyncTimeoutRejection() {
+ builder.asyncExecTimeoutRejection(true);
+ assertEquals(true, builder.isAsyncExecuteTimeoutRejection());
+
+ builder.asyncExecTimeoutRejection(false);
+ assertEquals(false, builder.isAsyncExecuteTimeoutRejection());
+ }
+
+ @Test
+ public void testConnectionTimeout() {
+ builder.connectionTimeout(POSITIVE_TIMEOUT);
+ assertEquals(POSITIVE_TIMEOUT, builder.getConnectionTimeout());
+
+ builder.connectionTimeout(NEGATIVE_TIMEOUT);
+ assertEquals(TIMEOUT_MIN_LIMIT, builder.getConnectionTimeout());
+ }
+
+ @Test
+ public void testReceiveTimeout() {
+ builder.receiveTimeout(POSITIVE_TIMEOUT);
+ assertEquals(POSITIVE_TIMEOUT, builder.getReceiveTimeout());
+
+ builder.receiveTimeout(NEGATIVE_TIMEOUT);
+ assertEquals(TIMEOUT_MIN_LIMIT, builder.getReceiveTimeout());
+ }
+
+ @Test
+ public void testConnectionType() {
+ builder.connectionType(ConnectionType.CLOSE);
+ assertEquals(ConnectionType.CLOSE, builder.getConnectionType());
+
+ builder.connectionType(null);
+ assertEquals(ConnectionType.KEEP_ALIVE, builder.getConnectionType());
+ }
+
+ @Test
+ public void testProxyType() {
+ builder.proxyType(ProxyType.SOCKS);
+
+ builder.proxyType(ProxyType.SOCKS);
+ assertEquals(ProxyType.SOCKS, builder.getProxyType());
+
+ builder.proxyType(null);
+ assertEquals(ProxyType.HTTP, builder.getProxyType());
+ }
+
+ @Test
+ public void testFollowRedirects() {
+ builder.followRedirects(true);
+ assertEquals(true, builder.isFollowRedirectsAllowed());
+
+ builder.followRedirects(false);
+ assertEquals(false, builder.isFollowRedirectsAllowed());
+ }
+
+ @Test
+ public void testChunkingSize() {
+ builder.chunkLength(POSITIVE_INT);
+ assertEquals(POSITIVE_INT, builder.getChunkLength());
+
+ builder.chunkLength(NEGATIVE_INT);
+ assertEquals(CHUNK_LENGTH_MIN_LIMIT, builder.getChunkLength());
+ }
+
+ @Test
+ public void testChunkingThreshold() {
+ builder.chunkingThreshold(POSITIVE_INT);
+ assertEquals(POSITIVE_INT, builder.getChunkingThreshold());
+
+ builder.chunkingThreshold(NEGATIVE_INT);
+ assertEquals(CHUNK_THRESHOLD_MIN_LIMIT, builder.getChunkingThreshold());
+ }
+
+ @Test
+ public void testMaxRetransmit() {
+ builder.maxRetransmits(POSITIVE_INT);
+ assertEquals(POSITIVE_INT, builder.getMaxRetransmits());
+
+ builder.maxRetransmits(NEGATIVE_INT);
+ assertEquals(RETRANSMIT_MIN_LIMIT, builder.getMaxRetransmits());
+ }
+
+ @Test
+ public void testCreateThreadSafeProxyClients() {
+ builder.createThreadSafeProxyClients(true);
+ assertEquals(true, builder.isCreateThreadSafeProxyClients());
+
+ builder.createThreadSafeProxyClients(false);
+ assertEquals(false, builder.isCreateThreadSafeProxyClients());
+ }
+
+ @Test
+ public void testProxyClientSubResourcesInheritHeaders() {
+ builder.proxyClientSubResourcesInheritHeaders(true);
+ assertEquals(true, builder.isProxyClientSubResourcesInheritHeaders());
+
+ builder.proxyClientSubResourcesInheritHeaders(false);
+ assertEquals(false, builder.isProxyClientSubResourcesInheritHeaders());
+ }
+
+ @Test
+ public void testNonProxyHosts() {
+ builder.nonProxyHosts(NON_PROXY_HOSTS);
+ assertEquals(NON_PROXY_HOSTS, builder.getNonProxyHosts());
+ }
+
+ @Test
+ public void testProxyAddress() {
+ builder.proxyAddress(FULL_PROXY_ADDRESS);
+
+ assertEquals(FULL_PROXY_ADDRESS, builder.getFullProxyAddress());
+ assertEquals(PROXY_ADDRESS, builder.getProxyAddress());
+ assertEquals(PROXY_PORT, builder.getProxyPort());
+ }
+
+ @Test
+ public void testProxyAuthorizationType() {
+ builder.proxyAuthorizationType(PROXY_AUTHORIZATION_TYPE);
+ assertEquals(PROXY_AUTHORIZATION_TYPE, builder.getProxyAuthorizationType());
+ }
+
+ @Test
+ public void testProxyPassword() {
+ builder.proxyPassword(PROXY_PASSWORD);
+ assertEquals(PROXY_PASSWORD, builder.getProxyPassword());
+ }
+
+ @Test
+ public void testProxyUsername() {
+ builder.proxyUsername(PROXY_USERNAME);
+ assertEquals(PROXY_USERNAME, builder.getProxyUsername());
+ }
+
+ @Test
+ public void testServerAuthorizationType() {
+ builder.authorizationType(SERVER_AUTHORIZATION_TYPE);
+ assertEquals(SERVER_AUTHORIZATION_TYPE, builder.getServerAuthorizationType());
+ }
+
+ @Test
+ public void testServerPassword() {
+ builder.password(SERVER_PASSWORD);
+ assertEquals(SERVER_PASSWORD, builder.getServerPassword());
+ }
+
+ @Test
+ public void testServerUsername() {
+ builder.username(SERVER_USERNAME);
+ assertEquals(SERVER_USERNAME, builder.getServerUsername());
+ }
+
+ @Test
+ public void testDefaultProperties() {
+ Map<String, Object> properties = new HashMap<String, Object>();
+ builder.properties(properties);
+
+ JaxRsClient actual = builder.build();
+ JaxRsClientConfig config = actual.getConfig();
+
+ //@formatter:off
+ assertEquals(DEFAULT_JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT, config.getAsyncExecuteTimeout());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CHUNKING_THRESHOLD, config.getChunkingThreshold());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CHUNK_SIZE, config.getChunkLength());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CONNECTION_TIMEOUT, config.getConnectionTimeout());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CONNECTION_TYPE, config.getConnectionType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_ADDRESS, config.getFullProxyAddress());
+ assertEquals(DEFAULT_JAXRS_CLIENT_MAX_RETRANSMITS, config.getMaxRetransmits());
+ assertEquals(DEFAULT_JAXRS_CLIENT_NON_PROXY_HOSTS, config.getNonProxyHosts());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_AUTHORIZATION_TYPE, config.getProxyAuthorizationType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_ADDRESS, config.getProxyAddress());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_PASSWORD, config.getProxyPassword());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_PORT, config.getProxyPort());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_TYPE, config.getProxyType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_USERNAME, config.getProxyUsername());
+ assertEquals(DEFAULT_JAXRS_CLIENT_RECEIVE_TIMEOUT, config.getReceiveTimeout());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_AUTHORIZATION_TYPE, config.getServerAuthorizationType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_PASSWORD, config.getServerPassword());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_USERNAME, config.getServerUsername());
+ assertEquals(DEFAULT_JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT_REJECTION, config.isAsyncExecuteTimeoutRejection());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CHUNKING_ALLOWED, config.isChunkingAllowed());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CREATE_THREADSAFE_PROXY_CLIENTS, config.isCreateThreadSafeProxyClients());
+ assertEquals(DEFAULT_JAXRS_CLIENT_FOLLOW_REDIRECTS, config.isFollowRedirectsAllowed());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS, config.isProxyClientSubResourcesInheritHeaders());
+ assertEquals(false, config.isProxyAuthorizationRequired());
+ assertEquals(false, config.isProxyRequired());
+ assertEquals(false, config.isServerAuthorizationRequired());
+ //@formatter:on
+ }
+
+ @Test
+ public void testPropertiesDefaultsWithNegatives() {
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(JAXRS_CLIENT_CONNECTION_TIMEOUT, NEGATIVE_TIMEOUT);
+ props.put(JAXRS_CLIENT_RECEIVE_TIMEOUT, NEGATIVE_TIMEOUT);
+ props.put(JAXRS_CLIENT_MAX_RETRANSMITS, NEGATIVE_INT);
+ props.put(JAXRS_CLIENT_CHUNKING_THRESHOLD, NEGATIVE_INT);
+ props.put(JAXRS_CLIENT_CHUNK_SIZE, NEGATIVE_INT);
+ props.put(JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT, NEGATIVE_TIMEOUT);
+ builder.properties(props);
+
+ JaxRsClient actual = builder.build();
+ JaxRsClientConfig config = actual.getConfig();
+
+ //@formatter:off
+ assertEquals(TIMEOUT_MIN_LIMIT, config.getAsyncExecuteTimeout());
+ assertEquals(CHUNK_THRESHOLD_MIN_LIMIT, config.getChunkingThreshold());
+ assertEquals(CHUNK_LENGTH_MIN_LIMIT, config.getChunkLength());
+ assertEquals(TIMEOUT_MIN_LIMIT, config.getConnectionTimeout());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CONNECTION_TYPE, config.getConnectionType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_ADDRESS, config.getFullProxyAddress());
+ assertEquals(RETRANSMIT_MIN_LIMIT, config.getMaxRetransmits());
+ assertEquals(DEFAULT_JAXRS_CLIENT_NON_PROXY_HOSTS, config.getNonProxyHosts());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_AUTHORIZATION_TYPE, config.getProxyAuthorizationType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_ADDRESS, config.getProxyAddress());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_PASSWORD, config.getProxyPassword());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_PORT, config.getProxyPort());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_TYPE, config.getProxyType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_USERNAME, config.getProxyUsername());
+ assertEquals(TIMEOUT_MIN_LIMIT, config.getReceiveTimeout());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_AUTHORIZATION_TYPE, config.getServerAuthorizationType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_PASSWORD, config.getServerPassword());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_USERNAME, config.getServerUsername());
+ assertEquals(DEFAULT_JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT_REJECTION, config.isAsyncExecuteTimeoutRejection());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CHUNKING_ALLOWED, config.isChunkingAllowed());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CREATE_THREADSAFE_PROXY_CLIENTS, config.isCreateThreadSafeProxyClients());
+ assertEquals(DEFAULT_JAXRS_CLIENT_FOLLOW_REDIRECTS, config.isFollowRedirectsAllowed());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS, config.isProxyClientSubResourcesInheritHeaders());
+ assertEquals(false, config.isProxyAuthorizationRequired());
+ assertEquals(false, config.isProxyRequired());
+ assertEquals(false, config.isServerAuthorizationRequired());
+ //@formatter:on
+ }
+
+ @Test
+ public void testProperties() {
+ Map<String, Object> props = new HashMap<String, Object>();
+ props.put(JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT, ASYNC_EXECUTE_TIMEOUT);
+ props.put(JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT_REJECTION, ASYNC_EXECUTE_TIMEOUT_REJECTION);
+ props.put(JAXRS_CLIENT_CHUNK_SIZE, CHUNK_SIZE);
+ props.put(JAXRS_CLIENT_CHUNKING_ALLOWED, CHUNKING_ALLOWED);
+ props.put(JAXRS_CLIENT_CHUNKING_THRESHOLD, CHUNKING_THRESHOLD);
+ props.put(JAXRS_CLIENT_CONNECTION_TIMEOUT, CONNECTION_TIMEOUT);
+ props.put(JAXRS_CLIENT_CONNECTION_TYPE, CONNECTION_TYPE);
+ props.put(JAXRS_CLIENT_CREATE_THREADSAFE_PROXY_CLIENTS, CREATE_THREADSAFE_PROXY_CLIENTS);
+ props.put(JAXRS_CLIENT_FOLLOW_REDIRECTS, FOLLOW_REDIRECTS);
+ props.put(JAXRS_CLIENT_MAX_RETRANSMITS, MAX_RETRANSMITS);
+ props.put(JAXRS_CLIENT_NON_PROXY_HOSTS, NON_PROXY_HOSTS);
+ props.put(JAXRS_CLIENT_PROXY_ADDRESS, FULL_PROXY_ADDRESS);
+ props.put(JAXRS_CLIENT_PROXY_AUTHORIZATION_TYPE, PROXY_AUTHORIZATION_TYPE);
+ props.put(JAXRS_CLIENT_PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS, PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS);
+ props.put(JAXRS_CLIENT_PROXY_PASSWORD, PROXY_PASSWORD);
+ props.put(JAXRS_CLIENT_PROXY_TYPE, PROXY_TYPE);
+ props.put(JAXRS_CLIENT_PROXY_USERNAME, PROXY_USERNAME);
+ props.put(JAXRS_CLIENT_RECEIVE_TIMEOUT, RECEIVE_TIMEOUT);
+ props.put(JAXRS_CLIENT_SERVER_AUTHORIZATION_TYPE, SERVER_AUTHORIZATION_TYPE);
+ props.put(JAXRS_CLIENT_SERVER_PASSWORD, SERVER_PASSWORD);
+ props.put(JAXRS_CLIENT_SERVER_USERNAME, SERVER_USERNAME);
+
+ builder.properties(props);
+
+ JaxRsClient actual = builder.build();
+ JaxRsClientConfig config = actual.getConfig();
+
+ assertEquals(ASYNC_EXECUTE_TIMEOUT, config.getAsyncExecuteTimeout());
+ assertEquals(ASYNC_EXECUTE_TIMEOUT_REJECTION, config.isAsyncExecuteTimeoutRejection());
+ assertEquals(CHUNK_SIZE, config.getChunkLength());
+ assertEquals(CHUNKING_ALLOWED, config.isChunkingAllowed());
+ assertEquals(CHUNKING_THRESHOLD, config.getChunkingThreshold());
+ assertEquals(CONNECTION_TIMEOUT, config.getConnectionTimeout());
+ assertEquals(CONNECTION_TYPE, config.getConnectionType());
+ assertEquals(CREATE_THREADSAFE_PROXY_CLIENTS, config.isCreateThreadSafeProxyClients());
+ assertEquals(FOLLOW_REDIRECTS, config.isFollowRedirectsAllowed());
+ assertEquals(MAX_RETRANSMITS, config.getMaxRetransmits());
+ assertEquals(NON_PROXY_HOSTS, config.getNonProxyHosts());
+ assertEquals(PROXY_ADDRESS, config.getProxyAddress());
+ assertEquals(PROXY_AUTHORIZATION_TYPE, config.getProxyAuthorizationType());
+ assertEquals(PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS, config.isProxyClientSubResourcesInheritHeaders());
+ assertEquals(PROXY_PASSWORD, config.getProxyPassword());
+ assertEquals(PROXY_TYPE, config.getProxyType());
+ assertEquals(PROXY_USERNAME, config.getProxyUsername());
+ assertEquals(RECEIVE_TIMEOUT, config.getReceiveTimeout());
+ assertEquals(SERVER_AUTHORIZATION_TYPE, config.getServerAuthorizationType());
+ assertEquals(SERVER_PASSWORD, config.getServerPassword());
+ assertEquals(SERVER_USERNAME, config.getServerUsername());
+ assertEquals(FULL_PROXY_ADDRESS, config.getFullProxyAddress());
+ assertEquals(true, config.isProxyAuthorizationRequired());
+ assertEquals(true, config.isProxyRequired());
+ assertEquals(true, config.isServerAuthorizationRequired());
+ }
+
+ @Test
+ public void testNoChangeAfterBuild() {
+ builder.allowChunking(CHUNKING_ALLOWED);
+ builder.asyncExecTimeout(ASYNC_EXECUTE_TIMEOUT);
+ builder.asyncExecTimeoutRejection(ASYNC_EXECUTE_TIMEOUT_REJECTION);
+ builder.chunkingThreshold(CHUNKING_THRESHOLD);
+ builder.chunkLength(CHUNK_SIZE);
+ builder.connectionTimeout(CONNECTION_TIMEOUT);
+ builder.connectionType(CONNECTION_TYPE);
+ builder.createThreadSafeProxyClients(CREATE_THREADSAFE_PROXY_CLIENTS);
+ builder.followRedirects(FOLLOW_REDIRECTS);
+ builder.maxRetransmits(MAX_RETRANSMITS);
+ builder.nonProxyHosts(NON_PROXY_HOSTS);
+ builder.proxyAddress(FULL_PROXY_ADDRESS);
+ builder.proxyAuthorizationType(PROXY_AUTHORIZATION_TYPE);
+ builder.proxyClientSubResourcesInheritHeaders(PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS);
+ builder.proxyPassword(PROXY_PASSWORD);
+ builder.proxyType(PROXY_TYPE);
+ builder.proxyUsername(PROXY_USERNAME);
+ builder.receiveTimeout(RECEIVE_TIMEOUT);
+ builder.authorizationType(SERVER_AUTHORIZATION_TYPE);
+ builder.password(SERVER_PASSWORD);
+ builder.username(SERVER_USERNAME);
+
+ JaxRsClient actual = builder.build();
+ JaxRsClientConfig config = actual.getConfig();
+
+ assertEquals(ASYNC_EXECUTE_TIMEOUT, config.getAsyncExecuteTimeout());
+ assertEquals(ASYNC_EXECUTE_TIMEOUT_REJECTION, config.isAsyncExecuteTimeoutRejection());
+ assertEquals(CHUNK_SIZE, config.getChunkLength());
+ assertEquals(CHUNKING_ALLOWED, config.isChunkingAllowed());
+ assertEquals(CHUNKING_THRESHOLD, config.getChunkingThreshold());
+ assertEquals(CONNECTION_TIMEOUT, config.getConnectionTimeout());
+ assertEquals(CONNECTION_TYPE, config.getConnectionType());
+ assertEquals(CREATE_THREADSAFE_PROXY_CLIENTS, config.isCreateThreadSafeProxyClients());
+ assertEquals(FOLLOW_REDIRECTS, config.isFollowRedirectsAllowed());
+ assertEquals(MAX_RETRANSMITS, config.getMaxRetransmits());
+ assertEquals(NON_PROXY_HOSTS, config.getNonProxyHosts());
+ assertEquals(PROXY_ADDRESS, config.getProxyAddress());
+ assertEquals(PROXY_AUTHORIZATION_TYPE, config.getProxyAuthorizationType());
+ assertEquals(PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS, config.isProxyClientSubResourcesInheritHeaders());
+ assertEquals(PROXY_PASSWORD, config.getProxyPassword());
+ assertEquals(PROXY_TYPE, config.getProxyType());
+ assertEquals(PROXY_USERNAME, config.getProxyUsername());
+ assertEquals(RECEIVE_TIMEOUT, config.getReceiveTimeout());
+ assertEquals(SERVER_AUTHORIZATION_TYPE, config.getServerAuthorizationType());
+ assertEquals(SERVER_PASSWORD, config.getServerPassword());
+ assertEquals(SERVER_USERNAME, config.getServerUsername());
+ assertEquals(FULL_PROXY_ADDRESS, config.getFullProxyAddress());
+ assertEquals(true, config.isProxyAuthorizationRequired());
+ assertEquals(true, config.isProxyRequired());
+ assertEquals(true, config.isServerAuthorizationRequired());
+
+ builder.properties(Collections.<String, Object> emptyMap());
+
+ actual = builder.build();
+ JaxRsClientConfig config2 = actual.getConfig();
+
+ assertEquals(ASYNC_EXECUTE_TIMEOUT, config.getAsyncExecuteTimeout());
+ assertEquals(ASYNC_EXECUTE_TIMEOUT_REJECTION, config.isAsyncExecuteTimeoutRejection());
+ assertEquals(CHUNK_SIZE, config.getChunkLength());
+ assertEquals(CHUNKING_ALLOWED, config.isChunkingAllowed());
+ assertEquals(CHUNKING_THRESHOLD, config.getChunkingThreshold());
+ assertEquals(CONNECTION_TIMEOUT, config.getConnectionTimeout());
+ assertEquals(CONNECTION_TYPE, config.getConnectionType());
+ assertEquals(CREATE_THREADSAFE_PROXY_CLIENTS, config.isCreateThreadSafeProxyClients());
+ assertEquals(FOLLOW_REDIRECTS, config.isFollowRedirectsAllowed());
+ assertEquals(MAX_RETRANSMITS, config.getMaxRetransmits());
+ assertEquals(NON_PROXY_HOSTS, config.getNonProxyHosts());
+ assertEquals(PROXY_ADDRESS, config.getProxyAddress());
+ assertEquals(PROXY_AUTHORIZATION_TYPE, config.getProxyAuthorizationType());
+ assertEquals(PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS, config.isProxyClientSubResourcesInheritHeaders());
+ assertEquals(PROXY_PASSWORD, config.getProxyPassword());
+ assertEquals(PROXY_TYPE, config.getProxyType());
+ assertEquals(PROXY_USERNAME, config.getProxyUsername());
+ assertEquals(RECEIVE_TIMEOUT, config.getReceiveTimeout());
+ assertEquals(SERVER_AUTHORIZATION_TYPE, config.getServerAuthorizationType());
+ assertEquals(SERVER_PASSWORD, config.getServerPassword());
+ assertEquals(SERVER_USERNAME, config.getServerUsername());
+ assertEquals(FULL_PROXY_ADDRESS, config.getFullProxyAddress());
+ assertEquals(true, config.isProxyAuthorizationRequired());
+ assertEquals(true, config.isProxyRequired());
+ assertEquals(true, config.isServerAuthorizationRequired());
+
+ //@formatter:off
+ assertEquals(DEFAULT_JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT, config2.getAsyncExecuteTimeout());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CHUNKING_THRESHOLD, config2.getChunkingThreshold());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CHUNK_SIZE, config2.getChunkLength());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CONNECTION_TIMEOUT, config2.getConnectionTimeout());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CONNECTION_TYPE, config2.getConnectionType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_ADDRESS, config2.getFullProxyAddress());
+ assertEquals(DEFAULT_JAXRS_CLIENT_MAX_RETRANSMITS, config2.getMaxRetransmits());
+ assertEquals(DEFAULT_JAXRS_CLIENT_NON_PROXY_HOSTS, config2.getNonProxyHosts());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_AUTHORIZATION_TYPE, config2.getProxyAuthorizationType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_ADDRESS, config2.getProxyAddress());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_PASSWORD, config2.getProxyPassword());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_PORT, config2.getProxyPort());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_TYPE, config2.getProxyType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_USERNAME, config2.getProxyUsername());
+ assertEquals(DEFAULT_JAXRS_CLIENT_RECEIVE_TIMEOUT, config2.getReceiveTimeout());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_AUTHORIZATION_TYPE, config2.getServerAuthorizationType());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_PASSWORD, config2.getServerPassword());
+ assertEquals(DEFAULT_JAXRS_CLIENT_SERVER_USERNAME, config2.getServerUsername());
+ assertEquals(DEFAULT_JAXRS_CLIENT_ASYNC_EXECUTE_TIMEOUT_REJECTION, config2.isAsyncExecuteTimeoutRejection());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CHUNKING_ALLOWED, config2.isChunkingAllowed());
+ assertEquals(DEFAULT_JAXRS_CLIENT_CREATE_THREADSAFE_PROXY_CLIENTS, config2.isCreateThreadSafeProxyClients());
+ assertEquals(DEFAULT_JAXRS_CLIENT_FOLLOW_REDIRECTS, config2.isFollowRedirectsAllowed());
+ assertEquals(DEFAULT_JAXRS_CLIENT_PROXY_CLIENT_SUB_RESOURCES_INHERIT_HEADERS, config2.isProxyClientSubResourcesInheritHeaders());
+ assertEquals(false, config2.isProxyAuthorizationRequired());
+ assertEquals(false, config2.isProxyRequired());
+ assertEquals(false, config2.isServerAuthorizationRequired());
+ //@formatter:on
+ }
+}
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java
new file mode 100644
index 0000000000..f726dc577f
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTest.java
@@ -0,0 +1,115 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.net.URI;
+import java.net.URISyntaxException;
+import javax.ws.rs.client.WebTarget;
+import org.eclipse.osee.jaxrs.client.JaxRsClient.JaxRsClientFactory;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+/**
+ * Test Case for {@link JaxRsClient}
+ *
+ * @author Roberto E. Escobar
+ */
+public class JaxRsClientTest {
+
+ private static final String URI_STRING = "hello";
+ private static final String URI = "http://hello.com";
+
+ //@formatter:off
+ @Mock private JaxRsClientFactory factory;
+ @Mock private JaxRsClientConfig config;
+ @Mock private WebTarget target;
+ //@formatter:on
+
+ private JaxRsClient client;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ client = new JaxRsClient(factory, config);
+ }
+
+ @Test
+ public void testTargetEmpty() {
+ when(factory.newTarget(config, null)).thenReturn(target);
+
+ WebTarget actual = client.target();
+ assertEquals(target, actual);
+ verify(factory).newTarget(config, null);
+ }
+
+ @Test
+ public void testTargetString() {
+ when(factory.newTarget(config, URI_STRING)).thenReturn(target);
+
+ WebTarget actual = client.target(URI_STRING);
+ assertEquals(target, actual);
+ verify(factory).newTarget(config, URI_STRING);
+ }
+
+ @Test
+ public void testTargetURI() throws URISyntaxException {
+ URI expectedUri = new URI(URI);
+
+ when(factory.newTarget(config, URI)).thenReturn(target);
+
+ WebTarget actual = client.target(expectedUri);
+ assertEquals(target, actual);
+ verify(factory).newTarget(config, URI);
+ }
+
+ @Test
+ public void testTargetProxyString() {
+ String instance = URI_STRING;
+ Class<?> clazz = String.class;
+
+ when(factory.newClient(config, URI_STRING, clazz)).thenAnswer(answer(instance));
+
+ Object actual = client.targetProxy(URI_STRING, clazz);
+ assertEquals(instance, actual);
+ verify(factory).newClient(config, URI_STRING, clazz);
+ }
+
+ @Test
+ public void testTargetProxyURI() throws URISyntaxException {
+ URI expectedUri = new URI(URI);
+ String instance = URI_STRING;
+ Class<?> clazz = String.class;
+
+ when(factory.newClient(config, URI, clazz)).thenAnswer(answer(instance));
+
+ Object actual = client.targetProxy(expectedUri, clazz);
+ assertEquals(instance, actual);
+ verify(factory).newClient(config, URI, clazz);
+ }
+
+ private static <T> Answer<T> answer(final T object) {
+ return new Answer<T>() {
+
+ @Override
+ public T answer(InvocationOnMock invocation) throws Throwable {
+ return object;
+ }
+ };
+ }
+}
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTestSuite.java b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTestSuite.java
new file mode 100644
index 0000000000..e193491af8
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/JaxRsClientTestSuite.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client;
+
+import org.eclipse.osee.jaxrs.client.internal.JaxRsClientInternalTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({JaxRsClientInternalTestSuite.class, JaxRsClientBuilderTest.class, JaxRsClientTest.class})
+public class JaxRsClientTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientInternalTestSuite.java b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientInternalTestSuite.java
new file mode 100644
index 0000000000..5a2b264063
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/JaxRsClientInternalTestSuite.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client.internal;
+
+import org.eclipse.osee.jaxrs.client.internal.ext.JaxRsClientExtTestSuite;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({JaxRsClientExtTestSuite.class})
+public class JaxRsClientInternalTestSuite {
+ // Test Suite
+}
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java
new file mode 100644
index 0000000000..83efe42475
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/CxfJaxRsClientConfiguratorTest.java
@@ -0,0 +1,409 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client.internal.ext;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.anyInt;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.ext.RuntimeDelegate;
+import org.apache.cxf.configuration.security.AuthorizationPolicy;
+import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy;
+import org.apache.cxf.feature.LoggingFeature;
+import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
+import org.apache.cxf.jaxrs.client.ThreadLocalClientState;
+import org.apache.cxf.transport.common.gzip.GZIPFeature;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+import org.apache.cxf.transports.http.configuration.ProxyServerType;
+import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
+import org.codehaus.jackson.jaxrs.JsonMappingExceptionMapper;
+import org.codehaus.jackson.jaxrs.JsonParseExceptionMapper;
+import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
+import org.eclipse.osee.jaxrs.client.JaxRsClientConfig;
+import org.eclipse.osee.jaxrs.client.JaxRsClientConstants.ConnectionType;
+import org.eclipse.osee.jaxrs.client.JaxRsClientConstants.ProxyType;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+/**
+ * Test Case for {@link CxfJaxRsClientConfigurator}
+ *
+ * @author Roberto E. Escobar
+ */
+public class CxfJaxRsClientConfiguratorTest {
+
+ private static final String SERVER_ADDRESS = "http://hello.com";
+
+ private static final long ASYNC_EXECUTE_TIMEOUT = 32423L;
+ private static final boolean ASYNC_EXECUTE_TIMEOUT_REJECTION = true;
+ private static final int CHUNK_SIZE = 864;
+ private static final boolean CHUNKING_ALLOWED = true;
+ private static final int CHUNKING_THRESHOLD = 9872394;
+ private static final long CONNECTION_TIMEOUT = 2327L;
+ private static final ConnectionType CONNECTION_TYPE = ConnectionType.CLOSE;
+ private static final boolean FOLLOW_REDIRECTS = false;
+ private static final int MAX_RETRANSMITS = 452;
+ private static final String NON_PROXY_HOSTS = "non-proxy-hosts";
+ private static final String PROXY_ADDRESS = "proxy-address.com";
+ private static final int PROXY_PORT = 78612;
+ private static final String PROXY_AUTHORIZATION_TYPE = "proxy-authentication-type";
+ private static final String PROXY_PASSWORD = "proxy-password";
+ private static final ProxyType PROXY_TYPE = ProxyType.SOCKS;
+ private static final String PROXY_USERNAME = "proxy-username";
+ private static final long RECEIVE_TIMEOUT = 87532L;
+ private static final String SERVER_AUTHORIZATION_TYPE = "server-authentication-type";
+ private static final String SERVER_PASSWORD = "server-password";
+ private static final String SERVER_USERNAME = "server-username";
+
+ private static final ProxyServerType CXF_PROXY_SERVER_TYPE = ProxyServerType.SOCKS;
+ private static final org.apache.cxf.transports.http.configuration.ConnectionType CXF_CONNECTION_TYPE =
+ org.apache.cxf.transports.http.configuration.ConnectionType.CLOSE;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ //@formatter:off
+ @Mock private JaxRsClientConfig config;
+ @Mock private HTTPConduit conduit;
+ @Mock private ClientBuilder builder;
+ @Mock private JAXRSClientFactoryBean bean;
+
+ @Mock private HTTPClientPolicy policy1;
+ @Mock private AuthorizationPolicy policy2;
+ @Mock private ProxyAuthorizationPolicy policy3;
+
+ @Captor private ArgumentCaptor<Object> captor;
+ @Captor private ArgumentCaptor<HTTPClientPolicy> captor1;
+ @Captor private ArgumentCaptor<AuthorizationPolicy> captor2;
+ @Captor private ArgumentCaptor<ProxyAuthorizationPolicy> captor3;
+ //@formatter:on
+
+ private Map<String, Object> props;
+ private CxfJaxRsClientConfigurator configurator;
+ private String mapAsString;
+
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+
+ configurator = new CxfJaxRsClientConfigurator();
+
+ props = new LinkedHashMap<String, Object>();
+ props.put("a", "1");
+ props.put("b", "2");
+ props.put("c", "3");
+ mapAsString = props.toString();
+ }
+
+ @Test
+ public void testConfigureJaxRsRuntime() {
+ configurator.configureJaxRsRuntime();
+
+ assertEquals(org.apache.cxf.jaxrs.impl.RuntimeDelegateImpl.class, RuntimeDelegate.getInstance().getClass());
+ assertEquals("org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl",
+ System.getProperty("javax.ws.rs.client.ClientBuilder"));
+ }
+
+ @Test
+ public void testConfigureDefaults() {
+ configurator.configureDefaults(props);
+
+ Iterator<? extends Object> iterator = configurator.getFeatures().iterator();
+ assertEquals(LoggingFeature.class, iterator.next().getClass());
+ assertEquals(GZIPFeature.class, iterator.next().getClass());
+
+ iterator = configurator.getProviders().iterator();
+ assertEquals(GenericResponseExceptionMapper.class, iterator.next().getClass());
+ assertEquals(JacksonJaxbJsonProvider.class, iterator.next().getClass());
+ assertEquals(JsonParseExceptionMapper.class, iterator.next());
+ assertEquals(JsonMappingExceptionMapper.class, iterator.next());
+
+ assertEquals(mapAsString, configurator.getProperties().toString());
+ }
+
+ @Test
+ public void testConfigureBean() {
+ when(config.isCreateThreadSafeProxyClients()).thenReturn(true);
+ when(config.isProxyClientSubResourcesInheritHeaders()).thenReturn(true);
+
+ configurator.configureBean(config, SERVER_ADDRESS, bean);
+
+ verify(bean).setProviders(configurator.getProviders());
+ verify(bean).setFeatures(configurator.getFeatures());
+ verify(bean).setProperties(configurator.getProperties());
+ verify(bean).setInheritHeaders(true);
+ verify(bean).setInitialState(Matchers.<ThreadLocalClientState> any());
+
+ verify(config).isCreateThreadSafeProxyClients();
+ verify(config).isProxyClientSubResourcesInheritHeaders();
+ }
+
+ @Test
+ public void testConfigureBeanOptionsFalse() {
+ when(config.isCreateThreadSafeProxyClients()).thenReturn(false);
+ when(config.isProxyClientSubResourcesInheritHeaders()).thenReturn(false);
+
+ configurator.configureBean(config, SERVER_ADDRESS, bean);
+
+ verify(bean).setProviders(configurator.getProviders());
+ verify(bean).setFeatures(configurator.getFeatures());
+ verify(bean).setProperties(configurator.getProperties());
+ verify(bean).setInheritHeaders(false);
+ verify(bean, times(0)).setInitialState(Matchers.<ThreadLocalClientState> any());
+
+ verify(config).isCreateThreadSafeProxyClients();
+ verify(config).isProxyClientSubResourcesInheritHeaders();
+ }
+
+ @Test
+ public void testConfigureBeanServerAddressNull() {
+ thrown.expect(OseeCoreException.class);
+ thrown.expectMessage("server address cannot be null");
+ configurator.configureBean(config, null, bean);
+ }
+
+ @Test
+ public void testConfigureBeanServerAddressEmpty() {
+ thrown.expect(OseeCoreException.class);
+ thrown.expectMessage("server address cannot be empty");
+ configurator.configureBean(config, "", bean);
+ }
+
+ @Test
+ public void testConfigureClientBuilder() {
+ configurator.configureDefaults(props);
+ configurator.configureClientBuilder(config, builder);
+
+ verify(builder, times(6)).register(captor.capture());
+
+ List<Object> actual = captor.getAllValues();
+ assertEquals(6, actual.size());
+
+ Iterator<Object> iterator = actual.iterator();
+ assertEquals(GenericResponseExceptionMapper.class, iterator.next().getClass());
+ assertEquals(JacksonJaxbJsonProvider.class, iterator.next().getClass());
+ assertEquals(JsonParseExceptionMapper.class, iterator.next());
+ assertEquals(JsonMappingExceptionMapper.class, iterator.next());
+ assertEquals(LoggingFeature.class, iterator.next().getClass());
+ assertEquals(GZIPFeature.class, iterator.next().getClass());
+
+ verify(builder).property("a", "1");
+ verify(builder).property("b", "2");
+ verify(builder).property("c", "3");
+ }
+
+ @Test
+ public void testConfigureConduitWithAuthorization() {
+ when(conduit.getClient()).thenReturn(policy1);
+ when(conduit.getAuthorization()).thenReturn(policy2);
+
+ when(config.isChunkingAllowed()).thenReturn(CHUNKING_ALLOWED);
+ when(config.getAsyncExecuteTimeout()).thenReturn(ASYNC_EXECUTE_TIMEOUT);
+ when(config.isAsyncExecuteTimeoutRejection()).thenReturn(ASYNC_EXECUTE_TIMEOUT_REJECTION);
+ when(config.isFollowRedirectsAllowed()).thenReturn(FOLLOW_REDIRECTS);
+ when(config.getChunkingThreshold()).thenReturn(CHUNKING_THRESHOLD);
+ when(config.getChunkLength()).thenReturn(CHUNK_SIZE);
+ when(config.getConnectionType()).thenReturn(CONNECTION_TYPE);
+ when(config.getConnectionTimeout()).thenReturn(CONNECTION_TIMEOUT);
+ when(config.getMaxRetransmits()).thenReturn(MAX_RETRANSMITS);
+ when(config.getReceiveTimeout()).thenReturn(RECEIVE_TIMEOUT);
+
+ when(config.isServerAuthorizationRequired()).thenReturn(true);
+ when(config.getServerUsername()).thenReturn(SERVER_USERNAME);
+ when(config.getServerPassword()).thenReturn(SERVER_PASSWORD);
+ when(config.getServerAuthorizationType()).thenReturn(SERVER_AUTHORIZATION_TYPE);
+
+ configurator.configureConnection(config, conduit);
+
+ verify(conduit).getClient();
+ verify(policy1).setAllowChunking(CHUNKING_ALLOWED);
+ verify(policy1).setAsyncExecuteTimeout(ASYNC_EXECUTE_TIMEOUT);
+ verify(policy1).setAsyncExecuteTimeoutRejection(ASYNC_EXECUTE_TIMEOUT_REJECTION);
+ verify(policy1).setAutoRedirect(FOLLOW_REDIRECTS);
+ verify(policy1).setChunkingThreshold(CHUNKING_THRESHOLD);
+ verify(policy1).setChunkLength(CHUNK_SIZE);
+ verify(policy1).setConnection(CXF_CONNECTION_TYPE);
+ verify(policy1).setConnectionTimeout(CONNECTION_TIMEOUT);
+ verify(policy1).setMaxRetransmits(MAX_RETRANSMITS);
+ verify(policy1).setReceiveTimeout(RECEIVE_TIMEOUT);
+
+ verify(conduit).getAuthorization();
+ verify(policy2).setUserName(SERVER_USERNAME);
+ verify(policy2).setPassword(SERVER_PASSWORD);
+ verify(policy2).setAuthorizationType(SERVER_AUTHORIZATION_TYPE);
+
+ verify(conduit, times(0)).getProxyAuthorization();
+ verify(conduit, times(0)).setClient(Matchers.<HTTPClientPolicy> any());
+ verify(conduit, times(0)).setAuthorization(Matchers.<AuthorizationPolicy> any());
+ verify(conduit, times(0)).setProxyAuthorization(Matchers.<ProxyAuthorizationPolicy> any());
+ }
+
+ @Test
+ public void testConfigureConduitNoAuthorization() {
+ when(conduit.getClient()).thenReturn(policy1);
+ when(conduit.getAuthorization()).thenReturn(policy2);
+
+ when(config.isChunkingAllowed()).thenReturn(CHUNKING_ALLOWED);
+ when(config.getAsyncExecuteTimeout()).thenReturn(ASYNC_EXECUTE_TIMEOUT);
+ when(config.isAsyncExecuteTimeoutRejection()).thenReturn(ASYNC_EXECUTE_TIMEOUT_REJECTION);
+ when(config.isFollowRedirectsAllowed()).thenReturn(FOLLOW_REDIRECTS);
+ when(config.getChunkingThreshold()).thenReturn(CHUNKING_THRESHOLD);
+ when(config.getChunkLength()).thenReturn(CHUNK_SIZE);
+ when(config.getConnectionType()).thenReturn(CONNECTION_TYPE);
+ when(config.getConnectionTimeout()).thenReturn(CONNECTION_TIMEOUT);
+ when(config.getMaxRetransmits()).thenReturn(MAX_RETRANSMITS);
+ when(config.getReceiveTimeout()).thenReturn(RECEIVE_TIMEOUT);
+
+ when(config.isServerAuthorizationRequired()).thenReturn(false);
+ when(config.getServerUsername()).thenReturn(SERVER_USERNAME);
+ when(config.getServerPassword()).thenReturn(SERVER_PASSWORD);
+ when(config.getServerAuthorizationType()).thenReturn(SERVER_AUTHORIZATION_TYPE);
+
+ configurator.configureConnection(config, conduit);
+
+ verify(conduit).getClient();
+ verify(policy1).setAllowChunking(CHUNKING_ALLOWED);
+ verify(policy1).setAsyncExecuteTimeout(ASYNC_EXECUTE_TIMEOUT);
+ verify(policy1).setAsyncExecuteTimeoutRejection(ASYNC_EXECUTE_TIMEOUT_REJECTION);
+ verify(policy1).setAutoRedirect(FOLLOW_REDIRECTS);
+ verify(policy1).setChunkingThreshold(CHUNKING_THRESHOLD);
+ verify(policy1).setChunkLength(CHUNK_SIZE);
+ verify(policy1).setConnection(CXF_CONNECTION_TYPE);
+ verify(policy1).setConnectionTimeout(CONNECTION_TIMEOUT);
+ verify(policy1).setMaxRetransmits(MAX_RETRANSMITS);
+ verify(policy1).setReceiveTimeout(RECEIVE_TIMEOUT);
+
+ verify(conduit, times(0)).getAuthorization();
+ verify(policy2, times(0)).setUserName(anyString());
+ verify(policy2, times(0)).setPassword(anyString());
+ verify(policy2, times(0)).setAuthorizationType(anyString());
+
+ verify(conduit, times(0)).getProxyAuthorization();
+ }
+
+ @Test
+ public void testConfigureProxyNotRequired() {
+ when(config.isProxyRequired()).thenReturn(false);
+
+ configurator.configureProxy(config, conduit);
+
+ verify(conduit, times(0)).getClient();
+ verify(policy1, times(0)).setProxyServer(anyString());
+ verify(policy1, times(0)).setProxyServerPort(anyInt());
+ verify(policy1, times(0)).setNonProxyHosts(anyString());
+ verify(policy1, times(0)).setProxyServerType(Matchers.<ProxyServerType> any());
+
+ verify(conduit, times(0)).getProxyAuthorization();
+ verify(policy3, times(0)).setUserName(anyString());
+ verify(policy3, times(0)).setPassword(anyString());
+ verify(policy3, times(0)).setAuthorizationType(anyString());
+ }
+
+ @Test
+ public void testConfigureProxyWithAuthorization() {
+ when(conduit.getClient()).thenReturn(policy1);
+ when(conduit.getProxyAuthorization()).thenReturn(policy3);
+
+ when(config.isProxyRequired()).thenReturn(true);
+ when(config.getNonProxyHosts()).thenReturn(NON_PROXY_HOSTS);
+ when(config.getProxyType()).thenReturn(PROXY_TYPE);
+
+ when(config.isProxyAuthorizationRequired()).thenReturn(true);
+ when(config.getProxyAddress()).thenReturn(PROXY_ADDRESS);
+ when(config.getProxyPort()).thenReturn(PROXY_PORT);
+ when(config.getProxyUsername()).thenReturn(PROXY_USERNAME);
+ when(config.getProxyPassword()).thenReturn(PROXY_PASSWORD);
+ when(config.getProxyAuthorizationType()).thenReturn(PROXY_AUTHORIZATION_TYPE);
+
+ configurator.configureProxy(config, conduit);
+
+ verify(conduit).getClient();
+ verify(policy1).setProxyServer(PROXY_ADDRESS);
+ verify(policy1).setProxyServerPort(PROXY_PORT);
+ verify(policy1).setNonProxyHosts(NON_PROXY_HOSTS);
+ verify(policy1).setProxyServerType(CXF_PROXY_SERVER_TYPE);
+
+ verify(conduit).getProxyAuthorization();
+ verify(policy3).setUserName(PROXY_USERNAME);
+ verify(policy3).setPassword(PROXY_PASSWORD);
+ verify(policy3).setAuthorizationType(PROXY_AUTHORIZATION_TYPE);
+
+ verify(conduit, times(0)).getAuthorization();
+ verify(conduit, times(0)).setClient(Matchers.<HTTPClientPolicy> any());
+ verify(conduit, times(0)).setAuthorization(Matchers.<AuthorizationPolicy> any());
+ verify(conduit, times(0)).setProxyAuthorization(Matchers.<ProxyAuthorizationPolicy> any());
+ }
+
+ @Test
+ public void testConfigureProxyNoPortAndNoAuthorization() {
+ when(conduit.getClient()).thenReturn(policy1);
+
+ when(config.isProxyRequired()).thenReturn(true);
+ when(config.getNonProxyHosts()).thenReturn(NON_PROXY_HOSTS);
+ when(config.getProxyType()).thenReturn(PROXY_TYPE);
+
+ when(config.isProxyAuthorizationRequired()).thenReturn(false);
+ when(config.getProxyAddress()).thenReturn(PROXY_ADDRESS);
+ when(config.getProxyPort()).thenReturn(-1);
+
+ configurator.configureProxy(config, conduit);
+
+ verify(conduit).getClient();
+ verify(policy1).setProxyServer(PROXY_ADDRESS);
+ verify(policy1, times(0)).setProxyServerPort(anyInt());
+ verify(policy1).setNonProxyHosts(NON_PROXY_HOSTS);
+ verify(policy1).setProxyServerType(CXF_PROXY_SERVER_TYPE);
+
+ verify(conduit, times(0)).getProxyAuthorization();
+ verify(policy3, times(0)).setUserName(anyString());
+ verify(policy3, times(0)).setPassword(anyString());
+ verify(policy3, times(0)).setAuthorizationType(anyString());
+ }
+
+ @Test
+ public void testConduitPolicyNull() {
+ when(conduit.getClient()).thenReturn(null);
+ when(conduit.getAuthorization()).thenReturn(null);
+ when(conduit.getProxyAuthorization()).thenReturn(null);
+
+ when(config.isProxyRequired()).thenReturn(true);
+ when(config.isProxyAuthorizationRequired()).thenReturn(true);
+ when(config.isServerAuthorizationRequired()).thenReturn(true);
+
+ configurator.configureConnection(config, conduit);
+ configurator.configureProxy(config, conduit);
+
+ verify(conduit, times(2)).setClient(captor1.capture());
+ verify(conduit).setAuthorization(captor2.capture());
+ verify(conduit).setProxyAuthorization(captor3.capture());
+
+ assertNotNull(captor1.getValue());
+ assertNotNull(captor2.getValue());
+ assertNotNull(captor3.getValue());
+ }
+
+}
diff --git a/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/JaxRsClientExtTestSuite.java b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/JaxRsClientExtTestSuite.java
new file mode 100644
index 0000000000..2b270c6347
--- /dev/null
+++ b/plugins/org.eclipse.osee.jaxrs.client.test/src/org/eclipse/osee/jaxrs/client/internal/ext/JaxRsClientExtTestSuite.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Boeing.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.jaxrs.client.internal.ext;
+
+import org.eclipse.osee.jaxrs.client.internal.ext.CxfJaxRsClientConfiguratorTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({CxfJaxRsClientConfiguratorTest.class})
+public class JaxRsClientExtTestSuite {
+ // Test Suite
+}

Back to the top