private void deleteUser(final String testUser, SpmlConnector connector) { try { connector.delete(ObjectClass.ACCOUNT, new Uid("person:" + testUser), null); } catch (UnknownUidException rte) { // Ignore } }
@Test // @Ignore public void testDelete() throws Exception { SpmlConfiguration config = createConfiguration(); SpmlConnector info = createConnector(config); Set<Attribute> attrs = fillInSampleUser(TEST_USER); try { // Create the account if it doesn't already exist // ConnectorObject user = getUser(TEST_USER); Uid newUid = null; if (user == null) { try { newUid = info.create(ObjectClass.ACCOUNT, attrs, null); System.out.println(newUid.getValue() + " created"); } catch (AlreadyExistsException rte) { // ignore } } else { newUid = user.getUid(); } // Delete the account // info.delete(ObjectClass.ACCOUNT, newUid, null); System.out.println(newUid.getValue() + " deleted"); try { info.delete(ObjectClass.ACCOUNT, newUid, null); Assert.fail("Should have seen exception"); } catch (UnknownUidException uue) { // expected } } finally { info.dispose(); } }
@Test public void testNegative() throws Exception { SpmlConfiguration config = createConfiguration(); config.setPassword(new GuardedString("bogus".toCharArray())); try { createConnector(config); Assert.fail("expected exception"); } catch (RuntimeException e) { // expected } config = createConfiguration(); config.setPostConnectCommand(null); SpmlConnector info = createConnector(config); try { Set<Attribute> attrs = fillInSampleUser(TEST_USER); info.create(ObjectClass.ACCOUNT, attrs, null); Assert.fail("expected exception"); } catch (RuntimeException e) { // expected } try { info.delete(ObjectClass.ACCOUNT, new Uid(TEST_USER), null); Assert.fail("expected exception"); } catch (RuntimeException e) { // expected } try { Set<Attribute> attrs = fillInSampleUser(TEST_USER); info.update(ObjectClass.ACCOUNT, attrs, null); Assert.fail("expected exception"); } catch (RuntimeException e) { // expected } try { TestHandler handler = new TestHandler(); TestHelpers.search( info, ObjectClass.ACCOUNT, new EqualsFilter(AttributeBuilder.build(Uid.NAME, "asdhjfdaslfh alsk fhasldk ")), handler, null); Assert.fail("expected exception"); } catch (RuntimeException e) { // expected } }