List of usage examples for javax.xml.ws Holder Holder
public Holder(T value)
From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java
License:asdf
@Test public void test002AddDerbyResource() throws Exception { final String TEST_NAME = "test002AddDerbyResource"; TestUtil.displayTestTile(TEST_NAME); // GIVEN// www .j ava2 s . co m OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME); checkRepoOpenDjResource(); assertNoRepoCache(); PrismObject<ResourceType> resource = PrismTestUtil.parseObject(new File(RESOURCE_DERBY_FILENAME)); assertParentConsistency(resource); fillInConnectorRef(resource, IntegrationTestTools.DBTABLE_CONNECTOR_TYPE, result); OperationResultType resultType = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType); Holder<String> oidHolder = new Holder<String>(); display("Adding Derby Resource", resource); // WHEN addObjectViaModelWS(resource.asObjectable(), null, oidHolder, resultHolder); // THEN // Check if Derby resource was imported correctly PrismObject<ResourceType> derbyResource = repositoryService.getObject(ResourceType.class, RESOURCE_DERBY_OID, null, result); AssertJUnit.assertEquals(RESOURCE_DERBY_OID, derbyResource.getOid()); assertNoRepoCache(); String dbConnectorOid = derbyResource.asObjectable().getConnectorRef().getOid(); PrismObject<ConnectorType> dbConnector = repositoryService.getObject(ConnectorType.class, dbConnectorOid, null, result); display("DB Connector: ", dbConnector); // Check if password was encrypted during import Object configurationPropertiesElement = JAXBUtil.findElement( derbyResource.asObjectable().getConnectorConfiguration().getAny(), new QName(dbConnector.asObjectable().getNamespace(), "configurationProperties")); Object passwordElement = JAXBUtil.findElement(JAXBUtil.listChildElements(configurationPropertiesElement), new QName(dbConnector.asObjectable().getNamespace(), "password")); System.out.println("Password element: " + passwordElement); }
From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java
License:asdf
/** * Attempt to add new user. It is only added to the repository, so check if * it is in the repository after the operation. *//* ww w. j a va 2 s. c o m*/ @Test public void test010AddUser() throws Exception { final String TEST_NAME = "test010AddUser"; TestUtil.displayTestTile(TEST_NAME); // GIVEN checkRepoOpenDjResource(); assertNoRepoCache(); PrismObject<UserType> user = PrismTestUtil.parseObject(USER_JACK_FILE); UserType userType = user.asObjectable(); assertParentConsistency(user); // Encrypt Jack's password protector.encrypt(userType.getCredentials().getPassword().getValue()); assertParentConsistency(user); OperationResultType result = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result); Holder<String> oidHolder = new Holder<String>(); display("Adding user object", userType); // WHEN addObjectViaModelWS(userType, null, oidHolder, resultHolder); // THEN assertNoRepoCache(); displayJaxb("addObject result:", resultHolder.value, SchemaConstants.C_RESULT); TestUtil.assertSuccess("addObject has failed", resultHolder.value); // AssertJUnit.assertEquals(USER_JACK_OID, oid); OperationResult repoResult = new OperationResult("getObject"); PrismObject<UserType> uObject = repositoryService.getObject(UserType.class, USER_JACK_OID, null, repoResult); UserType repoUser = uObject.asObjectable(); repoResult.computeStatus(); display("repository.getObject result", repoResult); TestUtil.assertSuccess("getObject has failed", repoResult); AssertJUnit.assertEquals(USER_JACK_OID, repoUser.getOid()); assertEqualsPolyString("fullName", userType.getFullName(), repoUser.getFullName()); // TODO: better checks }
From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java
License:asdf
@Test public void test100AssignRolePirate() throws Exception { final String TEST_NAME = "test100AssignRolePirate"; TestUtil.displayTestTile(TEST_NAME); // GIVEN/*from w ww. ja v a 2 s. co m*/ // IMPORTANT! Assignment enforcement is FULL now setAssignmentEnforcement(AssignmentPolicyEnforcementType.FULL); // This is not redundant. It checks that the previous command set the policy correctly assertSyncSettingsAssignmentPolicyEnforcement(AssignmentPolicyEnforcementType.FULL); PrismObject<UserType> user = PrismTestUtil.parseObject(USER_GUYBRUSH_FILE); UserType userType = user.asObjectable(); // Encrypt the password protector.encrypt(userType.getCredentials().getPassword().getValue()); OperationResultType result = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result); Holder<String> oidHolder = new Holder<String>(); assertNoRepoCache(); addObjectViaModelWS(userType, null, oidHolder, resultHolder); assertNoRepoCache(); TestUtil.assertSuccess("addObject has failed", resultHolder.value); ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ROLE_PIRATE_FILENAME, ObjectDeltaType.class); // WHEN ObjectTypes.USER.getTypeQName(), result = modifyObjectViaModelWS(objectChange); // THEN assertNoRepoCache(); displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT); TestUtil.assertSuccess("modifyObject has failed", result); // Check if user object was modified in the repo OperationResult repoResult = new OperationResult("getObject"); PrismObject<UserType> uObject = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, repoResult); UserType repoUser = uObject.asObjectable(); repoResult.computeStatus(); display("User (repository)", repoUser); List<ObjectReferenceType> accountRefs = repoUser.getLinkRef(); assertEquals(1, accountRefs.size()); ObjectReferenceType accountRef = accountRefs.get(0); accountShadowOidGuybrushOpendj = accountRef.getOid(); assertFalse(accountShadowOidGuybrushOpendj.isEmpty()); // Check if shadow was created in the repo repoResult = new OperationResult("getObject"); PrismObject<ShadowType> repoShadow = repositoryService.getObject(ShadowType.class, accountShadowOidGuybrushOpendj, null, repoResult); ShadowType repoShadowType = repoShadow.asObjectable(); repoResult.computeStatus(); TestUtil.assertSuccess("getObject has failed", repoResult); display("Shadow (repository)", repoShadowType); assertNotNull(repoShadowType); assertEquals(RESOURCE_OPENDJ_OID, repoShadowType.getResourceRef().getOid()); accountGuybrushOpendjEntryUuuid = checkRepoShadow(repoShadow); // check if account was created in LDAP Entry entry = openDJController.searchAndAssertByEntryUuid(accountGuybrushOpendjEntryUuuid); display("LDAP account", entry); OpenDJController.assertAttribute(entry, "uid", "guybrush"); OpenDJController.assertAttribute(entry, "givenName", "Guybrush"); OpenDJController.assertAttribute(entry, "sn", "Threepwood"); OpenDJController.assertAttribute(entry, "cn", "Guybrush Threepwood"); OpenDJController.assertAttribute(entry, "displayName", "Guybrush Threepwood"); // The "l" attribute is assigned indirectly through schemaHandling and // config object OpenDJController.assertAttribute(entry, "l", "Deep in the Caribbean"); // Set by the role OpenDJController.assertAttribute(entry, "employeeType", "sailor"); OpenDJController.assertAttribute(entry, "title", "Bloody Pirate"); OpenDJController.assertAttribute(entry, "businessCategory", "loot", "murder"); String guybrushPassword = OpenDJController.getAttributeValue(entry, "userPassword"); assertNotNull("Pasword was not set on create", guybrushPassword); // TODO: Derby }
From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java
License:asdf
/** * Judge role excludes pirate role. This assignment should fail. */// w w w .j a va2 s . co m @Test public void test104AssignRoleJudge() throws Exception { final String TEST_NAME = "test104AssignRoleJudge"; TestUtil.displayTestTile(TEST_NAME); // GIVEN OperationResultType result = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result); Holder<String> oidHolder = new Holder<String>(); assertNoRepoCache(); ObjectDeltaType objectChange = unmarshallValueFromFile(REQUEST_USER_MODIFY_ADD_ROLE_JUDGE_FILENAME, ObjectDeltaType.class); try { // WHEN ObjectTypes.USER.getTypeQName(), result = modifyObjectViaModelWS(objectChange); // THEN AssertJUnit.fail( "Expected a failure after assigning conflicting roles but nothing happened and life goes on"); } catch (FaultMessage f) { // This is expected // TODO: check if the fault is the right one } assertNoRepoCache(); displayJaxb("modifyObject result", result, SchemaConstants.C_RESULT); TestUtil.assertSuccess("modifyObject has failed", result); // Check if user object remain unmodified in the repo OperationResult repoResult = new OperationResult("getObject"); PrismObject<UserType> uObject = repositoryService.getObject(UserType.class, USER_GUYBRUSH_OID, null, repoResult); UserType repoUser = uObject.asObjectable(); repoResult.computeStatus(); display("User (repository)", repoUser); List<ObjectReferenceType> accountRefs = repoUser.getLinkRef(); assertEquals("Unexpected number or accountRefs", 1, accountRefs.size()); }
From source file:com.evolveum.midpoint.testing.sanity.TestSanityLegacy.java
License:asdf
@Test public void test303LiveSyncLink() throws Exception { final String TEST_NAME = "test303LiveSyncLink"; TestUtil.displayTestTile(TEST_NAME); // GIVEN//from w w w .j ava2s . co m assertNoRepoCache(); PrismObject<UserType> user = PrismTestUtil.parseObject(USER_E_LINK_ACTION_FILE); UserType userType = user.asObjectable(); final String userOid = userType.getOid(); // Encrypt e's password protector.encrypt(userType.getCredentials().getPassword().getValue()); // create user in repository OperationResultType resultType = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType); Holder<String> oidHolder = new Holder<String>(); display("Adding user object", userType); addObjectViaModelWS(userType, null, oidHolder, resultHolder); //check results assertNoRepoCache(); displayJaxb("addObject result:", resultHolder.value, SchemaConstants.C_RESULT); TestUtil.assertSuccess("addObject has failed", resultHolder.value); // AssertJUnit.assertEquals(userOid, oidHolder.value); //WHEN //create account for e which should be correlated final OperationResult result = new OperationResult(TestSanityLegacy.class.getName() + "." + TEST_NAME); final Task syncCycle = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result); AssertJUnit.assertNotNull(syncCycle); int tokenBefore = findSyncToken(syncCycle); display("Sync token before", tokenBefore); Entry entry = openDJController.addEntryFromLdifFile(LDIF_E_FILENAME_LINK); display("Entry from LDIF", entry); // THEN // Wait a bit to give the sync cycle time to detect the change basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 4, result); //check user and account ref userType = searchUserByName("e"); List<ObjectReferenceType> accountRefs = userType.getLinkRef(); assertEquals("Account ref not found, or found too many", 1, accountRefs.size()); //check account defined by account ref String accountOid = accountRefs.get(0).getOid(); ShadowType account = searchAccountByOid(accountOid); assertEqualsPolyString("Name doesn't match", "uid=e,ou=People,dc=example,dc=com", account.getName()); assertAndStoreSyncTokenIncrement(syncCycle, 4); checkAllShadows(); }
From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java
License:asdf
@Test public void test303LiveSyncLink() throws Exception { final String TEST_NAME = "test303LiveSyncLink"; TestUtil.displayTestTile(TEST_NAME); // GIVEN//from w w w .j ava 2 s . c o m assertNoRepoCache(); PrismObject<UserType> user = PrismTestUtil.parseObject(USER_E_LINK_ACTION_FILE); UserType userType = user.asObjectable(); final String userOid = userType.getOid(); // Encrypt e's password protector.encrypt(userType.getCredentials().getPassword().getValue()); // create user in repository OperationResultType resultType = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType); Holder<String> oidHolder = new Holder<String>(); display("Adding user object", userType); addObjectViaModelWS(userType, null, oidHolder, resultHolder); //check results assertNoRepoCache(); displayJaxb("addObject result:", resultHolder.value, SchemaConstants.C_RESULT); TestUtil.assertSuccess("addObject has failed", resultHolder.value); // AssertJUnit.assertEquals(userOid, oidHolder.value); //WHEN //create account for e which should be correlated final OperationResult result = new OperationResult(TestSanity.class.getName() + "." + TEST_NAME); final Task syncCycle = taskManager.getTask(TASK_OPENDJ_SYNC_OID, result); AssertJUnit.assertNotNull(syncCycle); int tokenBefore = findSyncToken(syncCycle); display("Sync token before", tokenBefore); Entry entry = openDJController.addEntryFromLdifFile(LDIF_E_FILENAME_LINK); display("Entry from LDIF", entry); // THEN // Wait a bit to give the sync cycle time to detect the change basicWaitForSyncChangeDetection(syncCycle, tokenBefore, 4, result); //check user and account ref userType = searchUserByName("e"); List<ObjectReferenceType> accountRefs = userType.getLinkRef(); assertEquals("Account ref not found, or found too many", 1, accountRefs.size()); //check account defined by account ref String accountOid = accountRefs.get(0).getOid(); ShadowType account = searchAccountByOid(accountOid); assertEqualsPolyString("Name doesn't match", "uid=e,ou=People,dc=example,dc=com", account.getName()); assertAndStoreSyncTokenIncrement(syncCycle, 4); checkAllShadows(); }
From source file:com.evolveum.midpoint.testing.sanity.TestSanityLegacy.java
License:asdf
@Test public void test480ListResources() throws Exception { final String TEST_NAME = "test480ListResources"; TestUtil.displayTestTile(TEST_NAME); // GIVEN//from www . j a v a 2 s. com OperationResultType result = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result); Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>(); SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType(); // WHEN modelWeb.searchObjects(ObjectTypes.RESOURCE.getTypeQName(), null, options, objectListHolder, resultHolder); // THEN display("Resources", objectListHolder.value); assertEquals("Unexpected number of resources", 3, objectListHolder.value.getObject().size()); // TODO for (ObjectType object : objectListHolder.value.getObject()) { // Marshalling may fail even though the Java object is OK so test for it String xml = prismContext.serializeObjectToString(object.asPrismObject(), PrismContext.LANG_XML); } }
From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java
License:asdf
@Test public void test480ListResources() throws Exception { final String TEST_NAME = "test480ListResources"; TestUtil.displayTestTile(TEST_NAME); // GIVEN/*from w w w .j a v a 2s . c om*/ OperationResultType result = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(result); Holder<ObjectListType> objectListHolder = new Holder<ObjectListType>(); SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType(); // WHEN modelWeb.searchObjects(ObjectTypes.RESOURCE.getTypeQName(), null, options, objectListHolder, resultHolder); // THEN display("Resources", objectListHolder.value); assertEquals("Unexpected number of resources", 4, objectListHolder.value.getObject().size()); // TODO for (ObjectType object : objectListHolder.value.getObject()) { // Marshalling may fail even though the Java object is OK so test for it String xml = prismContext.serializeObjectToString(object.asPrismObject(), PrismContext.LANG_XML); } }
From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java
License:asdf
private ShadowType searchAccountByOid(final String accountOid) throws Exception { OperationResultType resultType = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType); Holder<ObjectType> accountHolder = new Holder<ObjectType>(); SelectorQualifiedGetOptionsType options = new SelectorQualifiedGetOptionsType(); modelWeb.getObject(ObjectTypes.SHADOW.getTypeQName(), accountOid, options, accountHolder, resultHolder); ObjectType object = accountHolder.value; TestUtil.assertSuccess("searchObjects has failed", resultHolder.value); assertNotNull("Account is null", object); if (!(object instanceof ShadowType)) { fail("Object is not account."); }/*from w w w .j av a2s .c o m*/ ShadowType account = (ShadowType) object; assertEquals(accountOid, account.getOid()); return account; }
From source file:com.evolveum.midpoint.testing.sanity.TestSanity.java
License:asdf
private UserType searchUserByName(String name) throws Exception { // Document doc = DOMUtil.getDocument(); // Element nameElement = doc.createElementNS(SchemaConstants.C_NAME.getNamespaceURI(), // SchemaConstants.C_NAME.getLocalPart()); // nameElement.setTextContent(name); // Element filter = QueryUtil.createEqualFilter(doc, null, nameElement); ///*w ww . j av a 2 s . co m*/ // QueryType query = new QueryType(); // query.setFilter(filter); ObjectQuery q = ObjectQueryUtil.createNameQuery(UserType.class, prismContext, name); QueryType query = QueryJaxbConvertor.createQueryType(q, prismContext); OperationResultType resultType = new OperationResultType(); Holder<OperationResultType> resultHolder = new Holder<OperationResultType>(resultType); Holder<ObjectListType> listHolder = new Holder<ObjectListType>(); assertNoRepoCache(); modelWeb.searchObjects(ObjectTypes.USER.getTypeQName(), query, null, listHolder, resultHolder); assertNoRepoCache(); ObjectListType objects = listHolder.value; TestUtil.assertSuccess("searchObjects has failed", resultHolder.value); AssertJUnit.assertEquals("User not found (or found too many)", 1, objects.getObject().size()); UserType user = (UserType) objects.getObject().get(0); AssertJUnit.assertEquals(user.getName(), PrismTestUtil.createPolyStringType(name)); return user; }