| | |
| | | import java.util.HashMap; |
| | | import java.util.Enumeration; |
| | | import java.util.Map; |
| | | import java.util.Comparator; |
| | | import java.util.LinkedHashMap; |
| | | import java.util.logging.Logger; |
| | | import java.util.logging.Handler; |
| | |
| | | import org.opends.server.backends.MemoryBackend; |
| | | import org.opends.server.backends.jeb.BackendImpl; |
| | | import org.opends.server.config.ConfigException; |
| | | import org.opends.server.config.ConfigEntry; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.LockFileManager; |
| | |
| | | import org.opends.server.types.FilePermission; |
| | | import org.opends.server.types.InitializationException; |
| | | import org.opends.server.types.OperatingSystem; |
| | | import org.opends.server.types.NullOutputStream; |
| | | import org.opends.server.types.ResultCode; |
| | | import org.opends.server.util.ChangeRecordEntry; |
| | | import org.opends.server.util.AddChangeRecordEntry; |
| | | import org.opends.server.util.DeleteChangeRecordEntry; |
| | | import org.opends.server.util.ModifyChangeRecordEntry; |
| | | import org.opends.server.util.ModifyDNChangeRecordEntry; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import static org.testng.Assert.assertEquals; |
| | |
| | | * @throws SocketException in case of underlying exception. |
| | | */ |
| | | private static ServerSocket bindPort(int port) |
| | | throws IOException, SocketException |
| | | throws IOException |
| | | { |
| | | ServerSocket serverLdapSocket; |
| | | serverLdapSocket = new ServerSocket(); |
| | |
| | | * @throws IOException in case of underlying exception. |
| | | * @throws SocketException in case of underlying exception. |
| | | */ |
| | | public static ServerSocket bindFreePort() throws IOException, SocketException |
| | | public static ServerSocket bindFreePort() throws IOException |
| | | { |
| | | ServerSocket serverLdapSocket; |
| | | serverLdapSocket = new ServerSocket(); |
| | |
| | | { |
| | | memoryBackend = new MemoryBackend(); |
| | | memoryBackend.setBackendID("test"); |
| | | memoryBackend.initializeBackend(null, new DN[] { baseDN }); |
| | | memoryBackend.setBaseDNs(new DN[] { baseDN }); |
| | | memoryBackend.initializeBackend(); |
| | | DirectoryServer.registerBackend(memoryBackend); |
| | | } |
| | | |
| | |
| | | throws Exception |
| | | { |
| | | BackendImpl backend = (BackendImpl)DirectoryServer.getBackend(beID); |
| | | DN[] baseDNs = backend.getBaseDNs(); |
| | | ConfigEntry configEntry = TaskUtils.getConfigEntry(backend); |
| | | |
| | | TaskUtils.setBackendEnabled(configEntry, false); |
| | | TaskUtils.disableBackend(beID); |
| | | |
| | | try |
| | | { |
| | |
| | | |
| | | try |
| | | { |
| | | backend.clearBackend(configEntry, baseDNs); |
| | | backend.clearBackend(); |
| | | } |
| | | finally |
| | | { |
| | |
| | | } |
| | | finally |
| | | { |
| | | TaskUtils.setBackendEnabled(configEntry, true); |
| | | TaskUtils.enableBackend(beID); |
| | | } |
| | | |
| | | if (createBaseEntry) |
| | |
| | | LDIFReader reader = new LDIFReader(ldifImportConfig); |
| | | |
| | | List<Entry> entries = new ArrayList<Entry>(); |
| | | Entry entry = null; |
| | | Entry entry; |
| | | while ((entry = reader.readEntry()) != null) { |
| | | entries.add(entry); |
| | | } |
| | |
| | | */ |
| | | public static String makeLdif(String... lines) { |
| | | StringBuilder buffer = new StringBuilder(); |
| | | for (int i = 0; i < lines.length; i++) { |
| | | buffer.append(lines[i]).append(EOL); |
| | | for (String line : lines) { |
| | | buffer.append(line).append(EOL); |
| | | } |
| | | // Append an extra line so we can append LDIF Strings. |
| | | buffer.append(EOL); |
| | |
| | | } |
| | | |
| | | /** |
| | | * @return clear everything written to System.out since the last time |
| | | * clear everything written to System.out since the last time |
| | | * clearSystemOutContents was called. |
| | | */ |
| | | public synchronized static void clearSystemOutContents() { |
| | |
| | | } |
| | | |
| | | /** |
| | | * @return clear everything written to System.err since the last time |
| | | * clear everything written to System.err since the last time |
| | | * clearSystemErrContents was called. |
| | | */ |
| | | public synchronized static void clearSystemErrContents() { |
| | |
| | | */ |
| | | private static byte[] readFileBytes(File file) |
| | | throws IOException { |
| | | FileInputStream fis = null; |
| | | byte[] bytes = null; |
| | | FileInputStream fis; |
| | | byte[] bytes; |
| | | fis = new FileInputStream(file); |
| | | bytes = readInputStreamBytes(fis, true); |
| | | return bytes; |
| | |
| | | ByteArrayOutputStream bout = new ByteArrayOutputStream(1024); |
| | | try { |
| | | byte[] buf = new byte[1024]; |
| | | int bytesRead = 0; |
| | | int bytesRead; |
| | | while ((bytesRead = is.read(buf)) != -1) { |
| | | bout.write(buf, 0, bytesRead); |
| | | } // end of while ((read(buf) != -1) |