use of powermock.classloading.classes.MyReferenceFieldHolder in project powermock by powermock.
the class XStreamClassloaderExecutorTest method usesReferenceCloningWhenTwoFieldsPointToSameInstance.
@Test
public void usesReferenceCloningWhenTwoFieldsPointToSameInstance() throws Exception {
final MockClassLoader classloader = createClassloader();
final MyReferenceFieldHolder tested = new MyReferenceFieldHolder();
assertSame(tested.getMyArgument1(), tested.getMyArgument2());
assertSame(tested.getMyArgument1(), MyReferenceFieldHolder.MY_ARGUMENT);
new SingleClassloaderExecutor(classloader).execute(new Runnable() {
public void run() {
assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
assertEquals(tested.getMyArgument1(), tested.getMyArgument2());
assertEquals(tested.getMyArgument1(), MyReferenceFieldHolder.MY_ARGUMENT);
assertSame(tested.getMyArgument1(), tested.getMyArgument2());
// FIXME: This assertion should work:
// assertSame(tested.getMyArgument1(), MyReferenceFieldHolder.MY_ARGUMENT);
}
});
}
use of powermock.classloading.classes.MyReferenceFieldHolder in project powermock by powermock.
the class ObjenesisClassloaderExecutorTest method usesReferenceCloningWhenTwoFieldsPointToSameInstance.
@Test
public void usesReferenceCloningWhenTwoFieldsPointToSameInstance() throws Exception {
final MockClassLoader classloader = createClassloader();
final MyReferenceFieldHolder tested = new MyReferenceFieldHolder();
assertSame(tested.getMyArgument1(), tested.getMyArgument2());
assertSame(tested.getMyArgument1(), MyReferenceFieldHolder.MY_ARGUMENT);
new SingleClassloaderExecutor(classloader).execute(new Runnable() {
public void run() {
assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
assertEquals(tested.getMyArgument1(), tested.getMyArgument2());
assertEquals(tested.getMyArgument1(), MyReferenceFieldHolder.MY_ARGUMENT);
assertSame(tested.getMyArgument1(), tested.getMyArgument2());
// FIXME: This assertion should work:
// assertSame(tested.getMyArgument1(), MyReferenceFieldHolder.MY_ARGUMENT);
}
});
}
Aggregations