Esempio n. 1
0
 @Test
 public void testProxyThrows() throws Exception {
   MyInterface impl =
       (MyInterface)
           DuckTypeProxy.getProxy(
               MyInterface.class, Lists.newArrayList(new Object()), DuckTypeProxy.THROW);
   try {
     impl.getString();
     fail("should have thrown USOE");
   } catch (UnsupportedOperationException yay) {
   }
 }
Esempio n. 2
0
 @Test
 public void testNullParameter() throws Exception {
   Object obj =
       new Object() {
         public String get(String string) {
           return "how about: " + string;
         }
       };
   MyInterface impl =
       (MyInterface)
           DuckTypeProxy.getProxy(MyInterface.class, Lists.newArrayList(obj), DuckTypeProxy.THROW);
   assertEquals("how about: null", impl.get((String) null));
 }
Esempio n. 3
0
 @Test
 public void testProxyReturns() throws Exception {
   Object obj =
       new Object() {
         public String getString() {
           return "who's you're daddy?";
         }
       };
   MyInterface impl =
       (MyInterface)
           DuckTypeProxy.getProxy(MyInterface.class, Lists.newArrayList(obj), DuckTypeProxy.THROW);
   assertEquals("who's you're daddy?", impl.getString());
 }