1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 package org/apache/commons/httpclient/package-summary.html">> org.apache.commons.httpclient;
33
34 import org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory;
35 import org.apache.commons.httpclient.protocol.Protocol;
36 import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
37 import org.apache.commons.httpclient.protocol.SSLProtocolSocketFactory;
38
39 import junit.framework.Test;
40 import junit.framework.TestCase;
41 import junit.framework.TestSuite;
42
43 /***
44 */
45 public class TestEquals extends TestCase {
46
47 public static Test suite() {
48 return new TestSuite(TestEquals.class);
49 }
50
51 /***
52 *
53 */
54 public TestEquals() {
55 super();
56 }
57
58 /***
59 * @param arg0
60 */
61 public TestEquals(String arg0) {
62 super(arg0);
63 }
64
65 public void testProtocol() {
66
67 Protocol p1 = new Protocol("test", new DefaultProtocolSocketFactory(), 123);
68 Protocol p2 = new Protocol("test", new DefaultProtocolSocketFactory(), 123);
69
70 assertTrue(p1.equals(p2));
71 assertTrue(p2.equals(p1));
72 }
73
74 public void testProtocolSocketFactory() {
75
76 ProtocolSocketFactory p1 = new DefaultProtocolSocketFactory();
77 ProtocolSocketFactory p2 = new DefaultProtocolSocketFactory();
78
79 assertTrue(p1.equals(p2));
80 assertTrue(p2.equals(p1));
81
82 p1 = new SSLProtocolSocketFactory();
83 p2 = new SSLProtocolSocketFactory();
84
85 assertTrue(p1.equals(p2));
86 assertTrue(p2.equals(p1));
87
88 }
89
90 public void testProtocolSocketFactorySublass() {
91 ProtocolSocketFactory factory1 = new DefaultProtocolSocketFactory();
92 ProtocolSocketFactory factory2 = new DefaultProtocolSocketFactory() {};
93
94 Protocol protocolA = new Protocol("http", factory1, 80);
95 Protocol protocolB = new Protocol("http", factory2, 80);
96 Protocol protocolC = new Protocol("http", factory2, 80);
97
98 assertTrue(protocolB.equals(protocolC));
99 assertFalse(protocolA.equals(protocolB));
100 assertFalse(protocolB.equals(protocolA));
101 assertFalse(protocolA.equals(protocolB) != protocolB.equals(protocolA));
102 assertTrue(protocolB.equals(protocolB));
103 }
104
105 public void testHostConfiguration() {
106
107 HostConfiguration hc1 = new HostConfiguration();
108 hc1.setHost("http", 80, "http");
109
110 HostConfiguration hc2 = new HostConfiguration();
111 hc2.setHost("http", 80, "http");
112
113 assertTrue(hc1.equals(hc2));
114 assertTrue(hc2.equals(hc1));
115 }
116
117 }