Gerard Davison | 16 Dec 15:12 2011
Picon

JDK7 Support


All,

I have just commit a change to make abbot compile and run against JDK 7, there are about ten more test failures on JDK7u1 compared with JDK6u30 so obviously we would need to resolve some of these. Mostly in the area of tree controls.

If you want to try it out check out the tip of the SVN repository and run the all ant target.

Thanks,

Gerard


Begin forwarded message:

Subject: [abbot-commits] SF.net SVN: abbot:[2811] abbot/trunk
Date: 16 December 2011 12:18:05 GMT

Revision: 2811
         http://abbot.svn.sourceforge.net/abbot/?rev=2811&view=rev
Author:   gdavison
Date:     2011-12-16 12:18:04 +0000 (Fri, 16 Dec 2011)
Log Message:
-----------
2011-12-12  Gerard Davison

       * Added assertCellExists to JTableTester
       * Removed old JPEG API's so that the code now compiles properly under JDK 7 3452425
       * Added a test to cover long string case in bug 3441059
       * Replace sun.awt code in EventDispatchExceptionHandler with
         more modern Thread.setUncaught... bug 3441725

Modified Paths:
--------------
   abbot/trunk/ChangeLog
   abbot/trunk/projects/jdeveloper/Library/Library.jpr
   abbot/trunk/projects/jdeveloper/Tests/Tests.jpr
   abbot/trunk/src/abbot/tester/ImageComparator.java
   abbot/trunk/src/abbot/tester/JTableTester.java
   abbot/trunk/src/abbot/util/EDTExceptionCatcher.java
   abbot/trunk/src/abbot/util/EventDispatchExceptionHandler.java
   abbot/trunk/test/abbot/tester/JTableTesterTest.java
   abbot/trunk/test/abbot/util/EventDispatchExceptionHandlerTest.java
   abbot/trunk/test/junit/extensions/abbot/ComponentTestFixtureTest.java

Modified: abbot/trunk/ChangeLog
===================================================================
--- abbot/trunk/ChangeLog 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/ChangeLog 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -1,3 +1,16 <at> <at>
+2011-12-12  Gerard Davison
+
+        * Added assertCellExists to JTableTester
+        * Removed old JPEG API's so that the code now compiles properly under JDK 7 3452425
+        * Added a test to cover long string case in bug 3441059
+        * Replace sun.awt code in EventDispatchExceptionHandler with
+          more modern Thread.setUncaught... bug 3441725
+
+2011-*-*    Gerard Davison
+
+        * updated abbot to 1.2RC to use modern API, require JDK 7
+        * integrating a whole heap of bug fixed from Oracle interal branch.
+
2005-12-04  Timothy Wall  <twall <at> users.sf.net>

* build.xml: Exclude tests from clover reports.

Modified: abbot/trunk/projects/jdeveloper/Library/Library.jpr
===================================================================
--- abbot/trunk/projects/jdeveloper/Library/Library.jpr 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/projects/jdeveloper/Library/Library.jpr 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -7,14 +7,16 <at> <at>
      <value n="oracle.adfdtinternal.model.ide.security.wizard.JpsFilterMigrator" v="11.1.1.1.0"/>
      <value n="oracle.adfdtinternal.view.common.migration.wizards.MigrationHelper" v="11.1.1.1.0.3"/>
      <value n="oracle.adfdtinternal.view.rich.migration.ComponentIdNodeMigratorHelper" v="11.1.1.1.0.01"/>
+      <value n="oracle.adfdtinternal.view.rich.migration.FacesLibraryVersionMigrator" v="11.1.1.1.0.1"/>
      <value n="oracle.adfdtinternal.view.rich.migration.LibraryVersionMigrator" v="11.1.1.1.0.1"/>
-      <value n="oracle.ide.model.Project" v="12.1.1.0.0"/>
+      <value n="oracle.ide.model.Project" v="12.1.1.0.0;12.1.2.0.0"/>
      <value n="oracle.ide.model.ResourcePathsMigrator" v="11.1.1.1.0"/>
      <value n="oracle.ideimpl.model.TechnologyScopeUpdateMigrator" v="11.1.2.0.0.4"/>
      <value n="oracle.jbo.dt.jdevx.deployment.JbdProjectMigrator" v="11.1.2.0.0"/>
      <value n="oracle.jbo.dt.jdevx.ui.appnav.APProjectMigrator" v="11.1.1.0.1.5"/>
      <value n="oracle.jbo.dt.migrate.ResourceBundlePathMigrator" v="11.1.1.0.1.5"/>
      <value n="oracle.jbo.dt.migration.ServiceInterfaceMigrator" v="11.1.1.1.0"/>
+      <value n="oracle.jdeveloper.dbmodeler.Migration" v="12.1.1.0.0"/>
      <value n="oracle.jdeveloper.library.ProjectLibraryMigrator" v="11.1.1.1.0"/>
      <value n="oracle.jdeveloper.model.OutputDirectoryMigrator" v="11.1.1.1.0"/>
      <value n="oracle.jdevimpl.deploy.DeploymentProfilesMigrator" v="11.1.1.1.0"/>
<at> <at> -22,9 +24,11 <at> <at>
      <value n="oracle.jdevimpl.jsp.JspMigrator" v="11.1.1"/>
      <value n="oracle.jdevimpl.offlinedb.migration.OfflineDBProjectMigrator" v="11.1.1.1.0;12.1.1.0.0"/>
      <value n="oracle.jdevimpl.offlinedb.migration.OfflinePlSqlMigrator" v="11.1.1.1.0"/>
+      <value n="oracle.jdevimpl.resourcebundle.XliffAddin$XliffMigratorHelper" v="11.1.1.1.0"/>
      <value n="oracle.jdevimpl.webapp.jsp.libraries.JspLibraryMigrator" v="11.1.1.1.4"/>
+      <value n="oracle.jdevimpl.webapp.jsp.taglibraries.trinidad.migration.TrinidadLibraryVersionMigrator" v="11.1.1.1.0.1"/>
      <value n="oracle.jdevimpl.webapp.WebAppContentSetNodeMigratorHelper" v="11.1.1"/>
-      <value n="oracle.jdevimpl.webapp.WebAppProjectNodeMigratorHelper" v="11.1.2.0.0"/>
+      <value n="oracle.jdevimpl.webapp.WebAppProjectNodeMigratorHelper" v="11.1.2.0.0;12.1.2.0.0"/>
      <value n="oracle.jdevimpl.webservices.rest.migration.RestLibraryMigrator" v="12.1.1.0.0"/>
      <value n="oracle.jdevimpl.webservices.rest.migration.RestPathMigrator" v="11.1.2.0.0"/>
      <value n="oracle.jdevimpl.xml.wl.WeblogicMigratorHelper" v="11.1.1.1.0"/>
<at> <at> -61,6 +65,7 <at> <at>
               <list n="pattern-filters">
                  <string v="+build.xml"/>
                  <string v="+Makefile"/>
+                  <string v="+ChangeLog"/>
               </list>
               <list n="url-path">
                  <url path="../../../"/>
<at> <at> -81,12 +86,21 <at> <at>
         <string v="XML_SCHEMA"/>
      </list>
   </hash>
+   <hash n="oracle.jdeveloper.ant.AntRunConfiguration">
+      <hash n="jdkVersion">
+         <value n="id" v="1.6.0_27 (Default)"/>
+         <value n="isJDK" v="true"/>
+         <value n="jdkVersion" v="1.6.0_27"/>
+      </hash>
+   </hash>
   <hash n="oracle.jdeveloper.compiler.ant.AntConfiguration">
      <value n="makeTarget" v="default"/>
      <url n="projectBuildfile" path="../../../build.xml"/>
      <list n="targetList">
         <string v="all"/>
         <string v="zip-src"/>
+         <string v="clean"/>
+         <string v="test"/>
      </list>
   </hash>
   <hash n="oracle.jdeveloper.compiler.OjcConfiguration">
<at> <at> -117,11 +131,13 <at> <at>
   <hash n="oracle.jdeveloper.runner.RunConfigurations">
      <hash n="runConfigurationDefinitions">
         <hash n="Default">
+            <value n="compileBeforeRun" v="false"/>
            <value n="custom" v="false"/>
            <value n="name" v="Default"/>
            <hash n="oracle.jdevimpl.runner.debug.DebugConfiguration">
               <value n="tracingExclude" v="sun;sunw"/>
            </hash>
+            <value n="targetURL"/>
         </hash>
      </hash>
   </hash>
<at> <at> -133,6 +149,30 <at> <at>
         </hash>
      </list>
      <hash n="internalDefinitions">
+         <list n="jdkDefinitions">
+            <hash>
+               <list n="classPath">
+                  <url path="../../../../../source_bundles/jdk/jdk1.7.0_01/jre/lib/resources.jar" jar-entry=""/>
+                  <url path="../../../../../source_bundles/jdk/jdk1.7.0_01/jre/lib/rt.jar" jar-entry=""/>
+                  <url path="../../../../../source_bundles/jdk/jdk1.7.0_01/jre/lib/sunrsasign.jar" jar-entry=""/>
+                  <url path="../../../../../source_bundles/jdk/jdk1.7.0_01/jre/lib/jsse.jar" jar-entry=""/>
+                  <url path="../../../../../source_bundles/jdk/jdk1.7.0_01/jre/lib/jce.jar" jar-entry=""/>
+                  <url path="../../../../../source_bundles/jdk/jdk1.7.0_01/jre/lib/charsets.jar" jar-entry=""/>
+                  <url path="../../../../../source_bundles/jdk/jdk1.7.0_01/jre/classes/"/>
+               </list>
+               <value n="description" v="1.7.0_01"/>
+               <list n="docPath">
+                  <url protocol="http" host="download.oracle.com" path="/javase/7/docs/api/"/>
+               </list>
+               <value n="id" v="1.7.0_01"/>
+               <url n="javaExecutable" path="../../../../../source_bundles/jdk/jdk1.7.0_01/bin/java"/>
+               <url n="sdkBinDir" path="../../../../../source_bundles/jdk/jdk1.7.0_01/bin/"/>
+               <list n="sourcePath">
+                  <url path="../../../../../source_bundles/jdk/jdk1.7.0_01/src.zip" jar-entry=""/>
+               </list>
+               <value n="version" v="1.7.0_01"/>
+            </hash>
+         </list>
         <list n="libraryDefinitions">
            <hash>
               <list n="classPath">

Modified: abbot/trunk/projects/jdeveloper/Tests/Tests.jpr
===================================================================
--- abbot/trunk/projects/jdeveloper/Tests/Tests.jpr 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/projects/jdeveloper/Tests/Tests.jpr 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -7,14 +7,16 <at> <at>
      <value n="oracle.adfdtinternal.model.ide.security.wizard.JpsFilterMigrator" v="11.1.1.1.0"/>
      <value n="oracle.adfdtinternal.view.common.migration.wizards.MigrationHelper" v="11.1.1.1.0.3"/>
      <value n="oracle.adfdtinternal.view.rich.migration.ComponentIdNodeMigratorHelper" v="11.1.1.1.0.01"/>
+      <value n="oracle.adfdtinternal.view.rich.migration.FacesLibraryVersionMigrator" v="11.1.1.1.0.1"/>
      <value n="oracle.adfdtinternal.view.rich.migration.LibraryVersionMigrator" v="11.1.1.1.0.1"/>
-      <value n="oracle.ide.model.Project" v="12.1.1.0.0"/>
+      <value n="oracle.ide.model.Project" v="12.1.1.0.0;12.1.2.0.0"/>
      <value n="oracle.ide.model.ResourcePathsMigrator" v="11.1.1.1.0"/>
      <value n="oracle.ideimpl.model.TechnologyScopeUpdateMigrator" v="11.1.2.0.0.4"/>
      <value n="oracle.jbo.dt.jdevx.deployment.JbdProjectMigrator" v="11.1.2.0.0"/>
      <value n="oracle.jbo.dt.jdevx.ui.appnav.APProjectMigrator" v="11.1.1.0.1.5"/>
      <value n="oracle.jbo.dt.migrate.ResourceBundlePathMigrator" v="11.1.1.0.1.5"/>
      <value n="oracle.jbo.dt.migration.ServiceInterfaceMigrator" v="11.1.1.1.0"/>
+      <value n="oracle.jdeveloper.dbmodeler.Migration" v="12.1.1.0.0"/>
      <value n="oracle.jdeveloper.library.ProjectLibraryMigrator" v="11.1.1.1.0"/>
      <value n="oracle.jdeveloper.model.OutputDirectoryMigrator" v="11.1.1.1.0"/>
      <value n="oracle.jdevimpl.deploy.DeploymentProfilesMigrator" v="11.1.1.1.0"/>
<at> <at> -22,9 +24,11 <at> <at>
      <value n="oracle.jdevimpl.jsp.JspMigrator" v="11.1.1"/>
      <value n="oracle.jdevimpl.offlinedb.migration.OfflineDBProjectMigrator" v="11.1.1.1.0;12.1.1.0.0"/>
      <value n="oracle.jdevimpl.offlinedb.migration.OfflinePlSqlMigrator" v="11.1.1.1.0"/>
+      <value n="oracle.jdevimpl.resourcebundle.XliffAddin$XliffMigratorHelper" v="11.1.1.1.0"/>
      <value n="oracle.jdevimpl.webapp.jsp.libraries.JspLibraryMigrator" v="11.1.1.1.4"/>
+      <value n="oracle.jdevimpl.webapp.jsp.taglibraries.trinidad.migration.TrinidadLibraryVersionMigrator" v="11.1.1.1.0.1"/>
      <value n="oracle.jdevimpl.webapp.WebAppContentSetNodeMigratorHelper" v="11.1.1"/>
-      <value n="oracle.jdevimpl.webapp.WebAppProjectNodeMigratorHelper" v="11.1.2.0.0"/>
+      <value n="oracle.jdevimpl.webapp.WebAppProjectNodeMigratorHelper" v="11.1.2.0.0;12.1.2.0.0"/>
      <value n="oracle.jdevimpl.webservices.rest.migration.RestLibraryMigrator" v="12.1.1.0.0"/>
      <value n="oracle.jdevimpl.webservices.rest.migration.RestPathMigrator" v="11.1.2.0.0"/>
      <value n="oracle.jdevimpl.xml.wl.WeblogicMigratorHelper" v="11.1.1.1.0"/>

Modified: abbot/trunk/src/abbot/tester/ImageComparator.java
===================================================================
--- abbot/trunk/src/abbot/tester/ImageComparator.java 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/src/abbot/tester/ImageComparator.java 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -7,10 +7,11 <at> <at>

import abbot.Log;

-import com.sun.image.codec.jpeg.*;

import java.net.URL;

+import javax.imageio.ImageIO;
+
/**
   This code expects the availability of the com.sun.image.codec.jpeg
   extensions from the Sun JDK 1.3 or JRE.
<at> <at> -75,12 +76,10 <at> <at>
    public static void writeJPEG(File file, BufferedImage img)
        throws IOException {
        FileOutputStream os = new FileOutputStream(file);
-        JPEGImageEncoder ie = JPEGCodec.createJPEGEncoder(os);
-        JPEGEncodeParam param = ie.getDefaultJPEGEncodeParam(img);
-        // Lossless, please
-        param.setQuality(1.0f, false);
-        ie.setJPEGEncodeParam(param);
-        ie.encode(img);
+
+        // Replace code with JDK clean code        
+        ImageIO.write(img, "jpeg", os);
+        
        os.close();
    }


Modified: abbot/trunk/src/abbot/tester/JTableTester.java
===================================================================
--- abbot/trunk/src/abbot/tester/JTableTester.java 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/src/abbot/tester/JTableTester.java 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -92,6 +92,47 <at> <at>
        actionClick(c, loc);
    }

+    /**
+     * <at> param c The table to test
+     * <at> param loc The location to assert exists
+     */
+    public boolean assertCellExists(Component c, final JTableLocation loc) {
+        return assertCellExists(c, loc, componentDelay);
+    }
+
+    /**
+     * <at> param c The table to test
+     * <at> param loc The location to assert
+     * <at> param timeout The timeout to use, tends to be low in negative cases
+     */
+    public boolean assertCellExists(Component c, final JTableLocation loc, int timeout) {
+       final JTable table = (JTable)c;
+       
+       final JTableLocation.Cell found[] = new JTableLocation.Cell[1];
+       try {
+           wait(new Condition()
+               {
+                   public boolean test() {
+                       try{
+                           found[0] = loc.getCell(table);
+                           return found[0]!=null;
+                       }
+                       catch (LocationUnavailableException lue) {
+                           return false;
+                       }
+                   }
+                   public String toString() {
+                       return Strings.get("tester.Component.show_wait",
+                                          new Object[] { loc.toString() });
+                   }
+               }, timeout);
+           return true;
+       } catch(WaitTimedOutError e) {
+           return false;
+       }
+    }
+
+
    /** Select the given cell, if not already.
        Equivalent to actionSelectCell(c, new JTableLocation(row, col)).
     */

Modified: abbot/trunk/src/abbot/util/EDTExceptionCatcher.java
===================================================================
--- abbot/trunk/src/abbot/util/EDTExceptionCatcher.java 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/src/abbot/util/EDTExceptionCatcher.java 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -5,7 +5,10 <at> <at>

import abbot.*;

+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;

+
/** Provide access to the most recent exception caught on the event
    dispatch thread.
 */
<at> <at> -24,25 +27,38 <at> <at>
        <code>null</code> if none has been thrown or the exception has been
        cleared.  Also clears the exception.
    */
-    public synchronized static Throwable getThrowable() {
-        Throwable t = throwable;
-        clear();
-        return t;
+    public static Throwable getThrowable() {
+        
+        synchronized (synchronizedBlock)
+        {
+            Throwable t = throwable;
+            clear();
+            return t;
+        }
    }

    /** Returns when the most recent exception was caught on the dispatch
        thread, or -1 if none has been thrown or the exception has been
        cleared.
    */
-    public synchronized static long getThrowableTime() {
-        return when;
+    public static long getThrowableTime() {
+        synchronized (synchronizedBlock)
+        {
+            return when;
+        }
    }

-    public synchronized static void clear() {
-        throwable = null;
-        when = -1;
+    public static void clear() {
+        synchronized (synchronizedBlock)
+        {
+            throwable = null;
+            when = -1;
+        }
    }

+    /**
+     * Note we are synchronized by synchronizeBlock at this point
+     */
    protected void exceptionCaught(Throwable thr) {
        if (!(thr instanceof ExitException)) {
            if (System.getProperty("java.class.path").indexOf("eclipse") != -1) {

Modified: abbot/trunk/src/abbot/util/EventDispatchExceptionHandler.java
===================================================================
--- abbot/trunk/src/abbot/util/EventDispatchExceptionHandler.java 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/src/abbot/util/EventDispatchExceptionHandler.java 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -6,118 +6,164 <at> <at>

import abbot.Log;

-/** Handler for uncaught exceptions on any event dispatch thread.
-    Once this has been installed, the class must be accessible by any
-    subsequently launched dispatch thread.<p>
+import java.lang.reflect.InvocationTargetException;

-    This handler is installed by setting the System property
-    sun.awt.exception.handler.  See javadoc for java.awt.EventDispatchThread
-    for details.  This is sort of a patch to Sun's implementation, which only
-    checks the property once and caches the result ever after.  This
-    implementation will always chain to the handler indicated by the current
-    value of the property.<p>
+import java.security.AccessController;
+import java.security.PrivilegedAction;

-    It is most definitely NOT safe to try to install several of these on
-    different threads.
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Handler for uncaught exceptions on any event dispatch thread.<p>
+ * It now uses the Thread.UncaughtExceptionHandler class which introduces
+ * a minor issue in that when this is called the current event queue object
+ * has already been replaced by a new instance. (See the source code for
+ * { <at> link java.awt.EventDispatchThread#run} for more information). To work around
+ * this a shared synchronization object has been added, although a read/write lock
+ * would also have been a possible design and should be considered if a time out
+ * ends up being required.
 */
public class EventDispatchExceptionHandler {
-    /** See javadoc for java.awt.EventDispatchThread. */
-    public static final String PROP_NAME = "sun.awt.exception.handler";

    private static boolean installed = false;
    private static boolean canInstall = true;
+    /**
+     * Allows sychronization between the current queue and the exception handler
+     * queue of which the only thing we know for sure is that it is definitely not
+     * the AWT event queue, if it ever was.
+     */
+    private static CountDownLatch instalLatch = new CountDownLatch(1);
+    
+    /**
+     * We need to make sure that we can't query the state of the hander while we are dealing with an exception
+     */
+    protected static Object synchronizedBlock = new Object() {};
+    
+    private static Thread.UncaughtExceptionHandler existingHandler;

-    /** Install a handler for event dispatch exceptions.  This is kind
-        of a hack, but it's Sun's hack.
-        See the javadoc for java.awt.EventDispatchThread for details.
-        NOTE: we throw an exception immediately, which
-        ensures that our handler is installed, since otherwise
-        someone might set this property later.
-        java.awt.EventDispatchThread doesn't actually load the handler
-        specified by the property until an exception is caught by the
-        event dispatch thread.  SwingSet2 in 1.4.1 installs its own.
-        Note that a new instance is created for each exception thrown.
+    public void install() {

-         <at> throws RuntimeException if the handler cannot be installed.
-         <at> throws IllegalStateException if this method is invoked from an event
-        dispatch thread.
-         <at> throws IllegalArgumentException if the given class is not derived
-        from this one.
-
-        // TODO: read the private static field
-        // String EventDispatchThread.handlerClassName and override it if
-        // necessary.
-    */
-    public void install() {
        if (SwingUtilities.isEventDispatchThread()) {
            throw new IllegalStateException("Handler must not be installed from the event dispatch thread");
        }

-        Class cls = getClass();
-        final String className = cls.getName();
-        try {
-            cls.newInstance();
-        }
-        catch(Exception e) {
-            String msg = "Exception handler ("
-                + cls + ") must have an accessible no-args Constructor: " + e;
-            throw new IllegalArgumentException(msg);
-        }
-        if (installed) {
-            // If we've already installed an instance of
-            // this handler, all we need to do is set the
-            // property name.
-            Log.debug("Exception handler class already installed");
-            System.setProperty(PROP_NAME, className);
-        }
-        else if (!canInstall) {
+    
+        if (!canInstall) {
            Log.warn("Can't install event dispatch exception handler");
        }
-        else {
-            Log.log("Attempting to install handler " + className);
-            class PropertiesHolder {
-                /** Preserve the system properties state. */
-                public java.util.Properties properties = null;
-            }
-            final PropertiesHolder holder = new PropertiesHolder();
-            // Even if it's been set to something else, we can override it
-            // if there hasn't been an event exception thrown yet.
-            EventQueue.invokeLater(new Runnable() {
-                public void run() {
-                    holder.properties = (java.util.Properties)
-                        System.getProperties().clone();
-                    // Set the property just before throwing the exception;
-                    // OSX sets the property as part of AWT startup, so
-                    // we have to override it here.
-                    System.setProperty(PROP_NAME, className);
-                    throw new DummyException();
+        else if (!installed)
+        {
+            existingHandler = Thread.getDefaultUncaughtExceptionHandler();
+
+
+            final Thread.UncaughtExceptionHandler swingOnly = new Thread.UncaughtExceptionHandler() {
+                 <at> Override
+                public void uncaughtException(Thread t, Throwable e) {
+
+                    synchronized (synchronizedBlock)
+                    {
+                        // So at this point the original thread has died
+                        // so we would need to be able to add another exception listener to the thread
+                        // that doesn't necessarily exist as yet, so we need to test to see if t is an intance
+                        // of EventDispatchThread
+                        // and make sure that the existing handler is check for the current thread
+                        //
+                        
+                        boolean isWasEDT = false;
+                        
+                        Class $parent = t.getClass();
+                        while ($parent!=null && !isWasEDT) {
+                            String name = $parent.getName();
+                            if ("java.awt.EventDispatchThread".equals(name)) {
+                                isWasEDT = true;
+                            }
+                            $parent = $parent.getSuperclass();
+                        }
+                        
+                        
+                        if (!isWasEDT) {
+                            if (existingHandler!=null)
+                            {
+                                existingHandler.uncaughtException(t,e);
+                            }
+                            else {
+                                e.printStackTrace();
+                            }
+                        }
+                        
+                        
+                        
+    
+                        // The exception may be created by a different class loader
+                        // so compare by name only
+                        if (e instanceof DummyException) {
+                            // Install succeeded
+                            Log.debug("Installation succeeded");
+                            installed = true;
+                            instalLatch.countDown();
+                            return;
+                        }
+    
+                        
+                        // We are assuming that the current thread is the EDT, so delegate to
+                        // the existing handler is required
+                        
+                        if (existingHandler!=null) {
+                            existingHandler.uncaughtException(t, e);
+                        }
+                        else  {
+                            handle(e);
+                        }
+                    }
                }
-            });
-            // Does nothing but wait for the previous invocation to finish
-            AWT.invokeAndWait(new Runnable() { public void run() { } });
-            System.setProperties(holder.properties);
-            String oldHandler = System.getProperty(PROP_NAME);
-            
-            if (installed) {
-                if (oldHandler != null) {
-                    Log.debug("Replaced an existing event exception handler ("
-                              + oldHandler + ")");
+            };
+
+            try {
+
+                Thread.currentThread().setDefaultUncaughtExceptionHandler(swingOnly);
+                
+                // Check we can catch the dummy exception
+                //
+                EventQueue.invokeLater(new Runnable() {
+                    public void run() {
+                        throw new DummyException();
+                    }
+                });
+                // Does nothing but wait for the previous invocation to finish
+                AWT.invokeAndWait(new Runnable() { public void run() { } });
+                
+                if (instalLatch.await(30, TimeUnit.SECONDS) &&
+                    installed) {
+                    // Horrah we are good to go
+                    int i = 9;
                }
-            }
-            else {
+                else {
+                    //
+                    canInstall = false;
+                }
+                
+            } catch (Exception e)  {
+                installed = false;
                canInstall = false;
+
                String msg = "The handler for event "
                    + "dispatch thread exceptions could not be installed";
-                if (oldHandler != null) {
-                    msg += " (" + oldHandler + " has already been "
-                        + "set and cached; there is no way to override it)";
-                }
-                Log.warn(msg);
-                throw new RuntimeException(msg);
+                Log.warn(msg, e);
+                throw new RuntimeException(msg, e);
+
            }
        }
+        else {
+            // We are fine, don't install again
+            //
+
+            Log.debug("Exception handler class already installed");
+        }
+        
+        
    }
-
+    
    /** Define this to handle the exception as needed.  
     * Default prints a warning to System.err.
     */
<at> <at> -128,38 +174,13 <at> <at>
    /** Handle exceptions thrown on the event dispatch thread. */
    public void handle(Throwable thrown) {
        Log.debug("Handling event dispatch exception: " + thrown);
-        String handler = System.getProperty(PROP_NAME);
-        boolean handled = false;
-        if (handler != null && !handler.equals(getClass().getName())) {
-            Log.debug("A user exception handler ("
-                      + handler + ") has been set, invoking it");
-            try {
-                ClassLoader cl =
-                    Thread.currentThread().getContextClassLoader();
-                Class c = Class.forName(handler, true, cl);
-                c.getMethod("handle", new Class[] { Throwable.class }).
-                    invoke(c.newInstance(), new Object[] { thrown });
-                handled = true;
-            }
-            catch(Throwable e) {
-                Log.warn("Could not invoke user handler: " + e);
-            }
+
+        {
+            Log.debug("Handling exception on event dispatch thread: "
+                      + thrown + " with " + getClass());
+            Log.debug(thrown);
+            exceptionCaught(thrown);
        }
-        // The exception may be created by a different class loader
-        // so compare by name only
-        if (thrown instanceof DummyException) {
-            // Install succeeded
-            Log.debug("Installation succeeded");
-            installed = true;
-        }
-        else {
-            if (!handled) {
-                Log.debug("Handling exception on event dispatch thread: "
-                          + thrown + " with " + getClass());
-                Log.debug(thrown);
-                exceptionCaught(thrown);
-            }
-        }
        Log.debug("Handling done");
    }


Modified: abbot/trunk/test/abbot/tester/JTableTesterTest.java
===================================================================
--- abbot/trunk/test/abbot/tester/JTableTesterTest.java 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/test/abbot/tester/JTableTesterTest.java 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -2,11 +2,15 <at> <at>

import java.awt.Component;
import java.awt.Dimension;
+import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import java.util.Vector;

+import java.util.concurrent.TimeUnit;
+
+import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
<at> <at> -44,7 +48,7 <at> <at>
        };
        String[] names = { "one", "two", "three", "four" };
        table = new JTable(new DefaultTableModel(data, names));
-        scroll = new JScrollPane(table);
+        scroll = new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
        tester = new JTableTester();
    }

<at> <at> -89,6 +93,68 <at> <at>
        assertEquals("Wrong column selected", 0, table.getSelectedColumn());

    }
+
+    /**
+     * Verify we can deal with the case where the string exceeds the visible space
+     */
+    public void testSelectHugeString() throws Exception {
+        
+        // Make sure that the viewport is much bigger than the table cell in question
+        table.setMinimumSize(new Dimension(700,300));
+        JPanel largePanel = new JPanel(new FlowLayout());
+        largePanel.add(table);
+        scroll.setViewportView(largePanel);
+        
+        // Show the frame
+        showFrame(scroll);
+        
+        final DefaultTableModel dtm = (DefaultTableModel)table.getModel();
+
+        // Add an item two seconds later
+        //
+
+        String longString = "this is a really long section of text that means that the middle co-ordinate just isn't ever going to be visible";
+        dtm.removeRow(0);
+        dtm.removeRow(0);
+        dtm.removeRow(0);
+        dtm.removeRow(0);
+        dtm.addRow(new Object[] {"new value", "", "",  longString });
+        
+        table.getTableHeader().getColumnModel().getColumn(3)
+            .setMinWidth(500);
+        table.invalidate();
+        
+        // Now try to select
+        //
+                        
+        
+        tester.actionSelectCell(
+            table,
+            new JTableLocation(longString));
+        
+        assertEquals("Wrong row selected", 0, table.getSelectedRow());
+        assertEquals("Wrong column selected", 3, table.getSelectedColumn());
+        
+    }
+
+
+    public void testAssertCellsPresent() {
+        showFrame(scroll);
+        
+        final DefaultTableModel dtm = (DefaultTableModel)table.getModel();
+
+        // Now try to select
+        //
+                        
+        
+        
+        assertTrue("Should have found 0 one", tester.assertCellExists(table, new JTableLocation("0 one")));
+        assertTrue("Should have found 3 four", tester.assertCellExists(table, new JTableLocation("3 four")));
+        
+        assertFalse("Shouldn't have found 4 five", tester.assertCellExists(table, new JTableLocation("4 five"), 100));
+        assertFalse("Shouldn't have found dog", tester.assertCellExists(table, new JTableLocation("dog"), 100));
+
+    }


    /** Ensure scrolling works. */

Modified: abbot/trunk/test/abbot/util/EventDispatchExceptionHandlerTest.java
===================================================================
--- abbot/trunk/test/abbot/util/EventDispatchExceptionHandlerTest.java 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/test/abbot/util/EventDispatchExceptionHandlerTest.java 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -46,26 +46,26 <at> <at>
        assertNotNull("No exception caught", Catcher.throwable);
    }

-    /** Ensure subsequently set handlers will get called. */
-    public void testForwardException() throws Throwable {
-        // ensure the standard handler is always installed first
-        new Catcher().install();
-        Catcher.throwable = null;
-        SampleCatcher.throwable = null;
-        System.setProperty(EventDispatchExceptionHandler.PROP_NAME,
-                           SampleCatcher.class.getName());
-        EventQueue.invokeLater(new Runnable() {
-            public void run() {
-                throw new RuntimeException("Test exception for " + getName());
-            }
-        });
-        EventQueue.invokeAndWait(empty);
-        // Only one handler can be installed at a time, so if there was
-        // already a handler installed, this handler won't see the
-        // exception.
-        //assertNotNull("No exception caught", Catcher.throwable);
-        assertNotNull("Exception not forwarded", SampleCatcher.throwable);
-    }
+//    /** Ensure subsequently set handlers will get called. */
+//    public void testForwardException() throws Throwable {
+//        // ensure the standard handler is always installed first
+//        new Catcher().install();
+//        Catcher.throwable = null;
+//        SampleCatcher.throwable = null;
+//        System.setProperty(EventDispatchExceptionHandler.PROP_NAME,
+//                           SampleCatcher.class.getName());
+//        EventQueue.invokeLater(new Runnable() {
+//            public void run() {
+//                throw new RuntimeException("Test exception for " + getName());
+//            }
+//        });
+//        EventQueue.invokeAndWait(empty);
+//        // Only one handler can be installed at a time, so if there was
+//        // already a handler installed, this handler won't see the
+//        // exception.
+//        //assertNotNull("No exception caught", Catcher.throwable);
+//        assertNotNull("Exception not forwarded", SampleCatcher.throwable);
+//    }

    public EventDispatchExceptionHandlerTest(String name) {
        super(name);

Modified: abbot/trunk/test/junit/extensions/abbot/ComponentTestFixtureTest.java
===================================================================
--- abbot/trunk/test/junit/extensions/abbot/ComponentTestFixtureTest.java 2011-11-22 18:02:37 UTC (rev 2810)
+++ abbot/trunk/test/junit/extensions/abbot/ComponentTestFixtureTest.java 2011-12-16 12:18:04 UTC (rev 2811)
<at> <at> -237,7 +237,7 <at> <at>
        public void testCatchEventThreadException() throws Throwable {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
-                    throw edtException;
+                        throw edtException;
                }
            });
            SwingUtilities.invokeAndWait(new Runnable() {

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
abbot-commits mailing list
abbot-commits <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/abbot-commits

------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
abbot-users mailing list
abbot-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/abbot-users
SourceForge.net | 21 Dec 08:38 2011
Picon
Picon

[Developers] RE: launch abbot scripts on a server when commit

The following forum message was posted by nikhilkr1984 at http://sourceforge.net/projects/abbot/forums/forum/168263/topic/3401336:

Assume you have prepared the script (ie: xml file) using Abbot. Follow the 3
steps to run it automatically.

1. Create a class like below for initiating your test.

[code]

package sample.test;

import java.io.File;
import junit.extensions.abbot.ScriptTestSuite;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.textui.TestRunner;
import abbot.Log;
import abbot.finder.AWTHierarchy;
import abbot.finder.Hierarchy;
import abbot.finder.TestHierarchy;
import abbot.script.Script;
import abbot.script.StepRunner;
import abbot.util.AWTFixtureHelper;

public class AbbotStarter extends ScriptFixture
{
	static String ABBOT_SCRIPT_HOME ;

	public AbbotStarter(String name)
	{
		super(name);
	}

	public static Test suite()
	{
		return new ScriptTestSuite(AbbotStarter.class, ABBOT_SCRIPT_HOME);
	}

	public static void main(String[] args)
	{
               if(args.length<1)
		{
			System.out.println("Usage : sample.test.AbbotStarter <Abbot-Script-home>");
			return;
		}
                ABBOT_SCRIPT_HOME = args[0];
		TestRunner.run(AbbotStarter.suite());
		new File(burbLog).delete();
	}

}

class ScriptFixture extends TestCase
{

	private static AWTFixtureHelper oldContext = null;
	private static final Hierarchy DUMMY_HIERARCHY = new AWTHierarchy();
	private StepRunner runner;

	/**
	 * Construct a test case with the given name, which <i>must</i> be the
	 * filename of the script to run.
	 */
	public ScriptFixture(String filename)
	{
		// It is essential that the name be passed to super() unmodified, or
		// the JUnit GUI will consider it a different test.
		super(filename);
	}

	/**
	 * Saves the current UI state for restoration when the fixture (if any) is
	 * terminated. Also sets up a { <at> link TestHierarchy} for the duration of the
	 * test.
	 */
	protected void setUp() throws Exception
	{
		if (oldContext == null)
		{
			oldContext = new AWTFixtureHelper();
		}
		runner = new StepRunner(oldContext);
		// Support for deprecated ComponentTester.assertFrameShowing usage
		// only. Eventually this will go away.
		AWTHierarchy.setDefault(runner.getHierarchy());
	}

	protected void tearDown() throws Exception
	{
		AWTHierarchy.setDefault(null);
		runner = null;
	}

	/**
	 * Override the default TestCase runTest method to invoke the script. The
	 * { <at> link Script} is created and a default { <at> link StepRunner} is used to run
	 * it.
	 * 
	 *  <at> see junit.framework.TestCase#runTest
	 */
	protected void runTest() throws Throwable
	{
         	Script script = new Script(getName(), DUMMY_HIERARCHY);
		Log.log("Running " + script + " with " + getClass());

		try
		{
			runner.run(script);
		}
		finally
		{
			Log.log(script.toString() + " finished");
		}
	}
}

[/code]

2. Invoke the above class from a batch file, abbot.bat

[code]

 <at> echo off
title Abbot Runner

set CP=-classpath 
set CP=%CP%./lib/abbot.jar;
set CP=%CP%./lib/burpsuite_v1.4.01.jar;
set CP=%CP%./lib/costello.jar;
set CP=%CP%./lib/commons-logging-1.1.1.jar;
set CP=%CP%./lib/jdom-1.1.1.jar;
set CP=%CP%./lib/junit-4.8.2.jar;
set CP=%CP%./AbbotTestRunner.jar

java %CP% sample.test.AbbotStarter
[/code]

3. Run your application as  "abbot.bat my_automation.xml"

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
SourceForge.net | 21 Dec 10:17 2011
Picon
Picon

[Developers] RE: New AbbotRunners for junit4

The following forum message was posted by gdavison at http://sourceforge.net/projects/abbot/forums/forum/168263/topic/3523167:

Tis is now resolved in abbot 1.2

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
Gerard Davison | 21 Dec 11:21 2011
Picon

Abbot 1.2 Released


Get it while it is warm:

http://abbot.sourceforge.net/doc/RELNOTES.shtml

http://sourceforge.net/projects/abbot/files/abbot/1.2/

Thanks,

Gerard

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
xiaokun | 27 Dec 06:50 2011
Picon

About the usage of the abbot.

hi all,
 
I am new to abbot.
I wonder if i could start two or more jars at one time with the costello. Because in some cases, i must do some other operations with other to be tested tools. Or i may use another tool to check whether i works after the main task.
And just though to add classpaths to make it work or something else? but how to deal with the main method?
 
Also i want to know the usage of checkbow "threaded lunch".
May u can describe it steply, It will be helpful.
Thank you!
 
ps: The document about the abbot is so limitted. what a pity.
Best Regards.
Sean
------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
abbot-users mailing list
abbot-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/abbot-users
xiaokun | 31 Dec 07:13 2011
Picon

Can't find the class ScriptTestSuite!!

hi all,


I added the abbot.jar to the library. But why I can't use the class ScriptTestSuite?

Best Regards,

Sean
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
abbot-users mailing list
abbot-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/abbot-users
xiaokun | 31 Dec 09:12 2011
Picon

Re: Can't find the class ScriptTestSuite!!

Okay, It's in the costello.jar...ORZ

2011/12/31 xiaokun <xiaokunhou <at> gmail.com>
hi all,

I added the abbot.jar to the library. But why I can't use the class ScriptTestSuite?

Best Regards,

Sean

------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
abbot-users mailing list
abbot-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/abbot-users

Gmane