예제 #1
0
 @Test
 public void upperProxy() {
   Hello hello = new HelloUppercase(new HelloTarget());
   assertThat(hello.sayHello("Toby"), is("HELLO TOBY"));
   assertThat(hello.sayHi("Toby"), is("HI TOBY"));
   assertThat(hello.sayThankYou("Toby"), is("THANK YOU TOBY"));
 }
예제 #2
0
 @Test
 public void simpleProxy() {
   Hello hello = new HelloTarget();
   assertThat(hello.sayHello("Toby"), is("Hello Toby"));
   assertThat(hello.sayHi("Toby"), is("Hi Toby"));
   assertThat(hello.sayThankYou("Toby"), is("Thank You Toby"));
 }
예제 #3
0
 @Test
 public void dynamicProxy() {
   Hello proxiedHello =
       (Hello)
           Proxy.newProxyInstance(
               getClass().getClassLoader(),
               new Class[] {Hello.class},
               new UppercaseHandler(new HelloTarget()));
   assertThat(proxiedHello.sayHello("Toby"), is("HELLO TOBY"));
   assertThat(proxiedHello.sayHi("Toby"), is("HI TOBY"));
   assertThat(proxiedHello.sayThankYou("Toby"), is("THANK YOU TOBY"));
 }