use of powermock.classloading.classes.MyPrimitiveArrayHolder in project powermock by powermock.
the class XStreamClassloaderExecutorTest method loadsObjectGraphThatIncludesPrimitiveArraysInSpecifiedClassloaderAndReturnsResultInOriginalClassloader.
@Test
public void loadsObjectGraphThatIncludesPrimitiveArraysInSpecifiedClassloaderAndReturnsResultInOriginalClassloader() throws Exception {
MockClassLoader classloader = createClassloader();
final int[] expected = new int[] { 1, 2 };
final MyPrimitiveArrayHolder myClass = new MyPrimitiveArrayHolder(expected);
int[] actual = new SingleClassloaderExecutor(classloader).execute(new Callable<int[]>() {
public int[] call() throws Exception {
assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
int[] myArray = myClass.getMyArray();
assertArrayEquals(expected, myArray);
return myArray;
}
});
assertFalse(MockClassLoader.class.getName().equals(this.getClass().getClassLoader().getClass().getName()));
assertArrayEquals(expected, actual);
}
use of powermock.classloading.classes.MyPrimitiveArrayHolder in project powermock by powermock.
the class ObjenesisClassloaderExecutorTest method loadsObjectGraphThatIncludesPrimitiveArraysInSpecifiedClassloaderAndReturnsResultInOriginalClassloader.
@Test
public void loadsObjectGraphThatIncludesPrimitiveArraysInSpecifiedClassloaderAndReturnsResultInOriginalClassloader() throws Exception {
MockClassLoader classloader = createClassloader();
final int[] expected = new int[] { 1, 2 };
final MyPrimitiveArrayHolder myClass = new MyPrimitiveArrayHolder(expected);
int[] actual = new SingleClassloaderExecutor(classloader).execute(new Callable<int[]>() {
public int[] call() throws Exception {
assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
int[] myArray = myClass.getMyArray();
assertArrayEquals(expected, myArray);
return myArray;
}
});
assertFalse(MockClassLoader.class.getName().equals(this.getClass().getClassLoader().getClass().getName()));
assertArrayEquals(expected, actual);
}
Aggregations