Author: cziegeler Date: Wed Sep 21 20:39:50 2016 New Revision: 1761810 URL: http://svn.apache.org/viewvc?rev=1761810&view=rev Log: SLING-5999 : JcrResourceBundleProvider should move to new ResourceChangeListener API
Modified: sling/trunk/bundles/extensions/i18n/pom.xml sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java Modified: sling/trunk/bundles/extensions/i18n/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/pom.xml?rev=1761810&r1=1761809&r2=1761810&view=diff ============================================================================== --- sling/trunk/bundles/extensions/i18n/pom.xml (original) +++ sling/trunk/bundles/extensions/i18n/pom.xml Wed Sep 21 20:39:50 2016 @@ -100,6 +100,26 @@ <artifactId>maven-source-plugin</artifactId> </plugin> <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>reserve-network-port</id> + <goals> + <goal>reserve-network-port</goal> + </goals> + <phase>pre-integration-test</phase> + <configuration> + <portNames> + <portName>http.port</portName> + </portNames> + <minPortNumber>45000</minPortNumber> + <maxPortNumber>45999</maxPortNumber> + </configuration> + </execution> + </executions> + </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.18.1</version> @@ -117,22 +137,12 @@ <pax.exam.log.level>${pax.exam.log.level}</pax.exam.log.level> <java.protocol.handler.pkgs>org.ops4j.pax.url</java.protocol.handler.pkgs> <bundle.filename>${basedir}/target/${project.build.finalName}.jar</bundle.filename> + <bundle.build.dir>${basedir}/target</bundle.build.dir> + <org.osgi.service.http.port>${http.port}</org.osgi.service.http.port> </systemPropertyVariables> </configuration> </plugin> <plugin> - <groupId>org.apache.servicemix.tooling</groupId> - <artifactId>depends-maven-plugin</artifactId> - <version>1.3.1</version> - <executions> - <execution> - <goals> - <goal>generate-depends-file</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> <artifactId>maven-clean-plugin</artifactId> <configuration> <filesets> @@ -213,12 +223,6 @@ </dependency> <!-- Testing --> <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>org.apache.sling.testing.paxexam</artifactId> - <version>0.0.2</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>javax.jcr</groupId> <artifactId>jcr</artifactId> <scope>test</scope> Modified: sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java?rev=1761810&r1=1761809&r2=1761810&view=diff ============================================================================== --- sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java (original) +++ sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java Wed Sep 21 20:39:50 2016 @@ -18,13 +18,17 @@ */ package org.apache.sling.i18n.it; -import static org.apache.sling.testing.paxexam.SlingOptions.slingExtensionModels; -import static org.apache.sling.testing.paxexam.SlingOptions.slingLaunchpadOakTar; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import static org.ops4j.pax.exam.CoreOptions.frameworkProperty; import static org.ops4j.pax.exam.CoreOptions.junitBundles; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.CoreOptions.systemProperty; +import static org.ops4j.pax.exam.CoreOptions.when; +import java.io.File; import java.util.Locale; import java.util.ResourceBundle; @@ -36,12 +40,14 @@ import javax.jcr.Session; import org.apache.sling.i18n.ResourceBundleProvider; import org.apache.sling.i18n.impl.Message; import org.apache.sling.jcr.api.SlingRepository; -import org.apache.sling.testing.paxexam.TestSupport; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Configuration; +import org.ops4j.pax.exam.CoreOptions; import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.cm.ConfigurationAdminOptions; import org.ops4j.pax.exam.junit.PaxExam; import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; import org.ops4j.pax.exam.spi.reactors.PerClass; @@ -50,10 +56,19 @@ import org.slf4j.LoggerFactory; @RunWith(PaxExam.class) @ExamReactorStrategy(PerClass.class) -public class ResourceBundleProviderIT extends TestSupport { +public class ResourceBundleProviderIT { private final Logger log = LoggerFactory.getLogger(getClass()); + private static final String BUNDLE_JAR_SYS_PROP = "bundle.filename"; + + /** The property containing the build directory. */ + private static final String SYS_PROP_BUILD_DIR = "bundle.build.dir"; + + private static final String DEFAULT_BUILD_DIR = "target"; + + private static final String PORT_CONFIG = "org.osgi.service.http.port"; + public static final int RETRY_TIMEOUT_MSEC = 10000; public static final String MSG_KEY1 = "foo"; public static final String MSG_KEY2 = "foo2"; @@ -71,35 +86,167 @@ public class ResourceBundleProviderIT ex private Node frRoot; private Node enRoot; - @org.ops4j.pax.exam.Configuration - public Option[] configuration() { - final String workingDirectory = workingDirectory(); // from TestSupport - final int httpPort = findFreePort(); // from TestSupport - - return new Option[]{ - baseConfiguration(), // from TestSupport - slingLaunchpadOakTar(workingDirectory, httpPort), // from SlingOptions - slingExtensionModels(), // from SlingOptions (for illustration) - // build artifact - testBundle("bundle.filename"), // from TestSupport - // testing - junitBundles() - }; - } -/* - @org.ops4j.pax.exam.Configuration + @Configuration public Option[] config() { - final File thisProjectsBundle = new File(System.getProperty( "bundle.file.name", "BUNDLE_FILE_NOT_SET" )); - final String launchpadVersion = System.getProperty("sling.launchpad.version", "LAUNCHPAD_VERSION_NOT_SET"); - return new DefaultCompositeOption( - SlingPaxOptions.defaultLaunchpadOptions(launchpadVersion), - CoreOptions.provision(CoreOptions.bundle(thisProjectsBundle.toURI().toString())), + final String buildDir = System.getProperty(SYS_PROP_BUILD_DIR, DEFAULT_BUILD_DIR); + final String bundleFileName = System.getProperty( BUNDLE_JAR_SYS_PROP ); + final File bundleFile = new File( bundleFileName ); + if ( !bundleFile.canRead() ) { + throw new IllegalArgumentException( "Cannot read from bundle file " + bundleFileName + " specified in the " + + BUNDLE_JAR_SYS_PROP + " system property" ); + } + + String localRepo = System.getProperty("maven.repo.local", ""); + + final String jackrabbitVersion = "2.13.1"; + final String oakVersion = "1.5.7"; + + final String slingHome = new File(buildDir + File.separatorChar + "sling_" + System.currentTimeMillis()).getAbsolutePath(); + + return options( + frameworkProperty("sling.home").value(slingHome), + frameworkProperty("repository.home").value(slingHome + File.separatorChar + "repository"), + when( localRepo.length() > 0 ).useOptions( + systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo) + ), + when( System.getProperty(PORT_CONFIG) != null ).useOptions( + systemProperty(PORT_CONFIG).value(System.getProperty(PORT_CONFIG))), + systemProperty("pax.exam.osgi.unresolved.fail").value("true"), + + ConfigurationAdminOptions.newConfiguration("org.apache.felix.jaas.ConfigurationSpi") + .create(true) + .put("jaas.defaultRealmName", "jackrabbit.oak") + .put("jaas.configProviderName", "FelixJaasProvider") + .asOption(), + ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory") + .create(true) + .put("jaas.controlFlag", "optional") + .put("jaas.classname", "org.apache.jackrabbit.oak.spi.security.authentication.GuestLoginModule") + .put("jaas.ranking", 300) + .asOption(), + ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory") + .create(true) + .put("jaas.controlFlag", "required") + .put("jaas.classname", "org.apache.jackrabbit.oak.security.authentication.user.LoginModuleImpl") + .asOption(), + ConfigurationAdminOptions.factoryConfiguration("org.apache.felix.jaas.Configuration.factory") + .create(true) + .put("jaas.controlFlag", "sufficient") + .put("jaas.classname", "org.apache.jackrabbit.oak.security.authentication.token.TokenLoginModule") + .put("jaas.ranking", 200) + .asOption(), + ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.security.authentication.AuthenticationConfigurationImpl") + .create(true) + .put("org.apache.jackrabbit.oak.authentication.configSpiName", "FelixJaasProvider") + .asOption(), + ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.security.user.UserConfigurationImpl") + .create(true) + .put("groupsPath", "/home/groups") + .put("usersPath", "/home/users") + .put("defaultPath", "1") + .put("importBehavior", "besteffort") + .asOption(), + ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.security.user.RandomAuthorizableNodeName") + .create(true) + .put("enabledActions", new String[] {"org.apache.jackrabbit.oak.spi.security.user.action.AccessControlAction"}) + .put("userPrivilegeNames", new String[] {"jcr:all"}) + .put("groupPrivilegeNames", new String[] {"jcr:read"}) + .asOption(), + ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.spi.security.user.action.DefaultAuthorizableActionProvider") + .create(true) + .put("length", 21) + .asOption(), + ConfigurationAdminOptions.newConfiguration("org.apache.jackrabbit.oak.plugins.segment.SegmentNodeStoreService") + .create(true) + .put("name", "Default NodeStore") + .asOption(), + + // logging + systemProperty("pax.exam.logging").value("none"), + mavenBundle("org.apache.sling", "org.apache.sling.commons.log", "4.0.6"), + mavenBundle("org.apache.sling", "org.apache.sling.commons.logservice", "1.0.6"), + mavenBundle("org.slf4j", "slf4j-api", "1.7.13"), + mavenBundle("org.slf4j", "jcl-over-slf4j", "1.7.13"), + mavenBundle("org.slf4j", "log4j-over-slf4j", "1.7.13"), + + mavenBundle("commons-io", "commons-io", "2.4"), + mavenBundle("commons-fileupload", "commons-fileupload", "1.3.1"), + mavenBundle("commons-collections", "commons-collections", "3.2.2"), + mavenBundle("commons-codec", "commons-codec", "1.10"), + mavenBundle("commons-lang", "commons-lang", "2.6"), + mavenBundle("commons-pool", "commons-pool", "1.6"), + + mavenBundle("org.apache.servicemix.bundles", "org.apache.servicemix.bundles.concurrent", "1.3.4_1"), + + mavenBundle("org.apache.geronimo.bundles", "commons-httpclient", "3.1_1"), + mavenBundle("org.apache.tika", "tika-core", "1.9"), + mavenBundle("org.apache.tika", "tika-bundle", "1.9"), + + // infrastructure mavenBundle("org.apache.felix", "org.apache.felix.http.servlet-api", "1.1.2"), mavenBundle("org.apache.felix", "org.apache.felix.http.jetty", "3.1.6"), - mavenBundle("org.apache.sling", "org.apache.sling.commons.osgi", "2.4.0") - ).getOptions(); + mavenBundle("org.apache.felix", "org.apache.felix.eventadmin", "1.4.4"), + mavenBundle("org.apache.felix", "org.apache.felix.scr", "2.0.4"), + mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.8.10"), + mavenBundle("org.apache.felix", "org.apache.felix.inventory", "1.0.4"), + mavenBundle("org.apache.felix", "org.apache.felix.metatype", "1.1.2"), + + // sling + mavenBundle("org.apache.sling", "org.apache.sling.settings", "1.3.8"), + mavenBundle("org.apache.sling", "org.apache.sling.commons.osgi", "2.3.0"), + mavenBundle("org.apache.sling", "org.apache.sling.commons.json", "2.0.16"), + mavenBundle("org.apache.sling", "org.apache.sling.commons.mime", "2.1.8"), + mavenBundle("org.apache.sling", "org.apache.sling.commons.classloader", "1.3.2"), + mavenBundle("org.apache.sling", "org.apache.sling.commons.scheduler", "2.4.14"), + mavenBundle("org.apache.sling", "org.apache.sling.commons.threads", "3.2.4"), + + mavenBundle("org.apache.sling", "org.apache.sling.auth.core", "1.3.12"), + mavenBundle("org.apache.sling", "org.apache.sling.discovery.api", "1.0.2"), + mavenBundle("org.apache.sling", "org.apache.sling.discovery.commons", "1.0.12"), + mavenBundle("org.apache.sling", "org.apache.sling.discovery.standalone", "1.0.2"), + + mavenBundle("org.apache.sling", "org.apache.sling.api", "2.14.2"), + mavenBundle("org.apache.sling", "org.apache.sling.resourceresolver", "1.4.18"), + mavenBundle("org.apache.sling", "org.apache.sling.adapter", "2.1.2"), + mavenBundle("org.apache.sling", "org.apache.sling.jcr.resource", "2.8.0"), + mavenBundle("org.apache.sling", "org.apache.sling.jcr.classloader", "3.2.2"), + mavenBundle("org.apache.sling", "org.apache.sling.jcr.contentloader", "2.1.8"), + mavenBundle("org.apache.sling", "org.apache.sling.engine", "2.6.2"), + mavenBundle("org.apache.sling", "org.apache.sling.serviceusermapper", "1.2.2"), + + mavenBundle("org.apache.sling", "org.apache.sling.jcr.jcr-wrapper", "2.0.0"), + mavenBundle("org.apache.sling", "org.apache.sling.jcr.api", "2.4.0"), + mavenBundle("org.apache.sling", "org.apache.sling.jcr.base", "2.4.0"), + + mavenBundle("com.google.guava", "guava", "15.0"), + mavenBundle("org.apache.jackrabbit", "jackrabbit-api", jackrabbitVersion), + mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-commons", jackrabbitVersion), + mavenBundle("org.apache.jackrabbit", "jackrabbit-spi", jackrabbitVersion), + mavenBundle("org.apache.jackrabbit", "jackrabbit-spi-commons", jackrabbitVersion), + mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-rmi", jackrabbitVersion), + + mavenBundle("org.apache.felix", "org.apache.felix.jaas", "0.0.4"), + + mavenBundle("org.apache.jackrabbit", "oak-core", oakVersion), + mavenBundle("org.apache.jackrabbit", "oak-commons", oakVersion), + mavenBundle("org.apache.jackrabbit", "oak-lucene", oakVersion), + mavenBundle("org.apache.jackrabbit", "oak-blob", oakVersion), + mavenBundle("org.apache.jackrabbit", "oak-jcr", oakVersion), + + mavenBundle("org.apache.jackrabbit", "oak-segment", oakVersion), + + mavenBundle("org.apache.sling", "org.apache.sling.jcr.oak.server", "1.1.0"), + + mavenBundle("org.apache.sling", "org.apache.sling.testing.tools", "1.0.6"), + mavenBundle("org.apache.httpcomponents", "httpcore-osgi", "4.1.2"), + mavenBundle("org.apache.httpcomponents", "httpclient-osgi", "4.1.2"), + + junitBundles(), + + CoreOptions.bundle( bundleFile.toURI().toString() ) + ); } -*/ + static abstract class Retry { Retry(int timeoutMsec) { final long timeout = System.currentTimeMillis() + timeoutMsec; @@ -122,11 +269,6 @@ public class ResourceBundleProviderIT ex protected abstract void exec() throws Exception; } - @Test - public void test_dummy() { - System.err.println("All tests are disabled for now ...."); - } - @Before public void setup() throws RepositoryException { session = repository.loginAdministrative(null); @@ -183,23 +325,6 @@ public class ResourceBundleProviderIT ex } @Test - public void testRepositoryName() { - final String name = repository.getDescriptor("jcr.repository.name"); - log.info("Test running on {} repository {}", - name, - repository.getDescriptor("jcr.repository.version")); - - // We could use JUnit categories to select tests, as we - // do in our integration tests, but let's avoid a dependency on - // that in this module - if(System.getProperty("sling.run.modes", "").contains("oak")) { - assertEquals("Apache Jackrabbit Oak", name); - } else { - assertEquals("Jackrabbit", name); - } - } - - @Test public void testChangesDetection() throws RepositoryException { // set a key which is only available in the en dictionary new Message("", MSG_KEY2, "EN_message", false).add(enRoot);