Revision: 8441
Author: [email protected]
Date: Thu Jul 29 09:26:40 2010
Log: Refactoring to one top level class per .java file, since some
tools don't understand more than that.

Review by: jat

Review at http://gwt-code-reviews.appspot.com/686801

http://code.google.com/p/google-web-toolkit/source/detail?r=8441

Added:
 /trunk/user/src/com/google/gwt/i18n/tools/ArgHandlerValueChooser.java
 /trunk/user/src/com/google/gwt/junit/ClassBatchingStrategy.java
 /trunk/user/src/com/google/gwt/junit/ModuleBatchingStrategy.java
 /trunk/user/src/com/google/gwt/junit/NoBatchingStrategy.java
 /trunk/user/src/com/google/gwt/junit/ParallelCompileStrategy.java
 /trunk/user/src/com/google/gwt/junit/PreCompileStrategy.java
 /trunk/user/src/com/google/gwt/junit/SimpleCompileStrategy.java
Modified:
 /trunk/dev/core/super/com/google/gwt/lang/LongLibBase.java
 /trunk/dev/core/test/com/google/gwt/lang/LongLibTest.java
 /trunk/dev/core/test/com/google/gwt/lang/LongLibTestBase.java
 /trunk/user/src/com/google/gwt/i18n/tools/I18NSync.java
 /trunk/user/src/com/google/gwt/junit/BatchingStrategy.java
 /trunk/user/src/com/google/gwt/junit/CompileStrategy.java
 /trunk/user/super/com/google/gwt/emul/java/util/Arrays.java

=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/i18n/tools/ArgHandlerValueChooser.java Thu Jul 29 09:26:40 2010
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2008 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.i18n.tools;
+
+import com.google.gwt.i18n.client.Constants;
+import com.google.gwt.i18n.client.ConstantsWithLookup;
+import com.google.gwt.i18n.client.Localizable;
+import com.google.gwt.i18n.client.Messages;
+import com.google.gwt.util.tools.ArgHandler;
+import com.google.gwt.util.tools.ArgHandlerFlag;
+
+/**
+ * This class holds the '-createConstantsWithLookup' and '-createMessages'
+ * ArgHandler classes. It is shared by both I18NSync and I18NCreator classes.
+ *
+ * To use this class, call the getConstantsWithLookupArgHandler()
+ * and getMessagesArgHandler() methods and add the returned ArgHandler
+ * instances to a ToolBase registerHandler() method. When parsing the arguments + * is complete, you can retrieve the selected type by calling getArgValue().
+ */
+class ArgHandlerValueChooser {
+
+  private Class<? extends Localizable> argValue = Constants.class;
+  private ArgHandler cwlArgHandler;
+  private ArgHandler messagesArgHandler;
+
+  /**
+   * Returns one on "Messages.class", "ConstantsWithLookup.class", or
+   * "Constants.class" depending on which argument handlers fired.
+   *
+   * @return A class literal, returns "Constants.class" by default.
+   */
+  Class<? extends Localizable> getArgValue() {
+    return argValue;
+  }
+
+  /**
+   * Retrieve the argument handler for -createConstantsWithLookup.
+   *
+   * @return a flag argument handler
+   */
+   ArgHandler getConstantsWithLookupArgHandler() {
+    if (cwlArgHandler == null) {
+      cwlArgHandler = new ArgHandlerFlag() {
+
+        @Override
+        public String getPurpose() {
+          return "Create scripts for a ConstantsWithLookup interface "
+              + "rather than a Constants one";
+        }
+
+        @Override
+        public String getTag() {
+          return "-createConstantsWithLookup";
+        }
+
+        @Override
+        public boolean setFlag() {
+          if (argValue == Messages.class) {
+ System.err.println("-createMessages cannot be used with -createConstantsWithLookup");
+            return false;
+          }
+          argValue = ConstantsWithLookup.class;
+          return true;
+        }
+      };
+    }
+    return cwlArgHandler;
+  }
+
+  /**
+   * Retrieves the -createMessages argument handler.
+   *
+   * @return a flag argument handler
+   */
+  ArgHandler getMessagesArgHandler() {
+    if (messagesArgHandler == null) {
+      messagesArgHandler = new ArgHandlerFlag() {
+
+        @Override
+        public String getPurpose() {
+          return "Create scripts for a Messages interface "
+              + "rather than a Constants one";
+        }
+
+        @Override
+        public String getTag() {
+          return "-createMessages";
+        }
+
+        @Override
+        public boolean setFlag() {
+          if (argValue == ConstantsWithLookup.class) {
+ System.err.println("-createMessages cannot be used with -createConstantsWithLookup");
+            return false;
+          }
+          argValue = Messages.class;
+          return true;
+        }
+      };
+    }
+    return messagesArgHandler;
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/junit/ClassBatchingStrategy.java Thu Jul 29 09:26:40 2010
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.junit;
+
+import com.google.gwt.junit.client.impl.JUnitHost.TestInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Strategy that batches all tests belonging to one class.
+ */
+class ClassBatchingStrategy extends BatchingStrategy {
+  @Override
+  public List<TestInfo[]> getTestBlocks(String syntheticModuleName) {
+ Set<TestInfo> allTestsInModule = getTestsForModule(syntheticModuleName);
+    List<TestInfo[]> testBlocks = new ArrayList<TestInfo[]>();
+    String lastTestClass = null;
+    List<TestInfo> lastTestBlock = null;
+    for (TestInfo testInfo : allTestsInModule) {
+      String testClass = testInfo.getTestClass();
+      if (!testClass.equals(lastTestClass)) {
+        // Add the last test block to the collection.
+        if (lastTestBlock != null) {
+ testBlocks.add(lastTestBlock.toArray(new TestInfo[lastTestBlock.size()]));
+        }
+
+        // Start a new test block.
+        lastTestClass = testClass;
+        lastTestBlock = new ArrayList<TestInfo>();
+      }
+      lastTestBlock.add(testInfo);
+    }
+
+    // Add the last test block.
+    if (lastTestBlock != null) {
+ testBlocks.add(lastTestBlock.toArray(new TestInfo[lastTestBlock.size()]));
+    }
+    return testBlocks;
+  }
+
+  @Override
+  public boolean isSingleTestOnly() {
+    return false;
+  }
+
+  @Override
+  protected int getTimeoutMultiplier() {
+    return 4;
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/junit/ModuleBatchingStrategy.java Thu Jul 29 09:26:40 2010
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.junit;
+
+import com.google.gwt.junit.client.impl.JUnitHost.TestInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Strategy that batches all tests belonging to one module.
+ */
+class ModuleBatchingStrategy extends BatchingStrategy {
+  @Override
+  public List<TestInfo[]> getTestBlocks(String syntheticModuleName) {
+ Set<TestInfo> allTestsInModule = getTestsForModule(syntheticModuleName);
+    List<TestInfo[]> testBlocks = new ArrayList<TestInfo[]>();
+    if (allTestsInModule.size() > 0) {
+ TestInfo[] testBlock = allTestsInModule.toArray(new TestInfo[allTestsInModule.size()]);
+      testBlocks.add(testBlock);
+    }
+    return testBlocks;
+  }
+
+  @Override
+  public boolean isSingleTestOnly() {
+    return false;
+  }
+
+  @Override
+  protected int getTimeoutMultiplier() {
+    return 4;
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/junit/NoBatchingStrategy.java Thu Jul 29 09:26:40 2010
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.junit;
+
+import com.google.gwt.junit.client.impl.JUnitHost.TestInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+/**
+ *
+ * Strategy that does not batch tests.
+ */
+class NoBatchingStrategy extends BatchingStrategy {
+  @Override
+  public List<TestInfo[]> getTestBlocks(String syntheticModuleName) {
+ Set<TestInfo> allTestsInModule = getTestsForModule(syntheticModuleName);
+    List<TestInfo[]> testBlocks = new ArrayList<TestInfo[]>();
+    for (TestInfo testInfo : allTestsInModule) {
+      testBlocks.add(new TestInfo[] {testInfo});
+    }
+    return testBlocks;
+  }
+
+  @Override
+  public boolean isSingleTestOnly() {
+    return true;
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/junit/ParallelCompileStrategy.java Thu Jul 29 09:26:40 2010
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.junit;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.cfg.ModuleDef;
+import com.google.gwt.junit.JUnitShell.Strategy;
+import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.junit.client.GWTTestCase.TestModuleInfo;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * Strategy that compiles modules as tests run. Optimizes total test time.
+ */
+class ParallelCompileStrategy extends PreCompileStrategy {
+
+  /**
+ * The {...@link BatchingStrategy} used to compile, which is set on the first
+   * compilation and is the same across all compilations.
+   */
+  private BatchingStrategy batchingStrategy;
+
+  /**
+   * The list of all synthetic module names to be compiled.
+   */
+  private List<String> modulesToCompile = new ArrayList<String>();
+
+  /**
+   * The {...@link TreeLogger} used to compile, which is set on the first
+   * compilation and is the same across all compilations.
+   */
+  private TreeLogger treeLogger;
+
+  public ParallelCompileStrategy(JUnitShell junitShell) {
+    super(junitShell);
+  }
+
+  @Override
+  public void maybeCompileAhead() throws UnableToCompleteException {
+    if (modulesToCompile.size() > 0) {
+      String nextModule = modulesToCompile.remove(0);
+ TestModuleInfo moduleInfo = GWTTestCase.getTestsForModule(nextModule);
+      String syntheticModuleName = moduleInfo.getSyntheticModuleName();
+ maybeCompileModuleImpl(moduleInfo.getModuleName(), syntheticModuleName,
+          moduleInfo.getStrategy(), batchingStrategy, treeLogger);
+    }
+  }
+
+  @Override
+  public ModuleDef maybeCompileModule(String moduleName,
+      String syntheticModuleName, Strategy strategy,
+      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
+      throws UnableToCompleteException {
+
+    // Initialize the map of modules.
+    if (preCompiledModuleDefs == null) {
+      this.batchingStrategy = batchingStrategy;
+      this.treeLogger = treeLogger;
+      preCompiledModuleDefs = new HashMap<String, ModuleDef>();
+      String[] allModuleNames = GWTTestCase.getAllTestModuleNames();
+      for (String curModuleName : allModuleNames) {
+        modulesToCompile.add(curModuleName);
+      }
+    }
+
+    // Compile the requested module if needed.
+    ModuleDef moduleDef = preCompiledModuleDefs.get(syntheticModuleName);
+    if (moduleDef == null) {
+      moduleDef = maybeCompileModuleImpl(moduleName, syntheticModuleName,
+          strategy, batchingStrategy, treeLogger);
+    }
+    return moduleDef;
+  }
+
+  @Override
+  protected ModuleDef maybeCompileModuleImpl(String moduleName,
+      String syntheticModuleName, Strategy strategy,
+      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
+      throws UnableToCompleteException {
+    modulesToCompile.remove(syntheticModuleName);
+    ModuleDef moduleDef = super.maybeCompileModuleImpl(moduleName,
+        syntheticModuleName, strategy, batchingStrategy, treeLogger);
+    preCompiledModuleDefs.put(syntheticModuleName, moduleDef);
+    return moduleDef;
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/junit/PreCompileStrategy.java Thu Jul 29 09:26:40 2010
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.junit;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.cfg.ModuleDef;
+import com.google.gwt.junit.JUnitShell.Strategy;
+import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.junit.client.GWTTestCase.TestModuleInfo;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * Strategy that compiles all modules before returning results. Optimizes test
+ * system usage.
+ */
+class PreCompileStrategy extends CompileStrategy {
+  /**
+ * A mapping of synthetic module names to their precompiled synthetic module
+   * defs.
+   */
+  Map<String, ModuleDef> preCompiledModuleDefs;
+
+  public PreCompileStrategy(JUnitShell junitShell) {
+    super(junitShell);
+  }
+
+  @Override
+  public ModuleDef maybeCompileModule(String moduleName,
+      String syntheticModuleName, Strategy strategy,
+      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
+      throws UnableToCompleteException {
+    maybePrecompileModules(batchingStrategy, treeLogger);
+
+    // Since all test blocks from a module are added to the queue at the
+    // same time, we can safely take the module out of the hash map at
+    // this point.
+    return preCompiledModuleDefs.get(syntheticModuleName);
+  }
+
+  /**
+   * Precompile all modules if needed.
+   */
+  private void maybePrecompileModules(BatchingStrategy batchingStrategy,
+      TreeLogger treeLogger) throws UnableToCompleteException {
+    if (preCompiledModuleDefs == null) {
+      preCompiledModuleDefs = new HashMap<String, ModuleDef>();
+      for (String moduleName : GWTTestCase.getAllTestModuleNames()) {
+ TestModuleInfo moduleInfo = GWTTestCase.getTestsForModule(moduleName);
+        String syntheticModuleName = moduleInfo.getSyntheticModuleName();
+        if (syntheticModuleName != null) {
+          ModuleDef moduleDef = maybeCompileModuleImpl(
+              moduleInfo.getModuleName(), syntheticModuleName,
+              moduleInfo.getStrategy(), batchingStrategy, treeLogger);
+          preCompiledModuleDefs.put(syntheticModuleName, moduleDef);
+        }
+      }
+    }
+  }
+}
=======================================
--- /dev/null
+++ /trunk/user/src/com/google/gwt/junit/SimpleCompileStrategy.java Thu Jul 29 09:26:40 2010
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2009 Google Inc.
+ *
+ * Licensed 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 com.google.gwt.junit;
+
+import com.google.gwt.core.ext.TreeLogger;
+import com.google.gwt.core.ext.UnableToCompleteException;
+import com.google.gwt.dev.cfg.ModuleDef;
+import com.google.gwt.junit.JUnitShell.Strategy;
+
+/**
+ * Strategy that compiles only one module at a time. Optimizes memory usage.
+ */
+class SimpleCompileStrategy extends CompileStrategy {
+  public SimpleCompileStrategy(JUnitShell junitShell) {
+    super(junitShell);
+  }
+
+  @Override
+  public ModuleDef maybeCompileModule(String moduleName,
+      String syntheticModuleName, Strategy strategy,
+      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
+      throws UnableToCompleteException {
+ return maybeCompileModuleImpl(moduleName, syntheticModuleName, strategy,
+        batchingStrategy, treeLogger);
+  }
+}
=======================================
--- /trunk/dev/core/super/com/google/gwt/lang/LongLibBase.java Mon Jun 14 08:04:23 2010 +++ /trunk/dev/core/super/com/google/gwt/lang/LongLibBase.java Thu Jul 29 09:26:40 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- *
+ *
* Licensed 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
@@ -17,20 +17,20 @@

 import com.google.gwt.core.client.UnsafeNativeLong;

-final class LongEmul {
-  public static LongEmul getInstance() {
-    return new LongEmul();
-  }
-
-  int l, m, h; // Used only when RUN_IN_JVM is true
-}
-
 /**
  * Implements a Java <code>long</code> in a way that can be translated to
* JavaScript. Methods that are meant to be called from outside this package are
  * located in {...@link LongLib}.
  */
 class LongLibBase {
+  static final class LongEmul {
+    public static LongEmul getInstance() {
+      return new LongEmul();
+    }
+
+    int l, m, h; // Used only when RUN_IN_JVM is true
+  }
+
   // Force the class to exist
   public static LongEmul instance = new LongEmul();

@@ -39,10 +39,10 @@
* high) such that (x.l + ((long) x.m << 22) + ((long) x.h << 44)) is equal to * the original long integer. The constant 22 is chosen since some browsers
    * are faster when operating on integers of 24 bits or less.
-   *
+   *
* By convention, we expect and maintain that the upper bits of each word be
    * zeroed.
-   *
+   *
    * Note that this class must be careful using type "long". Being the
* implementation of the long type for web mode, any place it uses a long is
    * not usable in web mode. There is currently one such method: {...@link
@@ -150,7 +150,7 @@
      * 'negative' (which tracks the sign of both a and b and is used to
* determine the sign of the quotient) and 'aIsNegative' (which is used to
      * determine the sign of the remainder).
-     *
+     *
* For all values of a except MIN_VALUE, we can just negate a and modify * negative and aIsNegative appropriately. When a == MIN_VALUE, negation is
      * not possible without overflowing 64 bits, so instead of computing
@@ -158,7 +158,7 @@
* only circumstance under which these quotients differ is when b is a power * of two, which will divide abs(MIN_VALUE) == 2^64 exactly. In this case, * we can get the proper result by shifting MIN_VALUE in unsigned fashion.
-     *
+     *
      * We make a single copy of a before the first operation that needs to
      * modify its value.
      */
@@ -321,7 +321,7 @@
   }

   private static native LongEmul create0(int l, int m, int h) /*-{
-    return (a = @com.google.gwt.lang.LongEmul::getInstance()(),
+    return (a = @com.google.gwt.lang.LongLibBase$LongEmul::getInstance()(),
         a.l = l, a.m = m, a.h = h, a);
   }-*/;

@@ -432,7 +432,7 @@

   /**
    * Return the exact log base 2 of a, or -1 if a is not a power of two:
-   *
+   *
    * <pre>
    * if (x == 2^n) {
    *   return n;
@@ -536,7 +536,7 @@

   /**
    * Attempt to subtract b from a if a >= b:
-   *
+   *
    * <pre>
    * if (a >= b) {
    *   a -= b;
=======================================
--- /trunk/dev/core/test/com/google/gwt/lang/LongLibTest.java Thu Jun 17 10:25:32 2010 +++ /trunk/dev/core/test/com/google/gwt/lang/LongLibTest.java Thu Jul 29 09:26:40 2010
@@ -1,6 +1,6 @@
 package com.google.gwt.lang;

-import com.google.gwt.lang.LongEmul;
+import com.google.gwt.lang.LongLibBase.LongEmul;

 import junit.framework.TestCase;

=======================================
--- /trunk/dev/core/test/com/google/gwt/lang/LongLibTestBase.java Wed Jun 16 15:55:40 2010 +++ /trunk/dev/core/test/com/google/gwt/lang/LongLibTestBase.java Thu Jul 29 09:26:40 2010
@@ -16,6 +16,7 @@
 package com.google.gwt.lang;

 import com.google.gwt.lang.LongLib.Const;
+import com.google.gwt.lang.LongLibBase.LongEmul;

 import junit.framework.TestCase;

=======================================
--- /trunk/user/src/com/google/gwt/i18n/tools/I18NSync.java Tue Dec 23 16:45:21 2008 +++ /trunk/user/src/com/google/gwt/i18n/tools/I18NSync.java Thu Jul 29 09:26:40 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2008 Google Inc.
- *
+ *
* Licensed 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
@@ -23,9 +23,7 @@
 import com.google.gwt.i18n.rebind.ConstantsInterfaceCreator;
 import com.google.gwt.i18n.rebind.LocalizableGenerator;
 import com.google.gwt.i18n.rebind.MessagesInterfaceCreator;
-import com.google.gwt.util.tools.ArgHandler;
 import com.google.gwt.util.tools.ArgHandlerExtra;
-import com.google.gwt.util.tools.ArgHandlerFlag;
 import com.google.gwt.util.tools.ArgHandlerString;
 import com.google.gwt.util.tools.ToolBase;

@@ -128,7 +126,7 @@
   /**
    * Creates a <code>Constants</code> interface from a class name. The
    * resource file needed to create the class must be on your class path.
-   *
+   *
    * @param className the name of the Constants class to be created
    * @param outDir source dir root
    * @throws IOException
@@ -141,7 +139,7 @@
   /**
* Creates a <code>ConstantsWithLookup</code> interface from a class name. * The resource file needed to create the class must be on your class path.
-   *
+   *
    * @param className the name of the Constants class to be created
    * @throws IOException
    */
@@ -154,7 +152,7 @@
   /**
* Creates a <code>ConstantsWithLookup</code> interface from a class name. * The resource file needed to create the class must be on your class path.
-   *
+   *
    * @param className the name of the Constants class to be created
    * @param sourceDir source dir root
    * @throws IOException
@@ -192,7 +190,7 @@
   /**
* Creates a <code>Messages</code> interface from a class name. The resource
    * file needed to create the class must be on your class path.
-   *
+   *
    * @param className the name of the Constants class to be created
    * @throws IOException
    */
@@ -200,11 +198,11 @@
       throws IOException {
     createMessagesInterfaceFromClassName(className, null);
   }
-
+
   /**
* Creates a <code>Messages</code> interface from a class name. The resource
    * file needed to create the class must be on your class path.
-   *
+   *
    * @param className the name of the Constants class to be created
    * @param sourceDir source directory root
    * @throws IOException
@@ -236,7 +234,7 @@

   /**
    * Creates Messages and Constants java source files.
-   *
+   *
    * @param args arguments for generation
    */
   public static void main(String[] args) {
@@ -354,7 +352,7 @@

   /**
    * Creates the interface.
-   *
+   *
    * @return whether the interface was created
    */
   protected boolean run() {
@@ -368,97 +366,3 @@
     }
   }
 }
-
-/**
- * This class holds the '-createConstantsWithLookup' and '-createMessages'
- * ArgHandler classes. It is shared by both I18NSync and I18NCreator classes.
- *
- * To use this class, call the getConstantsWithLookupArgHandler()
- * and getMessagesArgHandler() methods and add the returned ArgHandler
- * instances to a ToolBase registerHandler() method. When parsing the arguments - * is complete, you can retrieve the selected type by calling getArgValue().
- */
-class ArgHandlerValueChooser {
-
-  private  Class<? extends Localizable> argValue = Constants.class;
-  private ArgHandler cwlArgHandler;
-  private ArgHandler messagesArgHandler;
-
-  /**
-   * Returns one on "Messages.class", "ConstantsWithLookup.class", or
-   * "Constants.class" depending on which argument handlers fired.
-   *
-   * @return A class literal, returns "Constants.class" by default.
-   */
-  Class<? extends Localizable> getArgValue() {
-    return argValue;
-  }
-
-  /**
-   * Retrieve the argument handler for -createConstantsWithLookup.
-   *
-   * @return a flag argument handler
-   */
-   ArgHandler getConstantsWithLookupArgHandler() {
-    if (cwlArgHandler == null) {
-      cwlArgHandler = new ArgHandlerFlag() {
-
-        @Override
-        public String getPurpose() {
-          return "Create scripts for a ConstantsWithLookup interface "
-              + "rather than a Constants one";
-        }
-
-        @Override
-        public String getTag() {
-          return "-createConstantsWithLookup";
-        }
-
-        @Override
-        public boolean setFlag() {
-          if (argValue == Messages.class) {
- System.err.println("-createMessages cannot be used with -createConstantsWithLookup");
-            return false;
-          }
-          argValue = ConstantsWithLookup.class;
-          return true;
-        }
-      };
-    }
-    return cwlArgHandler;
-  }
-
-  /**
-   * Retrieves the -createMessages argument handler.
-   *
-   * @return a flag argument handler
-   */
-  ArgHandler getMessagesArgHandler() {
-    if (messagesArgHandler == null) {
-      messagesArgHandler = new ArgHandlerFlag() {
-
-        @Override
-        public String getPurpose() {
-          return "Create scripts for a Messages interface "
-              + "rather than a Constants one";
-        }
-
-        @Override
-        public String getTag() {
-          return "-createMessages";
-        }
-
-        @Override
-        public boolean setFlag() {
-          if (argValue == ConstantsWithLookup.class) {
- System.err.println("-createMessages cannot be used with -createConstantsWithLookup");
-            return false;
-          }
-          argValue = Messages.class;
-          return true;
-        }
-      };
-    }
-    return messagesArgHandler;
-  }
-}
=======================================
--- /trunk/user/src/com/google/gwt/junit/BatchingStrategy.java Wed Oct 28 13:37:33 2009 +++ /trunk/user/src/com/google/gwt/junit/BatchingStrategy.java Thu Jul 29 09:26:40 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2009 Google Inc.
- *
+ *
* Licensed 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
@@ -18,7 +18,6 @@
 import com.google.gwt.junit.client.GWTTestCase;
 import com.google.gwt.junit.client.impl.JUnitHost.TestInfo;

-import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -33,7 +32,7 @@
   /**
* Returns an ordered list of all tests blocks that should be executed for the
    * specified module. Each test block is an array of {...@link TestInfo}.
-   *
+   *
    * @param syntheticModuleName the name of the synthetic module
    * @return an ordered list of test blocks to run
    */
@@ -42,14 +41,14 @@
   /**
* Check if this batching strategy only supports execution of a single test at
    * a time.
-   *
+   *
* If this method returns true, test methods will be executed on the client as * they are run by JUnit. If it returns false, test methods will be batched
    * and sent to the clients in groups. If you are using a test runner that
* shards test methods across multiple clients, you should use a strategy that * returns false (such as {...@link NoBatchingStrategy}) or all tests will be
    * executed on all clients.
-   *
+   *
    * @return true if batches never contain more than one test
    */
   public abstract boolean isSingleTestOnly();
@@ -57,7 +56,7 @@
   /**
    * Get the set of tests for this module, minus tests that should not be
    * executed.
-   *
+   *
    * @return the set of tests to execute
    */
protected final Set<TestInfo> getTestsForModule(String syntheticModuleName) {
@@ -81,93 +80,3 @@
   }

 }
-
-/**
- *
- * Strategy that does not batch tests.
- */
-class NoBatchingStrategy extends BatchingStrategy {
-  @Override
-  public List<TestInfo[]> getTestBlocks(String syntheticModuleName) {
- Set<TestInfo> allTestsInModule = getTestsForModule(syntheticModuleName);
-    List<TestInfo[]> testBlocks = new ArrayList<TestInfo[]>();
-    for (TestInfo testInfo : allTestsInModule) {
-      testBlocks.add(new TestInfo[] {testInfo});
-    }
-    return testBlocks;
-  }
-
-  @Override
-  public boolean isSingleTestOnly() {
-    return true;
-  }
-}
-
-/**
- * Strategy that batches all tests belonging to one class.
- */
-class ClassBatchingStrategy extends BatchingStrategy {
-  @Override
-  public List<TestInfo[]> getTestBlocks(String syntheticModuleName) {
- Set<TestInfo> allTestsInModule = getTestsForModule(syntheticModuleName);
-    List<TestInfo[]> testBlocks = new ArrayList<TestInfo[]>();
-    String lastTestClass = null;
-    List<TestInfo> lastTestBlock = null;
-    for (TestInfo testInfo : allTestsInModule) {
-      String testClass = testInfo.getTestClass();
-      if (!testClass.equals(lastTestClass)) {
-        // Add the last test block to the collection.
-        if (lastTestBlock != null) {
- testBlocks.add(lastTestBlock.toArray(new TestInfo[lastTestBlock.size()]));
-        }
-
-        // Start a new test block.
-        lastTestClass = testClass;
-        lastTestBlock = new ArrayList<TestInfo>();
-      }
-      lastTestBlock.add(testInfo);
-    }
-
-    // Add the last test block.
-    if (lastTestBlock != null) {
- testBlocks.add(lastTestBlock.toArray(new TestInfo[lastTestBlock.size()]));
-    }
-    return testBlocks;
-  }
-
-  @Override
-  public boolean isSingleTestOnly() {
-    return false;
-  }
-
-  @Override
-  protected int getTimeoutMultiplier() {
-    return 4;
-  }
-}
-
-/**
- * Strategy that batches all tests belonging to one module.
- */
-class ModuleBatchingStrategy extends BatchingStrategy {
-  @Override
-  public List<TestInfo[]> getTestBlocks(String syntheticModuleName) {
- Set<TestInfo> allTestsInModule = getTestsForModule(syntheticModuleName);
-    List<TestInfo[]> testBlocks = new ArrayList<TestInfo[]>();
-    if (allTestsInModule.size() > 0) {
- TestInfo[] testBlock = allTestsInModule.toArray(new TestInfo[allTestsInModule.size()]);
-      testBlocks.add(testBlock);
-    }
-    return testBlocks;
-  }
-
-  @Override
-  public boolean isSingleTestOnly() {
-    return false;
-  }
-
-  @Override
-  protected int getTimeoutMultiplier() {
-    return 4;
-  }
-}
=======================================
--- /trunk/user/src/com/google/gwt/junit/CompileStrategy.java Tue Jun 22 06:26:45 2010 +++ /trunk/user/src/com/google/gwt/junit/CompileStrategy.java Thu Jul 29 09:26:40 2010
@@ -1,12 +1,12 @@
 /*
  * Copyright 2009 Google Inc.
- *
+ *
* Licensed 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
@@ -23,14 +23,11 @@
 import com.google.gwt.dev.util.collect.HashSet;
 import com.google.gwt.junit.JUnitShell.Strategy;
 import com.google.gwt.junit.client.GWTTestCase;
-import com.google.gwt.junit.client.GWTTestCase.TestModuleInfo;
 import com.google.gwt.junit.client.impl.GWTRunner;
 import com.google.gwt.junit.client.impl.JUnitHost.TestInfo;

 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;

 /**
@@ -48,7 +45,7 @@

   /**
    * Construct a CompileStrategy.
-   *
+   *
    * @param junitShell
    */
   public CompileStrategy(JUnitShell junitShell) {
@@ -57,7 +54,7 @@

   /**
    * Maybe add a test block for the currently executed test case.
-   *
+   *
    * @param testCase the test case being run
    * @param batchingStrategy the batching strategy
    */
@@ -75,7 +72,7 @@
   /**
    * Let the compile strategy compile another module. This is called while
    * {...@link JUnitShell} is waiting for the current test to complete.
-   *
+   *
    * @throws UnableToCompleteException if the compilation fails
    */
   public void maybeCompileAhead() throws UnableToCompleteException {
@@ -83,7 +80,7 @@

   /**
* Compile a single module using a synthetic module that adds JUnit support.
-   *
+   *
    * @param moduleName the module name
    * @param syntheticModuleName the synthetic module name
    * @param strategy the strategy
@@ -99,7 +96,7 @@

   /**
* Compile a single module using a synthetic module that adds JUnit support.
-   *
+   *
    * @param moduleName the module name
    * @param syntheticModuleName the synthetic module name
    * @param strategy the strategy
@@ -131,7 +128,7 @@

   /**
    * Visible for testing and mocking.
-   *
+   *
    * @return the {...@link JUnitMessageQueue}
    */
   JUnitMessageQueue getMessageQueue() {
@@ -140,7 +137,7 @@

   /**
    * Visible for testing and mocking.
-   *
+   *
    * @return the number of modules to test
    */
   int getModuleCount() {
@@ -149,9 +146,9 @@

   /**
    * Compile the module if needed.
-   *
+   *
    * Visible for testing and mocking.
-   *
+   *
    * @param moduleName the module name
    * @param syntheticModuleName the synthetic module name
    * @param strategy the strategy
@@ -186,147 +183,3 @@
     return moduleDef;
   }
 }
-
-/**
- * Strategy that compiles modules as tests run. Optimizes total test time.
- */
-class ParallelCompileStrategy extends PreCompileStrategy {
-
-  /**
- * The {...@link BatchingStrategy} used to compile, which is set on the first
-   * compilation and is the same across all compilations.
-   */
-  private BatchingStrategy batchingStrategy;
-
-  /**
-   * The list of all synthetic module names to be compiled.
-   */
-  private List<String> modulesToCompile = new ArrayList<String>();
-
-  /**
-   * The {...@link TreeLogger} used to compile, which is set on the first
-   * compilation and is the same across all compilations.
-   */
-  private TreeLogger treeLogger;
-
-  public ParallelCompileStrategy(JUnitShell junitShell) {
-    super(junitShell);
-  }
-
-  @Override
-  public void maybeCompileAhead() throws UnableToCompleteException {
-    if (modulesToCompile.size() > 0) {
-      String nextModule = modulesToCompile.remove(0);
- TestModuleInfo moduleInfo = GWTTestCase.getTestsForModule(nextModule);
-      String syntheticModuleName = moduleInfo.getSyntheticModuleName();
- maybeCompileModuleImpl(moduleInfo.getModuleName(), syntheticModuleName,
-          moduleInfo.getStrategy(), batchingStrategy, treeLogger);
-    }
-  }
-
-  @Override
-  public ModuleDef maybeCompileModule(String moduleName,
-      String syntheticModuleName, Strategy strategy,
-      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
-      throws UnableToCompleteException {
-
-    // Initialize the map of modules.
-    if (preCompiledModuleDefs == null) {
-      this.batchingStrategy = batchingStrategy;
-      this.treeLogger = treeLogger;
-      preCompiledModuleDefs = new HashMap<String, ModuleDef>();
-      String[] allModuleNames = GWTTestCase.getAllTestModuleNames();
-      for (String curModuleName : allModuleNames) {
-        modulesToCompile.add(curModuleName);
-      }
-    }
-
-    // Compile the requested module if needed.
-    ModuleDef moduleDef = preCompiledModuleDefs.get(syntheticModuleName);
-    if (moduleDef == null) {
-      moduleDef = maybeCompileModuleImpl(moduleName, syntheticModuleName,
-          strategy, batchingStrategy, treeLogger);
-    }
-    return moduleDef;
-  }
-
-  @Override
-  protected ModuleDef maybeCompileModuleImpl(String moduleName,
-      String syntheticModuleName, Strategy strategy,
-      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
-      throws UnableToCompleteException {
-    modulesToCompile.remove(syntheticModuleName);
-    ModuleDef moduleDef = super.maybeCompileModuleImpl(moduleName,
-        syntheticModuleName, strategy, batchingStrategy, treeLogger);
-    preCompiledModuleDefs.put(syntheticModuleName, moduleDef);
-    return moduleDef;
-  }
-}
-
-/**
- * Strategy that compiles all modules before returning results. Optimizes test
- * system usage.
- */
-class PreCompileStrategy extends CompileStrategy {
-  /**
- * A mapping of synthetic module names to their precompiled synthetic module
-   * defs.
-   */
-  Map<String, ModuleDef> preCompiledModuleDefs;
-
-  public PreCompileStrategy(JUnitShell junitShell) {
-    super(junitShell);
-  }
-
-  @Override
-  public ModuleDef maybeCompileModule(String moduleName,
-      String syntheticModuleName, Strategy strategy,
-      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
-      throws UnableToCompleteException {
-    maybePrecompileModules(batchingStrategy, treeLogger);
-
-    // Since all test blocks from a module are added to the queue at the
-    // same time, we can safely take the module out of the hash map at
-    // this point.
-    return preCompiledModuleDefs.get(syntheticModuleName);
-  }
-
-  /**
-   * Precompile all modules if needed.
-   */
-  private void maybePrecompileModules(BatchingStrategy batchingStrategy,
-      TreeLogger treeLogger) throws UnableToCompleteException {
-    if (preCompiledModuleDefs == null) {
-      preCompiledModuleDefs = new HashMap<String, ModuleDef>();
-      for (String moduleName : GWTTestCase.getAllTestModuleNames()) {
- TestModuleInfo moduleInfo = GWTTestCase.getTestsForModule(moduleName);
-        String syntheticModuleName = moduleInfo.getSyntheticModuleName();
-        if (syntheticModuleName != null) {
-          ModuleDef moduleDef = maybeCompileModuleImpl(
-              moduleInfo.getModuleName(), syntheticModuleName,
-              moduleInfo.getStrategy(), batchingStrategy, treeLogger);
-          preCompiledModuleDefs.put(syntheticModuleName, moduleDef);
-        }
-      }
-    }
-  }
-}
-
-/**
- *
- * Strategy that compiles only one module at a time. Optimizes memory usage.
- */
-class SimpleCompileStrategy extends CompileStrategy {
-  public SimpleCompileStrategy(JUnitShell junitShell) {
-    super(junitShell);
-  }
-
-  @Override
-  public ModuleDef maybeCompileModule(String moduleName,
-      String syntheticModuleName, Strategy strategy,
-      BatchingStrategy batchingStrategy, TreeLogger treeLogger)
-      throws UnableToCompleteException {
- return maybeCompileModuleImpl(moduleName, syntheticModuleName, strategy,
-        batchingStrategy, treeLogger);
-  }
-}
=======================================
--- /trunk/user/super/com/google/gwt/emul/java/util/Arrays.java Mon Jun 7 09:38:44 2010 +++ /trunk/user/super/com/google/gwt/emul/java/util/Arrays.java Thu Jul 29 09:26:40 2010
@@ -1345,7 +1345,7 @@
    */
   @UnsafeNativeLong
   private static native void nativeLongSort(Object array) /*-{
- array.sort(@com.google.gwt.lang.LongLib::compare(Lcom/google/gwt/lang/LongEmul;Lcom/google/gwt/lang/LongEmul;)); + array.sort(@com.google.gwt.lang.LongLib::compare(Lcom/google/gwt/lang/LongLibBase$LongEmul;Lcom/google/gwt/lang/LongLibBase$LongEmul;));
   }-*/;

   /**
@@ -1355,7 +1355,7 @@
   private static native void nativeLongSort(Object array, int fromIndex,
       int toIndex) /*-{
     var temp = array.slice(fromIndex, toIndex);
- temp.sort(@com.google.gwt.lang.LongLib::compare(Lcom/google/gwt/lang/LongEmul;Lcom/google/gwt/lang/LongEmul;)); + temp.sort(@com.google.gwt.lang.LongLib::compare(Lcom/google/gwt/lang/LongLibBase$LongEmul;Lcom/google/gwt/lang/LongLibBase$LongEmul;));
     var n = toIndex - fromIndex;
     // Do the equivalent of array.splice(fromIndex, n, temp) except
     // flattening the temp slice.

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to