From 1892a783cc39a5e73ac3bae9cbfefcfcd3d85210 Mon Sep 17 00:00:00 2001 From: Roland Weber Date: Sun, 3 Feb 2008 23:26:29 +0000 Subject: [PATCH] first tests for route params git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@618122 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/http/conn/TestAllConn.java | 3 +- .../http/conn/params/TestAllConnParams.java | 61 ++++++++++ .../http/conn/{ => params}/TestParams.java | 2 +- .../http/conn/params/TestRouteParams.java | 111 ++++++++++++++++++ 4 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 module-client/src/test/java/org/apache/http/conn/params/TestAllConnParams.java rename module-client/src/test/java/org/apache/http/conn/{ => params}/TestParams.java (99%) create mode 100644 module-client/src/test/java/org/apache/http/conn/params/TestRouteParams.java diff --git a/module-client/src/test/java/org/apache/http/conn/TestAllConn.java b/module-client/src/test/java/org/apache/http/conn/TestAllConn.java index 9b5588b9b..159403853 100644 --- a/module-client/src/test/java/org/apache/http/conn/TestAllConn.java +++ b/module-client/src/test/java/org/apache/http/conn/TestAllConn.java @@ -30,6 +30,7 @@ package org.apache.http.conn; +import org.apache.http.conn.params.TestAllConnParams; import org.apache.http.conn.routing.TestAllRouting; import org.apache.http.conn.ssl.TestAllSSL; import org.apache.http.conn.util.TestAllUtil; @@ -48,8 +49,8 @@ public class TestAllConn extends TestCase { TestSuite suite = new TestSuite(); suite.addTest(TestScheme.suite()); - suite.addTest(TestParams.suite()); suite.addTest(TestExceptions.suite()); + suite.addTest(TestAllConnParams.suite()); suite.addTest(TestAllRouting.suite()); suite.addTest(TestAllSSL.suite()); suite.addTest(TestAllUtil.suite()); diff --git a/module-client/src/test/java/org/apache/http/conn/params/TestAllConnParams.java b/module-client/src/test/java/org/apache/http/conn/params/TestAllConnParams.java new file mode 100644 index 000000000..98d543c9b --- /dev/null +++ b/module-client/src/test/java/org/apache/http/conn/params/TestAllConnParams.java @@ -0,0 +1,61 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * ==================================================================== + * 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 + * . + * + */ + +package org.apache.http.conn.params; + +import org.apache.http.conn.routing.TestAllRouting; +import org.apache.http.conn.ssl.TestAllSSL; +import org.apache.http.conn.util.TestAllUtil; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +public class TestAllConnParams extends TestCase { + + public TestAllConnParams(String testName) { + super(testName); + } + + public static Test suite() { + TestSuite suite = new TestSuite(); + + suite.addTest(TestParams.suite()); + suite.addTest(TestRouteParams.suite()); + + return suite; + } + + public static void main(String args[]) { + String[] testCaseName = { TestAllConnParams.class.getName() }; + junit.textui.TestRunner.main(testCaseName); + } + +} diff --git a/module-client/src/test/java/org/apache/http/conn/TestParams.java b/module-client/src/test/java/org/apache/http/conn/params/TestParams.java similarity index 99% rename from module-client/src/test/java/org/apache/http/conn/TestParams.java rename to module-client/src/test/java/org/apache/http/conn/params/TestParams.java index 87f34c9a6..ee88e748d 100644 --- a/module-client/src/test/java/org/apache/http/conn/TestParams.java +++ b/module-client/src/test/java/org/apache/http/conn/params/TestParams.java @@ -29,7 +29,7 @@ * */ -package org.apache.http.conn; +package org.apache.http.conn.params; import junit.framework.Test; import junit.framework.TestCase; diff --git a/module-client/src/test/java/org/apache/http/conn/params/TestRouteParams.java b/module-client/src/test/java/org/apache/http/conn/params/TestRouteParams.java new file mode 100644 index 000000000..eeae0972d --- /dev/null +++ b/module-client/src/test/java/org/apache/http/conn/params/TestRouteParams.java @@ -0,0 +1,111 @@ +/* + * $HeadURL$ + * $Revision$ + * $Date$ + * + * ==================================================================== + * 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 + * . + * + */ + +package org.apache.http.conn.params; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +import org.apache.http.HttpHost; +import org.apache.http.params.HttpParams; +import org.apache.http.params.BasicHttpParams; +import org.apache.http.conn.params.HttpConnectionManagerParams; +import org.apache.http.conn.routing.HttpRoute; + + +/** + * Unit tests for parameters. + * Trivial, but it looks better in the Clover reports. + */ +public class TestRouteParams extends TestCase { + + public final static + HttpHost TARGET1 = new HttpHost("target1.test.invalid"); + public final static + HttpRoute ROUTE1 = new HttpRoute(TARGET1); + + + public TestRouteParams(String testName) { + super(testName); + } + + public static void main(String args[]) { + String[] testCaseName = { TestRouteParams.class.getName() }; + junit.textui.TestRunner.main(testCaseName); + } + + public static Test suite() { + return new TestSuite(TestRouteParams.class); + } + + + public void testBadArgs() { + + try { + HttpRouteParams.getDefaultProxy(null); + } catch (IllegalArgumentException iax) { + // expected + } + + try { + HttpRouteParams.getForcedRoute(null); + } catch (IllegalArgumentException iax) { + // expected + } + + try { + HttpRouteParams.getLocalAddress(null); + } catch (IllegalArgumentException iax) { + // expected + } + + try { + HttpRouteParams.setDefaultProxy(null, null); + } catch (IllegalArgumentException iax) { + // expected + } + + try { + HttpRouteParams.setForcedRoute(null, null); + } catch (IllegalArgumentException iax) { + // expected + } + + try { + HttpRouteParams.setLocalAddress(null, null); + } catch (IllegalArgumentException iax) { + // expected + } + } + + +}