Example #1
0
  /**
   * *************************************************************************
   *
   * <p>*************************************************************************
   */
  @Test
  public void test_proper() throws Exception {

    final Object arg = new Object();

    final SuperInterface superProxy = DProxy.make(SuperInterface.class, new ExampleClass());

    assertEquals(arg.toString(), superProxy.foo(arg));

    final ExampleInterface exampleProxy = DProxy.make(ExampleInterface.class, new ExampleClass());

    assertEquals(arg.toString(), exampleProxy.foo(arg));
    assertEquals(arg.hashCode(), exampleProxy.bar(arg));
  }
Example #2
0
  /**
   * *************************************************************************
   *
   * <p>*************************************************************************
   */
  @Test
  public void test_incompatible() throws Exception {

    try {
      DProxy.make(SuperInterface.class, "example");
      fail();
    } catch (final IllegalArgumentException e) {
      assertTrue(true);
    }

    try {
      DProxy.make(ExampleInterface.class, new SuperClass());
      fail();
    } catch (final IllegalArgumentException e) {
      assertTrue(true);
    }
  }
Example #3
0
  /**
   * *************************************************************************
   *
   * <p>*************************************************************************
   */
  @Test
  public void test_null_arguments() throws Exception {

    try {
      DProxy.make(null, "examle");
      fail();
    } catch (final NullPointerException e) {
      assertTrue(true);
    }

    try {
      DProxy.make(SuperInterface.class, null);
      fail();
    } catch (final NullPointerException e) {
      assertTrue(true);
    }
  }