Example #1
0
  @Test
  public void testAddGenericBinding() throws XadesProfileResolutionException {
    System.out.println("addGenericBinding");

    XadesProfileCore instance = new XadesProfileCore();
    instance.addGenericBinding(Action.class, ActionOfA.class, A.class);
    C c = instance.getInstance(C.class, new Module[0], new Module[0]);
    assertTrue(c.action instanceof ActionOfA);
  }
Example #2
0
  @Test
  public void testAddMultibinding() throws Exception {
    System.out.println("addMultibinding");

    XadesProfileCore instance = new XadesProfileCore();
    instance.addMultibinding(A.class, AImpl1.class);
    instance.addMultibinding(A.class, new AImpl1());
    instance.addMultibinding(A.class, AImpl2.class);

    D d = instance.getInstance(D.class, new Module[0], new Module[0]);
    assertEquals(3, d.as.size());
  }
Example #3
0
  @Test
  public void testAddMapBinding() throws Exception {
    System.out.println("addMapBinding");

    XadesProfileCore instance = new XadesProfileCore();
    instance.addMapBinding(A.class, "A1", AImpl1.class);
    instance.addMapBinding(A.class, "A2", AImpl2.class);

    E e = instance.getInstance(E.class, new Module[0], new Module[0]);

    assertEquals(2, e.as.size());
    assertEquals(AImpl1.class, e.as.get("A1").getClass());
    assertEquals(AImpl2.class, e.as.get("A2").getClass());
  }
Example #4
0
  @Test
  public void testGetInstance() throws XadesProfileResolutionException {
    System.out.println("getInstance");

    Module module =
        new AbstractModule() {
          @Override
          protected void configure() {
            bind(A.class).to(AImpl1.class);
          }
        };
    XadesProfileCore instance = new XadesProfileCore();
    A a = instance.getInstance(A.class, new Module[] {module}, new Module[0]);
    assertNotNull(a);
    assertTrue(a instanceof AImpl1);
  }
Example #5
0
  @Test
  public void testAddBinding() throws XadesProfileResolutionException {
    System.out.println("addBinding");

    Module module =
        new AbstractModule() {
          @Override
          protected void configure() {
            bind(A.class).to(AImpl1.class);
          }
        };
    XadesProfileCore instance = new XadesProfileCore();
    instance.addBinding(A.class, AImpl2.class);
    A a = instance.getInstance(A.class, new Module[] {module}, new Module[0]);
    assertNotNull(a);
    assertTrue(a instanceof AImpl2);

    B b1 = new BImpl();
    instance.addBinding(B.class, b1);
    B b2 = instance.getInstance(B.class, new Module[] {module}, new Module[0]);
    assertNotNull(a);
    assertEquals(b1, b2);
  }
Example #6
0
 @Test(expected = XadesProfileResolutionException.class)
 public void testGetInstanceException() throws XadesProfileResolutionException {
   System.out.println("getInstance_Exception");
   XadesProfileCore instance = new XadesProfileCore();
   instance.getInstance(A.class, new Module[0], new Module[0]);
 }