@Ignore @Test public void shouldAddAndReadNodeRepeatedly() throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); System.setOut(new PrintStream(baos)); graph.create("/cacheTest").with("jcr:primaryType").and(); for (int i = 0; i < 3; i++) { graph.getNodeAt("/cacheTest"); } System.err.println(baos.toByteArray().length); }
@Test public void shouldCreateSequencerContextThatProvidesMimeTypeForNonJcrFileNodeStructure() throws Exception { this.sequencedProperty = mock(Property.class); graph.create("/a").and().create("/a/myFile.rdf").and().create("/a/myFile.rdf/content").and(); Node input = graph.getNodeAt("/a/myFile.rdf/content"); StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems); assertThat(sequencerContext.getMimeType(), is("text/plain")); assertThat(context.getMimeTypeDetector().mimeTypeOf("myFile.rdf", null), is("application/rdf+xml")); assertThat(context.getMimeTypeDetector().mimeTypeOf("content", null), is("text/plain")); }
@Test public void shouldCreateSequencerContextThatProvidesMimeTypeForJcrFileNodeStructure() throws Exception { this.sequencedProperty = mock(Property.class); graph.create("/a").and().create("/a/myFile.rdf").and().create("/a/myFile.rdf/jcr:content").and(); Node input = graph.getNodeAt("/a/myFile.rdf/jcr:content"); StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems); assertThat(sequencerContext.getMimeType(), is("application/rdf+xml")); assertThat(context.getMimeTypeDetector().mimeTypeOf("myFile.rdf", null), is("application/rdf+xml")); assertThat(context.getMimeTypeDetector().mimeTypeOf("jcr:content", null), is("text/plain")); }
@Test public void shouldAddChildUnderRootNode() { graph.batch().create("/a").with("propB", "valueB").and("propC", "valueC").and().execute(); // Now look up the root node ... Node root = graph.getNodeAt("/"); assertThat(root, is(notNullValue())); assertThat(root, hasProperty(ModeShapeLexicon.UUID, getRootNodeUuid())); assertThat(root.getChildren(), hasChild(segment("a"))); // Now look up node A ... Node nodeA = graph.getNodeAt("/a"); assertThat(nodeA, is(notNullValue())); assertThat(nodeA, hasProperty("propB", "valueB")); assertThat(nodeA, hasProperty("propC", "valueC")); assertThat(nodeA.getChildren(), isEmpty()); }
@Test public void shouldCreateSequencerContextThatProvidesMimeType() throws Exception { this.sequencedProperty = mock(Property.class); graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); Node input = graph.getNodeAt("/a/b/c"); StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems); assertThat(sequencerContext.getMimeType(), is("text/plain")); assertThat(context.getMimeTypeDetector().mimeTypeOf("myFile.rdf", null), is("application/rdf+xml")); assertThat(context.getMimeTypeDetector().mimeTypeOf("c", null), is("text/plain")); }
/** * {@inheritDoc} * * @see org.modeshape.graph.sequencer.SequencerOutput#setReference(java.lang.String, java.lang.String, java.lang.String[]) */ public void setReference( String nodePath, String propertyName, String... paths ) { Path path = pathFactory.create(nodePath); path = absolute(path); if (this.paths.add(path)) { batch.create(path).and(); } batch.set(propertyName).on(nodePath).to(paths); }
@Test public void shouldNeverReturnNullInputProperties() throws Exception { this.sequencedProperty = mock(Property.class); graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); Node input = graph.getNodeAt("/a/b/c"); StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems); assertThat(sequencerContext.getInputProperties(), notNullValue()); assertThat(sequencerContext.getInputProperties().isEmpty(), is(false)); }
@Test public void shouldProvideValueFactories() throws Exception { this.sequencedProperty = mock(Property.class); graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); Node input = graph.getNodeAt("/a/b/c"); StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems); assertThat(sequencerContext.getValueFactories(), notNullValue()); }
@Test public void shouldStartUpUsingConfigurationRepositoryThatContainsNoSources() throws Exception { // Set up the configuration repository to contain NO sources ... configRepository.create("/mode:sources").and(); // Now, start up the service ... service.getAdministrator().start(); // and verify that the sources were never added to the manager... verifyNoMoreInteractions(sources); }
@Test public void shouldCreateNodesWithBatch() { graph.batch().create(validPath, validIdProperty1).and().remove("prop").on(validPathString).execute(); graph.batch().move(validPath).and(validPath).into(validPathString).and().create(validPath).and().execute(); graph.batch().createUnder(validLocation).nodeNamed("someName").and().delete(validLocation).execute(); }
protected void createSubgraph( Batch batch, SubgraphNode initialNode, Path pathOfInitialNode ) { // Create the node with the properties ... batch.create(pathOfInitialNode).and(initialNode.getProperties()).ifAbsent().and(); // And create the children ... for (Location childLocation : initialNode.getChildren()) { Path path = childLocation.getPath(); SubgraphNode initialChild = initialNode.getNode(path.getLastSegment()); createSubgraph(batch, initialChild, path); } }
@Test public void shouldProvideNamespaceRegistry() throws Exception { this.sequencedProperty = mock(Property.class); graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); Node input = graph.getNodeAt("/a/b/c"); StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems); assertThat(sequencerContext.getNamespaceRegistry(), notNullValue()); }
@Test public void shouldCreateNodeAndReturnGraph() { graph.create(validPath).and().getNodeAt(validPath); assertThat(numberOfExecutions, is(2)); assertNextRequestIsCreate(Location.create(validPath.getParent()), "c"); assertNextRequestReadNode(Location.create(validPath)); assertNoMoreRequests(); }
@Test public void shouldProvidePathToInput() throws Exception { this.sequencedProperty = mock(Property.class); graph.create("/a").and().create("/a/b").and().create("/a/b/c").and(); Node input = graph.getNodeAt("/a/b/c"); StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems); assertThat(sequencerContext.getInputPath(), is(context.getValueFactories().getPathFactory().create("/a/b/c"))); }
@Test public void shouldInitializeSourceWithOnlySomeNodes() { assertNoChildren(graph, "/"); graph.create("/Aircraft").and(); graph.merge(initialContent); // print = true; printSubgraph(graph, "/"); assertNodeExists(initialContent, "Aircraft"); assertNodeDoesNotExist(initialContent, "Aircraft[2]"); }
/** * This method attempts to create a small subgraph and then delete all of the nodes in that subgraph, all within the same * batch operation. */ @FixFor( "MODE-788" ) @Test public void shouldCreateAndDeleteNodeInSameOperation() { graph.batch().create("/a").with("propB", "valueB").and("propC", "valueC").and().delete("/a").and().execute(); }
@Test( expected = InvalidRequestException.class ) public void shouldNotAllowMultipleUpdatesInBatch() { Graph.Create<Graph.Batch> create = graph.batch().create("/a"); for (int i = 0; i != 100; ++i) { create = create.with("property" + i, "value" + i); } create.and().execute(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.connector.test.AbstractConnectorTest#initializeContent(org.modeshape.graph.Graph) */ @Override protected void initializeContent( Graph graph ) { graph.create("/testNode").and(); source.setAllowsUpdates(false); }