001: /*
002: * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//httpclient/src/test/org/apache/commons/httpclient/TestEquals.java,v 1.2 2004/02/22 18:08:49 olegk Exp $
003: * $Revision: 480424 $
004: * $Date: 2006-11-29 06:56:49 +0100 (Wed, 29 Nov 2006) $
005: *
006: * ====================================================================
007: *
008: * Licensed to the Apache Software Foundation (ASF) under one or more
009: * contributor license agreements. See the NOTICE file distributed with
010: * this work for additional information regarding copyright ownership.
011: * The ASF licenses this file to You under the Apache License, Version 2.0
012: * (the "License"); you may not use this file except in compliance with
013: * the License. You may obtain a copy of the License at
014: *
015: * http://www.apache.org/licenses/LICENSE-2.0
016: *
017: * Unless required by applicable law or agreed to in writing, software
018: * distributed under the License is distributed on an "AS IS" BASIS,
019: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
020: * See the License for the specific language governing permissions and
021: * limitations under the License.
022: * ====================================================================
023: *
024: * This software consists of voluntary contributions made by many
025: * individuals on behalf of the Apache Software Foundation. For more
026: * information on the Apache Software Foundation, please see
027: * <http://www.apache.org/>.
028: *
029: * [Additional notices, if required by prior licensing conditions]
030: *
031: */
032: package org.apache.commons.httpclient;
033:
034: import org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory;
035: import org.apache.commons.httpclient.protocol.Protocol;
036: import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
037: import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory;
038:
039: import junit.framework.Test;
040: import junit.framework.TestCase;
041: import junit.framework.TestSuite;
042:
043: /**
044: */
045: public class TestEquals extends TestCase {
046:
047: public static Test suite() {
048: return new TestSuite(TestEquals.class);
049: }
050:
051: /**
052: *
053: */
054: public TestEquals() {
055: super ();
056: }
057:
058: /**
059: * @param arg0
060: */
061: public TestEquals(String arg0) {
062: super (arg0);
063: }
064:
065: public void testProtocol() {
066:
067: Protocol p1 = new Protocol("test",
068: new DefaultProtocolSocketFactory(), 123);
069: Protocol p2 = new Protocol("test",
070: new DefaultProtocolSocketFactory(), 123);
071:
072: assertTrue(p1.equals(p2));
073: assertTrue(p2.equals(p1));
074: }
075:
076: public void testProtocolSocketFactory() {
077:
078: ProtocolSocketFactory p1 = new DefaultProtocolSocketFactory();
079: ProtocolSocketFactory p2 = new DefaultProtocolSocketFactory();
080:
081: assertTrue(p1.equals(p2));
082: assertTrue(p2.equals(p1));
083:
084: p1 = new SSLProtocolSocketFactory();
085: p2 = new SSLProtocolSocketFactory();
086:
087: assertTrue(p1.equals(p2));
088: assertTrue(p2.equals(p1));
089:
090: }
091:
092: public void testProtocolSocketFactorySublass() {
093: ProtocolSocketFactory factory1 = new DefaultProtocolSocketFactory();
094: ProtocolSocketFactory factory2 = new DefaultProtocolSocketFactory() {
095: };
096:
097: Protocol protocolA = new Protocol("http", factory1, 80);
098: Protocol protocolB = new Protocol("http", factory2, 80);
099: Protocol protocolC = new Protocol("http", factory2, 80);
100:
101: assertTrue(protocolB.equals(protocolC));
102: assertFalse(protocolA.equals(protocolB));
103: assertFalse(protocolB.equals(protocolA));
104: assertFalse(protocolA.equals(protocolB) != protocolB
105: .equals(protocolA));
106: assertTrue(protocolB.equals(protocolB));
107: }
108:
109: public void testHostConfiguration() {
110:
111: HostConfiguration hc1 = new HostConfiguration();
112: hc1.setHost("http", 80, "http");
113:
114: HostConfiguration hc2 = new HostConfiguration();
115: hc2.setHost("http", 80, "http");
116:
117: assertTrue(hc1.equals(hc2));
118: assertTrue(hc2.equals(hc1));
119: }
120:
121: }
|