Beispiel #1
0
 /** Test of renderChildren method, of class Activity. */
 @Test
 public void testCreateChildren() throws Exception {
   System.out.println("renderChildren");
   // Setup
   ChildPane childPane = new ChildPane();
   childPane.setChild("Child");
   VBox vbox = VBoxBuilder.create().children(childPane).build();
   Parent parent = new Parent();
   parent.setScene(vbox);
   Data data = new Data();
   Map<Field, Object> fieldParams = new HashMap<Field, Object>();
   for (Field field : data.getClass().getDeclaredFields()) {
     field.setAccessible(true);
     fieldParams.put(field, field.get(data));
   }
   RenderParameter renderParam = new RenderParameter();
   String id = renderParam.putParam("checkForLabel", "CheckForLabel");
   childPane.setId(id);
   parent.createChildren(fieldParams, renderParam, ValidationResult.getEmptyResult());
   // Assertoin
   Child child = (Child) parent.getChildActivities(Child.class).get(0);
   assertNotNull(child);
   assertNotNull(child.getScene());
   assertEquals(childPane, child.getScene());
   assertEquals(parent, child.getParent());
   VBox cvbox = (VBox) child.getScene().getChildren().get(0);
   assertTrue(cvbox.getChildren().get(0) instanceof Button);
   assertTrue(cvbox.getChildren().get(1) instanceof Label);
   assertEquals(data.checkForButton, ((Button) cvbox.getChildren().get(0)).getText());
   assertEquals("CheckForLabel", ((Label) cvbox.getChildren().get(1)).getText());
 }
Beispiel #2
0
 /** Test of initialize method, of class Activity. */
 @Test
 public void testInitialize_Activity_Map() throws Exception {
   System.out.println("initialize");
   // Setup
   ParentActivity parent = new ParentActivity();
   Data data = new Data();
   Map<Field, Object> fieldParams = new HashMap<Field, Object>();
   for (Field field : data.getClass().getDeclaredFields()) {
     field.setAccessible(true);
     fieldParams.put(field, field.get(data));
   }
   final String field2 = "field2value";
   final List<String> field3 = new ArrayList<String>();
   Map<String, Object> takeoverParams =
       new HashMap<String, Object>() {
         {
           put("field2", field2);
           put("field3", field3);
         }
       };
   ChildActivity child = new ChildActivity();
   child.initialize(parent, fieldParams, takeoverParams);
   // Assertion
   assertEquals(parent, child.getParent());
   assertEquals(data.getField0(), child.field0);
   assertEquals(data.getField1(), child.field1);
   assertEquals(field2, child.field2);
   assertEquals(field3, child.field3);
   assertEquals("TESTING", child.getTest());
 }
  private Data dereference(XMLCryptoContext context) throws XMLSignatureException {
    Data data = null;

    // use user-specified URIDereferencer if specified; otherwise use deflt
    URIDereferencer deref = context.getURIDereferencer();
    if (deref == null) {
      deref = DOMURIDereferencer.INSTANCE;
    }
    try {
      data = deref.dereference(this, context);
      if (log.isLoggable(Level.FINE)) {
        log.log(Level.FINE, "URIDereferencer class name: " + deref.getClass().getName());
        log.log(Level.FINE, "Data class name: " + data.getClass().getName());
      }
    } catch (URIReferenceException ure) {
      throw new XMLSignatureException(ure);
    }

    return data;
  }