Java Doc for SerializationTest.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » testframework » serialization » 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.apache.harmony.testframework.serialization 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


org.apache.harmony.testframework.serialization.SerializationTest

All known Subclasses:   org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.TimestampTest,  org.apache.harmony.security.tests.java.security.serialization.InvalidParameterExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.CredentialExpiredExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.KeyExceptionTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CertificateNotYetValidExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.NoSuchProviderExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.PasswordCallbackTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CRLExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.serialization.DestroyFailedExceptionTest,  org.apache.harmony.crypto.tests.javax.crypto.serialization.IllegalBlockSizeExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.DelegationPermissionTest,  org.apache.harmony.auth.tests.javax.security.sasl.serialization.RealmChoiceCallbackTest,  org.apache.harmony.security.tests.java.security.serialization.SignatureExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.PrivilegedActionExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.AccountExceptionTest,  org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateEncodingExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.KeyManagementExceptionTest,  org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.BasicPermissionCollectionTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.AccountExpiredExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.AllPermissionTest,  org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLSessionBindingEventTest,  org.apache.harmony.security.tests.java.security.serialization.GuardedObjectTest,  org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbDelegationPermissionCollectionTest,  org.apache.harmony.security.tests.java.security.serialization.UnrecoverableEntryExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.LoginExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.ChoiceCallbackTest,  org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.TextInputCallbackTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CertificateExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.ConfirmationCallbackTest,  org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateExpiredExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.PermissionsTest,  org.apache.harmony.security.tests.java.security.serialization.GeneralSecurityExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.CodeSignerTest,  org.apache.harmony.auth.tests.javax.security.auth.serialization.SubjectTest,  org.apache.harmony.security.tests.java.security.serialization.AccessControlExceptionTest,  org.apache.harmony.xnet.tests.javax.net.ssl.serialization.HandshakeCompletedEventTest,  org.apache.harmony.security.tests.java.security.serialization.SecurityPermissionTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CertificateEncodingExceptionTest,  org.apache.harmony.crypto.tests.javax.crypto.serialization.BadPaddingExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.KeyStoreExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.PermissionCollectionTest,  org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateParsingExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.serialization.AuthPermissionTest,  org.apache.harmony.auth.tests.javax.security.sasl.serialization.RealmCallbackTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CertificateExpiredExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.BasicPermissionTest,  org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.KrbServicePermissionCollectionTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CertPathBuilderExceptionTest,  org.apache.harmony.auth.tests.javax.security.sasl.serialization.SaslExceptionTest,  org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLPeerUnverifiedExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.FailedLoginExceptionTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CertPathValidatorExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.DigestExceptionTest,  org.apache.harmony.security.tests.java.security.spec.serialization.InvalidKeySpecExceptionTest,  org.apache.harmony.security.tests.javax.security.cert.serialization.CertificateNotYetValidExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.UnresolvedPermissionTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.CredentialExceptionTest,  org.apache.harmony.crypto.tests.javax.crypto.serialization.ExemptionMechanismExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.UnrecoverableKeyExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.UnresolvedPermissionCollectionTest,  org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLProtocolExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.NameCallbackTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CertificateParsingExceptionTest,  org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLHandshakeExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.SignedObjectTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.AccountLockedExceptionTest,  org.apache.harmony.security.tests.java.security.cert.serialization.CertStoreExceptionTest,  org.apache.harmony.security.tests.java.security.spec.serialization.InvalidParameterSpecExceptionTest,  org.apache.harmony.crypto.tests.javax.crypto.serialization.ShortBufferExceptionTest,  org.apache.harmony.xnet.tests.javax.net.ssl.serialization.SSLKeyExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.kerberos.serialization.ServicePermissionTest,  org.apache.harmony.security.tests.java.security.serialization.AllPermissionCollectionTest,  org.apache.harmony.auth.tests.javax.security.auth.serialization.PrivateCredentialPermissionTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.CredentialNotFoundExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.NoSuchAlgorithmExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.LanguageCallbackTest,  org.apache.harmony.security.tests.java.security.serialization.InvalidAlgorithmParameterExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.TextOutputCallbackTest,  org.apache.harmony.security.tests.java.security.serialization.PermissionTest,  org.apache.harmony.auth.tests.javax.security.sasl.serialization.AuthorizeCallbackTest,  org.apache.harmony.auth.tests.javax.security.auth.login.serialization.AccountNotFoundExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.callback.serialization.UnsupportedCallbackExceptionTest,  org.apache.harmony.crypto.tests.javax.crypto.serialization.NoSuchPaddingExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.ProviderExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.CodeSourceTest,  org.apache.harmony.auth.tests.javax.security.auth.x500.serialization.X500PrincipalTest,  org.apache.harmony.auth.tests.javax.security.sasl.serialization.AuthenticationExceptionTest,  org.apache.harmony.security.tests.java.security.serialization.InvalidKeyExceptionTest,  org.apache.harmony.auth.tests.javax.security.auth.serialization.RefreshFailedExceptionTest,
SerializationTest
abstract public class SerializationTest extends TestCase (Code)
Framework for serialization testing. Subclasses only need to override getData() method and, optionally, assertDeserialized() method. The first one returns array of objects to be de/serialized in tests, and the second compares reference and deserialized objects (needed only if tested objects do not provide specific method equals()).
There are two modes of test run: reference generation mode and testing mode . The actual mode is selected via "test.mode" system property. The testing mode is the default mode.
To turn on the reference generation mode , the test.mode property should be set to value "serial.reference". In this mode, no testing is performed but golden files are produced, which contain reference serialized objects. This mode should be run on a pure Implementation classes, which are targeted for compartibility.
The location of golden files (in both modes) is controlled via "RESOURCE_DIR" system property.

Inner Class :public interface SerializableAssert

Field Summary
final public static  StringGOLDEN_PATH
     Key to a system property defining root location of golden files.
final public static  StringMODE_KEY
     Property name for the testing mode.
final public static  SerializableAssertPERMISSION_COLLECTION_COMPARATOR
    
final public static  SerializableAssertSAME_COMPARATOR
     Comparator for verifying that deserialized object is the same as initial.
final public static  StringSERIAL_REFERENCE_MODE
     Reference files generation mode switch.
final public static  SerializableAssertTHROWABLE_COMPARATOR
    
public static  Stringmode
     Testing mode.

Constructor Summary
public  SerializationTest(String name)
     Parameterized c-tor inherited from superclass.
public  SerializationTest()
     Default c-tor inherited from superclass.

Method Summary
public static  SerializablecopySerializable(Serializable initial)
     Copies an object by serializing/deserializing it.
public static  voidcreateGoldenFile(String root, TestCase test, Object object)
     Creates golden file.
public static  SerializableAssertdefineComparator(TestCase test, Object object)
     Returns comparator for provided serializable object.
abstract protected  Object[]getData()
     This is the main working method of this framework.
protected  FilegetDataFile(int index)
     Returns golden file for an object being tested.
public static  SerializablegetObjectFromStream(InputStream is)
     Deserializes single object from an input stream.
protected  voidproduceGoldenFiles()
     Working method for files generation mode.
public static  voidputObjectToStream(Object obj, OutputStream os)
     Serializes specified object to an output stream.
public  voidrunBare()
     Depending on testing mode, produces golden files or performs testing.
public  voidtestGolden()
     Tests that data objects can be deserialized from golden files, to verify compartibility with Reference Implementation.
public  voidtestSelf()
     Tests that data objects can be serialized and deserialized without exceptions, and that deserialization really produces deeply cloned objects.
public static  voidverifyGolden(TestCase test, Object object)
     Verifies that object deserialized from golden file correctly.
public static  voidverifyGolden(TestCase test, Object object, SerializableAssert comparator)
     Verifies that object deserialized from golden file correctly.
public static  voidverifyGolden(TestCase test, Object[] objects)
     Verifies that objects from array deserialized from golden files correctly.
public static  voidverifyGolden(TestCase test, Object[] objects, SerializableAssert comparator)
     Verifies that objects from array deserialized from golden files correctly. The method loads "testName.golden.N.ser" resource files from "/src/test/resources/serialization/testPackage" folder, from each loaded file it reads an object from and compares it with corresponding object in provided array (i.e.
public static  voidverifySelf(Object object)
     Verifies that object can be smoothly serialized/deserialized.
public static  voidverifySelf(Object object, SerializableAssert comparator)
     Verifies that object can be smoothly serialized/deserialized.
public static  voidverifySelf(Object[] objects)
     Verifies that that objects from array can be smoothly serialized/deserialized.
public static  voidverifySelf(Object[] objects, SerializableAssert comparator)
     Verifies that that objects from array can be smoothly serialized/deserialized.

Field Detail
GOLDEN_PATH
final public static String GOLDEN_PATH(Code)
Key to a system property defining root location of golden files.



MODE_KEY
final public static String MODE_KEY(Code)
Property name for the testing mode.



PERMISSION_COLLECTION_COMPARATOR
final public static SerializableAssert PERMISSION_COLLECTION_COMPARATOR(Code)
Comparator for java.security.PermissionCollection objects



SAME_COMPARATOR
final public static SerializableAssert SAME_COMPARATOR(Code)
Comparator for verifying that deserialized object is the same as initial.



SERIAL_REFERENCE_MODE
final public static String SERIAL_REFERENCE_MODE(Code)
Reference files generation mode switch.



THROWABLE_COMPARATOR
final public static SerializableAssert THROWABLE_COMPARATOR(Code)
Comparator for java.lang.Throwable objects



mode
public static String mode(Code)
Testing mode.




Constructor Detail
SerializationTest
public SerializationTest(String name)(Code)
Parameterized c-tor inherited from superclass.



SerializationTest
public SerializationTest()(Code)
Default c-tor inherited from superclass.




Method Detail
copySerializable
public static Serializable copySerializable(Serializable initial) throws IOException, ClassNotFoundException(Code)
Copies an object by serializing/deserializing it.
Parameters:
  initial - -an object to be copied copy of provided object



createGoldenFile
public static void createGoldenFile(String root, TestCase test, Object object) throws IOException(Code)
Creates golden file. The folder for created file is: root + test's package name. The file name is: test's name + "golden.ser"
Parameters:
  root - -root directory for serialization resource files
Parameters:
  test - -test case
Parameters:
  object - -object to be serialized
throws:
  IOException - -if I/O error



defineComparator
public static SerializableAssert defineComparator(TestCase test, Object object) throws Exception(Code)
Returns comparator for provided serializable object. The comparator is searched in the following order:
- if test implements SerializableAssert interface then it is selected as comparator.
- if passed object has class in its classes hierarchy that overrides equals(Object) method then DEFAULT_COMPARATOR is selected.
- the method tries to select one of known comparators basing on object's class,for example, if passed object is instance of java.lang.Throwable then THROWABLE_COMPARATOR is used.
- otherwise RuntimeException is thrown
Parameters:
  test - -test case
Parameters:
  object - -object to be compared object's comparator



getData
abstract protected Object[] getData()(Code)
This is the main working method of this framework. Subclasses must override it to provide actual objects for testing. array of objects to be de/serialized in tests.



getDataFile
protected File getDataFile(int index)(Code)
Returns golden file for an object being tested.
Parameters:
  index - array index of tested data (as returned bySerializationTest.getData() getData()) corresponding golden file



getObjectFromStream
public static Serializable getObjectFromStream(InputStream is) throws IOException, ClassNotFoundException(Code)
Deserializes single object from an input stream.



produceGoldenFiles
protected void produceGoldenFiles() throws IOException(Code)
Working method for files generation mode. Serializes test objects returned by SerializationTest.getData() getData() to golden files, each object to a separate file.
throws:
  IOException -



putObjectToStream
public static void putObjectToStream(Object obj, OutputStream os) throws IOException(Code)
Serializes specified object to an output stream.



runBare
public void runBare() throws Throwable(Code)
Depending on testing mode, produces golden files or performs testing.



testGolden
public void testGolden() throws Throwable(Code)
Tests that data objects can be deserialized from golden files, to verify compartibility with Reference Implementation.



testSelf
public void testSelf() throws Throwable(Code)
Tests that data objects can be serialized and deserialized without exceptions, and that deserialization really produces deeply cloned objects.



verifyGolden
public static void verifyGolden(TestCase test, Object object) throws Exception(Code)
Verifies that object deserialized from golden file correctly. The method invokes
verifyGolden(test, object, defineComparator(test, object));
Parameters:
  test - -test case
Parameters:
  object - -to be compared



verifyGolden
public static void verifyGolden(TestCase test, Object object, SerializableAssert comparator) throws Exception(Code)
Verifies that object deserialized from golden file correctly. The method loads "testName.golden.ser" resource file from "/src/test/resources/serialization/testPackage" folder, reads an object from the loaded file and compares it with object using specified comparator. test-test case object-to be compared
Parameters:
  comparator - -for comparing (de)serialized objects



verifyGolden
public static void verifyGolden(TestCase test, Object[] objects) throws Exception(Code)
Verifies that objects from array deserialized from golden files correctly. The method invokes
verifyGolden(test, objects, defineComparator(test, object[0]));
Parameters:
  test - -test case
Parameters:
  objects - -array of objects to be compared



verifyGolden
public static void verifyGolden(TestCase test, Object[] objects, SerializableAssert comparator) throws Exception(Code)
Verifies that objects from array deserialized from golden files correctly. The method loads "testName.golden.N.ser" resource files from "/src/test/resources/serialization/testPackage" folder, from each loaded file it reads an object from and compares it with corresponding object in provided array (i.e. objects[N]) using specified comparator. (N is index in object's array.) test-test case
Parameters:
  objects - -array of objects to be compared
Parameters:
  comparator - -for comparing (de)serialized objects



verifySelf
public static void verifySelf(Object object) throws Exception(Code)
Verifies that object can be smoothly serialized/deserialized. The method invokes
verifySelf(object, defineComparator(null, object));
Parameters:
  object - -to be serialized/deserialized



verifySelf
public static void verifySelf(Object object, SerializableAssert comparator) throws Exception(Code)
Verifies that object can be smoothly serialized/deserialized. The method serialize/deserialize object and compare it with initial object.
Parameters:
  object - -object to be serialized/deserialized
Parameters:
  comparator - -for comparing serialized/deserialized object with initialobject



verifySelf
public static void verifySelf(Object[] objects) throws Exception(Code)
Verifies that that objects from array can be smoothly serialized/deserialized. The method invokes
verifySelf(objects, defineComparator(null, object[0]));
Parameters:
  objects - -array of objects to be serialized/deserialized



verifySelf
public static void verifySelf(Object[] objects, SerializableAssert comparator) throws Exception(Code)
Verifies that that objects from array can be smoothly serialized/deserialized. The method serialize/deserialize each object in objects array and compare it with initial object.
Parameters:
  objects - -array of objects to be serialized/deserialized
Parameters:
  comparator - -for comparing serialized/deserialized object with initialobject



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.