AutoRefactor: fix String usage
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS |
| | | * Portions Copyright 2013-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.quicksetup; |
| | | |
| | |
| | | throw new IllegalStateException( |
| | | "setup server process failed:\n" + |
| | | "exit value: " + p.exitValue() + "\n" + |
| | | "stdout contents: " + stdOut.toString() + "\n" + |
| | | "stderr contents: " + stdErr.toString()); |
| | | "stdout contents: " + stdOut + "\n" + |
| | | "stderr contents: " + stdErr); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions copyright 2011-2015 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.admin; |
| | | |
| | |
| | | return params; |
| | | } |
| | | |
| | | // Exceptions to config objects having a differnt objectclass |
| | | // Exceptions to config objects having a different objectclass |
| | | private static final List<String> CLASS_OBJECT_CLASS_EXCEPTIONS = |
| | | Arrays.asList( |
| | | "org.opends.server.admin.std.meta.RootCfgDefn", |
| | |
| | | validatePropertyDefinition(objectDef, configObjectClass, propDef, errors); |
| | | } |
| | | |
| | | if (errors.length() > 0) { |
| | | Assert.fail("The configuration definition for " + objectDef.getName() + " has the following problems: " + EOL + |
| | | errors.toString()); |
| | | } |
| | | Assert.assertEquals(errors.length(), 0, |
| | | "The configuration definition for " + objectDef.getName() + " has the following problems: " + EOL + errors); |
| | | } |
| | | |
| | | // Exceptions to properties ending in -class being exactly 'java-class'. |
| | |
| | | |
| | | tempDir = TestCaseUtils.createTemporaryDirectory("jebimporttest"); |
| | | homeDirName = tempDir.getAbsolutePath(); |
| | | System.out.println(homeDirName.toString()); |
| | | System.out.println(homeDirName); |
| | | |
| | | EnvManager.createHomeDir(homeDirName); |
| | | |
| | |
| | | String taskDN = |
| | | "ds-recurring-task-id=" + taskID |
| | | + ",cn=Recurring Tasks,cn=tasks"; |
| | | String taskSchedule = "00 * * " + |
| | | Integer.toString(scheduledMonth) + " *"; |
| | | String taskSchedule = "00 * * " + scheduledMonth + " *"; |
| | | |
| | | TaskBackend taskBackend = |
| | | (TaskBackend) DirectoryServer.getBackend(DN.valueOf("cn=tasks")); |
| | |
| | | * |
| | | * |
| | | * Copyright 2009 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | public void checkECLRequestControlTest(boolean critical, String value) |
| | | throws Exception |
| | | { |
| | | // Test contructor |
| | | // Test constructor |
| | | MultiDomainServerState mdss = new MultiDomainServerState(value); |
| | | ExternalChangelogRequestControl eclrc |
| | | = new ExternalChangelogRequestControl(critical, mdss); |
| | |
| | | bsb.clear(); |
| | | eclrc.write(writer); |
| | | LDAPControl control = LDAPReader.readControl(ASN1.getReader(bsb)); |
| | | eclrc = |
| | | ExternalChangelogRequestControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | | eclrc = ExternalChangelogRequestControl.DECODER.decode(control.isCritical(), control.getValue()); |
| | | assertNotNull(eclrc); |
| | | assertEquals(critical, eclrc.isCritical()); |
| | | assertEquals(OID_ECL_COOKIE_EXCHANGE_CONTROL, eclrc.getOID()); |
| | | assertTrue(eclrc.getCookie().equalsTo(mdss), |
| | | "Expect:"+value+", Got:"+eclrc.getCookie().toString()); |
| | | "Expect:" + value + ", Got:" + eclrc.getCookie()); |
| | | } |
| | | } |
| | |
| | | |
| | | // check to String |
| | | String toString = |
| | | "PasswordPolicyResponseControl(" + |
| | | warningType.toString() + |
| | | "=" + |
| | | warningValue + |
| | | ", " + |
| | | errorType.toString() + |
| | | ")" ; |
| | | assertEquals(toString, pprc.toString()) ; |
| | | "PasswordPolicyResponseControl(" + warningType + "=" + warningValue + ", " + errorType + ")" ; |
| | | assertEquals(pprc.toString(), toString); |
| | | |
| | | |
| | | // check null value for the control |
| | |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.controls.PersistentSearchChangeType.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.*; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.ldap.SearchScope; |
| | | import org.forgerock.util.Utils; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.ModifyOperation; |
| | | import org.opends.server.protocols.internal.InternalClientConnection; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.api.Assertions.*; |
| | | import static org.opends.server.controls.PersistentSearchChangeType.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | @SuppressWarnings("javadoc") |
| | | public class PersistentSearchControlTest extends ControlsTestCase |
| | | { |
| | |
| | | { |
| | | Set<Integer> keys = exceptedValues.keySet() ; |
| | | |
| | | Set<PersistentSearchChangeType> returnTypes; |
| | | Set<PersistentSearchChangeType> expectedTypes = |
| | | new HashSet<PersistentSearchChangeType>(4); |
| | | |
| | |
| | | expectedTypes.add(PersistentSearchChangeType.valueOf(key)); |
| | | } |
| | | } |
| | | returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | Set<PersistentSearchChangeType> returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | assertEquals(expectedTypes.size(), returnTypes.size()); |
| | | for (PersistentSearchChangeType type: expectedTypes) |
| | | { |
| | |
| | | public void checkTypesToIntTest(Map<Integer, String> exceptedValues) |
| | | throws Exception |
| | | { |
| | | Set<PersistentSearchChangeType> returnTypes; |
| | | for (int i = 1; i <= 15; i++) |
| | | { |
| | | returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | Set<PersistentSearchChangeType> returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | int ret = PersistentSearchChangeType.changeTypesToInt(returnTypes); |
| | | assertEquals(ret, i); |
| | | } |
| | |
| | | public void checkChangeTypesToStringTest(Map<Integer, String> exceptedValues) |
| | | throws Exception |
| | | { |
| | | Set<PersistentSearchChangeType> returnTypes; |
| | | for (int i = 1; i <= 15; i++) |
| | | { |
| | | returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | Set<PersistentSearchChangeType> returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | String ret = PersistentSearchChangeType.changeTypesToString(returnTypes); |
| | | String exceptedRet = null ; |
| | | for (PersistentSearchChangeType type : returnTypes) |
| | | { |
| | | if (exceptedRet == null) |
| | | { |
| | | exceptedRet = type.toString(); |
| | | } |
| | | else |
| | | { |
| | | exceptedRet = exceptedRet + "|" + type.toString(); |
| | | } |
| | | } |
| | | assertEquals(ret, exceptedRet); |
| | | assertEquals(ret, Utils.joinAsString("|", returnTypes)); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | // Test constructor |
| | | // CheclPersistentSearchControlTest(Set<PersistentSearchChangeType> |
| | | // changeTypes, |
| | | // boolean changesOnly, boolean returnECs |
| | | Set<PersistentSearchChangeType> returnTypes; |
| | | // changeTypes, boolean changesOnly, boolean returnECs |
| | | for (int i = 1; i <= 15; i++) |
| | | { |
| | | returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | PersistentSearchControl psc = new PersistentSearchControl(returnTypes, |
| | | changesOnly, returnECs); |
| | | Set<PersistentSearchChangeType> returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | PersistentSearchControl psc = new PersistentSearchControl(returnTypes, changesOnly, returnECs); |
| | | assertNotNull(psc); |
| | | assertEquals(changesOnly, psc.getChangesOnly()); |
| | | assertEquals(returnECs, psc.getReturnECs()); |
| | |
| | | // boolean changesOnly, boolean returnECs |
| | | for (int i = 1; i <= 15; i++) |
| | | { |
| | | returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | Set<PersistentSearchChangeType> returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | PersistentSearchControl psc = new PersistentSearchControl( |
| | | isCritical, returnTypes, changesOnly, returnECs); |
| | | assertNotNull(psc); |
| | |
| | | for (int i = 1; i <= 15; i++) |
| | | { |
| | | bsb.clear(); |
| | | returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | Set<PersistentSearchChangeType> returnTypes = PersistentSearchChangeType.intToTypes(i); |
| | | PersistentSearchControl psc = new PersistentSearchControl( |
| | | isCritical, returnTypes, changesOnly, returnECs); |
| | | psc.write(writer); |
| | |
| | | lines.add("objectClass: ds-cfg-memory-backend"); |
| | | lines.add("ds-cfg-backend-id: " + backendID); |
| | | lines.add("ds-cfg-java-class: org.opends.server.backends.MemoryBackend"); |
| | | lines.add("ds-cfg-enabled: " + String.valueOf(enabled)); |
| | | lines.add("ds-cfg-enabled: " + enabled); |
| | | lines.add("ds-cfg-writability-mode: enabled"); |
| | | |
| | | for (DN dn : baseDNs) |
| | | { |
| | | lines.add("ds-cfg-base-dn: " + dn.toString()); |
| | | lines.add("ds-cfg-base-dn: " + dn); |
| | | } |
| | | |
| | | String[] lineArray = new String[lines.size()]; |
| | |
| | | Entry oldEntry = configHandler.getEntry(DN_CORE_SCHEMA); |
| | | |
| | | configHandler.replaceEntry(oldEntry, |
| | | new LinkedHashMapEntry("dn: " + DN_CORE_SCHEMA.toString(), |
| | | new LinkedHashMapEntry("dn: " + DN_CORE_SCHEMA, |
| | | "objectclass: ds-cfg-schema-provider", |
| | | "ds-cfg-enabled: false")); |
| | | |
| | |
| | | Entry oldEntry = configHandler.getEntry(DN_CORE_SCHEMA); |
| | | |
| | | configHandler.replaceEntry(oldEntry, |
| | | new LinkedHashMapEntry("dn: " + DN_CORE_SCHEMA.toString(), |
| | | new LinkedHashMapEntry("dn: " + DN_CORE_SCHEMA, |
| | | "objectclass: ds-cfg-schema-provider", |
| | | "ds-cfg-enabled: false")); |
| | | } |
| | |
| | | Entry oldEntry = configHandler.getEntry(DN_CORE_SCHEMA); |
| | | |
| | | configHandler.replaceEntry(oldEntry, |
| | | new LinkedHashMapEntry("dn: " + DN_CORE_SCHEMA.toString(), |
| | | new LinkedHashMapEntry("dn: " + DN_CORE_SCHEMA, |
| | | "objectclass: ds-cfg-schema-provider", |
| | | "ds-cfg-enabled: false")); |
| | | } |
| | |
| | | } |
| | | |
| | | assertTrue(match, |
| | | EOL + "Expected order: " + expectedOrder.toString() + EOL + |
| | | "Actual order: " + actualOrder.toString()); |
| | | EOL + "Expected order: " + expectedOrder + EOL + |
| | | "Actual order: " + actualOrder); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2013-2014 ForgeRock AS. |
| | | * Portions Copyright 2013-2015 ForgeRock AS. |
| | | */ |
| | | package org.opends.server.extensions; |
| | | |
| | | |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.admin.std.server.EntryCacheCfg; |
| | | import org.opends.server.api.Backend; |
| | | import org.opends.server.api.EntryCache; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.admin.std.server.EntryCacheCfg; |
| | | import org.opends.server.util.ServerConstants; |
| | | |
| | | import static org.testng.Assert.*; |
| | | import org.testng.annotations.AfterClass; |
| | | |
| | | |
| | | /** |
| | | * A common set of test cases for all entry cache implementations. |
| | | * @param <C> The type of entry cache configuration. |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | assertFalse(cache.containsEntry(testEntriesList.get(0).getName()), |
| | | "Not expected to find " + testEntriesList.get(0).getName() + |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | assertNull(cache.getEntry(testEntriesList.get(0).getName()), |
| | | "Not expected to find " + testEntriesList.get(0).getName() + |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | assertNull(cache.getEntry(testEntriesList.get(0).getName()), |
| | | "Not expected to find " + testEntriesList.get(0).getName() + |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | assertNull(cache.getEntry(b, -1), |
| | | "Not expected to find entry id " + Integer.toString(-1) + |
| | | "Not expected to find entry id " + -1 + |
| | | " in the cache. Cache contents:" + ServerConstants.EOL + |
| | | cache.toVerboseString()); |
| | | |
| | | cache.putEntry(testEntriesList.get(0), b, 1); |
| | | |
| | | assertNotNull(cache.getEntry(b, 1), |
| | | "Expected to find entry id " + Integer.toString(1) + |
| | | "Expected to find entry id " + 1 + |
| | | " in the cache. Cache contents:" + ServerConstants.EOL + |
| | | cache.toVerboseString()); |
| | | |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | assertEquals(cache.getEntryID(testEntriesList.get(0).getName()), -1, |
| | | "Not expected to find " + testEntriesList.get(0).getName() + |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | cache.putEntry(testEntriesList.get(0), b, 1); |
| | | |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | assertNotNull(cache.getEntry(b, 1), |
| | | "Expected to find entry id " + Integer.toString(-1) + |
| | | "Expected to find entry id " + -1 + |
| | | " in the cache. Cache contents:" + ServerConstants.EOL + |
| | | cache.toVerboseString()); |
| | | |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | assertTrue(cache.putEntryIfAbsent(testEntriesList.get(0), b, 1), |
| | | "Not expected to find " + testEntriesList.get(0).getName() + |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | assertNotNull(cache.getEntry(b, 1), |
| | | "Expected to find entry id " + Integer.toString(-1) + |
| | | "Expected to find entry id " + -1 + |
| | | " in the cache. Cache contents:" + ServerConstants.EOL + |
| | | cache.toVerboseString()); |
| | | |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | cache.removeEntry(testEntriesList.get(0).getName()); |
| | | cache.putEntry(testEntriesList.get(0), b, 1); |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | assertNull(cache.getEntry(b, 1), |
| | | "Not expected to find entry id " + Integer.toString(-1) + |
| | | "Not expected to find entry id " + -1 + |
| | | " in the cache. Cache contents:" + ServerConstants.EOL + |
| | | cache.toVerboseString()); |
| | | |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | cache.clear(); |
| | | cache.putEntry(testEntriesList.get(0), b, 1); |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | assertNull(cache.getEntry(b, 1), |
| | | "Not expected to find entry id " + Integer.toString(-1) + |
| | | "Not expected to find entry id " + -1 + |
| | | " in the cache. Cache contents:" + ServerConstants.EOL + |
| | | cache.toVerboseString()); |
| | | |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend c = DirectoryServer.getBackend(DN.valueOf("cn=config")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> c = DirectoryServer.getBackend(DN.valueOf("cn=config")); |
| | | |
| | | cache.clearBackend(b); |
| | | cache.putEntry(testEntriesList.get(0), b, 1); |
| | |
| | | cache.clearBackend(b); |
| | | |
| | | assertNull(cache.getEntry(b, 1), |
| | | "Not expected to find entry id " + Integer.toString(1) + " on backend " + |
| | | "Not expected to find entry id " + 1 + " on backend " + |
| | | b.getBackendID() + " in the cache. Cache contents:" + |
| | | ServerConstants.EOL + cache.toVerboseString()); |
| | | |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | assertNotNull(cache.getEntry(c, 1), |
| | | "Expected to find entry id " + Integer.toString(1) + " on backend " + |
| | | "Expected to find entry id " + 1 + " on backend " + |
| | | c.getBackendID() + " in the cache. Cache contents:" + |
| | | ServerConstants.EOL + cache.toVerboseString()); |
| | | |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend c = DirectoryServer.getBackend(DN.valueOf("cn=config")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> c = DirectoryServer.getBackend(DN.valueOf("cn=config")); |
| | | |
| | | cache.putEntry(testEntriesList.get(0), b, 1); |
| | | Entry testEntry = testEntriesList.get(1); |
| | |
| | | cache.toVerboseString()); |
| | | |
| | | assertNull(cache.getEntry(b, 1), |
| | | "Not expected to find entry id " + Integer.toString(-1) + |
| | | "Not expected to find entry id " + -1 + |
| | | " in the cache. Cache contents:" + ServerConstants.EOL + |
| | | cache.toVerboseString()); |
| | | |
| | | assertNotNull(cache.getEntry(testEntry.getName()), |
| | | "Expected to find " + testEntry.getName().toString() + |
| | | "Expected to find " + testEntry.getName() + |
| | | " in the cache. Cache contents:" + ServerConstants.EOL + |
| | | cache.toVerboseString()); |
| | | |
| | |
| | | public void testCacheConcurrency() |
| | | throws Exception |
| | | { |
| | | Backend b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | Backend<?> b = DirectoryServer.getBackend(DN.valueOf("o=test")); |
| | | |
| | | for(int loops = 0; loops < CONCURRENCYLOOPS; loops++) { |
| | | for(int i = 0; i < NUMTESTENTRIES; i++) { |
| | |
| | | |
| | | // Check for registered short circuits. |
| | | Integer resultCode = shortCircuits.get( |
| | | operation.getOperationType().toString() + "/" + section.toLowerCase()); |
| | | operation.getOperationType() + "/" + section.toLowerCase()); |
| | | if (resultCode != null) |
| | | { |
| | | return resultCode; |
| | |
| | | * @param section The plugin point the short circuit applies to. |
| | | * @param resultCode The result code to be returned for the short circuit. |
| | | */ |
| | | public static void registerShortCircuit(OperationType operation, |
| | | String section, int resultCode) |
| | | public static void registerShortCircuit(OperationType operation, String section, int resultCode) |
| | | { |
| | | shortCircuits.put(operation.toString() + "/" + section.toLowerCase(), |
| | | resultCode); |
| | | shortCircuits.put(operation + "/" + section.toLowerCase(), resultCode); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param operation The type of operation the short circuit applies to. |
| | | * @param section The plugin point the short circuit applies to. |
| | | */ |
| | | public static void deregisterShortCircuit(OperationType operation, |
| | | String section) |
| | | public static void deregisterShortCircuit(OperationType operation, String section) |
| | | { |
| | | shortCircuits.remove(operation.toString() + "/" + section.toLowerCase()); |
| | | shortCircuits.remove(operation + "/" + section.toLowerCase()); |
| | | } |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import org.forgerock.opendj.io.*; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import static org.opends.server.util.ServerConstants.EOL; |
| | | |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.types.*; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import org.testng.annotations.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | | import org.forgerock.opendj.io.ASN1Reader; |
| | | import org.forgerock.opendj.io.ASN1Writer; |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.ByteStringBuilder; |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | ArrayList<String> referralURLs = new ArrayList<String>(); |
| | | referralURLs.add("ds1.example.com"); |
| | | referralURLs.add("ds2.example.com"); |
| | | referralURLs.add("ds3.example.com"); |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | addResponse = new AddResponseProtocolOp(resultCode, resultMsg, dn, |
| | | referralURLs); |
| | | addResponse = new AddResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | addResponse.toString(buffer); |
| | | |
| | | key.append("AddResponse(resultCode="+resultCode+", " + |
| | | "errorMessage="+resultMsg+", matchedDN="+dn.toString()+", " + |
| | | "referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | key.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | key.append(", "); |
| | | key.append(iterator.next()); |
| | | } |
| | | |
| | | key.append("AddResponse(resultCode=" + resultCode |
| | | + ", " + "errorMessage=" + resultMsg + ", matchedDN=" + dn + ", " |
| | | + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | } |
| | | |
| | | static void join(StringBuilder sb, List<String> referralURLs) |
| | | { |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | sb.append(iterator.next()); |
| | | while (iterator.hasNext()) |
| | | { |
| | | sb.append(", "); |
| | | sb.append(iterator.next()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Test the toString (multi line) method. |
| | | * |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.ldap.TestAddResponseProtocolOp.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | referralURLs); |
| | | compareResponse.toString(buffer); |
| | | |
| | | key.append("CompareResponse(resultCode="+resultCode+", " + |
| | | "errorMessage="+resultMsg+", matchedDN="+dn.toString()+", " + |
| | | "referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | key.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | key.append(", "); |
| | | key.append(iterator.next()); |
| | | } |
| | | |
| | | key.append("CompareResponse(resultCode=" + resultCode + ", " |
| | | + "errorMessage=" + resultMsg + ", matchedDN=" + dn |
| | | + ", " + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | |
| | | ByteStringBuilder builder = new ByteStringBuilder(); |
| | | ASN1Writer writer = ASN1.getWriter(builder); |
| | | DeleteRequestProtocolOp deleteEncoded; |
| | | DeleteRequestProtocolOp deleteDecoded; |
| | | |
| | | deleteEncoded = new DeleteRequestProtocolOp(null); |
| | | deleteEncoded.write(writer); |
| | | ASN1Reader reader = ASN1.getReader(builder.toByteString()); |
| | | deleteDecoded = (DeleteRequestProtocolOp)LDAPReader.readProtocolOp(reader); |
| | | LDAPReader.readProtocolOp(reader); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void TestToStringSingleLine() throws Exception |
| | | { |
| | | DeleteRequestProtocolOp deleteRequest = new DeleteRequestProtocolOp(dn); |
| | | StringBuilder buffer = new StringBuilder(); |
| | | |
| | | String expectedStr = "DeleteRequest(dn=" + dn.toString() + ")"; |
| | | deleteRequest.toString(buffer); |
| | | |
| | | assertEquals(buffer.toString(), expectedStr); |
| | | assertEquals(deleteRequest.toString(), "DeleteRequest(dn=" + dn + ")"); |
| | | } |
| | | |
| | | /** |
| | |
| | | public void TestToStringMultiLine() throws Exception |
| | | { |
| | | DeleteRequestProtocolOp deleteRequest = new DeleteRequestProtocolOp(dn); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | |
| | | String expectedStr = " Delete Request" + |
| | | EOL + " Entry DN: " + |
| | | dn.toString() + |
| | | EOL; |
| | | deleteRequest.toString(buffer, 3); |
| | | |
| | | assertEquals(buffer.toString(), expectedStr); |
| | | assertEquals(buffer.toString(), |
| | | " Delete Request" + EOL |
| | | + " Entry DN: " + dn + EOL); |
| | | } |
| | | } |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.ldap.TestAddResponseProtocolOp.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | ArrayList<String> referralURLs = new ArrayList<String>(); |
| | | referralURLs.add("ds1.example.com"); |
| | | referralURLs.add("ds2.example.com"); |
| | | referralURLs.add("ds3.example.com"); |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | deleteResponse = new DeleteResponseProtocolOp(resultCode, resultMsg, dn, |
| | | referralURLs); |
| | | deleteResponse = new DeleteResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | deleteResponse.toString(buffer); |
| | | |
| | | key.append("DeleteResponse(resultCode="+resultCode+", " + |
| | | "errorMessage="+resultMsg+", matchedDN="+dn.toString()+", " + |
| | | "referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | key.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | key.append(", "); |
| | | key.append(iterator.next()); |
| | | } |
| | | |
| | | key.append("})"); |
| | | |
| | | key.append("DeleteResponse(resultCode=" + resultCode + ", " |
| | | + "errorMessage=" + resultMsg + ", matchedDN=" + dn |
| | | + ", " + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | assertEquals(buffer.toString(), key.toString()); |
| | | } |
| | | |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import static org.opends.server.protocols.ldap.TestAddResponseProtocolOp.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | |
| | | import org.opends.server.DirectoryServerTestCase; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.AttributeType; |
| | | import org.opends.server.types.DN; |
| | | import org.opends.server.types.LDAPException; |
| | | import org.opends.server.types.RDN; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * This class defines a set of tests for the |
| | | * org.opends.server.protocol.ldap.ModifyDNResponseProtocolOp class. |
| | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | ArrayList<String> referralURLs = new ArrayList<String>(); |
| | | referralURLs.add("ds1.example.com"); |
| | | referralURLs.add("ds2.example.com"); |
| | | referralURLs.add("ds3.example.com"); |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | modifyResponse = new ModifyDNResponseProtocolOp(resultCode, resultMsg, dn, |
| | | referralURLs); |
| | | modifyResponse = new ModifyDNResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | modifyResponse.toString(buffer); |
| | | |
| | | key.append("ModifyDNResponse(resultCode="+resultCode+", " + |
| | | "errorMessage="+resultMsg+", matchedDN="+dn.toString()+", " + |
| | | "referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | key.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | key.append(", "); |
| | | key.append(iterator.next()); |
| | | } |
| | | |
| | | key.append("ModifyDNResponse(resultCode=" + resultCode + ", " |
| | | + "errorMessage=" + resultMsg + ", matchedDN=" + dn + ", " |
| | | + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.protocols.ldap; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.opendj.io.ASN1; |
| | |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.opends.server.protocols.ldap.TestAddResponseProtocolOp.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | StringBuilder key = new StringBuilder(); |
| | | |
| | | ArrayList<String> referralURLs = new ArrayList<String>(); |
| | | referralURLs.add("ds1.example.com"); |
| | | referralURLs.add("ds2.example.com"); |
| | | referralURLs.add("ds3.example.com"); |
| | | List<String> referralURLs = Arrays.asList( |
| | | "ds1.example.com", |
| | | "ds2.example.com", |
| | | "ds3.example.com"); |
| | | |
| | | modifyResponse = new ModifyResponseProtocolOp(resultCode, resultMsg, dn, |
| | | referralURLs); |
| | | modifyResponse = new ModifyResponseProtocolOp(resultCode, resultMsg, dn, referralURLs); |
| | | modifyResponse.toString(buffer); |
| | | |
| | | key.append("ModifyResponse(resultCode="+resultCode+", " + |
| | | "errorMessage="+resultMsg+", matchedDN="+dn.toString()+", " + |
| | | "referralURLs={"); |
| | | |
| | | Iterator<String> iterator = referralURLs.iterator(); |
| | | key.append(iterator.next()); |
| | | |
| | | while (iterator.hasNext()) |
| | | { |
| | | key.append(", "); |
| | | key.append(iterator.next()); |
| | | } |
| | | |
| | | key.append("ModifyResponse(resultCode=" + resultCode + ", " |
| | | + "errorMessage=" + resultMsg + ", matchedDN=" + dn |
| | | + ", " + "referralURLs={"); |
| | | join(key, referralURLs); |
| | | key.append("})"); |
| | | |
| | | assertEquals(buffer.toString(), key.toString()); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication; |
| | | |
| | |
| | | */ |
| | | Entry resultEntry = getEntry(personWithUUIDEntry.getName(), 10000, true); |
| | | assertNotNull(resultEntry, |
| | | "The send ADD replication message was not applied for "+personWithUUIDEntry.getName().toString()); |
| | | "The send ADD replication message was not applied for "+personWithUUIDEntry.getName()); |
| | | |
| | | /* |
| | | * Test the reception of Modify Msg |
| | |
| | | * |
| | | * |
| | | * Copyright 2009-2010 Sun Microsystems, Inc. |
| | | * Portions Copyright 2011-2014 ForgeRock AS |
| | | * Portions Copyright 2011-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | |
| | | assertNotNull(attrValue); |
| | | assertFalse(attrValues.hasNext()); |
| | | assertEquals(attrValue.toString(), attributeValue, "Was expecting attribute " + |
| | | attributeName + "=" + attributeValue + " but got value: " + attrValue.toString()); |
| | | attributeName + "=" + attributeValue + " but got value: " + attrValue); |
| | | |
| | | } |
| | | |
| | |
| | | @Test |
| | | public void entryMsgTest() throws Exception |
| | | { |
| | | String taskInitFromS2 = new String( |
| | | String taskInitFromS2 = |
| | | "dn: ds-task-id=" + UUID.randomUUID() + |
| | | ",cn=Scheduled Tasks,cn=Tasks\n" + |
| | | "objectclass: top\n" + |
| | |
| | | "objectclass: ds-task-initialize\n" + |
| | | "ds-task-class-name: org.opends.server.replication.api.InitializeTask\n" + |
| | | "ds-task-initialize-domain-dn: " + TEST_ROOT_DN_STRING + "\n" + |
| | | "ds-task-initialize-source: 1\n"); |
| | | "ds-task-initialize-source: 1\n"; |
| | | int sender = 1; |
| | | int target = 45678; |
| | | byte[] entry = taskInitFromS2.getBytes(); |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2014 ForgeRock AS |
| | | * Portions Copyright 2014-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.schema; |
| | | |
| | |
| | | |
| | | return new Object[] { |
| | | AUTH_PASSWORD_SCHEME_NAME_SALTED_MD5 + "$" |
| | | + authPWComponents[1].toString() |
| | | + "$"+ authPWComponents[2].toString(), |
| | | + authPWComponents[1] |
| | | + "$"+ authPWComponents[2], |
| | | password, true}; |
| | | } |
| | | |
| | |
| | | DN taskDN = DN.valueOf("ds-task-id=" + taskID + |
| | | ",cn=Scheduled Tasks,cn=Tasks"); |
| | | TestCaseUtils.addEntry( |
| | | "dn: " + taskDN.toString(), |
| | | "dn: " + taskDN, |
| | | "objectClass: top", |
| | | "objectClass: ds-task", |
| | | "objectClass: ds-task-disconnect", |
| | |
| | | DN taskDN = DN.valueOf("ds-task-id=" + taskID + |
| | | ",cn=Scheduled Tasks,cn=Tasks"); |
| | | TestCaseUtils.addEntry( |
| | | "dn: " + taskDN.toString(), |
| | | "dn: " + taskDN, |
| | | "objectClass: top", |
| | | "objectClass: ds-task", |
| | | "objectClass: ds-task-disconnect", |
| | |
| | | |
| | | DirectoryServer.setSingleStructuralObjectClassPolicy(WARN); |
| | | assertTrue(e.conformsToSchema(null, false, true, true, invalidReason), |
| | | "Entry validation failed with WARN policy: " + |
| | | invalidReason.toString()); |
| | | "Entry validation failed with WARN policy: " + invalidReason); |
| | | |
| | | DirectoryServer.setSingleStructuralObjectClassPolicy(ACCEPT); |
| | | assertTrue(e.conformsToSchema(null, false, true, true, invalidReason), |
| | | "Entry validation failed with ACCEPT policy: " + |
| | | invalidReason.toString()); |
| | | "Entry validation failed with ACCEPT policy: " + invalidReason); |
| | | } |
| | | finally |
| | | { |
| | |
| | | * |
| | | * |
| | | * Copyright 2006-2008 Sun Microsystems, Inc. |
| | | * Portions Copyright 2012-2014 ForgeRock AS |
| | | * Portions Copyright 2012-2015 ForgeRock AS |
| | | */ |
| | | package org.opends.server.util; |
| | | |
| | |
| | | actualLine = reader.readLine(); |
| | | } |
| | | |
| | | if (failed) { |
| | | Assert.fail("expected:\n" + expected.toString() + "\nbut was:\n" |
| | | + actual.toString()); |
| | | } |
| | | Assert.assertFalse(failed, "expected:\n" + expected + "\nbut was:\n" + actual); |
| | | } |
| | | |
| | | /** |