Update to parent pom 27
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1754867 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/pom.xml b/pom.xml
index 538d8e2..dc19af9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling</artifactId>
- <version>26</version>
+ <version>27</version>
<relativePath />
</parent>
@@ -71,7 +71,11 @@
jackrabbit-jcr-commons;inline="org/apache/jackrabbit/util/ISO9075.*|org/apache/jackrabbit/util/XMLChar.*|org/apache/jackrabbit/util/Text.*|org/apache/jackrabbit/commons/json/Json*",
org.apache.sling.commons.osgi;inline="org/apache/sling/commons/osgi/ServiceUtil*|org/apache/sling/commons/osgi/PropertiesUtil*"
</Embed-Dependency>
-
+<!--
+ <Require-Capability>
+ osgi.implementation;filter:="(&(osgi.implementation=osgi.http)(version=1.0))"
+ </Require-Capability>
+ -->
</instructions>
</configuration>
</plugin>
@@ -130,6 +134,20 @@
</build>
<dependencies>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.event</artifactId>
+ <version>1.3.1</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
<version>2.2.4</version>
@@ -152,28 +170,11 @@
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.scheduler</artifactId>
<version>2.4.0</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
-
<!-- Testing -->
<dependency>
<groupId>org.apache.sling</groupId>
@@ -186,13 +187,11 @@
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
- <version>2.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
@@ -235,13 +234,13 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
- <version>1.5.0</version>
+ <version>1.7.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
- <version>1.2.13</version>
+ <version>1.2.17</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -271,7 +270,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
- <version>4.2.1</version>
+ <version>5.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java b/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
index d8d7fbf..60c759a 100644
--- a/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
+++ b/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
@@ -256,7 +256,7 @@
}
@Override
- public Enumeration<?> getLocales() {
+ public Enumeration<Locale> getLocales() {
return Collections.enumeration(getLocaleList());
}
@@ -357,7 +357,7 @@
}
@Override
- public Enumeration<?> getLocales() {
+ public Enumeration<Locale> getLocales() {
return Collections.enumeration(getLocaleList());
}
diff --git a/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java b/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
index a034313..f28eac0 100644
--- a/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
+++ b/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
@@ -41,8 +41,6 @@
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.SlingConstants;
import org.apache.sling.api.resource.LoginException;
@@ -56,7 +54,6 @@
import org.apache.sling.i18n.ResourceBundleProvider;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import org.osgi.service.component.ComponentContext;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
@@ -119,7 +116,7 @@
private ResourceResolver resourceResolver;
/**
- * Map of cached resource bundles indexed by a key combined of the base name
+ * Map of cached resource bundles indexed by a key combined of the base name
* and <code>Locale</code> used to load and identify the <code>ResourceBundle</code>.
*/
private final ConcurrentHashMap<Key, JcrResourceBundle> resourceBundleCache = new ConcurrentHashMap<Key, JcrResourceBundle>();
@@ -228,7 +225,7 @@
private boolean isDictionaryResource(final String path, final org.osgi.service.event.Event event) {
// language node changes happen quite frequently (https://issues.apache.org/jira/browse/SLING-2881)
- // therefore only consider changes either for sling:MessageEntry's
+ // therefore only consider changes either for sling:MessageEntry's
// or for JSON dictionaries
String resourceType = (String) event.getProperty(SlingConstants.PROPERTY_RESOURCE_TYPE);
if (resourceType == null) {
@@ -307,7 +304,7 @@
String baseName = bundle.getBaseName();
Locale locale = bundle.getLocale();
final Key key = new Key(baseName, locale);
-
+
// defer this job
ScheduleOptions options = scheduler.AT(new Date(System.currentTimeMillis() + invalidationDelay));
final String jobName = "JcrResourceBundleProvider: reload bundle with key " + key.toString();
@@ -364,11 +361,9 @@
/**
* Activates and configures this component with the repository access
* details and the default locale to use
- * @throws LoginException
+ * @throws LoginException
*/
- protected void activate(ComponentContext context) throws LoginException {
- Dictionary<?, ?> props = context.getProperties();
-
+ protected void activate(BundleContext context, Map<String, Object> props) throws LoginException {
Map<String, Object> repoCredentials;
String user = PropertiesUtil.toString(props.get(PROP_USER), null);
if (user == null || user.length() == 0) {
@@ -386,7 +381,7 @@
this.defaultLocale = toLocale(localeString);
this.preloadBundles = PropertiesUtil.toBoolean(props.get(PROP_PRELOAD_BUNDLES), DEFAULT_PRELOAD_BUNDLES);
- this.bundleContext = context.getBundleContext();
+ this.bundleContext = context;
this.bundleServiceRegistrations = new HashMap<Key, ServiceRegistration>();
invalidationDelay = PropertiesUtil.toLong(props.get(PROP_INVALIDATION_DELAY), DEFAULT_INVALIDATION_DELAY);
if (this.resourceResolverFactory != null) { // this is only null during test execution!
@@ -448,7 +443,7 @@
}
private void registerResourceBundle(Key key, JcrResourceBundle resourceBundle) {
- Dictionary<Object, Object> serviceProps = new Hashtable<Object, Object>();
+ Dictionary<String, Object> serviceProps = new Hashtable<String, Object>();
if (key.baseName != null) {
serviceProps.put("baseName", key.baseName);
}
diff --git a/src/main/java/org/apache/sling/i18n/package-info.java b/src/main/java/org/apache/sling/i18n/package-info.java
index 654c184..a24a548 100644
--- a/src/main/java/org/apache/sling/i18n/package-info.java
+++ b/src/main/java/org/apache/sling/i18n/package-info.java
@@ -17,8 +17,7 @@
* under the License.
*/
-@Version("2.2.0")
+@org.osgi.annotation.versioning.Version("2.2.0")
package org.apache.sling.i18n;
-import aQute.bnd.annotation.Version;
diff --git a/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java b/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java
index 2c7e476..90f862c 100644
--- a/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java
+++ b/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java
@@ -26,9 +26,9 @@
import static org.powermock.api.mockito.PowerMockito.spy;
import static org.powermock.api.mockito.PowerMockito.verifyPrivate;
-import java.util.Hashtable;
+import java.util.HashMap;
import java.util.Locale;
-import java.util.ResourceBundle;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@@ -40,7 +40,6 @@
import org.mockito.Mock;
import org.mockito.Mockito;
import org.osgi.framework.BundleContext;
-import org.osgi.service.component.ComponentContext;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -55,15 +54,15 @@
@Mock JcrResourceBundle english;
@Mock JcrResourceBundle german;
-
+
private JcrResourceBundleProvider provider;
-
+
@Before
public void setup() throws Exception {
provider = spy(new JcrResourceBundleProvider());
- Hashtable<String, Object> properties = new Hashtable<String, Object>();
+ Map<String, Object> properties = new HashMap<String, Object>();
properties.put("locale.default", "en");
- provider.activate(createComponentContext(properties));
+ provider.activate(PowerMockito.mock(BundleContext.class), properties);
doReturn(english).when(provider, "createResourceBundle", eq(null), eq(Locale.ENGLISH));
doReturn(german).when(provider, "createResourceBundle", eq(null), eq(Locale.GERMAN));
Mockito.when(german.getLocale()).thenReturn(Locale.GERMAN);
@@ -100,12 +99,12 @@
verifyPrivate(provider, times(1)).invoke("createResourceBundle", eq(null), eq(Locale.ENGLISH));
verifyPrivate(provider, times(1)).invoke("createResourceBundle", eq(null), eq(Locale.GERMAN));
}
-
+
@Test
public void newBundleUsedAfterReload() throws Exception {
provider.getResourceBundle(Locale.ENGLISH);
provider.getResourceBundle(Locale.GERMAN);
-
+
// reloading german should not reload any other bundle
provider.reloadBundle(new Key(null, Locale.GERMAN));
provider.getResourceBundle(Locale.ENGLISH);
@@ -118,12 +117,12 @@
verifyPrivate(provider, times(1)).invoke("createResourceBundle", eq(null), eq(Locale.ENGLISH));
verifyPrivate(provider, times(2)).invoke("createResourceBundle", eq(null), eq(Locale.GERMAN));
}
-
+
@Test
public void newBundleUsedAsParentAfterReload() throws Exception {
provider.getResourceBundle(Locale.ENGLISH);
provider.getResourceBundle(Locale.GERMAN);
-
+
// reloading english should also reload german (because it has english as a parent)
provider.reloadBundle(new Key(null, Locale.ENGLISH));
provider.getResourceBundle(Locale.ENGLISH);
@@ -136,11 +135,4 @@
verifyPrivate(provider, times(2)).invoke("createResourceBundle", eq(null), eq(Locale.ENGLISH));
verifyPrivate(provider, times(2)).invoke("createResourceBundle", eq(null), eq(Locale.GERMAN));
}
-
- private ComponentContext createComponentContext(Hashtable<String, Object> config) {
- final ComponentContext componentContext = PowerMockito.mock(ComponentContext.class);
- Mockito.when(componentContext.getBundleContext()).thenReturn(PowerMockito.mock(BundleContext.class));
- Mockito.when(componentContext.getProperties()).thenReturn(config);
- return componentContext;
- }
}
\ No newline at end of file
diff --git a/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java b/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java
index 1e2fa25..736b9f3 100644
--- a/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java
+++ b/src/test/java/org/apache/sling/i18n/it/ResourceBundleProviderIT.java
@@ -21,6 +21,7 @@
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.mavenBundle;
import java.io.File;
import java.util.Locale;
@@ -77,7 +78,8 @@
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()))
+ CoreOptions.provision(CoreOptions.bundle(thisProjectsBundle.toURI().toString())),
+ mavenBundle("org.apache.felix", "org.apache.felix.http.servlet-api", "1.1.2")
).getOptions();
}
@@ -142,6 +144,7 @@
private void assertMessages(final String key, final String deMessage, final String deDeMessage, final String frMessage) {
new Retry(RETRY_TIMEOUT_MSEC) {
+ @Override
protected void exec() {
{
final ResourceBundle deDE = resourceBundleProvider.getResourceBundle(Locale.GERMANY); // this is the resource bundle for de_DE
@@ -186,7 +189,7 @@
session.save();
// since "en" is the fallback for all other resource bundle, the value from "en" must be exposed
assertMessages(MSG_KEY2, "EN_message", "EN_message", "EN_message");
-
+
new Message("", MSG_KEY1, "DE_message", false).add(deRoot);
new Message("", MSG_KEY1, "FR_message", false).add(frRoot);
session.save();
@@ -196,13 +199,13 @@
new Message("", MSG_KEY1, "FR_changed", false).add(frRoot);
session.save();
assertMessages(MSG_KEY1, "DE_changed", "DE_changed", "FR_changed");
-
+
new Message("", MSG_KEY1, "DE_message", false).add(deRoot);
new Message("", MSG_KEY1, "DE_DE_message", false).add(deDeRoot);
new Message("", MSG_KEY1, "FR_message", false).add(frRoot);
session.save();
assertMessages(MSG_KEY1, "DE_message", "DE_DE_message", "FR_message");
-
+
// now change a key which is only available in the "en" dictionary
new Message("", MSG_KEY2, "EN_changed", false).add(enRoot);
session.save();