| | |
| | | |
| | | import static org.testng.Assert.assertNotNull; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | |
| | | public void testSetExcludeBranchDoesntAllowNull() throws Exception { |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setExcludeBranch(null); |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setExcludeAttribute(null); |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testSetIncludeBranchDoesntAllowNull() throws Exception { |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setIncludeBranch(null); |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void testSetIncludeFilterDoesntAllowNull() throws Exception { |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setIncludeFilter(null); |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(strEntry); |
| | | reader.setSchema(Schema.getDefaultSchema()); |
| | | reader.setSchemaValidationPolicy(null); |
| | | |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | final LDIFEntryReader reader = new LDIFEntryReader(getStandardEntry()); |
| | | reader.setSchema(null); // must throw a NullPointerException |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Test() |
| | | public void testValueOfLDIFEntryReadEntryContainingURL() throws Exception { |
| | | |
| | | final File file = File.createTempFile("sdk", ".jpeg"); |
| | | final String url = file.toURI().toURL().toString(); |
| | | |
| | | // @formatter:off |
| | | final LDIFEntryReader reader = new LDIFEntryReader( |
| | | "#A single comment", |
| | |
| | | "sn: Jensen", |
| | | "uid: hjensen", |
| | | "telephonenumber: +1 408 555 1212", |
| | | "jpegphoto:< http://www.forgerock.com/sites/default/files/forgerock_logo.png", |
| | | "jpegphoto:< " + url, |
| | | "#This is a end line comment", "# Followed by another" |
| | | ); |
| | | // @formatter:on |
| | |
| | | assertThat(entry.getAttribute("jpegphoto")).isNotEmpty(); |
| | | assertThat(entry.getAttribute("cn").firstValueAsString()).isEqualTo("Horatio Jensen"); |
| | | } finally { |
| | | file.delete(); |
| | | reader.close(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * LDIFEntryReader entry containing a reference to an external file & an |
| | | * invalid protocol. |
| | | * LDIFEntryReader entry containing a malformed URL. |
| | | * |
| | | * @throws Exception |
| | | */ |
| | | // TODO |
| | | @Test(expectedExceptions = DecodeException.class) |
| | | public void testValueOfLDIFEntryReadEntryContainingURLInvalidProtocol() throws Exception { |
| | | public void testValueOfLDIFEntryReadEntryContainingMalformedURL() throws Exception { |
| | | |
| | | // @formatter:off |
| | | final LDIFEntryReader reader = new LDIFEntryReader( |
| | |
| | | */ |
| | | @Test(expectedExceptions = NullPointerException.class) |
| | | public void testLDIFEntryReaderInpuStreamDoesntAllowNull() throws Exception { |
| | | new LDIFEntryReader((InputStream) null); |
| | | final LDIFEntryReader reader = new LDIFEntryReader((InputStream) null); |
| | | reader.close(); |
| | | } |
| | | |
| | | /** |