I'm thinking about using ByteArrayOutputStream and serializing 2 special object with readObject() implemented to throw the exception I want to test.
On Mon, Apr 11, 2011 at 5:30 PM, <[email protected]> wrote: > > http://gwt-code-reviews.appspot.com/1412801/diff/1/dev/core/test/com/google/gwt/dev/javac/PersistentUnitCacheTest.java > File dev/core/test/com/google/gwt/dev/javac/PersistentUnitCacheTest.java > (right): > > http://gwt-code-reviews.appspot.com/1412801/diff/1/dev/core/test/com/google/gwt/dev/javac/PersistentUnitCacheTest.java#newcode41 > dev/core/test/com/google/gwt/dev/javac/PersistentUnitCacheTest.java:41: > private final byte[] INVALID_CACHE_LOG = { // > This seems kinda.... brittle? I wonder if there's a way to generate an > appropriate stream programmatically. > > Maybe something involving a pair of class loaders, A and B, which are > children of the system class loader, but provide one additional class, a > CompilationUnit subtype that isn't loaded in the system class loader. > You write the stream using A and read it back using B. In addition to > testing a class that doesn't exist in B, you could test slightly > different versions of the same class in A & B and test for the > incompatible class change. Not sure if it's worth all that trouble tho, > just rambling here. > > http://gwt-code-reviews.appspot.com/1412801/ > -- Eric Z. Ayers Google Web Toolkit, Atlanta, GA USA -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
