Moved classic HttpClient and HC fluent integration tests to httpclient-testing module

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1793319 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2017-05-01 12:38:41 +00:00
parent 25c6afed7c
commit da5797f470
32 changed files with 125 additions and 104 deletions

View File

@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<Configuration status="WARN" name="XMLConfigTest">
<Appenders>
<Console name="STDOUT">
<PatternLayout pattern="%d %-5level [%t][%logger]%notEmpty{[%markerSimpleName]} %msg%n%xThrowable" />
</Console>
</Appenders>
<Loggers>
<Root level="WARN">
<AppenderRef ref="STDOUT" />
</Root>
</Loggers>
</Configuration>

View File

@ -43,6 +43,23 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-fluent</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.client5</groupId>
<artifactId>httpclient5-win</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5-testing</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
@ -53,6 +70,16 @@
<artifactId>log4j-core</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.localserver;
package org.apache.hc.client5.testing.auth;
import java.nio.charset.StandardCharsets;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.localserver;
package org.apache.hc.client5.testing.auth;
import java.io.IOException;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.localserver;
package org.apache.hc.client5.testing.auth;
import java.io.IOException;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.localserver;
package org.apache.hc.client5.testing.classic;
import java.io.IOException;
import java.util.Locale;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.localserver;
package org.apache.hc.client5.testing.classic;
import java.io.IOException;
import java.io.InputStream;

View File

@ -0,0 +1,48 @@
/*
* ====================================================================
* 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.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.win;
import com.sun.jna.platform.win32.Sspi;
import com.sun.jna.platform.win32.Win32Exception;
import com.sun.jna.platform.win32.WinError;
public final class WindowsNegotiateSchemeGetTokenFail extends WindowsNegotiateScheme {
public WindowsNegotiateSchemeGetTokenFail(final String scheme, final String servicePrincipalName) {
super(scheme, servicePrincipalName);
}
@Override
String getToken(final Sspi.CtxtHandle continueCtx, final Sspi.SecBufferDesc continueToken, final String targetName) {
dispose();
/* We will rather throw SEC_E_TARGET_UNKNOWN because SEC_E_DOWNGRADE_DETECTED is not
* available on Windows XP and this unit test always fails.
*/
throw new Win32Exception(WinError.SEC_E_TARGET_UNKNOWN);
}
}

View File

@ -24,15 +24,18 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.fluent;
package org.apache.hc.client5.testing.fluent;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.Charset;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.fluent.Content;
import org.apache.hc.client5.http.fluent.Executor;
import org.apache.hc.client5.http.fluent.Request;
import org.apache.hc.client5.http.protocol.ClientProtocolException;
import org.apache.hc.client5.testing.sync.LocalServerTestBase;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.ContentType;

View File

@ -25,11 +25,13 @@
*
*/
package org.apache.hc.client5.http.localserver;
package org.apache.hc.client5.testing.sync;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.HttpClientBuilder;
import org.apache.hc.client5.testing.classic.EchoHandler;
import org.apache.hc.client5.testing.classic.RandomHandler;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.config.SocketConfig;
import org.apache.hc.core5.http.impl.bootstrap.HttpServer;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.localserver;
package org.apache.hc.client5.testing.sync;
import javax.net.ssl.SSLContext;

View File

@ -24,11 +24,10 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import org.apache.hc.client5.http.impl.io.BasicHttpClientConnectionManager;
import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.io.entity.EntityUtils;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@ -47,16 +47,15 @@ import org.apache.hc.client5.http.impl.auth.BasicAuthCache;
import org.apache.hc.client5.http.impl.auth.BasicScheme;
import org.apache.hc.client5.http.impl.protocol.DefaultAuthenticationStrategy;
import org.apache.hc.client5.http.impl.sync.BasicCredentialsProvider;
import org.apache.hc.client5.http.localserver.BasicAuthTokenExtractor;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.localserver.RequestBasicAuth;
import org.apache.hc.client5.http.localserver.ResponseBasicUnauthorized;
import org.apache.hc.client5.http.protocol.ClientProtocolException;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.protocol.NonRepeatableRequestException;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.client5.http.sync.methods.HttpPost;
import org.apache.hc.client5.http.sync.methods.HttpPut;
import org.apache.hc.client5.testing.auth.BasicAuthTokenExtractor;
import org.apache.hc.client5.testing.auth.RequestBasicAuth;
import org.apache.hc.client5.testing.auth.ResponseBasicUnauthorized;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.EndpointDetails;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
@ -32,7 +32,6 @@ import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.NTCredentials;
import org.apache.hc.client5.http.impl.sync.BasicCredentialsProvider;
import org.apache.hc.client5.http.impl.sync.HttpClients;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -33,10 +33,9 @@ import org.apache.hc.client5.http.auth.AuthScope;
import org.apache.hc.client5.http.auth.Credentials;
import org.apache.hc.client5.http.auth.CredentialsProvider;
import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.localserver.RequestBasicAuth;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.client5.testing.auth.RequestBasicAuth;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.EntityDetails;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -41,10 +41,9 @@ import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.impl.auth.BasicScheme;
import org.apache.hc.client5.http.impl.auth.BasicSchemeFactory;
import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.localserver.RequestBasicAuth;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.client5.testing.auth.RequestBasicAuth;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.EntityDetails;

View File

@ -24,14 +24,13 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.URI;
import java.util.List;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.protocol.ClientProtocolException;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.protocol.NonRepeatableRequestException;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@ -38,7 +38,6 @@ import java.util.concurrent.TimeoutException;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.io.ConnectionEndpoint;
import org.apache.hc.client5.http.io.LeaseRequest;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.function.Supplier;
import org.apache.hc.core5.http.ClassicHttpResponse;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.util.Collections;
import java.util.concurrent.TimeUnit;
@ -35,7 +35,6 @@ import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager;
import org.apache.hc.client5.http.io.ConnectionEndpoint;
import org.apache.hc.client5.http.io.LeaseRequest;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.HttpHost;

View File

@ -25,15 +25,14 @@
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.net.URI;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.localserver.RandomHandler;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.client5.testing.classic.RandomHandler;
import org.apache.hc.core5.http.ClassicHttpResponse;
import org.apache.hc.core5.http.EntityDetails;
import org.apache.hc.core5.http.Header;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -43,7 +43,6 @@ import java.util.zip.GZIPOutputStream;
import org.apache.hc.client5.http.impl.sync.BasicResponseHandler;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.net.URI;
@ -34,7 +34,6 @@ import org.apache.hc.client5.http.cookie.BasicCookieStore;
import org.apache.hc.client5.http.cookie.Cookie;
import org.apache.hc.client5.http.cookie.CookieStore;
import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;

View File

@ -25,11 +25,10 @@
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import org.apache.hc.client5.http.impl.IdleConnectionEvictor;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.protocol.ClientProtocolException;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;

View File

@ -24,13 +24,12 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.net.Socket;
import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.util.HashSet;
@ -32,7 +32,6 @@ import java.util.Locale;
import java.util.Set;
import org.apache.hc.client5.http.impl.sync.HttpClients;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.net.InetSocketAddress;
@ -36,7 +36,6 @@ import org.apache.hc.client5.http.config.RequestConfig;
import org.apache.hc.client5.http.cookie.BasicCookieStore;
import org.apache.hc.client5.http.cookie.CookieStore;
import org.apache.hc.client5.http.impl.cookie.BasicClientCookie;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.protocol.CircularRedirectException;
import org.apache.hc.client5.http.protocol.ClientProtocolException;
import org.apache.hc.client5.http.protocol.HttpClientContext;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.security.Principal;
@ -37,7 +37,6 @@ import org.apache.hc.client5.http.config.AuthSchemes;
import org.apache.hc.client5.http.impl.auth.SPNegoScheme;
import org.apache.hc.client5.http.impl.sync.BasicCredentialsProvider;
import org.apache.hc.client5.http.impl.sync.HttpClients;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;

View File

@ -25,7 +25,7 @@
*
*/
package org.apache.hc.client5.http.ssl;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import java.net.InetSocketAddress;
@ -43,7 +43,10 @@ import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocket;
import org.apache.hc.client5.http.localserver.SSLTestContexts;
import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
import org.apache.hc.client5.http.ssl.SSLConnectionSocketFactory;
import org.apache.hc.client5.http.ssl.TrustAllStrategy;
import org.apache.hc.client5.http.ssl.TrustSelfSignedStrategy;
import org.apache.hc.core5.http.HttpHost;
import org.apache.hc.core5.http.impl.bootstrap.HttpServer;
import org.apache.hc.core5.http.impl.bootstrap.SSLServerSetupHandler;

View File

@ -24,13 +24,12 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.integration;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
import org.apache.hc.client5.http.HttpRoute;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.client5.http.protocol.UserTokenHandler;
import org.apache.hc.client5.http.sync.methods.HttpGet;

View File

@ -24,7 +24,7 @@
* <http://www.apache.org/>.
*
*/
package org.apache.hc.client5.http.impl.win;
package org.apache.hc.client5.testing.sync;
import java.io.IOException;
@ -34,7 +34,8 @@ import org.apache.hc.client5.http.config.AuthSchemes;
import org.apache.hc.client5.http.impl.sync.CloseableHttpClient;
import org.apache.hc.client5.http.impl.sync.CloseableHttpResponse;
import org.apache.hc.client5.http.impl.sync.HttpClientBuilder;
import org.apache.hc.client5.http.localserver.LocalServerTestBase;
import org.apache.hc.client5.http.impl.win.WinHttpClients;
import org.apache.hc.client5.http.impl.win.WindowsNegotiateSchemeGetTokenFail;
import org.apache.hc.client5.http.sync.methods.HttpGet;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
@ -52,11 +53,6 @@ import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import com.sun.jna.platform.win32.Sspi.CtxtHandle;
import com.sun.jna.platform.win32.Sspi.SecBufferDesc;
import com.sun.jna.platform.win32.Win32Exception;
import com.sun.jna.platform.win32.WinError;
/**
* Unit tests for Windows negotiate authentication.
*/
@ -113,21 +109,4 @@ public class TestWindowsNegotiateScheme extends LocalServerTestBase {
}
}
private final class WindowsNegotiateSchemeGetTokenFail extends WindowsNegotiateScheme {
public WindowsNegotiateSchemeGetTokenFail(final String scheme, final String servicePrincipalName) {
super(scheme, servicePrincipalName);
}
@Override
String getToken(final CtxtHandle continueCtx, final SecBufferDesc continueToken, final String targetName) {
dispose();
/* We will rather throw SEC_E_TARGET_UNKNOWN because SEC_E_DOWNGRADE_DETECTED is not
* available on Windows XP and this unit test always fails.
*/
throw new Win32Exception(WinError.SEC_E_TARGET_UNKNOWN);
}
}
}

View File

@ -93,6 +93,11 @@
<artifactId>httpcore5-h2</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents.core5</groupId>
<artifactId>httpcore5-testing</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>