checkstyle passes (sorted) git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@55 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/super/com/google/gwt/emul/java/util/HashMap.java b/user/super/com/google/gwt/emul/java/util/HashMap.java index a86e973..0835c2d 100644 --- a/user/super/com/google/gwt/emul/java/util/HashMap.java +++ b/user/super/com/google/gwt/emul/java/util/HashMap.java
@@ -21,6 +21,12 @@ public class HashMap extends AbstractMap implements Map, Cloneable { private static class ImplMapEntry implements Map.Entry { + private boolean inUse; + + private Object key; + + private Object value; + public boolean equals(Object a) { if (a instanceof Map.Entry) { Map.Entry s = (Map.Entry) a; @@ -67,14 +73,22 @@ return a.equals(b); } } - - private boolean inUse; - private Object key; - private Object value; } private class ImplMapEntryIterator implements Iterator { + /** + * Always points at the next full slot; equal to <code>entries.length</code> + * if we're at the end. + */ + private int i = 0; + + /** + * Always points to the last element returned by next, or <code>-1</code> + * if there is no last element. + */ + private int last = -1; + public ImplMapEntryIterator() { maybeAdvanceToFullSlot(); } @@ -113,20 +127,35 @@ } } } - - /** - * Always points at the next full slot; equal to <code>entries.length</code> - * if we're at the end. - */ - private int i = 0; - - /** - * Always points to the last element returned by next, or <code>-1</code> - * if there is no last element. - */ - private int last = -1; } + /** + * Number of physically empty slots in {@link #entries}. + */ + private int emptySlots; + + /** + * The underlying data store. + */ + private ImplMapEntry[] entries; + + /** + * Number of logically full slots in {@link #entries}. + */ + private int fullSlots; + + /** + * A number between 0 and 1, exclusive. Used to calculated the new + * {@link #threshold} at which this map will be rehashed. + */ + private float loadFactor; + + /** + * Always equal to {@link #entries}.length * {@link #loadFactor}. When the + * number of non-empty slots exceeds this number, a rehash is performed. + */ + private int threshold; + public HashMap() { this(16); } @@ -384,31 +413,4 @@ entries = new ImplMapEntry[capacity]; } - /** - * Number of physically empty slots in {@link #entries}. - */ - private int emptySlots; - - /** - * The underlying data store. - */ - private ImplMapEntry[] entries; - - /** - * Number of logically full slots in {@link #entries}. - */ - private int fullSlots; - - /** - * A number between 0 and 1, exclusive. Used to calculated the new - * {@link #threshold} at which this map will be rehashed. - */ - private float loadFactor; - - /** - * Always equal to {@link #entries}.length * {@link #loadFactor}. When the - * number of non-empty slots exceeds this number, a rehash is performed. - */ - private int threshold; - }
diff --git a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/GWTTestCase.java b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/GWTTestCase.java index 72ded6d..adee751 100644 --- a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/GWTTestCase.java +++ b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/GWTTestCase.java
@@ -26,6 +26,12 @@ */ public abstract class GWTTestCase extends TestCase { + /** + * A reference to my implementation class. All substantive methods simply + * delegate to the implementation class, to make debugging easier. + */ + public final GWTTestCaseImpl impl = new GWTTestCaseImpl(this); + public final void addCheckpoint(String msg) { impl.addCheckpoint(msg); } @@ -41,7 +47,7 @@ public final String[] getCheckpoints() { return impl.getCheckpoints(); } - + public abstract String getModuleName(); /** @@ -70,10 +76,4 @@ impl.finishTest(); } - /** - * A reference to my implementation class. All substantive methods simply - * delegate to the implementation class, to make debugging easier. - */ - public final GWTTestCaseImpl impl = new GWTTestCaseImpl(this); - }
diff --git a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTTestCaseImpl.java b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTTestCaseImpl.java index 29eaf43..8f52f07 100644 --- a/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTTestCaseImpl.java +++ b/user/super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/impl/GWTTestCaseImpl.java
@@ -65,7 +65,6 @@ testCase.impl.runTest(); } } - } /** @@ -76,6 +75,11 @@ */ private final class KillTimer extends Timer { + /** + * Stashed so the timeout can be reported via {@link TimeoutException}. + */ + private final int timeoutMillis; + public KillTimer(int timeoutMillis) { this.timeoutMillis = timeoutMillis; schedule(timeoutMillis); @@ -90,11 +94,6 @@ // Just do nothing. } } - - /** - * Stashed so the timeout can be reported via {@link TimeoutException}. - */ - private final int timeoutMillis; } /** @@ -102,6 +101,46 @@ */ private static final JUnitHostAsync junitHost = (JUnitHostAsync) GWT.create(JUnitHost.class); + static { + // Bind junitHost to the appropriate url. + ServiceDefTarget endpoint = (ServiceDefTarget) junitHost; + String url = GWT.getModuleBaseURL() + "junithost"; + endpoint.setServiceEntryPoint(url); + + // Null out the default uncaught exception handler since control it. + GWT.setUncaughtExceptionHandler(null); + } + + /** + * The collected checkpoint messages. + */ + private List checkPoints; + + /** + * Handles all RPC responses. + */ + private final JUnitHostListener junitHostListener = new JUnitHostListener(); + + /** + * Tracks whether the main test body has run (for asynchronous mode). + */ + private boolean mainTestHasRun = false; + + /** + * My paired (enclosing) {@link GWTTestCase}. + */ + private final GWTTestCase outer; + + /** + * Tracks whether this test is completely done. + */ + private boolean testIsFinished = false; + + /** + * If non-null, a timer to kill the current test case (for asynchronous mode). + */ + private KillTimer timer; + /** * Constructs a new GWTTestCaseImpl that is paired one-to-one with a * {@link GWTTestCase}. @@ -150,7 +189,7 @@ if (timer == null) { throw new IllegalStateException( - "This test is not in asynchronous mode; call delayTestFinish() first"); + "This test is not in asynchronous mode; call delayTestFinish() first"); } if (mainTestHasRun) { @@ -222,7 +261,7 @@ } } junitHost.reportResultsAndGetNextMethod(outer.getTestName(), ew, - junitHostListener); + junitHostListener); } /** @@ -293,44 +332,4 @@ return true; } } - - static { - // Bind junitHost to the appropriate url. - ServiceDefTarget endpoint = (ServiceDefTarget) junitHost; - String url = GWT.getModuleBaseURL() + "junithost"; - endpoint.setServiceEntryPoint(url); - - // Null out the default uncaught exception handler since control it. - GWT.setUncaughtExceptionHandler(null); - } - - /** - * The collected checkpoint messages. - */ - private List checkPoints; - - /** - * Handles all RPC responses. - */ - private final JUnitHostListener junitHostListener = new JUnitHostListener(); - - /** - * Tracks whether the main test body has run (for asynchronous mode). - */ - private boolean mainTestHasRun = false; - - /** - * My paired (enclosing) {@link GWTTestCase}. - */ - private final GWTTestCase outer; - - /** - * Tracks whether this test is completely done. - */ - private boolean testIsFinished = false; - - /** - * If non-null, a timer to kill the current test case (for asynchronous mode). - */ - private KillTimer timer; }
diff --git a/user/super/com/google/gwt/junit/translatable/junit/framework/Assert.java b/user/super/com/google/gwt/junit/translatable/junit/framework/Assert.java index 13819a9..0d0d66e 100644 --- a/user/super/com/google/gwt/junit/translatable/junit/framework/Assert.java +++ b/user/super/com/google/gwt/junit/translatable/junit/framework/Assert.java
@@ -15,14 +15,87 @@ */ package junit.framework; +/** + * Translatable version of JUnit's <code>Assert</code>. + */ public class Assert { - /** - * Utility class, no public constructor needed - */ - protected Assert() { + public static void assertEquals(boolean obj1, boolean obj2) { + assertEquals("", obj1, obj2); } - static public void assertEquals(String msg, Object obj1, Object obj2) { + public static void assertEquals(byte obj1, byte obj2) { + assertEquals("", obj1, obj2); + } + + public static void assertEquals(char obj1, char obj2) { + assertEquals("", obj1, obj2); + } + + public static void assertEquals(double obj1, double obj2, double delta) { + assertEquals("", obj1, obj2, delta); + } + + public static void assertEquals(float obj1, float obj2, float delta) { + assertEquals("", obj1, obj2, delta); + } + + public static void assertEquals(int expected, int actual) { + assertEquals("", expected, actual); + } + + public static void assertEquals(long obj1, long obj2) { + assertEquals("", obj1, obj2); + } + + public static void assertEquals(Object obj1, Object obj2) { + assertEquals("", obj1, obj2); + } + + public static void assertEquals(String str, boolean obj1, boolean obj2) { + assertEquals(str, Boolean.valueOf(obj1), Boolean.valueOf(obj2)); + } + + public static void assertEquals(String str, byte obj1, byte obj2) { + assertEquals(str, new Byte(obj1), new Byte(obj2)); + } + + public static void assertEquals(String str, char obj1, char obj2) { + assertEquals(str, new Character(obj1), new Character(obj2)); + } + + public static void assertEquals(String str, double obj1, double obj2, + double delta) { + if (obj1 == obj2) { + return; + } else if (Math.abs(obj1 - obj2) <= delta) { + return; + } else { + fail(str + " expected=" + obj1 + " actual=" + obj2 + " delta=" + delta); + } + } + + public static void assertEquals(String str, float obj1, float obj2, + float delta) { + if (obj1 == obj2) { + return; + } else if (Math.abs(obj1 - obj2) <= delta) { + return; + } else { + fail(str + " expected=" + obj1 + " actual=" + obj2 + " delta=" + delta); + } + } + + public static void assertEquals(String msg, int expected, int actual) { + if (expected != actual) { + fail(msg + " expected=" + expected + " actual=" + actual); + } + } + + public static void assertEquals(String str, long obj1, long obj2) { + assertEquals(str, new Long(obj1), new Long(obj2)); + } + + public static void assertEquals(String msg, Object obj1, Object obj2) { if (obj1 == null && obj2 == null) { return; } @@ -34,132 +107,27 @@ fail(msg + " expected=" + obj1 + " actual=" + obj2); } - static public void assertEquals(int expected, int actual) { - assertEquals("", expected, actual); - } - - static public void assertEquals(String msg, int expected, int actual) { - if (expected != actual) { - fail(msg + " expected=" + expected + " actual=" + actual); - } - } - - static public void assertEquals(Object obj1, Object obj2) { - assertEquals("", obj1, obj2); - } - - static public void assertEquals(long obj1, long obj2) { - assertEquals("", obj1, obj2); - } - - static public void assertEquals(boolean obj1, boolean obj2) { - assertEquals("", obj1, obj2); - } - - static public void assertEquals(byte obj1, byte obj2) { - assertEquals("", obj1, obj2); - } - - static public void assertEquals(char obj1, char obj2) { - assertEquals("", obj1, obj2); - } - - static public void assertEquals(String str, double obj1, double obj2, - double delta) { - if (obj1 == obj2) { - return; - } else if (Math.abs(obj1 - obj2) <= delta) { - return; - } else { - fail(str + " expected=" + obj1 + " actual=" + obj2 + " delta=" + delta); - } - } - - static public void assertEquals(String str, float obj1, float obj2, - float delta) { - if (obj1 == obj2) { - return; - } else if (Math.abs(obj1 - obj2) <= delta) { - return; - } else { - fail(str + " expected=" + obj1 + " actual=" + obj2 + " delta=" + delta); - } - } - - static public void assertEquals(double obj1, double obj2, double delta) { - assertEquals("", obj1, obj2, delta); - } - - static public void assertEquals(float obj1, float obj2, float delta) { - assertEquals("", obj1, obj2, delta); - } - - static public void assertEquals(String str, long obj1, long obj2) { - assertEquals(str, new Long(obj1), new Long(obj2)); - } - - static public void assertEquals(String str, boolean obj1, boolean obj2) { - assertEquals(str, Boolean.valueOf(obj1), Boolean.valueOf(obj2)); - } - - static public void assertEquals(String str, byte obj1, byte obj2) { - assertEquals(str, new Byte(obj1), new Byte(obj2)); - } - - static public void assertEquals(String str, char obj1, char obj2) { - assertEquals(str, new Character(obj1), new Character(obj2)); - } - - static public void assertTrue(String message, boolean condition) { - if (!condition) - fail(message); - } - - static public void assertTrue(boolean condition) { - assertTrue(null, condition); - } - - static public void assertFalse(String message, boolean condition) { - assertTrue(message, !condition); - } - - static public void assertFalse(boolean condition) { + public static void assertFalse(boolean condition) { assertFalse(null, condition); } - static public void fail(String message) { - throw new AssertionFailedError(message); + public static void assertFalse(String message, boolean condition) { + assertTrue(message, !condition); } - static public void fail() { - fail(null); - } - - static public void assertSame(String msg, Object obj1, Object obj2) { - if (obj1 == obj2) { - return; - } - - if (msg == null) { - msg = ""; - } - - fail(msg + " expected and actual do not match"); - } - - static public void assertSame(Object obj1, Object obj2) { - assertSame(null, obj1, obj2); - } - - static public void assertNotNull(String msg, Object obj) { - assertTrue(msg, obj != null); - } - - static public void assertNotNull(Object obj) { + public static void assertNotNull(Object obj) { assertNotNull(null, obj); } - static public void assertNotSame(String msg, Object obj1, Object obj2) { + public static void assertNotNull(String msg, Object obj) { + assertTrue(msg, obj != null); + } + + public static void assertNotSame(Object obj1, Object obj2) { + assertNotSame(null, obj1, obj2); + } + + public static void assertNotSame(String msg, Object obj1, Object obj2) { if (obj1 != obj2) { return; } @@ -171,15 +139,51 @@ fail(msg + " expected and actual match"); } - static public void assertNotSame(Object obj1, Object obj2) { - assertNotSame(null, obj1, obj2); + public static void assertNull(Object obj) { + assertNull(null, obj); } - static public void assertNull(String msg, Object obj) { + public static void assertNull(String msg, Object obj) { assertTrue(msg, obj == null); } - static public void assertNull(Object obj) { - assertNull(null, obj); + public static void assertSame(Object obj1, Object obj2) { + assertSame(null, obj1, obj2); + } + + public static void assertSame(String msg, Object obj1, Object obj2) { + if (obj1 == obj2) { + return; + } + + if (msg == null) { + msg = ""; + } + + fail(msg + " expected and actual do not match"); + } + + public static void assertTrue(boolean condition) { + assertTrue(null, condition); + } + + public static void assertTrue(String message, boolean condition) { + if (!condition) { + fail(message); + } + } + + public static void fail() { + fail(null); + } + + public static void fail(String message) { + throw new AssertionFailedError(message); + } + + /** + * Utility class, no public constructor needed. + */ + protected Assert() { } }
diff --git a/user/super/com/google/gwt/junit/translatable/junit/framework/AssertionFailedError.java b/user/super/com/google/gwt/junit/translatable/junit/framework/AssertionFailedError.java index eee4de1..c42a09a 100644 --- a/user/super/com/google/gwt/junit/translatable/junit/framework/AssertionFailedError.java +++ b/user/super/com/google/gwt/junit/translatable/junit/framework/AssertionFailedError.java
@@ -16,7 +16,7 @@ package junit.framework; /** - * Thrown when an assertion failed. + * Translatable version of JUnit's <code>AssertionFailedError</code>. */ public class AssertionFailedError extends Error {
diff --git a/user/super/com/google/gwt/junit/translatable/junit/framework/Test.java b/user/super/com/google/gwt/junit/translatable/junit/framework/Test.java index 52ba1e9..e9f4c3a 100644 --- a/user/super/com/google/gwt/junit/translatable/junit/framework/Test.java +++ b/user/super/com/google/gwt/junit/translatable/junit/framework/Test.java
@@ -15,6 +15,9 @@ */ package junit.framework; +/** + * Translatable version of JUnit's <code>Test</code>. + */ public interface Test { public abstract int countTestCases(); }
diff --git a/user/super/com/google/gwt/junit/translatable/junit/framework/TestCase.java b/user/super/com/google/gwt/junit/translatable/junit/framework/TestCase.java index 812399f..c834da0 100644 --- a/user/super/com/google/gwt/junit/translatable/junit/framework/TestCase.java +++ b/user/super/com/google/gwt/junit/translatable/junit/framework/TestCase.java
@@ -17,8 +17,13 @@ import com.google.gwt.core.client.GWT; +/** + * Translatable version of JUnit's <code>TestCase</code>. + */ public class TestCase extends Assert implements Test { + private String name; + public int countTestCases() { return 1; } @@ -65,6 +70,4 @@ protected void tearDown() throws Exception { } - private String name; - }