Search in sources :

Example 1 with MyStaticFinalNumberHolder

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

the class XStreamClassloaderExecutorTest method clonesStaticFinalNumberFields.

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

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

Example 2 with MyStaticFinalNumberHolder

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

the class ObjenesisClassloaderExecutorTest method clonesStaticFinalNumberFields.

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

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

Aggregations

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