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 2017/06/15 13:25:06 UTC

[1/3] httpcomponents-core git commit: Line ending normalization (no functional changes)

Repository: httpcomponents-core
Updated Branches:
  refs/heads/master 8b5b5ba3e -> 09d65b9b3


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java
index b2a4228..bbcdd75 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/protocol/TestUriRegexMatcher.java
@@ -1,211 +1,211 @@
-/*
- * ====================================================================
- * 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.core5.http.protocol;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestUriRegexMatcher {
-
-    @Test
-    public void testRegisterUnregister() throws Exception {
-        final Object h1 = new Object();
-        final Object h2 = new Object();
-        final Object h3 = new Object();
-
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.register("/h1", h1);
-        matcher.register("/h2", h2);
-        matcher.register("/h3", h3);
-
-        Object h;
-
-        h = matcher.lookup("/h1");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h1 == h);
-        h = matcher.lookup("/h2");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h2 == h);
-        h = matcher.lookup("/h3");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h3 == h);
-
-        matcher.unregister("/h1");
-        h = matcher.lookup("/h1");
-        Assert.assertNull(h);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testRegisterNull() throws Exception {
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.register(null, null);
-    }
-
-    @Test
-    public void testWildCardMatching1a() throws Exception {
-        final Object h1 = new Object();
-        final Object h2 = new Object();
-        final Object h3 = new Object();
-        final Object def = new Object();
-
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.register(".*", def);
-        matcher.register("/one/.*", h1);
-        matcher.register("/one/two/.*", h2);
-        matcher.register("/one/two/three/.*", h3);
-
-        Object h;
-
-        h = matcher.lookup("/one/request");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-
-        h = matcher.lookup("/one/two/request");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-
-        h = matcher.lookup("/one/two/three/request");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-
-        h = matcher.lookup("default/request");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-    }
-
-    @Test
-    public void testWildCardMatching1b() throws Exception {
-        final Object h1 = new Object();
-        final Object h2 = new Object();
-        final Object h3 = new Object();
-        final Object def = new Object();
-
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.register("/one/two/three/.*", h3);
-        matcher.register("/one/two/.*", h2);
-        matcher.register("/one/.*", h1);
-        matcher.register(".*", def);
-
-        Object h;
-
-        h = matcher.lookup("/one/request");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h1 == h);
-
-        h = matcher.lookup("/one/two/request");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h2 == h);
-
-        h = matcher.lookup("/one/two/three/request");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h3 == h);
-
-        h = matcher.lookup("default/request");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-    }
-
-    @Test
-    public void testWildCardMatching2a() throws Exception {
-        final Object h1 = new Object();
-        final Object h2 = new Object();
-        final Object def = new Object();
-
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.register(".*", def);
-        matcher.register(".*\\.view", h1);
-        matcher.register(".*\\.form", h2);
-
-        Object h;
-
-        h = matcher.lookup("/that.view");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-
-        h = matcher.lookup("/that.form");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-
-        h = matcher.lookup("/whatever");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-    }
-
-    @Test
-    public void testWildCardMatching2b() throws Exception {
-        final Object h1 = new Object();
-        final Object h2 = new Object();
-        final Object def = new Object();
-
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.register(".*\\.form", h2);
-        matcher.register(".*\\.view", h1);
-        matcher.register(".*", def);
-
-        Object h;
-
-        h = matcher.lookup("/that.view");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h1 == h);
-
-        h = matcher.lookup("/that.form");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h2 == h);
-
-        h = matcher.lookup("/whatever");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(def == h);
-    }
-
-    @Test
-    public void testSuffixPatternOverPrefixPatternMatch() throws Exception {
-        final Object h1 = new Object();
-        final Object h2 = new Object();
-
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.register("/ma.*", h1);
-        matcher.register(".*tch", h2);
-
-        final Object h = matcher.lookup("/match");
-        Assert.assertNotNull(h);
-        Assert.assertTrue(h1 == h);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testRegisterInvalidInput() throws Exception {
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.register(null, null);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testLookupInvalidInput() throws Exception {
-        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
-        matcher.lookup(null);
-    }
-
-}
+/*
+ * ====================================================================
+ * 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.core5.http.protocol;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestUriRegexMatcher {
+
+    @Test
+    public void testRegisterUnregister() throws Exception {
+        final Object h1 = new Object();
+        final Object h2 = new Object();
+        final Object h3 = new Object();
+
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.register("/h1", h1);
+        matcher.register("/h2", h2);
+        matcher.register("/h3", h3);
+
+        Object h;
+
+        h = matcher.lookup("/h1");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
+        h = matcher.lookup("/h2");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h2 == h);
+        h = matcher.lookup("/h3");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h3 == h);
+
+        matcher.unregister("/h1");
+        h = matcher.lookup("/h1");
+        Assert.assertNull(h);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testRegisterNull() throws Exception {
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.register(null, null);
+    }
+
+    @Test
+    public void testWildCardMatching1a() throws Exception {
+        final Object h1 = new Object();
+        final Object h2 = new Object();
+        final Object h3 = new Object();
+        final Object def = new Object();
+
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.register(".*", def);
+        matcher.register("/one/.*", h1);
+        matcher.register("/one/two/.*", h2);
+        matcher.register("/one/two/three/.*", h3);
+
+        Object h;
+
+        h = matcher.lookup("/one/request");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+
+        h = matcher.lookup("/one/two/request");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+
+        h = matcher.lookup("/one/two/three/request");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+
+        h = matcher.lookup("default/request");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+    }
+
+    @Test
+    public void testWildCardMatching1b() throws Exception {
+        final Object h1 = new Object();
+        final Object h2 = new Object();
+        final Object h3 = new Object();
+        final Object def = new Object();
+
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.register("/one/two/three/.*", h3);
+        matcher.register("/one/two/.*", h2);
+        matcher.register("/one/.*", h1);
+        matcher.register(".*", def);
+
+        Object h;
+
+        h = matcher.lookup("/one/request");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
+
+        h = matcher.lookup("/one/two/request");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h2 == h);
+
+        h = matcher.lookup("/one/two/three/request");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h3 == h);
+
+        h = matcher.lookup("default/request");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+    }
+
+    @Test
+    public void testWildCardMatching2a() throws Exception {
+        final Object h1 = new Object();
+        final Object h2 = new Object();
+        final Object def = new Object();
+
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.register(".*", def);
+        matcher.register(".*\\.view", h1);
+        matcher.register(".*\\.form", h2);
+
+        Object h;
+
+        h = matcher.lookup("/that.view");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+
+        h = matcher.lookup("/that.form");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+
+        h = matcher.lookup("/whatever");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+    }
+
+    @Test
+    public void testWildCardMatching2b() throws Exception {
+        final Object h1 = new Object();
+        final Object h2 = new Object();
+        final Object def = new Object();
+
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.register(".*\\.form", h2);
+        matcher.register(".*\\.view", h1);
+        matcher.register(".*", def);
+
+        Object h;
+
+        h = matcher.lookup("/that.view");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
+
+        h = matcher.lookup("/that.form");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h2 == h);
+
+        h = matcher.lookup("/whatever");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(def == h);
+    }
+
+    @Test
+    public void testSuffixPatternOverPrefixPatternMatch() throws Exception {
+        final Object h1 = new Object();
+        final Object h2 = new Object();
+
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.register("/ma.*", h1);
+        matcher.register(".*tch", h2);
+
+        final Object h = matcher.lookup("/match");
+        Assert.assertNotNull(h);
+        Assert.assertTrue(h1 == h);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testRegisterInvalidInput() throws Exception {
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.register(null, null);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testLookupInvalidInput() throws Exception {
+        final LookupRegistry<Object> matcher = new UriRegexMatcher<>();
+        matcher.lookup(null);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
index 7b08112..b1b73b5 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeValue.java
@@ -1,157 +1,157 @@
-/*
- * ====================================================================
- * 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.core5.util;
-
-import java.text.ParseException;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestTimeValue {
-
-    private void checkToDays(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toDays(value), TimeValue.of(value, timeUnit).toDays());
-    }
-
-    private void checkToHours(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toHours(value), TimeValue.of(value, timeUnit).toHours());
-    }
-
-    private void checkToMicros(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toMicros(value), TimeValue.of(value, timeUnit).toMicros());
-    }
-
-    private void checkToMillis(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toMillis(value), TimeValue.of(value, timeUnit).toMillis());
-    }
-
-    private void checkToMinutes(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toMinutes(value), TimeValue.of(value, timeUnit).toMinutes());
-    }
-
-    private void checkToNanos(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toNanos(value), TimeValue.of(value, timeUnit).toNanos());
-    }
-
-    private void checkToSeconds(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toSeconds(value), TimeValue.of(value, timeUnit).toSeconds());
-    }
-
-    private void test(final long value) {
-        for (final TimeUnit timeUnit : TimeUnit.values()) {
-            checkToDays(value, timeUnit);
-            checkToHours(value, timeUnit);
-            checkToMinutes(value, timeUnit);
-            checkToSeconds(value, timeUnit);
-            checkToMillis(value, timeUnit);
-            checkToMicros(value, timeUnit);
-            checkToNanos(value, timeUnit);
-        }
-    }
-
-    @Test
-    public void test0() {
-        test(0);
-    }
-
-    @Test
-    public void test1() {
-        test(1);
-    }
-
-    private void testFactory(final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit, TimeValue.of(1, timeUnit).getTimeUnit());
-    }
-
-    @Test
-    public void testFactoryForDays() {
-        testFactory(TimeUnit.DAYS);
-    }
-
-    @Test
-    public void testFactoryForHours() {
-        testFactory(TimeUnit.HOURS);
-    }
-
-    @Test
-    public void testFactoryForMicroseconds() {
-        testFactory(TimeUnit.MICROSECONDS);
-    }
-
-    @Test
-    public void testFactoryForMillisseconds() {
-        testFactory(TimeUnit.MILLISECONDS);
-    }
-
-    @Test
-    public void testFactoryForMinutes() {
-        testFactory(TimeUnit.MINUTES);
-    }
-
-    @Test
-    public void testFactoryForNanoseconds() {
-        testFactory(TimeUnit.NANOSECONDS);
-    }
-
-    @Test
-    public void testFactoryForSeconds() {
-        testFactory(TimeUnit.SECONDS);
-    }
-
-    @Test
-    public void testMaxInt() {
-        test(Integer.MAX_VALUE);
-    }
-
-    @Test
-    public void testMaxLong() {
-        test(Long.MAX_VALUE);
-    }
-
-    @Test
-    public void testNegative1() {
-        test(-1);
-    }
-
-    @Test
-    public void testToString() {
-        Assert.assertEquals("9,223,372,036,854,775,807 SECONDS", TimeValue.ofSeconds(Long.MAX_VALUE).toString());
-        Assert.assertEquals("0 MILLISECONDS", TimeValue.ZERO_MILLISECONDS.toString());
-    }
-
-    @Test
-    public void testFromString() throws ParseException {
-        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807 SECONDS"));
-        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807 Seconds"));
-        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807  Seconds"));
-        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807\tSeconds"));
-        Assert.assertEquals(TimeValue.ZERO_MILLISECONDS, TimeValue.parse("0 MILLISECONDS"));
-    }
-
-}
+/*
+ * ====================================================================
+ * 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.core5.util;
+
+import java.text.ParseException;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestTimeValue {
+
+    private void checkToDays(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toDays(value), TimeValue.of(value, timeUnit).toDays());
+    }
+
+    private void checkToHours(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toHours(value), TimeValue.of(value, timeUnit).toHours());
+    }
+
+    private void checkToMicros(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toMicros(value), TimeValue.of(value, timeUnit).toMicros());
+    }
+
+    private void checkToMillis(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toMillis(value), TimeValue.of(value, timeUnit).toMillis());
+    }
+
+    private void checkToMinutes(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toMinutes(value), TimeValue.of(value, timeUnit).toMinutes());
+    }
+
+    private void checkToNanos(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toNanos(value), TimeValue.of(value, timeUnit).toNanos());
+    }
+
+    private void checkToSeconds(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toSeconds(value), TimeValue.of(value, timeUnit).toSeconds());
+    }
+
+    private void test(final long value) {
+        for (final TimeUnit timeUnit : TimeUnit.values()) {
+            checkToDays(value, timeUnit);
+            checkToHours(value, timeUnit);
+            checkToMinutes(value, timeUnit);
+            checkToSeconds(value, timeUnit);
+            checkToMillis(value, timeUnit);
+            checkToMicros(value, timeUnit);
+            checkToNanos(value, timeUnit);
+        }
+    }
+
+    @Test
+    public void test0() {
+        test(0);
+    }
+
+    @Test
+    public void test1() {
+        test(1);
+    }
+
+    private void testFactory(final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit, TimeValue.of(1, timeUnit).getTimeUnit());
+    }
+
+    @Test
+    public void testFactoryForDays() {
+        testFactory(TimeUnit.DAYS);
+    }
+
+    @Test
+    public void testFactoryForHours() {
+        testFactory(TimeUnit.HOURS);
+    }
+
+    @Test
+    public void testFactoryForMicroseconds() {
+        testFactory(TimeUnit.MICROSECONDS);
+    }
+
+    @Test
+    public void testFactoryForMillisseconds() {
+        testFactory(TimeUnit.MILLISECONDS);
+    }
+
+    @Test
+    public void testFactoryForMinutes() {
+        testFactory(TimeUnit.MINUTES);
+    }
+
+    @Test
+    public void testFactoryForNanoseconds() {
+        testFactory(TimeUnit.NANOSECONDS);
+    }
+
+    @Test
+    public void testFactoryForSeconds() {
+        testFactory(TimeUnit.SECONDS);
+    }
+
+    @Test
+    public void testMaxInt() {
+        test(Integer.MAX_VALUE);
+    }
+
+    @Test
+    public void testMaxLong() {
+        test(Long.MAX_VALUE);
+    }
+
+    @Test
+    public void testNegative1() {
+        test(-1);
+    }
+
+    @Test
+    public void testToString() {
+        Assert.assertEquals("9,223,372,036,854,775,807 SECONDS", TimeValue.ofSeconds(Long.MAX_VALUE).toString());
+        Assert.assertEquals("0 MILLISECONDS", TimeValue.ZERO_MILLISECONDS.toString());
+    }
+
+    @Test
+    public void testFromString() throws ParseException {
+        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807 SECONDS"));
+        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807 Seconds"));
+        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807  Seconds"));
+        Assert.assertEquals(TimeValue.ofSeconds(Long.MAX_VALUE), TimeValue.parse("9,223,372,036,854,775,807\tSeconds"));
+        Assert.assertEquals(TimeValue.ZERO_MILLISECONDS, TimeValue.parse("0 MILLISECONDS"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java
index 9dec674..25d62a5 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestTimeout.java
@@ -1,184 +1,184 @@
-/*
- * ====================================================================
- * 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.core5.util;
-
-import java.text.ParseException;
-import java.util.concurrent.TimeUnit;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestTimeout {
-
-    private void checkToDays(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toDays(value), Timeout.of(value, timeUnit).toDays());
-    }
-
-    private void checkToHours(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toHours(value), Timeout.of(value, timeUnit).toHours());
-    }
-
-    private void checkToMicros(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toMicros(value), Timeout.of(value, timeUnit).toMicros());
-    }
-
-    private void checkToMillis(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toMillis(value), Timeout.of(value, timeUnit).toMillis());
-    }
-
-    private void checkToMinutes(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toMinutes(value), Timeout.of(value, timeUnit).toMinutes());
-    }
-
-    private void checkToNanos(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toNanos(value), Timeout.of(value, timeUnit).toNanos());
-    }
-
-    private void checkToSeconds(final long value, final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit.toSeconds(value), Timeout.of(value, timeUnit).toSeconds());
-    }
-
-    private void test(final long value) {
-        for (final TimeUnit timeUnit : TimeUnit.values()) {
-            checkToDays(value, timeUnit);
-            checkToHours(value, timeUnit);
-            checkToMinutes(value, timeUnit);
-            checkToSeconds(value, timeUnit);
-            checkToMillis(value, timeUnit);
-            checkToMicros(value, timeUnit);
-            checkToNanos(value, timeUnit);
-        }
-    }
-
-    @Test
-    public void test0() {
-        test(0);
-    }
-
-    @Test
-    public void test1() {
-        test(1);
-    }
-
-    @Test
-    public void testDisabled() {
-        Assert.assertTrue(Timeout.DISABLED.isDisabled());
-        Assert.assertFalse(Timeout.DISABLED.isEnabled());
-        Assert.assertFalse(Timeout.DISABLED.isUndefinedMilliseconds());
-        Assert.assertFalse(Timeout.DISABLED.isUndefinedSeconds());
-    }
-
-    private void testFactory(final TimeUnit timeUnit) {
-        Assert.assertEquals(timeUnit, Timeout.of(1, timeUnit).getTimeUnit());
-    }
-
-    @Test
-    public void testFactoryForDays() {
-        testFactory(TimeUnit.DAYS);
-    }
-
-    @Test
-    public void testFactoryForHours() {
-        testFactory(TimeUnit.HOURS);
-    }
-
-    @Test
-    public void testFactoryForMicroseconds() {
-        testFactory(TimeUnit.MICROSECONDS);
-    }
-
-    @Test
-    public void testFactoryForMillisseconds() {
-        testFactory(TimeUnit.MILLISECONDS);
-    }
-
-    @Test
-    public void testFactoryForMinutes() {
-        testFactory(TimeUnit.MINUTES);
-    }
-
-    @Test
-    public void testFactoryForNanoseconds() {
-        testFactory(TimeUnit.NANOSECONDS);
-    }
-
-    @Test
-    public void testFactoryForSeconds() {
-        testFactory(TimeUnit.SECONDS);
-    }
-
-    @Test
-    public void testMaxInt() {
-        test(Integer.MAX_VALUE);
-    }
-
-    @Test
-    public void testMaxLong() {
-        test(Long.MAX_VALUE);
-    }
-
-    @Test
-    public void testNegative1() {
-        test(-1);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testNegative2() {
-        test(-2);
-    }
-
-    @Test
-    public void testUndefinedMilliseconds() {
-        Assert.assertTrue(Timeout.UNDEFINED_MILLISECONDS.isUndefinedMilliseconds());
-        Assert.assertFalse(Timeout.UNDEFINED_MILLISECONDS.isEnabled());
-        Assert.assertFalse(Timeout.UNDEFINED_MILLISECONDS.isDisabled());
-    }
-
-    @Test
-    public void testUndefinedSeconds() {
-        Assert.assertTrue(Timeout.UNDEFINED_SECONDS.isUndefinedSeconds());
-        Assert.assertFalse(Timeout.UNDEFINED_SECONDS.isEnabled());
-        Assert.assertFalse(Timeout.UNDEFINED_SECONDS.isDisabled());
-    }
-
-    @Test
-    public void testToString() {
-        Assert.assertEquals("9,223,372,036,854,775,807 SECONDS", Timeout.ofSeconds(Long.MAX_VALUE).toString());
-        Assert.assertEquals("0 MILLISECONDS", Timeout.ZERO_MILLISECONDS.toString());
-    }
-
-    @Test
-    public void testFromString() throws ParseException {
-        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 SECONDS"));
-        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 Seconds"));
-        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807  Seconds"));
-        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807\tSeconds"));
-        Assert.assertEquals(Timeout.ZERO_MILLISECONDS, Timeout.parse("0 MILLISECONDS"));
-    }
-
-}
+/*
+ * ====================================================================
+ * 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.core5.util;
+
+import java.text.ParseException;
+import java.util.concurrent.TimeUnit;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestTimeout {
+
+    private void checkToDays(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toDays(value), Timeout.of(value, timeUnit).toDays());
+    }
+
+    private void checkToHours(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toHours(value), Timeout.of(value, timeUnit).toHours());
+    }
+
+    private void checkToMicros(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toMicros(value), Timeout.of(value, timeUnit).toMicros());
+    }
+
+    private void checkToMillis(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toMillis(value), Timeout.of(value, timeUnit).toMillis());
+    }
+
+    private void checkToMinutes(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toMinutes(value), Timeout.of(value, timeUnit).toMinutes());
+    }
+
+    private void checkToNanos(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toNanos(value), Timeout.of(value, timeUnit).toNanos());
+    }
+
+    private void checkToSeconds(final long value, final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit.toSeconds(value), Timeout.of(value, timeUnit).toSeconds());
+    }
+
+    private void test(final long value) {
+        for (final TimeUnit timeUnit : TimeUnit.values()) {
+            checkToDays(value, timeUnit);
+            checkToHours(value, timeUnit);
+            checkToMinutes(value, timeUnit);
+            checkToSeconds(value, timeUnit);
+            checkToMillis(value, timeUnit);
+            checkToMicros(value, timeUnit);
+            checkToNanos(value, timeUnit);
+        }
+    }
+
+    @Test
+    public void test0() {
+        test(0);
+    }
+
+    @Test
+    public void test1() {
+        test(1);
+    }
+
+    @Test
+    public void testDisabled() {
+        Assert.assertTrue(Timeout.DISABLED.isDisabled());
+        Assert.assertFalse(Timeout.DISABLED.isEnabled());
+        Assert.assertFalse(Timeout.DISABLED.isUndefinedMilliseconds());
+        Assert.assertFalse(Timeout.DISABLED.isUndefinedSeconds());
+    }
+
+    private void testFactory(final TimeUnit timeUnit) {
+        Assert.assertEquals(timeUnit, Timeout.of(1, timeUnit).getTimeUnit());
+    }
+
+    @Test
+    public void testFactoryForDays() {
+        testFactory(TimeUnit.DAYS);
+    }
+
+    @Test
+    public void testFactoryForHours() {
+        testFactory(TimeUnit.HOURS);
+    }
+
+    @Test
+    public void testFactoryForMicroseconds() {
+        testFactory(TimeUnit.MICROSECONDS);
+    }
+
+    @Test
+    public void testFactoryForMillisseconds() {
+        testFactory(TimeUnit.MILLISECONDS);
+    }
+
+    @Test
+    public void testFactoryForMinutes() {
+        testFactory(TimeUnit.MINUTES);
+    }
+
+    @Test
+    public void testFactoryForNanoseconds() {
+        testFactory(TimeUnit.NANOSECONDS);
+    }
+
+    @Test
+    public void testFactoryForSeconds() {
+        testFactory(TimeUnit.SECONDS);
+    }
+
+    @Test
+    public void testMaxInt() {
+        test(Integer.MAX_VALUE);
+    }
+
+    @Test
+    public void testMaxLong() {
+        test(Long.MAX_VALUE);
+    }
+
+    @Test
+    public void testNegative1() {
+        test(-1);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testNegative2() {
+        test(-2);
+    }
+
+    @Test
+    public void testUndefinedMilliseconds() {
+        Assert.assertTrue(Timeout.UNDEFINED_MILLISECONDS.isUndefinedMilliseconds());
+        Assert.assertFalse(Timeout.UNDEFINED_MILLISECONDS.isEnabled());
+        Assert.assertFalse(Timeout.UNDEFINED_MILLISECONDS.isDisabled());
+    }
+
+    @Test
+    public void testUndefinedSeconds() {
+        Assert.assertTrue(Timeout.UNDEFINED_SECONDS.isUndefinedSeconds());
+        Assert.assertFalse(Timeout.UNDEFINED_SECONDS.isEnabled());
+        Assert.assertFalse(Timeout.UNDEFINED_SECONDS.isDisabled());
+    }
+
+    @Test
+    public void testToString() {
+        Assert.assertEquals("9,223,372,036,854,775,807 SECONDS", Timeout.ofSeconds(Long.MAX_VALUE).toString());
+        Assert.assertEquals("0 MILLISECONDS", Timeout.ZERO_MILLISECONDS.toString());
+    }
+
+    @Test
+    public void testFromString() throws ParseException {
+        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 SECONDS"));
+        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807 Seconds"));
+        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807  Seconds"));
+        Assert.assertEquals(Timeout.ofSeconds(Long.MAX_VALUE), Timeout.parse("9,223,372,036,854,775,807\tSeconds"));
+        Assert.assertEquals(Timeout.ZERO_MILLISECONDS, Timeout.parse("0 MILLISECONDS"));
+    }
+
+}


[2/3] httpcomponents-core git commit: Line ending normalization (no functional changes)

Posted by ol...@apache.org.
Line ending normalization (no functional changes)


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/d7768b2c
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/d7768b2c
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/d7768b2c

Branch: refs/heads/master
Commit: d7768b2cdb59ca2f8dddf11dc4148e34420f8f86
Parents: 8b5b5ba
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Thu Jun 15 15:15:44 2017 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Thu Jun 15 15:16:07 2017 +0200

----------------------------------------------------------------------
 .../framework/TestClientTestingAdapter.java     | 106 ++--
 .../testing/framework/TestFrameworkTest.java    | 230 ++++----
 .../hc/core5/http/protocol/LookupRegistry.java  | 118 ++--
 .../hc/core5/http/protocol/UriRegexMatcher.java | 238 ++++----
 .../java/org/apache/hc/core5/net/Ports.java     | 136 ++---
 .../org/apache/hc/core5/util/TimeValue.java     | 578 +++++++++----------
 .../java/org/apache/hc/core5/util/Timeout.java  | 422 +++++++-------
 .../TestAsyncServerExchangeHandlerRegistry.java | 146 ++---
 .../http/protocol/TestUriRegexMatcher.java      | 422 +++++++-------
 .../org/apache/hc/core5/util/TestTimeValue.java | 314 +++++-----
 .../org/apache/hc/core5/util/TestTimeout.java   | 368 ++++++------
 11 files changed, 1539 insertions(+), 1539 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java
index 1f56fad..62af90f 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestClientTestingAdapter.java
@@ -1,53 +1,53 @@
-/*
- * ====================================================================
- * 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.core5.testing.framework;
-
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestClientTestingAdapter {
-
-    @Test
-    public void getHttpClientPOJOAdapter() throws Exception {
-        final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
-
-        final ClientPOJOAdapter pojoAdapter = adapter.getClientPOJOAdapter();
-
-        Assert.assertNotNull("pojoAdapter should not be null", pojoAdapter);
-    }
-
-    @Test
-    public void isRequestSupported() throws Exception {
-        final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
-
-        final Map<String, Object> request = null;
-        Assert.assertTrue("isRequestSupported should return true", adapter.isRequestSupported(request));
-
-    }
-}
+/*
+ * ====================================================================
+ * 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.core5.testing.framework;
+
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestClientTestingAdapter {
+
+    @Test
+    public void getHttpClientPOJOAdapter() throws Exception {
+        final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
+
+        final ClientPOJOAdapter pojoAdapter = adapter.getClientPOJOAdapter();
+
+        Assert.assertNotNull("pojoAdapter should not be null", pojoAdapter);
+    }
+
+    @Test
+    public void isRequestSupported() throws Exception {
+        final ClientTestingAdapter adapter = new ClassicTestClientTestingAdapter();
+
+        final Map<String, Object> request = null;
+        Assert.assertTrue("isRequestSupported should return true", adapter.isRequestSupported(request));
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
----------------------------------------------------------------------
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
index 095c215..7b36152 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/framework/TestFrameworkTest.java
@@ -1,115 +1,115 @@
-/*
- * ====================================================================
- * 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.core5.testing.framework;
-
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.BODY;
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.CONTENT_TYPE;
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.HEADERS;
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.METHOD;
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.PROTOCOL_VERSION;
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.QUERY;
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.REQUEST;
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.RESPONSE;
-import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.STATUS;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-public class TestFrameworkTest {
-    @Test
-    public void defaults() throws Exception {
-        final FrameworkTest test = new FrameworkTest();
-        final Map<String, Object> request = test.initRequest();
-
-        Assert.assertNotNull("request should not be null", request);
-        Assert.assertEquals("Default method should be GET", "GET", request.get(METHOD));
-
-        Assert.assertEquals("Default request body expected.",
-                TestingFramework.DEFAULT_REQUEST_BODY,
-                request.get(BODY));
-
-        Assert.assertEquals("Default request content type expected.",
-                TestingFramework.DEFAULT_REQUEST_CONTENT_TYPE,
-                request.get(CONTENT_TYPE));
-
-        Assert.assertEquals("Default request query parameters expected.",
-                            TestingFramework.DEFAULT_REQUEST_QUERY,
-                            request.get(QUERY));
-
-        Assert.assertEquals("Default request headers expected.",
-                            TestingFramework.DEFAULT_REQUEST_HEADERS,
-                            request.get(HEADERS));
-
-        Assert.assertEquals("Default protocol version expected.",
-                TestingFramework.DEFAULT_REQUEST_PROTOCOL_VERSION,
-                request.get(PROTOCOL_VERSION));
-
-        final Map<String, Object> responseExpectations = test.initResponseExpectations();
-        Assert.assertNotNull("responseExpectations should not be null", responseExpectations);
-        Assert.assertEquals("Default status expected.", TestingFramework.DEFAULT_RESPONSE_STATUS,
-                            responseExpectations.get(STATUS));
-
-        Assert.assertEquals("Default body expected.", TestingFramework.DEFAULT_RESPONSE_BODY,
-                            responseExpectations.get(BODY));
-
-        Assert.assertEquals("Default response content type expected.", TestingFramework.DEFAULT_RESPONSE_CONTENT_TYPE,
-                responseExpectations.get(CONTENT_TYPE));
-
-        Assert.assertEquals("Default headers expected.", TestingFramework.DEFAULT_RESPONSE_HEADERS,
-                            responseExpectations.get(HEADERS));
-    }
-
-    @Test
-    public void changeStatus() throws Exception {
-        final Map<String, Object> testMap = new HashMap<String, Object>();
-        final Map<String, Object> response = new HashMap<String, Object>();
-        testMap.put(RESPONSE, response);
-        response.put(STATUS, 201);
-
-        final FrameworkTest test = new FrameworkTest(testMap);
-        final Map<String, Object> responseExpectations = test.initResponseExpectations();
-
-        Assert.assertEquals("Status unexpected.", 201, responseExpectations.get(STATUS));
-    }
-
-    @Test
-    public void changeMethod() throws Exception {
-        final Map<String, Object> testMap = new HashMap<String, Object>();
-        final Map<String, Object> request = new HashMap<String, Object>();
-        testMap.put(REQUEST, request);
-        request.put(METHOD, "POST");
-
-        final FrameworkTest test = new FrameworkTest(testMap);
-        final Map<String, Object> requestExpectations = test.initRequest();
-
-        Assert.assertEquals("Method unexpected.", "POST", requestExpectations.get(METHOD));
-    }
-}
+/*
+ * ====================================================================
+ * 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.core5.testing.framework;
+
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.BODY;
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.CONTENT_TYPE;
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.HEADERS;
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.METHOD;
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.PROTOCOL_VERSION;
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.QUERY;
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.REQUEST;
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.RESPONSE;
+import static org.apache.hc.core5.testing.framework.ClientPOJOAdapter.STATUS;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class TestFrameworkTest {
+    @Test
+    public void defaults() throws Exception {
+        final FrameworkTest test = new FrameworkTest();
+        final Map<String, Object> request = test.initRequest();
+
+        Assert.assertNotNull("request should not be null", request);
+        Assert.assertEquals("Default method should be GET", "GET", request.get(METHOD));
+
+        Assert.assertEquals("Default request body expected.",
+                TestingFramework.DEFAULT_REQUEST_BODY,
+                request.get(BODY));
+
+        Assert.assertEquals("Default request content type expected.",
+                TestingFramework.DEFAULT_REQUEST_CONTENT_TYPE,
+                request.get(CONTENT_TYPE));
+
+        Assert.assertEquals("Default request query parameters expected.",
+                            TestingFramework.DEFAULT_REQUEST_QUERY,
+                            request.get(QUERY));
+
+        Assert.assertEquals("Default request headers expected.",
+                            TestingFramework.DEFAULT_REQUEST_HEADERS,
+                            request.get(HEADERS));
+
+        Assert.assertEquals("Default protocol version expected.",
+                TestingFramework.DEFAULT_REQUEST_PROTOCOL_VERSION,
+                request.get(PROTOCOL_VERSION));
+
+        final Map<String, Object> responseExpectations = test.initResponseExpectations();
+        Assert.assertNotNull("responseExpectations should not be null", responseExpectations);
+        Assert.assertEquals("Default status expected.", TestingFramework.DEFAULT_RESPONSE_STATUS,
+                            responseExpectations.get(STATUS));
+
+        Assert.assertEquals("Default body expected.", TestingFramework.DEFAULT_RESPONSE_BODY,
+                            responseExpectations.get(BODY));
+
+        Assert.assertEquals("Default response content type expected.", TestingFramework.DEFAULT_RESPONSE_CONTENT_TYPE,
+                responseExpectations.get(CONTENT_TYPE));
+
+        Assert.assertEquals("Default headers expected.", TestingFramework.DEFAULT_RESPONSE_HEADERS,
+                            responseExpectations.get(HEADERS));
+    }
+
+    @Test
+    public void changeStatus() throws Exception {
+        final Map<String, Object> testMap = new HashMap<String, Object>();
+        final Map<String, Object> response = new HashMap<String, Object>();
+        testMap.put(RESPONSE, response);
+        response.put(STATUS, 201);
+
+        final FrameworkTest test = new FrameworkTest(testMap);
+        final Map<String, Object> responseExpectations = test.initResponseExpectations();
+
+        Assert.assertEquals("Status unexpected.", 201, responseExpectations.get(STATUS));
+    }
+
+    @Test
+    public void changeMethod() throws Exception {
+        final Map<String, Object> testMap = new HashMap<String, Object>();
+        final Map<String, Object> request = new HashMap<String, Object>();
+        testMap.put(REQUEST, request);
+        request.put(METHOD, "POST");
+
+        final FrameworkTest test = new FrameworkTest(testMap);
+        final Map<String, Object> requestExpectations = test.initRequest();
+
+        Assert.assertEquals("Method unexpected.", "POST", requestExpectations.get(METHOD));
+    }
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/LookupRegistry.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/LookupRegistry.java b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/LookupRegistry.java
index d37b2c0..2bddaf2 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/LookupRegistry.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/LookupRegistry.java
@@ -1,59 +1,59 @@
-/*
- * ====================================================================
- * 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.core5.http.protocol;
-
-/**
- * A lookup registry.
- *
- * @param <T> The type of objects to register and lookup.
- */
-public interface LookupRegistry<T> {
-
-    /**
-     * Registers the given object for URIs matching the given pattern.
-     *
-     * @param pattern the pattern to register the handler for.
-     * @param obj the object.
-     */
-    void register(String pattern, T obj);
-
-    /**
-     * Looks up an object matching the given request path.
-     *
-     * @param value the request path
-     * @return object or {@code null} if no match is found.
-     */
-    T lookup(String value);
-
-    /**
-     * Removes registered object, if exists, for the given pattern.
-     *
-     * @param pattern the pattern to unregister.
-     */
-    void unregister(String pattern);
-
-}
+/*
+ * ====================================================================
+ * 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.core5.http.protocol;
+
+/**
+ * A lookup registry.
+ *
+ * @param <T> The type of objects to register and lookup.
+ */
+public interface LookupRegistry<T> {
+
+    /**
+     * Registers the given object for URIs matching the given pattern.
+     *
+     * @param pattern the pattern to register the handler for.
+     * @param obj the object.
+     */
+    void register(String pattern, T obj);
+
+    /**
+     * Looks up an object matching the given request path.
+     *
+     * @param value the request path
+     * @return object or {@code null} if no match is found.
+     */
+    T lookup(String value);
+
+    /**
+     * Removes registered object, if exists, for the given pattern.
+     *
+     * @param pattern the pattern to unregister.
+     */
+    void unregister(String pattern);
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriRegexMatcher.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriRegexMatcher.java b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriRegexMatcher.java
index d24e53b..c833036 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriRegexMatcher.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/protocol/UriRegexMatcher.java
@@ -1,119 +1,119 @@
-/*
- * ====================================================================
- * 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.core5.http.protocol;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.regex.Pattern;
-
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-import org.apache.hc.core5.util.Args;
-
-/**
- * Maintains a map of objects keyed by a request URI regular expression.
- *
- * <p>
- * The insertion order is in maintained in that map such that the lookup tests each regex until there is a match. This
- * class can be used to resolve an object matching a particular request URI.
- * </p>
- *
- * @since 5.0
- */
-@Contract(threading = ThreadingBehavior.SAFE)
-public class UriRegexMatcher<T> implements LookupRegistry<T> {
-
-    private final Map<String, T> objectMap;
-    private final Map<String, Pattern> patternMap;
-
-    public UriRegexMatcher() {
-        super();
-        this.objectMap = new LinkedHashMap<>();
-        this.patternMap = new LinkedHashMap<>();
-    }
-
-    /**
-     * Registers the given object for URIs matching the given regex.
-     *
-     * @param regex
-     *            the regex to register the handler for.
-     * @param obj
-     *            the object.
-     */
-    @Override
-    public synchronized void register(final String regex, final T obj) {
-        Args.notNull(regex, "URI request regex");
-        this.objectMap.put(regex, obj);
-        this.patternMap.put(regex, Pattern.compile(regex));
-    }
-
-    /**
-     * Removes registered object, if exists, for the given regex.
-     *
-     * @param regex
-     *            the regex to unregister.
-     */
-    @Override
-    public synchronized void unregister(final String regex) {
-        if (regex == null) {
-            return;
-        }
-        this.objectMap.remove(regex);
-        this.patternMap.remove(regex);
-    }
-
-    /**
-     * Looks up an object matching the given request path.
-     *
-     * @param path
-     *            the request path
-     * @return object or {@code null} if no match is found.
-     */
-    @Override
-    public synchronized T lookup(final String path) {
-        Args.notNull(path, "Request path");
-        // direct match?
-        final T obj = this.objectMap.get(path);
-        if (obj == null) {
-            // regex match?
-            for (final Entry<String, Pattern> entry : this.patternMap.entrySet()) {
-                if (entry.getValue().matcher(path).matches()) {
-                    return objectMap.get(entry.getKey());
-                }
-            }
-        }
-        return obj;
-    }
-
-    @Override
-    public String toString() {
-        return this.objectMap.toString();
-    }
-
-}
+/*
+ * ====================================================================
+ * 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.core5.http.protocol;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.regex.Pattern;
+
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+import org.apache.hc.core5.util.Args;
+
+/**
+ * Maintains a map of objects keyed by a request URI regular expression.
+ *
+ * <p>
+ * The insertion order is in maintained in that map such that the lookup tests each regex until there is a match. This
+ * class can be used to resolve an object matching a particular request URI.
+ * </p>
+ *
+ * @since 5.0
+ */
+@Contract(threading = ThreadingBehavior.SAFE)
+public class UriRegexMatcher<T> implements LookupRegistry<T> {
+
+    private final Map<String, T> objectMap;
+    private final Map<String, Pattern> patternMap;
+
+    public UriRegexMatcher() {
+        super();
+        this.objectMap = new LinkedHashMap<>();
+        this.patternMap = new LinkedHashMap<>();
+    }
+
+    /**
+     * Registers the given object for URIs matching the given regex.
+     *
+     * @param regex
+     *            the regex to register the handler for.
+     * @param obj
+     *            the object.
+     */
+    @Override
+    public synchronized void register(final String regex, final T obj) {
+        Args.notNull(regex, "URI request regex");
+        this.objectMap.put(regex, obj);
+        this.patternMap.put(regex, Pattern.compile(regex));
+    }
+
+    /**
+     * Removes registered object, if exists, for the given regex.
+     *
+     * @param regex
+     *            the regex to unregister.
+     */
+    @Override
+    public synchronized void unregister(final String regex) {
+        if (regex == null) {
+            return;
+        }
+        this.objectMap.remove(regex);
+        this.patternMap.remove(regex);
+    }
+
+    /**
+     * Looks up an object matching the given request path.
+     *
+     * @param path
+     *            the request path
+     * @return object or {@code null} if no match is found.
+     */
+    @Override
+    public synchronized T lookup(final String path) {
+        Args.notNull(path, "Request path");
+        // direct match?
+        final T obj = this.objectMap.get(path);
+        if (obj == null) {
+            // regex match?
+            for (final Entry<String, Pattern> entry : this.patternMap.entrySet()) {
+                if (entry.getValue().matcher(path).matches()) {
+                    return objectMap.get(entry.getKey());
+                }
+            }
+        }
+        return obj;
+    }
+
+    @Override
+    public String toString() {
+        return this.objectMap.toString();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/main/java/org/apache/hc/core5/net/Ports.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/net/Ports.java b/httpcore5/src/main/java/org/apache/hc/core5/net/Ports.java
index 51b7bf6..c8938c7 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/net/Ports.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/net/Ports.java
@@ -1,68 +1,68 @@
-/*
- * ====================================================================
- * 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.core5.net;
-
-import org.apache.hc.core5.util.Args;
-
-/**
- * Port helper methods.
- *
- * @since 5.0
- */
-public class Ports {
-
-    /**
-     * The scheme default port.
-     */
-    public final static int SCHEME_DEFAULT = -1;
-
-    /**
-     * The minimum port value per https://tools.ietf.org/html/rfc6335.
-     */
-    public final static int MIN_VALUE = 0;
-
-    /**
-     * The maxium port value per https://tools.ietf.org/html/rfc6335.
-     */
-    public final static int MAX_VALUE = 65535;
-
-    /**
-     * Checks a port number where {@code -1} indicates the scheme default port.
-     *
-     * @param port
-     *            The port to check where {@code -1} indicates the scheme default port.
-     * @return the port
-     *
-     * @throws IllegalArgumentException
-     *             If the port parameter is outside the specified range of valid port values, which is between 0 and
-     *             65535, inclusive. {@code -1} indicates the scheme default port.
-     */
-    public static int check(final int port) {
-        return Args.checkRange(port, SCHEME_DEFAULT, MAX_VALUE,
-                "Port number(Use -1 to specify the scheme default port)");
-    }
-}
+/*
+ * ====================================================================
+ * 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.core5.net;
+
+import org.apache.hc.core5.util.Args;
+
+/**
+ * Port helper methods.
+ *
+ * @since 5.0
+ */
+public class Ports {
+
+    /**
+     * The scheme default port.
+     */
+    public final static int SCHEME_DEFAULT = -1;
+
+    /**
+     * The minimum port value per https://tools.ietf.org/html/rfc6335.
+     */
+    public final static int MIN_VALUE = 0;
+
+    /**
+     * The maxium port value per https://tools.ietf.org/html/rfc6335.
+     */
+    public final static int MAX_VALUE = 65535;
+
+    /**
+     * Checks a port number where {@code -1} indicates the scheme default port.
+     *
+     * @param port
+     *            The port to check where {@code -1} indicates the scheme default port.
+     * @return the port
+     *
+     * @throws IllegalArgumentException
+     *             If the port parameter is outside the specified range of valid port values, which is between 0 and
+     *             65535, inclusive. {@code -1} indicates the scheme default port.
+     */
+    public static int check(final int port) {
+        return Args.checkRange(port, SCHEME_DEFAULT, MAX_VALUE,
+                "Port number(Use -1 to specify the scheme default port)");
+    }
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java b/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
index d81253a..a8646ca 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/TimeValue.java
@@ -1,289 +1,289 @@
-/*
- * ====================================================================
- * 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.core5.util;
-
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.Locale;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-
-/**
- * Represents a time value as a {@code long} time and {@link TimeUnit}.
- *
- * @since 5.0
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
-public class TimeValue {
-
-    static final int INT_UNDEFINED = -1;
-    public static final TimeValue NEG_ONE_MILLISECONDS = TimeValue.of(INT_UNDEFINED, TimeUnit.MILLISECONDS);
-    public static final TimeValue NEG_ONE_SECONDS = TimeValue.of(INT_UNDEFINED, TimeUnit.SECONDS);
-    public static final TimeValue ZERO_MILLISECONDS = TimeValue.of(0, TimeUnit.MILLISECONDS);
-
-    /**
-     * Returns the given {@code long} value as an {@code int} where long values out of int range are returned as
-     * {@link Integer#MIN_VALUE} and {@link Integer#MAX_VALUE}.
-     *
-     * <p>
-     * For example: {@code TimeValue.asBoundInt(Long.MAX_VALUE)} returns {@code Integer.MAX_VALUE}.
-     * </p>
-     *
-     * @param value
-     *            a long value to convert
-     * @return an int value bound within {@link Integer#MIN_VALUE} and {@link Integer#MAX_VALUE}.
-     */
-    public static int asBoundInt(final long value) {
-        if (value > Integer.MAX_VALUE) {
-            return Integer.MAX_VALUE;
-        } else if (value < Integer.MIN_VALUE) {
-            return Integer.MIN_VALUE;
-        }
-        return (int) value;
-    }
-
-    /**
-     * Returns the given {@code timeValue} if it is not {@code null}, if {@code null} then returns the given
-     * {@code defaultValue}.
-     *
-     * @param timeValue
-     *            may be {@code null}
-     * @param defaultValue
-     *            may be {@code null}
-     * @return {@code timeValue} or {@code defaultValue}
-     */
-    public static TimeValue defaultsTo(final TimeValue timeValue, final TimeValue defaultValue) {
-        return timeValue != null ? timeValue : defaultValue;
-    }
-
-    /**
-     * Returns the given {@code timeValue} if it is not {@code null}, if {@code null} then returns
-     * {@link #NEG_ONE_SECONDS}.
-     *
-     * @param timeValue
-     *            may be {@code null}
-     * @return {@code timeValue} or {@link #NEG_ONE_SECONDS}
-     */
-    public static TimeValue defaultsToNegativeOneMillisecond(final TimeValue timeValue) {
-        return defaultsTo(timeValue, NEG_ONE_MILLISECONDS);
-    }
-
-    /**
-     * Returns the given {@code timeValue} if it is not {@code null}, if {@code null} then returns
-     * {@link #NEG_ONE_SECONDS}.
-     *
-     * @param timeValue
-     *            may be {@code null}
-     * @return {@code timeValue} or {@link #NEG_ONE_SECONDS}
-     */
-    public static TimeValue defaultsToNegativeOneSecond(final TimeValue timeValue) {
-        return defaultsTo(timeValue, NEG_ONE_SECONDS);
-    }
-
-    /**
-     * Returns the given {@code timeValue} if it is not {@code null}, if {@code null} then returns
-     * {@link #ZERO_MILLISECONDS}.
-     *
-     * @param timeValue
-     *            may be {@code null}
-     * @return {@code timeValue} or {@link #ZERO_MILLISECONDS}
-     */
-    public static TimeValue defaultsToZeroMillis(final TimeValue timeValue) {
-        return defaultsTo(timeValue, ZERO_MILLISECONDS);
-    }
-
-    public static boolean isNonNegative(final TimeValue timeValue) {
-        return timeValue != null && timeValue.getDuration() >= 0;
-    }
-
-    public static boolean isPositive(final TimeValue timeValue) {
-        return timeValue != null && timeValue.getDuration() > 0;
-    }
-
-    /**
-     * Creates a TimeValue.
-     *
-     * @param duration
-     *            the time duration in the given {@code timeUnit}.
-     * @param timeUnit
-     *            the time unit for the given durarion.
-     * @return a Timeout
-     */
-    public static TimeValue of(final long duration, final TimeUnit timeUnit) {
-        return new TimeValue(duration, timeUnit);
-    }
-
-    public static TimeValue ofDays(final long days) {
-        return of(days, TimeUnit.DAYS);
-    }
-
-    public static TimeValue ofHours(final long hours) {
-        return of(hours, TimeUnit.HOURS);
-    }
-
-    public static TimeValue ofMicroseconds(final long microseconds) {
-        return of(microseconds, TimeUnit.MICROSECONDS);
-    }
-
-    public static TimeValue ofMillis(final long millis) {
-        return of(millis, TimeUnit.MILLISECONDS);
-    }
-
-    public static TimeValue ofMinutes(final long minutes) {
-        return of(minutes, TimeUnit.MINUTES);
-    }
-
-    public static TimeValue ofNanoseconds(final long nanoseconds) {
-        return of(nanoseconds, TimeUnit.NANOSECONDS);
-    }
-
-    public static TimeValue ofSeconds(final long seconds) {
-        return of(seconds, TimeUnit.SECONDS);
-    }
-
-    /**
-     * Parses a TimeValue in the format {@code <Integer><SPACE><TimeUnit>}, for example {@code "1,200 MILLISECONDS"}
-     *
-     * @param value
-     *            the TimeValue to parse
-     * @return a new TimeValue
-     * @throws ParseException
-     *             if the number cannot be parsed
-     */
-    public static TimeValue parse(final String value) throws ParseException {
-        final String split[] = value.split("\\s+");
-        if (split.length < 2) {
-            throw new IllegalArgumentException(
-                    String.format("Expected format for <Integer><SPACE><TimeUnit>: ", value));
-        }
-        return TimeValue.of(NumberFormat.getInstance().parse(split[0]).longValue(),
-                TimeUnit.valueOf(split[1].trim().toUpperCase(Locale.ROOT)));
-    }
-
-    private final long duration;
-
-    private final TimeUnit timeUnit;
-
-    TimeValue(final long duration, final TimeUnit timeUnit) {
-        super();
-        this.duration = duration;
-        this.timeUnit = Args.notNull(timeUnit, "timeUnit");
-    }
-
-    public long convert(final TimeUnit sourceUnit) {
-        return timeUnit.convert(duration, sourceUnit);
-    }
-
-    @Override
-    public boolean equals(final Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof TimeValue) {
-            final TimeValue that = (TimeValue) obj;
-            return this.duration == that.duration && LangUtils.equals(this.timeUnit, that.timeUnit);
-        }
-        return false;
-    }
-
-    public long getDuration() {
-        return duration;
-    }
-
-    public TimeUnit getTimeUnit() {
-        return timeUnit;
-    }
-
-    @Override
-    public int hashCode() {
-        int hash = LangUtils.HASH_SEED;
-        hash = LangUtils.hashCode(hash, Long.valueOf(duration));
-        hash = LangUtils.hashCode(hash, timeUnit);
-        return hash;
-    }
-
-    public void sleep() throws InterruptedException {
-        timeUnit.sleep(duration);
-    }
-
-    public void timedJoin(final Thread thread) throws InterruptedException {
-        timeUnit.timedJoin(thread, duration);
-    }
-
-    public void timedWait(final Object obj) throws InterruptedException {
-        timeUnit.timedWait(obj, duration);
-    }
-
-    public long toDays() {
-        return timeUnit.toDays(duration);
-    }
-
-    public long toHours() {
-        return timeUnit.toHours(duration);
-    }
-
-    public long toMicros() {
-        return timeUnit.toMicros(duration);
-    }
-
-    public long toMillis() {
-        return timeUnit.toMillis(duration);
-    }
-
-    public int toMillisIntBound() {
-        return asBoundInt(toMillis());
-    }
-
-    public long toMinutes() {
-        return timeUnit.toMinutes(duration);
-    }
-
-    public long toNanos() {
-        return timeUnit.toNanos(duration);
-    }
-
-    public long toSeconds() {
-        return timeUnit.toSeconds(duration);
-    }
-
-    public int toSecondsIntBound() {
-        return asBoundInt(toSeconds());
-    }
-
-    @Override
-    public String toString() {
-        return String.format("%,d %s", Long.valueOf(duration), timeUnit);
-    }
-
-    public Timeout toTimeout() {
-        return Timeout.of(duration, timeUnit);
-    }
-
-}
+/*
+ * ====================================================================
+ * 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.core5.util;
+
+import java.text.NumberFormat;
+import java.text.ParseException;
+import java.util.Locale;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+
+/**
+ * Represents a time value as a {@code long} time and {@link TimeUnit}.
+ *
+ * @since 5.0
+ */
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class TimeValue {
+
+    static final int INT_UNDEFINED = -1;
+    public static final TimeValue NEG_ONE_MILLISECONDS = TimeValue.of(INT_UNDEFINED, TimeUnit.MILLISECONDS);
+    public static final TimeValue NEG_ONE_SECONDS = TimeValue.of(INT_UNDEFINED, TimeUnit.SECONDS);
+    public static final TimeValue ZERO_MILLISECONDS = TimeValue.of(0, TimeUnit.MILLISECONDS);
+
+    /**
+     * Returns the given {@code long} value as an {@code int} where long values out of int range are returned as
+     * {@link Integer#MIN_VALUE} and {@link Integer#MAX_VALUE}.
+     *
+     * <p>
+     * For example: {@code TimeValue.asBoundInt(Long.MAX_VALUE)} returns {@code Integer.MAX_VALUE}.
+     * </p>
+     *
+     * @param value
+     *            a long value to convert
+     * @return an int value bound within {@link Integer#MIN_VALUE} and {@link Integer#MAX_VALUE}.
+     */
+    public static int asBoundInt(final long value) {
+        if (value > Integer.MAX_VALUE) {
+            return Integer.MAX_VALUE;
+        } else if (value < Integer.MIN_VALUE) {
+            return Integer.MIN_VALUE;
+        }
+        return (int) value;
+    }
+
+    /**
+     * Returns the given {@code timeValue} if it is not {@code null}, if {@code null} then returns the given
+     * {@code defaultValue}.
+     *
+     * @param timeValue
+     *            may be {@code null}
+     * @param defaultValue
+     *            may be {@code null}
+     * @return {@code timeValue} or {@code defaultValue}
+     */
+    public static TimeValue defaultsTo(final TimeValue timeValue, final TimeValue defaultValue) {
+        return timeValue != null ? timeValue : defaultValue;
+    }
+
+    /**
+     * Returns the given {@code timeValue} if it is not {@code null}, if {@code null} then returns
+     * {@link #NEG_ONE_SECONDS}.
+     *
+     * @param timeValue
+     *            may be {@code null}
+     * @return {@code timeValue} or {@link #NEG_ONE_SECONDS}
+     */
+    public static TimeValue defaultsToNegativeOneMillisecond(final TimeValue timeValue) {
+        return defaultsTo(timeValue, NEG_ONE_MILLISECONDS);
+    }
+
+    /**
+     * Returns the given {@code timeValue} if it is not {@code null}, if {@code null} then returns
+     * {@link #NEG_ONE_SECONDS}.
+     *
+     * @param timeValue
+     *            may be {@code null}
+     * @return {@code timeValue} or {@link #NEG_ONE_SECONDS}
+     */
+    public static TimeValue defaultsToNegativeOneSecond(final TimeValue timeValue) {
+        return defaultsTo(timeValue, NEG_ONE_SECONDS);
+    }
+
+    /**
+     * Returns the given {@code timeValue} if it is not {@code null}, if {@code null} then returns
+     * {@link #ZERO_MILLISECONDS}.
+     *
+     * @param timeValue
+     *            may be {@code null}
+     * @return {@code timeValue} or {@link #ZERO_MILLISECONDS}
+     */
+    public static TimeValue defaultsToZeroMillis(final TimeValue timeValue) {
+        return defaultsTo(timeValue, ZERO_MILLISECONDS);
+    }
+
+    public static boolean isNonNegative(final TimeValue timeValue) {
+        return timeValue != null && timeValue.getDuration() >= 0;
+    }
+
+    public static boolean isPositive(final TimeValue timeValue) {
+        return timeValue != null && timeValue.getDuration() > 0;
+    }
+
+    /**
+     * Creates a TimeValue.
+     *
+     * @param duration
+     *            the time duration in the given {@code timeUnit}.
+     * @param timeUnit
+     *            the time unit for the given durarion.
+     * @return a Timeout
+     */
+    public static TimeValue of(final long duration, final TimeUnit timeUnit) {
+        return new TimeValue(duration, timeUnit);
+    }
+
+    public static TimeValue ofDays(final long days) {
+        return of(days, TimeUnit.DAYS);
+    }
+
+    public static TimeValue ofHours(final long hours) {
+        return of(hours, TimeUnit.HOURS);
+    }
+
+    public static TimeValue ofMicroseconds(final long microseconds) {
+        return of(microseconds, TimeUnit.MICROSECONDS);
+    }
+
+    public static TimeValue ofMillis(final long millis) {
+        return of(millis, TimeUnit.MILLISECONDS);
+    }
+
+    public static TimeValue ofMinutes(final long minutes) {
+        return of(minutes, TimeUnit.MINUTES);
+    }
+
+    public static TimeValue ofNanoseconds(final long nanoseconds) {
+        return of(nanoseconds, TimeUnit.NANOSECONDS);
+    }
+
+    public static TimeValue ofSeconds(final long seconds) {
+        return of(seconds, TimeUnit.SECONDS);
+    }
+
+    /**
+     * Parses a TimeValue in the format {@code <Integer><SPACE><TimeUnit>}, for example {@code "1,200 MILLISECONDS"}
+     *
+     * @param value
+     *            the TimeValue to parse
+     * @return a new TimeValue
+     * @throws ParseException
+     *             if the number cannot be parsed
+     */
+    public static TimeValue parse(final String value) throws ParseException {
+        final String split[] = value.split("\\s+");
+        if (split.length < 2) {
+            throw new IllegalArgumentException(
+                    String.format("Expected format for <Integer><SPACE><TimeUnit>: ", value));
+        }
+        return TimeValue.of(NumberFormat.getInstance().parse(split[0]).longValue(),
+                TimeUnit.valueOf(split[1].trim().toUpperCase(Locale.ROOT)));
+    }
+
+    private final long duration;
+
+    private final TimeUnit timeUnit;
+
+    TimeValue(final long duration, final TimeUnit timeUnit) {
+        super();
+        this.duration = duration;
+        this.timeUnit = Args.notNull(timeUnit, "timeUnit");
+    }
+
+    public long convert(final TimeUnit sourceUnit) {
+        return timeUnit.convert(duration, sourceUnit);
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof TimeValue) {
+            final TimeValue that = (TimeValue) obj;
+            return this.duration == that.duration && LangUtils.equals(this.timeUnit, that.timeUnit);
+        }
+        return false;
+    }
+
+    public long getDuration() {
+        return duration;
+    }
+
+    public TimeUnit getTimeUnit() {
+        return timeUnit;
+    }
+
+    @Override
+    public int hashCode() {
+        int hash = LangUtils.HASH_SEED;
+        hash = LangUtils.hashCode(hash, Long.valueOf(duration));
+        hash = LangUtils.hashCode(hash, timeUnit);
+        return hash;
+    }
+
+    public void sleep() throws InterruptedException {
+        timeUnit.sleep(duration);
+    }
+
+    public void timedJoin(final Thread thread) throws InterruptedException {
+        timeUnit.timedJoin(thread, duration);
+    }
+
+    public void timedWait(final Object obj) throws InterruptedException {
+        timeUnit.timedWait(obj, duration);
+    }
+
+    public long toDays() {
+        return timeUnit.toDays(duration);
+    }
+
+    public long toHours() {
+        return timeUnit.toHours(duration);
+    }
+
+    public long toMicros() {
+        return timeUnit.toMicros(duration);
+    }
+
+    public long toMillis() {
+        return timeUnit.toMillis(duration);
+    }
+
+    public int toMillisIntBound() {
+        return asBoundInt(toMillis());
+    }
+
+    public long toMinutes() {
+        return timeUnit.toMinutes(duration);
+    }
+
+    public long toNanos() {
+        return timeUnit.toNanos(duration);
+    }
+
+    public long toSeconds() {
+        return timeUnit.toSeconds(duration);
+    }
+
+    public int toSecondsIntBound() {
+        return asBoundInt(toSeconds());
+    }
+
+    @Override
+    public String toString() {
+        return String.format("%,d %s", Long.valueOf(duration), timeUnit);
+    }
+
+    public Timeout toTimeout() {
+        return Timeout.of(duration, timeUnit);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/main/java/org/apache/hc/core5/util/Timeout.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/Timeout.java b/httpcore5/src/main/java/org/apache/hc/core5/util/Timeout.java
index 04b40e0..888a25b 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/Timeout.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/Timeout.java
@@ -1,211 +1,211 @@
-/*
- * ====================================================================
- * 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.core5.util;
-
-import java.text.ParseException;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.hc.core5.annotation.Contract;
-import org.apache.hc.core5.annotation.ThreadingBehavior;
-
-/**
- * Represents a timeout value as a {@code long} time and {@link TimeUnit}.
- *
- * @since 5.0
- */
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
-public class Timeout extends TimeValue {
-
-    public static final Timeout ZERO_MILLISECONDS = Timeout.of(0, TimeUnit.MILLISECONDS);
-
-    /**
-     * A disabled timeout represented as 0 {@code MILLISECONDS}.
-     */
-    public static final Timeout DISABLED = new Timeout(0, TimeUnit.MILLISECONDS);
-
-    /**
-     * An undefined timeout represented as -1 {@code MILLISECONDS}.
-     */
-    public static final Timeout UNDEFINED_MILLISECONDS = new Timeout(INT_UNDEFINED, TimeUnit.MILLISECONDS);
-
-    /**
-     * An undefined timeout represented as -1 {@code SECONDS}.
-     */
-    public static final Timeout UNDEFINED_SECONDS = new Timeout(INT_UNDEFINED, TimeUnit.SECONDS);
-
-    /**
-     * Creates a Timeout.
-     *
-     * @param duration
-     *            the time duration in the given {@code timeUnit}.
-     * @param timeUnit
-     *            the time unit for the given durarion.
-     * @return a Timeout
-     */
-    public static Timeout of(final long duration, final TimeUnit timeUnit) {
-        return new Timeout(duration, timeUnit);
-    }
-
-    /**
-     * Creates a Timeout.
-     *
-     * @param days
-     *            the duration in days and the given {@code timeUnit}.
-     * @return a Timeout
-     */
-    public static Timeout ofDays(final long days) {
-        return of(days, TimeUnit.DAYS);
-    }
-
-    /**
-     * Creates a Timeout.
-     *
-     * @param hours
-     *            the duration in hours and the given {@code timeUnit}.
-     * @return a Timeout
-     */
-    public static Timeout ofHours(final long hours) {
-        return of(hours, TimeUnit.HOURS);
-    }
-
-    /**
-     * Creates a Timeout.
-     *
-     * @param microseconds
-     *            the duration in seconds and the given {@code timeUnit}.
-     * @return a Timeout
-     */
-    public static Timeout ofMicroseconds(final long microseconds) {
-        return of(microseconds, TimeUnit.MICROSECONDS);
-    }
-
-    /**
-     * Creates a Timeout.
-     *
-     * @param milliseconds
-     *            the duration in milliseconds and the given {@code timeUnit}.
-     * @return a Timeout
-     */
-    public static Timeout ofMillis(final long milliseconds) {
-        return of(milliseconds, TimeUnit.MILLISECONDS);
-    }
-
-    /**
-     * Creates a Timeout.
-     *
-     * @param minutes
-     *            the duration in minutes and the given {@code timeUnit}.
-     * @return a Timeout
-     */
-    public static Timeout ofMinutes(final long minutes) {
-        return of(minutes, TimeUnit.MINUTES);
-    }
-
-    /**
-     * Creates a Timeout.
-     *
-     * @param nanoseconds
-     *            the duration in seconds and the given {@code timeUnit}.
-     * @return a Timeout
-     */
-    public static Timeout ofNanoseconds(final long nanoseconds) {
-        return of(nanoseconds, TimeUnit.NANOSECONDS);
-    }
-
-    /**
-     * Creates a Timeout.
-     *
-     * @param seconds
-     *            the duration in seconds and the given {@code timeUnit}.
-     * @return a Timeout
-     */
-    public static Timeout ofSeconds(final long seconds) {
-        return of(seconds, TimeUnit.SECONDS);
-    }
-
-    /**
-     * Parses a Timeout in the format {@code <Integer><SPACE><TimeUnit>}, for example {@code "1,200 MILLISECONDS"}
-     *
-     * @param value
-     *            the TimeValue to parse
-     * @return a new TimeValue
-     * @throws ParseException
-     *             if the number cannot be parsed
-     */
-    public static Timeout parse(final String value) throws ParseException {
-        return TimeValue.parse(value).toTimeout();
-    }
-
-    private static long validateDuration(final long duration) {
-        if (duration < INT_UNDEFINED) {
-            throw new IllegalArgumentException("Duration may not be less than " + INT_UNDEFINED);
-        }
-        return duration;
-    }
-
-    Timeout(final long duration, final TimeUnit timeUnit) {
-        super(validateDuration(duration), Args.notNull(timeUnit, "timeUnit"));
-    }
-
-    /**
-     * Whether this timeout is disabled.
-     *
-     * @return Whether this timeout is disabled.
-     */
-    public boolean isDisabled() {
-        return getDuration() == 0;
-    }
-
-    /**
-     * Whether this timeout is enabled.
-     *
-     * @return Whether this timeout is disabled.
-     */
-    public boolean isEnabled() {
-        return !isDisabled() && !(isUndefinedMilliseconds() || isUndefinedSeconds());
-    }
-
-    /**
-     * Whether this timeout is undefined.
-     *
-     * @return Whether this timeout is undefined.
-     */
-    public boolean isUndefinedMilliseconds() {
-        return getDuration() == INT_UNDEFINED && getTimeUnit() == TimeUnit.MILLISECONDS;
-    }
-
-    /**
-     * Whether this timeout is undefined.
-     *
-     * @return Whether this timeout is undefined.
-     */
-    public boolean isUndefinedSeconds() {
-        return getDuration() == INT_UNDEFINED && getTimeUnit() == TimeUnit.SECONDS;
-    }
-
-}
+/*
+ * ====================================================================
+ * 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.core5.util;
+
+import java.text.ParseException;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.ThreadingBehavior;
+
+/**
+ * Represents a timeout value as a {@code long} time and {@link TimeUnit}.
+ *
+ * @since 5.0
+ */
+@Contract(threading = ThreadingBehavior.IMMUTABLE)
+public class Timeout extends TimeValue {
+
+    public static final Timeout ZERO_MILLISECONDS = Timeout.of(0, TimeUnit.MILLISECONDS);
+
+    /**
+     * A disabled timeout represented as 0 {@code MILLISECONDS}.
+     */
+    public static final Timeout DISABLED = new Timeout(0, TimeUnit.MILLISECONDS);
+
+    /**
+     * An undefined timeout represented as -1 {@code MILLISECONDS}.
+     */
+    public static final Timeout UNDEFINED_MILLISECONDS = new Timeout(INT_UNDEFINED, TimeUnit.MILLISECONDS);
+
+    /**
+     * An undefined timeout represented as -1 {@code SECONDS}.
+     */
+    public static final Timeout UNDEFINED_SECONDS = new Timeout(INT_UNDEFINED, TimeUnit.SECONDS);
+
+    /**
+     * Creates a Timeout.
+     *
+     * @param duration
+     *            the time duration in the given {@code timeUnit}.
+     * @param timeUnit
+     *            the time unit for the given durarion.
+     * @return a Timeout
+     */
+    public static Timeout of(final long duration, final TimeUnit timeUnit) {
+        return new Timeout(duration, timeUnit);
+    }
+
+    /**
+     * Creates a Timeout.
+     *
+     * @param days
+     *            the duration in days and the given {@code timeUnit}.
+     * @return a Timeout
+     */
+    public static Timeout ofDays(final long days) {
+        return of(days, TimeUnit.DAYS);
+    }
+
+    /**
+     * Creates a Timeout.
+     *
+     * @param hours
+     *            the duration in hours and the given {@code timeUnit}.
+     * @return a Timeout
+     */
+    public static Timeout ofHours(final long hours) {
+        return of(hours, TimeUnit.HOURS);
+    }
+
+    /**
+     * Creates a Timeout.
+     *
+     * @param microseconds
+     *            the duration in seconds and the given {@code timeUnit}.
+     * @return a Timeout
+     */
+    public static Timeout ofMicroseconds(final long microseconds) {
+        return of(microseconds, TimeUnit.MICROSECONDS);
+    }
+
+    /**
+     * Creates a Timeout.
+     *
+     * @param milliseconds
+     *            the duration in milliseconds and the given {@code timeUnit}.
+     * @return a Timeout
+     */
+    public static Timeout ofMillis(final long milliseconds) {
+        return of(milliseconds, TimeUnit.MILLISECONDS);
+    }
+
+    /**
+     * Creates a Timeout.
+     *
+     * @param minutes
+     *            the duration in minutes and the given {@code timeUnit}.
+     * @return a Timeout
+     */
+    public static Timeout ofMinutes(final long minutes) {
+        return of(minutes, TimeUnit.MINUTES);
+    }
+
+    /**
+     * Creates a Timeout.
+     *
+     * @param nanoseconds
+     *            the duration in seconds and the given {@code timeUnit}.
+     * @return a Timeout
+     */
+    public static Timeout ofNanoseconds(final long nanoseconds) {
+        return of(nanoseconds, TimeUnit.NANOSECONDS);
+    }
+
+    /**
+     * Creates a Timeout.
+     *
+     * @param seconds
+     *            the duration in seconds and the given {@code timeUnit}.
+     * @return a Timeout
+     */
+    public static Timeout ofSeconds(final long seconds) {
+        return of(seconds, TimeUnit.SECONDS);
+    }
+
+    /**
+     * Parses a Timeout in the format {@code <Integer><SPACE><TimeUnit>}, for example {@code "1,200 MILLISECONDS"}
+     *
+     * @param value
+     *            the TimeValue to parse
+     * @return a new TimeValue
+     * @throws ParseException
+     *             if the number cannot be parsed
+     */
+    public static Timeout parse(final String value) throws ParseException {
+        return TimeValue.parse(value).toTimeout();
+    }
+
+    private static long validateDuration(final long duration) {
+        if (duration < INT_UNDEFINED) {
+            throw new IllegalArgumentException("Duration may not be less than " + INT_UNDEFINED);
+        }
+        return duration;
+    }
+
+    Timeout(final long duration, final TimeUnit timeUnit) {
+        super(validateDuration(duration), Args.notNull(timeUnit, "timeUnit"));
+    }
+
+    /**
+     * Whether this timeout is disabled.
+     *
+     * @return Whether this timeout is disabled.
+     */
+    public boolean isDisabled() {
+        return getDuration() == 0;
+    }
+
+    /**
+     * Whether this timeout is enabled.
+     *
+     * @return Whether this timeout is disabled.
+     */
+    public boolean isEnabled() {
+        return !isDisabled() && !(isUndefinedMilliseconds() || isUndefinedSeconds());
+    }
+
+    /**
+     * Whether this timeout is undefined.
+     *
+     * @return Whether this timeout is undefined.
+     */
+    public boolean isUndefinedMilliseconds() {
+        return getDuration() == INT_UNDEFINED && getTimeUnit() == TimeUnit.MILLISECONDS;
+    }
+
+    /**
+     * Whether this timeout is undefined.
+     *
+     * @return Whether this timeout is undefined.
+     */
+    public boolean isUndefinedSeconds() {
+        return getDuration() == INT_UNDEFINED && getTimeUnit() == TimeUnit.SECONDS;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/d7768b2c/httpcore5/src/test/java/org/apache/hc/core5/http/impl/bootstrap/TestAsyncServerExchangeHandlerRegistry.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/bootstrap/TestAsyncServerExchangeHandlerRegistry.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/bootstrap/TestAsyncServerExchangeHandlerRegistry.java
index 7a35684..fae4844 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/bootstrap/TestAsyncServerExchangeHandlerRegistry.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/bootstrap/TestAsyncServerExchangeHandlerRegistry.java
@@ -1,73 +1,73 @@
-/*
- * ====================================================================
- * 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.core5.http.impl.bootstrap;
-
-import org.apache.hc.core5.function.Supplier;
-import org.apache.hc.core5.http.HttpStatus;
-import org.apache.hc.core5.http.message.BasicHttpRequest;
-import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
-import org.apache.hc.core5.http.nio.support.ImmediateResponseExchangeHandler;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-public class TestAsyncServerExchangeHandlerRegistry {
-    private AsyncServerExchangeHandlerRegistry handlerRegistry;
-    private AsyncServerExchangeHandler handler;
-    private Supplier<AsyncServerExchangeHandler> supplier;
-
-    @Before
-    public void setUp() {
-        handlerRegistry = new AsyncServerExchangeHandlerRegistry("localhost");
-        handler = new ImmediateResponseExchangeHandler(HttpStatus.SC_OK, "Hello world");
-        supplier = new Supplier<AsyncServerExchangeHandler>() {
-
-            @Override
-            public AsyncServerExchangeHandler get() {
-                return handler;
-            }
-        };
-    }
-
-    @Test
-    public void testCreate() throws Exception {
-        handlerRegistry.register(null, "/test*", supplier);
-        Assert.assertNotEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/")));
-        Assert.assertNotEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/abc")));
-        Assert.assertEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/test")));
-        Assert.assertEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/testabc")));
-    }
-
-    @Test
-    public void testCreateQuery() throws Exception {
-        handlerRegistry.register(null, "/test*", supplier);
-        Assert.assertEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/test?test=a")));
-        Assert.assertNotEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/tes?test=a")));
-    }
-
-}
+/*
+ * ====================================================================
+ * 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.core5.http.impl.bootstrap;
+
+import org.apache.hc.core5.function.Supplier;
+import org.apache.hc.core5.http.HttpStatus;
+import org.apache.hc.core5.http.message.BasicHttpRequest;
+import org.apache.hc.core5.http.nio.AsyncServerExchangeHandler;
+import org.apache.hc.core5.http.nio.support.ImmediateResponseExchangeHandler;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestAsyncServerExchangeHandlerRegistry {
+    private AsyncServerExchangeHandlerRegistry handlerRegistry;
+    private AsyncServerExchangeHandler handler;
+    private Supplier<AsyncServerExchangeHandler> supplier;
+
+    @Before
+    public void setUp() {
+        handlerRegistry = new AsyncServerExchangeHandlerRegistry("localhost");
+        handler = new ImmediateResponseExchangeHandler(HttpStatus.SC_OK, "Hello world");
+        supplier = new Supplier<AsyncServerExchangeHandler>() {
+
+            @Override
+            public AsyncServerExchangeHandler get() {
+                return handler;
+            }
+        };
+    }
+
+    @Test
+    public void testCreate() throws Exception {
+        handlerRegistry.register(null, "/test*", supplier);
+        Assert.assertNotEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/")));
+        Assert.assertNotEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/abc")));
+        Assert.assertEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/test")));
+        Assert.assertEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/testabc")));
+    }
+
+    @Test
+    public void testCreateQuery() throws Exception {
+        handlerRegistry.register(null, "/test*", supplier);
+        Assert.assertEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/test?test=a")));
+        Assert.assertNotEquals(handler, handlerRegistry.create(new BasicHttpRequest("GET", "/tes?test=a")));
+    }
+
+}


[3/3] httpcomponents-core git commit: HTTPCORE-472: Fixed problem with blocking message parsers incorrectly throwing "Maximum line length limit exceeded" exception in some corner cases

Posted by ol...@apache.org.
HTTPCORE-472: Fixed problem with blocking message parsers incorrectly throwing "Maximum line length limit exceeded" exception in some corner cases


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/09d65b9b
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/09d65b9b
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/09d65b9b

Branch: refs/heads/master
Commit: 09d65b9b3e4aefe9c36b1a5ee6b8d6944e411302
Parents: d7768b2
Author: Oleg Kalnichevski <ol...@apache.org>
Authored: Thu Jun 15 13:30:24 2017 +0200
Committer: Oleg Kalnichevski <ol...@apache.org>
Committed: Thu Jun 15 15:21:05 2017 +0200

----------------------------------------------------------------------
 .../hc/core5/http/impl/io/SessionInputBufferImpl.java    |  2 +-
 .../hc/core5/http/impl/io/TestSessionInOutBuffers.java   | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/09d65b9b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
index d5bd31e..5e8c03d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/io/SessionInputBufferImpl.java
@@ -252,7 +252,7 @@ public class SessionInputBufferImpl implements SessionInputBuffer {
 
             if (this.maxLineLen > 0) {
                 final int currentLen = this.linebuffer.length()
-                        + (pos > 0 ? pos : this.bufferlen) - this.bufferpos;
+                        + (pos >= 0 ? pos : this.bufferlen) - this.bufferpos;
                 if (currentLen >= this.maxLineLen) {
                     throw new MessageConstraintException("Maximum line length limit exceeded");
                 }

http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/09d65b9b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
index 2e68a20..f532c81 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
@@ -438,6 +438,17 @@ public class TestSessionInOutBuffers {
         }
     }
 
+    @Test //HTTPCORE-472
+    public void testLineLimit3() throws Exception {
+        final String s = "012345678\r\nblaaaaaaaaaaaaaaaaaah";
+        final byte[] tmp = s.getBytes(StandardCharsets.US_ASCII);
+        final SessionInputBuffer inbuffer1 = new SessionInputBufferImpl(128);
+        final ByteArrayInputStream inputStream = new ByteArrayInputStream(tmp);
+        final CharArrayBuffer chbuffer = new CharArrayBuffer(16);
+        inbuffer1.readLine(chbuffer, inputStream);
+        Assert.assertEquals("012345678", chbuffer.toString());
+    }
+
     @Test
     public void testReadLineFringeCase1() throws Exception {
         final String s = "abc\r\n";