Search in sources :

Example 1 with AnonymousClassInfos

use of org.hotswap.agent.plugin.jvm.AnonymousClassInfos in project HotswapAgent by HotswapProjects.

the class AnonymousClassInfosTest method testTransitionsSignatrues.

@Test
public void testTransitionsSignatrues() throws Exception {
    AnonymousClassInfos stateInfo = getClassPoolInfos(AnonymousTestClass2.class);
    stateInfo.mapPreviousState(getClassPoolInfos(AnonymousTestClass1.class));
    Map<AnonymousClassInfo, AnonymousClassInfo> mappings = stateInfo.getCompatibleTransitions();
    for (Map.Entry<AnonymousClassInfo, AnonymousClassInfo> mapping : mappings.entrySet()) {
        assertNotNull("Class not mapped " + mapping.getKey(), mapping.getValue());
        assertEquals(mapping.getKey().getClassName(), AnonymousTestClass1.class.getName() + "$1");
        assertEquals(mapping.getValue().getClassName(), AnonymousTestClass2.class.getName() + "$1");
    }
}
Also used : AnonymousClassInfos(org.hotswap.agent.plugin.jvm.AnonymousClassInfos) AnonymousClassInfo(org.hotswap.agent.plugin.jvm.AnonymousClassInfo) Map(java.util.Map) Test(org.junit.Test)

Example 2 with AnonymousClassInfos

use of org.hotswap.agent.plugin.jvm.AnonymousClassInfos in project HotswapAgent by HotswapProjects.

the class AnonymousClassInfosTest method testTransitionsNotCompatibleRemove.

@Test
public void testTransitionsNotCompatibleRemove() throws Exception {
    AnonymousClassInfos stateInfo = getClassPoolInfos(AnonymousTestClass1.class);
    stateInfo.mapPreviousState(getClassPoolInfos(AnonymousTestClass3.class));
    assertNull("Mapping class$1 -> class$1", stateInfo.getCompatibleTransition(AnonymousTestClass1.class.getName() + "$1"));
}
Also used : AnonymousClassInfos(org.hotswap.agent.plugin.jvm.AnonymousClassInfos) Test(org.junit.Test)

Example 3 with AnonymousClassInfos

use of org.hotswap.agent.plugin.jvm.AnonymousClassInfos in project HotswapAgent by HotswapProjects.

the class AnonymousClassInfosTest method testTransitionsInsertAnonymousClass.

@Test
public void testTransitionsInsertAnonymousClass() throws Exception {
    AnonymousClassInfos stateInfo = getClassPoolInfos(AnonymousTestClass3.class);
    stateInfo.mapPreviousState(getClassPoolInfos(AnonymousTestClass2.class));
    assertEquals("Mapping class$1 -> class$2", AnonymousTestClass3.class.getName() + "$2", stateInfo.getCompatibleTransition(AnonymousTestClass2.class.getName() + "$1"));
}
Also used : AnonymousClassInfos(org.hotswap.agent.plugin.jvm.AnonymousClassInfos) Test(org.junit.Test)

Example 4 with AnonymousClassInfos

use of org.hotswap.agent.plugin.jvm.AnonymousClassInfos in project HotswapAgent by HotswapProjects.

the class AnonymousClassInfosTest method testTransitionsNotCompatible.

@Test
public void testTransitionsNotCompatible() throws Exception {
    AnonymousClassInfos stateInfo = getClassPoolInfos(AnonymousTestClass4.class);
    stateInfo.mapPreviousState(getClassPoolInfos(AnonymousTestClass1.class));
    assertNull("Mapping class$1 -> $hotswapAgent1", stateInfo.getCompatibleTransition(AnonymousTestClass4.class.getName() + "$1"));
}
Also used : AnonymousClassInfos(org.hotswap.agent.plugin.jvm.AnonymousClassInfos) Test(org.junit.Test)

Example 5 with AnonymousClassInfos

use of org.hotswap.agent.plugin.jvm.AnonymousClassInfos in project HotswapAgent by HotswapProjects.

the class AnonymousClassInfosTest method getClassPoolInfos.

private AnonymousClassInfos getClassPoolInfos(Class clazz) throws ClassNotFoundException {
    ClassPool classPool = new ClassPool();
    classPool.insertClassPath(new LoaderClassPath(getClass().getClassLoader()));
    return new AnonymousClassInfos(classPool, clazz.getName());
}
Also used : ClassPool(org.hotswap.agent.javassist.ClassPool) AnonymousClassInfos(org.hotswap.agent.plugin.jvm.AnonymousClassInfos) LoaderClassPath(org.hotswap.agent.javassist.LoaderClassPath)

Aggregations

AnonymousClassInfos (org.hotswap.agent.plugin.jvm.AnonymousClassInfos)6 Test (org.junit.Test)5 Map (java.util.Map)2 AnonymousClassInfo (org.hotswap.agent.plugin.jvm.AnonymousClassInfo)2 ClassPool (org.hotswap.agent.javassist.ClassPool)1 LoaderClassPath (org.hotswap.agent.javassist.LoaderClassPath)1