@Test public void test200RoundTrip() throws Exception { final String TEST_NAME = "test200RoundTrip"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); roundTrip(getFile(USER_JACK_FILE_BASENAME)); }
@Test public void test230RoundTripAdhoc() throws Exception { final String TEST_NAME = "test230RoundTripAdhoc"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); roundTripAdhoc(getFile(USER_JACK_ADHOC_BASENAME)); }
@Test public void test220RoundTripObject() throws Exception { final String TEST_NAME = "test220RoundTripObject"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); roundTrip(getFile(USER_JACK_OBJECT_BASENAME)); }
@Test public void test210RoundTripNoNs() throws Exception { final String TEST_NAME = "test210RoundTripNoNs"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); roundTrip(getFile(USER_JACK_NO_NS_BASENAME)); }
@Test(enabled = false, expectedExceptions = SchemaException.class) public void test110ParseWrongNamespaceStrict() throws Exception { final String TEST_NAME = "test110ParseWrongNamespaceStrict"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN+THEN PrismObject<UserType> user = prismContext.parseObject(WRONG_NAMESPACE_FILE); System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); }
@Test(expectedExceptions = SchemaException.class) public void test010ParseWrongItemStrict() throws Exception { final String TEST_NAME = "testParseWrongItemStrict"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN+THEN try { prismContext.parseObject(WRONG_ITEM_FILE); } catch (SchemaException e) { e.printStackTrace(); throw e; } }
@Test public void test120ParseWrongNamespaceCompat() throws Exception { final String TEST_NAME = "test120ParseWrongNamespaceCompat"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parserFor(WRONG_NAMESPACE_FILE).compat().parse(); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); }
@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); }
@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 test020ParseWrongItemCompat() throws Exception { final String TEST_NAME = "testParseWrongItemCompat"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parserFor(WRONG_ITEM_FILE).compat().parse(); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); }
@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); }
@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); }
/** * Construct object without schema. Starts by creating object "out of the blue" and * the working downwards. */ @Test(enabled = false) // definition-less containers are no longer supported public void testDefinitionlessConstruction() throws Exception { final String TEST_NAME = "testDefinitionlessConstruction"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN // No context needed // WHEN PrismObject<UserType> user = new PrismObjectImpl<>(USER_QNAME, UserType.class); // Fill-in object values, no schema checking fillInUserDrake(user, false); // THEN System.out.println("User:"); System.out.println(user.debugDump()); // Check if the values are correct, no schema checking PrismContext ctx = constructInitializedPrismContext(); assertUserDrake(user, false, ctx); }
/** * Construct object with schema. Starts by instantiating a definition and working downwards. * All the items in the object should have proper definition. */ @Test public void testConstructionWithSchema() throws Exception { final String TEST_NAME = "testConstructionWithSchema"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition<UserType> userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); // WHEN PrismObject<UserType> user = userDefinition.instantiate(); // Fill-in object values, checking presence of definition while doing so fillInUserDrake(user, true); // THEN System.out.println("User:"); System.out.println(user.debugDump()); // Check if the values are correct, also checking definitions assertUserDrake(user, true, ctx); }
@Test public void testParseResourceRumToPrism() throws Exception { final String TEST_NAME = "testParseResourceRumToPrism"; displayTestTitle(TEST_NAME); // GIVEN LexicalProcessor lexicalProcessor = createParser(); PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN (parse to xnode) RootXNodeImpl xnode = lexicalProcessor.read(getFileSource(RESOURCE_RUM_FILE_BASENAME), createDefaultParsingContext()); System.out.println("XNode after parsing:"); System.out.println(xnode.debugDump()); // WHEN (parse to prism) PrismObject<ResourceType> resource = prismContext.parserFor(xnode).parse(); // THEN System.out.println("Parsed resource:"); System.out.println(resource.debugDump()); assertResourceRum(resource); }
@Test public void testPrismParseDom() throws Exception { final String TEST_NAME = "testPrismParseDom"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN Document document = DOMUtil.parseFile(getFile(USER_JACK_FILE_BASENAME)); Element userElement = DOMUtil.getFirstChildElement(document); PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parserFor(userElement).parse(); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserJack(user, true); }
@Test public void testPrismParseDomAdhoc() throws Exception { final String TEST_NAME = "testPrismParseDomAdhoc"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN Document document = DOMUtil.parseFile(getFile(USER_JACK_ADHOC_BASENAME)); Element userElement = DOMUtil.getFirstChildElement(document); PrismContext prismContext = constructInitializedPrismContext(); // WHEN PrismObject<UserType> user = prismContext.parserFor(userElement).parse(); // THEN System.out.println("User:"); System.out.println(user.debugDump()); assertNotNull(user); assertUserAdhoc(user, true); }
@Test public void testCloneEquals() throws Exception { final String TEST_NAME = "testCloneEquals"; PrismInternalTestUtil.displayTestTitle(TEST_NAME); // GIVEN PrismContext ctx = constructInitializedPrismContext(); PrismObjectDefinition<UserType> userDefinition = getFooSchema(ctx).findObjectDefinitionByElementName(new QName(NS_FOO,"user")); PrismObject<UserType> user = userDefinition.instantiate(); fillInUserDrake(user, true); PrismObject<UserType> clone = user.clone(); // WHEN, THEN assertTrue("Clone not equal", clone.equals(user)); assertTrue("Clone not equivalent", clone.equivalent(user)); }
@Test public void testParseProtectedStringEncrypted() throws Exception { final String TEST_NAME = "testParseProtectedStringEncrypted"; displayTestTitle(TEST_NAME); // GIVEN Protector protector = PrismInternalTestUtil.createProtector(XMLCipher.AES_128); ProtectedStringType protectedStringType = protector.encryptString("salalala"); PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN MapXNodeImpl protectedStringTypeXNode = ((PrismContextImpl) prismContext).getBeanMarshaller().marshalProtectedDataType(protectedStringType, null); System.out.println("Protected string type XNode: " + protectedStringTypeXNode.debugDump()); // THEN ProtectedStringType unmarshalled = new ProtectedStringType(); prismContext.hacks().parseProtectedType(unmarshalled, protectedStringTypeXNode, prismContext, createDefaultParsingContext()); System.out.println("Unmarshalled value: " + unmarshalled); assertEquals("Unmarshalled value differs from the original", protectedStringType, unmarshalled); }