use of powermock.classloading.classes.MyClass in project powermock by powermock.
the class ObjenesisClassloaderExecutorTest method loadsObjectGraphInSpecifiedClassloaderAndReturnsResultInOriginalClassloader.
@Test
public void loadsObjectGraphInSpecifiedClassloaderAndReturnsResultInOriginalClassloader() throws Exception {
MockClassLoader classloader = createClassloader();
final MyReturnValue expectedConstructorValue = new MyReturnValue(new MyArgument("first value"));
final MyClass myClass = new MyClass(expectedConstructorValue);
final MyArgument expected = new MyArgument("A value");
MyReturnValue[] actual = new SingleClassloaderExecutor(classloader).execute(new Callable<MyReturnValue[]>() {
public MyReturnValue[] call() throws Exception {
assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
return myClass.myMethod(expected);
}
});
assertFalse(MockClassLoader.class.getName().equals(this.getClass().getClassLoader().getClass().getName()));
final MyReturnValue myReturnValue = actual[0];
assertEquals(expectedConstructorValue.getMyArgument().getValue(), myReturnValue.getMyArgument().getValue());
assertEquals(expected.getValue(), actual[1].getMyArgument().getValue());
}
use of powermock.classloading.classes.MyClass in project powermock by powermock.
the class XStreamClassloaderExecutorTest method loadsObjectGraphInSpecifiedClassloaderAndReturnsResultInOriginalClassloader.
@Test
public void loadsObjectGraphInSpecifiedClassloaderAndReturnsResultInOriginalClassloader() throws Exception {
MockClassLoader classloader = createClassloader();
final MyReturnValue expectedConstructorValue = new MyReturnValue(new MyArgument("first value"));
final MyClass myClass = new MyClass(expectedConstructorValue);
final MyArgument expected = new MyArgument("A value");
MyReturnValue[] actual = new SingleClassloaderExecutor(classloader).execute(new Callable<MyReturnValue[]>() {
public MyReturnValue[] call() throws Exception {
assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
return myClass.myMethod(expected);
}
});
assertFalse(MockClassLoader.class.getName().equals(this.getClass().getClassLoader().getClass().getName()));
final MyReturnValue myReturnValue = actual[0];
assertEquals(expectedConstructorValue.getMyArgument().getValue(), myReturnValue.getMyArgument().getValue());
assertEquals(expected.getValue(), actual[1].getMyArgument().getValue());
}
Aggregations