Ejemplo n.º 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"));
 }
Ejemplo n.º 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"));
 }
Ejemplo n.º 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"));
 }