Examples of ReadNodeRequest


Examples of org.jboss.dna.graph.request.ReadNodeRequest

        processor.await();
    }

    @Test
    public void shouldReturnFromAwaitAfterChannelsAreCompleted() throws Exception {
        ReadNodeRequest requestA = new ReadNodeRequest(location("/a/some"), workspaceNameA);
        ReadNodeRequest requestB = new ReadNodeRequest(location("/b/some"), workspaceNameB);
        ReadNodeRequest requestC = new ReadNodeRequest(location("/c/some"), workspaceNameC);
        processor.submit(requestA, sourceNameA);
        processor.submit(requestB, sourceNameB);
        processor.submit(requestC, sourceNameC);
        processor.close();
        processor.await();
View Full Code Here

Examples of org.jboss.dna.graph.request.ReadNodeRequest

        assertThat(result, is(location.getString(context.getNamespaceRegistry())));
    }

    @Test
    public void shouldFindFederatedWorkspaceByName() {
        ReadNodeRequest request = new ReadNodeRequest(location("/some"), this.workspace.getName());
        FederatedWorkspace workspace = processor.getWorkspace(request, request.inWorkspace());
        assertThat(workspace, is(sameInstance(this.workspace)));
    }
View Full Code Here

Examples of org.jboss.dna.graph.request.ReadNodeRequest

        assertThat(workspace, is(sameInstance(this.workspace)));
    }

    @Test
    public void shouldRecordErrorOnRequestIfFederatedWorkspaceCouldNotBeFoundByName() {
        ReadNodeRequest request = new ReadNodeRequest(location("/some"), nonExistantWorkspaceName);
        FederatedWorkspace workspace = processor.getWorkspace(request, request.inWorkspace());
        assertThat(workspace, is(nullValue()));
        assertThat(request.hasError(), is(true));
        assertThat(request.getError(), is(instanceOf(InvalidWorkspaceException.class)));
    }
View Full Code Here

Examples of org.jboss.dna.graph.request.ReadNodeRequest

        assertThat(federatedRequests.get(0), is(sameInstance(request)));
    }

    @Test
    public void shouldSubmitToSourcesTheSingleRequestInFederatedRequestAndAddFederatedRequestToQueue() throws Exception {
        ReadNodeRequest original = new ReadNodeRequest(location("/a/some"), this.workspace.getName());
        FederatedRequest request = new FederatedRequest(original);
        // Create the projection and the source request ...
        ReadNodeRequest sourceRequest = new ReadNodeRequest(location("/some"), workspaceNameA);
        request.add(sourceRequest, false, false, projectionA);
        assertThat(request.getFirstProjectedRequest().getProjection(), is(sameInstance(projectionA)));
        assertThat(request.getFirstProjectedRequest().hasNext(), is(false));

        // Submit the federated request ...
View Full Code Here

Examples of org.jboss.dna.graph.request.ReadNodeRequest

        assertThat(connectionForSourceA.getProcessedRequests().contains(sourceRequest), is(true));
    }

    @Test
    public void shouldSubmitToSourcesTheMultipleRequestsInFederatedRequestAndAddFederatedRequestToQueue() throws Exception {
        ReadNodeRequest original = new ReadNodeRequest(location("/some"), this.workspace.getName());
        FederatedRequest request = new FederatedRequest(original);

        // Create the first projection and the source request ...
        ReadNodeRequest sourceRequestA = new ReadNodeRequest(location("/a/some/other"), workspaceNameA);
        request.add(sourceRequestA, false, false, projectionA);
        assertThat(request.getFirstProjectedRequest().getProjection(), is(sameInstance(projectionA)));

        // Create the second projection and the source request ...
        ReadNodeRequest sourceRequestB = new ReadNodeRequest(location("/b/some/other"), workspaceNameB);
        request.add(sourceRequestB, false, false, projectionB);
        assertThat(request.getFirstProjectedRequest().next().getProjection(), is(sameInstance(projectionB)));

        assertThat(request.getFirstProjectedRequest().next().hasNext(), is(false));
View Full Code Here

Examples of org.jboss.dna.graph.request.ReadNodeRequest

    public void shouldNotForkReadNodeRequestIfWorkspaceNameIsInvalid() {
        // Stub the workspace to have no projection ...
        Location locationInFed = location("/a/b");
        stub(workspace.project(context, locationInFed, false)).toReturn(null);

        ReadNodeRequest request = new ReadNodeRequest(locationInFed, nonExistantWorkspaceName);
        processor.process(request);
        assertThat(request.hasError(), is(true));
        assertThat(request.getError(), is(instanceOf(InvalidWorkspaceException.class)));
    }
View Full Code Here

Examples of org.jboss.dna.graph.request.ReadNodeRequest

    public void shouldNotForkReadNodeRequestIfThereIsNoProjection() {
        // Stub the workspace to have no projection ...
        Location locationInFed = location("/a/b");
        stub(workspace.project(context, locationInFed, false)).toReturn(null);

        ReadNodeRequest request = new ReadNodeRequest(locationInFed, workspaceName);
        processor.process(request);
        assertThat(request.hasError(), is(true));
        assertThat(request.getError(), is(instanceOf(PathNotFoundException.class)));
    }
View Full Code Here

Examples of org.jboss.dna.graph.request.ReadNodeRequest

        Location locationInFed = location("/a/x/y");
        Location locationInSource = location("/x/y");
        ProjectedNode projectedNode = new ProxyNode(projectionA, locationInSource, locationInFed, false);
        stub(workspace.project(context, locationInFed, false)).toReturn(projectedNode);

        ReadNodeRequest request = new ReadNodeRequest(locationInFed, workspaceName);
        processor.process(request);
        assertThat(request.hasError(), is(false));

        // Check that the federated request has the right information ...
        FederatedRequest fedRequest = federatedRequests.poll();
        ReadNodeRequest projectedRequest = (ReadNodeRequest)fedRequest.getFirstProjectedRequest().getRequest();
        assertThat(projectedRequest.at(), is(locationInSource));
        assertThat(fedRequest.getFirstProjectedRequest().hasNext(), is(false));

        // Close the processor ...
        processor.close();
        processor.await();

        // Verify the source saw the expected read ...
        ReadNodeRequest sourceRequest = (ReadNodeRequest)connectionForSourceA.getProcessedRequests().poll();
        assertThat(sourceRequest.at().getPath(), is(locationInSource.getPath()));
        assertThat(connectionForSourceB.getProcessedRequests().isEmpty(), is(true));
        assertThat(connectionForSourceC.getProcessedRequests().isEmpty(), is(true));
    }
View Full Code Here

Examples of org.jboss.dna.graph.request.ReadNodeRequest

        addChild(locationInSource, "child1");
        addChild(locationInSource, "child2");
        PlaceholderNode projectedNode = new PlaceholderNode(locationInSource, properties, children);
        stub(workspace.project(context, locationInFed, false)).toReturn(projectedNode);

        ReadNodeRequest request = new ReadNodeRequest(locationInFed, workspaceName);
        processor.process(request);
        assertThat(request.hasError(), is(false));

        // Check that the federated request has the right information ...
        FederatedRequest fedRequest = federatedRequests.poll();
        ReadNodeRequest projectedRequest = (ReadNodeRequest)fedRequest.getFirstProjectedRequest().getRequest();
        assertThat(projectedRequest.at(), is(locationInFed));
        List<Location> expectedChildren = new ArrayList<Location>();
        for (ProjectedNode child : children) {
            expectedChildren.add(child.location());
        }
        assertThat(projectedRequest.getChildren(), is(expectedChildren));
        assertThat(projectedRequest.getPropertiesByName(), is(properties));
        assertThat(fedRequest.getFirstProjectedRequest().hasNext(), is(false));

        // Close the processor ...
        processor.close();
        processor.await();
View Full Code Here

Examples of org.jboss.dna.graph.requests.ReadNodeRequest

     * @see org.jboss.dna.graph.requests.processor.RequestProcessor#process(org.jboss.dna.graph.requests.ReadNodeRequest)
     */
    @Override
    public void process( ReadNodeRequest request ) {
        Location locationInSource = projectIntoSource(request.at());
        ReadNodeRequest projected = new ReadNodeRequest(locationInSource);
        getConnection().execute(this.getExecutionContext(), projected);
        if (projected.hasError()) {
            projectError(projected, request.at(), request);
            return;
        }
        for (Property property : projected.getProperties()) {
            request.addProperty(property);
        }
        for (Location child : projected.getChildren()) {
            request.addChild(child);
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.