You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ro...@apache.org on 2007/07/11 13:05:32 UTC
svn commit: r555241 - in
/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn:
TestAllConn.java TestExceptions.java TestParams.java
Author: rolandw
Date: Wed Jul 11 04:05:31 2007
New Revision: 555241
URL: http://svn.apache.org/viewvc?view=rev&rev=555241
Log:
trivial tests on exceptions and params to make coverage look better
Added:
jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestExceptions.java (with props)
jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestParams.java (with props)
Modified:
jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestAllConn.java
Modified: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestAllConn.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestAllConn.java?view=diff&rev=555241&r1=555240&r2=555241
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestAllConn.java (original)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestAllConn.java Wed Jul 11 04:05:31 2007
@@ -47,6 +47,8 @@
suite.addTest(TestRouteDirector.suite());
suite.addTest(TestRouteTracker.suite());
suite.addTest(TestScheme.suite());
+ suite.addTest(TestParams.suite());
+ suite.addTest(TestExceptions.suite());
return suite;
}
Added: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestExceptions.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestExceptions.java?view=auto&rev=555241
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestExceptions.java (added)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestExceptions.java Wed Jul 11 04:05:31 2007
@@ -0,0 +1,79 @@
+/*
+ * $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
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Unit tests for exceptions.
+ * Trivial, but it looks better in the Clover reports.
+ */
+public class TestExceptions extends TestCase {
+
+ public TestExceptions(String testName) {
+ super(testName);
+ }
+
+ public static void main(String args[]) {
+ String[] testCaseName = { TestExceptions.class.getName() };
+ junit.textui.TestRunner.main(testCaseName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestExceptions.class);
+ }
+
+ public void testCTX() {
+ String msg = "sample exception message";
+ ConnectTimeoutException ctx =
+ new ConnectTimeoutException(msg);
+ assertFalse(ctx.toString().indexOf(msg) < 0);
+ assertSame(msg, ctx.getMessage());
+
+ ctx = new ConnectTimeoutException();
+ assertNull(ctx.getMessage());
+ }
+
+ public void testCPTX() {
+ String msg = "sample exception message";
+ ConnectionPoolTimeoutException cptx =
+ new ConnectionPoolTimeoutException(msg);
+ assertFalse(cptx.toString().indexOf(msg) < 0);
+ assertSame(msg, cptx.getMessage());
+
+ cptx = new ConnectionPoolTimeoutException();
+ assertNull(cptx.getMessage());
+ }
+}
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestExceptions.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestExceptions.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestExceptions.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestParams.java
URL: http://svn.apache.org/viewvc/jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestParams.java?view=auto&rev=555241
==============================================================================
--- jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestParams.java (added)
+++ jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestParams.java Wed Jul 11 04:05:31 2007
@@ -0,0 +1,171 @@
+/*
+ * $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
+ * <http://www.apache.org/>.
+ *
+ */
+
+package org.apache.http.conn;
+
+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;
+
+
+/**
+ * Unit tests for parameters.
+ * Trivial, but it looks better in the Clover reports.
+ */
+public class TestParams extends TestCase {
+
+ public final static
+ HttpHost TARGET1 = new HttpHost("target1.test.invalid");
+ public final static
+ HostConfiguration HOSTCFG1 = new HostConfiguration(TARGET1,null,null);
+
+
+ public TestParams(String testName) {
+ super(testName);
+ }
+
+ public static void main(String args[]) {
+ String[] testCaseName = { TestParams.class.getName() };
+ junit.textui.TestRunner.main(testCaseName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestParams.class);
+ }
+
+
+ public void testBadArgs() {
+ HttpParams params = new BasicHttpParams();
+
+/* not checked
+ try {
+ HttpConnectionManagerParams.
+ setMaxConnectionsPerHost(params, null, 3);
+ fail();
+ } catch (IllegalArgumentException iax) {
+ // expected
+ }
+*/
+
+ try {
+ HttpConnectionManagerParams.
+ setMaxConnectionsPerHost(null, HOSTCFG1, 3);
+ fail();
+ } catch (IllegalArgumentException iax) {
+ // expected
+ }
+
+ try {
+ HttpConnectionManagerParams.
+ setMaxConnectionsPerHost(params, HOSTCFG1, 0);
+ fail();
+ } catch (IllegalArgumentException iax) {
+ // expected
+ }
+
+/* not checked
+ try {
+ HttpConnectionManagerParams.
+ getMaxConnectionsPerHost(params, null);
+ fail();
+ } catch (IllegalArgumentException iax) {
+ // expected
+ }
+*/
+
+ try {
+ HttpConnectionManagerParams.
+ getMaxConnectionsPerHost(null, HOSTCFG1);
+ fail();
+ } catch (IllegalArgumentException iax) {
+ // expected
+ }
+
+
+ try {
+ HttpConnectionManagerParams.
+ setMaxTotalConnections(null, 50);
+ fail();
+ } catch (IllegalArgumentException iax) {
+ // expected
+ }
+
+/* not checked
+ try {
+ HttpConnectionManagerParams.
+ setMaxTotalConnections(null, 0);
+ fail();
+ } catch (IllegalArgumentException iax) {
+ // expected
+ }
+*/
+
+ try {
+ HttpConnectionManagerParams.
+ getMaxTotalConnections(null);
+ fail();
+ } catch (IllegalArgumentException iax) {
+ // expected
+ }
+ }
+
+
+ public void testDefMaxConn() {
+
+ HttpParams params = new BasicHttpParams();
+
+ int fdmcph = HttpConnectionManagerParams.
+ getDefaultMaxConnectionsPerHost(params);
+
+ int fmcph = HttpConnectionManagerParams.
+ getMaxConnectionsPerHost(params, HOSTCFG1);
+
+ assertEquals(fdmcph, fmcph);
+
+ int dmcph = fdmcph + 3;
+ HttpConnectionManagerParams.
+ setDefaultMaxConnectionsPerHost(params, dmcph);
+ int ndmcph = HttpConnectionManagerParams.
+ getDefaultMaxConnectionsPerHost(params);
+ assertEquals(dmcph, ndmcph);
+
+
+ int mcph = HttpConnectionManagerParams.
+ getMaxConnectionsPerHost(params, HOSTCFG1);
+ assertEquals(ndmcph, mcph);
+ }
+
+}
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestParams.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestParams.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: jakarta/httpcomponents/httpclient/trunk/module-client/src/test/java/org/apache/http/conn/TestParams.java
------------------------------------------------------------------------------
svn:mime-type = text/plain