Esempio n. 1
0
  @Test(enabled = true)
  public void test100SerializeContext() throws Exception {

    OperationResult result = new OperationResult("test100SerializeContext");

    LensContext<UserType> context =
        new LensContext<UserType>(UserType.class, prismContext, provisioningService);
    PrismObject<UserType> bill = prismContext.parseObject(USER_BARBOSSA_FILE);
    CryptoUtil.encryptValues(protector, bill);
    ObjectDelta<UserType> userDelta = ObjectDelta.createAddDelta(bill);
    LensFocusContext<UserType> focusContext = context.getOrCreateFocusContext();
    focusContext.setPrimaryDelta(userDelta);

    LensContextType contextType = context.toLensContextType();
    JaxbValueContainer<LensContextType> container =
        new JaxbValueContainer<LensContextType>(contextType, prismContext);
    container.clearActualValue();
    System.out.println("XML value = " + container.getXmlValue());
    LensContextType contextTypeRetrieved = container.getValue();
    LensContext<UserType> contextRetrieved =
        LensContext.fromLensContextType(
            contextTypeRetrieved, prismContext, provisioningService, result);

    assertEquals(
        "Context after serialization/deserialization does not match context before it (object to add is changed)",
        context.getFocusContext().getPrimaryDelta().getObjectToAdd(),
        contextRetrieved.getFocusContext().getPrimaryDelta().getObjectToAdd());
  }
Esempio n. 2
0
  @Test(enabled = true)
  public void test101SerializeJaxb() throws Exception {

    OperationResult result = new OperationResult("test101SerializeJaxb");

    ScheduleType scheduleType = new ScheduleType();
    scheduleType.setInterval(100);

    JaxbValueContainer<ScheduleType> container =
        new JaxbValueContainer<ScheduleType>(scheduleType, prismContext);
    container.clearActualValue();
    System.out.println("XML value = " + container.getXmlValue());
    ScheduleType scheduleTypeRetrieved = container.getValue();

    assertEquals(
        "Object after serialization/deserialization does not match original one",
        scheduleType,
        scheduleTypeRetrieved);
  }