Issue Details (XML | Word | Printable)

Key: JDO-309
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Trivial Trivial
Assignee: Martin Zaun
Reporter: Martin Zaun
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
JDO

minor extensions to tck20 test utilities

Created: 18/Feb/06 02:49 AM   Updated: 17/Mar/06 04:04 AM
Return to search
Component/s: tck2
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Java Source File Licensed for inclusion in ASF works RogueBarrier.java 2006-03-04 01:57 AM Martin Zaun 5 kB

Resolution Date: 08/Mar/06 07:14 AM


 Description  « Hide
JDO_Test should be extended for methods collection error messages.
ThreadExceptionHandler should be extended for clearing stored exceptions.

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Zaun added a comment - 18/Feb/06 02:50 AM
My planned extensions to tck20's ThreadExceptionHandler:

$ svn diff src/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java
Index: src/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java
===================================================================
--- src/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java (revisio
n 375502)
+++ src/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java (working
 copy)
@@ -32,7 +32,7 @@
      * Map of uncaught exceptions. The thread is the key and the uncaught
      * Throwable is the value in the map.
      */
- private Map uncaughtExceptions = new HashMap();
+ private final Map uncaughtExceptions = new HashMap();

     /** Constructor. */
     public ThreadExceptionHandler() {
@@ -53,11 +53,18 @@
     }

     /**
- * Returns all uncaught exception stored in this ThreadGroup.
+ * Returns all uncaught exceptions stored in this ThreadGroup.
      * Each element in the returned set is a Map.Entry with the
      * thread as the key and the uncaught Throwable is the value.
      */
     public Set getAllUncaughtExceptions() {
         return uncaughtExceptions.entrySet();
     }
+
+ /**
+ * Clears all exceptions in this ThreadGroup.
+ */
+ public void clear() {
+ uncaughtExceptions.clear();
+ }
 }

Martin Zaun added a comment - 18/Feb/06 02:52 AM
The planned extensions to tck20's JDO_Test (based on Craig's suggestion):

$ 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

Craig Russell added a comment - 19/Feb/06 06:16 AM
Looks good. Just a comment.

1. Please change name of popMessages to something else. Pop has a specific meaning (remove the top element of a Stack) and I don't think it's appropriate for a Message pad.

How about:

String retrieveMessages() that has the same semantics as your popMessages.


Martin Zaun made changes - 25/Feb/06 10:10 AM
Field Original Value New Value
Assignee Martin Zaun [ mzaun ]
Martin Zaun added a comment - 04/Mar/06 01:55 AM
> How about:
> String retrieveMessages() that has the same semantics as your popMessages.

OK.

Martin Zaun added a comment - 04/Mar/06 01:57 AM
For thread-safety testing, a simple barrier synchronization utility is needed.

Martin Zaun made changes - 04/Mar/06 01:57 AM
Attachment RogueBarrier.java [ 12323683 ]
Repository Revision Date User Message
ASF #384047 Tue Mar 07 23:05:53 UTC 2006 mzaun JDO-309: minor extensions to tck20 test utilities
Files Changed
ADD /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/RogueBarrier.java
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/ThreadExceptionHandler.java

Michael Bouschen added a comment - 08/Mar/06 06:40 AM
Hi Martin,

the ThreadExceptionHandler changes look good.

I looked at the RougueBarriere class. It's small, but still takes some time to understand (at least for me :-)). Maybe you can add some comments motivating why we need a holder for the boolean tripped. I think this allows other threads to see that the barrier is tripped, but the current thread can prepare the value for the next run. Maybe you can also rearrange the code in the await method executed when the barrier is reset. I think
    tripped[0] = true;
    lock.notifyAll();
is needed to wake up the other threads, where
    missing = parties;
    tripped = new boolean[1]; // new generation
is used to initialized the next run.

Am I right?

Michael

Martin Zaun made changes - 08/Mar/06 07:05 AM
Summary minor extensions to tck20's JDO_Test and ThreadExceptionHandler minor extensions to tck20 test utilities
Martin Zaun added a comment - 08/Mar/06 07:12 AM
Followed Michael's comments on new class RougueBarrier.
Added extension to ThreadExceptionHandler and new RougueBarrier with revision 384047.
(Additions to JDO_Test had been checked in already on another JIRA issue.)

Martin Zaun made changes - 08/Mar/06 07:14 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Repository Revision Date User Message
ASF #386446 Thu Mar 16 20:02:56 UTC 2006 mzaun JDO-309 removed executable property from new file RogueBarrier.java
Files Changed
MODIFY /db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/util/RogueBarrier.java

Martin Zaun added a comment - 17/Mar/06 04:04 AM
Removed executable property from new file RogueBarrier.java with revision 386446.