/*
* 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 2008 Sun Microsystems, Inc.
*/
/**
* This class defines a set of generic tests that may be used to examine the
* server schema.
*/
public class GenericSchemaTestCase
extends SchemaTestCase
{
/**
* Ensures that the Directory Server is running.
*
* @throws Exception If an unexpected problem occurs.
*/
@BeforeClass()
public void setUp()
throws Exception
{
}
/**
* Tests to ensure that all attribute syntaxes defined in the schema have
* valid OIDs.
*/
@Test()
public void testEnsureValidSyntaxOIDs()
{
{
{
}
}
if (! invalidOIDs.isEmpty())
{
"valid OIDs assigned.");
for (String s : invalidOIDs)
{
}
}
}
/**
* Tests to ensure that all matching rules defined in the schema have valid
* OIDs.
*/
@Test()
public void testEnsureValidMatchingRuleOIDs()
{
{
{
}
}
if (! invalidOIDs.isEmpty())
{
"OIDs assigned.");
for (String s : invalidOIDs)
{
}
}
}
/**
* Tests to ensure that all attribute types defined in the schema have valid
* OIDs.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testEnsureValidAttributeTypeOIDs()
throws Exception
{
{
{
// This could be some other kind of file, like ".svn".
continue;
}
if (e == null)
{
// An empty schema file. This is OK.
continue;
}
{
// No attribute types in the schema file. This is OK.
continue;
}
{
for (AttributeValue v : a)
{
true);
{
}
}
}
}
if (! invalidOIDs.isEmpty())
{
"OIDs assigned.");
for (String s : invalidOIDs)
{
}
}
}
/**
* Tests to ensure that all object classes defined in the schema have valid
* OIDs.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testEnsureValidObjectClassOIDs()
throws Exception
{
{
{
// This could be some other kind of file, like ".svn".
continue;
}
if (e == null)
{
// An empty schema file. This is OK.
continue;
}
{
// No attribute types in the schema file. This is OK.
continue;
}
{
for (AttributeValue v : a)
{
true);
{
}
}
}
}
if (! invalidOIDs.isEmpty())
{
"OIDs assigned.");
for (String s : invalidOIDs)
{
}
}
}
/**
* Tests to ensure that all name forms defined in the schema have valid OIDs.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testEnsureValidNameFormOIDs()
throws Exception
{
{
{
// This could be some other kind of file, like ".svn".
continue;
}
if (e == null)
{
// An empty schema file. This is OK.
continue;
}
{
// No attribute types in the schema file. This is OK.
continue;
}
{
for (AttributeValue v : a)
{
DirectoryServer.getSchema(), true);
{
}
}
}
}
if (! invalidOIDs.isEmpty())
{
"assigned.");
for (String s : invalidOIDs)
{
}
}
}
/**
* Indicates whether the string represents a valid numeric OID.
*
* @param oid The string for which to make the determination.
*
* @return {@code true} if the provided string represents a valid numeric
* OID, or {@code false} if not.
*/
{
// It must not be null, and it must not be empty.
{
return false;
}
// It must start and end with numeric digits.
{
return false;
}
// It must contain at least one period.
{
return false;
}
// It must not contain any double periods.
{
return false;
}
// It must not contain any characters other than digits and periods.
while (tokenizer.hasMoreTokens())
{
for (char c : token.toCharArray())
{
{
return false;
}
}
}
// If we've gotten here, then it should be a valid numeric OID.
return true;
}
}