You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The mocked objects that are returned by createMock (and the like) no longer
have runtime annotations. This causes problem when you have code that you
are testing that depend on the existence of these annotations.
Though in some cases this is because of code in PowerMock, there are some
lower level libraries (i.e. EasyMock 's use of gclib and java's Proxy class)
which also are responsible for the missing annotations. I have created a
patch for PowerMock that would allow for these values to be returned. I
opted for doing it at the PowerMock level as it already uses javassist
(which is more straightforward then gclib) and already had started
overriding EasyMock 's class ProxyFactory.
The patch involves a class that will take an originating class and the
mocked class and the generated byte code for the mocked class and will
reapply the runtime annotations. I also had to change the way that
interface mocks were created by creating an InterfaceProxyFactory class
(this does change interfaces from being created with java's Proxy class to
a similar method as creating a class). Hence there are some minor changes
to how to determine if a class is an interface proxy (i.e. instead of
calling Proxy.isProxyClass()). For now the class just reapplies
annotations to the class and method objects, I could do fields and
parameters for completeness, but wanted to see if this functionality and
implementation would be acceptable.
From mathos.m...@gmail.com on April 28, 2010 20:06:05
The mocked objects that are returned by createMock (and the like) no longer
have runtime annotations. This causes problem when you have code that you
are testing that depend on the existence of these annotations.
Though in some cases this is because of code in PowerMock, there are some
lower level libraries (i.e. EasyMock 's use of gclib and java's Proxy class)
which also are responsible for the missing annotations. I have created a
patch for PowerMock that would allow for these values to be returned. I
opted for doing it at the PowerMock level as it already uses javassist
(which is more straightforward then gclib) and already had started
overriding EasyMock 's class ProxyFactory.
The patch involves a class that will take an originating class and the
mocked class and the generated byte code for the mocked class and will
reapply the runtime annotations. I also had to change the way that
interface mocks were created by creating an InterfaceProxyFactory class
(this does change interfaces from being created with java's Proxy class to
a similar method as creating a class). Hence there are some minor changes
to how to determine if a class is an interface proxy (i.e. instead of
calling Proxy.isProxyClass()). For now the class just reapplies
annotations to the class and method objects, I could do fields and
parameters for completeness, but wanted to see if this functionality and
implementation would be acceptable.
Attachment: powerMockAnnotation.txt
Original issue: http://code.google.com/p/powermock/issues/detail?id=258
The text was updated successfully, but these errors were encountered: