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

Examples of org.eclipse.orion.server.core.metastore.IMetaStore


  }

  @Test
  public void testReadWorkspaceSpecifyNullWorkspaceId() throws CoreException {
    // create the MetaStore
    IMetaStore metaStore = OrionConfiguration.getMetaStore();

    // read the workspace that does not exist
    WorkspaceInfo readWorkspaceInfo = metaStore.readWorkspace(null);
    assertNull(readWorkspaceInfo);
  }
View Full Code Here


  }

  @Test
  public void testReadWorkspaceThatDoesNotExist() throws CoreException {
    // create the MetaStore
    IMetaStore metaStore = OrionConfiguration.getMetaStore();

    // create the user
    UserInfo userInfo = new UserInfo();
    userInfo.setUserName(testUserLogin);
    userInfo.setFullName(testUserLogin);
    metaStore.createUser(userInfo);

    // create the workspace
    String workspaceName1 = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    WorkspaceInfo workspaceInfo1 = new WorkspaceInfo();
    workspaceInfo1.setFullName(workspaceName1);
    workspaceInfo1.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo1);

    // read the workspace that does not exist
    WorkspaceInfo readWorkspaceInfo = metaStore.readWorkspace("anthony-Workspace77");
    assertNull(readWorkspaceInfo);
  }
View Full Code Here

  }

  @Test
  public void testUpdateProject() throws URISyntaxException, CoreException {
    // create the MetaStore
    IMetaStore metaStore = OrionConfiguration.getMetaStore();

    // create the user
    UserInfo userInfo = new UserInfo();
    userInfo.setUserName(testUserLogin);
    userInfo.setFullName(testUserLogin);
    metaStore.createUser(userInfo);

    // create the workspace
    String workspaceName = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    WorkspaceInfo workspaceInfo = new WorkspaceInfo();
    workspaceInfo.setFullName(workspaceName);
    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // create the project
    String projectName = "Orion Project";
    ProjectInfo projectInfo = new ProjectInfo();
    projectInfo.setFullName(projectName);
    try {
      projectInfo.setContentLocation(new URI("file:/home/anthony/orion/project"));
    } catch (URISyntaxException e) {
      // should not get an exception here, simple URI
    }
    projectInfo.setWorkspaceId(workspaceInfo.getUniqueId());
    metaStore.createProject(projectInfo);

    // update the project
    URI newURI = new URI("file:/workspace/foo");
    projectInfo.setContentLocation(newURI);
    projectInfo.setProperty("New", "Property");

    // update the project
    metaStore.updateProject(projectInfo);

    // read the project back again
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceInfo.getUniqueId(), projectInfo.getFullName());
    assertNotNull(readProjectInfo);
    assertTrue(readProjectInfo.getContentLocation().equals(newURI));
    assertEquals(readProjectInfo.getProperty("New"), "Property");
  }
View Full Code Here

  }

  @Test
  public void testUpdateUser() throws CoreException {
    // create the MetaStore
    IMetaStore metaStore = OrionConfiguration.getMetaStore();

    // create the user
    UserInfo userInfo = new UserInfo();
    userInfo.setUserName(testUserLogin);
    userInfo.setFullName(testUserLogin);
    metaStore.createUser(userInfo);

    // update the UserInfo
    String fullName = "Anthony Hunter";
    userInfo.setProperty("New", "Property");
    userInfo.setFullName(fullName);

    // update the user
    metaStore.updateUser(userInfo);

    // read the user back again
    UserInfo readUserInfo = metaStore.readUser(userInfo.getUniqueId());
    assertNotNull(readUserInfo);
    assertEquals(readUserInfo.getFullName(), fullName);
    assertEquals(readUserInfo.getFullName(), userInfo.getFullName());
    assertEquals(readUserInfo.getProperty("New"), "Property");

    // delete the user
    metaStore.deleteUser(userInfo.getUniqueId());
    List<String> allUsers = metaStore.readAllUsers();
    assertFalse(allUsers.contains(userInfo.getUniqueId()));
  }
View Full Code Here

  }

  @Test
  public void testUpdateWorkspace() throws CoreException {
    // create the MetaStore
    IMetaStore metaStore = OrionConfiguration.getMetaStore();

    // create the user
    UserInfo userInfo = new UserInfo();
    userInfo.setUserName(testUserLogin);
    userInfo.setFullName(testUserLogin);
    metaStore.createUser(userInfo);

    // create the workspace
    String workspaceName = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    WorkspaceInfo workspaceInfo = new WorkspaceInfo();
    workspaceInfo.setFullName(workspaceName);
    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // update the workspace
    workspaceInfo.setProperty("New", "Property");
    metaStore.updateWorkspace(workspaceInfo);

    // read the workspace back again
    WorkspaceInfo readWorkspaceInfo = metaStore.readWorkspace(workspaceInfo.getUniqueId());
    assertNotNull(readWorkspaceInfo);
    assertEquals(readWorkspaceInfo.getProperty("New"), "Property");
  }
View Full Code Here

import org.eclipse.orion.server.core.metastore.WorkspaceInfo;
import org.junit.Test;

public class MetaStoreTest extends AbstractServerTest {
  private WorkspaceInfo createWorkspace() throws CoreException {
    IMetaStore store = getMetaStore();
    UserInfo user = new UserInfo();
    user.setUserName("MetaStoreTestUser");
    store.createUser(user);
    WorkspaceInfo workspace = new WorkspaceInfo();
    workspace.setFullName(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
    workspace.setUserId(user.getUniqueId());
    store.createWorkspace(workspace);
    return workspace;
  }
View Full Code Here

    return OrionConfiguration.getMetaStore();
  }

  @Test
  public void testCreateUser() throws CoreException {
    IMetaStore store = getMetaStore();
    UserInfo user = new UserInfo();
    user.setUserName("testCreateUser");
    store.createUser(user);
    assertNotNull(user.getUniqueId());
  }
View Full Code Here

  @Test
  public void testUniqueProjectIds() throws CoreException {
    //tests that creating multiple projects will create unique ids
    WorkspaceInfo workspace = createWorkspace();
    IMetaStore metaStore = getMetaStore();
    List<String> ids = new ArrayList<String>();
    for (int i = 0; i < 100; i++) {
      ProjectInfo projectInfo = new ProjectInfo();
      projectInfo.setFullName("Project " + i);
      projectInfo.setWorkspaceId(workspace.getUniqueId());
      IFileStore fileStore = metaStore.getDefaultContentLocation(projectInfo);
      projectInfo.setContentLocation(fileStore.toURI());
      metaStore.createProject(projectInfo);
      String projectId = projectInfo.getUniqueId();
      final java.io.File currentProject = new java.io.File(projectId);
      for (String id : ids) {
        //tests that project id is unique based on current file system case sensitivity
        assertTrue(new java.io.File(id).compareTo(currentProject) != 0);
View Full Code Here

  protected Thread createPropertyThread(int number) {
    Runnable runnable = new Runnable() {
      public void run() {
        try {
          Logger logger = LoggerFactory.getLogger("org.eclipse.orion.server.config"); //$NON-NLS-1$
          IMetaStore metaStore = getMetaStore();
          String currentThreadName = Thread.currentThread().getName();
          for (int i = 0; i < PROPERTY_COUNT; i++) {
            // read the user
            UserInfo userInfo = metaStore.readUser("anthony");
            if (userInfo == null) {
              logger.debug("Meta File Error, could not read user anthony to add a property.");
              continue;
            }

            // set a new property
            JSONObject propertyValue = createProperty();
            String propertyKey = "property/" + currentThreadName + "/" + propertyValue.getString("property");
            userInfo.setProperty(propertyKey, propertyValue.toString());
            metaStore.updateUser(userInfo);

            // read the user again
            userInfo = metaStore.readUser("anthony");
            if (userInfo == null) {
              logger.debug("Meta File Error, could not read user anthony to verify the property.");
            } else if (userInfo.getProperty(propertyKey) == null) {
              logger.debug("Meta File Error, JSONObject is missing " + propertyKey + " that was just added.");
            }
View Full Code Here

    }
  }

  @Test
  public void testUpdateUser() throws CoreException {
    IMetaStore store = getMetaStore();
    UserInfo user = new UserInfo();
    user.setUserName("testUpdateUser");
    //should not be able to update user that does not exist
    try {
      store.updateUser(user);
      assertTrue("Update should have failed", false);
    } catch (Exception e) {
      //expected
    }
    store.createUser(user);
    //now update should succeed
    try {
      store.updateUser(user);
    } catch (Exception e) {
      assertTrue("Update should have succeeded", false);
    }
    store.deleteUser(user.getUniqueId());
    //should not be able to update user that does not exist
    try {
      store.updateUser(user);
      assertTrue("Update should have failed", false);
    } catch (Exception e) {
      //expected
    }
  }
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.core.metastore.IMetaStore

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.