vlingo / xoom-schemata

The VLINGO XOOM Schema Registry.
https://vlingo.io
Mozilla Public License 2.0
17 stars 9 forks source link

Failing tests after update to 0.9.1-RC2 #59

Closed wwerner closed 4 years ago

wwerner commented 4 years ago

Since the update to 0.9.1-RC2, most unit tests in schemata fail with the exception below.

It seems the Grid c'tor has been replaced by static factory methods in this version as of https://github.com/vlingo/vlingo-lattice/commit/d1de410aeae8b8be6ae5650ff6d8820c73bb52ae which is still used in actors.World: https://github.com/vlingo/vlingo-actors/blob/master/src/main/java/io/vlingo/actors/World.java#L430

java.lang.IllegalStateException: World cannot create new stage: vlingo-schemata-grid because: io.vlingo.lattice.grid.Grid.<init>(io.vlingo.actors.World, io.vlingo.actors.AddressFactory, java.lang.String)

    at io.vlingo.actors.World.stageNamed(World.java:439)
    at io.vlingo.schemata.Bootstrap.<init>(Bootstrap.java:37)
    at io.vlingo.schemata.Bootstrap.instance(Bootstrap.java:87)
    at io.vlingo.schemata.BootstrapTest.testThatBootstrapStartsServerCleanly(BootstrapTest.java:18)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    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.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.NoSuchMethodException: io.vlingo.lattice.grid.Grid.<init>(io.vlingo.actors.World, io.vlingo.actors.AddressFactory, java.lang.String)
    at java.lang.Class.getConstructor0(Class.java:3082)
    at java.lang.Class.getConstructor(Class.java:1825)
    at io.vlingo.actors.World.stageNamed(World.java:430)
    ... 25 more
wwerner commented 4 years ago

From what I can see, io.vlingo.actors.World#stageNamed(java.lang.String, java.lang.Class<? extends io.vlingo.actors.Stage>, io.vlingo.actors.AddressFactory) is the only place where a Stage is registered with World.

Creating the Stage like this stage = Grid.startWith(world, new GridAddressFactory(IdentityGeneratorType.RANDOM),Schemata.StageName); does not make the World aware of the new stage. This has the effect that an additional Stage with a wrong AddressFactory is created, leading to, e.g.

java.lang.NumberFormatException: For input string: "9542cc78-fe9c-4c08-95a5-b89b9b5306d5"

    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:589)
    at java.lang.Long.parseLong(Long.java:631)
    at io.vlingo.actors.BasicAddressFactory.from(BasicAddressFactory.java:35)
    at io.vlingo.schemata.model.Context.with(Context.java:40)
    at io.vlingo.schemata.model.Context.with(Context.java:31)
    at io.vlingo.schemata.resource.ContextResource.defineWith(ContextResource.java:55)
    at io.vlingo.schemata.resource.ContextResourceTest.testThatContextIsDefined(ContextResourceTest.java:31)
wwerner commented 4 years ago

Whithout knowing why Grid's c'tor was made private, I'm not sure about the right way to resolve this.

Options: 1) Simply make Grid.<init> public again. I did this locally so I can continue and can push it if this is the correct solution. 2) Re-write io.vlingo.actors.World#stageNamed(java.lang.String, java.lang.Class<? extends io.vlingo.actors.Stage>, io.vlingo.actors.AddressFactory) not to use the constructor. I'd guess this could spread widely through the platform and would require additional changes. 3) Allow for adding Stages to an existing World and using that from io.vlingo.lattice.grid.Grid#startWith(io.vlingo.actors.World, io.vlingo.actors.AddressFactory, java.lang.String)

Any wisdom to share, @VaughnVernon?

VaughnVernon commented 4 years ago

@wwerner I made the ctor private in favor of a factory method but overlooked that dependency. The fix is committed in vlingo-lattice. (Sorry forgot to #59 on it.)

VaughnVernon commented 4 years ago

Fixed https://github.com/vlingo/vlingo-lattice/commit/f2eae71cfe7eb1806a5924a4958e38be73531f1e