@Override public void beforeEach() throws Exception { super.beforeEach(); }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); if (startRepositoryAutomatically()) { startRepository(); } tools = new JcrTools(); }
protected void startRepositoryWithConfigurationFrom(String pathToConfiguration) throws Exception { startRepositoryWithConfiguration(getClass().getClassLoader().getResourceAsStream(pathToConfiguration)); }
/** * Import under the supplied parent node the repository content in the XML file at the given location on the classpath. * * @param parentPath the path to the node under which the content should be imported; may not be null * @param resourceName the name of the XML file on the classpath * @param uuidBehavior the UUID behavior; see {@link ImportUUIDBehavior} for values * @throws RepositoryException if there is a problem importing the content * @throws IOException if the XML file could not be read */ protected void importContent( String parentPath, String resourceName, int uuidBehavior ) throws RepositoryException, IOException { InputStream stream = resourceStream(resourceName); assertThat(stream, is(notNullValue())); session().getWorkspace().importXML(parentPath, stream, uuidBehavior); }
@After @Override public void afterEach() throws Exception { super.afterEach(); FileUtil.delete(storageDir()); }
@After public void afterEach() throws Exception { stopRepository(); }
/** * Import under the supplied parent node the repository content in the XML file at the given location on the classpath. * * @param parent the node under which the content should be imported; may not be null * @param resourceName the name of the XML file on the classpath * @param uuidBehavior the UUID behavior; see {@link ImportUUIDBehavior} for values * @throws RepositoryException if there is a problem importing the content * @throws IOException if the XML file could not be read */ protected void importContent( Node parent, String resourceName, int uuidBehavior ) throws RepositoryException, IOException { InputStream stream = resourceStream(resourceName); assertThat(stream, is(notNullValue())); parent.getSession().getWorkspace().importXML(parent.getPath(), stream, uuidBehavior); }
protected void startRepository() throws Exception { RepositoryConfiguration repositoryConfiguration = createRepositoryConfiguration(REPO_NAME); repositoryConfiguration = repositoryConfiguration.with(new TestingEnvironment()); repository = new JcrRepository(repositoryConfiguration); repository.start(); session = repository.login(); }
/** * Register the node types in the CND file at the given location on the classpath. * * @param resourceName the name of the CND file on the classpath * @throws RepositoryException if there is a problem registering the node types * @throws IOException if the CND file could not be read */ protected void registerNodeTypes( String resourceName ) throws RepositoryException, IOException { InputStream stream = resourceStream(resourceName); assertThat(stream, is(notNullValue())); Workspace workspace = session().getWorkspace(); org.modeshape.jcr.api.nodetype.NodeTypeManager ntMgr = (org.modeshape.jcr.api.nodetype.NodeTypeManager)workspace.getNodeTypeManager(); ntMgr.registerNodeTypes(stream, true); }
@Override public void afterEach() throws Exception { for (EventListenerIterator it = observationManager.getRegisteredEventListeners(); it.hasNext();) { observationManager.removeEventListener(it.nextEventListener()); } super.afterEach(); cleanupData(); }
@Override public void beforeEach() throws Exception { super.beforeEach(); mBeanName = new ObjectName("org.modeshape:type=RepositoryStatistics,name=" + REPO_NAME); }
/** * Subclasses can call this method at the beginning of each test to shutdown any currently-running repository and to start up * a new repository with the given JSON configuration document. * * @param doc the JSON document containing the configuration for the repository * @throws Exception if there was a problem starting the repository * @see #startRepositoryWithConfiguration(String) * @see #startRepositoryWithConfiguration(InputStream) * @see #startRepositoryWithConfiguration(RepositoryConfiguration) * @see #startRepositoryAutomatically */ protected void startRepositoryWithConfiguration( Document doc ) throws Exception { assertThat(doc, is(notNullValue())); RepositoryConfiguration config = new RepositoryConfiguration(doc, REPO_NAME); startRepositoryWithConfiguration(config); }
@Override public void beforeEach() throws Exception { // c3p0 is async, so it might take a bit until we can do this.... TestingUtil.waitUntilFolderCleanedUp("target/persistent_repository"); super.beforeEach(); }
/** * Subclasses can call this method at the beginning of each test to shutdown any currently-running repository and to start up * a new repository with the given JSON configuration content. * * @param configInputStream the input stream containing the JSON content defining the configuration for the repository * @throws Exception if there was a problem starting the repository * @see #startRepositoryWithConfiguration(String) * @see #startRepositoryWithConfiguration(Document) * @see #startRepositoryWithConfiguration(RepositoryConfiguration) * @see #startRepositoryAutomatically */ protected void startRepositoryWithConfiguration( InputStream configInputStream ) throws Exception { assertThat(configInputStream, is(notNullValue())); RepositoryConfiguration config = RepositoryConfiguration.read(configInputStream, REPO_NAME); startRepositoryWithConfiguration(config); }
@Before @Override public void beforeEach() throws Exception { backupArea = new File("target/backupArea"); FileUtil.delete(backupArea.getPath()); //use a UUID for the backup folder to prevent some file locks lingering between tests String folderId = UUID.randomUUID().toString(); backupDirectory = new File(backupArea, "repoBackups_" + folderId); backupDirectory2 = new File(backupArea, "repoBackupsAfter_" + folderId); backupDirectory.mkdirs(); backupDirectory2.mkdirs(); backupRepoDir = new File(backupArea, "backupRepo"); backupRepoDir.mkdirs(); new File(backupArea, "restoreRepo").mkdirs(); super.beforeEach(); }
/** * Subclasses can call this method at the beginning of each test to shutdown any currently-running repository and to start up * a new repository with the given JSON configuration content. * * @param configContent the JSON string containing the configuration for the repository (note that single quotes can be used * in place of double quote, making it easier for to specify a JSON content as a Java string) * @throws Exception if there was a problem starting the repository * @see #startRepositoryWithConfiguration(Document) * @see #startRepositoryWithConfiguration(InputStream) * @see #startRepositoryWithConfiguration(RepositoryConfiguration) * @see #startRepositoryAutomatically */ protected void startRepositoryWithConfiguration( String configContent ) throws Exception { assertThat(configContent, is(notNullValue())); Document doc = Json.read(configContent); startRepositoryWithConfiguration(doc); }
@Override public void beforeEach() throws Exception { super.beforeEach(); rootNode = session.getRootNode(); addSequencingListeners(session); }
@Before @Override public void beforeEach() throws Exception { super.beforeEach(); tools = new JcrTools(); Node rootNode = session.getRootNode(); personNode = rootNode.addNode("Person"); personNode.setProperty("First Name", "Ryan"); personNode.setProperty("Middle Name", "Joseph"); personNode.setProperty("Last Name", "Franklin"); personNode.setProperty("Age", 37); personNode.setProperty("Children", new String[] {"Sally", "Brent", "Michael"}); addressNode = personNode.addNode("Address"); addressNode.setProperty("Street", "Frost Avenue"); addressNode.setProperty("House Number", 166); addressNode.setProperty("City", "Flagstaff"); addressNode.setProperty("State", "AZ"); addressNode.setProperty("Country", "US"); addressNode.setProperty("Zip Code", 77777); problems = new SimpleProblems(); }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); versionManager = session.getWorkspace().getVersionManager(); }
@Override @Before public void beforeEach() throws Exception { super.beforeEach(); this.nodeTypeManager = session.getWorkspace().getNodeTypeManager(); }