ListBackendsTestCase.java revision 378931eeabc8709b956de2da88403d571c4aac07
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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
*
*
* Portions Copyright 2006-2007 Sun Microsystems, Inc.
*/
/**
* A set of test cases for the ListBackends tool.
*/
public class ListBackendsTestCase
extends ToolsTestCase
{
// The path to the Directory Server configuration file.
private String configFilePath;
/**
* Ensures that the Directory Server is running and gets the config file path.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
public void startServer()
throws Exception
{
}
/**
* Retrieves sets of invalid arguments that may not be used to initialize
* the ListBackends tool.
*
* @return Sets of invalid arguments that may not be used to initialize the
* ListBackends tool.
*/
public Object[][] getInvalidArgumentLists()
{
{
"-c",
};
{
"-f",
};
{
"-n",
};
{
"-b",
};
{
"-I"
};
{
"--invalidLongArgument"
};
{
"--backendID", "nosuchbackend"
};
{
"--configFile", configFilePath,
"--backendID", "nosuchbackend"
};
{
"--configFile", configFilePath,
"--baseDN", "invaliddn"
};
{
"--configFile", configFilePath,
"--backendID", "userRoot",
"--baseDN", "dc=example,dc=com"
};
{
}
return returnArray;
}
/**
* Tests the ListBackends tool with sets of invalid arguments.
*
* @param args The set of arguments to use for the ListBackends
* tool.
* @param invalidReason The reason the provided set of arguments is invalid.
*/
{
"Should have been invalid because: " + invalidReason);
}
/**
* Tests the ListBackends tool with the no arguments.
*/
@Test()
public void testNoArguments()
{
{
"--configFile", configFilePath
};
}
/**
* Tests the ListBackends tool with one instance of the --backendID argument
* and a valid backend ID.
*/
@Test()
public void testSingleBackendID()
{
{
"--configFile", configFilePath,
"--backendID", "userRoot"
};
}
/**
* Tests the ListBackends tool with multiple instances of the --backendID
* argument valid backend IDs.
*/
@Test()
public void testMultipleBackendIDs()
{
{
"--configFile", configFilePath,
"--backendID", "userRoot",
"--backendID", "schema"
};
}
/**
* Tests the ListBackends tool with multiple instances of the --backendID
* argument in which one is valid and one is not.
*/
@Test()
public void testMultipleBackendIDsPartiallyValid()
{
{
"--configFile", configFilePath,
"--backendID", "userRoot",
"--backendID", "invalid"
};
}
/**
* Tests the ListBackends tool with multiple instances of the --backendID
* argument in which all are invalid.
*/
@Test()
public void testMultipleBackendIDsAllInvalid()
{
{
"--configFile", configFilePath,
"--backendID", "invalid1",
"--backendID", "invalid2"
};
}
/**
* Tests the ListBackends tool with one instance of the --baseDN argument
* and a valid DN that is a base DN.
*/
@Test()
public void testSingleBaseDN()
{
{
"--configFile", configFilePath,
"--baseDN", "dc=example,dc=com"
};
}
/**
* Tests the ListBackends tool with one instance of the --baseDN argument
* and a valid DN that is not a base DN but is directly below a valid base DN.
*/
@Test()
public void testSingleBaseDNBelowActualBaseDN()
{
{
"--configFile", configFilePath,
"--baseDN", "ou=notbase,dc=example,dc=com"
};
}
/**
* Tests the ListBackends tool with one instance of the --baseDN argument
* and a valid DN that is not a base DN but is two levels below a valid base
* DN.
*/
@Test()
public void testSingleBaseDNTwoLevelsBelowActualBaseDN()
{
{
"--configFile", configFilePath,
"--baseDN", "ou=notbase,ou=alsonotbase,dc=example,dc=com"
};
}
/**
* Tests the ListBackends tool with one instance of the --baseDN argument
* and a valid DN that is not associated with any backend in the server
*/
@Test()
public void testSingleBaseDNNotBelowAnyBaseDN()
{
{
"--configFile", configFilePath,
"--baseDN", "ou=nonexistent"
};
}
/**
* Tests the ListBackends tool with multiple instances of the "--baseDN"
* argument with valid base DNs.
*/
@Test()
public void testMultipleBaseDNs()
{
{
"--configFile", configFilePath,
"--baseDN", "dc=example,dc=com",
"--baseDN", "cn=schema"
};
}
/**
* Tests the ListBackends tool with the "--help" option.
*/
@Test()
public void testHelp()
{
}
}