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

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


  }

  @Test
  public void testCreateProjectWithEmojiChactersInName() 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);

    // create the project with Emoji characters in the project name.
    // U+1F60A: SMILING FACE WITH SMILING EYES ("\ud83d\ude0a")
    // U+1F431: CAT FACE ("\ud83d\udc31")
    // U+1F435: MONKEY FACE ("\ud83d\udc35")
    String projectName = "Project \ud83d\ude0a\ud83d\udc31\ud83d\udc35";
    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);

    // read the project
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceInfo.getUniqueId(), projectInfo.getFullName());
    assertNotNull(readProjectInfo);
    assertEquals(projectName, readProjectInfo.getFullName());
    assertEquals(readProjectInfo.getFullName(), projectInfo.getFullName());
  }
View Full Code Here


  }

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

    // create the project, do not specify a workspace id
    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
    }
    try {
      metaStore.createProject(projectInfo);
    } catch (CoreException e) {
      // we expect to get a core exception here
      String message = e.getMessage();
      assertTrue(message.contains("workspace id is null"));
    }
View Full Code Here

  }

  @Test
  public void testCreateProjectWithURLAsName() 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);

    // create the project, specify a URL as the name, which is not a valid project name.
    String badProjectName = "http://orion.eclipse.org/";
    ProjectInfo projectInfo = new ProjectInfo();
    projectInfo.setFullName(badProjectName);
    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());
    try {
      metaStore.createProject(projectInfo);
    } catch (CoreException e) {
      // we expect to get a core exception here
      String message = e.getMessage();
      assertTrue(message.contains("could not create project"));
    }
View Full Code Here

   * @throws CoreException
   */
  @Test
  public void testCreateSecondWorkspace() 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);

    // create another workspace with the same workspace name
    String workspaceName2 = "Orion Sandbox";
    WorkspaceInfo workspaceInfo2 = new WorkspaceInfo();
    workspaceInfo2.setFullName(workspaceName2);
    workspaceInfo2.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo2);

    // read the workspace
    WorkspaceInfo readWorkspaceInfo = metaStore.readWorkspace(workspaceInfo2.getUniqueId());
    assertNotNull(readWorkspaceInfo);
    assertEquals(readWorkspaceInfo.getFullName(), workspaceInfo1.getFullName());
    assertEquals(readWorkspaceInfo.getUniqueId(), workspaceInfo1.getUniqueId());
    assertEquals(readWorkspaceInfo.getUserId(), workspaceInfo1.getUserId());
  }
View Full Code Here

  }

  @Test
  public void testCreateSimpleProject() 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);

    // 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);

    IFileStore defaultLocation = metaStore.getDefaultContentLocation(projectInfo);
    // Test that the project is linked
    assertFalse(defaultLocation == projectInfo.getProjectStore());
    // Test that no content folder is created
    assertFalse(defaultLocation.fetchInfo().exists());
  }
View Full Code Here

  }

  @Test
  public void testCreateSimpleUser() 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);

    // read the user back again
    UserInfo readUserInfo = metaStore.readUser(userInfo.getUniqueId());
    assertNotNull(readUserInfo);
    assertEquals(readUserInfo.getUniqueId(), userInfo.getUniqueId());
    assertEquals(readUserInfo.getUserName(), userInfo.getUserName());

    // make sure the user is in the list of all users
    List<String> allUsers = metaStore.readAllUsers();
    assertTrue(allUsers.contains(userInfo.getUniqueId()));

    // delete the user
    metaStore.deleteUser(userInfo.getUniqueId());

    // make sure the user is not the list of all users
    allUsers = metaStore.readAllUsers();
    assertFalse(allUsers.contains(userInfo.getUniqueId()));
  }
View Full Code Here

  }

  @Test
  public void testCreateSimpleWorkspace() 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);
  }
View Full Code Here

  }

  @Test
  public void testCreateTwoWorkspacesWithSameName() 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);

    // create another workspace with the same workspace name
    String workspaceName2 = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    WorkspaceInfo workspaceInfo2 = new WorkspaceInfo();
    workspaceInfo2.setFullName(workspaceName2);
    workspaceInfo2.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo2);

    // read the user
    UserInfo readUserInfo = metaStore.readUser(userInfo.getUniqueId());
    assertNotNull(readUserInfo);
    assertEquals(readUserInfo.getUserName(), userInfo.getUserName());
    assertEquals(1, readUserInfo.getWorkspaceIds().size());
    assertTrue(readUserInfo.getWorkspaceIds().contains(workspaceInfo1.getUniqueId()));
    assertTrue(readUserInfo.getWorkspaceIds().contains(workspaceInfo2.getUniqueId()));

    // read the workspace
    WorkspaceInfo readWorkspaceInfo = metaStore.readWorkspace(workspaceInfo2.getUniqueId());
    assertNotNull(readWorkspaceInfo);
    assertEquals(readWorkspaceInfo.getFullName(), workspaceInfo2.getFullName());
  }
View Full Code Here

  }

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

    // create the user and do not provide a userId
    UserInfo userInfo = new UserInfo();
    userInfo.setFullName(testUserLogin);
    try {
      metaStore.createUser(userInfo);
    } catch (CoreException e) {
      // we expect to get a core exception here
      String message = e.getMessage();
      assertTrue(message.contains("could not create user"));
    }
View Full Code Here

  }

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

    // create the workspace without specifying an existing userid.
    // the user with id '77' is created at the readUser() API.
    String workspaceName = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    WorkspaceInfo workspaceInfo = new WorkspaceInfo();
    workspaceInfo.setUserId("77");
    workspaceInfo.setFullName(workspaceName);
    metaStore.createWorkspace(workspaceInfo);
  }
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.