protected void tryCreatingAWorkspaceNamed( String workspaceName ) { try { graph.createWorkspace().named(workspaceName); } catch (Exception ex) { assumeNoException(ex); } }
/** * {@inheritDoc} * * @see org.modeshape.graph.connector.test.AbstractConnectorTest#initializeContent(org.modeshape.graph.Graph) */ @Override protected void initializeContent( Graph graph ) { if (!graph.getWorkspaces().contains("default")) { graph.createWorkspace().named("default"); } else { graph.useWorkspace("default"); } }
@Test public void shouldCreateWorkspaceUsingSpecificName() { graph.createWorkspace().named("something"); assertNextRequestIsCreateWorkspace("something", CreateConflictBehavior.DO_NOT_CREATE); }
@Test public void shouldCreateWorkspaceAlteringNameIfRequired() { graph.createWorkspace().namedSomethingLike("something"); assertNextRequestIsCreateWorkspace("something", CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME); }
/** * {@inheritDoc} * * @throws SAXException * @throws IOException * @see org.modeshape.graph.connector.test.AbstractConnectorTest#initializeContent(org.modeshape.graph.Graph) */ @Override protected void initializeContent( Graph graph ) throws IOException, SAXException { // Set up a workspace for 'cars' graph.createWorkspace().named("Cars"); graph.importXmlFrom("src/test/resources/cars.xml").into("/"); // Set up a workspace for 'aircraft' graph.createWorkspace().named("Aircraft"); graph.importXmlFrom("src/test/resources/aircraft.xml").into("/"); }
@Test public void shouldCreateWorkspaceByCloningExistingAndAlteringNameIfRequired() { graph.createWorkspace().clonedFrom("original").namedSomethingLike("something"); assertNextRequestIsCloneWorkspace("original", "something", CreateConflictBehavior.CREATE_WITH_ADJUSTED_NAME, CloneConflictBehavior.DO_NOT_CLONE); }
@Test public void shouldCreateWorkspaceByCloningExistingAndUsingSpecificName() { graph.createWorkspace().clonedFrom("original").named("something"); assertNextRequestIsCloneWorkspace("original", "something", CreateConflictBehavior.DO_NOT_CREATE, CloneConflictBehavior.DO_NOT_CLONE); }
@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))); } } }
/** * {@inheritDoc} * * @see org.modeshape.graph.connector.test.AbstractConnectorTest#initializeContent(org.modeshape.graph.Graph) */ @Override protected void initializeContent( Graph graph ) { String initialPath = ""; int depth = 4; int numChildrenPerNode = 4; int numPropertiesPerNode = 7; Stopwatch sw = new Stopwatch(); boolean batch = true; if (!graph.getWorkspaces().contains("default")) { graph.createWorkspace().named("default"); } else { graph.useWorkspace("default"); } createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null); graph.createWorkspace().named("other workspace"); createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null); graph.useWorkspace("default"); } }
@Test public void shouldNotAllowCreatingWorkspacesIfCapabilitiesSayCreatingWorkspacesIsNotSupported() { if (!source.getCapabilities().supportsCreatingWorkspaces()) { // Should not allow creating workspaces using name alteration ... try { graph.createWorkspace().namedSomethingLike("argle bargle"); fail("Should not allow creating workspaces when source capabilities say it's not supported"); } catch (InvalidRequestException error) { // expected } // Should not allow creating workspaces with exact name... String nonExistWorkspaceName = generateNonExistantWorkspaceName(); try { graph.createWorkspace().named(nonExistWorkspaceName); fail("Should not allow creating workspaces when source capabilities say it's not supported"); } catch (InvalidRequestException error) { // expected } } }
@Test public void shouldNotAllowCloningWorkspacesIfCapabilitiesSayCreatingWorkspacesIsNotSupported() { if (!source.getCapabilities().supportsCreatingWorkspaces()) { // Should not allow cloning workspaces using name alteration ... String existingWorkspaceName = graph.getWorkspaces().iterator().next(); String nonExistWorkspaceName = generateNonExistantWorkspaceName(); try { graph.createWorkspace().clonedFrom(existingWorkspaceName).namedSomethingLike("something"); fail("Should not allow cloning workspaces when source capabilities say it's not supported"); } catch (InvalidRequestException error) { // expected } // Should not allow cloning workspaces with exact name ... try { graph.createWorkspace().clonedFrom(existingWorkspaceName).named(nonExistWorkspaceName); fail("Should not allow cloning workspaces when source capabilities say it's not supported"); } catch (InvalidRequestException error) { // expected } } }
@FixFor( "MODE-1182" ) @Test public void shouldBeAbleToCreateThenDestroyThenRecreateWorkspace() throws Exception { if (source.getCapabilities().supportsCreatingWorkspaces()) { String defaultWorkspaceName = graph.getCurrentWorkspaceName(); String validWorkspaceName = generateNonExistantWorkspaceName(); graph.createWorkspace().named(validWorkspaceName); graph.useWorkspace(defaultWorkspaceName); graph.destroyWorkspace().named(validWorkspaceName); graph.createWorkspace().named(validWorkspaceName); } }
sourceGraph.useWorkspace(workspaceName); } else { sourceGraph.createWorkspace().named(workspaceName);
/** * {@inheritDoc} * * @see org.modeshape.graph.connector.test.AbstractConnectorTest#initializeContent(org.modeshape.graph.Graph) */ @Override protected void initializeContent( Graph graph ) { String initialPath = ""; int depth = 4; int numChildrenPerNode = 4; int numPropertiesPerNode = 7; Stopwatch sw = new Stopwatch(); boolean batch = true; // graph.createWorkspace().named("default"); createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null); graph.createWorkspace().named("other workspace"); createSubgraph(graph, initialPath, depth, numChildrenPerNode, numPropertiesPerNode, batch, sw, System.out, null); graph.useWorkspace("default"); }
String[] validWorkspaceNames = generateValidNamesForNewWorkspaces(); if (validWorkspaceNames.length == 0) return; existing = graph.createWorkspace().namedSomethingLike(validWorkspaceNames[0]); assertThat(existing, is(notNullValue())); String workspaceName1 = existing.getName(); 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) {
@Test public void shouldNotAllowCreatingWorkspaceWithInvalidNameIfAllowedByCapabilities() { if (source.getCapabilities().supportsCreatingWorkspaces()) { String[] invalidNames = generateInvalidNamesForNewWorkspaces(); if (invalidNames != null) { for (String invalidName : invalidNames) { try { graph.createWorkspace().named(invalidName); fail("Did not fail to create workspace with name that should be invalid"); } catch (InvalidWorkspaceException error) { // expected } } } } }
String newWorkspaceName = null; if (existingWorkspaceNames.isEmpty()) { workspace1 = graph.createWorkspace().namedSomethingLike(validWorkspaceNames[0]); newWorkspaceName = validWorkspaceNames[1]; assertThat(workspace1, is(notNullValue())); Workspace workspace2 = graph.createWorkspace().clonedFrom(workspaceName).named(newWorkspaceName);
workspace = graph.createWorkspace().named(workspaceName);
configRepository.createWorkspace().named("configSpace"); Graph.Batch batch = configRepository.batch(); batch.create("/a").and();