Parth
Parth

Reputation: 519

Spring CGLib and EasyMock - attempted duplicate class definition

Are you able to mock a class defined in Spring and proxied in Spring in the unit test simultaneously? I am constantly receiving duplicate class definition issues, because the spring proxy is using the same class name as easymock generated proxy because both are proxying using CGLib.

Why does it generate the same names? Why can't it generate random names? Is there a setting for this to make it work?

I am using following.

Spring 3.0
EasyMock 3.2
CGLib 2.2.2 (nodep)

References: Easymock3 Spring4.0.0.RELEASE cglib compatibility

Upvotes: 2

Views: 452

Answers (1)

Rafael Winterhalter
Rafael Winterhalter

Reputation: 44032

This error occurs because both are independently using the DefaultNamingPolicy which computes the class's name from the hash codes of the provided interceptors. This naming policy claims that it detects duplicate names but this does not seem to work. You should therefore set a different naming policy, either within Spring or EasyMock in order to resolve this conflict.

Upvotes: 2

Related Questions