On 05/01/2009, Rahul Akolkar <rahul.akol...@gmail.com> wrote:
> On Sun, Jan 4, 2009 at 6:36 PM,  <s...@apache.org> wrote:
>  > Author: sebb
>  > Date: Sun Jan  4 15:36:29 2009
>  > New Revision: 731387
>  >
>  > URL: http://svn.apache.org/viewvc?rev=731387&view=rev
>  > Log:
>  > Remove try/catch blocks for Exceptions that are not expected in testing
>  >
>  > Modified:
>  >    
> commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/SCXMLTestHelper.java
>  >
>  <snip/>
>
>  The two changes below to treat NSEs as test errors are probably OK,
>  given that most JDKs 1.6 and above seem to use a sensible DOM
>  implementation (and general XML support). The same doesn't hold for
>  this class in trunk, however.
>

I have just committed the trunk version; it will throw NSE if the
failing class does not start with: "org.apache.crimson.tree.". That
should catch any other non-serialisable fields.
Hope that's OK.

>  -Rahul
>
>
>
>  >
>  > -    public static SCXML testModelSerializability(final SCXML scxml) {
>  > +    public static SCXML testModelSerializability(final SCXML scxml) 
> throws Exception {
>  >         File fileDir = new File(SERIALIZATION_DIR);
>  >         if (!fileDir.exists() && !fileDir.mkdir()) {
>  >             System.err.println("SKIPPED SERIALIZATION: Failed directory 
> creation");
>  > @@ -293,29 +259,18 @@
>  >         String filename = SERIALIZATION_FILE_PREFIX
>  >             + getSequenceNumber() + SERIALIZATION_FILE_SUFFIX;
>  >         SCXML roundtrip = null;
>  > -        try {
>  > -            ObjectOutputStream out =
>  > -                new ObjectOutputStream(new FileOutputStream(filename));
>  > -            out.writeObject(scxml);
>  > -            out.close();
>  > -            ObjectInputStream in =
>  > -                new ObjectInputStream(new FileInputStream(filename));
>  > -            roundtrip = (SCXML) in.readObject();
>  > -            in.close();
>  > -        } catch (NotSerializableException nse) {
>  > -            // <data> nodes failed serialization
>  > -            System.err.println("SERIALIZATION ERROR: The DOM 
> implementation"
>  > -                + " in use is not serializable");
>  > -            return scxml;
>  > -        } catch(IOException ex) {
>  > -            throw new RuntimeException(ex);
>  > -        } catch(ClassNotFoundException ex) {
>  > -            throw new RuntimeException(ex);
>  > -        }
>  > +        ObjectOutputStream out =
>  > +            new ObjectOutputStream(new FileOutputStream(filename));
>  > +        out.writeObject(scxml);
>  > +        out.close();
>  > +        ObjectInputStream in =
>  > +            new ObjectInputStream(new FileInputStream(filename));
>  > +        roundtrip = (SCXML) in.readObject();
>  > +        in.close();
>  >         return roundtrip;
>  >     }
>  >
>  > -    public static SCXMLExecutor testExecutorSerializability(final 
> SCXMLExecutor exec) {
>  > +    public static SCXMLExecutor testExecutorSerializability(final 
> SCXMLExecutor exec) throws Exception {
>  >         File fileDir = new File(SERIALIZATION_DIR);
>  >         if (!fileDir.exists() && !fileDir.mkdir()) {
>  >             System.err.println("SKIPPED SERIALIZATION: Failed directory 
> creation");
>  > @@ -324,26 +279,14 @@
>  >         String filename = SERIALIZATION_FILE_PREFIX
>  >             + getSequenceNumber() + SERIALIZATION_FILE_SUFFIX;
>  >         SCXMLExecutor roundtrip = null;
>  > -        try {
>  > -            ObjectOutputStream out =
>  > -                new ObjectOutputStream(new FileOutputStream(filename));
>  > -            out.writeObject(exec);
>  > -            out.close();
>  > -            ObjectInputStream in =
>  > -                new ObjectInputStream(new FileInputStream(filename));
>  > -            roundtrip = (SCXMLExecutor) in.readObject();
>  > -            in.close();
>  > -        } catch (NotSerializableException nse) {
>  > -            // <data> nodes failed serialization, test cases do not add
>  > -            // other non-serializable context data
>  > -            System.err.println("SERIALIZATION ERROR: The DOM 
> implementation"
>  > -                + " in use is not serializable");
>  > -            return exec;
>  > -        } catch(IOException ex) {
>  > -            throw new RuntimeException(ex);
>  > -        } catch(ClassNotFoundException ex) {
>  > -            throw new RuntimeException(ex);
>  > -        }
>  > +        ObjectOutputStream out =
>  > +            new ObjectOutputStream(new FileOutputStream(filename));
>  > +        out.writeObject(exec);
>  > +        out.close();
>  > +        ObjectInputStream in =
>  > +            new ObjectInputStream(new FileInputStream(filename));
>  > +        roundtrip = (SCXMLExecutor) in.readObject();
>  > +        in.close();
>  >         return roundtrip;
>  >     }
>  >
>  > @@ -355,4 +298,3 @@
>  >     }
>  >
>  >  }
>  > -
>  >
>  >
>  >
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
>  For additional commands, e-mail: dev-h...@commons.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to