Problem with abstract superclass

299 views
Skip to first unread message

Thiago Augusto V. Lima

unread,
Jul 24, 2010, 2:08:37 AM7/24/10
to equalsverifier
I followed the example by Richard Jepps @ http://tal.forum2.org/equals,
except that my "Point" class (actually, it's name is ClienteAbstrato)
is, as you could guess, abstract. The "ColorPoint" class is
"ClientePF". I would understand an "abstract delegation" error or
something, but not this "symmetry" problem (unless Richard Jepps
"template" fails if the superclass is abstract...)

The backtrace is below. Thanks for any help...

junit.framework.AssertionFailedError: Symmetry:
HIDDEN.base.cliente.ClientePF@ee004eb4
does not equal superclass instance
HIDDEN.base.cliente.ClienteAbstrato$$EnhancerByCGLIB$$79687366@5
at nl.jqno.equalsverifier.util.Assert.fail(Assert.java:96)
at
nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:310)
at
br.com.manutencaodesoftware.ogro.base.cliente.ClientePFTest.testEquals(ClientePFTest.java:
66)

Jan Ouwens

unread,
Jul 27, 2010, 3:58:32 PM7/27/10
to equalsv...@googlegroups.com
Hi Thiago,

I'm assuming you get this error when you call EqualsVerifier on your
"Point" class?
If so, you need to call it like this:

EqualsVerifier.forClass(Point.class)
.withRedefinedSubclass(ColorPoint.class)
.verify();

That way, EV will know that you want to be able to override equals in
your subclasses. Otherwise, it will assume that you don't. It has to
do different checks for that case.

Did you solve your earlier problem, with the IllegalArgumentException?


Regards,
Jan

Thiago Augusto V. Lima

unread,
Jul 27, 2010, 4:31:11 PM7/27/10
to equalsverifier
Hi, Jan...

Actually, I'm calling EV from my "ClientePF" class, that is something
like the "ColorPoint" example. About the previous problem, I couldn't
fix it yet. Still fixing other stuff, before I can send you the code.

Any suggestion about this symmetry problem?

Anyway, thanks for the quick answers... =)


Regards,
Thiago


On 27 jul, 16:58, Jan Ouwens <jan.ouw...@gmail.com> wrote:
> Hi Thiago,
>
> I'm assuming you get this error when you call EqualsVerifier on your
> "Point" class?
> If so, you need to call it like this:
>
> EqualsVerifier.forClass(Point.class)
>         .withRedefinedSubclass(ColorPoint.class)
>         .verify();
>
> That way, EV will know that you want to be able to override equals in
> your subclasses. Otherwise, it will assume that you don't. It has to
> do different checks for that case.
>
> Did you solve your earlier problem, with the IllegalArgumentException?
>
> Regards,
> Jan
>
> On 24 July 2010 08:08, Thiago Augusto V. Lima <t.augu...@gmail.com> wrote:
>
>
>
> > I followed the example by Richard Jepps @http://tal.forum2.org/equals,

Jan Ouwens

unread,
Jul 27, 2010, 5:18:56 PM7/27/10
to equalsv...@googlegroups.com
Hi Thiago,

> Actually, I'm calling EV from my "ClientePF" class, that is something
> like the "ColorPoint" example.
>

> Any suggestion about this symmetry problem?

In that case, you should call it like this:

EqualsVerifier.forClass(ColorPoint.class)
.withRedefinedSuperclass()
.verify();

Maybe I should explain this stuff in the FAQ ...

BTW, you should use EV on all the classes in the hierarchy, including
the super/base class, for maximum coverage.


> About the previous problem, I couldn't
> fix it yet. Still fixing other stuff, before I can send you the code.

Ok, let me know when you do -- I'd love to find out how to reproduce
that error :).


> Anyway, thanks for the quick answers... =)

You're welcome.


Jan

Thiago Augusto V. Lima

unread,
Jul 27, 2010, 10:45:20 PM7/27/10
to equalsverifier
Jan,

your suggestion solved that problem, thanks!

Here are my current problems... :)

java.lang.AssertionError: Recursive datastructure.
Add prefab values for one of the following classes: [class
HIDDEN.base.projeto.ProjetoIntegracao, class
HIDDEN.base.colaborador.Colaborador, class java.util.Date, class
sun.util.calendar.BaseCalendar, class sun.util.calendar.Era, class
sun.util.calendar.CalendarDate].

java.lang.AssertionError: Recursive datastructure.
Add prefab values for one of the following classes: [class
HIDDEN.base.colaborador.Desligamento, class java.util.Date, class
sun.util.calendar.BaseCalendar, class sun.util.calendar.Era, class
sun.util.calendar.CalendarDate].

java.lang.AssertionError: Caught IllegalArgumentException on id (d !=
java.lang.String)
at nl.jqno.equalsverifier.util.Assert.fail(Assert.java:96)
at
nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:310)
at
HIDDEN.base.pessoa.EnderecoTest.testEquals(EnderecoTest.java:79)

java.lang.AssertionError: Caught IllegalArgumentException on cliente
(Added equal prefab values: HIDDEN.base.cliente.ClienteAbstrato$
$EnhancerByCGLIB$$862e587a@5.)
at nl.jqno.equalsverifier.util.Assert.fail(Assert.java:96)
at
nl.jqno.equalsverifier.EqualsVerifier.verify(EqualsVerifier.java:310)
at
HIDDEN.base.projeto.ProjetoExternoTest.testEquals(ProjetoExternoTest.java:
81)


What you think/suggest?


Thanks in advance,

Jan Ouwens

unread,
Jul 28, 2010, 5:43:14 PM7/28/10
to equalsv...@googlegroups.com
Hello Thiago,

You can solve the Recursive datastructures by calling
.withPrefabValue(...), with some instances of the Date class, as the
error message suggests :).
See also http://code.google.com/p/equalsverifier/issues/detail?id=30

For the IllegalArgumentExceptions, I really need to see some code,
because I have no idea what could cause this ... it might be a bug in
EqualsVerifier, but I'm not sure.


Regards,
Jan

Reply all
Reply to author
Forward
0 new messages