Source Code Cross Referenced for ChannelBindingTest.java in  » Apache-Harmony-Java-SE » org-package » org » ietf » jgss » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » org package » org.ietf.jgss 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Alexander V. Esin
020:         * @version $Revision$
021:         */package org.ietf.jgss;
022:
023:        import java.net.InetAddress;
024:        import java.util.Arrays;
025:
026:        import junit.framework.TestCase;
027:
028:        /**
029:         * Tests ChannelBinding class
030:         */
031:        public class ChannelBindingTest extends TestCase {
032:
033:            public void testGetApplicationData() {
034:                byte data[] = { 0, 1, 2, 10, 20 };
035:                ChannelBinding cb = new ChannelBinding(data);
036:                assertTrue(Arrays.equals(new byte[] { 0, 1, 2, 10, 20 }, cb
037:                        .getApplicationData()));
038:            }
039:
040:            public void testGetApplicationData_0() throws Exception {
041:                byte data[] = { 0, 10, 20, 40, 50 };
042:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
043:                        0, 0, 1 });
044:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
045:                        0, 0, 2 });
046:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
047:                assertTrue(Arrays.equals(new byte[] { 0, 10, 20, 40, 50 }, cb
048:                        .getApplicationData()));
049:            }
050:
051:            public void testGetApplicationData_1() {
052:                ChannelBinding cb = new ChannelBinding(null);
053:                assertNull(cb.getApplicationData());
054:            }
055:
056:            public void testGetInitiatorAddress() throws Exception {
057:                InetAddress addr = InetAddress.getByAddress(new byte[] { 127,
058:                        0, 0, 1 });
059:                ChannelBinding cb = new ChannelBinding(addr, null, null);
060:                assertEquals(InetAddress
061:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), cb
062:                        .getInitiatorAddress());
063:            }
064:
065:            public void testGetInitiatorAddress_0() throws Exception {
066:                byte data[] = { 0, 10, 20, 40, 50 };
067:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
068:                        0, 0, 1 });
069:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
070:                        0, 0, 2 });
071:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
072:                assertEquals(InetAddress
073:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), cb
074:                        .getInitiatorAddress());
075:            }
076:
077:            public void testGetInitiatorAddress_1() {
078:                ChannelBinding cb = new ChannelBinding(null);
079:                assertNull(cb.getInitiatorAddress());
080:            }
081:
082:            public void testGetAcceptorAddress() throws Exception {
083:                InetAddress addr = InetAddress.getByAddress(new byte[] { 127,
084:                        0, 0, 1 });
085:                ChannelBinding cb = new ChannelBinding(null, addr, null);
086:                assertEquals(InetAddress
087:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), cb
088:                        .getAcceptorAddress());
089:            }
090:
091:            public void testGetAcceptorAddress_0() throws Exception {
092:                byte data[] = { 0, 10, 20, 40, 50 };
093:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
094:                        0, 0, 1 });
095:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
096:                        0, 0, 2 });
097:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
098:                assertEquals(InetAddress
099:                        .getByAddress(new byte[] { 127, 0, 0, 2 }), cb
100:                        .getAcceptorAddress());
101:            }
102:
103:            public void testGetAcceptorAddress_1() {
104:                ChannelBinding cb = new ChannelBinding(null);
105:                assertNull(cb.getAcceptorAddress());
106:            }
107:
108:            public void testEquals() {
109:                ChannelBinding cb = new ChannelBinding(null);
110:                assertTrue((new ChannelBinding(null, null, null).equals(cb)));
111:            }
112:
113:            public void testEquals_0_0_0() {
114:                ChannelBinding cb = new ChannelBinding(new byte[] { 0, 10, 20,
115:                        40, 50 });
116:                assertTrue(cb.equals(cb));
117:            }
118:
119:            public void testEquals_0() throws Exception {
120:                byte data[] = { 0, 10, 20, 40, 50 };
121:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
122:                        0, 0, 1 });
123:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
124:                        0, 0, 2 });
125:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
126:
127:                assertTrue((new ChannelBinding(InetAddress
128:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), InetAddress
129:                        .getByAddress(new byte[] { 127, 0, 0, 2 }), new byte[] {
130:                        0, 10, 20, 40, 50 })).equals(cb));
131:            }
132:
133:            public void testEquals_0_0() throws Exception {
134:                byte data[] = { 0, 10, 20, 40, 50 };
135:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
136:                        0, 0, 1 });
137:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
138:                        0, 0, 2 });
139:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
140:
141:                assertTrue((new ChannelBinding(addr1, addr2, new byte[] { 0,
142:                        10, 20, 40, 50 })).equals(cb));
143:            }
144:
145:            public void testEquals_1() throws Exception {
146:                byte data[] = { 0, 10, 20, 40, 5 };
147:                ChannelBinding cb = new ChannelBinding(data);
148:                assertTrue((new ChannelBinding(new byte[] { 0, 10, 20, 40, 5 }))
149:                        .equals(cb));
150:            }
151:
152:            public void testEquals_2() throws Exception {
153:                byte data[] = null;
154:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
155:                        0, 0, 1 });
156:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
157:                        0, 0, 2 });
158:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
159:
160:                assertTrue((new ChannelBinding(InetAddress
161:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), InetAddress
162:                        .getByAddress(new byte[] { 127, 0, 0, 2 }), null))
163:                        .equals(cb));
164:            }
165:
166:            public void testEquals_2_0() throws Exception {
167:                byte data[] = null;
168:                InetAddress addr1 = null;
169:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
170:                        0, 0, 2 });
171:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
172:
173:                assertTrue((new ChannelBinding(null, InetAddress
174:                        .getByAddress(new byte[] { 127, 0, 0, 2 }), null))
175:                        .equals(cb));
176:            }
177:
178:            //Negative
179:            public void testEquals_Negative() throws Exception {
180:                byte data[] = { 0, 10, 20 };
181:                ChannelBinding cb = new ChannelBinding(data);
182:                assertTrue(!(new ChannelBinding(null)).equals(cb));
183:            }
184:
185:            public void testEquals_Negative_0() throws Exception {
186:                byte data[] = { 0, 10, 20 };
187:                ChannelBinding cb = new ChannelBinding(null);
188:                assertTrue(!(new ChannelBinding(data)).equals(cb));
189:            }
190:
191:            public void testEquals_Negative_0_0() throws Exception {
192:                byte data[] = { 0, 10, 20 };
193:                ChannelBinding cb = new ChannelBinding(data);
194:                assertTrue(!cb.equals(new Object()));
195:            }
196:
197:            public void testEquals_Negative_1() throws Exception {
198:                byte data[] = { 0, 10, 20 };
199:                ChannelBinding cb = new ChannelBinding(data);
200:                assertTrue(!(new ChannelBinding(
201:                        new byte[] { 0, 10, 20, 30, 40 })).equals(cb));
202:            }
203:
204:            public void testEquals_Negative_2() throws Exception {
205:                byte data[] = { 0, 10, 20 };
206:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
207:                        0, 0, 1 });
208:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
209:                        0, 0, 2 });
210:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
211:                assertTrue(!(new ChannelBinding(new byte[] { 0, 10, 20 }))
212:                        .equals(cb));
213:            }
214:
215:            public void testEquals_Negative_3() throws Exception {
216:                byte data[] = { 0, 10, 20, 30 };
217:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
218:                        0, 0, 1 });
219:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
220:                        0, 0, 2 });
221:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
222:                assertTrue(!(new ChannelBinding(addr1, addr2, new byte[] { 0,
223:                        10, 20 })).equals(cb));
224:            }
225:
226:            public void testEquals_Negative_3_0() throws Exception {
227:                byte data[] = { 0, 10, 20, 30 };
228:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
229:                        0, 0, 1 });
230:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
231:                        0, 0, 2 });
232:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
233:                assertTrue(!(new ChannelBinding(InetAddress
234:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), InetAddress
235:                        .getByAddress(new byte[] { 127, 0, 0, 2 }), new byte[] {
236:                        0, 10, 20 })).equals(cb));
237:            }
238:
239:            public void testEquals_Negative_4() throws Exception {
240:                byte data[] = { 0, 10, 20 };
241:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
242:                        0, 0, 1 });
243:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
244:                        0, 0, 2 });
245:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
246:                assertTrue(!(new ChannelBinding(InetAddress
247:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), InetAddress
248:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), new byte[] {
249:                        0, 10, 20 })).equals(cb));
250:            }
251:
252:            public void testEquals_Negative_5() throws Exception {
253:                byte data[] = { 0, 10, 20 };
254:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
255:                        0, 0, 2 });
256:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
257:                        0, 0, 1 });
258:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
259:                assertTrue(!(new ChannelBinding(InetAddress
260:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), InetAddress
261:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), new byte[] {
262:                        0, 10, 20 })).equals(cb));
263:            }
264:
265:            public void testEquals_Negative_6() throws Exception {
266:                byte data[] = { 0, 10, 20 };
267:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
268:                        0, 0, 2 });
269:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
270:                        0, 0, 1 });
271:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
272:                assertTrue(!(new ChannelBinding(null, InetAddress
273:                        .getByAddress(new byte[] { 127, 0, 0, 1 }), new byte[] {
274:                        0, 10, 20 })).equals(cb));
275:            }
276:
277:            public void testHashCode() throws Exception {
278:                byte data[] = { 0, 10, 20, 40, 50 };
279:                InetAddress addr1 = InetAddress.getByAddress(new byte[] { 127,
280:                        0, 0, 1 });
281:                InetAddress addr2 = InetAddress.getByAddress(new byte[] { 127,
282:                        0, 0, 2 });
283:                ChannelBinding cb = new ChannelBinding(addr1, addr2, data);
284:                assertEquals(addr1.hashCode(), cb.hashCode());
285:            }
286:
287:            public void testHashCode_0() throws Exception {
288:                byte data[] = { 0, 10, 20, 40, 50 };
289:                InetAddress addr = InetAddress.getByAddress(new byte[] { 127,
290:                        0, 0, 1 });
291:                ChannelBinding cb = new ChannelBinding(null, addr, data);
292:                assertEquals(addr.hashCode(), cb.hashCode());
293:            }
294:
295:            public void testHashCode_1() throws Exception {
296:                byte data[] = { 1, 2 };
297:                ChannelBinding cb = new ChannelBinding(null, null, data);
298:                assertEquals(33, cb.hashCode());
299:            }
300:
301:            public void testHashCode_2() throws Exception {
302:                byte data[] = { 10, 2 };
303:                ChannelBinding cb = new ChannelBinding(null, null, data);
304:                assertEquals(312, cb.hashCode());
305:            }
306:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.