Search in sources :

Example 6 with ExampleInterface

use of net.bytebuddy.benchmark.specimen.ExampleInterface in project byte-buddy by raphw.

the class ClassByImplementationBenchmarkTest method testJavassistClassCreation.

@Test
public void testJavassistClassCreation() throws Exception {
    ExampleInterface instance = classByImplementationBenchmark.benchmarkJavassist();
    assertThat(Arrays.asList(instance.getClass().getInterfaces()), hasItem(ClassByImplementationBenchmark.BASE_CLASS));
    assertThat(instance.getClass().getSuperclass(), CoreMatchers.<Class<?>>is(Object.class));
    assertThat(classByImplementationBenchmark.benchmarkJavassist().getClass(), not(CoreMatchers.<Class<?>>is(instance.getClass())));
    assertReturnValues(instance);
}
Also used : ExampleInterface(net.bytebuddy.benchmark.specimen.ExampleInterface) Test(org.junit.Test)

Example 7 with ExampleInterface

use of net.bytebuddy.benchmark.specimen.ExampleInterface in project byte-buddy by raphw.

the class ClassByImplementationBenchmarkTest method testBaseline.

@Test
public void testBaseline() throws Exception {
    ExampleInterface instance = classByImplementationBenchmark.baseline();
    assertThat(Arrays.asList(instance.getClass().getInterfaces()), hasItem(ClassByImplementationBenchmark.BASE_CLASS));
    assertThat(instance.getClass().getSuperclass(), CoreMatchers.<Class<?>>is(Object.class));
    assertThat(classByImplementationBenchmark.benchmarkByteBuddy().getClass(), not(CoreMatchers.<Class<?>>is(instance.getClass())));
    assertReturnValues(instance);
}
Also used : ExampleInterface(net.bytebuddy.benchmark.specimen.ExampleInterface) Test(org.junit.Test)

Example 8 with ExampleInterface

use of net.bytebuddy.benchmark.specimen.ExampleInterface in project byte-buddy by raphw.

the class ClassByImplementationBenchmarkTest method testCglibClassCreation.

@Test
public void testCglibClassCreation() throws Exception {
    ExampleInterface instance = classByImplementationBenchmark.benchmarkCglib();
    assertThat(Arrays.asList(instance.getClass().getInterfaces()), hasItem(ClassByImplementationBenchmark.BASE_CLASS));
    assertThat(instance.getClass().getSuperclass(), CoreMatchers.<Class<?>>is(Object.class));
    assertThat(classByImplementationBenchmark.benchmarkCglib().getClass(), not(CoreMatchers.<Class<?>>is(instance.getClass())));
    assertReturnValues(instance);
}
Also used : ExampleInterface(net.bytebuddy.benchmark.specimen.ExampleInterface) Test(org.junit.Test)

Aggregations

ExampleInterface (net.bytebuddy.benchmark.specimen.ExampleInterface)8 Test (org.junit.Test)6 Method (java.lang.reflect.Method)2 Proxy (java.lang.reflect.Proxy)2 StubMethod (net.bytebuddy.implementation.StubMethod)2 URLClassLoader (java.net.URLClassLoader)1 MethodFilter (javassist.util.proxy.MethodFilter)1 MethodHandler (javassist.util.proxy.MethodHandler)1 ProxyFactory (javassist.util.proxy.ProxyFactory)1 CallbackHelper (net.sf.cglib.proxy.CallbackHelper)1 Enhancer (net.sf.cglib.proxy.Enhancer)1 FixedValue (net.sf.cglib.proxy.FixedValue)1