Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made PlaceManagerImplTest independent of other tests #727

Merged
merged 1 commit into from
Aug 28, 2015

Conversation

rcpaul
Copy link

@rcpaul rcpaul commented Aug 27, 2015

To make PlaceManagerImplTest independent of PlaceManagerImpl2Test, we just need to add GWTMockUtilities.disarm(). This voids the need to have tests run in a specific order.

Whenever GWTMockUtilities.disarm() is called however, we should also call GWTMockUtilities.restore() somewhere when the test ends if we really want to do it by the book. There are other tests in which disarm is called without a corresponding restore (hence the previously indeterministic test behavior) but fixing this is behind the scope of this issue I think.

@olafleur
Copy link
Member

It's that simple? @Pacane could you review?

@meriouma
Copy link
Member

Good catch! What was the failure stacktrave before that change?

@Pacane
Copy link
Contributor

Pacane commented Aug 28, 2015

@olafleur This is the fix I intended to do for this issue. LGTM

olafleur pushed a commit that referenced this pull request Aug 28, 2015
Made PlaceManagerImplTest independent of other tests
@olafleur olafleur merged commit 396753e into ArcBees:master Aug 28, 2015
@rcpaul rcpaul deleted the test-fix branch August 28, 2015 05:14
@rcpaul
Copy link
Author

rcpaul commented Aug 28, 2015

@meriouma Thanks!

A stacktrace of the error:

Running com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest
Tests run: 4, Failures: 0, Errors: 4, Skipped: 0, Time elapsed: 0.309 sec <<< FAILURE! - in com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest
placeManagerRevealPlaceStandard(com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest)  Time elapsed: 0.051 sec  <<< ERROR!
com.google.inject.ProvisionException: Guice provision errors:

1) Error injecting constructor, java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code!  It cannot be called, for example, from server code.  If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
  at com.gwtplatform.mvp.client.proxy.PlaceManagerTestUtil.<init>(PlaceManagerTestUtil.java:38)
  while locating com.gwtplatform.mvp.client.proxy.PlaceManagerTestUtil
  at com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$Module.configureTest(PlaceManagerImplTest.java:62)
  while locating com.gwtplatform.mvp.client.proxy.PlaceManager
    for parameter 0 at com.gwtplatform.mvp.client.proxy.ProxyImpl.bind(ProxyImpl.java:68)
  at com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$Module.configureTest(PlaceManagerImplTest.java:65)
  while locating com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$DummyProxyBasic
    for parameter 0 at com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$DummyProxyPlaceBasic.<init>(PlaceManagerImplTest.java:118)
  at com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$Module.configureTest(PlaceManagerImplTest.java:66)
  while locating com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$DummyProxyPlaceBasic
    for parameter 1 at com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$DummyPresenterRedirect.<init>(PlaceManagerImplTest.java:136)
  at com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$Module.configureTest(PlaceManagerImplTest.java:63)
  while locating com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest$DummyPresenterRedirect
Caused by: java.lang.UnsupportedOperationException: ERROR: GWT.create() is only usable in client code!  It cannot be called, for example, from server code.  If you are running a unit test, check that your test case extends GWTTestCase and that GWT.create() is not called from within an initializer or constructor.
    at com.google.gwt.core.shared.GWT.createImpl(GWT.java:77)
    at com.google.gwt.core.shared.GWT.create(GWT.java:65)
    at com.gwtplatform.mvp.client.proxy.PlaceManagerImpl.<init>(PlaceManagerImpl.java:60)
    at com.gwtplatform.mvp.client.proxy.PlaceManagerTestUtil.<init>(PlaceManagerTestUtil.java:38)
    at com.gwtplatform.mvp.client.proxy.PlaceManagerTestUtil$$FastClassByGuice$$1ddc3f2.newInstance(<generated>)
    at com.google.inject.internal.cglib.reflect.$FastConstructor.newInstance(FastConstructor.java:40)
    at com.google.inject.internal.DefaultConstructionProxyFactory$1.newInstance(DefaultConstructionProxyFactory.java:60)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:85)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
    at com.google.inject.internal.FactoryProxy.get(FactoryProxy.java:54)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at org.jukito.TestScope$Singleton$1.get(TestScope.java:56)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.SingleMethodInjector.inject(SingleMethodInjector.java:83)
    at com.google.inject.internal.MembersInjectorImpl.injectMembers(MembersInjectorImpl.java:110)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:94)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at org.jukito.TestScope$Singleton$1.get(TestScope.java:56)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at org.jukito.TestScope$Singleton$1.get(TestScope.java:56)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:38)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:62)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:84)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:254)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:46)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1031)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at org.jukito.TestScope$Singleton$1.get(TestScope.java:56)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:40)
    at com.google.inject.internal.InjectorImpl$4$1.call(InjectorImpl.java:978)
    at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1024)
    at com.google.inject.internal.InjectorImpl$4.get(InjectorImpl.java:974)
    at org.jukito.JukitoRunner.instantiateEagerTestSingletons(JukitoRunner.java:364)
    at org.jukito.JukitoRunner.createTest(JukitoRunner.java:203)
    at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.jukito.JukitoRunner.run(JukitoRunner.java:197)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:264)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:153)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)

This error was triggered by
mvn Dtest=com.gwtplatform.mvp.client.proxy.PlaceManagerImplTest test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants