Add mockito to gwt user.
This also removes easymock from GWT codebase, so that
we only have one mocking framework going forward.
Change-Id: I4eb6ab2243e44561e3fecbcdbd2cad94b66482ed
diff --git a/eclipse/user/.classpath b/eclipse/user/.classpath
index 89d75a3..fda97e0 100644
--- a/eclipse/user/.classpath
+++ b/eclipse/user/.classpath
@@ -20,6 +20,7 @@
<classpathentry kind="var" path="GWT_TOOLS/lib/apache/commons/commons-logging-1.1.1.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/apache/commons/commons-io-2.4.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/cssparser/cssparser-0.9.11.jar"/>
+ <classpathentry kind="var" path="GWT_TOOLS/lib/mockito/1.9.5/mockito-all-1.9.5.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/nekohtml/nekohtml-1.9.19.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/selenium/selenium-java-client-driver.jar" sourcepath="/GWT_TOOLS/lib/selenium/selenium-java-client-driver-sources.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/cup/java-cup-11a.jar"/>
@@ -31,7 +32,6 @@
<classpathentry kind="var" path="GWT_TOOLS/lib/w3c/flute/flute-1.3-gg2.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/cglib/cglib-2.2.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/objenesis/objenesis-1.2.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/easymock/easymock-3.0.jar"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/objectweb/asm-3.1.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/gwt-dev"/>
<classpathentry kind="var" path="GWT_TOOLS/lib/htmlunit/htmlunit-2.13/htmlunit-2.13.jar"/>
diff --git a/user/build.xml b/user/build.xml
index 6675a82..4eecd46 100755
--- a/user/build.xml
+++ b/user/build.xml
@@ -52,8 +52,8 @@
<pathelement location="test_i18n_${gwt.i18n.test.InnerClassChar}"/>
<pathelement location="${gwt.tools.lib}/apache/log4j/log4j-1.2.16.jar"/>
<pathelement location="${gwt.tools.lib}/cglib/cglib-2.2.jar"/>
+ <pathelement location="${gwt.tools.lib}/mockito/1.9.5/mockito-all-1.9.5.jar"/>
<pathelement location="${gwt.tools.lib}/objenesis/objenesis-1.2.jar"/>
- <pathelement location="${gwt.tools.lib}/easymock/easymock-3.0.jar"/>
<pathelement location="${gwt.tools.lib}/objectweb/asm-3.1.jar"/>
<pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA.jar"/>
<pathelement location="${gwt.tools.lib}/javax/validation/validation-api-1.0.0.GA-sources.jar"/>
diff --git a/user/test/com/google/gwt/resources/rg/CssOutputTestCase.java b/user/test/com/google/gwt/resources/rg/CssOutputTestCase.java
index 95a1897..2f1d974 100644
--- a/user/test/com/google/gwt/resources/rg/CssOutputTestCase.java
+++ b/user/test/com/google/gwt/resources/rg/CssOutputTestCase.java
@@ -25,7 +25,10 @@
import junit.framework.TestCase;
-import org.easymock.EasyMock;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+import static org.mockito.Mockito.when;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
@@ -40,38 +43,33 @@
public void testOutputCssMapArtifact() throws UnableToCompleteException {
UnitTestTreeLogger testLogger = new UnitTestTreeLogger.Builder().createLogger();
- ResourceContext mockResourceContext = EasyMock.createMock(ResourceContext.class);
+ ResourceContext mockResourceContext = mock(ResourceContext.class);
Map<JMethod, String> testMap = new HashMap<JMethod, String>();
- OutputStream mockOutputStream = EasyMock.createMock(OutputStream.class);
- GeneratorContext mockGeneratorContext = EasyMock.createMock(GeneratorContext.class);
- GeneratedResource mockGeneratedResource = EasyMock.createMock(GeneratedResource.class);
+ OutputStream mockOutputStream = mock(OutputStream.class);
+ GeneratorContext mockGeneratorContext = mock(GeneratorContext.class);
+ GeneratedResource mockGeneratedResource = mock(GeneratedResource.class);
- EasyMock.expect(mockResourceContext.getGeneratorContext()).andReturn(mockGeneratorContext);
- EasyMock.expectLastCall().times(2);
- EasyMock.expect(mockGeneratorContext.tryCreateResource(
- testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap")).andReturn(mockOutputStream);
- EasyMock.expect(mockGeneratorContext.commitResource(testLogger, mockOutputStream)).andReturn(
+ when(mockResourceContext.getGeneratorContext()).thenReturn(mockGeneratorContext);
+ when(mockGeneratorContext.tryCreateResource(
+ testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap")).thenReturn(mockOutputStream);
+ when(mockGeneratorContext.commitResource(testLogger, mockOutputStream)).thenReturn(
mockGeneratedResource);
- JMethod method = EasyMock.createMock(JMethod.class);
- JClassType bundleType = EasyMock.createMock(JClassType.class);
- EasyMock.expect(method.getEnclosingType()).andReturn(bundleType);
- EasyMock.expect(bundleType.getQualifiedSourceName()).andReturn("com.test.Bundle");
- EasyMock.expect(method.getName()).andReturn("cssMethod");
-
- EasyMock.replay(mockResourceContext);
- EasyMock.replay(mockGeneratorContext);
- EasyMock.replay(method);
- EasyMock.replay(bundleType);
+ JMethod method = mock(JMethod.class);
+ JClassType bundleType = mock(JClassType.class);
+ when(method.getEnclosingType()).thenReturn(bundleType);
+ when(bundleType.getQualifiedSourceName()).thenReturn("com.test.Bundle");
+ when(method.getName()).thenReturn("cssMethod");
CssResourceGenerator crg = new CssResourceGenerator();
+ // Test the method
crg.outputCssMapArtifact(testLogger, mockResourceContext, method, testMap);
testLogger.assertCorrectLogEntries();
- EasyMock.verify(mockResourceContext);
- EasyMock.verify(mockGeneratorContext);
- EasyMock.verify(method);
- EasyMock.verify(bundleType);
+
+ verify(mockGeneratorContext).tryCreateResource(testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap");
+ verify(mockGeneratorContext).commitResource(testLogger, mockOutputStream);
+ verifyNoMoreInteractions(mockGeneratorContext);
}
public void testOutputCssMapArtifactThrowOnTryCreateResource() throws UnableToCompleteException {
@@ -79,68 +77,53 @@
builder.expectWarn(
"Could not create resource: cssResource/com.test.Bundle.cssMethod.cssmap", null);
UnitTestTreeLogger testLogger = builder.createLogger();
- ResourceContext mockResourceContext = EasyMock.createMock(ResourceContext.class);
+ ResourceContext mockResourceContext = mock(ResourceContext.class);
Map<JMethod, String> testMap = new HashMap<JMethod, String>();
- OutputStream mockOutputStream = EasyMock.createMock(OutputStream.class);
- GeneratorContext mockGeneratorContext = EasyMock.createMock(GeneratorContext.class);
- GeneratedResource mockGeneratedResource = EasyMock.createMock(GeneratedResource.class);
+ GeneratorContext mockGeneratorContext = mock(GeneratorContext.class);
- EasyMock.expect(mockResourceContext.getGeneratorContext()).andReturn(mockGeneratorContext);
- EasyMock.expect(mockGeneratorContext.tryCreateResource(testLogger,
- "cssResource/com.test.Bundle.cssMethod.cssmap")).andThrow(new UnableToCompleteException());
+ when(mockResourceContext.getGeneratorContext()).thenReturn(mockGeneratorContext);
+ when(mockGeneratorContext.tryCreateResource(testLogger,
+ "cssResource/com.test.Bundle.cssMethod.cssmap")).thenThrow(new UnableToCompleteException());
- JMethod method = EasyMock.createMock(JMethod.class);
- JClassType bundleType = EasyMock.createMock(JClassType.class);
- EasyMock.expect(method.getEnclosingType()).andReturn(bundleType);
- EasyMock.expect(bundleType.getQualifiedSourceName()).andReturn("com.test.Bundle");
- EasyMock.expect(method.getName()).andReturn("cssMethod");
-
- EasyMock.replay(mockResourceContext);
- EasyMock.replay(mockGeneratorContext);
- EasyMock.replay(method);
- EasyMock.replay(bundleType);
+ JMethod method = mock(JMethod.class);
+ JClassType bundleType = mock(JClassType.class);
+ when(method.getEnclosingType()).thenReturn(bundleType);
+ when(bundleType.getQualifiedSourceName()).thenReturn("com.test.Bundle");
+ when(method.getName()).thenReturn("cssMethod");
CssResourceGenerator crg = new CssResourceGenerator();
crg.outputCssMapArtifact(testLogger, mockResourceContext, method, testMap);
testLogger.assertCorrectLogEntries();
- EasyMock.verify(mockResourceContext);
- EasyMock.verify(mockGeneratorContext);
- EasyMock.verify(method);
- EasyMock.verify(bundleType);
+
+ verify(mockGeneratorContext).tryCreateResource(testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap");
+ verifyNoMoreInteractions(mockGeneratorContext);
}
public void testOutputCssMapArtifactReturnNullOutputString() throws UnableToCompleteException {
UnitTestTreeLogger testLogger = new UnitTestTreeLogger.Builder().createLogger();
- ResourceContext mockResourceContext = EasyMock.createMock(ResourceContext.class);
+ ResourceContext mockResourceContext = mock(ResourceContext.class);
Map<JMethod, String> testMap = new HashMap<JMethod, String>();
- OutputStream mockOutputStream = EasyMock.createMock(OutputStream.class);
- GeneratorContext mockGeneratorContext = EasyMock.createMock(GeneratorContext.class);
- GeneratedResource mockGeneratedResource = EasyMock.createMock(GeneratedResource.class);
+ GeneratorContext mockGeneratorContext = mock(GeneratorContext.class);
- EasyMock.expect(mockResourceContext.getGeneratorContext()).andReturn(mockGeneratorContext);
- EasyMock.expect(mockGeneratorContext.tryCreateResource(
- testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap")).andReturn(null);
+ when(mockResourceContext.getGeneratorContext()).thenReturn(mockGeneratorContext);
+ when(mockGeneratorContext.tryCreateResource(
+ testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap")).thenReturn(null);
- JMethod method = EasyMock.createMock(JMethod.class);
- JClassType bundleType = EasyMock.createMock(JClassType.class);
- EasyMock.expect(method.getEnclosingType()).andReturn(bundleType);
- EasyMock.expect(bundleType.getQualifiedSourceName()).andReturn("com.test.Bundle");
- EasyMock.expect(method.getName()).andReturn("cssMethod");
-
- EasyMock.replay(mockResourceContext);
- EasyMock.replay(mockGeneratorContext);
- EasyMock.replay(method);
- EasyMock.replay(bundleType);
+ JMethod method = mock(JMethod.class);
+ JClassType bundleType = mock(JClassType.class);
+ when(method.getEnclosingType()).thenReturn(bundleType);
+ when(bundleType.getQualifiedSourceName()).thenReturn("com.test.Bundle");
+ when(method.getName()).thenReturn("cssMethod");
CssResourceGenerator crg = new CssResourceGenerator();
crg.outputCssMapArtifact(testLogger, mockResourceContext, method, testMap);
testLogger.assertCorrectLogEntries();
- EasyMock.verify(mockResourceContext);
- EasyMock.verify(mockGeneratorContext);
- EasyMock.verify(method);
- EasyMock.verify(bundleType);
+
+ verify(mockGeneratorContext).tryCreateResource(testLogger,
+ "cssResource/com.test.Bundle.cssMethod.cssmap");
+ verifyNoMoreInteractions(mockGeneratorContext);
}
public void testOutputCssMapArtifactThrowOnCommitResource() throws UnableToCompleteException {
@@ -148,89 +131,69 @@
builder.expectWarn(
"Error trying to commit artifact: cssResource/com.test.Bundle.cssMethod.cssmap", null);
UnitTestTreeLogger testLogger = builder.createLogger();
- ResourceContext mockResourceContext = EasyMock.createMock(ResourceContext.class);
+ ResourceContext mockResourceContext = mock(ResourceContext.class);
Map<JMethod, String> testMap = new HashMap<JMethod, String>();
- OutputStream mockOutputStream = EasyMock.createMock(OutputStream.class);
- GeneratorContext mockGeneratorContext = EasyMock.createMock(GeneratorContext.class);
- GeneratedResource mockGeneratedResource = EasyMock.createMock(GeneratedResource.class);
+ OutputStream mockOutputStream = mock(OutputStream.class);
+ GeneratorContext mockGeneratorContext = mock(GeneratorContext.class);
- EasyMock.expect(mockResourceContext.getGeneratorContext()).andReturn(mockGeneratorContext);
- EasyMock.expectLastCall().times(2);
- EasyMock.expect(mockGeneratorContext.tryCreateResource(
- testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap")).andReturn(mockOutputStream);
- EasyMock.expect(mockGeneratorContext.commitResource(testLogger, mockOutputStream)).andThrow(
+ when(mockResourceContext.getGeneratorContext()).thenReturn(mockGeneratorContext);
+ when(mockGeneratorContext.tryCreateResource(
+ testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap")).thenReturn(mockOutputStream);
+ when(mockGeneratorContext.commitResource(testLogger, mockOutputStream)).thenThrow(
new UnableToCompleteException());
- JMethod method = EasyMock.createMock(JMethod.class);
- JClassType bundleType = EasyMock.createMock(JClassType.class);
- EasyMock.expect(method.getEnclosingType()).andReturn(bundleType);
- EasyMock.expect(bundleType.getQualifiedSourceName()).andReturn("com.test.Bundle");
- EasyMock.expect(method.getName()).andReturn("cssMethod");
-
- EasyMock.replay(mockResourceContext);
- EasyMock.replay(mockGeneratorContext);
- EasyMock.replay(method);
- EasyMock.replay(bundleType);
+ JMethod method = mock(JMethod.class);
+ JClassType bundleType = mock(JClassType.class);
+ when(method.getEnclosingType()).thenReturn(bundleType);
+ when(bundleType.getQualifiedSourceName()).thenReturn("com.test.Bundle");
+ when(method.getName()).thenReturn("cssMethod");
CssResourceGenerator crg = new CssResourceGenerator();
crg.outputCssMapArtifact(testLogger, mockResourceContext, method, testMap);
testLogger.assertCorrectLogEntries();
- EasyMock.verify(mockResourceContext);
- EasyMock.verify(mockGeneratorContext);
- EasyMock.verify(method);
- EasyMock.verify(bundleType);
+
+ verify(mockGeneratorContext).tryCreateResource(testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap");
+ verify(mockGeneratorContext).commitResource(testLogger, mockOutputStream);
}
public void testOutputCssMapArtifactWithTestData() throws UnableToCompleteException {
UnitTestTreeLogger testLogger = new UnitTestTreeLogger.Builder().createLogger();
- ResourceContext mockResourceContext = EasyMock.createMock(ResourceContext.class);
- JMethod mockJMethod1 = EasyMock.createMock(JMethod.class);
- JMethod mockJMethod2 = EasyMock.createMock(JMethod.class);
- JMethod mockJMethod3 = EasyMock.createMock(JMethod.class);
- JClassType mockJClassType1 = EasyMock.createMock(JClassType.class);
- JClassType mockJClassType2 = EasyMock.createMock(JClassType.class);
- JClassType mockJClassType3 = EasyMock.createMock(JClassType.class);
+ ResourceContext mockResourceContext = mock(ResourceContext.class);
+ JMethod mockJMethod1 = mock(JMethod.class);
+ JMethod mockJMethod2 = mock(JMethod.class);
+ JMethod mockJMethod3 = mock(JMethod.class);
+ JClassType mockJClassType1 = mock(JClassType.class);
+ JClassType mockJClassType2 = mock(JClassType.class);
+ JClassType mockJClassType3 = mock(JClassType.class);
Map<JMethod, String> testMap = new LinkedHashMap<JMethod, String>();
testMap.put(mockJMethod1, "TESTCSSNAME1");
testMap.put(mockJMethod2, "TESTCSSNAME2");
testMap.put(mockJMethod3, "TESTCSSNAME3");
ByteArrayOutputStream testOutputStream = new ByteArrayOutputStream();
- GeneratorContext mockGeneratorContext = EasyMock.createMock(GeneratorContext.class);
- GeneratedResource mockGeneratedResource = EasyMock.createMock(GeneratedResource.class);
+ GeneratorContext mockGeneratorContext = mock(GeneratorContext.class);
+ GeneratedResource mockGeneratedResource = mock(GeneratedResource.class);
- EasyMock.expect(mockResourceContext.getGeneratorContext()).andReturn(mockGeneratorContext);
- EasyMock.expectLastCall().times(2);
- EasyMock.expect(mockGeneratorContext.tryCreateResource(
- testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap")).andReturn(testOutputStream);
- EasyMock.expect(mockJMethod1.getEnclosingType()).andReturn(mockJClassType1);
- EasyMock.expect(mockJClassType1.getQualifiedSourceName()).andReturn("test.class.type.1");
- EasyMock.expect(mockJMethod1.getName()).andReturn("basename1");
- EasyMock.expect(mockJMethod2.getEnclosingType()).andReturn(mockJClassType2);
- EasyMock.expect(mockJClassType2.getQualifiedSourceName()).andReturn("test.class.type.2");
- EasyMock.expect(mockJMethod2.getName()).andReturn("basename2");
- EasyMock.expect(mockJMethod3.getEnclosingType()).andReturn(mockJClassType3);
- EasyMock.expect(mockJClassType3.getQualifiedSourceName()).andReturn("test.class.type.3");
- EasyMock.expect(mockJMethod3.getName()).andReturn("basename3");
- EasyMock.expect(mockGeneratorContext.commitResource(testLogger, testOutputStream)).andReturn(
+ when(mockResourceContext.getGeneratorContext()).thenReturn(mockGeneratorContext);
+ when(mockGeneratorContext.tryCreateResource(
+ testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap")).thenReturn(testOutputStream);
+ when(mockJMethod1.getEnclosingType()).thenReturn(mockJClassType1);
+ when(mockJClassType1.getQualifiedSourceName()).thenReturn("test.class.type.1");
+ when(mockJMethod1.getName()).thenReturn("basename1");
+ when(mockJMethod2.getEnclosingType()).thenReturn(mockJClassType2);
+ when(mockJClassType2.getQualifiedSourceName()).thenReturn("test.class.type.2");
+ when(mockJMethod2.getName()).thenReturn("basename2");
+ when(mockJMethod3.getEnclosingType()).thenReturn(mockJClassType3);
+ when(mockJClassType3.getQualifiedSourceName()).thenReturn("test.class.type.3");
+ when(mockJMethod3.getName()).thenReturn("basename3");
+ when(mockGeneratorContext.commitResource(testLogger, testOutputStream)).thenReturn(
mockGeneratedResource);
- JMethod method = EasyMock.createMock(JMethod.class);
- JClassType bundleType = EasyMock.createMock(JClassType.class);
- EasyMock.expect(method.getEnclosingType()).andReturn(bundleType);
- EasyMock.expect(bundleType.getQualifiedSourceName()).andReturn("com.test.Bundle");
- EasyMock.expect(method.getName()).andReturn("cssMethod");
-
- EasyMock.replay(mockResourceContext);
- EasyMock.replay(mockGeneratorContext);
- EasyMock.replay(mockJMethod1);
- EasyMock.replay(mockJMethod2);
- EasyMock.replay(mockJMethod3);
- EasyMock.replay(mockJClassType1);
- EasyMock.replay(mockJClassType2);
- EasyMock.replay(mockJClassType3);
- EasyMock.replay(method);
- EasyMock.replay(bundleType);
+ JMethod method = mock(JMethod.class);
+ JClassType bundleType = mock(JClassType.class);
+ when(method.getEnclosingType()).thenReturn(bundleType);
+ when(bundleType.getQualifiedSourceName()).thenReturn("com.test.Bundle");
+ when(method.getName()).thenReturn("cssMethod");
CssResourceGenerator crg = new CssResourceGenerator();
crg.outputCssMapArtifact(testLogger, mockResourceContext, method, testMap);
@@ -240,16 +203,8 @@
assertEquals(expectedOutput, testOutputStream.toString());
testLogger.assertCorrectLogEntries();
- EasyMock.verify(mockResourceContext);
- EasyMock.verify(mockGeneratorContext);
- EasyMock.verify(mockJMethod1);
- EasyMock.verify(mockJMethod2);
- EasyMock.verify(mockJMethod3);
- EasyMock.verify(mockJClassType1);
- EasyMock.verify(mockJClassType2);
- EasyMock.verify(mockJClassType3);
- EasyMock.verify(method);
- EasyMock.verify(bundleType);
- }
+ verify(mockGeneratorContext).tryCreateResource(testLogger, "cssResource/com.test.Bundle.cssMethod.cssmap");
+ verify(mockGeneratorContext).commitResource(testLogger, testOutputStream);
+ }
}
diff --git a/user/test/com/google/gwt/uibinder/rebind/FieldWriterOfExistingTypeTest.java b/user/test/com/google/gwt/uibinder/rebind/FieldWriterOfExistingTypeTest.java
index 63c0b0c..d8619be 100644
--- a/user/test/com/google/gwt/uibinder/rebind/FieldWriterOfExistingTypeTest.java
+++ b/user/test/com/google/gwt/uibinder/rebind/FieldWriterOfExistingTypeTest.java
@@ -15,14 +15,15 @@
*/
package com.google.gwt.uibinder.rebind;
-import static org.easymock.EasyMock.expect;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import com.google.gwt.core.ext.typeinfo.JClassType;
import junit.framework.TestCase;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
+import org.mockito.Mockito;
/**
* Tests for FieldWriterOfExistingType.
@@ -32,44 +33,37 @@
private static final String FIELD_NAME = "field_name";
private static final String QUALIFIED_SOURCE_NAME = "qualified_source_name";
- private IMocksControl control;
-
private JClassType type;
@Override
public void setUp() throws Exception {
super.setUp();
-
- control = EasyMock.createControl();
-
- type = control.createMock(JClassType.class);
+ type = mock(JClassType.class);
}
/**
* Null type not allowed, must fail.
*/
public void testNullType() throws Exception {
- control.replay();
try {
- FieldWriter field = new FieldWriterOfExistingType(null,
+ new FieldWriterOfExistingType(null,
FieldWriterType.DEFAULT, null, FIELD_NAME, MortalLogger.NULL);
fail("Expected exception not thrown.");
} catch (IllegalArgumentException e) {
// Expected
}
- control.verify();
+ Mockito.verifyZeroInteractions(type);
}
public void testType() throws Exception {
- expect(type.getQualifiedSourceName()).andReturn(QUALIFIED_SOURCE_NAME);
+ when(type.getQualifiedSourceName()).thenReturn(QUALIFIED_SOURCE_NAME);
- control.replay();
FieldWriter field = new FieldWriterOfExistingType(null,
FieldWriterType.DEFAULT, type, FIELD_NAME, MortalLogger.NULL);
assertSame(type, field.getAssignableType());
assertSame(type, field.getInstantiableType());
assertEquals(QUALIFIED_SOURCE_NAME, field.getQualifiedSourceName());
- control.verify();
+ verify(type).getQualifiedSourceName();
}
}
diff --git a/user/test/com/google/gwt/uibinder/rebind/FieldWriterOfLazyDomElementTest.java b/user/test/com/google/gwt/uibinder/rebind/FieldWriterOfLazyDomElementTest.java
index bdedb05..9ff2cc7 100644
--- a/user/test/com/google/gwt/uibinder/rebind/FieldWriterOfLazyDomElementTest.java
+++ b/user/test/com/google/gwt/uibinder/rebind/FieldWriterOfLazyDomElementTest.java
@@ -15,7 +15,8 @@
*/
package com.google.gwt.uibinder.rebind;
-import static org.easymock.EasyMock.expect;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.typeinfo.JClassType;
@@ -24,9 +25,6 @@
import junit.framework.TestCase;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
-
/**
* Tests for FieldWriterOfLazyDomElement.
*/
@@ -36,8 +34,6 @@
private static final String QUALIFIED_SOURCE_NAME = "qualified_source_name";
private static final String ARG_QUALIFIED_SOURCE_NAME = "arg_qualified_source_name";
- private IMocksControl control;
-
private JClassType templateFieldType;
private OwnerField ownerField;
private JClassType ownerFieldType;
@@ -46,14 +42,12 @@
public void setUp() throws Exception {
super.setUp();
- control = EasyMock.createControl();
+ templateFieldType = mock(JClassType.class);
+ ownerField = mock(OwnerField.class);
+ ownerFieldType = mock(JClassType.class);
- templateFieldType = control.createMock(JClassType.class);
- ownerField = control.createMock(OwnerField.class);
- ownerFieldType = control.createMock(JClassType.class);
-
- expect(ownerField.getName()).andStubReturn(FIELD_NAME);
- expect(ownerField.getRawType()).andStubReturn(ownerFieldType);
+ when(ownerField.getName()).thenReturn(FIELD_NAME);
+ when(ownerField.getRawType()).thenReturn(ownerFieldType);
}
/**
@@ -63,9 +57,8 @@
* </pre>
*/
public void testLazyDomElementNotParameterized() throws Exception {
- expect(ownerFieldType.isParameterized()).andReturn(null);
+ when(ownerFieldType.isParameterized()).thenReturn(null);
- control.replay();
try {
FieldWriter field = new FieldWriterOfLazyDomElement(null,
templateFieldType, ownerField, MortalLogger.NULL);
@@ -73,7 +66,6 @@
} catch (UnableToCompleteException utce) {
// Expected
}
- control.verify();
}
/**
@@ -89,48 +81,44 @@
* </pre>
*/
public void testLazyDomElementIncompatibleParameter() throws Exception {
- JParameterizedType parameterClass = control.createMock(JParameterizedType.class);
- expect(ownerFieldType.isParameterized()).andReturn(parameterClass);
+ JParameterizedType parameterClass = mock(JParameterizedType.class);
+ when(ownerFieldType.isParameterized()).thenReturn(parameterClass);
- JClassType arg = control.createMock(JClassType.class);
- expect(parameterClass.getTypeArgs()).andReturn(new JClassType[] { arg });
+ JClassType arg = mock(JClassType.class);
+ when(parameterClass.getTypeArgs()).thenReturn(new JClassType[] { arg });
- expect(templateFieldType.isAssignableTo(arg)).andReturn(false);
- expect(parameterClass.getQualifiedSourceName()).andStubReturn(QUALIFIED_SOURCE_NAME);
+ when(templateFieldType.isAssignableTo(arg)).thenReturn(false);
+ when(parameterClass.getQualifiedSourceName()).thenReturn(QUALIFIED_SOURCE_NAME);
- control.replay();
try {
- FieldWriter field = new FieldWriterOfLazyDomElement(null,
+ new FieldWriterOfLazyDomElement(null,
templateFieldType, ownerField, MortalLogger.NULL);
fail("Expected exception not thrown.");
} catch (UnableToCompleteException utce) {
// Expected
}
- control.verify();
}
/**
* The success test, everything works fine.
*/
public void testLazyDomElementCompatibleType() throws Exception {
- JParameterizedType parameterClass = control.createMock(JParameterizedType.class);
- expect(ownerFieldType.isParameterized()).andReturn(parameterClass);
+ JParameterizedType parameterClass = mock(JParameterizedType.class);
+ when(ownerFieldType.isParameterized()).thenReturn(parameterClass);
- JClassType arg = control.createMock(JClassType.class);
- expect(parameterClass.getTypeArgs()).andReturn(new JClassType[] { arg });
+ JClassType arg = mock(JClassType.class);
+ when(parameterClass.getTypeArgs()).thenReturn(new JClassType[] { arg });
- expect(templateFieldType.isAssignableTo(arg)).andReturn(true);
+ when(templateFieldType.isAssignableTo(arg)).thenReturn(true);
- expect(parameterClass.getQualifiedSourceName()).andStubReturn(QUALIFIED_SOURCE_NAME);
- expect(arg.getQualifiedSourceName()).andReturn(ARG_QUALIFIED_SOURCE_NAME);
+ when(parameterClass.getQualifiedSourceName()).thenReturn(QUALIFIED_SOURCE_NAME);
+ when(arg.getQualifiedSourceName()).thenReturn(ARG_QUALIFIED_SOURCE_NAME);
- control.replay();
FieldWriter field = new FieldWriterOfLazyDomElement(null,
templateFieldType, ownerField, MortalLogger.NULL);
assertSame(parameterClass, field.getAssignableType());
assertSame(parameterClass, field.getInstantiableType());
assertEquals(QUALIFIED_SOURCE_NAME + "<" + ARG_QUALIFIED_SOURCE_NAME + ">",
field.getQualifiedSourceName());
- control.verify();
}
}
diff --git a/user/test/com/google/gwt/uibinder/rebind/HandlerEvaluatorTest.java b/user/test/com/google/gwt/uibinder/rebind/HandlerEvaluatorTest.java
index c4a0b1d..ebaa500 100644
--- a/user/test/com/google/gwt/uibinder/rebind/HandlerEvaluatorTest.java
+++ b/user/test/com/google/gwt/uibinder/rebind/HandlerEvaluatorTest.java
@@ -24,8 +24,8 @@
import junit.framework.TestCase;
-import org.easymock.EasyMock;
-import org.easymock.IMocksControl;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -38,9 +38,6 @@
HandlerEvaluator evaluator;
- // Defines the mock control.
- private IMocksControl mockControl;
-
private OwnerClass ownerType;
private MortalLogger logger;
private TypeOracle oracle;
@@ -53,31 +50,22 @@
logger = new MortalLogger(new PrintWriterTreeLogger());
// Creates all needed mocks.
- mockControl = EasyMock.createControl();
- ownerType = mockControl.createMock(OwnerClass.class);
- oracle = mockControl.createMock(TypeOracle.class);
- fieldManager = mockControl.createMock(FieldManager.class);
-
- // TODO(hermes): sucks I know!!!! This class shouldn't be using EasyMock
- // but for now that's the easiest way of creating new instances of
- // TypeOracle, TreeLogger, etc. Again, I must check a better way of
- // injecting TypeOracle, TreeLogger and JClassType.
-
- JClassType handlerRegistrationJClass = mockControl.createMock(JClassType.class);
- EasyMock.expect(oracle.findType(HandlerRegistration.class.getName())).andReturn(
- handlerRegistrationJClass);
-
- JClassType eventHandlerJClass = mockControl.createMock(JClassType.class);
- EasyMock.expect(oracle.findType(EventHandler.class.getName())).andReturn(
- eventHandlerJClass);
-
- mockControl.replay();
- evaluator = new HandlerEvaluator(ownerType, logger, oracle, false);
- mockControl.verify();
- mockControl.reset();
+ ownerType = mock(OwnerClass.class);
+ oracle = mock(TypeOracle.class);
+ fieldManager = mock(FieldManager.class);
}
public void testWriteAddHandler() throws Exception {
+ JClassType handlerRegistrationJClass = mock(JClassType.class);
+ when(oracle.findType(HandlerRegistration.class.getName())).thenReturn(
+ handlerRegistrationJClass);
+
+ JClassType eventHandlerJClass = mock(JClassType.class);
+ when(oracle.findType(EventHandler.class.getName())).thenReturn(
+ eventHandlerJClass);
+
+ evaluator = new HandlerEvaluator(ownerType, logger, oracle, false);
+
StringWriter sw = new StringWriter();
evaluator.writeAddHandler(new IndentedWriter(new PrintWriter(sw)),
fieldManager, "handler1", "addClickHandler", "label1");
diff --git a/user/test/com/google/gwt/uibinder/rebind/JClassTypeAdapter.java b/user/test/com/google/gwt/uibinder/rebind/JClassTypeAdapter.java
index c170dbb..94489a7 100644
--- a/user/test/com/google/gwt/uibinder/rebind/JClassTypeAdapter.java
+++ b/user/test/com/google/gwt/uibinder/rebind/JClassTypeAdapter.java
@@ -15,9 +15,6 @@
*/
package com.google.gwt.uibinder.rebind;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.isA;
-
import com.google.gwt.core.ext.typeinfo.HasAnnotations;
import com.google.gwt.core.ext.typeinfo.HasTypeParameters;
import com.google.gwt.core.ext.typeinfo.JAbstractMethod;
@@ -29,8 +26,12 @@
import com.google.gwt.core.ext.typeinfo.JPrimitiveType;
import com.google.gwt.core.ext.typeinfo.JType;
-import org.easymock.EasyMock;
-import org.easymock.IAnswer;
+import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.when;
+
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
@@ -78,10 +79,6 @@
new HashMap<Class<?>, JClassType>();
private final List<Object> allMocks = new ArrayList<Object>();
- public void verifyAll() {
- EasyMock.verify(allMocks.toArray());
- }
-
/**
* Creates a mock GWT class type for the given Java class.
*
@@ -112,9 +109,9 @@
// TODO(rdamazio): Add generics behaviour
// Add behaviour for getting methods
- expect(type.getMethods()).andStubAnswer(new IAnswer<JMethod[]>() {
- public JMethod[] answer() throws Throwable {
- // TODO(rdamazio): Check behaviour for parent methods
+ when(type.getMethods()).thenAnswer(new Answer<JMethod[]>() {
+ @Override
+ public JMethod[] answer(InvocationOnMock invocation) throws Throwable {
Method[] realMethods = clazz.getDeclaredMethods();
JMethod[] methods = new JMethod[realMethods.length];
for (int i = 0; i < realMethods.length; i++) {
@@ -125,8 +122,9 @@
});
// Add behaviour for getting constructors
- expect(type.getConstructors()).andStubAnswer(new IAnswer<JConstructor[]>() {
- public JConstructor[] answer() throws Throwable {
+ when(type.getConstructors()).thenAnswer(new Answer<JConstructor[]>() {
+ @Override
+ public JConstructor[] answer(InvocationOnMock invocation) throws Throwable {
Constructor<?>[] realConstructors = clazz.getDeclaredConstructors();
JConstructor[] constructors = new JConstructor[realConstructors.length];
for (int i = 0; i < realConstructors.length; i++) {
@@ -137,8 +135,9 @@
});
// Add behaviour for getting fields
- expect(type.getFields()).andStubAnswer(new IAnswer<JField[]>() {
- public JField[] answer() throws Throwable {
+ when(type.getFields()).thenAnswer(new Answer<JField[]>() {
+ @Override
+ public JField[] answer(InvocationOnMock invocation) throws Throwable {
Field[] realFields = clazz.getDeclaredFields();
JField[] fields = new JField[realFields.length];
for (int i = 0; i < realFields.length; i++) {
@@ -149,33 +148,34 @@
});
// Add behaviour for getting names
- expect(type.getName()).andStubReturn(clazz.getName());
- expect(type.getQualifiedSourceName()).andStubReturn(
+ when(type.getName()).thenReturn(clazz.getName());
+ when(type.getQualifiedSourceName()).thenReturn(
clazz.getCanonicalName());
- expect(type.getSimpleSourceName()).andStubReturn(clazz.getSimpleName());
+ when(type.getSimpleSourceName()).thenReturn(clazz.getSimpleName());
// Add modifier behaviour
int modifiers = clazz.getModifiers();
- expect(type.isAbstract()).andStubReturn(Modifier.isAbstract(modifiers));
- expect(type.isFinal()).andStubReturn(Modifier.isFinal(modifiers));
- expect(type.isPublic()).andStubReturn(Modifier.isPublic(modifiers));
- expect(type.isProtected()).andStubReturn(Modifier.isProtected(modifiers));
- expect(type.isPrivate()).andStubReturn(Modifier.isPrivate(modifiers));
+ when(type.isAbstract()).thenReturn(Modifier.isAbstract(modifiers));
+ when(type.isFinal()).thenReturn(Modifier.isFinal(modifiers));
+ when(type.isPublic()).thenReturn(Modifier.isPublic(modifiers));
+ when(type.isProtected()).thenReturn(Modifier.isProtected(modifiers));
+ when(type.isPrivate()).thenReturn(Modifier.isPrivate(modifiers));
// Add conversion behaviours
- expect(type.isArray()).andStubReturn(null);
- expect(type.isEnum()).andStubReturn(null);
- expect(type.isPrimitive()).andStubReturn(null);
- expect(type.isClassOrInterface()).andStubReturn(type);
+ when(type.isArray()).thenReturn(null);
+ when(type.isEnum()).thenReturn(null);
+ when(type.isPrimitive()).thenReturn(null);
+ when(type.isClassOrInterface()).thenReturn(type);
if (clazz.isInterface()) {
- expect(type.isClass()).andStubReturn(null);
- expect(type.isInterface()).andStubReturn(type);
+ when(type.isClass()).thenReturn(null);
+ when(type.isInterface()).thenReturn(type);
} else {
- expect(type.isClass()).andStubReturn(type);
- expect(type.isInterface()).andStubReturn(null);
+ when(type.isClass()).thenReturn(type);
+ when(type.isInterface()).thenReturn(null);
}
- expect(type.getEnclosingType()).andStubAnswer(new IAnswer<JClassType>() {
- public JClassType answer() throws Throwable {
+ when(type.getEnclosingType()).thenAnswer(new Answer<JClassType>() {
+ @Override
+ public JClassType answer(InvocationOnMock invocation) throws Throwable {
Class<?> enclosingClass = clazz.getEnclosingClass();
if (enclosingClass == null) {
return null;
@@ -184,8 +184,9 @@
return adaptJavaClass(enclosingClass);
}
});
- expect(type.getSuperclass()).andStubAnswer(new IAnswer<JClassType>() {
- public JClassType answer() throws Throwable {
+ when(type.getSuperclass()).thenAnswer(new Answer<JClassType>() {
+ @Override
+ public JClassType answer(InvocationOnMock invocation) throws Throwable {
Class<?> superclass = clazz.getSuperclass();
if (superclass == null) {
return null;
@@ -199,7 +200,6 @@
// TODO(rdamazio): Figure out what to do with reflections that GWT allows
// but Java doesn't
- EasyMock.replay(type);
return type;
}
@@ -215,16 +215,16 @@
addAnnotationBehaviour(realField, field);
- expect(field.getType()).andStubAnswer(new IAnswer<JType>() {
- public JType answer() throws Throwable {
+ when(field.getType()).thenAnswer(new Answer<JType>() {
+ @Override
+ public JType answer(InvocationOnMock invocation) throws Throwable {
return adaptType(realField.getType());
}
});
- expect(field.getEnclosingType()).andStubReturn(enclosingType);
- expect(field.getName()).andStubReturn(realField.getName());
+ when(field.getEnclosingType()).thenReturn(enclosingType);
+ when(field.getName()).thenReturn(realField.getName());
- EasyMock.replay(field);
return field;
}
@@ -244,18 +244,20 @@
addAnnotationBehaviour(realConstructor, constructor);
// Parameters
- expect(constructor.getParameters()).andStubAnswer(
- new IAnswer<JParameter[]>() {
- public JParameter[] answer() throws Throwable {
+ when(constructor.getParameters()).thenAnswer(
+ new Answer<JParameter[]>() {
+ @Override
+ public JParameter[] answer(InvocationOnMock invocation) throws Throwable {
return adaptParameters(realConstructor.getParameterTypes(),
realConstructor.getParameterAnnotations(), constructor);
}
});
// Thrown exceptions
- expect(constructor.getThrows()).andStubAnswer(
- new IAnswer<JClassType[]>() {
- public JClassType[] answer() throws Throwable {
+ when(constructor.getThrows()).thenAnswer(
+ new Answer<JClassType[]>() {
+ @Override
+ public JClassType[] answer(InvocationOnMock invocation) throws Throwable {
Class<?>[] realThrows = realConstructor.getExceptionTypes();
JClassType[] gwtThrows = new JClassType[realThrows.length];
for (int i = 0; i < realThrows.length; i++) {
@@ -265,7 +267,6 @@
}
});
- EasyMock.replay(constructor);
return constructor;
}
@@ -285,27 +286,30 @@
addAnnotationBehaviour(realMethod, method);
addGenericsBehaviour(realMethod, method);
- expect(method.isStatic()).andStubReturn(
+ when(method.isStatic()).thenReturn(
Modifier.isStatic(realMethod.getModifiers()));
// Return type
- expect(method.getReturnType()).andStubAnswer(new IAnswer<JType>() {
- public JType answer() throws Throwable {
+ when(method.getReturnType()).thenAnswer(new Answer<JType>() {
+ @Override
+ public JType answer(InvocationOnMock invocation) throws Throwable {
return adaptType(realMethod.getReturnType());
}
});
// Parameters
- expect(method.getParameters()).andStubAnswer(new IAnswer<JParameter[]>() {
- public JParameter[] answer() throws Throwable {
+ when(method.getParameters()).thenAnswer(new Answer<JParameter[]>() {
+ @Override
+ public JParameter[] answer(InvocationOnMock invocation) throws Throwable {
return adaptParameters(realMethod.getParameterTypes(),
realMethod.getParameterAnnotations(), method);
}
});
// Thrown exceptions
- expect(method.getThrows()).andStubAnswer(new IAnswer<JClassType[]>() {
- public JClassType[] answer() throws Throwable {
+ when(method.getThrows()).thenAnswer(new Answer<JClassType[]>() {
+ @Override
+ public JClassType[] answer(InvocationOnMock invocation) throws Throwable {
Class<?>[] realThrows = realMethod.getExceptionTypes();
JClassType[] gwtThrows = new JClassType[realThrows.length];
for (int i = 0; i < realThrows.length; i++) {
@@ -315,7 +319,6 @@
}
});
- EasyMock.replay(method);
return method;
}
@@ -340,9 +343,10 @@
// TODO(rdamazio): getName() has no plain java equivalent.
// Perhaps compiling with -g:vars ?
- expect(parameter.getEnclosingMethod()).andStubReturn(method);
- expect(parameter.getType()).andStubAnswer(new IAnswer<JType>() {
- public JType answer() throws Throwable {
+ when(parameter.getEnclosingMethod()).thenReturn(method);
+ when(parameter.getType()).thenAnswer(new Answer<JType>() {
+ @Override
+ public JType answer(InvocationOnMock invocation) throws Throwable {
return adaptType(realParameterType);
}
});
@@ -350,12 +354,14 @@
// Add annotation behaviour
final Annotation[] annotations = parameterAnnotations[i];
- expect(parameter.isAnnotationPresent(isA(Class.class))).andStubAnswer(
- new IAnswer<Boolean>() {
- public Boolean answer() throws Throwable {
+ when(parameter.isAnnotationPresent(any(Class.class))).thenAnswer(
+ new Answer<Boolean>() {
+
+ @Override
+ public Boolean answer(InvocationOnMock invocation) throws Throwable {
Class<? extends Annotation> annotationClass =
(Class<? extends Annotation>)
- EasyMock.getCurrentArguments()[0];
+ invocation.getArguments()[0];
for (Annotation annotation : annotations) {
if (annotation.equals(annotationClass)) {
return true;
@@ -365,12 +371,13 @@
}
});
- expect(parameter.getAnnotation(isA(Class.class))).andStubAnswer(
- new IAnswer<Annotation>() {
- public Annotation answer() throws Throwable {
+ when(parameter.getAnnotation(any(Class.class))).thenAnswer(
+ new Answer<Annotation>() {
+ @Override
+ public Annotation answer(InvocationOnMock invocation) throws Throwable {
Class<? extends Annotation> annotationClass =
(Class<? extends Annotation>)
- EasyMock.getCurrentArguments()[0];
+ invocation.getArguments()[0];
for (Annotation annotation : annotations) {
if (annotation.equals(annotationClass)) {
return annotation;
@@ -379,8 +386,6 @@
return null;
}
});
-
- EasyMock.replay(parameter);
}
return parameters;
@@ -433,11 +438,11 @@
JAbstractMethod member, JClassType enclosingType) {
// Attributes
int modifiers = realMember.getModifiers();
- expect(member.isPublic()).andStubReturn(Modifier.isPublic(modifiers));
- expect(member.isProtected()).andStubReturn(Modifier.isProtected(modifiers));
- expect(member.isPrivate()).andStubReturn(Modifier.isPrivate(modifiers));
- expect(member.getName()).andStubReturn(realMember.getName());
- expect(member.getEnclosingType()).andStubReturn(enclosingType);
+ when(member.isPublic()).thenReturn(Modifier.isPublic(modifiers));
+ when(member.isProtected()).thenReturn(Modifier.isProtected(modifiers));
+ when(member.isPrivate()).thenReturn(Modifier.isPrivate(modifiers));
+ when(member.getName()).thenReturn(realMember.getName());
+ when(member.getEnclosingType()).thenReturn(enclosingType);
}
/**
@@ -450,20 +455,22 @@
@SuppressWarnings("unchecked")
private void addAnnotationBehaviour(final AnnotatedElement realElement,
final HasAnnotations element) {
- expect(element.isAnnotationPresent(isA(Class.class))).andStubAnswer(
- new IAnswer<Boolean>() {
- public Boolean answer() throws Throwable {
+ when(element.isAnnotationPresent(any(Class.class))).thenAnswer(
+ new Answer<Boolean>() {
+ @Override
+ public Boolean answer(InvocationOnMock invocation) throws Throwable {
Class<? extends Annotation> annotationClass =
- (Class<? extends Annotation>) EasyMock.getCurrentArguments()[0];
+ (Class<? extends Annotation>) invocation.getArguments()[0];
return realElement.isAnnotationPresent(annotationClass);
}
});
- expect(element.getAnnotation(isA(Class.class))).andStubAnswer(
- new IAnswer<Annotation>() {
- public Annotation answer() throws Throwable {
+ when(element.getAnnotation(any(Class.class))).thenAnswer(
+ new Answer<Annotation>() {
+ @Override
+ public Annotation answer(InvocationOnMock invocation) throws Throwable {
Class<? extends Annotation> annotationClass =
- (Class<? extends Annotation>) EasyMock.getCurrentArguments()[0];
+ (Class<? extends Annotation>) invocation.getArguments()[0];
return realElement.getAnnotation(annotationClass);
}
});
@@ -489,7 +496,7 @@
* @return the mock
*/
private <T> T createMock(Class<T> clazz) {
- T mock = EasyMock.createMock(clazz);
+ T mock = Mockito.mock(clazz);
allMocks.add(mock);
return mock;
}
diff --git a/user/test/com/google/gwt/uibinder/rebind/model/OwnerFieldClassTest.java b/user/test/com/google/gwt/uibinder/rebind/model/OwnerFieldClassTest.java
index a9cdc01..8e47183 100644
--- a/user/test/com/google/gwt/uibinder/rebind/model/OwnerFieldClassTest.java
+++ b/user/test/com/google/gwt/uibinder/rebind/model/OwnerFieldClassTest.java
@@ -80,8 +80,6 @@
// Check that the same instance of the model is returned if asked again
assertSame(fieldClass,
OwnerFieldClass.getFieldClass(htmlType, MortalLogger.NULL, uiBinderCtx));
-
- gwtTypeAdapter.verifyAll();
}
/**
@@ -156,14 +154,14 @@
}
/**
- *
+ *
* base class for setters disambiguation tests.
*
*/
public class baseSetters {
public baseSetters() {
}
-
+
// setvalue1 is not ambiguous
public void setValue1(@SuppressWarnings("unused") boolean b) {
}
@@ -178,39 +176,39 @@
// this overload wins
public void setValue3(@SuppressWarnings("unused") int b) {
}
-
+
// this is not ambiguous since derived
// has the exact same signature
public void setValue4(@SuppressWarnings("unused") int b) {
}
-
+
// setvalue5 is ambiguous
public void setValue5(@SuppressWarnings("unused") float f) {
}
-
+
public void setValue5(@SuppressWarnings("unused") double d) {
}
-
+
// string always wins
public void setValue6(@SuppressWarnings("unused") String s) {
}
public void setValue6(@SuppressWarnings("unused") char s) {
}
-
+
public void setValue6(@SuppressWarnings("unused") Object s) {
}
-
+
// primitive wins
public void setValue7(@SuppressWarnings("unused") int s) {
}
-
+
public void setValue7(@SuppressWarnings("unused") StringBuffer s) {
}
}
/**
- *
+ *
* derived class for setter disambiguation tests.
*
*/
@@ -218,13 +216,13 @@
public derivedSetters() {
super();
}
-
+
public void setValue2(@SuppressWarnings("unused") int b) {
}
-
+
public void setValue3(@SuppressWarnings("unused") Integer b) {
}
-
+
@Override
public void setValue4(int b) {
}
@@ -239,8 +237,8 @@
MortalLogger.NULL, uiBinderCtx);
JMethod setValueSetter = settersClass.getSetter("value");
assertNotNull(setValueSetter);
- }
-
+ }
+
public void testDisambiguateClassHierarchySettersBase() throws Exception {
// ensure that primitive types win over boxed primitive types.
JClassType baseClassType = gwtTypeAdapter.adaptJavaClass(baseSetters.class);
@@ -256,22 +254,22 @@
JClassType derivedClass = gwtTypeAdapter.adaptJavaClass(derivedSetters.class);
OwnerFieldClass settersClass = OwnerFieldClass.getFieldClass(derivedClass,
MortalLogger.NULL, uiBinderCtx);
-
- // base.value1(boolean) and base.value1(Boolean) is never ambiguous
+
+ // base.value1(boolean) and base.value1(Boolean) is never ambiguous
// must return boolean
assertNotNull(settersClass.getSetter("value1"));
assertMethod(settersClass.getSetter("value1"), "setValue1", JPrimitiveType.BOOLEAN);
-
+
// base.value2(Integer) and derived.value2(int) is not ambiguous - must be int
assertNotNull(settersClass.getSetter("value2"));
assertMethod(settersClass.getSetter("value2"), "setValue2", JPrimitiveType.INT);
-
+
// base.value3 (int) and derived.value3(Integer) is not ambiguous - must be int.
assertNotNull(settersClass.getSetter("value3"));
-
+
// base.value4(int) and derived.value4(int) is not ambiguous.
assertNotNull(settersClass.getSetter("value4"));
-
+
// base.value5(float) and base.value5(double) is ambiguous
try {
settersClass.getSetter("value5");
@@ -279,19 +277,19 @@
} catch (UnableToCompleteException utce) {
// Expected
}
-
+
// value6 has multiple overload but string always wins
// base.value6(string), base.value6(char) and base.value6(object)
assertNotNull(settersClass.getSetter("value6"));
- assertMethod(settersClass.getSetter("value6"), "setValue6",
+ assertMethod(settersClass.getSetter("value6"), "setValue6",
gwtTypeAdapter.adaptJavaClass(String.class));
-
+
// base.value7(object) and base.value7(int) is not ambiguous - must be int.
assertNotNull(settersClass.getSetter("value7"));
- assertMethod(settersClass.getSetter("value7"), "setValue7",
+ assertMethod(settersClass.getSetter("value7"), "setValue7",
JPrimitiveType.INT);
}
-
+
public void testOwnerFieldClass_setters() throws Exception {
JClassType settersType = gwtTypeAdapter.adaptJavaClass(SettersTestClass.class);
JClassType stringType = gwtTypeAdapter.adaptJavaClass(String.class);
@@ -310,8 +308,6 @@
assertNull(settersClass.getSetter("notASetter"));
assertNull(settersClass.getSetter("aSetter"));
assertNull(settersClass.getSetter("static"));
-
- gwtTypeAdapter.verifyAll();
}
public void testOwnerFieldClass_ambiguousSetters() throws Exception {
@@ -330,8 +326,6 @@
} catch (UnableToCompleteException utce) {
// Expected
}
-
- gwtTypeAdapter.verifyAll();
}
/**
@@ -433,8 +427,6 @@
assertNull(settersClass.getSetter("notASetter"));
assertNull(settersClass.getSetter("aSetter"));
assertNull(settersClass.getSetter("static"));
-
- gwtTypeAdapter.verifyAll();
}
/**
@@ -475,8 +467,6 @@
Pair<JMethod, Integer> secondPair = childMethods.get("second");
assertEquals("doesNotStartWithAdd", secondPair.left.getName());
assertEquals(Integer.valueOf(4), secondPair.right);
-
- gwtTypeAdapter.verifyAll();
}
public void testOwnerFieldClass_withNoUiChildren() throws Exception {
@@ -488,8 +478,6 @@
Map<String, Pair<JMethod, Integer>> childMethods = parentClass.getUiChildMethods();
assertNotNull(childMethods);
assertEquals(0, childMethods.size());
-
- gwtTypeAdapter.verifyAll();
}
/**
@@ -514,7 +502,6 @@
OwnerFieldClass.getFieldClass(parentType, MortalLogger.NULL, uiBinderCtx);
fail("Class should error because @UiChild method has invalid name (and no tag specified).");
} catch (UnableToCompleteException expected) {
- gwtTypeAdapter.verifyAll();
}
}
@@ -543,8 +530,6 @@
JParameter[] parameters = constructor.getParameters();
assertEquals(1, parameters.length);
assertEquals(JPrimitiveType.BOOLEAN, parameters[0].getType());
-
- gwtTypeAdapter.verifyAll();
}
/**
diff --git a/user/test/com/google/gwt/uibinder/rebind/model/OwnerFieldTest.java b/user/test/com/google/gwt/uibinder/rebind/model/OwnerFieldTest.java
index bd22597..94ea21a 100644
--- a/user/test/com/google/gwt/uibinder/rebind/model/OwnerFieldTest.java
+++ b/user/test/com/google/gwt/uibinder/rebind/model/OwnerFieldTest.java
@@ -76,8 +76,6 @@
assertEquals("providedField", providedOwnerField.getName());
assertEquals(buttonType, providedOwnerField.getType().getRawType());
assertTrue(providedOwnerField.isProvided());
-
- gwtTypeAdapter.verifyAll();
}
public void testOwnerField_badFieldType() throws Exception {
@@ -89,8 +87,6 @@
} catch (UnableToCompleteException utce) {
// Expected
}
-
- gwtTypeAdapter.verifyAll();
}
public void testOwnerField_missingAnnotation() throws Exception {
@@ -102,7 +98,5 @@
} catch (UnableToCompleteException utce) {
// Expected
}
-
- gwtTypeAdapter.verifyAll();
}
}