use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.
the class LongNameTest method assertNoLongNamesTest.
@Test
public void assertNoLongNamesTest() throws IOException, RepositoryException {
RepositoryConfig config = createCrx2Config(crx2RepoDir);
RepositoryContext context = RepositoryContext.create(config);
try {
RepositoryUpgrade upgrade = new RepositoryUpgrade(context, new MemoryNodeStore());
try {
upgrade.assertNoLongNames();
fail("Exception should be thrown");
} catch (RepositoryException e) {
// that's fine
}
} finally {
context.getRepository().shutdown();
}
}
use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.
the class LongNameTest method upgrade.
private static void upgrade(NodeStore target, boolean skipNameCheck, boolean filterLongNames) throws RepositoryException, IOException {
RepositoryConfig config = createCrx2Config(crx2RepoDir);
RepositoryContext context = RepositoryContext.create(config);
try {
RepositoryUpgrade upgrade = new RepositoryUpgrade(context, target);
upgrade.setCheckLongNames(skipNameCheck);
upgrade.setFilterLongNames(filterLongNames);
upgrade.copy(null);
} finally {
context.getRepository().shutdown();
}
}
use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.
the class LongNameTest method prepareSourceRepository.
@BeforeClass
public static void prepareSourceRepository() throws RepositoryException, IOException, InterruptedException {
crx2RepoDir = new File("target", "upgrade-" + Clock.SIMPLE.getTimeIncreasing());
FileUtils.deleteQuietly(crx2RepoDir);
sourceRepositoryConfig = createCrx2Config(crx2RepoDir);
RepositoryContext ctx = RepositoryContext.create(sourceRepositoryConfig);
RepositoryImpl sourceRepository = ctx.getRepository();
Session session = sourceRepository.login(CREDENTIALS);
try {
Assert.assertTrue(TOO_LONG_NAME.getBytes().length > 150);
Assert.assertTrue(NOT_TOO_LONG_NAME.getBytes().length < 150);
Node longNameParent = createParent(session.getRootNode());
Assert.assertTrue(longNameParent.getPath().length() >= 350);
longNameParent.addNode(TOO_LONG_NAME);
longNameParent.addNode(NOT_TOO_LONG_NAME);
session.save();
Assert.assertTrue(longNameParent.hasNode(TOO_LONG_NAME));
Assert.assertTrue(longNameParent.hasNode(NOT_TOO_LONG_NAME));
} finally {
session.logout();
}
sourceRepository.shutdown();
}
use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.
the class CopyVersionHistoryTest method performCopy.
protected Session performCopy(VersionCopySetup setup) throws RepositoryException, IOException {
final RepositoryConfig sourceConfig = RepositoryConfig.create(source);
final RepositoryContext sourceContext = RepositoryContext.create(sourceConfig);
final NodeStore targetNodeStore = SegmentNodeStoreBuilders.builder(new MemoryStore()).build();
try {
final RepositoryUpgrade upgrade = new RepositoryUpgrade(sourceContext, targetNodeStore);
setup.setup(upgrade.versionCopyConfiguration);
upgrade.setEarlyShutdown(true);
upgrade.copy(null);
} finally {
sourceContext.getRepository().shutdown();
}
repository = (RepositoryImpl) new Jcr(new Oak(targetNodeStore)).createRepository();
Session s = repository.login(AbstractRepositoryUpgradeTest.CREDENTIALS);
sessions.add(s);
return s;
}
use of org.apache.jackrabbit.core.RepositoryContext in project jackrabbit-oak by apache.
the class Jackrabbit2Factory method create.
public RepositoryContext create(Closer closer) throws RepositoryException {
RepositoryContext source = RepositoryContext.create(RepositoryConfig.create(repositoryFile, repositoryDir));
closer.register(asCloseable(source));
return source;
}
Aggregations