TestImportJob.java revision c0a5d19fa897c532ced3e13e01f18f869270e9a0
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2006-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
@SuppressWarnings("javadoc")
public class TestImportJob extends JebTestCase
{
private String homeDirName;
// @formatter:off
"dn: dc=importtest,dc=com\n"
+ "objectclass: top\n"
+ "objectclass: domain\n"
+ "dc: importtest\n"
+ "\n"
+ "dn: ou=People,dc=importtest,dc=com\n"
+ "objectclass: top\n"
+ "objectclass: organizationalUnit\n"
+ "ou: People\n"
+ "\n"
+ "dn: ou=Others,ou=People,dc=importtest,dc=com\n"
+ "objectclass: top\n"
+ "objectclass: organizationalUnit\n"
+ "ou: Others\n"
+ "\n"
+ "dn: dc=importtest1,dc=com\n"
+ "objectclass: top\n"
+ "objectclass: domain\n"
+ "dc: importtest1\n";
"dn: uid=user.0,ou=People,dc=importtest,dc=com\n"
+ "objectClass: top\n"
+ "objectClass: person\n"
+ "objectClass: organizationalPerson\n"
+ "objectClass: inetOrgPerson\n"
+ "givenName: Aaccf\n"
+ "sn: Amar\n"
+ "cn: Aaccf Amar\n"
+ "initials: AQA\n"
+ "employeeNumber: 0\n"
+ "uid: user.0\n"
+ "mail: user.0@example.com\n"
+ "userPassword: password\n"
+ "telephoneNumber: 380-535-2354\n"
+ "homePhone: 707-626-3913\n"
+ "pager: 456-345-7750\n"
+ "mobile: 366-674-7274\n"
+ "street: 99262 Eleventh Street\n"
+ "l: Salem\n"
+ "st: NM\n"
+ "postalCode: 36530\n"
+ "postalAddress: Aaccf Amar$99262 Eleventh Street$Salem, NM 36530\n"
+ "description: This is the description for Aaccf Amar.\n"
+ "\n"
+ "dn: uid=user.539,ou=People,dc=importtest,dc=com\n"
+ "objectClass: top\n"
+ "objectClass: person\n"
+ "objectClass: organizationalPerson\n"
+ "objectClass: inetOrgPerson\n"
+ "givenName: Ardyth\n"
+ "sn: Bainton\n"
+ "cn: Ardyth Bainton\n"
+ "initials: AIB\n"
+ "employeeNumber: 539\n"
+ "uid: user.539\n"
+ "mail: user.539@example.com\n"
+ "userPassword: password\n"
+ "telephoneNumber: 641-433-7404\n"
+ "homePhone: 524-765-8780\n"
+ "pager: 985-331-1308\n"
+ "mobile: 279-423-0188\n"
+ "street: 81170 Taylor Street\n"
+ "l: Syracuse\n"
+ "st: WV\n"
+ "postalCode: 93507\n"
+ "postalAddress: Ardyth Bainton$81170 Taylor Street$Syracuse, WV 93507\n"
+ "description: This is the description for Ardyth Bainton.\n"
+ "\n"
+ "dn: uid=user.446,dc=importtest1,dc=com\n"
+ "objectClass: top\n"
+ "objectClass: person\n"
+ "objectClass: organizationalPerson\n"
+ "objectClass: inetOrgPerson\n"
+ "givenName: Annalee\n"
+ "sn: Avard\n"
+ "cn: Annalee Avard\n"
+ "initials: ANA\n"
+ "employeeNumber: 446\n"
+ "uid: user.446\n"
+ "mail: user.446@example.com\n"
+ "userPassword: password\n"
+ "telephoneNumber: 875-335-2712\n"
+ "homePhone: 181-995-6635\n"
+ "pager: 586-905-4185\n"
+ "mobile: 826-857-7592\n"
+ "street: 46168 Mill Street\n"
+ "l: Charleston\n"
+ "st: CO\n"
+ "postalCode: 60948\n"
+ "postalAddress: Annalee Avard$46168 Mill Street$Charleston, CO 60948\n"
+ "description: This is the description for Annalee Avard.\n"
+ "\n"
+ "dn: uid=user.362,dc=importtest1,dc=com\n"
+ "objectClass: top\n"
+ "objectClass: person\n"
+ "objectClass: organizationalPerson\n"
+ "objectClass: inetOrgPerson\n"
+ "givenName: Andaree\n"
+ "sn: Asawa\n"
+ "cn: Andaree Asawa\n"
+ "initials: AEA\n"
+ "employeeNumber: 362\n"
+ "uid: user.362\n"
+ "mail: user.362@example.com\n"
+ "userPassword: password\n"
+ "telephoneNumber: 399-788-7334\n"
+ "homePhone: 798-076-5683\n"
+ "pager: 034-026-9411\n"
+ "mobile: 948-743-9197\n"
+ "street: 81028 Forest Street\n"
+ "l: Wheeling\n"
+ "st: IA\n"
+ "postalCode: 60905\n"
+ "postalAddress: Andaree Asawa$81028 Forest Street$Wheeling, IA 60905\n"
+ "description: This is the description for Andaree Asawa.\n";
private String replacement1 =
"dn: uid=user.446,dc=importtest1,dc=com\n"
+ "objectClass: top\n"
+ "objectClass: person\n"
+ "objectClass: organizationalPerson\n"
+ "objectClass: inetOrgPerson\n"
+ "givenName: Annalee\n"
+ "sn: Bogard\n"
+ "cn: Annalee Bogard\n"
+ "initials: ANG\n"
+ "employeeNumber: 446\n"
+ "uid: user.446\n"
+ "mail: user.446@example.com\n"
+ "userPassword: password\n"
+ "telephoneNumber: 875-335-8882\n"
+ "homePhone: 181-995-6635\n"
+ "pager: 586-905-4185\n"
+ "mobile: 826-857-7592\n"
+ "street: 43221 Hill Street\n"
+ "l: Charleston\n"
+ "st: CO\n"
+ "postalCode: 60918\n"
+ "postalAddress: Annalee Avard$43221 Hill Street$Charleston, CO 60918\n"
+ "description: This is the description for Annalee Bogard.\n";
private String skippedEntries =
"dn: dc=skipped,dc=importtest1,dc=com\n"
+ "objectclass: top\n"
+ "objectclass: domain\n"
+ "dc: skipped\n"
+ "\n"
+ "dn: uid=user.446,dc=skipped,dc=importtest1,dc=com\n"
+ "objectClass: top\n"
+ "objectClass: person\n"
+ "objectClass: organizationalPerson\n"
+ "objectClass: inetOrgPerson\n"
+ "givenName: Annalee\n"
+ "sn: Bogard\n"
+ "cn: Annalee Bogard\n"
+ "initials: ANG\n"
+ "employeeNumber: 446\n"
+ "uid: user.446\n"
+ "mail: user.446@example.com\n"
+ "userPassword: password\n"
+ "telephoneNumber: 875-335-8882\n"
+ "homePhone: 181-995-6635\n"
+ "pager: 586-905-4185\n"
+ "mobile: 826-857-7592\n"
+ "street: 43221 Hill Street\n"
+ "l: Charleston\n"
+ "st: CO\n"
+ "postalCode: 60918\n"
+ "postalAddress: Annalee Avard$43221 Hill Street$Charleston, CO 60918\n"
+ "description: This is the description for Annalee Bogard.\n";
// @formatter:on
{
// This test suite depends on having the schema available, so we'll make
// sure the server is started.
+ "entries1.ldif");
+ "replacement1.ldif");
+ "skipped.ldif");
}
{
}
public void testImportAll() throws Exception
{
importConfig.setAppendToExistingData(false);
importConfig.setValidateSchema(true);
{
try
{
{
.valueOf("ou=People,dc=importtest,dc=com")));
.valueOf("ou=Others,ou=People,dc=importtest,dc=com")));
.valueOf("uid=user.0,ou=People,dc=importtest,dc=com")));
.valueOf("uid=user.539,ou=People,dc=importtest,dc=com")));
}
{
.valueOf("uid=user.446,dc=importtest1,dc=com")));
.valueOf("uid=user.362,dc=importtest1,dc=com")));
}
}
finally
{
}
}
}
public void testImportPartial() throws Exception
{
Set<DN> excludeBranches = Collections.singleton(DN.valueOf("ou=Others,ou=People,dc=importtest,dc=com"));
importConfig.setAppendToExistingData(false);
importConfig.setValidateSchema(true);
{
try
{
{
.valueOf("ou=People,dc=importtest,dc=com")));
.valueOf("ou=Others,ou=People,dc=importtest,dc=com")));
.valueOf("uid=user.0,ou=People,dc=importtest,dc=com")));
.valueOf("uid=user.539,ou=People,dc=importtest,dc=com")));
}
{
.valueOf("uid=user.446,dc=importtest1,dc=com")));
.valueOf("uid=user.362,dc=importtest1,dc=com")));
}
}
finally
{
}
}
}
public void testImportReplaceExisting() throws Exception
{
importConfig.setValidateSchema(true);
.valueOf("dc=importtest1,dc=com"));
try
{
.valueOf("uid=user.446,dc=importtest1,dc=com"));
.getAttributeType();
}
finally
{
}
}
public void testImportNoParent() throws Exception
{
importConfig.setAppendToExistingData(false);
importConfig.setValidateSchema(true);
"uid=user.446,dc=importtest1,dc=com"));
}
public void testImportAppend() throws Exception
{
importConfig.setAppendToExistingData(false);
importConfig.setValidateSchema(true);
+ "entries1.ldif");
importConfig.setValidateSchema(true);
{
try
{
{
.valueOf("ou=People,dc=importtest,dc=com")));
.valueOf("uid=user.0,ou=People,dc=importtest,dc=com")));
.valueOf("uid=user.539,ou=People,dc=importtest,dc=com")));
}
{
.valueOf("uid=user.446,dc=importtest1,dc=com")));
.valueOf("uid=user.362,dc=importtest1,dc=com")));
}
}
finally
{
}
}
}
public void testImportNotReplaceExisting() throws Exception
{
importConfig.setValidateSchema(true);
"uid=user.446,dc=importtest1,dc=com"));
}
public void testImportSkip() throws Exception
{
importConfig.setValidateSchema(true);
"dc=skipped,dc=importtest1,dc=com"));
"uid=user.446,dc=skipped,dc=importtest1,dc=com"));
}
{
try
{
}
finally
{
}
}
}