| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testWriteLineInOutputStream() throws UnsupportedEncodingException { |
| | | final MockConsoleApplication ca = MockConsoleApplication.getDefault(); |
| | | ca.print(msg); |
| | |
| | | assertThat(ca.getErr()).isEmpty(); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testWriteLineInErrorStream() throws UnsupportedEncodingException { |
| | | final MockConsoleApplication ca = MockConsoleApplication.getDefault(); |
| | | ca.errPrintln(msg); |
| | |
| | | assertThat(ca.getErr()).contains(msg.toString()); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testWriteOutputStreamVerbose() throws UnsupportedEncodingException { |
| | | final MockConsoleApplication ca = MockConsoleApplication.getDefault(); |
| | | ca.printVerboseMessage(msg); |
| | |
| | | assertThat(ca.getErr()).isEmpty(); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testWriteErrorStreamVerbose() throws UnsupportedEncodingException { |
| | | final MockConsoleApplication ca = MockConsoleApplication.getDefault(); |
| | | ca.errPrintVerboseMessage(msg); |
| | |
| | | * |
| | | * @throws UnsupportedEncodingException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testNonInteractiveApplicationShouldNotStdoutErrors() throws UnsupportedEncodingException { |
| | | final MockConsoleApplication ca = MockConsoleApplication.getDefault(); |
| | | |
| | |
| | | * |
| | | * @throws UnsupportedEncodingException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testInteractiveApplicationShouldStdoutErrors() throws UnsupportedEncodingException { |
| | | final MockConsoleApplication ca = MockConsoleApplication.getDefault(); |
| | | |
| | |
| | | * In quiet mode, only the stderr should contain lines. |
| | | * @throws UnsupportedEncodingException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testQuietMode() throws UnsupportedEncodingException { |
| | | final MockConsoleApplication ca = MockConsoleApplication.getDefault(); |
| | | ca.setQuiet(true); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testValidJavaVersion() throws ClientException { |
| | | Utils.checkJavaVersion(); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testCanWriteOnNewFile() throws ClientException, IOException { |
| | | final File f = File.createTempFile("tempFile", ".txt"); |
| | | f.deleteOnExit(); |
| | |
| | | assertTrue(Utils.canWrite(f.getPath())); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testCannotWriteOnNewFile() throws ClientException, IOException { |
| | | final File f = File.createTempFile("tempFile", ".txt"); |
| | | f.setReadOnly(); |
| | |
| | | assertFalse(Utils.canWrite(f.getPath())); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testGetHostNameForLdapUrl() { |
| | | assertEquals(Utils.getHostNameForLdapUrl("2a01:e35:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx"), |
| | | "[2a01:e35:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]"); |
| | |
| | | "[2a01:e35:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx]"); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void isDN() { |
| | | assertTrue(Utils.isDN("cn=Jensen,ou=people,dc=example,dc=com")); |
| | | assertTrue(Utils.isDN("cn=John Doe,dc=example,dc=org")); |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean equals(final Object o) { |
| | | if (o == this) { |
| | | return true; |
| | |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class AccountUsabilityRequestControlTestCase extends ControlsTestCase { |
| | | @Test() |
| | | @Test |
| | | public void testControl() throws Exception { |
| | | // Send this control with a search request and see that you get |
| | | // a valid response. |
| | |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | public class AccountUsabilityResponseControlTestCase extends ControlsTestCase { |
| | | @Test() |
| | | @Test |
| | | public void testInvalidResponseControl() throws Exception { |
| | | // Don't send the request control and hence there |
| | | // shouldn't be response. |
| | |
| | | assertNull(aurctrl); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testValidResponseControl() throws Exception { |
| | | // Send this control with a search request and see that you get |
| | | // a valid response. |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | private void run() { |
| | | final OperatingSystem os = OperatingSystem.getOperatingSystem(); |
| | | |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDecodeExtendedZeroLengthArrayAsNull() throws Exception { |
| | | final byte[] b = new byte[] { 0x05, (byte) 0x81, 0x00 }; |
| | | getReader(b, 0).readNull(); |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDecodeZeroLengthArrayAsNull() throws Exception { |
| | | final byte[] b = new byte[] { 0x05, 0x00 }; |
| | | getReader(b, 0).readNull(); |
| | |
| | | /** |
| | | * Tests the <CODE>skipElement</CODE> method providing a specific type. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSkipElementWithType() throws Exception { |
| | | final byte[] b = |
| | | new byte[] { 0x30, 0x09, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x02, 0x01, 0x02 }; |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testNegativeIntEncoding() throws Exception { |
| | | // Some negative integers of interest |
| | | // to test specific ranges/boundaries. |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testNegativeLongEncoding() throws Exception { |
| | | // Some negative integers of interest |
| | | // to test specific ranges/boundaries. |
| | |
| | | |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testAddRequestSuccess() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS); |
| | | final AddRequest addRequest = newAddRequest("cn=test"); |
| | | assertThat(mockConnection.add(addRequest).getResultCode()).isEqualTo(ResultCode.SUCCESS); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testAddRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final AddRequest addRequest = newAddRequest("cn=test"); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testBindRequestSuccess() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS); |
| | | final BindRequest bindRequest = newSimpleBindRequest(); |
| | | assertThat(mockConnection.bind(bindRequest).getResultCode()).isEqualTo(ResultCode.SUCCESS); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testBindRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final BindRequest bindRequest = newSimpleBindRequest(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testCompareRequestSuccess() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS); |
| | | final CompareRequest compareRequest = newCompareRequest("cn=test", "cn", "test"); |
| | |
| | | ResultCode.SUCCESS); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testCompareRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final CompareRequest compareRequest = newCompareRequest("cn=test", "cn", "test"); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testDeleteRequestSuccess() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS); |
| | | final DeleteRequest deleteRequest = newDeleteRequest("cn=test"); |
| | |
| | | ResultCode.SUCCESS); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testDeleteRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final DeleteRequest deleteRequest = newDeleteRequest("cn=test"); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testExtendedRequestSuccess() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS); |
| | | final GenericExtendedRequest extendedRequest = newGenericExtendedRequest("test"); |
| | |
| | | ResultCode.SUCCESS); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testExtendedRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final GenericExtendedRequest extendedRequest = newGenericExtendedRequest("test"); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testModifyRequestSuccess() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS); |
| | | final ModifyRequest modifyRequest = newModifyRequest("cn=test"); |
| | |
| | | ResultCode.SUCCESS); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testModifyRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final ModifyRequest modifyRequest = newModifyRequest("cn=test"); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testModifyDNRequestSuccess() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS); |
| | | final ModifyDNRequest modifyDNRequest = newModifyDNRequest("cn=test", "cn=newrdn"); |
| | |
| | | ResultCode.SUCCESS); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testModifyDNRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final ModifyDNRequest modifyDNRequest = newModifyDNRequest("cn=test", "cn=newrdn"); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSearchRequestSuccess() throws Exception { |
| | | final SearchResultEntry entry = newSearchResultEntry("cn=test"); |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS, entry); |
| | |
| | | assertThat(entries.iterator().next()).isSameAs(entry); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSearchRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final SearchRequest searchRequest = |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchRequestSuccess() throws Exception { |
| | | final SearchResultEntry entry = newSearchResultEntry("cn=test"); |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS, entry); |
| | |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchAsyncRequestSuccess() throws Exception { |
| | | final SearchResultEntry entry = newSearchResultEntry("cn=test"); |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS, entry); |
| | |
| | | verify(successHandler).handleResult(any(SearchResultEntry.class)); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchRequestNoEntryReturned() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS); |
| | | final SearchRequest request = |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchRequestMultipleEntriesToReturn() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SIZE_LIMIT_EXCEEDED, |
| | | newSearchResultEntry("cn=test")); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchRequestMultipleEntriesReturnedByServer() throws Exception { |
| | | // could happen if server does not enforce size limit |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS, newSearchResultEntry("cn=test"), |
| | |
| | | } |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchAsyncRequestMultipleEntriesToReturn() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.SIZE_LIMIT_EXCEEDED, |
| | | newSearchResultEntry("cn=test")); |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchAsyncRequestMultipleEntriesReturnedByServer() throws Exception { |
| | | // could happen if server does not enfore size limit |
| | | final Connection mockConnection = new MockConnection(ResultCode.SUCCESS, newSearchResultEntry("cn=test"), |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final SearchRequest request = |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testSingleEntrySearchAsyncRequestFail() throws Exception { |
| | | final Connection mockConnection = new MockConnection(ResultCode.UNWILLING_TO_PERFORM); |
| | | final SearchRequest request = |
| | |
| | | /** |
| | | * Disables logging before the tests. |
| | | */ |
| | | @BeforeClass() |
| | | @BeforeClass |
| | | public void disableLogging() { |
| | | TestCaseUtils.setDefaultLogLevel(Level.SEVERE); |
| | | } |
| | |
| | | /** |
| | | * Re-enable logging after the tests. |
| | | */ |
| | | @AfterClass() |
| | | @AfterClass |
| | | public void enableLogging() { |
| | | TestCaseUtils.setDefaultLogLevel(Level.INFO); |
| | | } |
| | |
| | | { "dc=opendj,dc=org", "dc=opendj,dc=com", false }, }; |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testAdminData() { |
| | | DN.valueOf("cn=cn\\=admin data"); |
| | | final DN theDN = DN.valueOf("cn=my dn"); |
| | |
| | | /** |
| | | * Tests the parent method that require iteration. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testIterableParent() { |
| | | final String str = "ou=people,dc=example,dc=com"; |
| | | final DN dn = DN.valueOf(str); |
| | |
| | | /** |
| | | * Test the <CODE>hasNext</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testHasNext() throws Exception { |
| | | GSERParser parser = new GSERParser("0"); |
| | | assertTrue(parser.hasNext()); |
| | |
| | | /** |
| | | * Test the <CODE>skipSP</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSkipSP() throws Exception { |
| | | String[] values = {" 42", " 42", "42"}; |
| | | for (String value : values) { |
| | |
| | | /** |
| | | * Test the <CODE>skipMSP</CODE> method. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSkipMSP() throws Exception { |
| | | String[] values = {" 42", " 42", " 42"}; |
| | | for (String value : values) { |
| | |
| | | /** |
| | | * Disables logging before the tests. |
| | | */ |
| | | @BeforeClass() |
| | | @BeforeClass |
| | | public void disableLogging() { |
| | | TestCaseUtils.setDefaultLogLevel(Level.SEVERE); |
| | | } |
| | |
| | | /** |
| | | * Re-enable logging after the tests. |
| | | */ |
| | | @AfterClass() |
| | | @AfterClass |
| | | public void enableLogging() { |
| | | TestCaseUtils.setDefaultLogLevel(Level.INFO); |
| | | } |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @BeforeClass() |
| | | @BeforeClass |
| | | public void startServer() throws Exception { |
| | | TestCaseUtils.startServer(); |
| | | } |
| | |
| | | protected Request unmodifiableOf(Request original) { |
| | | return Requests.unmodifiableUnbindRequest((UnbindRequest) original); |
| | | } |
| | | @Test() |
| | | |
| | | @Test |
| | | public void testModifiableRequest() { |
| | | final UnbindRequest copy = (UnbindRequest) copyOf(Requests.newUnbindRequest()); |
| | | assertThat(copy.toString()).isEqualTo("UnbindRequest(controls=[])"); |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class MatchingRuleTestCase extends AbstractSchemaTestCase { |
| | | |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesBasicMatchingRule() { |
| | | |
| | | // @formatter:off |
| | |
| | | assertThat(mr.isObsolete()).isFalse(); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesOverrideBasicMatchingRule() { |
| | | |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Matching rule name is optional. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsEmptyName() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Multiple names can be set to the matching rule. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsMultipleNames() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Name in optional for a matching rule. (RFC 4512) |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderRemoveNames() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * The builder allows to remove selected name. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderRemoveSelectedName() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * The builder allows a missing description. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNoDescription() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * The builder allows empty description. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsEmptyDescription() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Extra properties is not a mandatory field. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNoExtraProperties() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Removes all the extra properties. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderRemoveExtraProperties() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * If the implementation is not set, the schema will use the default matching rule for this one. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNoImplementation() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * If the implementation is null, the schema will use the default matching rule for this one. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNullImplementation() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Sets a matching rule using a string definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testAddingAMatchingRuleDefinitionStringNoOverride() { |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | |
| | | /** |
| | | * Sets a matching rule using a string definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testAddingAMatchingRuleDefinitionStringOverride() { |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | |
| | | /** |
| | | * Duplicates an existing matching rule. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testDuplicatesExistingMatchingRule() { |
| | | |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | |
| | | /** |
| | | * Equality between matching rules. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testMatchingRuleEqualsTrue() { |
| | | |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Equality between matching rules fails. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testMatchingRuleEqualsFalse() { |
| | | |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Verifies the builder definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testVerifyMatchingRuleDefinition() { |
| | | |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | |
| | | /** |
| | | * Equality between builder and definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testMatchingRuleEqualityReturnsTrueBetweenBuilderAndDefinition() { |
| | | |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Equality between builder and definition fails. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testMatchingRuleEqualityReturnsTrueBetweenBuilderAndDefinitionFails() { |
| | | |
| | | // @formatter:off |
| | |
| | | /** |
| | | * The builder allows to create chained matching rules. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesMatchingRulesUsingChainingMethods() { |
| | | final Map<String, List<String>> extraProperties = new TreeMap<String, List<String>>(); |
| | | final List<String> extra = new ArrayList<String>(); |
| | |
| | | * Creates a new form using the required parameters only (oid, structural |
| | | * OID and required attributes). |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesANewFormWithOnlyRequiredParameters() { |
| | | |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildNameForm("1.3.6.1.4.1.1466.115.121.1.35") |
| | | .structuralObjectClassOID("person") |
| | |
| | | /** |
| | | * Creates a new form with a name. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesANewFormWithAName() { |
| | | |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Creates a new form with optional attributes OID. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesANewFormWithOptionalAttributesOid() { |
| | | |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | |
| | | /** |
| | | * Creates a new form with ExtraProperties. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesANewNameFormWithExtraProperties() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsEmptyOptionalAttributes() { |
| | | |
| | | // @formatter:off |
| | | new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildNameForm("1.3.6.1.4.1.1466.115.121.1.35") |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowRemovingNonexistentAttributes() { |
| | | |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildNameForm("1.3.6.1.4.1.1466.115.121.1.35") |
| | |
| | | * Verifying the schema builder allows to add directly a definition. The |
| | | * name form is created as well. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testNameFormDefinition() { |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testDuplicatesTheNameForm() { |
| | | |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testDuplicatesTheNameFormFails() { |
| | | |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Compare two same name forms using the equal function. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testNameFormEqualsTrue() { |
| | | |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Equals between two name forms fails. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testNameFormEqualsFalse() { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testCreateFormUsingDefinitionAndSchemaBuilder() { |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | |
| | |
| | | * name form builder, the other by the schema builder directly using the |
| | | * definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testNameFormEqualityReturnsTrueBetweenBuilderAndDefinition() { |
| | | |
| | | // @formatter:off |
| | |
| | | * name form builder, the other by the schema builder directly using the |
| | | * definition with different OID. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testNameFormEqualityReturnsFalseBetweenBuilderAndDefinition() { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testNameFormValidateDoesntAllowAbstractObjectClass() { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testNameFormValidateAllowsStructuralObjectClass() { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuildsANewFormWithMultipleAttributes() { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesANewFormUsingChainingMethods() { |
| | | final Map<String, List<String>> extraProperties = new TreeMap<String, List<String>>(); |
| | | final List<String> extra = new ArrayList<String>(); |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesNewFormAndRemovesAttributes() { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testDuplicatesNameFormAndRemovesAttributes() { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testDuplicatesNameFormAndClears() { |
| | | |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | |
| | | * |
| | | * @throws SchemaException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testAddsSeveralFormsToSchemaBuilder() { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryWithCoreSchema() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddLdapSyntax() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddMalformedLdapSyntax() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddMatchingRuleUse() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddMalformedMatchingRuleUse() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddMatchingRule() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddMalformedMatchingRule() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddDITContentRule() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddMalformedDITContentRule() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddObjectClass() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderWithEntryAddMalformedObjectClass() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAddAttributeWithEntryContainingDescriptionWithCoreSchema() |
| | | throws Exception { |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAddAttributeContainingDescriptionWithCoreSchema() |
| | | throws Exception { |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderCompareAddAttributeTypesSucceed() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getDefaultSchema()); |
| | |
| | | /** |
| | | * Rewrite an existing object class. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAddObjectClass() throws Exception { |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getDefaultSchema()); |
| | | Set<String> attrs = new HashSet<String>(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAllowsConflictingAttributesOverwriteTrue() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(); |
| | | |
| | | //@formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAllowsConflictingDITStructureRuleOverwriteTrue() |
| | | throws Exception { |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAddDITContentRuleBuilder() throws Exception { |
| | | // @formatter:off |
| | | final Schema schema = |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAllowsConflictingDITContentRuleOverwriteTrue() |
| | | throws Exception { |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAllowsConflictingMatchingRuleOverwriteTrue() |
| | | throws Exception { |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAllowsConflictingMatchingRuleUseOverwriteTrue() |
| | | throws Exception { |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAllowsConflictingNameFormOverwriteTrue() throws Exception { |
| | | // @formatter:off |
| | | final Schema schema = |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveInexistantAttributeType() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | boolean isRemoved = scBuild.removeAttributeType("wrongName"); |
| | | assertThat(isRemoved).isFalse(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveInexistantSyntax() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | boolean isRemoved = scBuild.removeSyntax("1.3.6.1.4.1.14aa"); |
| | | assertThat(isRemoved).isFalse(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveDitContentRule() throws Exception { |
| | | |
| | | // @formatter:off |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | scBuild.addObjectClass("( 2.16.840.1.113730.3.2.2 NAME 'myCustomObjClass" |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveInexistantDitContentRule() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | boolean isRemoved = scBuild.removeDITContentRule("badDITContentRule"); |
| | | assertThat(isRemoved).isFalse(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveInexistantDitStructureRule() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | boolean isRemoved = scBuild.removeDITStructureRule(999014); |
| | | assertThat(isRemoved).isFalse(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveInexistantMatchingRule() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | boolean isRemoved = scBuild.removeMatchingRule("bitStringMatchZ"); |
| | | assertThat(isRemoved).isFalse(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveInexistantMatchingRuleUse() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | boolean isRemoved = scBuild.removeMatchingRuleUse("bitStringMatchZ"); |
| | | assertThat(isRemoved).isFalse(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveInexistantNameForm() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | boolean isRemoved = scBuild.removeNameForm("bitStringMatchZ"); |
| | | assertThat(isRemoved).isFalse(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderRemoveInexistantObjectClass() throws Exception { |
| | | |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | | boolean isRemoved = scBuild.removeObjectClass("bitStringMatchZ"); |
| | | assertThat(isRemoved).isFalse(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAddSchemaForEntryMockConnection() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testSchemaBuilderAddSchemaForEntryAsyncMockConnection() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | final SchemaBuilder scBuild = new SchemaBuilder(Schema.getCoreSchema()); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testReadSchemaAsyncMethodsMockConnection() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | |
| | |
| | | @SuppressWarnings("javadoc") |
| | | public class SyntaxTestCase extends AbstractSchemaTestCase { |
| | | |
| | | @Test() |
| | | @Test |
| | | public final void testCreatesANewSyntax() { |
| | | |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildSyntax("1.9.1.2.3") |
| | |
| | | * Tests that unrecognized syntaxes are automatically substituted with the |
| | | * default syntax and matching rule. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testDefaultSyntaxSubstitution() { |
| | | final Syntax syntax = Schema.getCoreSchema().getSyntax("1.2.3.4.5"); |
| | | assertThat(syntax).isNotNull(); |
| | |
| | | /** |
| | | * When syntax is missing, the default one is set. Actual default is OctetString.(case match) |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNullSyntax() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * When syntax is missing, the default one is set. Actual default is OctetString.(case match) |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNoSyntax() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | * When syntax is missing, the default one is set. Actual default is set to directory string |
| | | * (1.3.6.1.4.1.1466.115.121.1.15) - matchingRules of caseIgnoreMatch and caseIgnoreSubstringsMatch. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNoSyntaxCaseWhereDefaultSyntaxIsChanged() { |
| | | |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .defaultSyntax("1.3.6.1.4.1.1466.115.121.1.15") |
| | |
| | | /** |
| | | * The builder allows a missing description. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNoDescription() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * The builder allows a missing description. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNullDescription() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * The builder allows a missing description. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsEmptyDescription() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Extra properties is not a mandatory field. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderAllowsNoExtraProperties() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Removes all the extra properties. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderRemoveExtraProperties() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Removes specified extra properties. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderRemoveSpecifiedExtraProperties() { |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | |
| | | /** |
| | | * Sets a syntax using a string definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testAddingBERSyntaxDefinition() { |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | |
| | | /** |
| | | * Sets a syntax using a string definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testAddingASyntaxDefinitionStringOverride() { |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | |
| | | /** |
| | | * Sets a syntax using a string definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testAddingUnknownSyntaxDefinitionString() { |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | |
| | | /** |
| | | * Duplicates a syntax. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderDuplicatesExistingSyntax() { |
| | | |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | | |
| | |
| | | /** |
| | | * Another duplicated syntax example. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderDuplicatesSyntax() { |
| | | |
| | | final SchemaBuilder sb = new SchemaBuilder(); |
| | | sb.addSchema(Schema.getCoreSchema(), false); |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Equality between syntaxes. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderSyntaxesEqualsTrue() { |
| | | |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildSyntax("1.9.1.2.3") |
| | |
| | | /** |
| | | * Equality between syntaxes. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderSyntaxesEqualsFalse() { |
| | | |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildSyntax("1.9.1.2.3") |
| | |
| | | /** |
| | | * Equality between builder and definition. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderEqualityReturnsTrueBetweenBuilderAndDefinition() { |
| | | |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildSyntax("1.9.1.2.3") |
| | |
| | | /** |
| | | * Equality between builder and definition fails. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderEqualityReturnsFalseBetweenBuilderAndDefinition() { |
| | | |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildSyntax("1.9.1.2.3") |
| | |
| | | /** |
| | | * The builder allows to create chained syntaxes. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testBuilderCreatesSyntaxesUsingChainingMethods() { |
| | | |
| | | // @formatter:off |
| | | final Schema schema = new SchemaBuilder(Schema.getCoreSchema()) |
| | | .buildSyntax("1.9.1.2.3") |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCreateAndDecodeUTCTimeValue() throws Exception { |
| | | final Date d = new Date(); |
| | | final String timeValue = UTCTimeSyntaxImpl.createUTCTimeValue(d); |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDecode50to99() throws Exception { |
| | | Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); |
| | | |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDecode00to49() throws Exception { |
| | | Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); |
| | | |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCreate50to99() throws Exception { |
| | | Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); |
| | | |
| | |
| | | * @throws Exception |
| | | * If an unexpected problem occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCreate00to49() throws Exception { |
| | | Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC")); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testWriteChangeRecordAddRequest() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionChangeRecordWriter writer = null; |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testWriteChangeRecordContainingAddRequest() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionChangeRecordWriter writer = null; |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testWriteChangeRecordContainingDeleteRequest() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionChangeRecordWriter writer = null; |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testWriteChangeRecordDeleteRequest() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionChangeRecordWriter writer = null; |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testWriteChangeRecordModifyDNRequest() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionChangeRecordWriter writer = null; |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testWriteChangeRecordModifyRequest() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionChangeRecordWriter writer = null; |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testWriteCommentDoNotSupportComment() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionChangeRecordWriter writer = null; |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testConnectionChangeRecordWriterClose() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionChangeRecordWriter writer = null; |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public final void testReadEntry() throws Exception { |
| | | final ConnectionEntryReader reader = newReader(ENTRY1, SUCCESS); |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public final void testReadMultipleResults() throws Exception { |
| | | final ConnectionEntryReader reader = newReader(ENTRY1, ENTRY2, REF, ENTRY3, SUCCESS); |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public final void testReadReference() throws Exception { |
| | | final ConnectionEntryReader reader = newReader(REF, SUCCESS); |
| | | try { |
| | |
| | | } |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public final void testReadReferenceWhenEntry() throws Exception { |
| | | final ConnectionEntryReader reader = newReader(ENTRY1, SUCCESS); |
| | | try { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testConnectionEntryWriterWritesEntry() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionEntryWriter writer = null; |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testConnectionEntryWriterClose() throws Exception { |
| | | Connection connection = mock(Connection.class); |
| | | ConnectionEntryWriter writer = null; |
| | |
| | | * Test to show that reporting an error about an uninitialized variable when |
| | | * generating templates reports the correct line. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testMissingVariableErrorReport() throws Exception { |
| | | String[] lines = { |
| | | /* 0 */"template: template", |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesFalse() throws Exception { |
| | | |
| | | final LDIFChangeRecordReader reader = |
| | | new LDIFChangeRecordReader(getStandardLDIFChangeRecord()); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesTrue() throws Exception { |
| | | |
| | | final LDIFChangeRecordReader reader = |
| | | new LDIFChangeRecordReader(getStandardLDIFChangeRecord()); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesFalse() throws Exception { |
| | | |
| | | final LDIFChangeRecordReader reader = |
| | | new LDIFChangeRecordReader(getStandardLDIFChangeRecord()); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesTrue() throws Exception { |
| | | |
| | | final LDIFChangeRecordReader reader = |
| | | new LDIFChangeRecordReader(getStandardLDIFChangeRecord()); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeAttributeWithMatch() throws Exception { |
| | | |
| | | final LDIFChangeRecordReader reader = |
| | | new LDIFChangeRecordReader(getStandardLDIFChangeRecord()); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeAttributeWithNoMatch() throws Exception { |
| | | |
| | | final LDIFChangeRecordReader reader = |
| | | new LDIFChangeRecordReader(getStandardLDIFChangeRecord()); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeBranchWithMatch() throws Exception { |
| | | |
| | | final LDIFChangeRecordReader reader = |
| | | new LDIFChangeRecordReader(getStandardLDIFChangeRecord()); |
| | | reader.setIncludeBranch(DN.valueOf("dc=example,dc=com")); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeBranchWithMatch() throws Exception { |
| | | |
| | | final LDIFChangeRecordReader reader = |
| | | new LDIFChangeRecordReader(getStandardLDIFChangeRecord()); |
| | | reader.setExcludeBranch(DN.valueOf("dc=example,dc=org")); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetSchemaValidationPolicyDefaultAllowsEntry() throws Exception { |
| | | |
| | | // @formatter:off |
| | | final String[] strChangeRecord = { |
| | | "dn: uid=user.0,ou=People,dc=example,dc=com", |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadAddRecordWithChangeType() throws Exception { |
| | | // @formatter:off |
| | | LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadAddRecordWithoutChangeType() throws Exception { |
| | | // @formatter:off |
| | | LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadModifyRecord() throws Exception { |
| | | // @formatter:off |
| | | LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadModdnRecordWithoutNewSuperior() throws Exception { |
| | | // @formatter:off |
| | | LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadModdnRecordWithNewSuperior() throws Exception { |
| | | // @formatter:off |
| | | LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedRecordListenerMalformedFirstRecord() throws Exception { |
| | | |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | | // @formatter:off |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedRecordListenerMalformedSecondRecord() throws Exception { |
| | | |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | | // @formatter:off |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedRecordListenerSkipsRecord() throws Exception { |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedRecordListenerRejectsBadSchemaRecord() throws Exception { |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedRecordListenerWarnsBadSchemaRecord() throws Exception { |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadFileContainingSerieOfChanges() throws Exception { |
| | | final File file = File.createTempFile("sdk", ".png"); |
| | | final String url = file.toURI().toURL().toString(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithDeleteControl() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithAddControl() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithAddControlWithoutSpacesBetweenCriticalityValue() |
| | | throws Exception { |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithAddControlContainingWhiteSpaces() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithAddControlContainingBase64Value() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithAddControlContainingURL() throws Exception { |
| | | final File file = File.createTempFile("sdk", ".png"); |
| | | final String url = file.toURI().toURL().toString(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithAddControlWithoutValue() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithAddControlWithoutCriticality() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithAddControlProvidedByChangeRecordWriter() |
| | | throws Exception { |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseChangeRecordEntryWithMultipleControls() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseDeleteChangeRecordEntry() throws Exception { |
| | | // @formatter:off |
| | | LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseModifyChangeRecordEntryDeleteMultipleValuableAttributes() throws Exception { |
| | | // @formatter:off |
| | | final LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseModifyChangeRecordBEREncodingRequired() throws Exception { |
| | | // @formatter:off |
| | | String validcert1 = // a valid certificate but wrong can be used => no errors |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseModifyChangeRecordEntryReplaceOk() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseModifyChangeRecordEntryIncrement() throws Exception { |
| | | // @formatter:off |
| | | final ChangeRecord cr = LDIFChangeRecordReader.valueOfLDIFChangeRecord( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseModifyDNChangeRecordEntryRecordBase64NewRDN() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseModifyDNChangeRecordEntry() throws Exception { |
| | | // @formatter:off |
| | | final LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseModifyRecordEntryDeleteOldRDNFalse() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testParseModifyRecordEntryNewSuperior() throws Exception { |
| | | // @formatter:off |
| | | LDIFChangeRecordReader reader = new LDIFChangeRecordReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testChangeRecordReaderUseListConstructor() throws Exception { |
| | | // @formatter:off |
| | | List<String> cr = Arrays.asList( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testValueOfLDIFChangeRecordStandardLDIF() throws Exception { |
| | | |
| | | // @formatter:off |
| | | final ChangeRecord cr = |
| | | LDIFChangeRecordReader.valueOfLDIFChangeRecord(getStandardLDIFChangeRecord()); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesTrue() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesFalse() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesTrue() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesFalse() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeBranchWrongDN() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeBranchWithNoMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeBranchWithMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAttributeWithMatch() throws Exception { |
| | | |
| | | final AttributeDescription attribute = AttributeDescription.valueOf("cn"); |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAttributeWithNoMatch() throws Exception { |
| | | |
| | | final AttributeDescription attribute = AttributeDescription.valueOf("vip"); |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeAttributeWithMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeAttributeWithNoMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | */ @Test |
| | | public void testSetIncludeBranchWithNoMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeBranchWithMatch() throws Exception { |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteCommentUsingTheWrapFunction() throws Exception { |
| | | |
| | | final CharSequence comment = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteCommentUsingTheWrapFunctionShortComment() throws Exception { |
| | | |
| | | final CharSequence comment = "Lorem ipsum dolor"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteCommentUsingTheWrapFunctionNoEmptySpace() throws Exception { |
| | | |
| | | final CharSequence comment = "Lorem ipsumdolorsitamet,consecteturadipisicingelit"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteChangeRecord() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteAddRequest() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteAddRequestNoBranchExcluded() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteAddRequestBranchExcluded() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteAddRequestJpegAttributeOk() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | final File file = File.createTempFile("sdk", ".jpeg"); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteAddBinaryRequest() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteAddBinaryNonAsciiRequest() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteDeleteRequestBranchExcluded() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteDeleteRequestBranchNotExcluded() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteDeleteRequest() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteDeleteRequestContainingControl() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | final DN dn = DN.valueOf("uid=scarter,ou=People,dc=example,dc=com"); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModdnRequest() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModdnRequestNewSuperior() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModdnRequestDeleterdnFalse() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyRequest() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyRequestUsingControl() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyRequestNoModifications() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyRequestFilterAttributesExcluded() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyRequestBranchExcludedNoMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyRequestBranchExcludedMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyDNRequestBranchExcludedNoMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyDNRequestBranchExcludedMatch() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteModifyDNRequest() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteMultipleChangeRecords() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | final ChangeRecord changeRequest = Requests.newAddRequest(getAddLDIFChangeRecord()); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteMultipleChangesRecord() throws Exception { |
| | | // @formatter:off |
| | | final ChangeRecord changeRequest = Requests.newChangeRecord( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteComment() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(actual); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteChangeRecordFlushClose() throws Exception { |
| | | |
| | | final OutputStream mockOutput = mock(OutputStream.class); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(mockOutput); |
| | | try { |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteEntryOutputStreamUsingByteArrayOutputStream() throws Exception { |
| | | |
| | | final OutputStream out = new ByteArrayOutputStream(); |
| | | final LDIFChangeRecordWriter writer = new LDIFChangeRecordWriter(out); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeBranchWithMatch() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setExcludeBranch(DN.valueOf("dc=example,dc=org")); |
| | | final Entry entry = reader.readEntry(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesFalse() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setExcludeAllUserAttributes(false); |
| | | final Entry entry = reader.readEntry(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllUserAttributesTrue() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | |
| | | reader.setExcludeAllUserAttributes(true); |
| | | |
| | | final Entry entry = reader.readEntry(); |
| | | reader.close(); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAttributeWithNoMatch() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setExcludeAttribute(AttributeDescription.valueOf("vip")); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAttributeWithMatch() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | |
| | | reader.setExcludeAttribute(AttributeDescription.valueOf("cn")); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesFalse() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | |
| | | reader.setExcludeAllOperationalAttributes(false); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeAllOperationalAttributesTrue() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | |
| | | reader.setExcludeAllOperationalAttributes(true); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetExcludeFilterWithMatch() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | final Filter filter = Filter.equality("objectclass", "vip"); |
| | | final Matcher excludeFilter = filter.matcher(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeAttributeWithMatch() throws Exception { |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setIncludeAttribute(AttributeDescription.valueOf("cn")); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeAttributeWithNoMatch() throws Exception { |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setIncludeAttribute(AttributeDescription.valueOf("manager")); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeBranchWithMatch() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setIncludeBranch(DN.valueOf("dc=example,dc=com")); |
| | | final Entry entry = reader.readEntry(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetIncludeFilterWithMatch() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | final Filter filter = Filter.equality("objectclass", "person"); |
| | | final Matcher includeFilter = filter.matcher(); |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedLDIFListenerMalformedFirstRecord() throws Exception { |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedLDIFListenerMalformedSecondRecord() throws Exception { |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedRecordListenerRejectsBadSchemaRecord() throws Exception { |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | |
| | | * @throws Exception |
| | | * if an unexpected error occurred. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedLDIFListenerWarnsBadSchemaRecord() throws Exception { |
| | | |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | | LDIFEntryReader reader = |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testRejectedLDIFListenerSkipsRecord() throws Exception { |
| | | |
| | | RejectedLDIFListener listener = mock(RejectedLDIFListener.class); |
| | | |
| | | LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetRejectedLDIFListenerDoesAllowNull() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setRejectedLDIFListener(null); |
| | | Entry entry = reader.readEntry(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetSchemaValidationPolicyDefaultAllowsEntry() throws Exception { |
| | | |
| | | // @formatter:off |
| | | String[] strEntry = { |
| | | "dn: uid=user.0,ou=People,dc=example,dc=com", "objectClass: person", |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSetSchemaSetSchemaValidationPolicyDefaultAllowsEntryWithNewAttribute() |
| | | throws Exception { |
| | | |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | | "dn: uid=user.0,ou=People,dc=example,dc=com", |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadEntryWithNoSpaces() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | /** |
| | | * Test to read an entry containing spaces before the attribute. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadEntryWithAttributesSpacesAtStart() throws Exception { |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testLDIFEntryReaderFullEntry() throws Exception { |
| | | |
| | | // @formatter:off |
| | | final String[] strEntry = { |
| | | "version: 1", |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testValueOfLDIFEntryReadEntryContainingURL() throws Exception { |
| | | |
| | | final File file = File.createTempFile("sdk", ".jpeg"); |
| | | final String url = file.toURI().toURL().toString(); |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadEntryBase64Encoded() throws Exception { |
| | | |
| | | // @formatter:off |
| | | final LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList( |
| | | "version: 1", |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testReadEntryBase64EncodedDN() throws Exception { |
| | | |
| | | // @formatter:off |
| | | final LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList( |
| | | "dn:: dWlkPXJvZ2FzYXdhcmEsb3U95Za25qWt6YOoLG89QWlyaXVz", // adding space before ok, after : ko |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testLDIFEntryReaderEntryAsArray() throws Exception { |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(Arrays.asList(getStandardEntry())); |
| | | |
| | | try { |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testValueOfLDIFEntryWellFormedEntry() throws Exception { |
| | | // @formatter:off |
| | | final Entry entry = LDIFEntryReader.valueOfLDIFEntry( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testValueOfLDIFEntryReadStandardEntry() throws Exception { |
| | | |
| | | final Entry entry = LDIFEntryReader.valueOfLDIFEntry(getStandardEntry()); |
| | | |
| | | assertThat(entry).isNotNull(); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteCommentUsingTheWrapFunction() throws Exception { |
| | | |
| | | final CharSequence comment = "Lorem ipsum dolor sit amet, consectetur adipisicing elit"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteCommentUsingTheWrapFunctionShortComment() throws Exception { |
| | | |
| | | final CharSequence comment = "Lorem ipsum dolor"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteCommentUsingTheWrapFunctionNoEmptySpace() throws Exception { |
| | | |
| | | final CharSequence comment = "Lorem ipsumdolorsitamet,consecteturadipisicingelit"; |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteComment() throws Exception { |
| | | |
| | | final CharSequence comment1 = "This is a new comment"; |
| | | final CharSequence comment2 = "Another one"; |
| | | |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteEntryUsingStandardEntry() throws Exception { |
| | | |
| | | final List<String> actual = new ArrayList<String>(); |
| | | final LDIFEntryWriter writer = new LDIFEntryWriter(actual); |
| | | final int wrapColumn = 15; |
| | |
| | | * @throws Exception |
| | | * If the test failed unexpectedly. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testWriteEntry() throws Exception { |
| | | final Entry entry = new LinkedHashMapEntry("cn=John Doe,ou=people,dc=example,dc=com"); |
| | | entry.addAttribute("objectClass", "top", "person", "inetOrgPerson"); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithMatch() throws Exception { |
| | | |
| | | final EntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | final SearchRequest sr = |
| | | Requests.newSearchRequest("dc=example,dc=com", SearchScope.WHOLE_SUBTREE, |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithNoMatch() throws Exception { |
| | | |
| | | final EntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | final SearchRequest sr = |
| | | Requests.newSearchRequest("dc=example,dc=org", SearchScope.WHOLE_SUBTREE, |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithSchemaMatchNoAttributeDescription() throws Exception { |
| | | |
| | | // @formatter:off |
| | | final EntryReader reader = new LDIFEntryReader( |
| | | "dn: uid=user.0,ou=People,dc=example,dc=com", |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithSchemaMatchNoAttributeDescriptionTypeOnly() |
| | | throws Exception { |
| | | |
| | | // @formatter:off |
| | | final EntryReader reader = new LDIFEntryReader( |
| | | "dn: uid=user.0,ou=People,dc=example,dc=com", |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithSchemaMatchFullAttributes() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithSchemaMatchOnlyOperationalAttributes() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithSchemaMatchOnlyOperationalAttributesTypeOnly() |
| | | throws Exception { |
| | | |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithSchemaMatchSpecifiedAttribute() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifSearchWithSchemaNoMatchSpecifiedAttribute() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifNewEntryCollectionReader() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifNewEntryIteratorReader() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifCopyToChangeRecord() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifCopyToEntryWriter() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * -1 result”>Admin Guide</a> |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifDiffEntriesModsOnSameDN() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifDiffEntriesEntryInSourceNotInTarget() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifDiffEntriesEntryInTargetNotInSource() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifDiffEntriesNoDiff() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifDiffEntriesShortExamples() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifDiffEntriesNoDiffBase64() throws Exception { |
| | | |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchAddNoDiff() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchAddDiff() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchAddDiffNewEntry() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchAddModifyNonExistantEntryDoNothing() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchDeleteEntry() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchDeleteEntryAmongSeveral() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchDeleteAttributesEntry() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchModifyEntry() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchModifyDNEntryUppercaseUid() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchModifyDNEntryUpperCaseDnNameSurname() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchModifyDNEntry() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | reader.close(); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchModifyDnEntry2() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchModifyDnEntryBranch() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchModifyDnEntryBranchKeepsOldRdn() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchModifyDnEntryNewSuperior() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchAddReplace() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchAddReplaceLanguageTagExample() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchVariousChanges() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testLdifPatchContainingChanges() throws Exception { |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testOverwritePatchOnModifyRequestSucceedsEvenIfWrongDN() throws Exception { |
| | | |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.OVERWRITE; |
| | | // @formatter:off |
| | | final LDIFEntryReader input = new LDIFEntryReader( |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testOverwritePatchOnModifyDNRequestSucceedsEvenWithWrongDN() throws Exception { |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.OVERWRITE; |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testOverwritePatchOnModifyDNRequestSucceedsEvenWithDuplicateEntry() throws Exception { |
| | | final RejectedChangeRecordListener listener = RejectedChangeRecordListener.OVERWRITE; |
| | | // @formatter:off |
| | |
| | | /** |
| | | * Disables logging before the tests. |
| | | */ |
| | | @BeforeClass() |
| | | @BeforeClass |
| | | public void disableLogging() { |
| | | TestCaseUtils.setDefaultLogLevel(Level.SEVERE); |
| | | } |
| | |
| | | /** |
| | | * Re-enable logging after the tests. |
| | | */ |
| | | @AfterClass() |
| | | @AfterClass |
| | | public void enableLogging() { |
| | | TestCaseUtils.setDefaultLogLevel(Level.INFO); |
| | | } |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public boolean equals(Object o) { |
| | | if (o == this) { |
| | | return true; |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public int hashCode() { |
| | | int hashCode = 44 + initialMemory + maximumMemory; |
| | | for (String arg : additionalArguments) { |
| | |
| | | } |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override() |
| | | @Override |
| | | public String toString() { |
| | | final StringBuilder sb = new StringBuilder(); |
| | | sb.append("Initial Memory: ").append(initialMemory).append(" Max Memory: ").append(maximumMemory); |
| | |
| | | /** |
| | | * Default is a self-signed certificate. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testGetDefault() { |
| | | final Certificate cert = new Certificate(); |
| | | assertThat(cert.getType()).isEqualTo(CertificateType.SELF_SIGNED); |
| | |
| | | assertThat(cert.getKeyStorePin()).isEmpty(); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testValidateDefaultCertificate() throws ConfigException { |
| | | final Certificate cert = new Certificate(); |
| | | cert.validate(); |
| | |
| | | * @throws IOException |
| | | * If an exception occurs when creating the temp keystore. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testValidateJKSCertificate() throws ConfigException, IOException { |
| | | final Certificate cert = new Certificate(); |
| | | cert.setType(CertificateType.JKS); |
| | |
| | | /** |
| | | * Creates a default data configuration. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testGetDefaultDataConfiguration() { |
| | | final DataConfiguration data = new DataConfiguration(); |
| | | assertThat(data.getDirectoryBaseDN()).isEqualTo(DataConfiguration.DEFAULT_DIRECTORY_BASE_DN); |
| | |
| | | * |
| | | * @throws IOException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCustomDataConfiguration() throws IOException { |
| | | final DataConfiguration data = new DataConfiguration(); |
| | | final int userEntries = 300; |
| | |
| | | /** |
| | | * Tests the type of the data configuration to make sure the boolean types are correctly assigned. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testDataConfigurationType() { |
| | | final DataConfiguration data = new DataConfiguration(); |
| | | assertTrue(data.isAutomaticallyImportGenerated()); |
| | |
| | | /** |
| | | * Retrieves default settings. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testGetDefault() { |
| | | final ListenerSettings dsSettings = new ListenerSettings(); |
| | | assertThat(dsSettings.getAdminPort()).isEqualTo(DEFAULT_ADMIN_PORT); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testGetFreePort() throws Exception { |
| | | // Finds a free socket |
| | | final InetSocketAddress isa = TestCaseUtils.findFreeSocketAddress(); |
| | |
| | | * |
| | | * @throws ConfigException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCreateDefaultDS() throws ConfigException { |
| | | final Model ds = new DataStoreModel(); |
| | | |
| | |
| | | * @throws IOException |
| | | * If an error occurred when the temporary file is created. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testIsValidDSAllowsPasswordFile() throws ConfigException, IOException { |
| | | final Model ds = new DataStoreModel(); |
| | | File passwordFile = null; |
| | |
| | | ds.validate(); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testCreateDSAllowsNullCertificate() throws ConfigException { |
| | | final Model ds = new DataStoreModel(); |
| | | ds.getListenerSettings().setCertificate(null); |
| | | assertFalse(ds.isSecure()); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testCreateSecureDS() throws ConfigException { |
| | | final Model ds = new DataStoreModel(); |
| | | final Certificate cert = new Certificate(); |
| | |
| | | * @throws ConfigException |
| | | * If a configuration exception occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCreateDSFirstInTopology() throws ConfigException { |
| | | final Model ds = new DataStoreModel(); |
| | | ds.getListenerSettings().setPassword("password"); |
| | |
| | | * @throws ConfigException |
| | | * If a configuration exception occurs. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testCreateDefaultDSWithLicense() throws ConfigException { |
| | | final Model ds = new DataStoreModel(); |
| | | final String license = "This is a CDDL License"; |
| | |
| | | */ |
| | | public class RuntimeOptionsTestCase extends AbstractSetupTestCase { |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testGetDefault() { |
| | | final RuntimeOptions options = RuntimeOptions.getDefault(); |
| | | assertThat(options.getInitialMemory()).isEqualTo(INITIAL_MEMORY); |
| | |
| | | options.setAdditionalArguments((String[]) null); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testEqualitySucceed() { |
| | | final RuntimeOptions options = RuntimeOptions.getDefault(); |
| | | assertThat(options.getInitialMemory()).isEqualTo(INITIAL_MEMORY); |
| | |
| | | assertThat(options).isEqualTo(options2); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testEqualityFails() { |
| | | final RuntimeOptions options = RuntimeOptions.getDefault(); |
| | | assertThat(options.getInitialMemory()).isEqualTo(INITIAL_MEMORY); |
| | |
| | | assertThat(options).isNotEqualTo(options2); |
| | | } |
| | | |
| | | @Test() |
| | | @Test |
| | | public void testRuntimeOptionsToString() { |
| | | |
| | | final RuntimeOptions options = new RuntimeOptions(); |
| | |
| | | * This class defines a set of tests for the Adapters.class. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test() |
| | | @Test |
| | | public class AdaptersTestCase extends ForgeRockTestCase { |
| | | |
| | | /** |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSimpleLDAPConnectionFactorySimpleBind() throws LdapException { |
| | | final LDAPConnectionFactory factory = |
| | | new LDAPConnectionFactory("localhost", |
| | |
| | | * @throws GeneralSecurityException |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testLDAPSASLBind() throws NumberFormatException, GeneralSecurityException, LdapException { |
| | | LDAPConnectionFactory factory = |
| | | new LDAPConnectionFactory("localhost", |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSASLBindRequest() throws LdapException, |
| | | GeneralSecurityException { |
| | | final Connection connection = Adapters.newRootConnection(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBindAsRoot() throws Exception { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | final BindResult result = connection.bind("cn=Directory Manager", "password".toCharArray()); |
| | | assertThat(connection.isValid()).isTrue(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBindAsAUser() throws Exception { |
| | | // user |
| | | final Connection connection = |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBind() throws Exception { |
| | | // Anonymous |
| | | final Connection connection = Adapters.newAnonymousConnection(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterAddRequest() throws Exception { |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterSearchRequest() throws Exception { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | |
| | | final SearchRequest request = |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterDeleteRequest() throws LdapException { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | // Checks if the entry exists. |
| | | SearchResultEntry sre = |
| | |
| | | * @throws LdapException |
| | | * @throws DecodeException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterModifyRequest() throws LdapException, DecodeException { |
| | | |
| | | final ModifyRequest changeRequest = |
| | | Requests.newModifyRequest("uid=user.2, dc=example,dc=org").addControl( |
| | | PreReadRequestControl.newControl(true, "mail")).addModification( |
| | |
| | | * @throws LdapException |
| | | * @throws SearchResultReferenceIOException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testLDAPConnectionAndAdapterComparison() throws LdapException, SearchResultReferenceIOException { |
| | | // @formatter:off |
| | | final AddRequest addRequest = Requests.newAddRequest( |
| | |
| | | * </pre> |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test() |
| | | @Test |
| | | public class ConvertersTestCase extends ForgeRockTestCase { |
| | | |
| | | /** |
| | |
| | | * Converts a SDK {@link SearchResultEntry} to an LDAP Server |
| | | * {@link SearchResultEntry}. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToSearchResultEntry() throws Exception { |
| | | org.forgerock.opendj.ldap.responses.SearchResultEntry entry = |
| | | Responses.newSearchResultEntry(org.forgerock.opendj.ldap.DN |
| | |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToByteString() throws DirectoryException { |
| | | org.forgerock.opendj.ldap.ByteString sdkByteString = ByteString.valueOf("This is a test"); |
| | | |
| | |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToDeferencePolicy() { |
| | | org.forgerock.opendj.ldap.DereferenceAliasesPolicy sdkDeferenceAliasesPolicy = |
| | | org.forgerock.opendj.ldap.DereferenceAliasesPolicy.ALWAYS; |
| | |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToControl() throws DirectoryException { |
| | | |
| | | final PersistentSearchRequestControl control = |
| | | PersistentSearchRequestControl.newControl(false, true, |
| | | true, // isCritical, changesOnly, returnECs |
| | |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToListOfControl() throws DirectoryException { |
| | | List<org.forgerock.opendj.ldap.controls.Control> mySDKControlsList = |
| | | generateSdkControlsList(); |
| | |
| | | /** |
| | | * Converts an SDK attribute to an LDAP server attribute. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToRawAttribute() throws DirectoryException { |
| | | org.forgerock.opendj.ldap.Attribute attribute = new LinkedAttribute("test", "value1"); |
| | | |
| | |
| | | /** |
| | | * Converts a SDK modification to an LDAP server raw modification. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToRawModification() { |
| | | org.forgerock.opendj.ldap.Attribute attribute = |
| | | new LinkedAttribute("test", ByteString.valueOf("value1"), ByteString |
| | |
| | | /** |
| | | * Converts a SDK filter to an LDAP server filter. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToFilter() throws LDAPException { |
| | | Filter filter = Filter.valueOf("!(description=*)"); |
| | | org.opends.server.protocols.ldap.LDAPFilter srvFilter = |
| | |
| | | * Converts a SDK search result reference to a LDAP server search result |
| | | * reference. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToSearchResultReference() throws LDAPException { |
| | | String uri = "ldap://hostb/OU=People,O=MNN,C=WW??sub"; |
| | | final org.forgerock.opendj.ldap.responses.SearchResultReference sdkSearchResultReference = |
| | |
| | | */ |
| | | @Test(groups = { "needRunningServer" }) |
| | | public final void testFromAttribute() throws DirectoryException { |
| | | |
| | | final org.opends.server.types.Attribute srvAttribute = Attributes.create("CN", "JOHN DOE"); |
| | | final org.forgerock.opendj.ldap.Attribute sdkAttribute = from(srvAttribute); |
| | | |
| | |
| | | */ |
| | | @Test(groups = { "needRunningServer" }) |
| | | public final void testFromAttributeUsingBinary() throws DirectoryException { |
| | | |
| | | byte[] data = { 0x00, 0x01, 0x02, (byte) 0xff }; |
| | | |
| | | AttributeValue value = AttributeValues.create(org.opends.server.types.ByteString.wrap(data), |
| | |
| | | /** |
| | | * Converts an LDAP byte string to an SDK byte string. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testFromByteString() throws LDAPException { |
| | | String str = "This is a test"; |
| | | org.opends.server.types.ByteString srvByteString = |
| | |
| | | /** |
| | | * Converts an LDAP control to an SDK control. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public static void testFromLDAPControl() { |
| | | org.opends.server.protocols.ldap.LDAPControl ldapControl = |
| | | new LDAPControl("1.2.3.4", false, to("myData")); |
| | |
| | | /** |
| | | * Converts a server control to an SDK control. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public static void testFromControl() { |
| | | final org.opends.server.types.Control control = |
| | | new LDAPControl("1.2.3.4", false, to("myData")); |
| | |
| | | * This class defines a set of tests for the Adapters.class. |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test() |
| | | @Test |
| | | public class AdaptersTestCase extends ForgeRockTestCase { |
| | | |
| | | /** |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testSimpleLDAPConnectionFactorySimpleBind() throws LdapException { |
| | | final LDAPConnectionFactory factory = |
| | | new LDAPConnectionFactory("localhost", |
| | |
| | | * @throws GeneralSecurityException |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testLDAPSASLBind() throws NumberFormatException, GeneralSecurityException, LdapException { |
| | | LDAPConnectionFactory factory = |
| | | new LDAPConnectionFactory("localhost", |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSASLBindRequest() throws LdapException, |
| | | GeneralSecurityException { |
| | | final Connection connection = Adapters.newRootConnection(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBindAsRoot() throws Exception { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | final BindResult result = connection.bind("cn=Directory Manager", "password".toCharArray()); |
| | | assertThat(connection.isValid()).isTrue(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBindAsAUser() throws Exception { |
| | | // user |
| | | final Connection connection = |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterConnectionSimpleBind() throws Exception { |
| | | // Anonymous |
| | | final Connection connection = Adapters.newAnonymousConnection(); |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterAddRequest() throws Exception { |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | // @formatter:off |
| | |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterSearchRequest() throws Exception { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | |
| | | final SearchRequest request = |
| | |
| | | * |
| | | * @throws LdapException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterDeleteRequest() throws LdapException { |
| | | |
| | | final Connection connection = Adapters.newRootConnection(); |
| | | // Checks if the entry exists. |
| | | SearchResultEntry sre = |
| | |
| | | * @throws LdapException |
| | | * @throws DecodeException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testAdapterModifyRequest() throws LdapException, DecodeException { |
| | | |
| | | final ModifyRequest changeRequest = |
| | | Requests.newModifyRequest("uid=user.2, dc=example,dc=org").addControl( |
| | | PreReadRequestControl.newControl(true, "mail")).addModification( |
| | |
| | | * @throws LdapException |
| | | * @throws SearchResultReferenceIOException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public void testLDAPConnectionAndAdapterComparison() throws LdapException, SearchResultReferenceIOException { |
| | | // @formatter:off |
| | | final AddRequest addRequest = Requests.newAddRequest( |
| | |
| | | * </pre> |
| | | */ |
| | | @SuppressWarnings("javadoc") |
| | | @Test() |
| | | @Test |
| | | public class ConvertersTestCase extends ForgeRockTestCase { |
| | | |
| | | /** |
| | |
| | | * Converts a SDK {@link SearchResultEntry} to an LDAP Server |
| | | * {@link SearchResultEntry}. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToSearchResultEntry() throws Exception { |
| | | org.forgerock.opendj.ldap.responses.SearchResultEntry entry = |
| | | Responses.newSearchResultEntry(org.forgerock.opendj.ldap.DN |
| | |
| | | * Converts a SDK {@link Entry} to an LDAP Server |
| | | * {@link Entry}. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToEntry() throws Exception { |
| | | org.forgerock.opendj.ldap.Entry entry = |
| | | new LinkedHashMapEntry(org.forgerock.opendj.ldap.DN |
| | |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToControl() throws DirectoryException { |
| | | final PersistentSearchRequestControl control = |
| | | PersistentSearchRequestControl.newControl(false, true, |
| | |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToListOfControl() throws DirectoryException { |
| | | List<org.forgerock.opendj.ldap.controls.Control> mySDKControlsList = |
| | | generateSdkControlsList(); |
| | |
| | | /** |
| | | * Converts an SDK attribute to an LDAP server attribute. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToRawAttribute() throws DirectoryException { |
| | | org.forgerock.opendj.ldap.Attribute attribute = new LinkedAttribute("test", "value1"); |
| | | |
| | |
| | | /** |
| | | * Converts a SDK modification to an LDAP server raw modification. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToRawModification() { |
| | | org.forgerock.opendj.ldap.Attribute attribute = |
| | | new LinkedAttribute("test", ByteString.valueOf("value1"), ByteString |
| | |
| | | /** |
| | | * Converts a SDK filter to an LDAP server filter. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToFilter() throws LDAPException { |
| | | Filter filter = Filter.valueOf("!(description=*)"); |
| | | org.opends.server.protocols.ldap.LDAPFilter srvFilter = |
| | |
| | | * Converts a SDK search result reference to a LDAP server search result |
| | | * reference. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testToSearchResultReference() throws LDAPException { |
| | | String uri = "ldap://hostb/OU=People,O=MNN,C=WW??sub"; |
| | | final org.forgerock.opendj.ldap.responses.SearchResultReference sdkSearchResultReference = |
| | |
| | | /** |
| | | * Converts an LDAP control to an SDK control. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public static void testFromLDAPControl() { |
| | | org.opends.server.protocols.ldap.LDAPControl ldapControl = |
| | | new LDAPControl("1.2.3.4", false, ByteString.valueOf("myData")); |
| | |
| | | /** |
| | | * Converts an Scope to an SDK Scope. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public static void testFromScope() { |
| | | // WHOLE SUBTREE |
| | | assertThat(org.forgerock.opendj.ldap.SearchScope.WHOLE_SUBTREE).isEqualTo(from(Scope.WHOLE_SUBTREE)); |
| | |
| | | /** |
| | | * Converts a server control to an SDK control. |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public static void testFromControl() { |
| | | final org.opends.server.types.Control control = |
| | | new LDAPControl("1.2.3.4", false, ByteString.valueOf("myData")); |
| | |
| | | * |
| | | * @throws DirectoryException |
| | | */ |
| | | @Test() |
| | | @Test |
| | | public final void testFromDN() throws DirectoryException { |
| | | final String dnString = "uid=scarter,ou=People,dc=example,dc=com"; |
| | | org.opends.server.types.DN srvDN = org.opends.server.types.DN.valueOf(dnString); |