Package org.nasutekds.server.api

Examples of org.nasutekds.server.api.Backend


    assertNull(toVerboseString(),
      "Expected empty cache.  " + "Cache contents:" + ServerConstants.EOL +
      toVerboseString());

    // Preload.
    Backend backend = DirectoryServer.getBackend("cacheTest");
    backend.preloadEntryCache();

    // Check that all test entries are preloaded.
    for(int i = 0; i < NUMTESTENTRIES; i++ ) {
      assertNotNull(DirectoryServer.getEntryCache().getEntry(
        testEntriesList.get(i).getDN()), "Expected to find " +
View Full Code Here


         conn.processAdd(backendEntry.getDN(), backendEntry.getObjectClasses(),
                         backendEntry.getUserAttributes(),
                         backendEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);

    Backend backend = DirectoryServer.getBackend(backendID);
    assertNotNull(backend);
    assertEquals(backend, DirectoryServer.getBackendWithBaseDN(baseDN));
    assertNull(backend.getParentBackend());
    assertTrue(backend.getSubordinateBackends().length == 0);
    assertFalse(backend.entryExists(baseDN));
    assertTrue(DirectoryServer.isNamingContext(baseDN));

    Entry e = createEntry(baseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(backend.entryExists(baseDN));

    DeleteOperation deleteOperation = conn.processDelete(backendEntry.getDN());
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    assertNull(DirectoryServer.getBackend(backendID));
  }
View Full Code Here

        Attributes.create("ds-cfg-enabled", "true")));
    ModifyOperation modifyOperation =
         conn.processModify(backendEntry.getDN(), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);

    Backend backend = DirectoryServer.getBackend(backendID);
    assertNotNull(backend);
    assertEquals(backend, DirectoryServer.getBackendWithBaseDN(baseDN));
    assertNull(backend.getParentBackend());
    assertTrue(backend.getSubordinateBackends().length == 0);
    assertFalse(backend.entryExists(baseDN));
    assertTrue(DirectoryServer.isNamingContext(baseDN));

    Entry e = createEntry(baseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(backend.entryExists(baseDN));


    // Modify the backend to disable it.
    mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
View Full Code Here

                         parentBackendEntry.getObjectClasses(),
                         parentBackendEntry.getUserAttributes(),
                         parentBackendEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);

    Backend parentBackend = DirectoryServer.getBackend(parentBackendID);
    assertNotNull(parentBackend);
    assertEquals(parentBackend,
                 DirectoryServer.getBackendWithBaseDN(parentBaseDN));
    assertNull(parentBackend.getParentBackend());
    assertTrue(parentBackend.getSubordinateBackends().length == 0);
    assertFalse(parentBackend.entryExists(parentBaseDN));
    assertTrue(DirectoryServer.isNamingContext(parentBaseDN));

    Entry e = createEntry(parentBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(parentBackend.entryExists(parentBaseDN));


    // Create the child backend and the corresponding base entry.
    DN childBaseDN = DN.decode("ou=child,o=parent");
    String childBackendID = createBackendID(childBaseDN);
    Entry childBackendEntry = createBackendEntry(childBackendID, true,
                                                 childBaseDN);

    addOperation =
         conn.processAdd(childBackendEntry.getDN(),
                         childBackendEntry.getObjectClasses(),
                         childBackendEntry.getUserAttributes(),
                         childBackendEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);

    Backend childBackend = DirectoryServer.getBackend(childBackendID);
    assertNotNull(childBackend);
    assertEquals(childBackend,
                 DirectoryServer.getBackendWithBaseDN(childBaseDN));
    assertNotNull(childBackend.getParentBackend());
    assertEquals(parentBackend, childBackend.getParentBackend());
    assertTrue(parentBackend.getSubordinateBackends().length == 1);
    assertFalse(childBackend.entryExists(childBaseDN));
    assertFalse(DirectoryServer.isNamingContext(childBaseDN));

    e = createEntry(childBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(childBackend.entryExists(childBaseDN));


    // Make sure that both entries exist.
    InternalSearchOperation internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
View Full Code Here

                         childBackendEntry.getObjectClasses(),
                         childBackendEntry.getUserAttributes(),
                         childBackendEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);

    Backend childBackend = DirectoryServer.getBackend(childBackendID);
    assertNotNull(childBackend);
    assertEquals(childBackend,
                 DirectoryServer.getBackendWithBaseDN(childBaseDN));
    assertFalse(childBackend.entryExists(childBaseDN));
    assertNull(childBackend.getParentBackend());
    assertTrue(childBackend.getSubordinateBackends().length == 0);
    assertFalse(childBackend.entryExists(childBaseDN));

    Entry e = createEntry(childBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(childBackend.entryExists(childBaseDN));
    assertTrue(DirectoryServer.isNamingContext(childBaseDN));


    // Create the parent backend and the corresponding entry (and verify that
    // its DN is now a naming context and the child's is not).
    DN parentBaseDN = DN.decode("o=parent");
    String parentBackendID = createBackendID(parentBaseDN);
    Entry parentBackendEntry = createBackendEntry(parentBackendID, true,
                                                  parentBaseDN);

    addOperation =
         conn.processAdd(parentBackendEntry.getDN(),
                         parentBackendEntry.getObjectClasses(),
                         parentBackendEntry.getUserAttributes(),
                         parentBackendEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);

    Backend parentBackend = DirectoryServer.getBackend(parentBackendID);
    assertNotNull(parentBackend);
    assertEquals(parentBackend,
                 DirectoryServer.getBackendWithBaseDN(parentBaseDN));
    assertNotNull(childBackend.getParentBackend());
    assertEquals(parentBackend, childBackend.getParentBackend());
    assertTrue(parentBackend.getSubordinateBackends().length == 1);

    e = createEntry(parentBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(parentBackend.entryExists(parentBaseDN));
    assertTrue(DirectoryServer.isNamingContext(parentBaseDN));
    assertFalse(DirectoryServer.isNamingContext(childBaseDN));


    // Verify that we can see both entries with a subtree search.
    InternalSearchOperation internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
              SearchFilter.createFilterFromString("(objectClass=*)"));
    assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS);
    assertEquals(internalSearch.getSearchEntries().size(), 2);


    // Delete the backends from the server.
    DeleteOperation deleteOperation =
         conn.processDelete(childBackendEntry.getDN());
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    assertNull(DirectoryServer.getBackend(childBackendID));
    assertTrue(parentBackend.getSubordinateBackends().length == 0);

    deleteOperation = conn.processDelete(parentBackendEntry.getDN());
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    assertNull(DirectoryServer.getBackend(parentBackendID));
  }
View Full Code Here

                         parentBackendEntry.getObjectClasses(),
                         parentBackendEntry.getUserAttributes(),
                         parentBackendEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);

    Backend parentBackend = DirectoryServer.getBackend(parentBackendID);
    assertNotNull(parentBackend);
    assertEquals(parentBackend,
                 DirectoryServer.getBackendWithBaseDN(parentBaseDN));
    assertNull(parentBackend.getParentBackend());
    assertTrue(parentBackend.getSubordinateBackends().length == 0);
    assertFalse(parentBackend.entryExists(parentBaseDN));

    Entry e = createEntry(parentBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(parentBackend.entryExists(parentBaseDN));
    assertTrue(DirectoryServer.isNamingContext(parentBaseDN));


    // Add the grandchild backend to the server.
    DN grandchildBaseDN = DN.decode("ou=grandchild,ou=child,o=parent");
    String grandchildBackendID = createBackendID(grandchildBaseDN);
    Entry grandchildBackendEntry = createBackendEntry(grandchildBackendID, true,
                                                      grandchildBaseDN);

    addOperation =
         conn.processAdd(grandchildBackendEntry.getDN(),
                         grandchildBackendEntry.getObjectClasses(),
                         grandchildBackendEntry.getUserAttributes(),
                         grandchildBackendEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);

    Backend grandchildBackend = DirectoryServer.getBackend(grandchildBackendID);
    assertNotNull(grandchildBackend);
    assertEquals(grandchildBackend,
                 DirectoryServer.getBackendWithBaseDN(grandchildBaseDN));
    assertNotNull(grandchildBackend.getParentBackend());
    assertEquals(grandchildBackend.getParentBackend(), parentBackend);
    assertTrue(parentBackend.getSubordinateBackends().length == 1);
    assertFalse(grandchildBackend.entryExists(grandchildBaseDN));

    // Verify that we can't create the grandchild base entry because its parent
    // doesn't exist.
    e = createEntry(grandchildBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.NO_SUCH_OBJECT);
    assertFalse(grandchildBackend.entryExists(grandchildBaseDN));


    // Add the child backend to the server and create its base entry.
    DN childBaseDN = DN.decode("ou=child,o=parent");
    String childBackendID = createBackendID(childBaseDN);
    Entry childBackendEntry = createBackendEntry(childBackendID, true,
                                                 childBaseDN);

    addOperation =
         conn.processAdd(childBackendEntry.getDN(),
                         childBackendEntry.getObjectClasses(),
                         childBackendEntry.getUserAttributes(),
                         childBackendEntry.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);

    Backend childBackend = DirectoryServer.getBackend(childBackendID);
    assertNotNull(childBackend);
    assertEquals(childBackend,
                 DirectoryServer.getBackendWithBaseDN(childBaseDN));
    assertNotNull(childBackend.getParentBackend());
    assertEquals(parentBackend, childBackend.getParentBackend());
    assertTrue(parentBackend.getSubordinateBackends().length == 1);
    assertFalse(childBackend.entryExists(childBaseDN));
    assertTrue(childBackend.getSubordinateBackends().length == 1);
    assertEquals(childBackend.getSubordinateBackends()[0], grandchildBackend);
    assertEquals(grandchildBackend.getParentBackend(), childBackend);

    e = createEntry(childBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(childBackend.entryExists(childBaseDN));

    // Now we can create the grandchild base entry.
    e = createEntry(grandchildBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(grandchildBackend.entryExists(grandchildBaseDN));


    // Verify that a subtree search can see all three entries.
    InternalSearchOperation internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
              SearchFilter.createFilterFromString("(objectClass=*)"));
    assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS);
    assertEquals(internalSearch.getSearchEntries().size(), 3);


    // Disable the intermediate (child) backend.  This should be allowed.
    ArrayList<Modification> mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
        Attributes.create("ds-cfg-enabled",
                                            "false")));
    ModifyOperation modifyOperation =
         conn.processModify(childBackendEntry.getDN(), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);


    // Make sure that we now only see two entries with the subtree search
    // (and those two entries should be the parent and grandchild base entries).
    internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
              SearchFilter.createFilterFromString("(objectClass=*)"));
    assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS);
    assertEquals(internalSearch.getSearchEntries().size(), 2);


    // Re-enable the intermediate backend.
    mods = new ArrayList<Modification>();
    mods.add(new Modification(ModificationType.REPLACE,
        Attributes.create("ds-cfg-enabled", "true")));
    modifyOperation = conn.processModify(childBackendEntry.getDN(), mods);
    assertEquals(modifyOperation.getResultCode(), ResultCode.SUCCESS);


    // Update our reference to the child backend since the old one is no longer
    // valid, and make sure that it got re-inserted back into the same place in
    // the hierarchy.
    childBackend = DirectoryServer.getBackend(childBackendID);
    assertNotNull(childBackend);
    assertEquals(childBackend,
                 DirectoryServer.getBackendWithBaseDN(childBaseDN));
    assertNotNull(childBackend.getParentBackend());
    assertEquals(parentBackend, childBackend.getParentBackend());
    assertTrue(parentBackend.getSubordinateBackends().length == 1);
    assertFalse(childBackend.entryExists(childBaseDN));
    assertTrue(childBackend.getSubordinateBackends().length == 1);
    assertEquals(childBackend.getSubordinateBackends()[0], grandchildBackend);
    assertEquals(grandchildBackend.getParentBackend(), childBackend);


    // Since the memory backend that we're using for this test doesn't retain
    // entries across stops and restarts, a subtree search below the parent
    // should still only return two entries, which means that it's going through
    // the entire chain of backends.
    internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
              SearchFilter.createFilterFromString("(objectClass=*)"));
    assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS);
    assertEquals(internalSearch.getSearchEntries().size(), 2);


    // Add the child entry back into the server to get things back to the way
    // they were before we disabled the backend.
    e = createEntry(childBaseDN);
    addOperation = conn.processAdd(e.getDN(), e.getObjectClasses(),
                                   e.getUserAttributes(),
                                   e.getOperationalAttributes());
    assertEquals(addOperation.getResultCode(), ResultCode.SUCCESS);
    assertTrue(childBackend.entryExists(childBaseDN));


    // We should again be able to see all three entries when performing a
    // search.
    internalSearch =
         conn.processSearch(parentBaseDN, SearchScope.WHOLE_SUBTREE,
              SearchFilter.createFilterFromString("(objectClass=*)"));
    assertEquals(internalSearch.getResultCode(), ResultCode.SUCCESS);
    assertEquals(internalSearch.getSearchEntries().size(), 3);


    // Get rid of the entries in the proper order.
    DeleteOperation deleteOperation =
         conn.processDelete(grandchildBackendEntry.getDN());
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    assertNull(DirectoryServer.getBackend(grandchildBackendID));
    assertTrue(childBackend.getSubordinateBackends().length == 0);
    assertTrue(parentBackend.getSubordinateBackends().length == 1);

    deleteOperation = conn.processDelete(childBackendEntry.getDN());
    assertEquals(deleteOperation.getResultCode(), ResultCode.SUCCESS);
    assertNull(DirectoryServer.getBackend(childBackendID));
View Full Code Here

      debugInfo(tn, "publishes:" + delMsg1);

      // Initialize a second test backend o=test2, in addtion to o=test
      // Configure replication on this backend
      // Add the root entry in the backend
      Backend backend2 = initializeTestBackend(false, TEST_ROOT_DN_STRING2,
          TEST_BACKEND_ID2);
      backend2.setPrivateBackend(true);
      DN baseDn2 = DN.decode(TEST_ROOT_DN_STRING2);
      SortedSet<String> replServers = new TreeSet<String>();
      replServers.add("localhost:"+replicationServerPort);
     
      DomainFakeCfg domainConf =
View Full Code Here

    debugInfo(tn, "Starting test");

    try
    {
      // Initialize a second test backend
      Backend backend2 = initializeTestBackend(true,
          TEST_ROOT_DN_STRING2, TEST_BACKEND_ID2);

      //
      LDIFWriter ldifWriter = getLDIFWriter();
View Full Code Here

    debugInfo(tn, "Starting test");

    try
    {
      // Initialize a second test backend
      Backend backend2 = initializeTestBackend(true, TEST_ROOT_DN_STRING2,
          TEST_BACKEND_ID2);

      // --
      ReplicationBroker s1test = openReplicationSession(
          DN.decode(TEST_ROOT_DN_STRING)1201,
View Full Code Here

   */
  private void ECLIncludeAttributes()
  {
    String tn = "ECLIncludeAttributes";
    debugInfo(tn, "Starting test\n\n");
    Backend backend2 = null;
    Backend backend3 = null;
    DeleteOperationBasis delOp =null;
    LDAPReplicationDomain domain2 = null;
    LDAPReplicationDomain domain3 = null;
    LDAPReplicationDomain domain21 = null;
    DN baseDn2 = null;
View Full Code Here

TOP

Related Classes of org.nasutekds.server.api.Backend

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.