tsccm test coverage
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@609547 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
22cbf65e15
commit
74f349b0c5
|
@ -43,11 +43,13 @@ public class TestAllTSCCM extends TestCase {
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite();
|
TestSuite suite = new TestSuite();
|
||||||
|
|
||||||
|
suite.addTest(TestDumbHelpers.suite());
|
||||||
suite.addTest(TestWaitingThread.suite());
|
suite.addTest(TestWaitingThread.suite());
|
||||||
|
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
String[] testCaseName = { TestAllTSCCM.class.getName() };
|
String[] testCaseName = { TestAllTSCCM.class.getName() };
|
||||||
junit.textui.TestRunner.main(testCaseName);
|
junit.textui.TestRunner.main(testCaseName);
|
||||||
|
|
|
@ -0,0 +1,137 @@
|
||||||
|
/*
|
||||||
|
* $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.impl.conn.tsccm;
|
||||||
|
|
||||||
|
/*
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
|
import java.util.concurrent.locks.Condition;
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
*/
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.http.HttpHost;
|
||||||
|
import org.apache.http.conn.HttpRoute;
|
||||||
|
import org.apache.http.conn.Scheme;
|
||||||
|
import org.apache.http.conn.SchemeRegistry;
|
||||||
|
import org.apache.http.conn.SocketFactory;
|
||||||
|
import org.apache.http.conn.PlainSocketFactory;
|
||||||
|
import org.apache.http.conn.ClientConnectionOperator;
|
||||||
|
import org.apache.http.impl.conn.DefaultClientConnectionOperator;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for simple helper classes without advanced functionality.
|
||||||
|
*/
|
||||||
|
public class TestDumbHelpers extends TestCase {
|
||||||
|
|
||||||
|
public final static
|
||||||
|
HttpHost TARGET = new HttpHost("target.test.invalid");
|
||||||
|
|
||||||
|
|
||||||
|
/** The default scheme registry. */
|
||||||
|
private SchemeRegistry supportedSchemes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public TestDumbHelpers(String testName) {
|
||||||
|
super(testName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String args[]) {
|
||||||
|
String[] testCaseName = { TestDumbHelpers.class.getName() };
|
||||||
|
junit.textui.TestRunner.main(testCaseName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Test suite() {
|
||||||
|
return new TestSuite(TestDumbHelpers.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void setUp() {
|
||||||
|
supportedSchemes = new SchemeRegistry();
|
||||||
|
SocketFactory sf = PlainSocketFactory.getSocketFactory();
|
||||||
|
supportedSchemes.register(new Scheme("http", sf, 80));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void testBasicPoolEntry() {
|
||||||
|
HttpRoute route = new HttpRoute(TARGET);
|
||||||
|
ClientConnectionOperator ccop =
|
||||||
|
new DefaultClientConnectionOperator(supportedSchemes);
|
||||||
|
|
||||||
|
BasicPoolEntry bpe = null;
|
||||||
|
try {
|
||||||
|
bpe = new BasicPoolEntry(null, null, null);
|
||||||
|
fail("null operator not detected");
|
||||||
|
} catch (NullPointerException npx) {
|
||||||
|
// expected
|
||||||
|
} catch (IllegalArgumentException iax) {
|
||||||
|
// would be preferred
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
bpe = new BasicPoolEntry(ccop, null, null);
|
||||||
|
fail("null route not detected");
|
||||||
|
} catch (IllegalArgumentException iax) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
|
||||||
|
bpe = new BasicPoolEntry(ccop, route, null);
|
||||||
|
assertEquals ("wrong operator", ccop, bpe.getOperator());
|
||||||
|
assertEquals ("wrong route", route, bpe.getPlannedRoute());
|
||||||
|
assertNotNull("missing ref", bpe.getWeakRef());
|
||||||
|
|
||||||
|
assertEquals("bad weak ref", bpe, bpe.getWeakRef().get());
|
||||||
|
assertEquals("bad ref route", route, bpe.getWeakRef().getRoute());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void testBasicPoolEntryRef() {
|
||||||
|
// the actual reference is tested implicitly with BasicPoolEntry
|
||||||
|
// but we need to cover the argument check in the constructor
|
||||||
|
try {
|
||||||
|
new BasicPoolEntryRef(null, null);
|
||||||
|
fail("null pool entry not detected");
|
||||||
|
} catch (IllegalArgumentException iax) {
|
||||||
|
// expected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // class TestDumbHelpers
|
Loading…
Reference in New Issue