@Test public void shouldCancelFederatedRequestIfOneOfSeveralMultipleReadNodeRequestIsCancelled() { // Create the original read node request ... final ReadNodeRequest original = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); // Create a single federated request using the mirror projection... final FederatedRequest request = new FederatedRequest(original); // And "fork" the original request into the first source request ... final ReadNodeRequest projected1 = new ReadNodeRequest(location("/b/c"), "workspaceM"); projected1.setActualLocationOfNode(Location.create(projected1.at().getPath(), UUID.randomUUID())); projected1.addProperty(property("propA", "valueA")); projected1.addProperty(property("propB", "valueB")); projected1.addChild(child(projected1.getActualLocationOfNode(), "child1")); projected1.addChild(child(projected1.getActualLocationOfNode(), "child2")); request.add(projected1, false, false, projectionA); // And a second source request (that was cancelled)... final ReadNodeRequest projected2 = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); projected2.cancel(); request.add(projected2, true, false, mirrorProjection); request.freeze(); request.getLatch().countDown(); request.getLatch().countDown(); joinQueue.add(request); // Add a terminating request and join the request... joinQueue.add(new NoMoreFederatedRequests()); joinProcessor.process(joinQueue); // Check the results of the original has the same results of the projected... assertThat(original.getProperties().isEmpty(), is(true)); assertThat(original.getChildren().isEmpty(), is(true)); assertThat(original.isCancelled(), is(true)); }
request.cancel(); return;