Search in sources :

Example 1 with MyStaticFinalArgumentHolder

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

the class ObjenesisClassloaderExecutorTest method clonesStaticFinalObjectFields.

@Test
public void clonesStaticFinalObjectFields() throws Exception {
    MockClassLoader classloader = createClassloader();
    final MyStaticFinalArgumentHolder expected = new MyStaticFinalArgumentHolder();
    MyStaticFinalArgumentHolder actual = new SingleClassloaderExecutor(classloader).execute(new Callable<MyStaticFinalArgumentHolder>() {

        public MyStaticFinalArgumentHolder call() throws Exception {
            assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
            MyStaticFinalArgumentHolder actual = new MyStaticFinalArgumentHolder();
            assertEquals(expected.getMyObject(), actual.getMyObject());
            return actual;
        }
    });
    assertFalse(MockClassLoader.class.getName().equals(this.getClass().getClassLoader().getClass().getName()));
    assertEquals(expected.getMyObject(), actual.getMyObject());
}
Also used : MockClassLoader(org.powermock.core.classloader.MockClassLoader) SingleClassloaderExecutor(org.powermock.classloading.SingleClassloaderExecutor) MyStaticFinalArgumentHolder(powermock.classloading.classes.MyStaticFinalArgumentHolder) Test(org.junit.Test)

Example 2 with MyStaticFinalArgumentHolder

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

the class XStreamClassloaderExecutorTest method clonesStaticFinalObjectFields.

@Test
public void clonesStaticFinalObjectFields() throws Exception {
    MockClassLoader classloader = createClassloader();
    final MyStaticFinalArgumentHolder expected = new MyStaticFinalArgumentHolder();
    MyStaticFinalArgumentHolder actual = new SingleClassloaderExecutor(classloader).execute(new Callable<MyStaticFinalArgumentHolder>() {

        public MyStaticFinalArgumentHolder call() throws Exception {
            assertEquals(MockClassLoader.class.getName(), this.getClass().getClassLoader().getClass().getName());
            MyStaticFinalArgumentHolder actual = new MyStaticFinalArgumentHolder();
            assertEquals(expected.getMyObject(), actual.getMyObject());
            return actual;
        }
    });
    assertFalse(MockClassLoader.class.getName().equals(this.getClass().getClassLoader().getClass().getName()));
    assertEquals(expected.getMyObject(), actual.getMyObject());
}
Also used : MockClassLoader(org.powermock.core.classloader.MockClassLoader) SingleClassloaderExecutor(org.powermock.classloading.SingleClassloaderExecutor) MyStaticFinalArgumentHolder(powermock.classloading.classes.MyStaticFinalArgumentHolder) Test(org.junit.Test)

Aggregations

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