Source Code Cross Referenced for EqualsAndHashCodeTest.java in  » Security » Bouncy-Castle » org » bouncycastle » asn1 » test » 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 » Security » Bouncy Castle » org.bouncycastle.asn1.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.bouncycastle.asn1.test;
002:
003:        import org.bouncycastle.asn1.ASN1InputStream;
004:        import org.bouncycastle.asn1.ASN1OutputStream;
005:        import org.bouncycastle.asn1.BERConstructedOctetString;
006:        import org.bouncycastle.asn1.BERSequence;
007:        import org.bouncycastle.asn1.BERSet;
008:        import org.bouncycastle.asn1.BERTaggedObject;
009:        import org.bouncycastle.asn1.DERApplicationSpecific;
010:        import org.bouncycastle.asn1.DERBMPString;
011:        import org.bouncycastle.asn1.DERBitString;
012:        import org.bouncycastle.asn1.DERBoolean;
013:        import org.bouncycastle.asn1.DEREnumerated;
014:        import org.bouncycastle.asn1.DERGeneralString;
015:        import org.bouncycastle.asn1.DERGeneralizedTime;
016:        import org.bouncycastle.asn1.DERIA5String;
017:        import org.bouncycastle.asn1.DERInteger;
018:        import org.bouncycastle.asn1.DERNull;
019:        import org.bouncycastle.asn1.DERNumericString;
020:        import org.bouncycastle.asn1.DERObject;
021:        import org.bouncycastle.asn1.DERObjectIdentifier;
022:        import org.bouncycastle.asn1.DEROctetString;
023:        import org.bouncycastle.asn1.DERPrintableString;
024:        import org.bouncycastle.asn1.DERSequence;
025:        import org.bouncycastle.asn1.DERSet;
026:        import org.bouncycastle.asn1.DERT61String;
027:        import org.bouncycastle.asn1.DERTaggedObject;
028:        import org.bouncycastle.asn1.DERTags;
029:        import org.bouncycastle.asn1.DERUTCTime;
030:        import org.bouncycastle.asn1.DERUTF8String;
031:        import org.bouncycastle.asn1.DERUniversalString;
032:        import org.bouncycastle.asn1.DERUnknownTag;
033:        import org.bouncycastle.asn1.DERVisibleString;
034:        import org.bouncycastle.util.test.SimpleTestResult;
035:        import org.bouncycastle.util.test.Test;
036:        import org.bouncycastle.util.test.TestResult;
037:
038:        import java.io.ByteArrayInputStream;
039:        import java.io.ByteArrayOutputStream;
040:        import java.util.Date;
041:
042:        public class EqualsAndHashCodeTest implements  Test {
043:            public TestResult perform() {
044:                byte[] data = { 0, 1, 0, 1, 0, 0, 1 };
045:
046:                DERObject values[] = {
047:                        new BERConstructedOctetString(data),
048:                        new BERSequence(new DERPrintableString("hello world")),
049:                        new BERSet(new DERPrintableString("hello world")),
050:                        new BERTaggedObject(0, new DERPrintableString(
051:                                "hello world")),
052:                        new DERApplicationSpecific(0, data),
053:                        new DERBitString(data),
054:                        new DERBMPString("hello world"),
055:                        new DERBoolean(true),
056:                        new DERBoolean(false),
057:                        new DEREnumerated(100),
058:                        new DERGeneralizedTime("20070315173729Z"),
059:                        new DERGeneralString("hello world"),
060:                        new DERIA5String("hello"),
061:                        new DERInteger(1000),
062:                        new DERNull(),
063:                        new DERNumericString("123456"),
064:                        new DERObjectIdentifier("1.1.1.10000.1"),
065:                        new DEROctetString(data),
066:                        new DERPrintableString("hello world"),
067:                        new DERSequence(new DERPrintableString("hello world")),
068:                        new DERSet(new DERPrintableString("hello world")),
069:                        new DERT61String("hello world"),
070:                        new DERTaggedObject(0, new DERPrintableString(
071:                                "hello world")),
072:                        new DERUniversalString(data),
073:                        new DERUnknownTag(
074:                                0xff & (~(DERTags.TAGGED | DERTags.APPLICATION)),
075:                                data), new DERUTCTime(new Date()),
076:                        new DERUTF8String("hello world"),
077:                        new DERVisibleString("hello world") };
078:
079:                try {
080:                    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
081:                    ASN1OutputStream aOut = new ASN1OutputStream(bOut);
082:
083:                    for (int i = 0; i != values.length; i++) {
084:                        aOut.writeObject(values[i]);
085:                    }
086:
087:                    DERObject[] readValues = new DERObject[values.length];
088:
089:                    ByteArrayInputStream bIn = new ByteArrayInputStream(bOut
090:                            .toByteArray());
091:                    ASN1InputStream aIn = new ASN1InputStream(bIn);
092:
093:                    for (int i = 0; i != values.length; i++) {
094:                        DERObject o = aIn.readObject();
095:                        if (!o.equals(values[i])) {
096:                            return new SimpleTestResult(false, getName()
097:                                    + ": Failed equality test for " + o);
098:                        }
099:
100:                        if (o.hashCode() != values[i].hashCode()) {
101:                            return new SimpleTestResult(false, getName()
102:                                    + ": Failed hashCode test for " + o);
103:                        }
104:                    }
105:                } catch (Exception e) {
106:                    return new SimpleTestResult(false, getName()
107:                            + ": Failed - exception " + e.toString(), e);
108:                }
109:
110:                return new SimpleTestResult(true, getName() + ": Okay");
111:            }
112:
113:            public String getName() {
114:                return "EqualsAndHashCode";
115:            }
116:
117:            public static void main(String[] args) {
118:                EqualsAndHashCodeTest test = new EqualsAndHashCodeTest();
119:                TestResult result = test.perform();
120:
121:                System.out.println(result);
122:            }
123:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.