db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Bouschen <mbo.t...@spree.de>
Subject Re: error message handling for tck20's JDO_Test.java
Date Sat, 18 Feb 2006 21:03:55 GMT
Hi Martin,

thanks for the code! I added the same changes to the AbstractTest class 
in api20.

Regards Michael

>
> Michael, Craig,
> here are my extensions to tck20's JDO_Test.java for the error message
> handling.  They're independent from the ThreadSafe fixes I'm working
> on, so, I'll better file a separate, minor JIRA task to check them in.
>
> Martin
>
> $ svn diff src/java/org/apache/jdo/tck/JDO_Test.java
> Index: src/java/org/apache/jdo/tck/JDO_Test.java
> ===================================================================
> --- src/java/org/apache/jdo/tck/JDO_Test.java   (revision 375502)
> +++ src/java/org/apache/jdo/tck/JDO_Test.java   (working copy)
> @@ -128,6 +128,10 @@
>      /** identitytype value for datastoreidentity. */
>      public static final String DATASTORE_IDENTITY = "datastoreidentity";
>
> +    /** New line.
> +     */
> +    public static final String NL = 
> System.getProperty("line.separator");
> +
>      /**
>       * String indicating the type of identity used for the current 
> test case.
>       * The value is either "applicationidentity" or "datastoreidentity".
> @@ -147,6 +151,10 @@
>      /** The Properties object for the PersistenceManagerFactory. */
>      protected static Properties PMFPropertiesObject;
>
> +    /** A buffer of of error messages.
> +     */
> +    protected static StringBuffer messages;
> +
>      /** The PersistenceManagerFactory. */
>      protected PersistenceManagerFactory pmf;
>
> @@ -537,13 +545,36 @@
>          return props;
>      }
>
> +    /** Appends to error messages.
> +     */
> +    protected static synchronized void appendMessage(String message) {
> +        if (messages == null) {
> +            messages = new StringBuffer();
> +        }
> +        messages.append(message);
> +        messages.append(NL);
> +    }
> +
> +    /**
> +     * Returns collected error messages, or <code>null</code> if there
> +     * are none, and clears the buffer.
> +     */
> +    protected static synchronized String popMessages() {
> +        if (messages == null) {
> +            return null;
> +        }
> +        final String msg = messages.toString();
> +        messages = null;
> +        return msg;
> +    }
> +
>      /**
>       * Prints the specified msg (if debug is true), before it aborts the
>       * test case.
>       */
>      public void fail(String assertionFailure, String msg) {
>          if (debug) logger.debug(msg);
> -        fail(assertionFailure + "\n" + msg);
> +        fail(assertionFailure + NL + msg);
>      }
>
>      // Helper methods to check for supported options



-- 
Michael Bouschen		Tech@Spree Engineering GmbH
mailto:mbo.tech@spree.de	http://www.tech.spree.de/
Tel.:++49/30/235 520-33		Buelowstr. 66			
Fax.:++49/30/2175 2012		D-10783 Berlin			


Mime
View raw message