Project

General

Profile

Download (1.09 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.service;
2

    
3
import net.bytebuddy.ByteBuddy;
4
import net.bytebuddy.dynamic.ClassLoadingStrategy;
5
import net.bytebuddy.instrumentation.MethodDelegation;
6
import net.bytebuddy.matcher.ElementMatchers;
7

    
8
import org.apache.log4j.Logger;
9
import org.junit.Assert;
10
import org.junit.Test;
11

    
12
public class ServiceRebasingTest  {
13

    
14
	private static final Logger logger = Logger.getLogger(ServiceRebasingTest.class);
15
	
16
	@Test
17
	public void nameArgumentTest() throws InstantiationException, IllegalAccessException {
18
		ITestService testService = new TestService();
19
		String value = testService.test("Hello World");
20
		Assert.assertEquals("String : Hello World", value);
21
		
22
		testService = new ByteBuddy()
23
		.subclass(ITestService.class)		
24
		.method(ElementMatchers.named("test"))
25
		.intercept(MethodDelegation.to(TargetTestService.class).filter(ElementMatchers.named("test")))
26
		.make()
27
		.load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER)
28
		.getLoaded()
29
		.newInstance();
30
		
31
		value = testService.test("Hello World");
32
		Assert.assertEquals("Overridden String : Hello World", value);
33
	}
34
	
35
}
(3-3/5)