Package org.jboss.dna.graph

Examples of org.jboss.dna.graph.Workspace


    @Test
    public void shouldReturnListOfWorkspacesMatchingRepositoryURLs() throws Exception {
        // The the actual names of the workspaces ...
        Set<String> workspaceNames = new HashSet<String>();
        for (String workspaceName : graph.getWorkspaces()) {
            Workspace workspace = graph.useWorkspace(workspaceName);
            workspaceNames.add(workspace.getName());
        }

        assertThat(workspaceNames.remove(repositoryRootURL + "trunk"), is(true));
        assertThat(workspaceNames.remove(repositoryRootURL + "tags"), is(true));
        assertThat(workspaceNames.isEmpty(), is(true));
View Full Code Here


        CheckArg.isNotNull(source, "source");

        // Verify connectivity ...
        Graph graph = Graph.create(source, context);
        if (workspaceName != null) {
            Workspace workspace = null;
            try {
                workspace = graph.useWorkspace(workspaceName); // should throw exception if not connectable
            } catch (InvalidWorkspaceException e) {
                // Try creating the workspace ...
                workspace = graph.createWorkspace().named(workspaceName);
            }
            assert workspace.getRoot() != null;
        }

        // Verify the path ...
        Path path = pathInWorkspace != null ? path(pathInWorkspace) : path(DEFAULT_PATH);
        Node parent = graph.getNodeAt(path);
View Full Code Here

    @Test
    public void shouldNotAllowCloningWorkspaceFromWorkspaceWithSameNameIfAllowedByCapabilities() {
        if (source.getCapabilities().supportsCreatingWorkspaces()) {
            try {
                // Find an existing workspace or create a new one ...
                Workspace existing = null;
                Set<String> existingWorkspaceNames = graph.getWorkspaces();
                if (existingWorkspaceNames.isEmpty()) {
                    String[] validWorkspaceNames = generateValidNamesForNewWorkspaces();
                    if (validWorkspaceNames.length == 0) return;
                    existing = graph.createWorkspace().namedSomethingLike(validWorkspaceNames[0]);
                    assertThat(existing, is(notNullValue()));
                    String workspaceName1 = existing.getName();
                    assertThat(workspaceName1, is(notNullValue()));
                    assertThat(workspaceName1.trim().length(), is(not(0)));

                    // Initialize workspace one with some content ...
                    initializeContents(graph);
                } else {
                    existing = graph.useWorkspace(existingWorkspaceNames.iterator().next());
                }

                // Clone 'workspace1' into workspace1' ... yes this is invalid
                try {
                    graph.createWorkspace().clonedFrom(existing.getName()).named(existing.getName());
                    fail("No error reported after attempting to create a cloned workspace that was same name as clone");
                } catch (InvalidWorkspaceException error) {
                    // expected
                }
            } catch (InvalidRequestException error) {
View Full Code Here

    @Test
    public void shouldAllowCreatingWorkspaceWithValidNameIfAllowedByCapabilities() {
        if (source.getCapabilities().supportsCreatingWorkspaces()) {
            String[] validNames = generateValidNamesForNewWorkspaces();
            for (String validName : validNames) {
                Workspace workspace = graph.createWorkspace().named(validName);

                assertThat(workspace, is(notNullValue()));
                String workspaceName1 = workspace.getName();
                assertThat(workspaceName1, is(notNullValue()));
                assertThat(workspaceName1.trim().length(), is(not(0)));
            }
        }
    }
View Full Code Here

            if (validWorkspaceNames.length < 1) return;

            try {
                // Is there an existing workspace?
                Set<String> existingWorkspaceNames = graph.getWorkspaces();
                Workspace workspace1 = null;
                String newWorkspaceName = null;
                if (existingWorkspaceNames.isEmpty()) {
                    workspace1 = graph.createWorkspace().namedSomethingLike(validWorkspaceNames[0]);
                    newWorkspaceName = validWorkspaceNames[1];
                    assertThat(workspace1, is(notNullValue()));
                    String workspaceName1 = workspace1.getName();
                    assertThat(workspaceName1, is(notNullValue()));
                    assertThat(workspaceName1.trim().length(), is(not(0)));

                    // Initialize workspace one with some content ...
                    initializeContents(graph);
                } else {
                    workspace1 = graph.useWorkspace(existingWorkspaceNames.iterator().next());
                    newWorkspaceName = validWorkspaceNames[0];
                }
                assert workspace1 != null;
                assert newWorkspaceName != null;

                // Clone 'workspace1' into 'workspace2'
                String workspaceName = workspace1.getName();
                Workspace workspace2 = graph.createWorkspace().clonedFrom(workspaceName).named(newWorkspaceName);

                // Verify that the content of 'workspace1' matches that of 'workspace2'
                Subgraph subgraph1 = graph.getSubgraphOfDepth(100000).at(workspace1.getRoot());
                Subgraph subgraph2 = graph.getSubgraphOfDepth(100000).at(workspace2.getRoot());
                assertEquivalentSubgraphs(subgraph1, subgraph2, true, true);
            } catch (InvalidRequestException error) {
                // Updates may not be supported, but if they are then this is a failure ...
                if (source.getCapabilities().supportsUpdates()) throw error;
            }
View Full Code Here

    @Test
    public void shouldReturnListOfWorkspaces() {
        // The the actual names of the workspaces ...
        Set<String> workspaceNames = new HashSet<String>();
        for (String workspaceName : graph.getWorkspaces()) {
            Workspace workspace = graph.useWorkspace(workspaceName);
            workspaceNames.add(workspace.getName());
        }
        // The actual names should be the absolute paths to the directories representing the root ...
        for (String expectedName : predefinedWorkspaces) {
            assertThat(workspaceNames.remove(expectedName), is(true));
        }
View Full Code Here

    @Test
    public void shouldReturnListOfWorkspaces() {
        // The the actual names of the workspaces ...
        Set<String> workspaceNames = new HashSet<String>();
        for (String workspaceName : graph.getWorkspaces()) {
            Workspace workspace = graph.useWorkspace(workspaceName);
            workspaceNames.add(workspace.getName());
        }
        // The actual names should be the absolute paths to the directories representing the root ...
        for (String expectedName : predefinedWorkspaces) {
            assertThat(workspaceNames.remove(expectedName), is(true));
        }
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.Workspace

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.