Skip to content

Commit e619016

Browse files
authored
Create SpringProxyFactoryTest.java
1 parent 59de6e5 commit e619016

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.baeldung.overridemethod.proxy.spring;
2+
3+
import com.baeldung.overridemethod.Calculator;
4+
import com.baeldung.overridemethod.SimpleCalculator;
5+
import org.junit.jupiter.api.Test;
6+
import org.springframework.aop.framework.ProxyFactory;
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
public class SpringProxyFactoryTest {
10+
11+
@Test
12+
void testSpringProxyFactory() {
13+
SimpleCalculator simpleCalc = new SimpleCalculator();
14+
ProxyFactory factory = new ProxyFactory();
15+
16+
factory.setTarget(simpleCalc);
17+
factory.addAdvice(new LoggingMethodInterceptor());
18+
19+
Calculator proxyCalc = (Calculator) factory.getProxy();
20+
21+
assertEquals(40, proxyCalc.subtract(50, 10));
22+
}
23+
}

0 commit comments

Comments
 (0)