Avro Fields and Autogeneration

32 views
Skip to first unread message

allan...@gmail.com

unread,
Feb 5, 2015, 1:45:41 PM2/5/15
to equalsv...@googlegroups.com
I just came across this project and it seem to fit the bill for what I needed. When testing it out, however, I ran across an error [1]. MyClass that is being tested contains a field that is an Apache Avro generated object and it doesn't work with the objects that EqualsVerifier auto-generates. I see how I can supply EqualsVerifier a list of unequal objects to test, but is there a way to also supply a list of equal object? If not, is this an enhancement that you see as valuable, or would one of the other equals testing tools be better suited to my use case?

[1]
java.lang.AssertionError: org.apache.avro.AvroRuntimeException: Unknown datum type: java.lang.Object@46238a47
at nl.jqno.equalsverifier.EqualsVerifier.handleError(EqualsVerifier.java:382)
at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:368)
at com.acme.MyClassTest.equalsContract(MyClassTest.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.apache.avro.AvroRuntimeException: Unknown datum type: java.lang.Object@46238a47
at org.apache.avro.generic.GenericData.getSchemaName(GenericData.java:632)
at org.apache.avro.specific.SpecificData.getSchemaName(SpecificData.java:265)
at org.apache.avro.generic.GenericData.resolveUnion(GenericData.java:597)
at org.apache.avro.generic.GenericData.compare(GenericData.java:839)
at org.apache.avro.specific.SpecificData.compare(SpecificData.java:296)
at org.apache.avro.generic.GenericData.compare(GenericData.java:814)
at org.apache.avro.specific.SpecificData.compare(SpecificData.java:296)
at org.apache.avro.generic.GenericData.compare(GenericData.java:841)
at org.apache.avro.specific.SpecificData.compare(SpecificData.java:296)
at org.apache.avro.generic.GenericData.compare(GenericData.java:814)
at org.apache.avro.specific.SpecificData.compare(SpecificData.java:296)
at org.apache.avro.specific.SpecificRecordBase.equals(SpecificRecordBase.java:46)
at com.google.common.base.Objects.equal(Objects.java:51)
at com.acme.MyClass.equals(MyClass.java:192)
at nl.jqno.equalsverifier.FieldsChecker$MutableStateFieldCheck.execute(FieldsChecker.java:306)
at nl.jqno.equalsverifier.FieldInspector.check(FieldInspector.java:37)
at nl.jqno.equalsverifier.FieldsChecker.check(FieldsChecker.java:64)
at nl.jqno.equalsverifier.EqualsVerifier.verifyWithExamples(EqualsVerifier.java:426)
at nl.jqno.equalsverifier.EqualsVerifier.performVerification(EqualsVerifier.java:395)
at nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:362)
... 26 more



Jan Ouwens

unread,
Feb 5, 2015, 2:45:42 PM2/5/15
to equalsv...@googlegroups.com
Hi Allan,

I'm not familiar with Apache Avro, so I can't really say what's going on right now. I want to help you, though. Can you please show me the code that led to this error? I need to see the class that you're testing, and the unit test containing the call to EqualsVerifier.


Thanks!

Jan


--
You received this message because you are subscribed to the Google Groups "equalsverifier" group.
To unsubscribe from this group and stop receiving emails from it, send an email to equalsverifie...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

allan...@gmail.com

unread,
Feb 6, 2015, 5:17:47 PM2/6/15
to equalsv...@googlegroups.com
I talked to Jan offline and he pointed me to the withPrefabValues method that can be used to supply values that can not be generated.
Reply all
Reply to author
Forward
0 new messages