Peter Centgraf pushed to branch feature/HCM-154 at cms-community / hippo-configuration-management
Commits: 9ca6b8c9 by Peter Centgraf at 2017-07-03T15:46:06+02:00 HCM-154 Moving logic from ClasspathConfigurationModelReaderTest to repo engine project - - - - - 5 changed files: - model/src/test/java/org/onehippo/cm/model/AbstractBaseTest.java - model/src/test/java/org/onehippo/cm/model/ClasspathConfigurationModelReaderTest.java - − model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-actions.yaml - − model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-config/test.yaml - − model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-module.yaml Changes: ===================================== model/src/test/java/org/onehippo/cm/model/AbstractBaseTest.java ===================================== --- a/model/src/test/java/org/onehippo/cm/model/AbstractBaseTest.java +++ b/model/src/test/java/org/onehippo/cm/model/AbstractBaseTest.java @@ -127,7 +127,7 @@ public abstract class AbstractBaseTest { return module; } - protected SourceImpl assertSource(final ModuleImpl parent, final String path, final int definitionCount) { + public static SourceImpl assertSource(final ModuleImpl parent, final String path, final int definitionCount) { SourceImpl source = findByPath(path, parent.getSources()); assertNotNull(source); assertEquals(path, source.getPath()); ===================================== model/src/test/java/org/onehippo/cm/model/ClasspathConfigurationModelReaderTest.java ===================================== --- a/model/src/test/java/org/onehippo/cm/model/ClasspathConfigurationModelReaderTest.java +++ b/model/src/test/java/org/onehippo/cm/model/ClasspathConfigurationModelReaderTest.java @@ -18,14 +18,18 @@ package org.onehippo.cm.model; import java.io.IOException; import java.net.URISyntaxException; import java.util.HashSet; +import java.util.Optional; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; import org.junit.Test; +import org.onehippo.cm.ConfigurationService; import org.onehippo.cm.model.impl.ConfigurationModelImpl; import org.onehippo.cm.model.impl.ModelTestUtils; import org.onehippo.cm.model.impl.ModuleImpl; import org.onehippo.cm.model.parser.ParserException; +import org.onehippo.cms7.services.HippoServiceRegistry; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,10 +41,8 @@ public class ClasspathConfigurationModelReaderTest extends AbstractBaseTest { private static final Logger log = LoggerFactory.getLogger(ClasspathConfigurationModelReaderTest.class); - // Disable tests for now -- needs to be refactored now that ConfigurationServiceImpl loads FS modules -// @Test + @Test public void load_modules_from_classpath() throws IOException, ParserException, URISyntaxException { - Set<ModuleImpl> classpathModules = loadModules(); assertEquals("Classpath should contain correct number of modules", 1, @@ -59,46 +61,6 @@ public class ClasspathConfigurationModelReaderTest extends AbstractBaseTest { assertSource(loadedTestModule, "test.yaml", 1); } -// @Test - public void load_modules_from_classpath_and_filesystem() throws IOException, ParserException, URISyntaxException { - try { - // set system properties to trigger developer mode that loads config from source files - System.setProperty("project.basedir", calculateBaseDir() + nativePath("/src/test/resources")); - - Set<ModuleImpl> classpathModules = loadModules(); - - assertEquals("Classpath should contain correct number of modules", 1, - classpathModules.size()); - - Set<ModuleImpl> expectedModules = new HashSet<>(); - final ModuleImpl testModule = ModelTestUtils.makeModule("test-module"); - expectedModules.add(testModule); - - assertTrue("Classpath should contain test-module", classpathModules.containsAll(expectedModules)); - - ModuleImpl loadedTestModule = classpathModules.stream().filter(module -> module.equals(testModule)).findFirst().get(); - - // the test-module loaded from source files should have a single source with two definitions, not one, - // since that's what is contained in the files under TestModuleFileSource - assertSource(loadedTestModule, "test.yaml", 2); - } - finally { - // set system properties back to empty strings to make sure developer mode is off again - System.setProperty("project.basedir", ""); - } - } - - /** - * Utility method to calculate correct path in case when run under Intellij IDEA (Working directory should be set to - * module's root, e.g. ../master/engine) - * @return base directory - */ - private String calculateBaseDir() { - String basedir = System.getProperty("basedir"); - basedir = basedir != null ? basedir: System.getProperty("user.dir"); - return basedir; - } - /** * Helper to load modules using a ClasspathConfigurationModelReader. * @return the Set of Modules loaded by the ClasspathConfigurationModelReader with current system properties ===================================== model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-actions.yaml deleted ===================================== --- a/model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-actions.yaml +++ /dev/null @@ -1,8 +0,0 @@ -action-lists: -- 1.0: - /content/path1: reload - /content/pathX: reload -- 1.1: - /content/path2: reload -- 1.2: - /content/path3: delete ===================================== model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-config/test.yaml deleted ===================================== --- a/model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-config/test.yaml +++ /dev/null @@ -1,9 +0,0 @@ -# This file is used by ClasspathConfigurationModelReaderTest and needs to contain exactly two definitions -definitions: - config: - /testnode: - jcr:primaryType: nt:unstructured - testproperty: testvalue - /testnode/testnodefs: - jcr:primaryType: nt:unstructured - testpropertyfs: testvaluefs \ No newline at end of file ===================================== model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-module.yaml deleted ===================================== --- a/model/src/test/resources/TestModuleFileSource/src/main/resources/hcm-module.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# This file is used by ClasspathConfigurationModelReaderTest and needs to be located at TestModuleFileSource/src/main/resources -group: test-group -project: test-project -module: test-module \ No newline at end of file View it on GitLab: https://code.onehippo.org/cms-community/hippo-configuration-management/commit/9ca6b8c9ee364f80a7cc2e4f25ad1d3f6e295582
_______________________________________________ Hippocms-svn mailing list Hippocms-svn@lists.onehippo.org https://lists.onehippo.org/mailman/listinfo/hippocms-svn