org.eclipse.pde.junit.runtime_3.4.100.v20110928-1516

16:47:27.553 INFO  jd.cli.Main - Decompiling org.eclipse.pde.junit.runtime_3.4.100.v20110928-1516.jar
package org.eclipse.pde.internal.junit.runtime;

import org.eclipse.core.runtime.IPlatformRunnable;

public class CoreTestApplication
  implements IPlatformRunnable
{
  public Object run(Object arguments)
    throws Exception
  {
    RemotePluginTestRunner.main((String[])arguments);
    return null;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.CoreTestApplication
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

import org.eclipse.core.runtime.Platform;

class LegacyUITestApplication$1
  implements Runnable
{
  final LegacyUITestApplication this$0;
  
  LegacyUITestApplication$1(LegacyUITestApplication paramLegacyUITestApplication)
  {
    this$0 = paramLegacyUITestApplication;
  }
  
  public void run()
  {
    RemotePluginTestRunner.main(Platform.getCommandLineArgs());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.LegacyUITestApplication.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

import junit.framework.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.testing.ITestHarness;
import org.eclipse.ui.testing.TestableObject;

public class LegacyUITestApplication
  implements IPlatformRunnable, ITestHarness
{
  private static final String DEFAULT_APP_3_0 = "org.eclipse.ui.ide.workbench";
  private TestableObject fTestableObject;
  
  public Object run(Object args)
    throws Exception
  {
    IPlatformRunnable application = getApplication((String[])args);
    
    Assert.assertNotNull(application);
    
    fTestableObject = PlatformUI.getTestableObject();
    fTestableObject.setTestHarness(this);
    return application.run(args);
  }
  
  private IPlatformRunnable getApplication(String[] args)
    throws CoreException
  {
    IExtension extension = Platform.getExtensionRegistry().getExtension("org.eclipse.core.runtime", "applications", getApplicationToRun(args));
    
    Assert.assertNotNull(extension);
    
    IConfigurationElement[] elements = extension.getConfigurationElements();
    if (elements.length > 0)
    {
      IConfigurationElement[] runs = elements[0].getChildren("run");
      if (runs.length > 0)
      {
        Object runnable = runs[0].createExecutableExtension("class");
        if ((runnable instanceof IPlatformRunnable)) {
          return (IPlatformRunnable)runnable;
        }
      }
    }
    return null;
  }
  
  private String getApplicationToRun(String[] args)
  {
    IProduct product = Platform.getProduct();
    if (product != null) {
      return product.getApplication();
    }
    for (int i = 0; i < args.length; i++) {
      if ((args[i].equals("-testApplication")) && (i < args.length - 1)) {
        return args[(i + 1)];
      }
    }
    return "org.eclipse.ui.ide.workbench";
  }
  
  public void runTests()
  {
    fTestableObject.testingStarting();
    fTestableObject.runTest(new Runnable()
    {
      public void run()
      {
        RemotePluginTestRunner.main(Platform.getCommandLineArgs());
      }
    });
    fTestableObject.testingFinished();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.LegacyUITestApplication
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

import java.lang.reflect.Method;
import java.util.Map;
import junit.framework.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IPlatformRunnable;
import org.eclipse.core.runtime.IProduct;
import org.eclipse.core.runtime.Platform;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;

public class NonUIThreadTestApplication
  implements IApplication
{
  private static final String DEFAULT_HEADLESSAPP = "org.eclipse.pde.junit.runtime.coretestapplication";
  protected IApplication fApplication;
  protected Object fTestHarness;
  
  public Object start(IApplicationContext context)
    throws Exception
  {
    String[] args = (String[])context.getArguments().get("application.args");
    
    String appId = getApplicationToRun(args);
    Object app = getApplication(appId);
    
    Assert.assertNotNull(app);
    if (!"org.eclipse.pde.junit.runtime.coretestapplication".equals(appId)) {
      installPlatformUITestHarness();
    }
    return runApp(app, context, args);
  }
  
  protected Object runApp(Object app, IApplicationContext context, String[] args)
    throws Exception
  {
    if ((app instanceof IApplication))
    {
      fApplication = ((IApplication)app);
      return fApplication.start(context);
    }
    return ((IPlatformRunnable)app).run(args);
  }
  
  private void installPlatformUITestHarness()
    throws Exception
  {
    try
    {
      Class platformUIClass = Class.forName("org.eclipse.ui.PlatformUI", true, getClass().getClassLoader());
      Object testableObject = platformUIClass.getMethod("getTestableObject", null).invoke(null, null);
      fTestHarness = new PlatformUITestHarness(testableObject, true);
    }
    catch (ClassNotFoundException localClassNotFoundException) {}
  }
  
  public void stop()
  {
    if (fApplication != null) {
      fApplication.stop();
    }
    if (fTestHarness != null) {
      fTestHarness = null;
    }
  }
  
  private Object getApplication(String appId)
    throws CoreException
  {
    IExtension extension = Platform.getExtensionRegistry().getExtension("org.eclipse.core.runtime", "applications", appId);
    
    Assert.assertNotNull(extension);
    
    IConfigurationElement[] elements = extension.getConfigurationElements();
    if (elements.length > 0)
    {
      IConfigurationElement[] runs = elements[0].getChildren("run");
      if (runs.length > 0)
      {
        Object runnable = runs[0].createExecutableExtension("class");
        if (((runnable instanceof IPlatformRunnable)) || ((runnable instanceof IApplication))) {
          return runnable;
        }
      }
    }
    return null;
  }
  
  private String getApplicationToRun(String[] args)
  {
    for (int i = 0; i < args.length; i++) {
      if ((args[i].equals("-testApplication")) && (i < args.length - 1)) {
        return args[(i + 1)];
      }
    }
    IProduct product = Platform.getProduct();
    if (product != null) {
      return product.getApplication();
    }
    return getDefaultApplicationId();
  }
  
  protected String getDefaultApplicationId()
  {
    return "org.eclipse.pde.junit.runtime.coretestapplication";
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

import org.eclipse.core.runtime.Platform;

class PlatformUITestHarness$1
  implements Runnable
{
  final PlatformUITestHarness this$0;
  
  PlatformUITestHarness$1(PlatformUITestHarness paramPlatformUITestHarness)
  {
    this$0 = paramPlatformUITestHarness;
  }
  
  public void run()
  {
    RemotePluginTestRunner.main(Platform.getCommandLineArgs());
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.1
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

class PlatformUITestHarness$2
  implements Runnable
{
  final PlatformUITestHarness this$0;
  private final Thread val$testRunnerThread;
  
  PlatformUITestHarness$2(PlatformUITestHarness paramPlatformUITestHarness, Thread paramThread)
  {
    this$0 = paramPlatformUITestHarness;val$testRunnerThread = paramThread;
  }
  
  public void run()
  {
    val$testRunnerThread.start();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness.2
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

import org.eclipse.core.runtime.Platform;
import org.eclipse.ui.testing.ITestHarness;
import org.eclipse.ui.testing.TestableObject;

public class PlatformUITestHarness
  implements ITestHarness
{
  private TestableObject fTestableObject;
  private final boolean fRunTestsInSeparateThread;
  
  public PlatformUITestHarness(Object testableObject, boolean runTestsInSeparateThread)
  {
    fRunTestsInSeparateThread = runTestsInSeparateThread;
    fTestableObject = ((TestableObject)testableObject);
    fTestableObject.setTestHarness(this);
  }
  
  /* Error */
  public void runTests()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 63	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness:fTestableObject	Lorg/eclipse/ui/testing/TestableObject;
    //   4: invokevirtual 72	org/eclipse/ui/testing/TestableObject:testingStarting	()V
    //   7: new 33	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness$1
    //   10: dup
    //   11: aload_0
    //   12: invokespecial 69	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness$1:<init>	(Lorg/eclipse/pde/internal/junit/runtime/PlatformUITestHarness;)V
    //   15: astore_1
    //   16: aload_0
    //   17: getfield 62	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness:fRunTestsInSeparateThread	Z
    //   20: ifeq +47 -> 67
    //   23: new 31	java/lang/Thread
    //   26: dup
    //   27: aload_1
    //   28: ldc 1
    //   30: invokespecial 68	java/lang/Thread:<init>	(Ljava/lang/Runnable;Ljava/lang/String;)V
    //   33: astore_2
    //   34: aload_0
    //   35: getfield 63	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness:fTestableObject	Lorg/eclipse/ui/testing/TestableObject;
    //   38: new 34	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness$2
    //   41: dup
    //   42: aload_0
    //   43: aload_2
    //   44: invokespecial 70	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness$2:<init>	(Lorg/eclipse/pde/internal/junit/runtime/PlatformUITestHarness;Ljava/lang/Thread;)V
    //   47: invokevirtual 73	org/eclipse/ui/testing/TestableObject:runTest	(Ljava/lang/Runnable;)V
    //   50: aload_2
    //   51: invokevirtual 66	java/lang/Thread:join	()V
    //   54: goto +34 -> 88
    //   57: pop
    //   58: invokestatic 67	java/lang/Thread:currentThread	()Ljava/lang/Thread;
    //   61: invokevirtual 65	java/lang/Thread:interrupt	()V
    //   64: goto +24 -> 88
    //   67: aload_0
    //   68: getfield 63	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness:fTestableObject	Lorg/eclipse/ui/testing/TestableObject;
    //   71: aload_1
    //   72: invokevirtual 73	org/eclipse/ui/testing/TestableObject:runTest	(Ljava/lang/Runnable;)V
    //   75: goto +13 -> 88
    //   78: astore_3
    //   79: aload_0
    //   80: getfield 63	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness:fTestableObject	Lorg/eclipse/ui/testing/TestableObject;
    //   83: invokevirtual 71	org/eclipse/ui/testing/TestableObject:testingFinished	()V
    //   86: aload_3
    //   87: athrow
    //   88: aload_0
    //   89: getfield 63	org/eclipse/pde/internal/junit/runtime/PlatformUITestHarness:fTestableObject	Lorg/eclipse/ui/testing/TestableObject;
    //   92: invokevirtual 71	org/eclipse/ui/testing/TestableObject:testingFinished	()V
    //   95: return
    // Line number table:
    //   Java source line #42	-> byte code offset #0
    //   Java source line #45	-> byte code offset #7
    //   Java source line #51	-> byte code offset #16
    //   Java source line #53	-> byte code offset #23
    //   Java source line #54	-> byte code offset #34
    //   Java source line #63	-> byte code offset #50
    //   Java source line #64	-> byte code offset #57
    //   Java source line #65	-> byte code offset #58
    //   Java source line #69	-> byte code offset #67
    //   Java source line #71	-> byte code offset #78
    //   Java source line #73	-> byte code offset #79
    //   Java source line #74	-> byte code offset #86
    //   Java source line #73	-> byte code offset #88
    //   Java source line #75	-> byte code offset #95
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	96	0	this	PlatformUITestHarness
    //   15	57	1	testsRunner	Runnable
    //   33	18	2	testRunnerThread	Thread
    //   78	9	3	localObject	Object
    //   57	1	4	localInterruptedException	InterruptedException
    // Exception table:
    //   from	to	target	type
    //   50	54	57	java/lang/InterruptedException
    //   0	78	78	finally
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.PlatformUITestHarness
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import org.osgi.framework.Bundle;

class RemotePluginTestRunner$BundleClassLoader
  extends ClassLoader
{
  private Bundle bundle;
  final RemotePluginTestRunner this$0;
  
  public RemotePluginTestRunner$BundleClassLoader(RemotePluginTestRunner paramRemotePluginTestRunner, Bundle target)
  {
    this$0 = paramRemotePluginTestRunner;
    bundle = target;
  }
  
  protected Class findClass(String name)
    throws ClassNotFoundException
  {
    return bundle.loadClass(name);
  }
  
  protected URL findResource(String name)
  {
    return bundle.getResource(name);
  }
  
  protected Enumeration findResources(String name)
    throws IOException
  {
    return bundle.getResources(name);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.BundleClassLoader
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

import java.io.IOException;
import java.net.URL;
import java.util.Enumeration;
import java.util.Locale;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.internal.junit.runner.RemoteTestRunner;
import org.osgi.framework.Bundle;

public class RemotePluginTestRunner
  extends RemoteTestRunner
{
  private String fTestPluginName;
  private ClassLoader fLoaderClassLoader;
  
  class BundleClassLoader
    extends ClassLoader
  {
    private Bundle bundle;
    
    public BundleClassLoader(Bundle target)
    {
      bundle = target;
    }
    
    protected Class findClass(String name)
      throws ClassNotFoundException
    {
      return bundle.loadClass(name);
    }
    
    protected URL findResource(String name)
    {
      return bundle.getResource(name);
    }
    
    protected Enumeration findResources(String name)
      throws IOException
    {
      return bundle.getResources(name);
    }
  }
  
  public static void main(String[] args)
  {
    RemotePluginTestRunner testRunner = new RemotePluginTestRunner();
    testRunner.init(args);
    testRunner.run();
  }
  
  protected ClassLoader getTestClassLoader()
  {
    String pluginId = fTestPluginName;
    return getClassLoader(pluginId);
  }
  
  public ClassLoader getClassLoader(String bundleId)
  {
    Bundle bundle = Platform.getBundle(bundleId);
    if (bundle == null) {
      throw new IllegalArgumentException("Bundle \"" + bundleId + "\" not found. Possible causes include missing dependencies, too restrictive version ranges, or a non-matching required execution environment.");
    }
    return new BundleClassLoader(bundle);
  }
  
  public void init(String[] args)
  {
    readPluginArgs(args);
    defaultInit(args);
  }
  
  public void readPluginArgs(String[] args)
  {
    for (int i = 0; i < args.length; i++)
    {
      if (isFlag(args, i, "-testpluginname")) {
        fTestPluginName = args[(i + 1)];
      }
      if (isFlag(args, i, "-loaderpluginname")) {
        fLoaderClassLoader = getClassLoader(args[(i + 1)]);
      }
    }
    if (fTestPluginName == null) {
      throw new IllegalArgumentException("Parameter -testpluginnname not specified.");
    }
    if (fLoaderClassLoader == null) {
      fLoaderClassLoader = getClass().getClassLoader();
    }
  }
  
  protected Class loadTestLoaderClass(String className)
    throws ClassNotFoundException
  {
    return fLoaderClassLoader.loadClass(className);
  }
  
  private boolean isFlag(String[] args, int i, String wantedFlag)
  {
    String lowerCase = args[i].toLowerCase(Locale.ENGLISH);
    return (lowerCase.equals(wantedFlag)) && (i < args.length - 1);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.pde.internal.junit.runtime;

import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.ui.PlatformUI;

public class UITestApplication
  extends NonUIThreadTestApplication
{
  private static final String DEFAULT_APP_3_0 = "org.eclipse.ui.ide.workbench";
  
  protected String getDefaultApplicationId()
  {
    return "org.eclipse.ui.ide.workbench";
  }
  
  protected Object runApp(Object app, IApplicationContext context, String[] args)
    throws Exception
  {
    fTestHarness = new PlatformUITestHarness(PlatformUI.getTestableObject(), false);
    
    return super.runApp(app, context, args);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.pde.internal.junit.runtime.UITestApplication
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd