| | |
| | | import org.opends.server.protocols.ldap.LDAPReader; |
| | | import org.opends.server.tools.LDAPModify; |
| | | import org.opends.server.tools.dsconfig.DSConfig; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.AttributeTypeConstants; |
| | | import org.opends.server.types.ByteString; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.DirectoryEnvironmentConfig; |
| | |
| | | import org.opends.server.types.LDIFImportConfig; |
| | | import org.opends.server.types.OperatingSystem; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.types.Schema; |
| | | import org.opends.server.util.BuildVersion; |
| | | import org.opends.server.util.EmbeddedUtils; |
| | | import org.opends.server.util.LDIFReader; |
| | |
| | | private static File testConfigDir; |
| | | |
| | | /** |
| | | * Setup in-memory versions of everything needed to run unit tests with the |
| | | * {@link DirectoryServer} class. |
| | | * <p> |
| | | * This method is trying hard to provide sensible defaults and core data you |
| | | * would expect from a normal install, including AttributeTypes, etc. |
| | | */ |
| | | public static void startFakeServer() |
| | | { |
| | | DirectoryServer.setSchema(initializeInMemory(new Schema())); |
| | | } |
| | | |
| | | private static Schema initializeInMemory(final Schema schema) |
| | | { |
| | | try |
| | | { |
| | | for (AttributeType attributeType : AttributeTypeConstants.ALL) |
| | | { |
| | | schema.registerAttributeType(attributeType, true); |
| | | } |
| | | return schema; |
| | | } |
| | | catch (DirectoryException e) |
| | | { |
| | | // rethrow this to fail the current test |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Starts the Directory Server so that it will be available for use while |
| | | * running the unit tests. This will only actually start the server once, so |
| | | * subsequent attempts to start it will be ignored because it will already be |
| | |
| | | + "instance.loc"); |
| | | installLoc.deleteOnExit(); |
| | | FileWriter w = new FileWriter(installLoc); |
| | | w.write(testInstanceRoot.getAbsolutePath()); |
| | | w.close(); |
| | | try |
| | | { |
| | | w.write(testInstanceRoot.getAbsolutePath()); |
| | | } |
| | | finally |
| | | { |
| | | w.close(); |
| | | } |
| | | |
| | | if (opendmkJar.exists()) |
| | | { |