Search in sources :

Example 1 with MyStaticFinalPrimitiveHolder

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

the class ObjenesisClassloaderExecutorTest method clonesStaticFinalPrimitiveFields.

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

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

Example 2 with MyStaticFinalPrimitiveHolder

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

the class XStreamClassloaderExecutorTest method clonesStaticFinalPrimitiveFields.

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

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

Aggregations

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