Package org.eclipse.orion.internal.server.core.metastore

Examples of org.eclipse.orion.internal.server.core.metastore.SimpleMetaStoreUserPropertyCache


public class SimpleMetaStoreUserPropertyCacheTests {

  @Test
  public void testAddAllUsers() throws CoreException {
    // create a user property cache for a property
    SimpleMetaStoreUserPropertyCache userPropertyCache = new SimpleMetaStoreUserPropertyCache();
    List<String> propertyKeys = new ArrayList<String>();
    propertyKeys.add(UserConstants2.USER_NAME);
    userPropertyCache.register(propertyKeys);
    assertTrue(userPropertyCache.isRegistered(UserConstants2.USER_NAME));

    // add some users to the cache
    String users[] = {"anthony", "ahunter", "anthonyh"};
    List<String> userList = new ArrayList<String>(Arrays.asList(users));
    userPropertyCache.addUsers(userList);

    // ensure the users are in the cache
    assertEquals("anthony", userPropertyCache.readUserByProperty(UserConstants2.USER_NAME, "anthony", false, false));
    assertEquals("ahunter", userPropertyCache.readUserByProperty(UserConstants2.USER_NAME, "ahunter", false, false));
    assertEquals("anthonyh", userPropertyCache.readUserByProperty(UserConstants2.USER_NAME, "anthonyh", false, false));
    assertNull(userPropertyCache.readUserByProperty(UserConstants2.USER_NAME, "fred", false, false));
  }
View Full Code Here


  }

  @Test
  public void testAddUserProperty() throws CoreException {
    // create a user property cache for a property
    SimpleMetaStoreUserPropertyCache userPropertyCache = new SimpleMetaStoreUserPropertyCache();
    List<String> propertyKeys = new ArrayList<String>();
    propertyKeys.add("property");
    userPropertyCache.register(propertyKeys);
    assertTrue(userPropertyCache.isRegistered("property"));

    // add a property value and ensure it is in the cache
    userPropertyCache.add("property", "value", "user");
    assertEquals("user", userPropertyCache.readUserByProperty("property", "value", false, false));
  }
View Full Code Here

  }

  @Test
  public void testDeleteUser() throws CoreException {
    // create a user property cache for a property
    SimpleMetaStoreUserPropertyCache userPropertyCache = new SimpleMetaStoreUserPropertyCache();
    List<String> propertyKeys = new ArrayList<String>();
    propertyKeys.add("property");
    userPropertyCache.register(propertyKeys);
    assertTrue(userPropertyCache.isRegistered("property"));

    // add a property value and ensure it is in the cache
    userPropertyCache.add("property", "value", "user");
    assertEquals("user", userPropertyCache.readUserByProperty("property", "value", false, false));

    // delete the user and ensure it is no longer in the cache
    userPropertyCache.deleteUser("user");
    assertNull(userPropertyCache.readUserByProperty("property", "value", false, false));
  }
View Full Code Here

  }

  @Test
  public void testDeleteUserProperty() throws CoreException {
    // create a user property cache for a property
    SimpleMetaStoreUserPropertyCache userPropertyCache = new SimpleMetaStoreUserPropertyCache();
    List<String> propertyKeys = new ArrayList<String>();
    propertyKeys.add("property");
    userPropertyCache.register(propertyKeys);
    assertTrue(userPropertyCache.isRegistered("property"));

    // add a property value and ensure it is in the cache
    userPropertyCache.add("property", "value", "user");
    assertEquals("user", userPropertyCache.readUserByProperty("property", "value", false, false));

    // delete the property value and ensure it is no longer in the cache
    userPropertyCache.delete("property", "value", "user");
    assertNull(userPropertyCache.readUserByProperty("property", "value", false, false));
  }
View Full Code Here

    assertNull(userPropertyCache.readUserByProperty("property", "value", false, false));
  }

  @Test
  public void testNoUserProperty() {
    SimpleMetaStoreUserPropertyCache userPropertyCache = new SimpleMetaStoreUserPropertyCache();
    userPropertyCache.add("property", "value", "user");
    try {
      assertNull(userPropertyCache.readUserByProperty("property", "value", false, false));
    } catch (CoreException e) {
      // we expect a core exception since the property is not registered.
      return;
    }
    fail("We expected a core exception since the property is not registered.");
View Full Code Here

  }

  @Test
  public void testUpdateUserProperty() throws CoreException {
    // create a user property cache for a property
    SimpleMetaStoreUserPropertyCache userPropertyCache = new SimpleMetaStoreUserPropertyCache();
    List<String> propertyKeys = new ArrayList<String>();
    propertyKeys.add("property");
    userPropertyCache.register(propertyKeys);
    assertTrue(userPropertyCache.isRegistered("property"));

    // add a property value and ensure it is in the cache
    userPropertyCache.add("property", "value", "user");
    assertEquals("user", userPropertyCache.readUserByProperty("property", "value", false, false));

    // update the property value and ensure it is updated in the cache
    userPropertyCache.add("property", "newvalue", "user");
    assertEquals("user", userPropertyCache.readUserByProperty("property", "newvalue", false, false));
    assertNull(userPropertyCache.readUserByProperty("property", "value", false, false));
  }
View Full Code Here

TOP

Related Classes of org.eclipse.orion.internal.server.core.metastore.SimpleMetaStoreUserPropertyCache

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.