protected File getFile(String baseName) { return new File(getCommonSubdir(), baseName+"."+getFilenameSuffix()); }
@Test public void test230RoundTripAdhoc() throws Exception { final String TEST_NAME = "test230RoundTripAdhoc"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); roundTripAdhoc(getFile(USER_JACK_ADHOC_BASENAME)); }
@Test public void test500UserElisabethRoundTrip() throws Exception { final String TEST_NAME = "test500UserElisabethRoundTrip"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parseObject(getFile(USER_ELISABETH_FILE_BASENAME)); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserElisabeth(user); // WHEN String serialized = prismContext.serializeObjectToString(user, getOutputFormat()); // THEN assertNotNull(serialized); System.out.println("Serialized user:"); System.out.println(serialized); // WHEN PrismObject<UserType> reparsedUser = prismContext.parseObject(serialized); // THEN System.out.println("Re-parsed user:"); System.out.println(reparsedUser.debugDump()); assertNotNull(reparsedUser); assertUserElisabeth(reparsedUser); }
private void roundTripAdhoc(File file) throws SchemaException, SAXException, IOException { // GIVEN PrismContext prismContext = constructInitializedPrismContext(); PrismObject<UserType> originalUser = prismContext.parseObject(file); System.out.println("Input parsed user:"); System.out.println(originalUser.debugDump()); assertNotNull(originalUser); // precondition assertUserAdhoc(originalUser, true); // WHEN // We need to serialize with composite objects during roundtrip, otherwise the result will not be equal String userXml = prismContext.serializeObjectToString(originalUser, getOutputFormat()); // THEN System.out.println("Serialized user:"); System.out.println(userXml); assertNotNull(userXml); validateXml(userXml, prismContext); // WHEN PrismObject<UserType> parsedUser = prismContext.parseObject(userXml); System.out.println("Re-parsed user:"); System.out.println(parsedUser.debugDump()); assertNotNull(parsedUser); assertUserAdhoc(parsedUser, true); assertTrue("Users not equal", originalUser.equals(parsedUser)); }
@Test public void test410UserWillRoundTrip() throws Exception { final String TEST_NAME = "test410UserWillRoundTrip"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parseObject(getFile(USER_WILL_FILE_BASENAME)); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserWill(user); // WHEN String serialized = prismContext.serializerFor(getOutputFormat()).serialize(user); // THEN assertNotNull(serialized); System.out.println("Serialized user:"); System.out.println(serialized); // WHEN PrismObject<UserType> reparsedUser = prismContext.parseObject(serialized); // THEN System.out.println("Re-parsed user:"); System.out.println(reparsedUser.debugDump()); assertNotNull(reparsedUser); assertUserWill(reparsedUser); }
@Test public void test130PrismParseFileAdhoc() throws Exception { final String TEST_NAME = "test130PrismParseFileAdhoc"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parseObject(getFile(USER_JACK_ADHOC_BASENAME)); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserAdhoc(user, true); }
@Test public void test400UserWill() throws Exception { final String TEST_NAME = "test400UserWill"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parseObject(getFile(USER_WILL_FILE_BASENAME)); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserWill(user); }
private void roundTrip(File file) throws SchemaException, SAXException, IOException { // GIVEN PrismContext prismContext = constructInitializedPrismContext(); PrismObject<UserType> originalUser = prismContext.parseObject(file); System.out.println("Input parsed user:"); System.out.println(originalUser.debugDump()); assertNotNull(originalUser); // precondition assertUserJack(originalUser, true); // WHEN // We need to serialize with composite objects during roundtrip, otherwise the result will not be equal String userXml = prismContext.serializerFor(getOutputFormat()).serialize(originalUser); // THEN System.out.println("Serialized user:"); System.out.println(userXml); assertNotNull(userXml); validateXml(userXml, prismContext); // WHEN PrismObject<UserType> parsedUser = prismContext.parseObject(userXml); System.out.println("Re-parsed user:"); System.out.println(parsedUser.debugDump()); assertNotNull(parsedUser); assertUserJack(parsedUser, true); ObjectDelta<UserType> diff = DiffUtil.diff(originalUser, parsedUser); System.out.println("Diff:"); System.out.println(diff.debugDump()); assertTrue("Diff: "+diff, diff.isEmpty()); assertTrue("Users not equal", originalUser.equals(parsedUser)); }
PrismObject<UserType> userJack = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); PrismContainer<Containerable> meleeContextContainer = userJack.findOrCreateContainer(ItemPath.create(UserType.F_EXTENSION, EXTENSION_MELEE_CONTEXT_ELEMENT)); PrismReference opponentRef = meleeContextContainer.findOrCreateReference(EXTENSION_MELEE_CONTEXT_OPPONENT_REF_ELEMENT); PrismObject<UserType> userBarbossa = prismContext.parseObject(getFile(USER_BARBOSSA_FILE_BASENAME)); String elementJack = prismContext.serializeObjectToString(userJack, getOutputFormat());
@Test public void test110PrismParseFileNoNs() throws Exception { final String TEST_NAME = "test110PrismParseFileNoNs"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parseObject(getFile(USER_JACK_NO_NS_BASENAME)); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserJack(user, true); }
private void assertUserElisabeth(PrismObject<UserType> user) throws SchemaException { user.checkConsistence(); user.assertDefinitions("test"); assertUserElisabethExtension(user); //assertVisitor(user,55); }
protected void assertUserAdhoc(PrismObject<UserType> user, boolean expectRawInConstructions) throws SchemaException { user.checkConsistence(); assertUserJackContent(user, expectRawInConstructions); assertUserExtensionAdhoc(user); assertVisitor(user, 58); }
private void assertUserWill(PrismObject<UserType> user) throws SchemaException { user.checkConsistence(); user.assertDefinitions("test"); assertUserWillExtension(user); assertVisitor(user,55); }
@Test public void test120PrismParseFileObject() throws Exception { final String TEST_NAME = "test120PrismParseFileObject"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parseObject(getFile(USER_JACK_OBJECT_BASENAME)); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserJack(user, true); }
@Test public void test100PrismParseFile() throws Exception { final String TEST_NAME = "test100PrismParseFile"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parseObject(getFile(USER_JACK_FILE_BASENAME)); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserJack(user, true); }