* Added TestAll* test suites

* Fixed broken test cases

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@406434 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2006-05-14 21:19:51 +00:00
parent 9166e32b85
commit 020ec5017f
4 changed files with 160 additions and 5 deletions

View File

@ -0,0 +1,50 @@
/*
* $HeadURL$
* $Revision$
* $Date$
* ====================================================================
*
* Copyright 1999-2006 The Apache Software Foundation
*
* Licensed 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.cookie.impl;
import junit.framework.*;
public class TestAllCookieImpl extends TestCase {
public TestAllCookieImpl(String testName) {
super(testName);
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(TestAbstractCookieSpec.suite());
return suite;
}
public static void main(String args[]) {
String[] testCaseName = { TestAllCookieImpl.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
}

View File

@ -0,0 +1,54 @@
/*
* $HeadURL$
* $Revision$
* $Date$
* ====================================================================
*
* Copyright 1999-2006 The Apache Software Foundation
*
* Licensed 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.httpclient;
import org.apache.http.cookie.impl.TestAllCookieImpl;
import org.apache.httpclient.impl.TestAllHttpClientImpl;
import junit.framework.*;
public class TestAll extends TestCase {
public TestAll(String testName) {
super(testName);
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(TestAllCookieImpl.suite());
suite.addTest(TestAllHttpClientImpl.suite());
return suite;
}
public static void main(String args[]) {
String[] testCaseName = { TestAll.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
}

View File

@ -0,0 +1,51 @@
/*
* $HeadURL$
* $Revision$
* $Date$
* ====================================================================
*
* Copyright 1999-2006 The Apache Software Foundation
*
* Licensed 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.httpclient.impl;
import junit.framework.*;
public class TestAllHttpClientImpl extends TestCase {
public TestAllHttpClientImpl(String testName) {
super(testName);
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(TestAutoCloseInputStream.suite());
suite.addTest(TestDefaultResponseConsumedWatcher.suite());
return suite;
}
public static void main(String args[]) {
String[] testCaseName = { TestAllHttpClientImpl.class.getName() };
junit.textui.TestRunner.main(testCaseName);
}
}

View File

@ -29,6 +29,7 @@
package org.apache.httpclient.impl;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.apache.http.Header;
import org.apache.http.HttpConnection;
@ -94,10 +95,9 @@ public void testConnectionAutoClose() throws Exception {
// Wrap the entity input stream
ResponseConsumedWatcher watcher = new DefaultResponseConsumedWatcher(conn, response);
entity.setContent(new AutoCloseInputStream(entity.getContent(), watcher));
InputStream content = new AutoCloseInputStream(entity.getContent(), watcher);
assertTrue(conn.isOpen());
while (entity.getContent().read() != -1) {}
while (content.read() != -1) {}
assertFalse(conn.isOpen());
}
@ -117,10 +117,10 @@ public void testConnectionKeepAlive() throws Exception {
// Wrap the entity input stream
ResponseConsumedWatcher watcher = new DefaultResponseConsumedWatcher(conn, response);
entity.setContent(new AutoCloseInputStream(entity.getContent(), watcher));
InputStream content = new AutoCloseInputStream(entity.getContent(), watcher);
assertTrue(conn.isOpen());
while (entity.getContent().read() != -1) {}
while (content.read() != -1) {}
assertTrue(conn.isOpen());
}
}