@Override protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException { final Session session = installContext.getConfigJCRSession(); final String newCacheFactoryName = StringUtils.substringBefore(StringUtils.lowerCase(StringUtils.substringAfterLast(session.getNode("/modules/cache/config/cacheFactory/").getProperty("class").getString(), ".")), "factory"); new RenameNodeTask("", RepositoryConstants.CONFIG, "/modules/cache/config", "cacheFactory", newCacheFactoryName, false).execute(installContext); new BootstrapSingleModuleResource("config.modules.cache.config.cacheFactory.xml").execute(installContext); new MoveNodeTask("", "/modules/cache/config/" + newCacheFactoryName, "/modules/cache/config/cacheFactory/delegateFactories/" + newCacheFactoryName, false).execute(installContext); } }
@Test public void partialXmlBootstrap() throws Exception { // GIVEN Node child = NodeUtil.createPath(session.getRootNode(), "parent/child", NodeTypes.ContentNode.NAME); child.setProperty("propertyWhichShouldBeRemoved", "propertyWhichShouldBeRemoved"); final BootstrapSingleModuleResource task = new BootstrapSingleModuleResource("", "", "config.parent.xml", "parent/child"); // WHEN task.execute(ctx); //THEN assertThat(session.getRootNode(), hasNode("parent")); assertThat(session.getNode("/parent"), hasNode("child")); assertThat(session.getNode("/parent/child"), not(hasProperty("propertyWhichShouldBeRemoved"))); }
@Test public void partialYamlBootstrap() throws Exception { // GIVEN Node child = NodeUtil.createPath(session.getRootNode(), "/parent/child", NodeTypes.ContentNode.NAME); child.setProperty("propertyWhichShouldBeRemoved", "propertyWhichShouldBeRemoved"); final BootstrapSingleModuleResource task = new BootstrapSingleModuleResource("", "", "config.parent.yaml", "/parent/child"); // WHEN task.execute(ctx); //THEN assertThat(session.getRootNode(), hasNode("parent")); assertThat(session.getNode("/parent"), hasNode("child")); assertThat(session.getNode("/parent"), not(hasNode("sibling"))); assertThat(session.getNode("/parent/child"), hasProperty("property", "value")); assertThat(session.getNode("/parent/child"), not(hasProperty("propertyWhichShouldBeRemoved"))); }