openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r627979 [2/39] - in /openjpa/trunk: openjpa-lib/src/test/java/org/apache/openjpa/lib/test/ openjpa-persistence-jdbc/ openjpa-persistence-jdbc/src/test/java/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ openjpa-pers...
Date Fri, 15 Feb 2008 09:20:40 GMT

Modified: openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java?rev=627979&r1=627978&r2=627979&view=diff
==============================================================================
--- openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java (original)
+++ openjpa/trunk/openjpa-lib/src/test/java/org/apache/openjpa/lib/test/AbstractTestCase.java Fri Feb 15 01:19:55 2008
@@ -95,9 +95,6 @@
     private static final Localizer _loc =
         Localizer.forPackage(AbstractTestCase.class);
 
-    protected String multiThreadExecuting = null;
-    protected boolean inTimeoutThread = false;
-
     private Log log = null;
 
     private static Map _times = new HashMap();
@@ -454,410 +451,6 @@
         return bean;
     }
 
-    ///////////////////
-    // Multi threading
-    ///////////////////
-
-    /**
-     * Re-execute the invoking method a random number of times
-     * in a random number of Threads.
-     */
-    public void mttest() throws ThreadingException {
-        // 6 iterations in 8 threads is a good trade-off between
-        // tests taking way too long and having a decent chance of
-        // identifying MT problems.
-        int iterations = 6;
-        int threads = 8;
-
-        mttest(threads, iterations);
-    }
-
-    /**
-     * Execute the calling method <code>iterations</code>
-     * times in <code>threads</code> Threads.
-     */
-    public void mttest(int threads, int iterations) {
-        mttest(0, threads, iterations);
-    }
-
-    public void mttest(int serialCount, int threads, int iterations)
-        throws ThreadingException {
-        String methodName = callingMethod("mttest");
-        mttest(serialCount, threads, iterations, methodName, new Object [0]);
-    }
-
-    /**
-     * Execute a test method in multiple threads.
-     *
-     * @param threads the number of Threads to run in
-     * @param iterations the number of times the method should
-     * be execute in a single Thread
-     * @param method the name of the method to execute
-     * @param args the arguments to pass to the method
-     * @throws ThreadingException if an errors occur in
-     * any of the Threads. The actual exceptions
-     * will be embedded in the exception. Note that
-     * this means that assert() failures will be
-     * treated as errors rather than warnings.
-     * @author Marc Prud'hommeaux
-     */
-    public void mttest(int threads, int iterations, final String method,
-        final Object [] args) throws ThreadingException {
-        mttest(0, threads, iterations, method, args);
-    }
-
-    public void mttest(int serialCount,
-        int threads, int iterations, final String method, final Object [] args)
-        throws ThreadingException {
-        if (multiThreadExecuting != null && multiThreadExecuting.equals(method))
-        {
-            // we are currently executing in multi-threaded mode:
-            // don't deadlock!
-            return;
-        }
-
-        multiThreadExecuting = method;
-
-        try {
-            Class [] paramClasses = new Class [args.length];
-            for (int i = 0; i < paramClasses.length; i++)
-                paramClasses[i] = args[i].getClass();
-
-            final Method meth;
-
-            try {
-                meth = getClass().getMethod(method, paramClasses);
-            } catch (NoSuchMethodException nsme) {
-                throw new ThreadingException(nsme.toString(), nsme);
-            }
-
-            final Object thiz = this;
-
-            mttest("reflection invocation: (" + method + ")",
-                serialCount, threads, iterations, new VolatileRunnable() {
-                public void run() throws Exception {
-                    meth.invoke(thiz, args);
-                }
-            });
-        } finally {
-            multiThreadExecuting = null;
-        }
-    }
-
-    public void mttest(String title, final int threads, final int iterations,
-        final VolatileRunnable runner) throws ThreadingException {
-        mttest(title, 0, threads, iterations, runner);
-    }
-
-    /**
-     * Execute a test method in multiple threads.
-     *
-     * @param title a description of the test, for inclusion in the
-     * error message
-     * @param serialCount the number of times to run the method
-     * serially before spawning threads.
-     * @param threads the number of Threads to run in
-     * @param iterations the number of times the method should
-     * @param runner the VolatileRunnable that will execute
-     * the actual test from within the Thread.
-     * @throws ThreadingException if an errors occur in
-     * any of the Threads. The actual exceptions
-     * will be embedded in the exception. Note that
-     * this means that assert() failures will be
-     * treated as errors rather than warnings.
-     * @author Marc Prud'hommeaux be execute in a single Thread
-     * @author Marc Prud'hommeaux
-     */
-    public void mttest(String title, final int serialCount,
-        final int threads, final int iterations, final VolatileRunnable runner)
-        throws ThreadingException {
-        final List exceptions = Collections.synchronizedList(new LinkedList());
-
-        Thread [] runners = new Thread [threads];
-
-        final long startMillis = System.currentTimeMillis() + 1000;
-
-        for (int i = 1; i <= threads; i++) {
-            final int thisThread = i;
-
-            runners[i - 1] =
-                new Thread(title + " [" + i + " of " + threads + "]") {
-                    public void run() {
-                        // do our best to have all threads start at the exact
-                        // same time. This is imperfect, but the closer we
-                        // get to everyone starting at the same time, the
-                        // better chance we have for identifying MT problems.
-                        while (System.currentTimeMillis() < startMillis)
-                            yield();
-
-                        int thisIteration = 1;
-                        try {
-                            for (; thisIteration <= iterations; thisIteration++)
-                            {
-                                // go go go!
-                                runner.run();
-                            }
-                        } catch (Throwable error) {
-                            synchronized (exceptions) {
-                                // embed the exception into something that gives
-                                // us some more information about the threading
-                                // environment
-                                exceptions.add(new ThreadingException("thread="
-                                    + this.toString()
-                                    + ";threadNum=" + thisThread
-                                    + ";maxThreads=" + threads
-                                    + ";iteration=" + thisIteration
-                                    + ";maxIterations=" + iterations, error));
-                            }
-                        }
-                    }
-                };
-        }
-
-        // start the serial tests(does not spawn the threads)
-        for (int i = 0; i < serialCount; i++) {
-            runners[0].run();
-        }
-
-        // start the multithreaded
-        for (int i = 0; i < threads; i++) {
-            runners[i].start();
-        }
-
-        // wait for them all to complete
-        for (int i = 0; i < threads; i++) {
-            try {
-                runners[i].join();
-            } catch (InterruptedException e) {
-            }
-        }
-
-        if (exceptions.size() == 0)
-            return; // sweeeeeeeet: no errors
-
-        // embed all the exceptions that were throws into a
-        // ThreadingException
-        Throwable [] errors = (Throwable []) exceptions.toArray(
-            new Throwable [0]);
-        throw new ThreadingException("The "
-            + errors.length + " embedded errors "
-            + "occured in the execution of " + iterations + " iterations "
-            + "of " + threads + " threads: [" + title + "]", errors);
-    }
-
-    /**
-     * Check to see if we are in the top-level execution stack.
-     */
-    public boolean isRootThread() {
-        return multiThreadExecuting == null;
-    }
-
-    /**
-     * Return the last method name that called this one by
-     * parsing the current stack trace.
-     *
-     * @param exclude a method name to skip
-     * @throws IllegalStateException If the calling method could not be
-     * identified.
-     * @author Marc Prud'hommeaux
-     */
-    public String callingMethod(String exclude) {
-        // determine the currently executing method by
-        // looking at the stack track. Hackish, but convenient.
-        StringWriter sw = new StringWriter();
-        new Exception().printStackTrace(new PrintWriter(sw));
-        for (StringTokenizer stackTrace = new StringTokenizer(sw.toString(),
-            System.getProperty("line.separator"));
-            stackTrace.hasMoreTokens();) {
-            String line = stackTrace.nextToken().trim();
-
-            // not a stack trace element
-            if (!(line.startsWith("at ")))
-                continue;
-
-            String fullMethodName = line.substring(0, line.indexOf("("));
-
-            String shortMethodName = fullMethodName.substring(
-                fullMethodName.lastIndexOf(".") + 1);
-
-            // skip our own methods!
-            if (shortMethodName.equals("callingMethod"))
-                continue;
-            if (exclude != null && shortMethodName.equals(exclude))
-                continue;
-
-            return shortMethodName;
-        }
-
-        throw new IllegalStateException("Could not identify calling "
-            + "method in stack trace");
-    }
-
-    /**
-     * A Runnable that can throw an Exception: used to test cases.
-     */
-    public static interface VolatileRunnable {
-
-        public void run() throws Exception;
-    }
-
-    /**
-     * Exception for errors caught during threading tests.
-     */
-    public class ThreadingException extends RuntimeException {
-
-        private final Throwable[] _nested;
-
-        public ThreadingException(String msg, Throwable nested) {
-            super(msg);
-            if (nested == null)
-                _nested = new Throwable[0];
-            else
-                _nested = new Throwable[]{ nested };
-        }
-
-        public ThreadingException(String msg, Throwable[] nested) {
-            super(msg);
-            if (nested == null)
-                _nested = new Throwable[0];
-            else
-                _nested = nested;
-        }
-
-        public void printStackTrace() {
-            printStackTrace(System.out);
-        }
-
-        public void printStackTrace(PrintStream out) {
-            printStackTrace(new PrintWriter(out));
-        }
-
-        public void printStackTrace(PrintWriter out) {
-            super.printStackTrace(out);
-            for (int i = 0; i < _nested.length; i++) {
-                out.print("Nested Throwable #" + (i + 1) + ": ");
-                _nested[i].printStackTrace(out);
-            }
-        }
-    }
-
-    //////////
-    // Timing
-    //////////
-
-    /**
-     * Sleep the current Thread for a random amount of time from 0-1000 ms.
-     */
-    public void sleepRandom() {
-        sleepRandom(1000);
-    }
-
-    /**
-     * Sleep the current Thread for a random amount of time from
-     * 0-<code>max</code> ms.
-     */
-    public void sleepRandom(int max) {
-        try {
-            Thread.currentThread().sleep((long) (Math.random() * max));
-        } catch (InterruptedException ex) {
-        }
-    }
-
-    /**
-     * Re-run this method in the current thread, timing out
-     * after the specified number of seconds.
-     * Usage:
-     * <pre> public void timeOutOperation() { if (timeout(5 * 1000)) return;
-     *  Thread.currentThread().sleep(10 * 1000); }
-     * </pre>
-     * <p/>
-     * <p/>
-     * <strong>Warning</strong> this method should be used sparingly,
-     * and only when you expect that a timeout will <strong>not</strong>
-     * occur. It utilized the deprecated {@link Thread#stop()} and
-     * {@link Thread#interrupt} methods, which can leave monitors in an
-     * invalid state. It is only used because it provides more
-     * meaningful information than just seeing that the entire autobuild
-     * timed out.
-     *
-     * @param millis the number of milliseconds we should wait.
-     * @return true if we are are in the thread that requested the
-     *         timeout, false if we are in the timeout thread itself.
-     */
-    public boolean timeout(long millis) throws Throwable {
-        String methodName = callingMethod("timeout");
-        return timeout(millis, methodName);
-    }
-
-    /**
-     * @see #timeout(long)
-     */
-    public boolean timeout(long millis, String methodName) throws Throwable {
-        // we are in the timing out-thread: do nothing so the
-        // actual test method can run
-        if (inTimeoutThread)
-            return false;
-
-        inTimeoutThread = true;
-        long endTime = System.currentTimeMillis() + millis;
-
-        try {
-            final Method method = getClass().
-                getMethod(methodName, (Class[]) null);
-            final Object thz = this;
-
-            // spawn thread
-            TimeOutThread tot = new TimeOutThread("TimeOutThread ["
-                + methodName + "] (" + millis + "ms)") {
-                public void run() {
-                    try {
-                        method.invoke(thz, (Object[]) null);
-                    } catch (Throwable t) {
-                        throwable = t;
-                    } finally {
-                        completed = true;
-                    }
-                }
-            };
-
-            tot.start();
-
-            // wait for the completion or a timeout to occur
-            tot.join(millis);
-
-            // have we timed out? Kill the thread and throw an exception
-            if (System.currentTimeMillis() >= endTime) {
-                // if we are waiting on a monitor, this will give
-                // us a useful stack trace.
-                try {
-                    tot.interrupt();
-                } catch (Throwable e) {
-                }
-                Thread.currentThread().sleep(500);
-
-                // try to kill the thread
-                try {
-                    tot.stop();
-                } catch (Throwable e) {
-                }
-                Thread.currentThread().sleep(500);
-
-                throw new OperationTimedOutException("Execution of \""
-                    + methodName + "\" timed out after "
-                    + millis + " milliseconds", tot.throwable);
-            }
-
-            // throw any exceptions that may have occured
-            if (tot.throwable != null)
-                throw tot.throwable;
-
-            // I guess everything was OK
-            return true;
-        } finally {
-            inTimeoutThread = false;
-        }
-    }
-
     /**
      * Utility method to start a profile.
      *
@@ -888,46 +481,6 @@
         getLog().info(_loc.get("profile-info", name,
             (time == null ? "???" : "" + elapsed)));
         return elapsed;
-    }
-
-    private static class TimeOutThread extends Thread {
-
-        public Throwable throwable = null;
-        public boolean completed = false;
-
-        public TimeOutThread(String name) {
-            super(name);
-            setDaemon(true);
-        }
-    }
-
-    /**
-     * Indicates that a timeout occured.
-     */
-    public static class OperationTimedOutException extends RuntimeException {
-
-        private final Throwable _err;
-
-        public OperationTimedOutException(String msg, Throwable throwable) {
-            super(msg);
-            _err = throwable;
-        }
-
-        public void printStackTrace() {
-            printStackTrace(System.out);
-        }
-
-        public void printStackTrace(PrintStream out) {
-            printStackTrace(new PrintWriter(out));
-        }
-
-        public void printStackTrace(PrintWriter out) {
-            super.printStackTrace(out);
-            if (_err != null) {
-                out.print("Nested Throwable: ");
-                _err.printStackTrace(out);
-            }
-        }
     }
 
     /////////////////////////

Modified: openjpa/trunk/openjpa-persistence-jdbc/pom.xml
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/pom.xml?rev=627979&r1=627978&r2=627979&view=diff
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/pom.xml (original)
+++ openjpa/trunk/openjpa-persistence-jdbc/pom.xml Fri Feb 15 01:19:55 2008
@@ -261,6 +261,11 @@
             <version>3.2</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>jakarta-regexp</groupId>
+            <artifactId>jakarta-regexp</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
@@ -310,6 +315,242 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <argLine>${test.jvm.arguments}</argLine>
+                    <excludes>
+                        <!-- exclude classes that end with 'Test'; these 
+                             are not test cases per OpenJPA standards -->
+                        <exclude>org/apache/openjpa/**/*Test.java</exclude>
+
+                        <!-- exclude classes that include a $; inner classes
+                             are not test cases per OpenJPA standards -->
+                        <exclude>org/apache/openjpa/**/*$*</exclude>
+                        <exclude>org/apache/openjpa/**/*.*</exclude>
+
+                        <!-- exclude failing Slice tests -->
+                        <exclude>**/slice/**/*.java</exclude>
+
+                        <!-- exclude new tests that aren't passing yet -->
+                        <exclude>org/apache/openjpa/persistence/annotations/TestAdvAnnot.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestAdvAnnot.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestAnnotationBasics.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestDDCallbackMethods.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestEJBEmbedded.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestEmbeddableSuperclass.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestEmbeddedId.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestEntityListenerAnnot.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestEntityOrderBy.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestEnumerated.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestFlatInheritance.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestGenerators.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestJoinedInheritance.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestManyToMany.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestMapKey.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestOneToMany.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestOneToOne.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestPropertyAccess.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestSerializedLobs.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestTablePerClassInheritance.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/annotations/TestVersion.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/cache/TestQueryCache.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/conf/TestKodoConfiguration.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestCacheMultiThreadedLoad.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestConcurrentDataCache.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestDataCachePCDataGenerator.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestDataCacheScheduler.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestDistributedKodoDataCache.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestFlushDataCache.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestJPQL2Queries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestJPQL2ResultsAndResultClasses.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestJPQLRelationProjections.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestLocalCache.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestMutableParameters.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestPCParametersInQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestQueryResultTypes.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestResultShapes.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestSJVMCache.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/datacache/TestUniteratedQueryResult.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/enhance/TestClone.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/enhance/TestDynamicStorageGenerator.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/enhance/TestNoNoArgs.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/enhance/TestSubclassedBehavior.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/entityoperation/TestCascades.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestEvents.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestFakeRemoteEvents.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestLifecycleEventManager.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestLocalRemoteEvents.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestOrphanedKeyAction.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestTCPRemoteClassChanges.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestTCPRemoteEvents.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestTCPRemoteEventsDuration.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestTCPRemoteRecovery.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/event/TestTCPRemoteRecoveryTransmitAdds.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestByteArrayAppId.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestCircularFK.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestDataStoreTrips.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestEfficientAttach.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestEJBAutoIncrement.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestEmbeddedPessimisticLocking.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestIncrementalJDBCFlushes.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestOperationOrderUpdateManager.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestPagingResultObjectProvider.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestRawSQL.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestSQLListenerTestCase.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/kernel/TestUnknownSubclass.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/mapping/TestCompositeIdTraversalInSQLMapping.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/mapping/TestNativeQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestBuildSchema.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestDFG.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEagerDistinct.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEagerOuterToManyJoins.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEJBByteArray.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEJBColumnIOMappings.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEJBConstantJoinOnSameRefTable.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEJBCustomMapping.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEJBDateVersion.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEJBEager.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEJBInverseOneToOne.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestEJBOuterJoinValues.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestIntermediate.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestIrregularJoins.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestJDBCType.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestJoinToBaseClass.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestLocators.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestLRSProxies.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestMappedByKeyMaps.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestMetaDataValueIndicator.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestMultiDFG.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestMultiTableMappings.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestMultiTableSelfCollection.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestNoClassColumn.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestRawField.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/TestStateImage.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/horizontal/TestLockGroupsWithHorizontalBaseType.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/horizontal/TestQueryAgainstEntireMappedHierarchy.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/tableperclass/TestUnionPlaceholderTypes.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/vertical/TestJoinSubclasses.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/vertical/TestSubclassJoinExtent.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/vertical/TestSubclassJoinGetObjectById.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/meta/vertical/TestSubclassJoinRelations.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/query/TestEJBQLSelectNPlusOne.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/query/TestNamedSQLQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/query/TestSQLQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/query/TestStringFunctions.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestClassDBSequenceFactory.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestClassSequenceFactory.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestDBSequenceFactory.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestDynamicSchemaFactory.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestJDBCListener.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestLazySchemaFactory.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestPerClassSequenceFactory.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestSchema.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestSchemaClone.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerator.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestSequenceGeneratorEnsureCapacityCall.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestXMLSchemaParser.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jdbc/schema/TestXMLSchemaSerializer.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jpql/clauses/TestBulkUpdate.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jpql/clauses/TestEJBClauses.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jpql/clauses/TestEJBDeleteUpdateImpl.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jpql/clauses/TestEJBPolymorphicQuery.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jpql/clauses/TestEJBQueryInterface.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jpql/expressions/TestEJBQLCondExpression.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jpql/functions/TestEJBQLFunction.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/jpql/joins/TestEJBJoins.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/Test2EJBConcurrency.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestAbstractMappedAppIdSuper.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestArrayValues2.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestBigDecimals.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestBrokerFactoryPooling.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestCalendarFields.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestCheckConsistency.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestClassStringConstructor.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestConnectionRetainMode.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestDateQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestDependentFields2.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestDetachedStateManager.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBEmbedded.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBEntityManager.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBGetObjectByIdValue.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBIncrementalFlushes.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBInterfaces.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBLobs.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBLocales.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBManagedInverses.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBNoPersistentFields.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBNullValues.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBObjectCollections.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBRetainValues.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBState.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBTransactionalClass.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestEJBTransactions.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestExtents.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestExtents2.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestFetchGroups.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestFetchGroupsExtent.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestFetchGroupsQuery.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestFetchPlan.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestFieldRange.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestFieldRange2.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestFieldState.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestGetObjectsById.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestIncrementalFlushes.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestIncrementalFlushesDeletes.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestInheritance.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestInitialValueFetching.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestInstanceCallbacks.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestManagedInterfaces.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestManagedInterfacesAppId.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestMultiThreaded.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestNTW.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestOpenResultsCommit.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestOptimisticLockGroups.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestPCClass.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestPersistenceManager.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestPersistenceManagerFactoryImpl.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestPersistentMaps.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestPessimisticLocking.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestPMMemory.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestPojoWithoutAnnotationsCannotBePersisted.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestProxies2.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestRestoreValues.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestRetainValuesInOptimistic.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSavepointEmbedded.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSavepointEmbeddedPreFlush.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSavepointOrdering.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSavepoints.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSecondClassValues.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSecurityContext.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSequence.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSerialize.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSimple.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSpecialNumbers.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestSpecialNumbers2.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestStateManagerImplData.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestStaticInnerClasses.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestStoreBlob.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/kernel/TestTransition2.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestClassMetaData.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestExternalValues.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestFieldDeclarationOrder.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestNonPersistentFields.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestOrderBy.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestPersistentClasses.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestSequenceAssigned.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestValueStrategies.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/meta/TestXMLPersistenceMetaDataSerializer.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestComplexQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestEJBDeleteUpdateImpl.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestEJBPolymorphicQuery.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestEJBQueryInterface.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestJPAQuerySubclassFunc.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestMathQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestNamedQueries.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestQueryExpressionSplit.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestQueryResults.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestQuotedNumbersInFilters2.java</exclude>
+                        <exclude>org/apache/openjpa/persistence/query/TestSimple.java</exclude>
+                    </excludes>
                     <systemProperties>
                         <property>
                             <name>openjpa.Log</name>

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/BrokerImplInitialization.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/BrokerImplInitialization.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/BrokerImplInitialization.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/BrokerImplInitialization.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,29 @@
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+
+import junit.framework.TestCase;
+
+public class BrokerImplInitialization extends TestCase {
+
+    public void testInitialization() {
+        EntityManagerFactory emf = Persistence.createEntityManagerFactory(null);
+        emf.createEntityManager().close(); // initialization
+        long start = System.currentTimeMillis();
+        int count = 100000;
+        int hash = 0;
+        Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
+        for(int i = 0; i < count; i++) {
+            if (i % 10000 == 0)
+                System.out.printf("starting iteration %d after %d millis.\n",
+                    i, System.currentTimeMillis() - start);
+            EntityManager em = emf.createEntityManager();
+            hash |= em.hashCode();
+            em.close();
+        }
+        System.out.printf("took %d millis to complete %d runs.\n", 
+            System.currentTimeMillis() - start, count);
+        System.out.println("hash: " + hash);
+        emf.close();
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/CurrentTests.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/CurrentTests.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/CurrentTests.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/CurrentTests.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import org.apache.openjpa.kernel.TestEnhancedInstanceBrokerSerialization;
+import org.apache.openjpa.kernel.TestEntityManagerFactoryPool;
+import org.apache.openjpa.kernel.TestInstanceGraphBrokerSerialization;
+import org.apache.openjpa.kernel.TestUnenhancedFieldAccessInstanceBrokerSerialization;
+import org.apache.openjpa.kernel.TestUnenhancedFieldAccessWithRelationInstanceBrokerSerialization;
+import org.apache.openjpa.kernel.TestUnenhancedPropertyAccessInstanceBrokerSerialization;
+import org.apache.openjpa.kernel.TestUnenhancedPropertyAccessWithRelationInstanceBrokerSerialization;
+
+public class CurrentTests extends TestSuite {
+
+    public static Test suite() {
+        TestSuite suite = new TestSuite("Current Tests");
+        suite.addTestSuite(TestEnhancedInstanceBrokerSerialization.class);
+        suite.addTestSuite(TestInstanceGraphBrokerSerialization.class);
+        suite.addTestSuite(
+            TestUnenhancedFieldAccessWithRelationInstanceBrokerSerialization.class);
+        suite.addTestSuite(
+            TestUnenhancedPropertyAccessWithRelationInstanceBrokerSerialization.class);
+        suite.addTestSuite(
+            TestUnenhancedFieldAccessInstanceBrokerSerialization.class);
+        suite.addTestSuite(
+            TestUnenhancedPropertyAccessInstanceBrokerSerialization.class);
+
+//        suite.addTestSuite(TestPCSubclassNameConversion.class);
+//        suite.addTestSuite(ManagedCacheTest.class);
+        suite.addTestSuite(TestEntityManagerFactoryPool.class);
+        return suite;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestAdvAnnot.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestAdvAnnot.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestAdvAnnot.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestAdvAnnot.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.annotations;
+
+import junit.framework.*;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+import javax.persistence.*;
+
+import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
+import org.apache.openjpa.persistence.common.utils.*;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+public class TestAdvAnnot extends AbstractTestCase
+{
+	public TestAdvAnnot(String name)
+	{
+		super(name, "annotationcactusapp");
+	}
+
+	public void setUp()
+	{
+		deleteAll(Schedule.class);
+		deleteAll(FlightSchedule.class);
+
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		for(int i = 0; i<5; i++)
+		{
+			Calendar cal = Calendar.getInstance();
+			Date date = new Date(01012006l);
+			Date edate = new Date(10031980l);
+			String name = "AmericaWest"+i;
+			String schedname = "Schedule"+i;
+			FlightSchedule sched = new FlightSchedule(schedname, cal, date, edate, name);
+
+			em.persist(sched);
+
+
+		}
+
+		endTx(em);
+		endEm(em);
+	}
+
+	public void testTimeTemporalAnnot()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+
+		String query = "SELECT d.startDate FROM FlightSchedule d WHERE d.name = :name";
+
+		Date obj = (Date) em.createQuery(query)
+		              .setParameter("name", "Schedule3")
+		              .getSingleResult();
+
+		assertNotNull(obj);
+		assertTrue(obj instanceof Date);
+
+		endEm(em);
+	}
+
+	public void testCalendarTemporalAnnot()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		String query = "SELECT d FROM FlightSchedule d";
+
+		List list = em.createQuery(query).getResultList();
+		assertNotNull(list);
+		assertEquals(5, list.size());
+		/*
+		String query = "SELECT d.dob FROM FlightSchedule d WHERE d.name = :name";
+
+		List list = em.createQuery(query)
+		              .setParameter("name", "Schedule3")
+		              .getResultList();
+
+		assertNotNull(list);
+		assertTrue(list.get(0) instanceof Calendar);*/
+
+		endEm(em);
+	}
+
+	public void testUniqueConstraintAnnot()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		String query = "Update FlightSchedule f SET f.planeName = :plane WHERE f.name = :sname";
+		int upd = 0;
+
+		try
+		{
+			upd = em.createQuery(query)
+            .setParameter("plane", "AmericaWest3")
+            .setParameter("sname", "Schedule2")
+            .executeUpdate();
+
+			fail("Violated unique constraint rule...@Unique Constraint annotation needs to be supported");
+		}
+		catch(Exception e)
+		{
+			//suppose to throw exception based on the unique constraint rule
+		}
+
+		assertNotNull(upd);
+		assertEquals(0, upd);
+
+		endTx(em);
+		endEm(em);
+	}
+
+
+
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestAnnotationBasics.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestAnnotationBasics.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestAnnotationBasics.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestAnnotationBasics.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.annotations;
+
+import javax.persistence.*;
+
+import org.apache.openjpa.jdbc.meta.*;
+import org.apache.openjpa.meta.*;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.JPAFacadeHelper;
+
+import org.apache.openjpa.persistence.common.utils.*;
+
+import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
+
+public class TestAnnotationBasics extends AbstractTestCase {
+
+	public TestAnnotationBasics(String name)
+	{
+		super(name, "annotationcactusapp");
+	}
+
+    public void testSingleFieldIdentity()
+    {
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        ClassMetaData meta = JPAFacadeHelper.getMetaData(em, Entity1.class);
+        assertTrue("Entity1 should use application identity",
+            ClassMetaData.ID_APPLICATION == meta.getIdentityType());
+        assertTrue("Entity1 should use single-field identity",
+            meta.isOpenJPAIdentity());
+    }
+/*
+    public void testVersionField() {
+        ClassMapping mapping = (ClassMapping) getConfiguration().
+            getMetaDataRepositoryInstance().getMetaData(Entity1.class,
+            null, true);
+        FieldMapping fm = mapping.getFieldMapping("versionField");
+        assertTrue(fm.isVersion());
+        String col = mapping.getVersion().getColumns()[0].getName();
+        assertTrue(col, "VERSIONFIELD".equalsIgnoreCase(col));
+    }
+*/}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestDDCallbackMethods.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestDDCallbackMethods.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestDDCallbackMethods.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestDDCallbackMethods.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,266 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.annotations;
+
+import java.util.List;
+
+import junit.framework.*;
+import javax.persistence.*;
+
+import org.apache.openjpa.persistence.common.utils.*;
+import org.apache.openjpa.persistence.annotations.common.apps.annotApp.ddtype.*;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+public class TestDDCallbackMethods extends AbstractTestCase
+{
+
+	public TestDDCallbackMethods(String name)
+	{
+		super(name, "ddcactusapp");
+	}
+
+	public void setUp()
+	{
+		deleteAll(LifeCycleDDEntity.class);
+		deleteAll(LifeCycleDDEntity2.class);
+		CallbackStorage.clearStore();
+	}
+
+	public void testDDPrpPop()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		LifeCycleDDEntity lcd = new LifeCycleDDEntity("afam", "okeke");
+
+		em.persist(lcd);
+		CallbackStorage store = CallbackStorage.getInstance();
+
+		assertNotNull(store.getClist());
+		assertEquals(2, store.getClist().size());
+		assertEquals("def-prepersist", store.getClist().get(0));
+		assertEquals("def-postpersist", store.getClist().get(1));
+
+		endTx(em);
+		endEm(em);
+	}
+
+	public void testDDPrrPor()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		LifeCycleDDEntity lcd = new LifeCycleDDEntity("john", "rash");
+
+		em.persist(lcd);
+		int id = lcd.getId();
+
+		lcd = em.find(LifeCycleDDEntity.class, id);
+
+		assertNotNull(lcd);
+		CallbackStorage store = CallbackStorage.getInstance();
+		store.clearStore();
+
+		em.remove(lcd);
+
+		assertNotNull(store.getClist());
+		assertEquals(2, store.getClist().size());
+		assertEquals("def-preremove", store.getClist().get(0));
+		assertEquals("def-postremove", store.getClist().get(1) );
+
+		endTx(em);
+		endEm(em);
+	}
+
+	public void testDDPouPru()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		LifeCycleDDEntity lcd = new LifeCycleDDEntity("Don", "Shiddle");
+
+		em.persist(lcd);
+		int id = lcd.getId();
+
+		CallbackStorage.clearStore();
+
+		String query = "Update LifeCycleDDEntity e SET e.name = 'Joseph' WHERE e.id = :id";
+
+		int result = em.createQuery(query)
+		               .setParameter("id", id)
+		               .executeUpdate();
+
+		List store = CallbackStorage.getInstance().getClist();
+
+		assertNotNull(result);
+		assertEquals(1, result);
+		assertNotNull(store);
+		assertEquals(2, store.size());
+		assertEquals("def-preupdate", store.get(0));
+		assertEquals("def-postupdate", store.get(1));
+
+		endTx(em);
+		endEm(em);
+	}
+
+	public void testDDPol()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		LifeCycleDDEntity lcd = new LifeCycleDDEntity("Julie", "Jolie");
+
+		em.persist(lcd);
+		int id = lcd.getId();
+
+        CallbackStorage.clearStore();
+
+		endTx(em);
+
+		startTx(em);
+		CallbackStorage.clearStore();
+
+		assertTrue(CallbackStorage.getInstance().getClist().isEmpty());
+
+		lcd = em.find(LifeCycleDDEntity.class, id);
+		em.refresh(lcd);
+
+		assertNotNull(lcd);
+		assertNotNull(CallbackStorage.getInstance().getClist());
+		assertEquals(2, CallbackStorage.getInstance().getClist().size());
+		assertEquals("def-postload", CallbackStorage.getInstance().getClist().get(0));
+		assertEquals("def-postload", CallbackStorage.getInstance().getClist().get(1));
+
+		endTx(em);
+		endEm(em);
+
+	}
+
+	/**  DEFAULT LISTENER DD TESTING **/
+
+	public void testDefaultPrePostPersistListener()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		LifeCycleDDEntity2 lc = new LifeCycleDDEntity2("Bill", "Clinton");
+
+		CallbackStorage store = CallbackStorage.getInstance();
+		store.clearStore();
+
+		em.persist(lc);
+
+		assertEquals(4, store.getClist().size());
+		assertEquals("def-prepersist", store.getClist().get(0));
+		assertEquals("verifyprp", store.getClist().get(1));
+		assertEquals("def-postpersist", store.getClist().get(2));
+		assertEquals("verifypop", store.getClist().get(3));
+
+		endTx(em);
+		endEm(em);
+	}
+
+    //FIX-ME Default-Entity-listener Impl. is over firing
+	public void testDefaultPrePostUpdateListener()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		LifeCycleDDEntity2 emp = new LifeCycleDDEntity2("lincoln", "Abraham");
+
+		em.persist(emp);
+
+		int id = emp.getId();
+
+		CallbackStorage.clearStore();
+
+		String query = "Update LifeCycleDDEntity2 e SET e.name = 'Joseph' WHERE e.id = :id";
+
+		int result = em.createQuery(query)
+		               .setParameter("id", id)
+		               .executeUpdate();
+
+		List store = CallbackStorage.getInstance().getClist();
+
+		assertNotNull(result);
+		assertEquals(1, result);
+		assertNotNull(store);
+		assertEquals(2, store.size());
+		assertEquals("def-preupdate", store.get(0));
+		assertEquals("def-postupdate", store.get(1));
+//		assertEquals("def-postupdate", store.get(2));
+//		assertEquals("def-postupdate", store.get(3));
+
+		endTx(em);
+		endEm(em);
+	}
+
+	//FIX-ME Default-Entity-listener Impl. is over firing
+	public void testDefaultPostLoadListener()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		LifeCycleDDEntity2 emp = new LifeCycleDDEntity2("Thomas", "Jefferson");
+
+		em.persist(emp);
+		int id = emp.getId();
+		CallbackStorage.clearStore();
+
+		endTx(em);
+
+		startTx(em);
+		CallbackStorage.clearStore();
+
+		assertTrue("not empty...", CallbackStorage.isEmpty());
+
+		emp = em.find(LifeCycleDDEntity2.class, id);
+		em.refresh(emp);
+
+		assertNotNull(emp);
+		assertNotNull(CallbackStorage.getInstance().getClist());
+		assertEquals(2, CallbackStorage.getInstance().getClist().size());
+		assertEquals("def-postload", CallbackStorage.getInstance().getClist().get(0));
+		assertEquals("def-postload", CallbackStorage.getInstance().getClist().get(1));
+
+		endTx(em);
+		endEm(em);
+	}
+
+	public void testSubClassOverrideSuperCallbacksInh()
+	{
+		OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+		startTx(em);
+
+		LifeCycleDDEntity2 emp = new LifeCycleDDEntity2("Thomas", "Jefferson");
+
+		em.persist(emp);
+
+		assertNotNull(emp);
+		assertNotNull(CallbackStorage.getInstance().getClist());
+		assertEquals(4, CallbackStorage.getInstance().getClist().size());
+		assertEquals("def-prepersist", CallbackStorage.getInstance().getClist().get(0));
+		assertEquals("verifyprp", CallbackStorage.getInstance().getClist().get(1));
+		assertEquals("def-postpersist", CallbackStorage.getInstance().getClist().get(2));
+		assertEquals("verifypop", CallbackStorage.getInstance().getClist().get(3));
+
+		endTx(em);
+		endEm(em);
+	}
+}
\ No newline at end of file

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEJBEmbedded.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEJBEmbedded.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEJBEmbedded.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEJBEmbedded.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.annotations;
+
+import java.sql.*;
+
+import javax.persistence.*;
+
+import org.apache.openjpa.jdbc.conf.*;
+import org.apache.openjpa.jdbc.meta.*;
+import org.apache.openjpa.jdbc.meta.strats.*;
+import org.apache.openjpa.jdbc.sql.*;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+//import kodo.persistence.test.*;
+
+import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
+import org.apache.openjpa.persistence.common.utils.*;
+
+import junit.framework.*;
+
+/**
+ * Test for embedded
+ *
+ * @author Steve Kim
+ */
+public class TestEJBEmbedded extends AbstractTestCase
+{
+
+	public TestEJBEmbedded(String name)
+	{
+		super(name, "annotationcactusapp");
+	}
+
+    private static final String CLOB;
+
+    static {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < 1000; i++)
+            buf.append('a');
+        CLOB = buf.toString();
+    }
+
+    public void setUp()
+    {
+        deleteAll (EmbedOwner.class);
+    }
+
+    public void testEmbedded()
+    {
+        OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        EmbedOwner owner = new EmbedOwner();
+        owner.setBasic("foo");
+        EmbedValue embed = new EmbedValue();
+        embed.setClob(CLOB);
+        embed.setBasic("bar");
+        embed.setBlob("foobar".getBytes());
+        embed.setOwner(owner);
+        owner.setEmbed(embed);
+        em.persist(owner);
+        int pk = owner.getPk();
+        endTx(em);
+        endEm(em);
+
+        em =(OpenJPAEntityManager) currentEntityManager();
+        owner = em.find(EmbedOwner.class, pk);
+        assertEquals("foo", owner.getBasic());
+        embed = owner.getEmbed();
+        assertNotNull(embed);
+        assertEquals(CLOB, embed.getClob());
+        assertEquals("bar", embed.getBasic());
+        assertEquals("foobar", new String(embed.getBlob()));
+        assertEquals(owner, embed.getOwner());
+        endEm(em);
+    }
+
+    public void testNull() {
+        OpenJPAEntityManager em =(OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        EmbedOwner owner = new EmbedOwner();
+        owner.setBasic("foo");
+        em.persist(owner);
+        int pk = owner.getPk();
+        endTx(em);
+        endEm(em);
+
+        em =(OpenJPAEntityManager) currentEntityManager();
+        owner = em.find(EmbedOwner.class, pk);
+        assertEquals("foo", owner.getBasic());
+        EmbedValue embed = owner.getEmbed();
+        assertNotNull(embed);
+        assertNull(embed.getClob());
+        assertNull(embed.getBasic());
+        assertNull(embed.getBlob());
+        startTx(em);
+    }
+
+//    public void testMappingTransferAndOverride() {
+//        JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+//        ClassMapping cls = conf.getMappingRepositoryInstance().getMapping
+//            (EmbedOwner.class, null, true);
+//        assertEquals("OWN_BASIC", cls.getFieldMapping("basic").
+//            getColumns()[0].getName());
+//        ClassMapping embed = cls.getFieldMapping("embed").currentEntityManager()beddedMapping();
+//        assertEquals("EMB_BLOB", embed.getFieldMapping("blob").
+//            getColumns()[0].getName());
+//        assertEquals("OVER_BASIC", embed.getFieldMapping("basic").
+//            getColumns()[0].getName());
+//        assertEquals("OVER_OWNER", embed.getFieldMapping("owner").
+//            getColumns()[0].getName());
+//
+//        FieldMapping fm = embed.getFieldMapping("clob");
+//        DBDictionary dict = conf.getDBDictionaryInstance();
+//        if (dict.getPreferredType(Types.CLOB) == Types.CLOB) {
+//            if (dict.maxEmbeddedClobSize > 0)
+//                assertTrue(fm.getStrategy() instanceof
+//                    MaxEmbeddedClobFieldStrategy);
+//            else
+//                assertTrue(fm.getHandler() instanceof ClobValueHandler);
+//        } else
+//            assertTrue(fm.getStrategy() instanceof StringFieldStrategy);
+//    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEmbeddableSuperclass.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEmbeddableSuperclass.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEmbeddableSuperclass.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEmbeddableSuperclass.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.annotations;
+
+import java.sql.*;
+
+import org.apache.openjpa.jdbc.conf.*;
+import org.apache.openjpa.jdbc.meta.*;
+import org.apache.openjpa.jdbc.meta.strats.*;
+import org.apache.openjpa.jdbc.sql.*;
+import org.apache.openjpa.meta.*;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+
+import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
+import org.apache.openjpa.persistence.common.utils.*;
+
+import junit.framework.*;
+
+/**
+ * <p>Test embeddable superclasses.</p>
+ *
+ * @author Abe White
+ */
+public class TestEmbeddableSuperclass extends AbstractTestCase
+{
+
+	public TestEmbeddableSuperclass(String name)
+	{
+		super(name, "annotationcactusapp");
+	}
+
+    public void setUp() {
+        deleteAll(EmbeddableSuperSub.class);
+    }
+
+    /*public void testSuperclassEmbeddedOnly() {
+        ClassMapping cls = ((JDBCConfiguration) getConfiguration()).
+            getMappingRepositoryInstance().getMapping(EmbeddableSuper.class,
+            null, true);
+        assertTrue(cls.isEmbeddedOnly());
+        assertEquals(NoneClassStrategy.getInstance(), cls.getStrategy());
+    }
+
+    public void testSubclassMappingDefaultsAndOverrides() {
+        JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        assertTrue(!cls.isEmbeddedOnly());
+        assertTrue(cls.getStrategy() instanceof FullClassStrategy);
+        assertEquals(ClassMapping.ID_APPLICATION, cls.getIdentityType());
+        assertTrue(cls.isOpenJPAIdentity());
+
+        FieldMapping fm = cls.getFieldMapping("pk");
+        assertTrue(fm.isPrimaryKey());
+        assertEquals(ValueStrategies.SEQUENCE, fm.getValueStrategy());
+        assertEquals("ID", fm.getColumns()[0].getName());
+
+        assertNull(cls.getField("trans"));
+
+        fm = cls.getFieldMapping("clob");
+        assertEquals("CC", fm.getColumns()[0].getName());
+        DBDictionary dict = conf.getDBDictionaryInstance();
+        if (dict.getPreferredType(Types.CLOB) == Types.CLOB) {
+            if (dict.maxEmbeddedClobSize > 0)
+                assertTrue(fm.getStrategy() instanceof
+                    MaxEmbeddedClobFieldStrategy);
+            else
+                assertTrue(fm.getHandler() instanceof ClobValueHandler);
+        } else
+            assertTrue(fm.getStrategy() instanceof StringFieldStrategy);
+    }
+
+    public void testSubclassDiscriminatorMapping() {
+        JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        assertEquals("DISC", cls.getDiscriminator().getColumns()[0].
+            getName());
+    }
+
+    public void testVersionOverrideMapping() {
+        JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        assertEquals("VERSVAL", cls.getVersion().getColumns()[0].getName());
+    }
+
+    public void testRelationMappings() {
+        JDBCConfiguration conf = (JDBCConfiguration) getConfiguration();
+        ClassMapping cls = conf.getMappingRepositoryInstance().
+            getMapping(EmbeddableSuperSub.class, null, true);
+        FieldMapping fm = cls.getFieldMapping("sub");
+        assertTrue(fm.getStrategy() instanceof RelationFieldStrategy);
+
+        fm = cls.getFieldMapping("sup");
+        assertTrue(fm.getStrategy() instanceof RelationFieldStrategy);
+    }
+*/
+    public void testPersistAndFind() {
+        EmbeddableSuperSub parent = new EmbeddableSuperSub();
+        parent.setClob("parent");
+        EmbeddableSuperSub sub = new EmbeddableSuperSub();
+        sub.setClob("sub");
+        EmbeddableSuperSub sup = new EmbeddableSuperSub();
+        sup.setClob("sup");
+        parent.setSub(sub);
+        parent.setSup(sup);
+
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        em.persistAll(parent, sub, sup);
+        endTx(em);
+        long pk = parent.getPK();
+        endEm(em);
+
+        em = (OpenJPAEntityManager) currentEntityManager();
+        parent = em.find(EmbeddableSuperSub.class, pk);
+        assertEquals("parent", parent.getClob());
+        assertEquals("sub", parent.getSub().getClob());
+        assertEquals("sup", parent.getSup().getClob());
+        endEm(em);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEmbeddedId.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEmbeddedId.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEmbeddedId.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/annotations/TestEmbeddedId.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,264 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.annotations;
+
+import javax.persistence.*;
+
+import org.apache.openjpa.enhance.*;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+import junit.framework.*;
+
+import org.apache.openjpa.persistence.annotations.common.apps.annotApp.annotype.*;
+import org.apache.openjpa.persistence.common.utils.*;
+
+/**
+ * <p>Test embedded id classes.</p>
+ *
+ * @author Abe White
+ */
+public class TestEmbeddedId extends AbstractTestCase
+{
+
+	public TestEmbeddedId(String name)
+	{
+		super(name, "annotationcactusapp");
+	}
+
+    EmbeddedIdClass _oid;
+    EmbeddedIdClass _roid;
+
+    public void setUp() {
+        deleteAll(EmbeddedIdEntity.class);
+
+        _oid = new EmbeddedIdClass();
+        _oid.setPk1(1);
+        _oid.setPk2(2);
+
+        EmbeddedIdEntity e = new EmbeddedIdEntity();
+        e.setId(_oid);
+        e.setValue("e");
+
+        _roid = new EmbeddedIdClass();
+        _roid.setPk1(2);
+        _roid.setPk2(3);
+
+        EmbeddedIdEntity rel = new EmbeddedIdEntity();
+        rel.setId(_roid);
+        rel.setValue("r");
+        e.setRelation(rel);
+
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        em.persistAll(e, rel);
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testGetObjectId() {
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        EmbeddedIdEntity e = em.find(EmbeddedIdEntity.class, _oid);
+        assertNotNull(e);
+        assertEquals("e", e.getValue());
+        assertNull(e.getMappingOverrideRelation());
+        assertNotNull(e.getRelation());
+        assertEquals("r", e.getRelation().getValue());
+
+        assertEquals(_oid, em.getObjectId(e));
+        assertEquals(_roid, em.getObjectId(e.getRelation()));
+        assertEquals(_oid, e.getId());
+        assertEquals(_roid, e.getRelation().getId());
+        assertNull(((PersistenceCapable) e.getId()).pcGetGenericContext());
+        endEm(em);
+    }
+
+    public void testMutateEmbeddedIdFieldValueOfNew() {
+        EmbeddedIdEntity e1 = new EmbeddedIdEntity();
+        e1.setValue("e1");
+        EmbeddedIdEntity e2 = new EmbeddedIdEntity();
+        e2.setValue("e2");
+        
+        e2.setId(new EmbeddedIdClass());
+        //Comment this since pk3 is auto-generated and assigning
+        //it explicitly causes a rollback
+        //e2.getId().setPk3(99); // prevent assign on access
+
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        //em.persistAll(e1, e2);
+
+         EmbeddedIdClass oid = new EmbeddedIdClass();
+        oid.setPk1(4);
+        oid.setPk2(5);
+        //Comment this since pk3 is auto-generated and assigning
+        //it explicitly causes a rollback
+        //oid.setPk3(6);
+        e1.setId(oid);
+        e2.getId().setPk1(6);
+        e2.getId().setPk2(7);
+        em.persistAll(e1, e2);
+
+        endTx(em);
+
+        EmbeddedIdClass oid1 = e1.getId();
+        EmbeddedIdClass oid2 = e2.getId();
+        assertEquals(oid1, em.getObjectId(e1));
+        assertEquals(oid2, em.getObjectId(e2));
+        assertEquals(4, oid1.getPk1());
+        assertEquals(5, oid1.getPk2());
+        assertEquals(6, oid2.getPk1());
+        assertEquals(7, oid2.getPk2());
+        endEm(em);
+
+        em = (OpenJPAEntityManager) currentEntityManager();
+        e1 = em.find(EmbeddedIdEntity.class, oid1);
+        e2 = em.find(EmbeddedIdEntity.class, oid2);
+        assertEquals(oid1, em.getObjectId(e1));
+        assertEquals(oid2, em.getObjectId(e2));
+        assertEquals(oid1, e1.getId());
+        assertEquals(oid2, e2.getId());
+        endEm(em);
+    }
+
+    public void testMutateEmbeddedIdFieldValueOfExisting() 
+    {
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        EmbeddedIdEntity e = em.find(EmbeddedIdEntity.class, _oid);
+        e.setValue("changed");
+        try {
+            e.getId().setPk1(9);
+            endTx(em);
+            fail("Committed with changed oid field.");
+        } catch (RuntimeException re) {
+            if (isActiveTx(em))
+            	rollbackTx(em);
+        }
+        catch (Exception exc)
+        {
+            if (isActiveTx(em))
+            	rollbackTx(em);
+        }
+        endEm(em);
+    }
+
+    public void testDetachAttach() {
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        EmbeddedIdEntity e = em.find(EmbeddedIdEntity.class, _oid);
+        e.getRelation();
+        endEm(em);
+
+        e.setValue("echanged");
+        e.getRelation().setValue("rchanged");
+
+        em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        EmbeddedIdEntity me = (EmbeddedIdEntity) em.mergeAll(e,
+            e.getRelation())[0];
+        assertTrue(me != e);
+        assertNotNull(me.getRelation());
+        assertTrue(me.getRelation() != e.getRelation());
+        assertEquals("echanged", me.getValue());
+        assertEquals("rchanged", me.getRelation().getValue());
+        assertEquals(_oid, me.getId());
+        assertEquals(_oid, em.getObjectId(me));
+        assertEquals(_roid, me.getRelation().getId());
+        assertEquals(_roid, em.getObjectId(me.getRelation()));
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testQuery() {
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        Query q = em.createQuery("select e from EmbeddedIdEntity e "
+            + "where e.id.pk1 = 1");
+        EmbeddedIdEntity e = (EmbeddedIdEntity) q.getSingleResult();
+        assertEquals(_oid, e.getId());
+        assertEquals("e", e.getValue());
+
+        q = em.createQuery("select e.id.pk2 from EmbeddedIdEntity e "
+            + "where e.id.pk1 = 1");
+        assertEquals(new Long(_oid.getPk2()), q.getSingleResult());
+
+        q = em.createQuery("select e.id from EmbeddedIdEntity e "
+            + "where e.id.pk1 = 1");
+        assertEquals(_oid, q.getSingleResult());
+        endEm(em);
+    }
+
+    public void testAutoAssigned() {
+        // begin with null id object
+        OpenJPAEntityManager em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        EmbeddedIdEntity e = new EmbeddedIdEntity();
+        em.persist(e);
+        EmbeddedIdClass oid = e.getId();
+        assertNotNull(oid);
+        assertTrue(oid.getPk3() != 0);
+        assertEquals(oid, em.getObjectId(e));
+        endTx(em);
+        assertEquals(oid, em.getObjectId(e));
+        endEm(em);
+
+        em = (OpenJPAEntityManager) currentEntityManager();
+        e = em.find(EmbeddedIdEntity.class, oid);
+        assertEquals(oid, em.getObjectId(e));
+        endEm(em);
+
+        // begin with non-null id object
+        em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        e = new EmbeddedIdEntity();
+        oid = new EmbeddedIdClass();
+        oid.setPk1(4);
+        oid.setPk2(5);
+        e.setId(oid);
+        em.persist(e);
+        oid = e.getId();
+        assertEquals(4, oid.getPk1());
+        assertEquals(5, oid.getPk2());
+        assertTrue(oid.getPk3() != 0);
+        assertEquals(oid, em.getObjectId(e));
+        endTx(em);
+        assertEquals(oid, em.getObjectId(e));
+        endEm(em);
+
+        em = (OpenJPAEntityManager) currentEntityManager();
+        e = em.find(EmbeddedIdEntity.class, oid);
+        assertEquals(oid, em.getObjectId(e));
+        endEm(em);
+
+        // flush before accessing id field
+        em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+        e = new EmbeddedIdEntity();
+        em.persist(e);
+        endTx(em);
+        oid = e.getId();
+        assertTrue(oid.getPk3() != 0);
+        assertEquals(oid, em.getObjectId(e));
+        endEm(em);
+
+        em = (OpenJPAEntityManager) currentEntityManager();
+        e = em.find(EmbeddedIdEntity.class, oid);
+        assertEquals(oid, em.getObjectId(e));
+        endEm(em);
+    }
+}



Mime
View raw message