@Override public void handleRecord(LdapAttributes attributes) { callbackAttributeName = attributes.getName().toString(); } }
@Override public void handleRecord(LdapAttributes attributes) { callbackAttributeName = attributes.getName().toString(); } }
@Test public void testBasicRead() throws Exception { this.ldifReader = new LdifReaderBuilder().resource(context.getResource("classpath:/test.ldif")).name("foo").build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the first record did not match expected result", "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", ldapAttributes.getName().toString()); }
@Test public void testCurrentItemCount() throws Exception { this.ldifReader = new LdifReaderBuilder().currentItemCount(3) .resource(context.getResource("classpath:/test.ldif")).name("foo").build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the third record did not match expected result", "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", ldapAttributes.getName().toString()); }
@Test public void testSkipRecord() throws Exception { this.ldifReader = new LdifReaderBuilder().recordsToSkip(1).resource(context.getResource("classpath:/test.ldif")) .name("foo").build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the second record did not match expected result", "cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com", ldapAttributes.getName().toString()); }
@Test public void testBasicRead() throws Exception { this.mappingLdifReader = new MappingLdifReaderBuilder<LdapAttributes>() .recordMapper(new TestMapper()) .resource(context.getResource("classpath:/test.ldif")) .name("foo") .build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the first record did not match expected result", "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", ldapAttributes.getName().toString()); }
@Test public void testSkipRecord() throws Exception { this.mappingLdifReader = new MappingLdifReaderBuilder<LdapAttributes>() .recordsToSkip(1) .recordMapper(new TestMapper()) .resource(context.getResource("classpath:/test.ldif")) .name("foo") .build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the second record did not match expected result", "cn=Bjorn Jensen, ou=Accounting, dc=airius, dc=com", ldapAttributes.getName().toString()); }
@Test public void testMaxItemCount() throws Exception { this.ldifReader = new LdifReaderBuilder().maxItemCount(1).resource(context.getResource("classpath:/test.ldif")) .name("foo").build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the first record did not match expected result", "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", ldapAttributes.getName().toString()); ldapAttributes = this.ldifReader.read(); assertNull("The second read should have returned null", ldapAttributes); }
@Test public void testCurrentItemCount() throws Exception { this.mappingLdifReader = new MappingLdifReaderBuilder<LdapAttributes>() .currentItemCount(3) .recordMapper(new TestMapper()) .resource(context.getResource("classpath:/test.ldif")) .name("foo") .build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the third record did not match expected result", "cn=Gern Jensen, ou=Product Testing, dc=airius, dc=com", ldapAttributes.getName().toString()); }
@Test public void testMaxItemCount() throws Exception { this.mappingLdifReader = new MappingLdifReaderBuilder<LdapAttributes>() .maxItemCount(1) .recordMapper(new TestMapper()) .resource(context.getResource("classpath:/test.ldif")) .name("foo") .build(); LdapAttributes ldapAttributes = firstRead(); assertEquals("The attribute name for the first record did not match expected result", "cn=Barbara Jensen, ou=Product Development, dc=airius, dc=com", ldapAttributes.getName().toString()); ldapAttributes = this.mappingLdifReader.read(); assertNull("The second read should have returned null", ldapAttributes); }
LdapName dn = getName();
LdapName dn = getName();
LdapName dn = getName();
LdapName dn = record.getName(); if (dn != null) {
LdapName dn = record.getName(); if (dn != null) {
LdapName dn = record.getName(); if (dn != null) {
private static void loadLdif(DirContext context, Name rootNode, Resource ldifFile) { try { LdapName baseDn = (LdapName) context.getEnvironment().get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY); LdifParser parser = new LdifParser(ldifFile); parser.open(); while (parser.hasMoreRecords()) { LdapAttributes record = parser.getRecord(); LdapName dn = record.getName(); if(baseDn != null) { dn = LdapUtils.removeFirst(dn, baseDn); } if(!rootNode.isEmpty()) { dn = LdapUtils.prepend(dn, rootNode); } context.bind(dn, null, record); } } catch (Exception e) { throw new UncategorizedLdapException("Failed to populate LDIF", e); } }
private static void loadLdif(DirContext context, Name rootNode, Resource ldifFile) { try { LdapName baseDn = (LdapName) context.getEnvironment().get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY); LdifParser parser = new LdifParser(ldifFile); parser.open(); while (parser.hasMoreRecords()) { LdapAttributes record = parser.getRecord(); LdapName dn = record.getName(); if(baseDn != null) { dn = LdapUtils.removeFirst(dn, baseDn); } if(!rootNode.isEmpty()) { dn = LdapUtils.prepend(dn, rootNode); } context.bind(dn, null, record); } } catch (Exception e) { throw new UncategorizedLdapException("Failed to populate LDIF", e); } }
@SuppressWarnings("deprecation") private static void loadLdif(DirContext context, Name rootNode, Resource ldifFile) { try { LdapName baseDn = (LdapName) context.getEnvironment().get(DefaultDirObjectFactory.JNDI_ENV_BASE_PATH_KEY); LdifParser parser = new LdifParser(ldifFile); parser.open(); while (parser.hasMoreRecords()) { LdapAttributes record = parser.getRecord(); LdapName dn = record.getName(); if(baseDn != null) { dn = LdapUtils.removeFirst(dn, baseDn); } if(!rootNode.isEmpty()) { dn = LdapUtils.prepend(dn, rootNode); } context.bind(dn, null, record); } } catch (Exception e) { throw new UncategorizedLdapException("Failed to populate LDIF", e); } }