Author: cziegeler
Date: Tue Aug 2 11:08:44 2016
New Revision: 1754867
URL: http://svn.apache.org/viewvc?rev=1754867&view=rev
Log:
Update to parent pom 27
Modified:
sling/trunk/bundles/extensions/i18n/pom.xml
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/package-info.java
sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java
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=1754867&r1=1754866&r2=1754867&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/i18n/pom.xml (original)
+++ sling/trunk/bundles/extensions/i18n/pom.xml Tue Aug 2 11:08:44 2016
@@ -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>
Modified:
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java?rev=1754867&r1=1754866&r2=1754867&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
(original)
+++
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/I18NFilter.java
Tue Aug 2 11:08:44 2016
@@ -256,7 +256,7 @@ public class I18NFilter implements Filte
}
@Override
- public Enumeration<?> getLocales() {
+ public Enumeration<Locale> getLocales() {
return Collections.enumeration(getLocaleList());
}
@@ -357,7 +357,7 @@ public class I18NFilter implements Filte
}
@Override
- public Enumeration<?> getLocales() {
+ public Enumeration<Locale> getLocales() {
return Collections.enumeration(getLocaleList());
}
Modified:
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java?rev=1754867&r1=1754866&r2=1754867&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
(original)
+++
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/impl/JcrResourceBundleProvider.java
Tue Aug 2 11:08:44 2016
@@ -41,8 +41,6 @@ import java.util.concurrent.Semaphore;
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.commons.schedule
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 @@ public class JcrResourceBundleProvider i
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 @@ public class JcrResourceBundleProvider i
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 @@ public class JcrResourceBundleProvider i
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 @@ public class JcrResourceBundleProvider i
/**
* 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 @@ public class JcrResourceBundleProvider i
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 @@ public class JcrResourceBundleProvider i
}
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);
}
Modified:
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/package-info.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/package-info.java?rev=1754867&r1=1754866&r2=1754867&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/package-info.java
(original)
+++
sling/trunk/bundles/extensions/i18n/src/main/java/org/apache/sling/i18n/package-info.java
Tue Aug 2 11:08:44 2016
@@ -17,8 +17,7 @@
* under the License.
*/
-@Version("2.2.0")
[email protected]("2.2.0")
package org.apache.sling.i18n;
-import aQute.bnd.annotation.Version;
Modified:
sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java?rev=1754867&r1=1754866&r2=1754867&view=diff
==============================================================================
---
sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java
(original)
+++
sling/trunk/bundles/extensions/i18n/src/test/java/org/apache/sling/i18n/impl/ConcurrentJcrResourceBundleLoadingTest.java
Tue Aug 2 11:08:44 2016
@@ -26,9 +26,9 @@ import static org.powermock.api.mockito.
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.junit.runner.RunWith;
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 @@ public class ConcurrentJcrResourceBundle
@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 @@ public class ConcurrentJcrResourceBundle
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 @@ public class ConcurrentJcrResourceBundle
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 @@ public class ConcurrentJcrResourceBundle
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
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=1754867&r1=1754866&r2=1754867&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
Tue Aug 2 11:08:44 2016
@@ -21,6 +21,7 @@ package org.apache.sling.i18n.it;
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 @@ public class ResourceBundleProviderIT {
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 @@ public class ResourceBundleProviderIT {
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 @@ public class ResourceBundleProviderIT {
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 @@ public class ResourceBundleProviderIT {
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();