TestImportAndExport.java revision 42712d18141bafcee3f2ec5ec567552f43e16ed0
/*
* 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-2009 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* Tests invocation of the import and export tasks, but does not aim to
* thoroughly test the underlying backend implementations.
*/
public class TestImportAndExport extends TasksTestCase
{
/**
* A makeldif template used to create some test entries.
*/
"define suffix=dc=example,dc=com",
"define maildomain=example.com",
"define numusers=101",
"",
"branch: [suffix]",
"",
"branch: ou=People,[suffix]",
"subordinateTemplate: person:[numusers]",
"",
"template: person",
"rdnAttr: uid",
"objectClass: top",
"objectClass: person",
"objectClass: organizationalPerson",
"objectClass: inetOrgPerson",
"givenName: <first>",
"sn: <last>",
"cn: {givenName} {sn}",
"initials: {givenName:1}<random:chars:" +
"ABCDEFGHIJKLMNOPQRSTUVWXYZ:1>{sn:1}",
"employeeNumber: <sequential:0>",
"uid: user.{employeeNumber}",
"mail: {uid}@[maildomain]",
"userPassword: password",
"telephoneNumber: <random:telephone>",
"homePhone: <random:telephone>",
"pager: <random:telephone>",
"mobile: <random:telephone>",
"street: <random:numeric:5> <file:streets> Street",
"l: <file:cities>",
"st: <file:states>",
"postalCode: <random:numeric:5>",
"postalAddress: {cn}${street}${l}, {st} {postalCode}",
"description: This is the description for {cn}.",
""};
/**
* A temporary LDIF file containing some test entries.
*/
/**
* A temporary file to contain rejected entries.
*/
private File rejectFile;
{
// The server must be running for these tests.
// Create a temporary test LDIF file.
// Create a temporary rejects file.
}
public void tearDown()
{
rejectFile.delete();
}
/**
* Import and export tasks test data provider.
*
* @return The array of tasks test data. The first column is a task entry
* and the second column is the expected completed task state.
*/
{
return new Object[][] {
// A fairly simple, valid import task using backend ID.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-backend-id: userRoot",
"ds-task-import-overwrite-rejects: TRUE",
"ds-task-import-exclude-attribute: description",
"ds-task-import-exclude-filter: (st=CA)",
"ds-task-import-exclude-branch: o=exclude,dc=example,dc=com"
),
},
// A fairly simple, valid import task using include base DN.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-include-branch: dc=example,dc=com",
"ds-task-import-overwrite-rejects: TRUE",
"ds-task-import-exclude-attribute: description",
"ds-task-import-exclude-filter: (st=CA)",
"ds-task-import-exclude-branch: o=exclude,dc=example,dc=com"
),
},
// A complex, valid import task.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-backend-id: userRoot",
"ds-task-import-is-compressed: FALSE",
"ds-task-import-is-encrypted: FALSE",
"ds-task-import-overwrite-rejects: FALSE",
"ds-task-import-append: TRUE",
"ds-task-import-replace-existing: TRUE",
"ds-task-import-skip-schema-validation: TRUE",
"ds-task-import-include-branch: dc=example,dc=com",
"ds-task-import-exclude-branch: o=exclude,dc=example,dc=com",
"ds-task-import-include-attribute: cn",
"ds-task-import-include-attribute: sn",
"ds-task-import-include-attribute: uid",
"ds-task-import-include-filter: (objectclass=*)"
),
},
// A partial, valid import task.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-include-branch: ou=people,dc=example,dc=com",
"ds-task-import-overwrite-rejects: TRUE",
"ds-task-import-exclude-attribute: description",
"ds-task-import-exclude-filter: (st=CA)",
"ds-task-import-exclude-branch: o=exclude,dc=example,dc=com"
),
},
// Rejects file is a directory.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-backend-id: userRoot",
"ds-task-import-overwrite-rejects: TRUE"
),
},
};
}
/**
* Import and export tasks bad test data provider.
*
* @return The array of tasks test data. The first column is a task entry
* and the second column is the expected completed task state.
*/
{
return new Object[][] {
// Invalid exclude filter.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-backend-id: userRoot",
"ds-task-import-exclude-filter: ()"
),
},
// Invalid include filter.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-backend-id: userRoot",
"ds-task-import-include-filter: ()"
),
},
// Backend id does not exist.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-backend-id: doesnotexist"
),
},
// Backend does not support import.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-backend-id: monitor"
),
},
// Backend does not handle include branch.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-backend-id: userRoot",
"ds-task-import-include-branch: dc=opends,dc=org"
),
},
// Not specifying a destination.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
),
},
// ldif file does not exist.
{
",cn=Scheduled Tasks,cn=Tasks",
"objectclass: top",
"objectclass: ds-task",
"objectclass: ds-task-import",
"ds-task-class-name: org.opends.server.tasks.ImportTask",
"ds-task-import-ldif-file: doesnotexist",
"ds-task-import-backend-id: userRoot"
),
}
};
}
/**
* Test that various import and export task definitions complete with the
* expected state.
* @param taskEntry The task entry.
* @param expectedState The expected completion state of the task.
*/
throws Exception
{
// Use a big timeout since this test is sensitive to host environment (e.g.
// low memory, etc). See issue OPENDJ-256.
{
{
}
else
{
}
}
}
/**
* Add a task definition and check that it completes with the expected state.
* @param taskEntry The task entry.
* @param resultCode The expected result code of the task add.
* @throws Exception If the test fails.
*/
throws Exception
{
}
}