Search in sources :

Example 1 with IsolateMultipleClassPool

use of com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool in project pinpoint by naver.

the class IsolateMultipleClassPoolTest method testPoolSize.

@Test
public void testPoolSize() throws Exception {
    IsolateMultipleClassPool pool = new IsolateMultipleClassPool();
    NamedClassPool systemPool = pool.getClassPool(systemClassLoader);
    Assert.assertEquals(0, pool.size());
    pool.getClassPool(null);
    Assert.assertEquals(0, pool.size());
    Assert.assertSame(systemPool, pool.getClassPool(systemClassLoader));
    NamedClassPool child1Pool = pool.getClassPool(child1);
    Assert.assertEquals(1, pool.size());
    NamedClassPool child1Pool_recheck = pool.getClassPool(child1);
    Assert.assertEquals(1, pool.size());
    Assert.assertSame(child1Pool, child1Pool_recheck);
    Assert.assertNotSame(systemPool, child1Pool);
    NamedClassPool classPool2 = pool.getClassPool(child2);
    Assert.assertEquals(2, pool.size());
    pool.getClassPool(child2);
    Assert.assertEquals(2, pool.size());
    Assert.assertNotSame(systemPool, classPool2);
}
Also used : IsolateMultipleClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool) NamedClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool) Test(org.junit.Test)

Example 2 with IsolateMultipleClassPool

use of com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool in project pinpoint by naver.

the class IsolateMultipleClassPoolTest method testGetClass_childLookupFirst.

@Test
public void testGetClass_childLookupFirst() throws Exception {
    IsolateMultipleClassPool pool = new IsolateMultipleClassPool(false, IsolateMultipleClassPool.EMPTY_EVENT_LISTENER, null);
    NamedClassPool systemPool = pool.getClassPool(systemClassLoader);
    CtClass systemLogger = systemPool.get(TEST_CLASS);
    NamedClassPool rootPool = pool.getClassPool(root);
    CtClass rootLogger = rootPool.get(TEST_CLASS);
    Assert.assertSame(systemLogger, rootLogger);
    NamedClassPool childPool = pool.getClassPool(child1);
    CtClass childLogger = childPool.get(TEST_CLASS);
    Assert.assertSame(systemLogger, childLogger);
    NamedClassPool childPool2 = pool.getClassPool(child2);
    CtClass child2Logger = childPool2.get(TEST_CLASS);
    Assert.assertSame(systemLogger, child2Logger);
}
Also used : CtClass(javassist.CtClass) IsolateMultipleClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool) NamedClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool) Test(org.junit.Test)

Example 3 with IsolateMultipleClassPool

use of com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool in project pinpoint by naver.

the class IsolateMultipleClassPoolTest method testGetClass.

@Test
public void testGetClass() throws Exception {
    IsolateMultipleClassPool pool = new IsolateMultipleClassPool();
    NamedClassPool systemPool = pool.getClassPool(systemClassLoader);
    String classname = "java.lang.String";
    CtClass systemString = systemPool.get(classname);
    NamedClassPool childPool = pool.getClassPool(child1);
    CtClass childPoolString = childPool.get("java.lang.String");
    Assert.assertNotSame(systemString, childPoolString);
    Assert.assertNotSame(systemString.getClassPool(), childPoolString.getClassPool());
    CtClass testClass = childPool.get(this.getClass().getName());
    Assert.assertNotSame(systemString.getClassPool(), testClass.getClassPool());
    NamedClassPool childPool2 = pool.getClassPool(child2);
    CtClass testClass2 = childPool2.get(this.getClass().getName());
    Assert.assertNotSame(systemString.getClassPool(), testClass2.getClassPool());
    CtClass testCtClass = childPool2.get(TEST_CLASS);
    logger.debug("className:{}", Arrays.toString(testCtClass.getConstructors()));
}
Also used : CtClass(javassist.CtClass) IsolateMultipleClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool) NamedClassPool(com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool) Test(org.junit.Test)

Aggregations

IsolateMultipleClassPool (com.navercorp.pinpoint.profiler.instrument.classpool.IsolateMultipleClassPool)3 NamedClassPool (com.navercorp.pinpoint.profiler.instrument.classpool.NamedClassPool)3 Test (org.junit.Test)3 CtClass (javassist.CtClass)2