You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2016/01/12 21:43:42 UTC
svn commit: r1724315 [14/14] - in /httpcomponents/httpclient/trunk: ./
fluent-hc/src/examples/org/apache/http/client/fluent/
fluent-hc/src/main/java/org/apache/http/client/fluent/
fluent-hc/src/test/java/org/apache/http/client/fluent/ httpclient-cache/...
Modified: httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/FormBodyPartTest.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/FormBodyPartTest.java?rev=1724315&r1=1724314&r2=1724315&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/FormBodyPartTest.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/FormBodyPartTest.java Tue Jan 12 20:43:36 2016
@@ -27,13 +27,13 @@
package org.apache.http.entity.mime;
-import org.apache.http.entity.ContentType;
+import java.io.File;
+
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.entity.mime.content.FileBody;
import org.junit.Assert;
import org.junit.Test;
-import java.io.File;
-
public class FormBodyPartTest {
@Test
Modified: httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java?rev=1724315&r1=1724314&r2=1724315&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestFormBodyPartBuilder.java Tue Jan 12 20:43:36 2016
@@ -31,7 +31,7 @@ import java.io.File;
import java.util.Arrays;
import java.util.List;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.StringBody;
import org.junit.Assert;
Modified: httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java?rev=1724315&r1=1724314&r2=1724315&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java Tue Jan 12 20:43:36 2016
@@ -28,9 +28,9 @@
package org.apache.http.entity.mime;
import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Consts;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.entity.mime.content.StringBody;
import org.junit.Assert;
@@ -53,9 +53,9 @@ public class TestMultipartContentBody {
Assert.assertEquals(MIME.ENC_8BIT, b1.getTransferEncoding());
final StringBody b2 = new StringBody("more text",
- ContentType.create("text/other", MIME.DEFAULT_CHARSET));
+ ContentType.create("text/other", StandardCharsets.ISO_8859_1));
Assert.assertEquals(9, b2.getContentLength());
- Assert.assertEquals(MIME.DEFAULT_CHARSET.name(), b2.getCharset());
+ Assert.assertEquals(StandardCharsets.ISO_8859_1.name(), b2.getCharset());
Assert.assertNull(b2.getFilename());
Assert.assertEquals("text/other", b2.getMimeType());
@@ -72,12 +72,12 @@ public class TestMultipartContentBody {
@Test(expected=IllegalArgumentException.class)
public void testStringBodyInvalidConstruction2() throws Exception {
- Assert.assertNotNull(new StringBody("stuff", (ContentType) null)); // avoid unused warning
+ Assert.assertNotNull(new StringBody("stuff", null)); // avoid unused warning
}
@Test
public void testInputStreamBody() throws Exception {
- final byte[] stuff = "Stuff".getBytes(Consts.ASCII);
+ final byte[] stuff = "Stuff".getBytes(StandardCharsets.US_ASCII);
final InputStreamBody b1 = new InputStreamBody(new ByteArrayInputStream(stuff), "stuff");
Assert.assertEquals(-1, b1.getContentLength());
Modified: httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java?rev=1724315&r1=1724314&r2=1724315&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartEntityBuilder.java Tue Jan 12 20:43:36 2016
@@ -29,12 +29,11 @@ package org.apache.http.entity.mime;
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.nio.charset.StandardCharsets;
import java.util.List;
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.entity.ContentType;
-import org.apache.http.message.BasicNameValuePair;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.message.BasicNameValuePair;
import org.junit.Assert;
import org.junit.Test;
@@ -52,13 +51,13 @@ public class TestMultipartEntityBuilder
public void testMultipartOptions() throws Exception {
final MultipartFormEntity entity = MultipartEntityBuilder.create()
.setBoundary("blah-blah")
- .setCharset(Consts.UTF_8)
+ .setCharset(StandardCharsets.UTF_8)
.setLaxMode()
.buildEntity();
Assert.assertNotNull(entity);
Assert.assertTrue(entity.getMultipart() instanceof HttpBrowserCompatibleMultipart);
Assert.assertEquals("blah-blah", entity.getMultipart().boundary);
- Assert.assertEquals(Consts.UTF_8, entity.getMultipart().charset);
+ Assert.assertEquals(StandardCharsets.UTF_8, entity.getMultipart().charset);
}
@Test
@@ -80,13 +79,11 @@ public class TestMultipartEntityBuilder
final MultipartFormEntity entity = MultipartEntityBuilder.create()
.setContentType(ContentType.APPLICATION_XML)
.setBoundary("blah-blah")
- .setCharset(Consts.UTF_8)
+ .setCharset(StandardCharsets.UTF_8)
.setLaxMode()
.buildEntity();
Assert.assertNotNull(entity);
- final Header contentType = entity.getContentType();
- Assert.assertNotNull(contentType);
- Assert.assertEquals("application/xml; boundary=blah-blah; charset=UTF-8", contentType.getValue());
+ Assert.assertEquals("application/xml; boundary=blah-blah; charset=UTF-8", entity.getContentType());
}
@Test
@@ -97,12 +94,9 @@ public class TestMultipartEntityBuilder
new BasicNameValuePair("charset", "ascii")))
.buildEntity();
Assert.assertNotNull(entity);
- final Header contentType = entity.getContentType();
- Assert.assertNotNull(contentType);
- Assert.assertEquals("multipart/form-data; boundary=yada-yada; charset=US-ASCII",
- contentType.getValue());
+ Assert.assertEquals("multipart/form-data; boundary=yada-yada; charset=US-ASCII", entity.getContentType());
Assert.assertEquals("yada-yada", entity.getMultipart().boundary);
- Assert.assertEquals(Consts.ASCII, entity.getMultipart().charset);
+ Assert.assertEquals(StandardCharsets.US_ASCII, entity.getMultipart().charset);
}
@Test
@@ -113,14 +107,12 @@ public class TestMultipartEntityBuilder
new BasicNameValuePair("charset", "ascii"),
new BasicNameValuePair("my", "stuff")))
.setBoundary("blah-blah")
- .setCharset(Consts.UTF_8)
+ .setCharset(StandardCharsets.UTF_8)
.setLaxMode()
.buildEntity();
Assert.assertNotNull(entity);
- final Header contentType = entity.getContentType();
- Assert.assertNotNull(contentType);
Assert.assertEquals("multipart/form-data; boundary=blah-blah; charset=UTF-8; my=stuff",
- contentType.getValue());
+ entity.getContentType());
}
}
Modified: httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java?rev=1724315&r1=1724314&r2=1724315&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartForm.java Tue Jan 12 20:43:36 2016
@@ -33,10 +33,10 @@ import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.Writer;
import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
-import org.apache.http.Consts;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.entity.ContentType;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.apache.http.entity.mime.content.StringBody;
@@ -63,7 +63,7 @@ public class TestMultipartForm {
final FormBodyPart p2 = FormBodyPartBuilder.create(
"field2",
new StringBody("that stuff", ContentType.create(
- ContentType.TEXT_PLAIN.getMimeType(), Consts.UTF_8))).build();
+ ContentType.TEXT_PLAIN.getMimeType(), StandardCharsets.UTF_8))).build();
final FormBodyPart p3 = FormBodyPartBuilder.create(
"field3",
new StringBody("all kind of stuff", ContentType.DEFAULT_TEXT)).build();
@@ -317,7 +317,7 @@ public class TestMultipartForm {
"field2",
new InputStreamBody(new FileInputStream(tmpfile), s2 + ".tmp")).build();
final HttpBrowserCompatibleMultipart multipart = new HttpBrowserCompatibleMultipart(
- Consts.UTF_8, "foo",
+ StandardCharsets.UTF_8, "foo",
Arrays.asList(p1, p2));
final ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -368,17 +368,17 @@ public class TestMultipartForm {
"Content-Disposition: form-data; name=\"field1\"\r\n" +
"Content-Type: text/plain; charset=ISO-8859-1\r\n" +
"Content-Transfer-Encoding: 8bit\r\n" +
- "\r\n").getBytes(Consts.ASCII));
- out2.write(s1.getBytes(Consts.ISO_8859_1));
+ "\r\n").getBytes(StandardCharsets.US_ASCII));
+ out2.write(s1.getBytes(StandardCharsets.ISO_8859_1));
out2.write(("\r\n" +
"--foo\r\n" +
"Content-Disposition: form-data; name=\"field2\"\r\n" +
"Content-Type: text/plain; charset=KOI8-R\r\n" +
"Content-Transfer-Encoding: 8bit\r\n" +
- "\r\n").getBytes(Consts.ASCII));
+ "\r\n").getBytes(StandardCharsets.US_ASCII));
out2.write(s2.getBytes(Charset.forName("KOI8-R")));
out2.write(("\r\n" +
- "--foo--\r\n").getBytes(Consts.ASCII));
+ "--foo--\r\n").getBytes(StandardCharsets.US_ASCII));
out2.close();
final byte[] actual = out1.toByteArray();
Modified: httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java?rev=1724315&r1=1724314&r2=1724315&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartFormHttpEntity.java Tue Jan 12 20:43:36 2016
@@ -29,12 +29,14 @@ package org.apache.http.entity.mime;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.nio.charset.StandardCharsets;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.entity.ContentType;
+import org.apache.hc.core5.http.HeaderElement;
+import org.apache.hc.core5.http.HttpEntity;
+import org.apache.hc.core5.http.NameValuePair;
+import org.apache.hc.core5.http.entity.ContentType;
+import org.apache.hc.core5.http.message.BasicHeaderValueParser;
+import org.apache.hc.core5.http.message.ParserCursor;
import org.apache.http.entity.mime.content.InputStreamBody;
import org.junit.Assert;
import org.junit.Test;
@@ -46,17 +48,13 @@ public class TestMultipartFormHttpEntity
final HttpEntity entity = MultipartEntityBuilder.create()
.setLaxMode()
.setBoundary("whatever")
- .setCharset(MIME.UTF8_CHARSET)
+ .setCharset(StandardCharsets.UTF_8)
.build();
Assert.assertNull(entity.getContentEncoding());
- Assert.assertNotNull(entity.getContentType());
- final Header header = entity.getContentType();
- final HeaderElement[] elems = header.getElements();
- Assert.assertNotNull(elems);
- Assert.assertEquals(1, elems.length);
-
- final HeaderElement elem = elems[0];
+ final String contentType = entity.getContentType();
+ final HeaderElement elem = BasicHeaderValueParser.INSTANCE.parseHeaderElement(contentType,
+ new ParserCursor(0, contentType.length()));
Assert.assertEquals("multipart/form-data", elem.getName());
final NameValuePair p1 = elem.getParameterByName("boundary");
Assert.assertNotNull(p1);
@@ -70,13 +68,9 @@ public class TestMultipartFormHttpEntity
public void testImplictContractorParams() throws Exception {
final HttpEntity entity = MultipartEntityBuilder.create().build();
Assert.assertNull(entity.getContentEncoding());
- Assert.assertNotNull(entity.getContentType());
- final Header header = entity.getContentType();
- final HeaderElement[] elems = header.getElements();
- Assert.assertNotNull(elems);
- Assert.assertEquals(1, elems.length);
-
- final HeaderElement elem = elems[0];
+ final String contentType = entity.getContentType();
+ final HeaderElement elem = BasicHeaderValueParser.INSTANCE.parseHeaderElement(contentType,
+ new ParserCursor(0, contentType.length()));
Assert.assertEquals("multipart/form-data", elem.getName());
final NameValuePair p1 = elem.getParameterByName("boundary");
Assert.assertNotNull(p1);
Modified: httpcomponents/httpclient/trunk/pom.xml
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/pom.xml?rev=1724315&r1=1724314&r2=1724315&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/pom.xml (original)
+++ httpcomponents/httpclient/trunk/pom.xml Tue Jan 12 20:43:36 2016
@@ -66,7 +66,7 @@
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
- <httpcore.version>4.4.1</httpcore.version>
+ <httpcore.version>5.0-alpha1</httpcore.version>
<commons-logging.version>1.2</commons-logging.version>
<commons-codec.version>1.10</commons-codec.version>
<ehcache.version>2.6.11</ehcache.version>
@@ -83,8 +83,8 @@
<dependencyManagement>
<dependencies>
<dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
+ <groupId>org.apache.httpcomponents.core5</groupId>
+ <artifactId>httpcore5</artifactId>
<version>${httpcore.version}</version>
</dependency>
<dependency>