use of powermock.classloading.classes.MyIntegerHolder in project powermock by powermock.
the class XStreamClassloaderExecutorTest method loadsObjectGraphThatIncludesPrimitiveValuesInSpecifiedClassloaderAndReturnsResultInOriginalClassloader.
@Test
public void loadsObjectGraphThatIncludesPrimitiveValuesInSpecifiedClassloaderAndReturnsResultInOriginalClassloader() throws Exception {
MockClassLoader classloader = createClassloader();
final Integer expected = 42;
final MyIntegerHolder myClass = new MyIntegerHolder(expected);
Integer actual = new SingleClassloaderExecutor(classloader).execute(new Callable<Integer>() {
public Integer call() throws Exception {
assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
final int myInteger = myClass.getMyInteger();
assertEquals((int) expected, myInteger);
return myInteger;
}
});
assertFalse(MockClassLoader.class.getName().equals(this.getClass().getClassLoader().getClass().getName()));
assertEquals(expected, actual);
}
use of powermock.classloading.classes.MyIntegerHolder in project powermock by powermock.
the class ObjenesisClassloaderExecutorTest method loadsObjectGraphThatIncludesPrimitiveValuesInSpecifiedClassloaderAndReturnsResultInOriginalClassloader.
@Test
public void loadsObjectGraphThatIncludesPrimitiveValuesInSpecifiedClassloaderAndReturnsResultInOriginalClassloader() throws Exception {
MockClassLoader classloader = createClassloader();
final Integer expected = 42;
final MyIntegerHolder myClass = new MyIntegerHolder(expected);
Integer actual = new SingleClassloaderExecutor(classloader).execute(new Callable<Integer>() {
public Integer call() throws Exception {
assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
final int myInteger = myClass.getMyInteger();
assertEquals((int) expected, myInteger);
return myInteger;
}
});
assertFalse(MockClassLoader.class.getName().equals(this.getClass().getClassLoader().getClass().getName()));
assertEquals(expected, actual);
}
Aggregations