Search in sources :

Example 1 with MyHierarchicalFieldHolder

use of powermock.classloading.classes.MyHierarchicalFieldHolder in project powermock by powermock.

the class XStreamClassloaderExecutorTest method worksWithObjectHierarchy.

@Test
public void worksWithObjectHierarchy() throws Exception {
    final MockClassLoader classloader = createClassloader();
    final MyHierarchicalFieldHolder tested = new MyHierarchicalFieldHolder();
    assertSame(tested.getMyArgument1(), tested.getMyArgument2());
    assertEquals(tested.getMyArgument3(), tested.getMyArgument2());
    new SingleClassloaderExecutor(classloader).execute(new Runnable() {

        public void run() {
            assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
            assertSame(tested.getMyArgument1(), tested.getMyArgument2());
            assertEquals(tested.getMyArgument3(), tested.getMyArgument2());
        }
    });
}
Also used : MyHierarchicalFieldHolder(powermock.classloading.classes.MyHierarchicalFieldHolder) MockClassLoader(org.powermock.core.classloader.MockClassLoader) SingleClassloaderExecutor(org.powermock.classloading.SingleClassloaderExecutor) Test(org.junit.Test)

Example 2 with MyHierarchicalFieldHolder

use of powermock.classloading.classes.MyHierarchicalFieldHolder in project powermock by powermock.

the class ObjenesisClassloaderExecutorTest method worksWithObjectHierarchy.

@Test
public void worksWithObjectHierarchy() throws Exception {
    final MockClassLoader classloader = createClassloader();
    final MyHierarchicalFieldHolder tested = new MyHierarchicalFieldHolder();
    assertSame(tested.getMyArgument1(), tested.getMyArgument2());
    assertEquals(tested.getMyArgument3(), tested.getMyArgument2());
    new SingleClassloaderExecutor(classloader).execute(new Runnable() {

        public void run() {
            assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
            assertSame(tested.getMyArgument1(), tested.getMyArgument2());
            assertEquals(tested.getMyArgument3(), tested.getMyArgument2());
        }
    });
}
Also used : MyHierarchicalFieldHolder(powermock.classloading.classes.MyHierarchicalFieldHolder) MockClassLoader(org.powermock.core.classloader.MockClassLoader) SingleClassloaderExecutor(org.powermock.classloading.SingleClassloaderExecutor) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 SingleClassloaderExecutor (org.powermock.classloading.SingleClassloaderExecutor)2 MockClassLoader (org.powermock.core.classloader.MockClassLoader)2 MyHierarchicalFieldHolder (powermock.classloading.classes.MyHierarchicalFieldHolder)2