SLING-12284 apply spotless code formatting
diff --git a/core/pom.xml b/core/pom.xml
index b8ce296..23bd28e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -177,9 +177,9 @@
<scope>compile</scope>
</dependency>
<dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- <scope>compile</scope>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ <scope>compile</scope>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
@@ -287,7 +287,7 @@
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-annotation_1.3_spec</artifactId>
- <version>1.0</version>
+ <version>1.0</version>
<scope>test</scope>
</dependency>
@@ -326,7 +326,7 @@
<exclude>src/test/resources/**</exclude>
</excludes>
</configuration>
- </plugin>
+ </plugin>
</plugins>
</build>
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
index 9e6b9ae..b5f74e7 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockAdapterManagerImpl.java
@@ -18,9 +18,6 @@
*/
package org.apache.sling.testing.mock.sling;
-import static org.apache.sling.api.adapter.AdapterFactory.ADAPTABLE_CLASSES;
-import static org.apache.sling.api.adapter.AdapterFactory.ADAPTER_CLASSES;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Dictionary;
@@ -51,19 +48,30 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import static org.apache.sling.api.adapter.AdapterFactory.ADAPTABLE_CLASSES;
+import static org.apache.sling.api.adapter.AdapterFactory.ADAPTER_CLASSES;
+
/**
* This is a copy of org.apache.sling.adapter.internal.AdpaterManagerImpl from Sling Adapter 2.1.6,
* with all calls to SyntheticResource.setAdapterManager/unsetAdapterManager disabled, because this would
* break the {@link ThreadsafeMockAdapterManagerWrapper} concept.
* Additionally the reference to PackageAdmin is disabled.
*/
-@Component(immediate=true, service=AdapterManager.class,
- property={Constants.SERVICE_DESCRIPTION + "=Sling Adapter Manager",
- Constants.SERVICE_VENDOR + "=The Apache Software Foundation"},
- reference = @Reference(name="AdapterFactory", service=AdapterFactory.class,
- cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC,
- bind="bindAdapterFactory", unbind="unbindAdapterFactory")
-)
+@Component(
+ immediate = true,
+ service = AdapterManager.class,
+ property = {
+ Constants.SERVICE_DESCRIPTION + "=Sling Adapter Manager",
+ Constants.SERVICE_VENDOR + "=The Apache Software Foundation"
+ },
+ reference =
+ @Reference(
+ name = "AdapterFactory",
+ service = AdapterFactory.class,
+ cardinality = ReferenceCardinality.MULTIPLE,
+ policy = ReferencePolicy.DYNAMIC,
+ bind = "bindAdapterFactory",
+ unbind = "unbindAdapterFactory"))
public class MockAdapterManagerImpl implements AdapterManager {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -79,7 +87,8 @@
* the manager has been activated. These bound services will be accessed as
* soon as the manager is being activated.
*/
- private final List<ServiceReference<AdapterFactory>> boundAdapterFactories = new LinkedList<ServiceReference<AdapterFactory>>();
+ private final List<ServiceReference<AdapterFactory>> boundAdapterFactories =
+ new LinkedList<ServiceReference<AdapterFactory>>();
/**
* A map of {@link AdapterFactoryDescriptorMap} instances. The map is
@@ -89,7 +98,8 @@
*
* @see AdapterFactoryDescriptorMap
*/
- private final Map<String, AdapterFactoryDescriptorMap> descriptors = new HashMap<String, AdapterFactoryDescriptorMap>();
+ private final Map<String, AdapterFactoryDescriptorMap> descriptors =
+ new HashMap<String, AdapterFactoryDescriptorMap>();
/**
* Matrix of {@link AdapterFactoryDescriptor} instances primarily indexed by the fully
@@ -100,8 +110,8 @@
* {@link #getAdapterFactories(Class)} method. It is cleared
* whenever an adapter factory is registered on unregistered.
*/
- private final ConcurrentMap<String, Map<String, List<AdapterFactoryDescriptor>>> factoryCache
- = new ConcurrentHashMap<String, Map<String, List<AdapterFactoryDescriptor>>>();
+ private final ConcurrentMap<String, Map<String, List<AdapterFactoryDescriptor>>> factoryCache =
+ new ConcurrentHashMap<String, Map<String, List<AdapterFactoryDescriptor>>>();
// DISABLED IN THIS COPY OF CLASS
/*
@@ -119,8 +129,8 @@
*/
@Override
@SuppressWarnings("null")
- public <AdapterType> AdapterType getAdapter(@NotNull final Object adaptable,
- @NotNull final Class<AdapterType> type) {
+ public <AdapterType> AdapterType getAdapter(
+ @NotNull final Object adaptable, @NotNull final Class<AdapterType> type) {
// get the adapter factories for the type of adaptable object
final Map<String, List<AdapterFactoryDescriptor>> factories = getAdapterFactories(adaptable.getClass());
@@ -134,13 +144,11 @@
// have the factory adapt the adaptable if the factory exists
if (factory != null) {
- log.debug("Trying adapter factory {} to map {} to {}",
- new Object [] { factory, adaptable, type });
+ log.debug("Trying adapter factory {} to map {} to {}", new Object[] {factory, adaptable, type});
AdapterType adaptedObject = factory.getAdapter(adaptable, type);
if (adaptedObject != null) {
- log.debug("Using adapter factory {} to map {} to {}",
- new Object [] { factory, adaptable, type });
+ log.debug("Using adapter factory {} to map {} to {}", new Object[] {factory, adaptable, type});
return adaptedObject;
}
}
@@ -165,7 +173,7 @@
// register all adapter factories bound before activation
final List<ServiceReference<AdapterFactory>> refs;
- synchronized ( this.boundAdapterFactories ) {
+ synchronized (this.boundAdapterFactories) {
refs = new ArrayList<ServiceReference<AdapterFactory>>(this.boundAdapterFactories);
boundAdapterFactories.clear();
}
@@ -175,7 +183,7 @@
// final "enable" this manager by setting the instance
// DISABLED IN THIS COPY OF CLASS
- //SyntheticResource.setAdapterManager(this);
+ // SyntheticResource.setAdapterManager(this);
}
/**
@@ -184,7 +192,7 @@
*/
protected void deactivate(final ComponentContext context) {
// DISABLED IN THIS COPY OF CLASS
- //SyntheticResource.unsetAdapterManager(this);
+ // SyntheticResource.unsetAdapterManager(this);
this.context = null;
}
@@ -195,14 +203,14 @@
protected void bindAdapterFactory(final ServiceReference<AdapterFactory> reference) {
boolean create = true;
if (context == null) {
- synchronized ( this.boundAdapterFactories ) {
+ synchronized (this.boundAdapterFactories) {
if (context == null) {
boundAdapterFactories.add(reference);
create = false;
}
}
}
- if ( create ) {
+ if (create) {
registerAdapterFactory(context, reference);
}
}
@@ -242,13 +250,12 @@
* <code>reference</code> from the registry.
*/
@SuppressWarnings("null")
- private void registerAdapterFactory(final ComponentContext context,
- final ServiceReference<AdapterFactory> reference) {
+ private void registerAdapterFactory(
+ final ComponentContext context, final ServiceReference<AdapterFactory> reference) {
final String[] adaptables = PropertiesUtil.toStringArray(reference.getProperty(ADAPTABLE_CLASSES));
final String[] adapters = PropertiesUtil.toStringArray(reference.getProperty(ADAPTER_CLASSES));
- if (adaptables == null || adaptables.length == 0 || adapters == null
- || adapters.length == 0) {
+ if (adaptables == null || adaptables.length == 0 || adapters == null || adapters.length == 0) {
return;
}
@@ -267,19 +274,18 @@
}
*/
- final AdapterFactoryDescriptor factoryDesc = new AdapterFactoryDescriptor(context,
- reference, adapters);
+ final AdapterFactoryDescriptor factoryDesc = new AdapterFactoryDescriptor(context, reference, adapters);
for (final String adaptable : adaptables) {
AdapterFactoryDescriptorMap adfMap = null;
- synchronized ( this.descriptors ) {
+ synchronized (this.descriptors) {
adfMap = descriptors.get(adaptable);
if (adfMap == null) {
adfMap = new AdapterFactoryDescriptorMap();
descriptors.put(adaptable, adfMap);
}
}
- synchronized ( adfMap ) {
+ synchronized (adfMap) {
adfMap.put(reference, factoryDesc);
}
}
@@ -292,11 +298,16 @@
props.put(SlingConstants.PROPERTY_ADAPTABLE_CLASSES, adaptables);
props.put(SlingConstants.PROPERTY_ADAPTER_CLASSES, adapters);
- ServiceRegistration<Adaption> adaptionRegistration = this.context.getBundleContext().registerService(Adaption.class, AdaptionImpl.INSTANCE, props);
+ ServiceRegistration<Adaption> adaptionRegistration =
+ this.context.getBundleContext().registerService(Adaption.class, AdaptionImpl.INSTANCE, props);
if (log.isDebugEnabled()) {
- log.debug("Registered service {} with {} : {} and {} : {}", new Object[] { Adaption.class.getName(),
- SlingConstants.PROPERTY_ADAPTABLE_CLASSES, Arrays.toString(adaptables),
- SlingConstants.PROPERTY_ADAPTER_CLASSES, Arrays.toString(adapters) });
+ log.debug("Registered service {} with {} : {} and {} : {}", new Object[] {
+ Adaption.class.getName(),
+ SlingConstants.PROPERTY_ADAPTABLE_CLASSES,
+ Arrays.toString(adaptables),
+ SlingConstants.PROPERTY_ADAPTER_CLASSES,
+ Arrays.toString(adapters)
+ });
}
factoryDesc.setAdaption(adaptionRegistration);
}
@@ -330,14 +341,13 @@
* <code>reference</code> from the registry.
*/
private void unregisterAdapterFactory(final ServiceReference reference) {
- synchronized ( this.boundAdapterFactories ) {
+ synchronized (this.boundAdapterFactories) {
boundAdapterFactories.remove(reference);
}
final String[] adaptables = PropertiesUtil.toStringArray(reference.getProperty(ADAPTABLE_CLASSES));
final String[] adapters = PropertiesUtil.toStringArray(reference.getProperty(ADAPTER_CLASSES));
- if (adaptables == null || adaptables.length == 0 || adapters == null
- || adapters.length == 0) {
+ if (adaptables == null || adaptables.length == 0 || adapters == null || adapters.length == 0) {
return;
}
@@ -346,19 +356,20 @@
AdapterFactoryDescriptor removedDescriptor = null;
for (final String adaptable : adaptables) {
- synchronized ( this.descriptors ) {
+ synchronized (this.descriptors) {
adfMap = this.descriptors.get(adaptable);
}
if (adfMap != null) {
- synchronized ( adfMap ) {
+ synchronized (adfMap) {
AdapterFactoryDescriptor factoryDesc = adfMap.remove(reference);
if (factoryDesc != null) {
factoriesModified = true;
// A single ServiceReference should correspond to a single Adaption service being registered
// Since the code paths above does not fully guarantee it though, let's keep this check in place
if (removedDescriptor != null && removedDescriptor != factoryDesc) {
- log.error("When unregistering reference {} got duplicate service descriptors {} and {}. Unregistration of {} services may be incomplete.",
- new Object[] { reference, removedDescriptor, factoryDesc, Adaption.class.getName()} );
+ log.error(
+ "When unregistering reference {} got duplicate service descriptors {} and {}. Unregistration of {} services may be incomplete.",
+ new Object[] {reference, removedDescriptor, factoryDesc, Adaption.class.getName()});
}
removedDescriptor = factoryDesc;
}
@@ -376,9 +387,13 @@
if (removedDescriptor != null) {
removedDescriptor.getAdaption().unregister();
if (log.isDebugEnabled()) {
- log.debug("Unregistered service {} with {} : {} and {} : {}", new Object[] { Adaption.class.getName(),
- SlingConstants.PROPERTY_ADAPTABLE_CLASSES, Arrays.toString(adaptables),
- SlingConstants.PROPERTY_ADAPTER_CLASSES, Arrays.toString(adapters) });
+ log.debug("Unregistered service {} with {} : {} and {} : {}", new Object[] {
+ Adaption.class.getName(),
+ SlingConstants.PROPERTY_ADAPTABLE_CLASSES,
+ Arrays.toString(adaptables),
+ SlingConstants.PROPERTY_ADAPTER_CLASSES,
+ Arrays.toString(adapters)
+ });
}
}
}
@@ -423,12 +438,12 @@
// AdapterFactories for this class
AdapterFactoryDescriptorMap afdMap = null;
- synchronized ( this.descriptors ) {
+ synchronized (this.descriptors) {
afdMap = this.descriptors.get(clazz.getName());
}
if (afdMap != null) {
final List<AdapterFactoryDescriptor> afdSet;
- synchronized ( afdMap ) {
+ synchronized (afdMap) {
afdSet = new ArrayList<AdapterFactoryDescriptor>(afdMap.values());
}
for (final AdapterFactoryDescriptor afd : afdSet) {
@@ -472,8 +487,7 @@
* @param clazz The adaptable class whose adapter factories are considered
* for adding into <code>dest</code>.
*/
- private void copyAdapterFactories(final Map<String, List<AdapterFactoryDescriptor>> dest,
- final Class<?> clazz) {
+ private void copyAdapterFactories(final Map<String, List<AdapterFactoryDescriptor>> dest, final Class<?> clazz) {
// get the adapter factories for the adaptable clazz
final Map<String, List<AdapterFactoryDescriptor>> scMap = getAdapterFactories(clazz);
@@ -511,11 +525,10 @@
* signature has changed in adapter impl 2.2.0.
* </p>
*/
- static class AdapterFactoryDescriptorMap extends
- TreeMap<ServiceReference<AdapterFactory>, AdapterFactoryDescriptor> {
+ static class AdapterFactoryDescriptorMap
+ extends TreeMap<ServiceReference<AdapterFactory>, AdapterFactoryDescriptor> {
private static final long serialVersionUID = 2L;
-
}
/**
@@ -549,9 +562,8 @@
}
public AdapterFactory getFactory() {
- if ( factory == null ) {
- factory = context.locateService(
- "AdapterFactory", reference);
+ if (factory == null) {
+ factory = context.locateService("AdapterFactory", reference);
}
return factory;
}
@@ -568,5 +580,4 @@
this.adaption = adaption;
}
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockDynamicClassLoaderManager.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockDynamicClassLoaderManager.java
index 2ec7f15..2a50b44 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockDynamicClassLoaderManager.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockDynamicClassLoaderManager.java
@@ -29,5 +29,4 @@
public ClassLoader getDynamicClassLoader() {
return MockDynamicClassLoaderManager.class.getClassLoader();
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
index d9df564..f986ea3 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockJcrResourceResolverAdapter.java
@@ -36,5 +36,4 @@
public SlingRepository newSlingRepository() {
return new MockJcrSlingRepository();
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepository.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepository.java
index 8104b96..f8dae40 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepository.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepository.java
@@ -96,8 +96,8 @@
}
@Override
- public Session login(final Credentials credentials, final String workspaceName) throws LoginException,
- NoSuchWorkspaceException, RepositoryException {
+ public Session login(final Credentials credentials, final String workspaceName)
+ throws LoginException, NoSuchWorkspaceException, RepositoryException {
return this.repository.login(credentials, workspaceName);
}
@@ -107,8 +107,8 @@
}
@Override
- public Session login(final String workspaceName) throws LoginException, NoSuchWorkspaceException,
- RepositoryException {
+ public Session login(final String workspaceName)
+ throws LoginException, NoSuchWorkspaceException, RepositoryException {
return this.repository.login(workspaceName);
}
@@ -122,5 +122,4 @@
throws LoginException, RepositoryException {
return this.repository.login(credentials);
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
index 05a427c..b7a06e0 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockNoneResourceResolverAdapter.java
@@ -36,5 +36,4 @@
public SlingRepository newSlingRepository() {
return null;
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockResourceBundle.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockResourceBundle.java
index 0a0b1c4..468bd56 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockResourceBundle.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockResourceBundle.java
@@ -55,7 +55,7 @@
@Override
protected Object handleGetObject(String key) {
- return mappings.getOrDefault(key, key);
+ return mappings.getOrDefault(key, key);
}
@Override
@@ -91,5 +91,4 @@
public void putAll(@NotNull Map<? extends String, ? extends String> map) {
mappings.putAll(map);
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockResourceBundleProvider.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockResourceBundleProvider.java
index 8e6418e..d9ded41 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockResourceBundleProvider.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockResourceBundleProvider.java
@@ -99,8 +99,7 @@
return true;
} else if (obj instanceof Key) {
Key other = (Key) obj;
- return equals(this.baseName, other.baseName)
- && equals(this.locale, other.locale);
+ return equals(this.baseName, other.baseName) && equals(this.locale, other.locale);
}
return false;
@@ -122,5 +121,4 @@
return "Key(" + baseName + ", " + locale + ")";
}
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
index fb808b9..378e530 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockSling.java
@@ -44,9 +44,12 @@
/**
* Default resource resolver type is {@link ResourceResolverType#RESOURCERESOLVER_MOCK}.
*/
- public static final @NotNull ResourceResolverType DEFAULT_RESOURCERESOLVER_TYPE = ResourceResolverType.RESOURCERESOLVER_MOCK;
+ public static final @NotNull ResourceResolverType DEFAULT_RESOURCERESOLVER_TYPE =
+ ResourceResolverType.RESOURCERESOLVER_MOCK;
- private static final ThreadsafeMockAdapterManagerWrapper ADAPTER_MANAGER = new ThreadsafeMockAdapterManagerWrapper();
+ private static final ThreadsafeMockAdapterManagerWrapper ADAPTER_MANAGER =
+ new ThreadsafeMockAdapterManagerWrapper();
+
static {
// register mocked adapter manager
SlingAdaptable.setAdapterManager(ADAPTER_MANAGER);
@@ -61,7 +64,8 @@
* @param bundleContext Bundle context
* @return Resource resolver factory instance
*/
- public static @NotNull ResourceResolverFactory newResourceResolverFactory(@NotNull final BundleContext bundleContext) {
+ public static @NotNull ResourceResolverFactory newResourceResolverFactory(
+ @NotNull final BundleContext bundleContext) {
return newResourceResolverFactory(DEFAULT_RESOURCERESOLVER_TYPE, bundleContext);
}
@@ -72,12 +76,14 @@
* @return Resource resolver factory instance
*/
@SuppressWarnings("null")
- public static @NotNull ResourceResolverFactory newResourceResolverFactory(@NotNull final ResourceResolverType type,
- @NotNull final BundleContext bundleContext) {
+ public static @NotNull ResourceResolverFactory newResourceResolverFactory(
+ @NotNull final ResourceResolverType type, @NotNull final BundleContext bundleContext) {
- ServiceReference<ResourceResolverFactory> existingReference = bundleContext.getServiceReference(ResourceResolverFactory.class);
+ ServiceReference<ResourceResolverFactory> existingReference =
+ bundleContext.getServiceReference(ResourceResolverFactory.class);
if (existingReference != null) {
- throw new IllegalStateException("A ResourceResolverFactory is already registered in this BundleContext - please get the existing service instance.");
+ throw new IllegalStateException(
+ "A ResourceResolverFactory is already registered in this BundleContext - please get the existing service instance.");
}
ResourceResolverTypeAdapter adapter = getResourceResolverTypeAdapter(type, bundleContext);
@@ -85,33 +91,37 @@
if (factory == null) {
SlingRepository repository = adapter.newSlingRepository();
factory = ResourceResolverFactoryInitializer.setUp(repository, bundleContext, type.getNodeTypeMode());
- }
- else {
+ } else {
bundleContext.registerService(ResourceResolverFactory.class.getName(), factory, null);
}
return factory;
}
@SuppressWarnings("unchecked")
- private static ResourceResolverTypeAdapter getResourceResolverTypeAdapter(final ResourceResolverType type,
- @NotNull final BundleContext bundleContext) {
+ private static ResourceResolverTypeAdapter getResourceResolverTypeAdapter(
+ final ResourceResolverType type, @NotNull final BundleContext bundleContext) {
try {
Class clazz = Class.forName(type.getResourceResolverTypeAdapterClass());
try {
- Constructor<ResourceResolverTypeAdapter> bundleContextConstructor = clazz.getConstructor(BundleContext.class);
+ Constructor<ResourceResolverTypeAdapter> bundleContextConstructor =
+ clazz.getConstructor(BundleContext.class);
// use constructor with bundle context
return bundleContextConstructor.newInstance(bundleContext);
- }
- catch (NoSuchMethodException ex) {
+ } catch (NoSuchMethodException ex) {
// fallback to default constructor
- return (ResourceResolverTypeAdapter)clazz.newInstance();
+ return (ResourceResolverTypeAdapter) clazz.newInstance();
}
- }
- catch (ClassNotFoundException | InstantiationException | IllegalAccessException | InvocationTargetException ex) {
- throw new RuntimeException("Unable to instantiate resourcer resolver: "
- + type.getResourceResolverTypeAdapterClass()
- + (type.getArtifactCoordinates() != null ? ". Make sure this maven dependency is included: "
- + type.getArtifactCoordinates() : ""), ex);
+ } catch (ClassNotFoundException
+ | InstantiationException
+ | IllegalAccessException
+ | InvocationTargetException ex) {
+ throw new RuntimeException(
+ "Unable to instantiate resourcer resolver: "
+ + type.getResourceResolverTypeAdapterClass()
+ + (type.getArtifactCoordinates() != null
+ ? ". Make sure this maven dependency is included: " + type.getArtifactCoordinates()
+ : ""),
+ ex);
}
}
@@ -122,7 +132,8 @@
* @return Resource resolver instance
*/
@SuppressWarnings("deprecation")
- public static @NotNull ResourceResolver newResourceResolver(@NotNull final ResourceResolverType type, @NotNull BundleContext bundleContext) {
+ public static @NotNull ResourceResolver newResourceResolver(
+ @NotNull final ResourceResolverType type, @NotNull BundleContext bundleContext) {
ResourceResolverFactory factory = newResourceResolverFactory(type, bundleContext);
try {
return factory.getAdministrativeResourceResolver(null);
@@ -148,8 +159,10 @@
* @param bundleContext Bundle context
* @return Sling script helper instance
*/
- public static @NotNull SlingScriptHelper newSlingScriptHelper(@NotNull final SlingHttpServletRequest request,
- @NotNull final SlingHttpServletResponse response, @NotNull final BundleContext bundleContext) {
+ public static @NotNull SlingScriptHelper newSlingScriptHelper(
+ @NotNull final SlingHttpServletRequest request,
+ @NotNull final SlingHttpServletResponse response,
+ @NotNull final BundleContext bundleContext) {
return new MockSlingScriptHelper(request, response, bundleContext);
}
@@ -160,7 +173,8 @@
* @return Sling script helper instance
*/
public static @NotNull SlingScriptHelper newSlingScriptHelper(@NotNull BundleContext bundleContext) {
- SlingHttpServletRequest request = new MockSlingHttpServletRequest(newResourceResolver(bundleContext), bundleContext);
+ SlingHttpServletRequest request =
+ new MockSlingHttpServletRequest(newResourceResolver(bundleContext), bundleContext);
SlingHttpServletResponse response = new MockSlingHttpServletResponse();
return newSlingScriptHelper(request, response, bundleContext);
}
@@ -180,5 +194,4 @@
public static void clearAdapterManagerBundleContext() {
ADAPTER_MANAGER.clearBundleContext();
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockSlingScriptHelper.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockSlingScriptHelper.java
index 7e3fdb9..51497b4 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockSlingScriptHelper.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockSlingScriptHelper.java
@@ -49,7 +49,9 @@
* @param response Sling HTTP servlet response
* @param bundleContext OSGi bundle context
*/
- public MockSlingScriptHelper(@NotNull final SlingHttpServletRequest request, @NotNull final SlingHttpServletResponse response,
+ public MockSlingScriptHelper(
+ @NotNull final SlingHttpServletRequest request,
+ @NotNull final SlingHttpServletResponse response,
@NotNull final BundleContext bundleContext) {
this.request = request;
this.response = response;
@@ -79,10 +81,11 @@
@Override
@SuppressWarnings("unchecked")
- public @Nullable <ServiceType> ServiceType[] getServices(@NotNull final Class<ServiceType> serviceType, final String filter) {
+ public @Nullable <ServiceType> ServiceType[] getServices(
+ @NotNull final Class<ServiceType> serviceType, final String filter) {
try {
- ServiceReference[] serviceReferences = this.bundleContext.getServiceReferences(serviceType.getName(),
- filter);
+ ServiceReference[] serviceReferences =
+ this.bundleContext.getServiceReferences(serviceType.getName(), filter);
if (serviceReferences != null) {
ServiceType[] services = (ServiceType[]) Array.newInstance(serviceType, serviceReferences.length);
for (int i = 0; i < serviceReferences.length; i++) {
@@ -174,5 +177,4 @@
public void include(@NotNull final Resource resource, final RequestDispatcherOptions requestDispatcherOptions) {
throw new UnsupportedOperationException();
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSFilter.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSFilter.java
index 8928507..3803103 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSFilter.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSFilter.java
@@ -47,5 +47,4 @@
public boolean isValidHref(String url) {
return true;
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScanner.java b/core/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScanner.java
index 8783e19..55abc39 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScanner.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScanner.java
@@ -18,14 +18,6 @@
*/
package org.apache.sling.testing.mock.sling;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import javax.jcr.NamespaceRegistry;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -42,6 +34,14 @@
import javax.jcr.nodetype.PropertyDefinition;
import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.apache.jackrabbit.commons.cnd.CompactNodeTypeDefReader;
import org.apache.jackrabbit.commons.cnd.DefinitionBuilderFactory;
import org.apache.jackrabbit.commons.cnd.TemplateBuilderFactory;
@@ -80,8 +80,8 @@
* @throws RepositoryException Repository exception
*/
public void register(Session session, NodeTypeMode nodeTypeMode) throws RepositoryException {
- List<String> nodeTypeResources = getNodeTypeDefinitions();
- register(session, nodeTypeResources, nodeTypeMode);
+ List<String> nodeTypeResources = getNodeTypeDefinitions();
+ register(session, nodeTypeResources, nodeTypeMode);
}
/**
@@ -91,20 +91,21 @@
* @param nodeTypeMode Node type mode
* @throws RepositoryException Repository exception
*/
- public void register(Session session, List<String> nodeTypeResources, NodeTypeMode nodeTypeMode) throws RepositoryException {
- switch (nodeTypeMode) {
- case NOT_SUPPORTED:
- // do nothing
- break;
- case NAMESPACES_ONLY:
- registerNamespaces(session, nodeTypeResources);
- break;
- case NODETYPES_REQUIRED:
- registerNodeTypes(session, nodeTypeResources);
- break;
- default:
- throw new IllegalArgumentException("Node type mode not supported: " + nodeTypeMode);
- }
+ public void register(Session session, List<String> nodeTypeResources, NodeTypeMode nodeTypeMode)
+ throws RepositoryException {
+ switch (nodeTypeMode) {
+ case NOT_SUPPORTED:
+ // do nothing
+ break;
+ case NAMESPACES_ONLY:
+ registerNamespaces(session, nodeTypeResources);
+ break;
+ case NODETYPES_REQUIRED:
+ registerNodeTypes(session, nodeTypeResources);
+ break;
+ default:
+ throw new IllegalArgumentException("Node type mode not supported: " + nodeTypeMode);
+ }
}
/**
@@ -118,34 +119,31 @@
NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
ValueFactory valueFactory = session.getValueFactory();
- DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> factory =
- new TemplateBuilderFactory(new DummyNodeTypeManager(), valueFactory, namespaceRegistry);
+ DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> factory =
+ new TemplateBuilderFactory(new DummyNodeTypeManager(), valueFactory, namespaceRegistry);
- for (String nodeTypeResource : nodeTypeResources) {
- try (InputStream is = classLoader.getResourceAsStream(nodeTypeResource)) {
- if (is == null) {
- continue;
- }
- Reader reader = new InputStreamReader(is);
- CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry> cndReader
- = new CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry>(reader, nodeTypeResource, factory);
- NamespaceRegistry mapping = cndReader.getNamespaceMapping();
- for (int i=0; i<mapping.getURIs().length; i++) {
- String uri = mapping.getURIs()[i];
- String prefix = mapping.getPrefix(uri);
- try {
- namespaceRegistry.registerNamespace(prefix, uri);
- }
- catch (RepositoryException ex) {
- // ignore
- }
- }
- }
- catch (Throwable ex) {
- log.warn("Unable to parse node type definition: " + nodeTypeResource, ex);
- }
- }
-
+ for (String nodeTypeResource : nodeTypeResources) {
+ try (InputStream is = classLoader.getResourceAsStream(nodeTypeResource)) {
+ if (is == null) {
+ continue;
+ }
+ Reader reader = new InputStreamReader(is);
+ CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry> cndReader = new CompactNodeTypeDefReader<
+ NodeTypeTemplate, NamespaceRegistry>(reader, nodeTypeResource, factory);
+ NamespaceRegistry mapping = cndReader.getNamespaceMapping();
+ for (int i = 0; i < mapping.getURIs().length; i++) {
+ String uri = mapping.getURIs()[i];
+ String prefix = mapping.getPrefix(uri);
+ try {
+ namespaceRegistry.registerNamespace(prefix, uri);
+ } catch (RepositoryException ex) {
+ // ignore
+ }
+ }
+ } catch (Throwable ex) {
+ log.warn("Unable to parse node type definition: " + nodeTypeResource, ex);
+ }
+ }
}
/**
@@ -154,20 +152,20 @@
* @param nodeTypeResources List of classpath resource URLs pointing to node type definitions
*/
private void registerNodeTypes(Session session, List<String> nodeTypeResources) throws RepositoryException {
- ClassLoader classLoader = getClass().getClassLoader();
- Workspace workspace = session.getWorkspace();
- NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
- NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
- ValueFactory valueFactory = session.getValueFactory();
- DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> factory =
- new TemplateBuilderFactory(nodeTypeManager, valueFactory, namespaceRegistry);
+ ClassLoader classLoader = getClass().getClassLoader();
+ Workspace workspace = session.getWorkspace();
+ NodeTypeManager nodeTypeManager = workspace.getNodeTypeManager();
+ NamespaceRegistry namespaceRegistry = workspace.getNamespaceRegistry();
+ ValueFactory valueFactory = session.getValueFactory();
+ DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> factory =
+ new TemplateBuilderFactory(nodeTypeManager, valueFactory, namespaceRegistry);
- Map<String, NodeTypeTemplate> nodeTypes = new HashMap<>();
- for (String resource : nodeTypeResources) {
- nodeTypes.putAll(parseNodeTypesFromResource(resource, classLoader, factory));
- }
+ Map<String, NodeTypeTemplate> nodeTypes = new HashMap<>();
+ for (String resource : nodeTypeResources) {
+ nodeTypes.putAll(parseNodeTypesFromResource(resource, classLoader, factory));
+ }
- nodeTypeManager.registerNodeTypes(nodeTypes.values().toArray(new NodeTypeTemplate[0]), true);
+ nodeTypeManager.registerNodeTypes(nodeTypes.values().toArray(new NodeTypeTemplate[0]), true);
}
/**
@@ -177,14 +175,16 @@
* @param factory The factory to build node type definitions with.
* @return A mapping from node type names to node type definitions.
*/
- private Map<String, NodeTypeTemplate> parseNodeTypesFromResource(String resource, ClassLoader classLoader,
+ private Map<String, NodeTypeTemplate> parseNodeTypesFromResource(
+ String resource,
+ ClassLoader classLoader,
DefinitionBuilderFactory<NodeTypeTemplate, NamespaceRegistry> factory) {
try (InputStream is = classLoader.getResourceAsStream(resource)) {
if (is == null) {
return Map.of();
}
CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry> cndReader =
- new CompactNodeTypeDefReader<>(new InputStreamReader(is), resource, factory);
+ new CompactNodeTypeDefReader<>(new InputStreamReader(is), resource, factory);
Map<String, NodeTypeTemplate> result = new HashMap<>();
for (NodeTypeTemplate template : cndReader.getNodeTypeDefinitions()) {
result.put(template.getName(), template);
@@ -214,7 +214,6 @@
return SINGLETON;
}
-
/**
* Some dummy classes to allow usage of CompactNodeTypeDefReader with underlying JCR mock
*/
@@ -223,52 +222,62 @@
public NodeType getNodeType(String nodeTypeName) {
return null;
}
+
@Override
public boolean hasNodeType(String name) {
return false;
}
+
@Override
public NodeTypeIterator getAllNodeTypes() {
return null;
}
+
@Override
public NodeTypeIterator getPrimaryNodeTypes() {
return null;
}
+
@Override
public NodeTypeIterator getMixinNodeTypes() {
return null;
}
+
@Override
public NodeTypeTemplate createNodeTypeTemplate() {
return new DummyNodeTypeTemplate();
}
+
@Override
public NodeTypeTemplate createNodeTypeTemplate(NodeTypeDefinition ntd) {
return new DummyNodeTypeTemplate();
}
+
@Override
public NodeDefinitionTemplate createNodeDefinitionTemplate() {
return new DummyNodeDefinitionTemplate();
}
+
@Override
public PropertyDefinitionTemplate createPropertyDefinitionTemplate() {
return new DummyPropertyDefinitionTemplate();
}
+
@Override
public NodeType registerNodeType(NodeTypeDefinition ntd, boolean allowUpdate) {
return null;
}
+
@Override
public NodeTypeIterator registerNodeTypes(NodeTypeDefinition[] ntds, boolean allowUpdate) {
return null;
}
+
@Override
- public void unregisterNodeType(String name) {
- }
+ public void unregisterNodeType(String name) {}
+
@Override
- public void unregisterNodeTypes(String[] names) {
- }
+ public void unregisterNodeTypes(String[] names) {}
}
private static class DummyNodeTypeTemplate implements NodeTypeTemplate {
@@ -276,63 +285,73 @@
public String getName() {
return null;
}
+
@Override
public String[] getDeclaredSupertypeNames() {
return null;
}
+
@Override
public boolean isAbstract() {
return false;
}
+
@Override
public boolean isMixin() {
return false;
}
+
@Override
public boolean hasOrderableChildNodes() {
return false;
}
+
@Override
public boolean isQueryable() {
return false;
}
+
@Override
public String getPrimaryItemName() {
return null;
}
+
@Override
public PropertyDefinition[] getDeclaredPropertyDefinitions() {
return null;
}
+
@Override
public NodeDefinition[] getDeclaredChildNodeDefinitions() {
return null;
}
+
@Override
- public void setName(String name) {
- }
+ public void setName(String name) {}
+
@Override
- public void setDeclaredSuperTypeNames(String[] names) {
- }
+ public void setDeclaredSuperTypeNames(String[] names) {}
+
@Override
- public void setAbstract(boolean abstractStatus) {
- }
+ public void setAbstract(boolean abstractStatus) {}
+
@Override
- public void setMixin(boolean mixin) {
- }
+ public void setMixin(boolean mixin) {}
+
@Override
- public void setOrderableChildNodes(boolean orderable) {
- }
+ public void setOrderableChildNodes(boolean orderable) {}
+
@Override
- public void setPrimaryItemName(String name) {
- }
+ public void setPrimaryItemName(String name) {}
+
@Override
- public void setQueryable(boolean queryable) {
- }
+ public void setQueryable(boolean queryable) {}
+
@Override
public List getPropertyDefinitionTemplates() {
return new ArrayList();
}
+
@Override
public List getNodeDefinitionTemplates() {
return new ArrayList();
@@ -344,70 +363,80 @@
public NodeType[] getRequiredPrimaryTypes() {
return null;
}
+
@Override
public String[] getRequiredPrimaryTypeNames() {
return null;
}
+
@Override
public NodeType getDefaultPrimaryType() {
return null;
}
+
@Override
public String getDefaultPrimaryTypeName() {
return null;
}
+
@Override
public boolean allowsSameNameSiblings() {
return false;
}
+
@Override
public NodeType getDeclaringNodeType() {
return null;
}
+
@Override
public String getName() {
return null;
}
+
@Override
public boolean isAutoCreated() {
return false;
}
+
@Override
public boolean isMandatory() {
return false;
}
+
@Override
public int getOnParentVersion() {
return 0;
}
+
@Override
public boolean isProtected() {
return false;
}
+
@Override
- public void setName(String name) {
- }
+ public void setName(String name) {}
+
@Override
- public void setAutoCreated(boolean autoCreated) {
- }
+ public void setAutoCreated(boolean autoCreated) {}
+
@Override
- public void setMandatory(boolean mandatory) {
- }
+ public void setMandatory(boolean mandatory) {}
+
@Override
- public void setOnParentVersion(int opv) {
- }
+ public void setOnParentVersion(int opv) {}
+
@Override
- public void setProtected(boolean protectedStatus) {
- }
+ public void setProtected(boolean protectedStatus) {}
+
@Override
- public void setRequiredPrimaryTypeNames(String[] names) {
- }
+ public void setRequiredPrimaryTypeNames(String[] names) {}
+
@Override
- public void setDefaultPrimaryTypeName(String name) {
- }
+ public void setDefaultPrimaryTypeName(String name) {}
+
@Override
- public void setSameNameSiblings(boolean allowSameNameSiblings) {
- }
+ public void setSameNameSiblings(boolean allowSameNameSiblings) {}
}
private static class DummyPropertyDefinitionTemplate implements PropertyDefinitionTemplate {
@@ -415,90 +444,101 @@
public int getRequiredType() {
return 0;
}
+
@Override
public String[] getValueConstraints() {
return null;
}
+
@Override
public Value[] getDefaultValues() {
return null;
}
+
@Override
public boolean isMultiple() {
return false;
}
+
@Override
public String[] getAvailableQueryOperators() {
return null;
}
+
@Override
public boolean isFullTextSearchable() {
return false;
}
+
@Override
public boolean isQueryOrderable() {
return false;
}
+
@Override
public NodeType getDeclaringNodeType() {
return null;
}
+
@Override
public String getName() {
return null;
}
+
@Override
public boolean isAutoCreated() {
return false;
}
+
@Override
public boolean isMandatory() {
return false;
}
+
@Override
public int getOnParentVersion() {
return 0;
}
+
@Override
public boolean isProtected() {
return false;
}
- @Override
- public void setName(String name) {
- }
- @Override
- public void setAutoCreated(boolean autoCreated) {
- }
- @Override
- public void setMandatory(boolean mandatory) {
- }
- @Override
- public void setOnParentVersion(int opv) {
- }
- @Override
- public void setProtected(boolean protectedStatus) {
- }
- @Override
- public void setRequiredType(int type) {
- }
- @Override
- public void setValueConstraints(String[] constraints) {
- }
- @Override
- public void setDefaultValues(Value[] defaultValues) {
- }
- @Override
- public void setMultiple(boolean multiple) {
- }
- @Override
- public void setAvailableQueryOperators(String[] operators) {
- }
- @Override
- public void setFullTextSearchable(boolean fullTextSearchable) {
- }
- @Override
- public void setQueryOrderable(boolean queryOrderable) {
- }
- }
+ @Override
+ public void setName(String name) {}
+
+ @Override
+ public void setAutoCreated(boolean autoCreated) {}
+
+ @Override
+ public void setMandatory(boolean mandatory) {}
+
+ @Override
+ public void setOnParentVersion(int opv) {}
+
+ @Override
+ public void setProtected(boolean protectedStatus) {}
+
+ @Override
+ public void setRequiredType(int type) {}
+
+ @Override
+ public void setValueConstraints(String[] constraints) {}
+
+ @Override
+ public void setDefaultValues(Value[] defaultValues) {}
+
+ @Override
+ public void setMultiple(boolean multiple) {}
+
+ @Override
+ public void setAvailableQueryOperators(String[] operators) {}
+
+ @Override
+ public void setFullTextSearchable(boolean fullTextSearchable) {}
+
+ @Override
+ public void setQueryOrderable(boolean queryOrderable) {}
+ }
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeMode.java b/core/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeMode.java
index 9b60bdc..7fc3581 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeMode.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/NodeTypeMode.java
@@ -37,5 +37,4 @@
* Nodetypes including namespaces have to be registered.
*/
NODETYPES_REQUIRED
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/RPMockMockResourceResolverAdapter.java b/core/src/main/java/org/apache/sling/testing/mock/sling/RPMockMockResourceResolverAdapter.java
index 50a140c..1b43cd9 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/RPMockMockResourceResolverAdapter.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/RPMockMockResourceResolverAdapter.java
@@ -47,5 +47,4 @@
public SlingRepository newSlingRepository() {
return null;
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java b/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
index 1b5388a..929a6e3 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/RRMockMockResourceResolverAdapter.java
@@ -49,5 +49,4 @@
public SlingRepository newSlingRepository() {
return null;
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java b/core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
index b185770..b7296b6 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverFactoryInitializer.java
@@ -18,14 +18,14 @@
*/
package org.apache.sling.testing.mock.sling;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
import java.lang.reflect.Field;
import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
import org.apache.sling.jcr.api.SlingRepository;
@@ -63,8 +63,10 @@
* @param bundleContext Bundle context
*/
@SuppressWarnings("null")
- public static @NotNull ResourceResolverFactory setUp(@Nullable SlingRepository slingRepository,
- @NotNull BundleContext bundleContext, @NotNull NodeTypeMode nodeTypeMode) {
+ public static @NotNull ResourceResolverFactory setUp(
+ @Nullable SlingRepository slingRepository,
+ @NotNull BundleContext bundleContext,
+ @NotNull NodeTypeMode nodeTypeMode) {
if (slingRepository != null) {
// register sling repository as OSGi service
@@ -82,7 +84,8 @@
ensureResourceResolverFactoryActivatorDependencies(bundleContext);
initializeResourceResolverFactoryActivator(bundleContext);
- ServiceReference<ResourceResolverFactory> factoryRef = bundleContext.getServiceReference(ResourceResolverFactory.class);
+ ServiceReference<ResourceResolverFactory> factoryRef =
+ bundleContext.getServiceReference(ResourceResolverFactory.class);
if (factoryRef == null) {
throw new IllegalStateException("Unable to get ResourceResolverFactory.");
}
@@ -106,15 +109,19 @@
try {
Field pathMapperLoggerField = pathMapperClass.getDeclaredField("log");
pathMapperLoggerField.setAccessible(true);
- pathMapperLoggerField.set(pathMapper, Proxy.newProxyInstance(Logger.class.getClassLoader(),
- new Class[] { Logger.class },
- (proxy, method, methodArgs) -> { return null; }));
+ pathMapperLoggerField.set(
+ pathMapper,
+ Proxy.newProxyInstance(
+ Logger.class.getClassLoader(),
+ new Class[] {Logger.class},
+ (proxy, method, methodArgs) -> {
+ return null;
+ }));
} catch (Exception ex) {
// ignore
}
registerServiceIfNotPresent(bundleContext, pathMapperClass, pathMapper);
- }
- catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
// ignore - service was removed in org.apache.sling.jcr.resource 3.0.0
}
}
@@ -137,10 +144,13 @@
config.put("user.mapping", bundleContext.getBundle().getSymbolicName() + "=[admin]");
registerServiceIfNotPresent(bundleContext, ServiceUserMapper.class, ServiceUserMapperImpl.class, config);
- registerServiceIfNotPresent(bundleContext, ResourceAccessSecurityTracker.class, ResourceAccessSecurityTracker.class);
+ registerServiceIfNotPresent(
+ bundleContext, ResourceAccessSecurityTracker.class, ResourceAccessSecurityTracker.class);
registerServiceIfNotPresent(bundleContext, EventAdmin.class, MockEventAdmin.class);
// dependency required since resourceresolver 1.7.0
- registerServiceIfNotPresentByName(bundleContext, "org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProvider",
+ registerServiceIfNotPresentByName(
+ bundleContext,
+ "org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProvider",
"org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProviderImpl");
}
@@ -164,22 +174,27 @@
Thread.currentThread().interrupt();
}
if (System.currentTimeMillis() - startTime > RESOURCERESOLVER_FACTORY_ACTIVATOR_TIMEOUT_MS) {
- throw new IllegalStateException("ResourceResolverFactoryActivator did not register a ResourceResolverFactory after "
- + RESOURCERESOLVER_FACTORY_ACTIVATOR_TIMEOUT_MS + "ms.");
+ throw new IllegalStateException(
+ "ResourceResolverFactoryActivator did not register a ResourceResolverFactory after "
+ + RESOURCERESOLVER_FACTORY_ACTIVATOR_TIMEOUT_MS + "ms.");
}
}
}
- @SuppressWarnings({ "unchecked", "null" })
- private static void registerServiceIfNotPresentByName(@NotNull BundleContext bundleContext,
- @NotNull String interfaceClassName, @NotNull String implClassName) {
+ @SuppressWarnings({"unchecked", "null"})
+ private static void registerServiceIfNotPresentByName(
+ @NotNull BundleContext bundleContext, @NotNull String interfaceClassName, @NotNull String implClassName) {
try {
Class<?> interfaceClass = Class.forName(interfaceClassName);
Class<?> implClass = Class.forName(implClassName);
- registerServiceIfNotPresent(bundleContext, (Class)interfaceClass, implClass.newInstance());
+ registerServiceIfNotPresent(bundleContext, (Class) interfaceClass, implClass.newInstance());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
// ignore - probably not the latest sling models impl version
- log.debug("registerServiceIfNotPresentByName: Skip registering {} ({}), bundleContext={}", implClassName, interfaceClassName, bundleContext);
+ log.debug(
+ "registerServiceIfNotPresentByName: Skip registering {} ({}), bundleContext={}",
+ implClassName,
+ interfaceClassName,
+ bundleContext);
}
}
@@ -190,8 +205,8 @@
* @param serviceClass Service class
* @param instance Service instance
*/
- private static <T> void registerServiceIfNotPresent(@NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass,
- @NotNull T instance) {
+ private static <T> void registerServiceIfNotPresent(
+ @NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass, @NotNull T instance) {
registerServiceIfNotPresent(bundleContext, serviceClass, instance, new HashMap<>());
}
@@ -203,13 +218,19 @@
* @param instance Service instance
* @param config OSGi config
*/
- private static <T> void registerServiceIfNotPresent(@NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass,
- @NotNull T instance, Map<String, Object> config) {
+ private static <T> void registerServiceIfNotPresent(
+ @NotNull BundleContext bundleContext,
+ @NotNull Class<T> serviceClass,
+ @NotNull T instance,
+ Map<String, Object> config) {
if (bundleContext.getServiceReference(serviceClass.getName()) == null) {
MockOsgi.registerInjectActivateService(instance, bundleContext, config);
- }
- else if (log.isDebugEnabled()) {
- log.debug("registerServiceIfNotPresent: Skip registering {} ({}) because already present, bundleContext={}", instance.getClass(), serviceClass, bundleContext);
+ } else if (log.isDebugEnabled()) {
+ log.debug(
+ "registerServiceIfNotPresent: Skip registering {} ({}) because already present, bundleContext={}",
+ instance.getClass(),
+ serviceClass,
+ bundleContext);
}
}
@@ -220,8 +241,8 @@
* @param serviceClass Service class
* @param implClass Implementation class
*/
- private static <T> void registerServiceIfNotPresent(@NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass,
- @NotNull Class<?> implClass) {
+ private static <T> void registerServiceIfNotPresent(
+ @NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass, @NotNull Class<?> implClass) {
registerServiceIfNotPresent(bundleContext, serviceClass, implClass, new HashMap<>());
}
@@ -233,8 +254,11 @@
* @param implClass Implementation class
* @param config OSGi config
*/
- private static <T> void registerServiceIfNotPresent(@NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass,
- @NotNull Class<?> implClass, Map<String, Object> config) {
+ private static <T> void registerServiceIfNotPresent(
+ @NotNull BundleContext bundleContext,
+ @NotNull Class<T> serviceClass,
+ @NotNull Class<?> implClass,
+ Map<String, Object> config) {
if (bundleContext.getServiceReference(serviceClass.getName()) == null) {
MockOsgi.registerInjectActivateService(implClass, bundleContext, config);
}
@@ -245,21 +269,17 @@
* @param slingRepository Sling repository
*/
@SuppressWarnings("deprecation")
- private static void registerJcrNodeTypes(final SlingRepository slingRepository,
- final NodeTypeMode nodeTypeMode) {
- Session session = null;
- try {
- session = slingRepository.loginAdministrative(null);
- NodeTypeDefinitionScanner.get().register(session, nodeTypeMode);
- }
- catch (RepositoryException ex) {
- throw new RuntimeException("Error registering JCR nodetypes: " + ex.getMessage(), ex);
- }
- finally {
- if (session != null) {
- session.logout();
- }
- }
+ private static void registerJcrNodeTypes(final SlingRepository slingRepository, final NodeTypeMode nodeTypeMode) {
+ Session session = null;
+ try {
+ session = slingRepository.loginAdministrative(null);
+ NodeTypeDefinitionScanner.get().register(session, nodeTypeMode);
+ } catch (RepositoryException ex) {
+ throw new RuntimeException("Error registering JCR nodetypes: " + ex.getMessage(), ex);
+ } finally {
+ if (session != null) {
+ session.logout();
+ }
+ }
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java b/core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java
index e715829..080f618 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/ResourceResolverType.java
@@ -74,8 +74,10 @@
* <li>The <code>MemoryNodeStore</code> implementation is used, with no customizations.</li>
* </ul>
*/
- JCR_OAK("org.apache.sling.testing.mock.sling.oak.OakMockResourceResolverAdapter",
- "org.apache.sling:org.apache.sling.testing.sling-mock-oak", NodeTypeMode.NODETYPES_REQUIRED),
+ JCR_OAK(
+ "org.apache.sling.testing.mock.sling.oak.OakMockResourceResolverAdapter",
+ "org.apache.sling:org.apache.sling.testing.sling-mock-oak",
+ NodeTypeMode.NODETYPES_REQUIRED),
/**
* Provides resource resolver environment without any ResourceProvider.
@@ -87,13 +89,12 @@
*/
NONE(MockNoneResourceResolverAdapter.class.getName(), null, NodeTypeMode.NOT_SUPPORTED);
-
private final @NotNull String resourceResolverTypeAdapterClass;
private final @NotNull String artifactCoordinates;
private final @NotNull NodeTypeMode nodeTypeMode;
-
- private ResourceResolverType(@NotNull final String resourceResolverTypeAdapterClass,
+ private ResourceResolverType(
+ @NotNull final String resourceResolverTypeAdapterClass,
@NotNull final String artifactCoordinates,
@NotNull final NodeTypeMode nodeTypeMode) {
this.resourceResolverTypeAdapterClass = resourceResolverTypeAdapterClass;
@@ -101,11 +102,13 @@
this.nodeTypeMode = nodeTypeMode;
}
- @NotNull String getResourceResolverTypeAdapterClass() {
+ @NotNull
+ String getResourceResolverTypeAdapterClass() {
return this.resourceResolverTypeAdapterClass;
}
- @NotNull String getArtifactCoordinates() {
+ @NotNull
+ String getArtifactCoordinates() {
return this.artifactCoordinates;
}
@@ -115,5 +118,4 @@
public @NotNull NodeTypeMode getNodeTypeMode() {
return nodeTypeMode;
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java b/core/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java
index 36c17b4..f038591 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/ThreadsafeMockAdapterManagerWrapper.java
@@ -40,15 +40,16 @@
private static final InheritableThreadLocal<AdapterManagerBundleContextFactory> THREAD_LOCAL =
new InheritableThreadLocal<AdapterManagerBundleContextFactory>() {
- @Override
- protected AdapterManagerBundleContextFactory initialValue() {
- return new AdapterManagerBundleContextFactory();
- }
- };
+ @Override
+ protected AdapterManagerBundleContextFactory initialValue() {
+ return new AdapterManagerBundleContextFactory();
+ }
+ };
@Override
@SuppressWarnings("null")
- public <AdapterType> AdapterType getAdapter(@NotNull final Object adaptable, @NotNull final Class<AdapterType> type) {
+ public <AdapterType> AdapterType getAdapter(
+ @NotNull final Object adaptable, @NotNull final Class<AdapterType> type) {
AdapterManager adapterManager = THREAD_LOCAL.get().getAdapterManager();
return adapterManager.getAdapter(adaptable, type);
}
@@ -70,7 +71,6 @@
adapterManager.clearBundleContext();
}
-
private static class AdapterManagerBundleContextFactory {
private BundleContext bundleContext;
@@ -81,7 +81,7 @@
// register adapter manager
MockAdapterManagerImpl adapterManagerImpl = new MockAdapterManagerImpl();
- Dictionary<String,Object> properties = new Hashtable<String, Object>();
+ Dictionary<String, Object> properties = new Hashtable<String, Object>();
MockOsgi.injectServices(adapterManagerImpl, bundleContext);
MockOsgi.activate(adapterManagerImpl, bundleContext, properties);
bundleContext.registerService(AdapterManager.class.getName(), adapterManagerImpl, properties);
@@ -95,18 +95,17 @@
public synchronized AdapterManager getAdapterManager() {
if (bundleContext == null) {
BundleContext newBundleContext = MockOsgi.newBundleContext();
- log.warn("Create new bundle context for adapter manager because it was null, bundleContext={}", bundleContext);
+ log.warn(
+ "Create new bundle context for adapter manager because it was null, bundleContext={}",
+ bundleContext);
setBundleContext(newBundleContext);
}
ServiceReference<AdapterManager> serviceReference = bundleContext.getServiceReference(AdapterManager.class);
if (serviceReference != null) {
return bundleContext.getService(serviceReference);
- }
- else {
+ } else {
throw new RuntimeException("AdapterManager not registered in bundle context.");
}
}
-
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/builder/ContentBuilder.java b/core/src/main/java/org/apache/sling/testing/mock/sling/builder/ContentBuilder.java
index 70eb613..e355ec8 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/builder/ContentBuilder.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/builder/ContentBuilder.java
@@ -76,8 +76,8 @@
}
// check if properties map contains maps representing child resources
- Map<String,Object> propertiesWihtoutChildren;
- Map<String,Map<String,Object>> children = getChildMaps(properties);
+ Map<String, Object> propertiesWihtoutChildren;
+ Map<String, Map<String, Object>> children = getChildMaps(properties);
if (!children.isEmpty()) {
propertiesWihtoutChildren = new HashMap<>();
for (Map.Entry<String, Object> entry : properties.entrySet()) {
@@ -85,8 +85,7 @@
propertiesWihtoutChildren.put(entry.getKey(), entry.getValue());
}
}
- }
- else {
+ } else {
propertiesWihtoutChildren = properties;
}
@@ -101,7 +100,7 @@
}
// create child resources
- for (Map.Entry<String,Map<String,Object>> entry : children.entrySet()) {
+ for (Map.Entry<String, Map<String, Object>> entry : children.entrySet()) {
resource(newResource, entry.getKey(), entry.getValue());
}
@@ -109,11 +108,11 @@
}
@SuppressWarnings("unchecked")
- private Map<String,Map<String,Object>> getChildMaps(Map<String,Object> properties) {
- Map<String,Map<String,Object>> result = new LinkedHashMap<>();
+ private Map<String, Map<String, Object>> getChildMaps(Map<String, Object> properties) {
+ Map<String, Map<String, Object>> result = new LinkedHashMap<>();
for (Map.Entry<String, Object> entry : properties.entrySet()) {
if (entry.getValue() instanceof Map) {
- result.put(entry.getKey(), (Map)entry.getValue());
+ result.put(entry.getKey(), (Map) entry.getValue());
}
}
return result;
@@ -147,7 +146,8 @@
* @param properties Properties for resource.
* @return Resource object
*/
- public final @NotNull Resource resource(@NotNull Resource resource, @NotNull String name, @NotNull Map<String, Object> properties) {
+ public final @NotNull Resource resource(
+ @NotNull Resource resource, @NotNull String name, @NotNull Map<String, Object> properties) {
String path = resource.getPath() + "/" + StringUtils.stripStart(name, "/");
return resource(path, properties);
}
@@ -159,7 +159,8 @@
* @param properties Properties for resource.
* @return Resource object
*/
- public final @NotNull Resource resource(@NotNull Resource resource, @NotNull String name, @NotNull Object @NotNull ... properties) {
+ public final @NotNull Resource resource(
+ @NotNull Resource resource, @NotNull String name, @NotNull Object @NotNull ... properties) {
return resource(resource, name, MapUtil.toMap(properties));
}
@@ -185,7 +186,9 @@
String name = ResourceUtil.getName(path);
Resource parentResource = ensureResourceExists(parentPath);
try {
- resource = resourceResolver.create(parentResource, name,
+ resource = resourceResolver.create(
+ parentResource,
+ name,
ImmutableValueMap.of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_UNSTRUCTURED));
resourceResolver.commit();
return resource;
@@ -193,5 +196,4 @@
throw new RuntimeException("Unable to create resource at " + path, ex);
}
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/builder/ImmutableValueMap.java b/core/src/main/java/org/apache/sling/testing/mock/sling/builder/ImmutableValueMap.java
index e94c6bc..af17326 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/builder/ImmutableValueMap.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/builder/ImmutableValueMap.java
@@ -198,8 +198,8 @@
* @return ImmutableValueMap
* @throws IllegalArgumentException if duplicate keys are provided
*/
- public static @NotNull ImmutableValueMap of(@NotNull String k1, @NotNull Object v1, @NotNull String k2,
- @NotNull Object v2) {
+ public static @NotNull ImmutableValueMap of(
+ @NotNull String k1, @NotNull Object v1, @NotNull String k2, @NotNull Object v2) {
Map<String, Object> map = new HashMap<>();
map.put(k1, v1);
map.put(k2, v2);
@@ -217,8 +217,13 @@
* @return ImmutableValueMap
* @throws IllegalArgumentException if duplicate keys are provided
*/
- public static @NotNull ImmutableValueMap of(@NotNull String k1, @NotNull Object v1, @NotNull String k2,
- @NotNull Object v2, @NotNull String k3, @NotNull Object v3) {
+ public static @NotNull ImmutableValueMap of(
+ @NotNull String k1,
+ @NotNull Object v1,
+ @NotNull String k2,
+ @NotNull Object v2,
+ @NotNull String k3,
+ @NotNull Object v3) {
Map<String, Object> map = new HashMap<>();
map.put(k1, v1);
map.put(k2, v2);
@@ -240,8 +245,14 @@
* @throws IllegalArgumentException if duplicate keys are provided
*/
public static @NotNull ImmutableValueMap of( // NOPMD
- @NotNull String k1, @NotNull Object v1, @NotNull String k2, @NotNull Object v2, @NotNull String k3,
- @NotNull Object v3, @NotNull String k4, @NotNull Object v4) {
+ @NotNull String k1,
+ @NotNull Object v1,
+ @NotNull String k2,
+ @NotNull Object v2,
+ @NotNull String k3,
+ @NotNull Object v3,
+ @NotNull String k4,
+ @NotNull Object v4) {
Map<String, Object> map = new HashMap<>();
map.put(k1, v1);
map.put(k2, v2);
@@ -266,8 +277,16 @@
* @throws IllegalArgumentException if duplicate keys are provided
*/
public static ImmutableValueMap of( // NOPMD
- @NotNull String k1, @NotNull Object v1, @NotNull String k2, @NotNull Object v2, @NotNull String k3,
- @NotNull Object v3, @NotNull String k4, @NotNull Object v4, @NotNull String k5, @NotNull Object v5) {
+ @NotNull String k1,
+ @NotNull Object v1,
+ @NotNull String k2,
+ @NotNull Object v2,
+ @NotNull String k3,
+ @NotNull Object v3,
+ @NotNull String k4,
+ @NotNull Object v4,
+ @NotNull String k5,
+ @NotNull Object v5) {
Map<String, Object> map = new HashMap<>();
map.put(k1, v1);
map.put(k2, v2);
@@ -368,5 +387,4 @@
}
}
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/context/ContextResourceResolverFactory.java b/core/src/main/java/org/apache/sling/testing/mock/sling/context/ContextResourceResolverFactory.java
index bea7051..b73d661 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/context/ContextResourceResolverFactory.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/context/ContextResourceResolverFactory.java
@@ -38,8 +38,8 @@
// static methods only
}
- public static @NotNull ResourceResolverFactory get(@Nullable final ResourceResolverType resourceResolverType,
- @NotNull final BundleContext bundleContext) {
+ public static @NotNull ResourceResolverFactory get(
+ @Nullable final ResourceResolverType resourceResolverType, @NotNull final BundleContext bundleContext) {
ResourceResolverType type = resourceResolverType;
if (type == null) {
type = MockSling.DEFAULT_RESOURCERESOLVER_TYPE;
@@ -51,8 +51,8 @@
return factory;
} catch (Throwable ex) {
log.error("Failed initializing resource resolver factory, bundleContext={}", bundleContext, ex);
- throw new RuntimeException("Unable to initialize " + type + " resource resolver factory: " + ex.getMessage(), ex);
+ throw new RuntimeException(
+ "Unable to initialize " + type + " resource resolver factory: " + ex.getMessage(), ex);
}
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/context/MockSlingBindings.java b/core/src/main/java/org/apache/sling/testing/mock/sling/context/MockSlingBindings.java
index b766d5a..3b26035 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/context/MockSlingBindings.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/context/MockSlingBindings.java
@@ -62,7 +62,7 @@
return null;
}
if (key instanceof String) {
- Object result = context.resolveSlingBindingProperty((String)key, context.request());
+ Object result = context.resolveSlingBindingProperty((String) key, context.request());
if (result != null) {
return result;
}
@@ -75,8 +75,8 @@
*/
private void populateFromBindingsValuesProvider() {
Bindings bindings = new LazyBindings();
- for (BindingsValuesProvider provider : context.getServices(BindingsValuesProvider.class,
- "(!(" + SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE + "=true))")) {
+ for (BindingsValuesProvider provider : context.getServices(
+ BindingsValuesProvider.class, "(!(" + SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE + "=true))")) {
provider.addBindings(bindings);
}
this.clear();
@@ -89,7 +89,8 @@
if (this.context == null) {
return;
}
- // is triggered by OSGi events fired by {@link org.apache.sling.scripting.core.impl.BindingsValuesProvidersByContextImpl}
+ // is triggered by OSGi events fired by {@link
+ // org.apache.sling.scripting.core.impl.BindingsValuesProvidersByContextImpl}
// whenever a new bindings value provider is added or removed
populateFromBindingsValuesProvider();
}
@@ -137,5 +138,4 @@
public void tearDown() {
this.context = null;
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java b/core/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
index 88bf682..62a4428 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtil.java
@@ -63,8 +63,10 @@
private static final @NotNull String @NotNull [] MODELS_PACKAGES_FROM_MANIFEST;
private static final @NotNull String @NotNull [] MODELS_CLASSES_FROM_MANIFEST;
- private static final @NotNull ConcurrentMap<String, List<URL>> MODEL_URLS_FOR_PACKAGES = new ConcurrentHashMap<String, List<URL>>();
- private static final @NotNull ConcurrentMap<String, List<URL>> MODEL_URLS_FOR_CLASSES = new ConcurrentHashMap<String, List<URL>>();
+ private static final @NotNull ConcurrentMap<String, List<URL>> MODEL_URLS_FOR_PACKAGES =
+ new ConcurrentHashMap<String, List<URL>>();
+ private static final @NotNull ConcurrentMap<String, List<URL>> MODEL_URLS_FOR_CLASSES =
+ new ConcurrentHashMap<String, List<URL>>();
static {
// scan classpath for models bundle header entries only once
@@ -86,7 +88,8 @@
* @param bundleContext Bundle context
* @param packageNames Java package names
*/
- public static void addModelsForPackages(@NotNull BundleContext bundleContext, @NotNull String @NotNull ... packageNames) {
+ public static void addModelsForPackages(
+ @NotNull BundleContext bundleContext, @NotNull String @NotNull ... packageNames) {
Bundle bundle = new RegisterModelsBundle(bundleContext, Bundle.ACTIVE, packageNames, null);
BundleEvent event = new BundleEvent(BundleEvent.STARTED, bundle);
MockOsgi.sendBundleEvent(bundleContext, event);
@@ -97,7 +100,8 @@
* @param bundleContext Bundle context
* @param classNames Java class names
*/
- public static void addModelsForClasses(@NotNull BundleContext bundleContext, @NotNull String @NotNull ... classNames) {
+ public static void addModelsForClasses(
+ @NotNull BundleContext bundleContext, @NotNull String @NotNull ... classNames) {
Bundle bundle = new RegisterModelsBundle(bundleContext, Bundle.ACTIVE, null, classNames);
BundleEvent event = new BundleEvent(BundleEvent.STARTED, bundle);
MockOsgi.sendBundleEvent(bundleContext, event);
@@ -141,7 +145,7 @@
// add "." to each package name because it's a prefix, not a package name
ConfigurationBuilder reflectionsConfig = new ConfigurationBuilder();
Stream.of(StringUtils.split(packageNames, ","))
- .forEach(packageName -> reflectionsConfig.addUrls(ClasspathHelper.forPackage(packageName + ".")));
+ .forEach(packageName -> reflectionsConfig.addUrls(ClasspathHelper.forPackage(packageName + ".")));
Reflections reflections = new Reflections(reflectionsConfig);
Set<Class<?>> classes = reflections.getTypesAnnotatedWith(Model.class);
for (Class<?> clazz : classes) {
@@ -168,8 +172,7 @@
if (clazz.isAnnotationPresent(Model.class)) {
urls.add(classToUrl(clazz));
}
- }
- catch (ClassNotFoundException e) {
+ } catch (ClassNotFoundException e) {
// ignore
}
}
@@ -181,13 +184,11 @@
private static URL classToUrl(Class clazz) {
try {
return new URL("file:/" + clazz.getName().replace('.', '/') + ".class");
- }
- catch (MalformedURLException ex) {
+ } catch (MalformedURLException ex) {
throw new RuntimeException("Malformed URL.", ex);
}
}
-
private static class RegisterModelsBundle implements Bundle {
private static final String MAGIC_STRING = "MOCKS-YOU-KNOW-WHAT-TO-SCAN";
@@ -197,7 +198,8 @@
private final String packageNames;
private final String classNames;
- public RegisterModelsBundle(BundleContext bundleContext, int state, String[] packageNames, String[] classNames) {
+ public RegisterModelsBundle(
+ BundleContext bundleContext, int state, String[] packageNames, String[] classNames) {
this.bundleContext = bundleContext;
this.state = state;
this.packageNames = normalizeValueList(packageNames);
@@ -217,7 +219,7 @@
}
@Override
- public Dictionary<String,String> getHeaders() {
+ public Dictionary<String, String> getHeaders() {
Dictionary<String, String> headers = new Hashtable<String, String>();
headers.put(PACKAGE_HEADER, MAGIC_STRING);
return headers;
@@ -311,7 +313,7 @@
}
@Override
- public Dictionary<String,String> getHeaders(String locale) {
+ public Dictionary<String, String> getHeaders(String locale) {
return null;
}
@@ -365,7 +367,5 @@
public File getDataFile(String filename) {
return null;
}
-
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java b/core/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
index 5e95fd2..9229689 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java
@@ -18,8 +18,8 @@
*/
package org.apache.sling.testing.mock.sling.context;
-import static org.apache.sling.testing.mock.sling.context.MockSlingBindings.SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE;
-import static org.osgi.service.event.EventConstants.EVENT_TOPIC;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import java.util.Arrays;
import java.util.Collections;
@@ -29,9 +29,6 @@
import java.util.Set;
import java.util.function.Function;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.adapter.AdapterFactory;
import org.apache.sling.api.resource.LoginException;
@@ -70,6 +67,9 @@
import org.osgi.framework.ServiceReference;
import org.osgi.service.event.EventHandler;
+import static org.apache.sling.testing.mock.sling.context.MockSlingBindings.SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE;
+import static org.osgi.service.event.EventConstants.EVENT_TOPIC;
+
/**
* Defines Sling context objects with lazy initialization.
* Should not be used directly but via the SlingContext JUnit rule or extension.
@@ -85,7 +85,8 @@
// default to publish instance run mode
static final @NotNull Set<String> DEFAULT_RUN_MODES = Collections.singleton("publish");
- private static final @NotNull String RESOURCERESOLVERFACTORYACTIVATOR_PID = "org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl";
+ private static final @NotNull String RESOURCERESOLVERFACTORYACTIVATOR_PID =
+ "org.apache.sling.jcr.resource.internal.JcrResourceResolverFactoryImpl";
/**
* Resource resolver factory
@@ -151,8 +152,7 @@
protected void setResourceResolverType(@Nullable final ResourceResolverType resourceResolverType) {
if (resourceResolverType == null) {
this.resourceResolverType = MockSling.DEFAULT_RESOURCERESOLVER_TYPE;
- }
- else {
+ } else {
this.resourceResolverType = resourceResolverType;
}
}
@@ -180,8 +180,10 @@
MockSling.setAdapterManagerBundleContext(bundleContext());
if (this.resourceResolverFactoryActivatorProps != null) {
- // use OSGi ConfigurationAdmin to pass over customized configuration to Resource Resolver Factory Activator service
- MockOsgi.setConfigForPid(bundleContext(), RESOURCERESOLVERFACTORYACTIVATOR_PID, this.resourceResolverFactoryActivatorProps);
+ // use OSGi ConfigurationAdmin to pass over customized configuration to Resource Resolver Factory Activator
+ // service
+ MockOsgi.setConfigForPid(
+ bundleContext(), RESOURCERESOLVERFACTORYACTIVATOR_PID, this.resourceResolverFactoryActivatorProps);
}
// automatically register resource resolver factory when ResourceResolverType != NONE,
@@ -241,8 +243,8 @@
registerService(SlingSettingsService.class, new MockSlingSettingService(DEFAULT_RUN_MODES));
registerService(MimeTypeService.class, new MockMimeTypeService());
registerInjectActivateService(new ResourceBuilderFactoryService());
- registerInjectActivateService(new JcrObjectsBindingsValuesProvider(),
- SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE, true);
+ registerInjectActivateService(
+ new JcrObjectsBindingsValuesProvider(), SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE, true);
registerInjectActivateService(new MockResourceBundleProvider());
registerInjectActivateService(MockXSSFilter.class);
registerInjectActivateService(XSSAPIImpl.class);
@@ -273,9 +275,9 @@
protected void tearDown() {
if (this.request != null) {
- SlingBindings slingBindings = (SlingBindings)this.request.getAttribute(SlingBindings.class.getName());
+ SlingBindings slingBindings = (SlingBindings) this.request.getAttribute(SlingBindings.class.getName());
if (slingBindings instanceof MockSlingBindings) {
- ((MockSlingBindings)slingBindings).tearDown();
+ ((MockSlingBindings) slingBindings).tearDown();
}
}
@@ -284,7 +286,7 @@
// revert potential unsaved changes in resource resolver/JCR session
try {
this.resourceResolver.revert();
- } catch (UnsupportedOperationException ex){
+ } catch (UnsupportedOperationException ex) {
// ignore - this may happen when jcr-mock is used
}
Session session = this.resourceResolver.adaptTo(Session.class);
@@ -293,7 +295,7 @@
session.refresh(false);
} catch (RepositoryException ex) {
// ignore
- } catch (UnsupportedOperationException ex){
+ } catch (UnsupportedOperationException ex) {
// ignore - this may happen when jcr-mock is used
}
}
@@ -358,8 +360,11 @@
MockSlingBindings bindings = new MockSlingBindings(this);
// register as OSGi event handler to get notified on events fired by BindingsValuesProvidersByContextImpl
- this.registerService(EventHandler.class, bindings,
- EVENT_TOPIC, "org/apache/sling/scripting/core/BindingsValuesProvider/*");
+ this.registerService(
+ EventHandler.class,
+ bindings,
+ EVENT_TOPIC,
+ "org/apache/sling/scripting/core/BindingsValuesProvider/*");
this.request.setAttribute(SlingBindings.class.getName(), bindings);
}
@@ -372,7 +377,8 @@
* @param request Context request
* @return Resolved object or null if no result found
*/
- protected @Nullable Object resolveSlingBindingProperty(@NotNull String property, @NotNull SlingHttpServletRequest request) {
+ protected @Nullable Object resolveSlingBindingProperty(
+ @NotNull String property, @NotNull SlingHttpServletRequest request) {
return MockSlingBindings.resolveSlingBindingProperty(this, property);
}
@@ -391,7 +397,7 @@
* @return Request path info
*/
public final @NotNull MockRequestPathInfo requestPathInfo() {
- return (MockRequestPathInfo)request().getRequestPathInfo();
+ return (MockRequestPathInfo) request().getRequestPathInfo();
}
/**
@@ -409,8 +415,8 @@
*/
public final @NotNull SlingScriptHelper slingScriptHelper() {
if (this.slingScriptHelper == null) {
- this.slingScriptHelper = MockSling.newSlingScriptHelper(this.request(), this.response(),
- this.bundleContext());
+ this.slingScriptHelper =
+ MockSling.newSlingScriptHelper(this.request(), this.response(), this.bundleContext());
}
return this.slingScriptHelper;
}
@@ -429,13 +435,14 @@
public @NotNull ContentLoader load(boolean autoCommit) {
if (autoCommit) {
if (this.contentLoaderAutoCommit == null) {
- this.contentLoaderAutoCommit = new ContentLoader(resourceResolver(), bundleContext(), true, this.resourceResolverType());
+ this.contentLoaderAutoCommit =
+ new ContentLoader(resourceResolver(), bundleContext(), true, this.resourceResolverType());
}
return this.contentLoaderAutoCommit;
- }
- else {
+ } else {
if (this.contentLoader == null) {
- this.contentLoader = new ContentLoader(resourceResolver(), bundleContext(), false, this.resourceResolverType());
+ this.contentLoader =
+ new ContentLoader(resourceResolver(), bundleContext(), false, this.resourceResolverType());
}
return this.contentLoader;
}
@@ -488,7 +495,7 @@
}
return currentResource(resource);
} else {
- return currentResource((Resource)null);
+ return currentResource((Resource) null);
}
}
@@ -508,7 +515,7 @@
* @param packageName Java package name
*/
public final void addModelsForPackage(@NotNull String packageName) {
- ModelAdapterFactoryUtil.addModelsForPackages(bundleContext(), packageName);
+ ModelAdapterFactoryUtil.addModelsForPackages(bundleContext(), packageName);
}
/**
@@ -545,7 +552,8 @@
Set<String> newRunModes = new HashSet<>(Arrays.asList(runModes));
ServiceReference<SlingSettingsService> ref = bundleContext().getServiceReference(SlingSettingsService.class);
if (ref != null) {
- MockSlingSettingService slingSettings = (MockSlingSettingService)bundleContext().getService(ref);
+ MockSlingSettingService slingSettings =
+ (MockSlingSettingService) bundleContext().getService(ref);
slingSettings.setRunModes(newRunModes);
}
}
@@ -570,8 +578,8 @@
* @param <T1> Adaptable type
* @param <T2> Adapter type
*/
- public final <T1, T2> void registerAdapter(@NotNull final Class<T1> adaptableClass, @NotNull final Class<T2> adapterClass,
- @NotNull final T2 adapter) {
+ public final <T1, T2> void registerAdapter(
+ @NotNull final Class<T1> adaptableClass, @NotNull final Class<T2> adapterClass, @NotNull final T2 adapter) {
registerAdapter(adaptableClass, adapterClass, new Function<T1, T2>() {
@Override
public T2 apply(@Nullable T1 input) {
@@ -589,26 +597,24 @@
* @param <T1> Adaptable type
* @param <T2> Adapter type
*/
- public final <T1, T2> void registerAdapter(@NotNull final Class<T1> adaptableClass, @NotNull final Class<T2> adapterClass,
- @NotNull final Function<T1,T2> adaptHandler) {
+ public final <T1, T2> void registerAdapter(
+ @NotNull final Class<T1> adaptableClass,
+ @NotNull final Class<T2> adapterClass,
+ @NotNull final Function<T1, T2> adaptHandler) {
AdapterFactory adapterFactory = new AdapterFactory() {
@SuppressWarnings("unchecked")
@Override
public <AdapterType> AdapterType getAdapter(@NotNull Object adaptable, @NotNull Class<AdapterType> type) {
- return (AdapterType)adaptHandler.apply((T1)adaptable);
+ return (AdapterType) adaptHandler.apply((T1) adaptable);
}
};
- Map<String,Object> props = new HashMap<>();
- props.put(AdapterFactory.ADAPTABLE_CLASSES, new String[] {
- adaptableClass.getName()
- });
- props.put(AdapterFactory.ADAPTER_CLASSES, new String[] {
- adapterClass.getName()
- });
+ Map<String, Object> props = new HashMap<>();
+ props.put(AdapterFactory.ADAPTABLE_CLASSES, new String[] {adaptableClass.getName()});
+ props.put(AdapterFactory.ADAPTER_CLASSES, new String[] {adapterClass.getName()});
// make sure this overlay has higher ranking than other adapter factories
- // normally we should use Integer.MAX_VALUE for this - but due to SLING-7194 prefers lowest-ranking services first
+ // normally we should use Integer.MAX_VALUE for this - but due to SLING-7194 prefers lowest-ranking services
+ // first
props.put(Constants.SERVICE_RANKING, Integer.MIN_VALUE);
registerService(AdapterFactory.class, adapterFactory, props);
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java b/core/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
index 7877b2c..f4a01d3 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/context/UniqueRoot.java
@@ -70,11 +70,13 @@
*/
protected final Resource getOrCreateResource(@NotNull String path, @NotNull String primaryType) {
try {
- return ResourceUtil.getOrCreateResource(context.resourceResolver(), path,
+ return ResourceUtil.getOrCreateResource(
+ context.resourceResolver(),
+ path,
ImmutableValueMap.of(JcrConstants.JCR_PRIMARYTYPE, primaryType),
- null, true);
- }
- catch (PersistenceException ex) {
+ null,
+ true);
+ } catch (PersistenceException ex) {
throw new RuntimeException("Unable to create resource at " + path + ": " + ex.getMessage(), ex);
}
}
@@ -132,19 +134,15 @@
if (resource != null && context.resourceResolver.getResource(resource.getPath()) != null) {
try {
context.resourceResolver().delete(resource);
- }
- catch (PersistenceException ex) {
+ } catch (PersistenceException ex) {
log.warn("Unable to delete root path " + resource.getPath(), ex);
}
}
}
try {
context.resourceResolver().commit();
- }
- catch (PersistenceException ex) {
+ } catch (PersistenceException ex) {
log.warn("Unable to commit root path deletions.", ex);
}
-
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java b/core/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
index 5c6d756..7561db5 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/loader/ContentLoader.java
@@ -70,26 +70,24 @@
// set of resource or property names that are ignored for all resource resolver types
private static final Set<String> SHARED_IGNORED_NAMES = Stream.of(
- JcrConstants.JCR_BASEVERSION,
- JcrConstants.JCR_PREDECESSORS,
- JcrConstants.JCR_SUCCESSORS,
- JcrConstants.JCR_VERSIONHISTORY,
- "jcr:checkedOut",
- "jcr:isCheckedOut",
- "rep:policy")
+ JcrConstants.JCR_BASEVERSION,
+ JcrConstants.JCR_PREDECESSORS,
+ JcrConstants.JCR_SUCCESSORS,
+ JcrConstants.JCR_VERSIONHISTORY,
+ "jcr:checkedOut",
+ "jcr:isCheckedOut",
+ "rep:policy")
.collect(Collectors.toSet());
// set of resource or property names that are ignored when other resource resolver types than JCR_OAK are used
private static final Set<String> MOCK_IGNORED_NAMES = Stream.concat(
- SHARED_IGNORED_NAMES.stream(), Stream.of(
- JcrConstants.JCR_MIXINTYPES))
+ SHARED_IGNORED_NAMES.stream(), Stream.of(JcrConstants.JCR_MIXINTYPES))
.collect(Collectors.toSet());
- // set of resource or property names that are ignored when JCR_OAK resource resolver type (= a real repo impl) is used
+ // set of resource or property names that are ignored when JCR_OAK resource resolver type (= a real repo impl) is
+ // used
private static final Set<String> OAK_IGNORED_NAMES = Stream.concat(
- SHARED_IGNORED_NAMES.stream(), Stream.of(
- JcrConstants.JCR_UUID,
- JcrConstants.JCR_CREATED))
+ SHARED_IGNORED_NAMES.stream(), Stream.of(JcrConstants.JCR_UUID, JcrConstants.JCR_CREATED))
.collect(Collectors.toSet());
private final ResourceResolver resourceResolver;
@@ -121,7 +119,8 @@
* @param bundleContext Bundle context
* @param autoCommit Automatically commit changes after loading content (default: true)
*/
- public ContentLoader(@NotNull ResourceResolver resourceResolver, @Nullable BundleContext bundleContext, boolean autoCommit) {
+ public ContentLoader(
+ @NotNull ResourceResolver resourceResolver, @Nullable BundleContext bundleContext, boolean autoCommit) {
this(resourceResolver, bundleContext, autoCommit, null);
}
@@ -131,7 +130,10 @@
* @param autoCommit Automatically commit changes after loading content (default: true)
* @param resourceResolverType Resource resolver type.
*/
- public ContentLoader(@NotNull ResourceResolver resourceResolver, @Nullable BundleContext bundleContext, boolean autoCommit,
+ public ContentLoader(
+ @NotNull ResourceResolver resourceResolver,
+ @Nullable BundleContext bundleContext,
+ boolean autoCommit,
@Nullable ResourceResolverType resourceResolverType) {
this.resourceResolver = resourceResolver;
this.bundleContext = bundleContext;
@@ -139,10 +141,10 @@
this.ignoredNames = getIgnoredNamesForResourceResolverType(resourceResolverType);
this.jsonParserOptions = new JSONParserOptions()
- .withFeatures(EnumSet.of(JSONParserFeature.COMMENTS, JSONParserFeature.QUOTE_TICK))
- .detectCalendarValues(true)
- .ignorePropertyNames(this.ignoredNames)
- .ignoreResourceNames(this.ignoredNames);
+ .withFeatures(EnumSet.of(JSONParserFeature.COMMENTS, JSONParserFeature.QUOTE_TICK))
+ .detectCalendarValues(true)
+ .ignorePropertyNames(this.ignoredNames)
+ .ignoreResourceNames(this.ignoredNames);
this.jsonParser = new JSONContentParser();
this.fileVaultXmlParserOptions = new ParserOptions()
@@ -155,8 +157,7 @@
private final Set<String> getIgnoredNamesForResourceResolverType(ResourceResolverType resourceResolverType) {
if (resourceResolverType == null || resourceResolverType == ResourceResolverType.JCR_OAK) {
return OAK_IGNORED_NAMES;
- }
- else {
+ } else {
return MOCK_IGNORED_NAMES;
}
}
@@ -171,7 +172,8 @@
* @param childName Name of child resource to create with JSON content
* @return Resource
*/
- public @NotNull Resource json(@NotNull String classpathResourceOrFile, @NotNull Resource parentResource, @NotNull String childName) {
+ public @NotNull Resource json(
+ @NotNull String classpathResourceOrFile, @NotNull Resource parentResource, @NotNull String childName) {
return json(classpathResourceOrFile, parentResource.getPath() + "/" + childName);
}
@@ -199,7 +201,8 @@
* @param childName Name of child resource to create with JSON content
* @return Resource
*/
- public @NotNull Resource json(@NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String childName) {
+ public @NotNull Resource json(
+ @NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String childName) {
return json(inputStream, parentResource.getPath() + "/" + childName);
}
@@ -227,7 +230,8 @@
* @param childName Name of child resource to create with Filevault content
* @return Resource
*/
- public @NotNull Resource fileVaultXml(@NotNull String classpathResourceOrFile, @NotNull Resource parentResource, @NotNull String childName) {
+ public @NotNull Resource fileVaultXml(
+ @NotNull String classpathResourceOrFile, @NotNull Resource parentResource, @NotNull String childName) {
return fileVaultXml(classpathResourceOrFile, parentResource.getPath() + "/" + childName);
}
@@ -255,7 +259,8 @@
* @param childName Name of child resource to create with Filevault content
* @return Resource
*/
- public @NotNull Resource fileVaultXml(@NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String childName) {
+ public @NotNull Resource fileVaultXml(
+ @NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String childName) {
return fileVaultXml(inputStream, parentResource.getPath() + "/" + childName);
}
@@ -274,8 +279,11 @@
}
@SuppressWarnings("null")
- private @NotNull Resource mountParsedFile(@NotNull InputStream inputStream, @NotNull String destPath,
- @NotNull ContentParser contentParser, @NotNull ParserOptions parserOptions) {
+ private @NotNull Resource mountParsedFile(
+ @NotNull InputStream inputStream,
+ @NotNull String destPath,
+ @NotNull ContentParser contentParser,
+ @NotNull ParserOptions parserOptions) {
try {
String parentPath = ResourceUtil.getParent(destPath);
String childName = ResourceUtil.getName(destPath);
@@ -298,8 +306,7 @@
resourceResolver.commit();
}
return resourceResolver.getResource(destPath);
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
throw new RuntimeException(ex);
}
}
@@ -350,8 +357,10 @@
* @param mimeType Mime type of binary data
* @return Resource with binary data
*/
- public @NotNull Resource binaryFile(@NotNull String classpathResourceOrFile, @NotNull String path, @NotNull String mimeType) {
- return processInputStreamFromClasspathOrFilesystem(classpathResourceOrFile, is -> binaryFile(is, path, mimeType));
+ public @NotNull Resource binaryFile(
+ @NotNull String classpathResourceOrFile, @NotNull String path, @NotNull String mimeType) {
+ return processInputStreamFromClasspathOrFilesystem(
+ classpathResourceOrFile, is -> binaryFile(is, path, mimeType));
}
/**
@@ -382,7 +391,8 @@
* @param mimeType Mime type of binary data
* @return Resource with binary data
*/
- public @NotNull Resource binaryFile(@NotNull InputStream inputStream, @NotNull String path, @NotNull String mimeType) {
+ public @NotNull Resource binaryFile(
+ @NotNull InputStream inputStream, @NotNull String path, @NotNull String mimeType) {
String parentPath = ResourceUtil.getParent(path, 1);
String name = ResourceUtil.getName(path);
if (parentPath == null) {
@@ -407,7 +417,8 @@
* @param name Resource name for nt:file
* @return Resource with binary data
*/
- public @NotNull Resource binaryFile(@NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String name) {
+ public @NotNull Resource binaryFile(
+ @NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String name) {
return binaryFile(inputStream, parentResource, name, detectMimeTypeFromNames(name));
}
@@ -423,14 +434,24 @@
* @param mimeType Mime type of binary data
* @return Resource with binary data
*/
- public @NotNull Resource binaryFile(@NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String name, @NotNull String mimeType) {
+ public @NotNull Resource binaryFile(
+ @NotNull InputStream inputStream,
+ @NotNull Resource parentResource,
+ @NotNull String name,
+ @NotNull String mimeType) {
try {
- Resource file = resourceResolver.create(parentResource, name,
- ImmutableValueMap.of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_FILE));
- resourceResolver.create(file, JcrConstants.JCR_CONTENT,
- ImmutableValueMap.of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_RESOURCE,
- JcrConstants.JCR_DATA, inputStream,
- JcrConstants.JCR_MIMETYPE, mimeType));
+ Resource file = resourceResolver.create(
+ parentResource, name, ImmutableValueMap.of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_FILE));
+ resourceResolver.create(
+ file,
+ JcrConstants.JCR_CONTENT,
+ ImmutableValueMap.of(
+ JcrConstants.JCR_PRIMARYTYPE,
+ JcrConstants.NT_RESOURCE,
+ JcrConstants.JCR_DATA,
+ inputStream,
+ JcrConstants.JCR_MIMETYPE,
+ mimeType));
if (autoCommit) {
resourceResolver.commit();
}
@@ -466,8 +487,10 @@
* @param mimeType Mime type of binary data
* @return Resource with binary data
*/
- public @NotNull Resource binaryResource(@NotNull String classpathResourceOrFile, @NotNull String path, @NotNull String mimeType) {
- return processInputStreamFromClasspathOrFilesystem(classpathResourceOrFile, is -> binaryResource(is, path, mimeType));
+ public @NotNull Resource binaryResource(
+ @NotNull String classpathResourceOrFile, @NotNull String path, @NotNull String mimeType) {
+ return processInputStreamFromClasspathOrFilesystem(
+ classpathResourceOrFile, is -> binaryResource(is, path, mimeType));
}
/**
@@ -498,7 +521,8 @@
* @param mimeType Mime type of binary data
* @return Resource with binary data
*/
- public @NotNull Resource binaryResource(@NotNull InputStream inputStream, @NotNull String path, @NotNull String mimeType) {
+ public @NotNull Resource binaryResource(
+ @NotNull InputStream inputStream, @NotNull String path, @NotNull String mimeType) {
String parentPath = ResourceUtil.getParent(path, 1);
String name = ResourceUtil.getName(path);
if (parentPath == null) {
@@ -523,7 +547,8 @@
* @param name Resource name for nt:resource
* @return Resource with binary data
*/
- public @NotNull Resource binaryResource(@NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String name) {
+ public @NotNull Resource binaryResource(
+ @NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String name) {
return binaryResource(inputStream, parentResource, name, detectMimeTypeFromNames(name));
}
@@ -539,12 +564,22 @@
* @param mimeType Mime type of binary data
* @return Resource with binary data
*/
- public @NotNull Resource binaryResource(@NotNull InputStream inputStream, @NotNull Resource parentResource, @NotNull String name, @NotNull String mimeType) {
+ public @NotNull Resource binaryResource(
+ @NotNull InputStream inputStream,
+ @NotNull Resource parentResource,
+ @NotNull String name,
+ @NotNull String mimeType) {
try {
- Resource resource = resourceResolver.create(parentResource, name,
- ImmutableValueMap.of(JcrConstants.JCR_PRIMARYTYPE, JcrConstants.NT_RESOURCE,
- JcrConstants.JCR_DATA, inputStream,
- JcrConstants.JCR_MIMETYPE, mimeType));
+ Resource resource = resourceResolver.create(
+ parentResource,
+ name,
+ ImmutableValueMap.of(
+ JcrConstants.JCR_PRIMARYTYPE,
+ JcrConstants.NT_RESOURCE,
+ JcrConstants.JCR_DATA,
+ inputStream,
+ JcrConstants.JCR_MIMETYPE,
+ mimeType));
if (autoCommit) {
resourceResolver.commit();
}
@@ -587,7 +622,8 @@
* @param parentResource Parent resource
* @param childName Name of child resource to mount folder into
*/
- public void folderJson(@NotNull String mountFolderPath, @NotNull Resource parentResource, @NotNull String childName) {
+ public void folderJson(
+ @NotNull String mountFolderPath, @NotNull Resource parentResource, @NotNull String childName) {
folderJson(new File(mountFolderPath), parentResource, childName);
}
@@ -629,11 +665,16 @@
*/
public void folderJson(@NotNull File mountFolder, @NotNull String destPath) {
registerFileSystemResourceProvider(
- "provider.file", mountFolder.getAbsolutePath(),
- "provider.root", destPath,
- "provider.fs.mode", "INITIAL_CONTENT",
- "provider.initial.content.import.options", "overwrite:=true;ignoreImportProviders:=\"xml\"",
- "provider.checkinterval", 0);
+ "provider.file",
+ mountFolder.getAbsolutePath(),
+ "provider.root",
+ destPath,
+ "provider.fs.mode",
+ "INITIAL_CONTENT",
+ "provider.initial.content.import.options",
+ "overwrite:=true;ignoreImportProviders:=\"xml\"",
+ "provider.checkinterval",
+ 0);
}
/**
@@ -646,7 +687,8 @@
* @param parentResource Parent resource
* @param childName Name of child resource of subtree path that should be mounted from FileVault XML structure
*/
- public void folderFileVaultXml(@NotNull String mountFolderPath, @NotNull Resource parentResource, @NotNull String childName) {
+ public void folderFileVaultXml(
+ @NotNull String mountFolderPath, @NotNull Resource parentResource, @NotNull String childName) {
folderFileVaultXml(new File(mountFolderPath), parentResource, childName);
}
@@ -673,7 +715,8 @@
* @param parentResource Parent resource
* @param childName Name of child resource of subtree path that should be mounted from FileVault XML structure
*/
- public void folderFileVaultXml(@NotNull File mountFolder, @NotNull Resource parentResource, @NotNull String childName) {
+ public void folderFileVaultXml(
+ @NotNull File mountFolder, @NotNull Resource parentResource, @NotNull String childName) {
folderFileVaultXml(mountFolder, parentResource.getPath() + "/" + childName);
}
@@ -688,10 +731,14 @@
*/
public void folderFileVaultXml(@NotNull File mountFolder, @NotNull String destPath) {
registerFileSystemResourceProvider(
- "provider.file", mountFolder.getAbsolutePath(),
- "provider.root", destPath,
- "provider.fs.mode", "FILEVAULT_XML",
- "provider.checkinterval", 0);
+ "provider.file",
+ mountFolder.getAbsolutePath(),
+ "provider.root",
+ destPath,
+ "provider.fs.mode",
+ "FILEVAULT_XML",
+ "provider.checkinterval",
+ 0);
}
/**
@@ -700,20 +747,19 @@
* @param processor Processes input stream
*/
@SuppressWarnings("null")
- private <T> @NotNull T processInputStreamFromClasspathOrFilesystem(@NotNull String classpathResourceOrFile, @NotNull Function<InputStream,T> processor) {
+ private <T> @NotNull T processInputStreamFromClasspathOrFilesystem(
+ @NotNull String classpathResourceOrFile, @NotNull Function<InputStream, T> processor) {
InputStream is = ContentLoader.class.getResourceAsStream(classpathResourceOrFile);
if (is == null) {
try {
is = new FileInputStream(classpathResourceOrFile);
- }
- catch (FileNotFoundException ex) {
+ } catch (FileNotFoundException ex) {
throw new IllegalArgumentException("Classpath resource or file not found: " + classpathResourceOrFile);
}
}
try {
return processor.apply(is);
- }
- finally {
+ } finally {
IOUtils.closeQuietly(is);
}
}
@@ -724,26 +770,26 @@
throw new IllegalStateException("No bundle context given for content loader.");
}
if (isUsingMockResourceResolverFactory()) {
- throw new IllegalStateException("Loading folder content is not supported with RESOURCERESOLVER_MOCK resource resolver type. "
- + "Use RESOURCEPROVIDER_MOCK or one of the other types.");
+ throw new IllegalStateException(
+ "Loading folder content is not supported with RESOURCERESOLVER_MOCK resource resolver type. "
+ + "Use RESOURCEPROVIDER_MOCK or one of the other types.");
}
- Dictionary<String,Object> props = MapUtil.toDictionary(serviceProperties);
+ Dictionary<String, Object> props = MapUtil.toDictionary(serviceProperties);
FsResourceProvider service = MockOsgi.activateInjectServices(FsResourceProvider.class, bundleContext, props);
bundleContext.registerService(ResourceProvider.class, service, props);
}
private boolean isUsingMockResourceResolverFactory() {
- ServiceReference<ResourceResolverFactory> serviceReference = bundleContext.getServiceReference(ResourceResolverFactory.class);
+ ServiceReference<ResourceResolverFactory> serviceReference =
+ bundleContext.getServiceReference(ResourceResolverFactory.class);
if (serviceReference == null) {
throw new IllegalStateException("No resource resolver factory service present.");
}
try {
ResourceResolverFactory resourceResolverFactory = bundleContext.getService(serviceReference);
return resourceResolverFactory instanceof MockResourceResolverFactory;
- }
- finally {
+ } finally {
bundleContext.ungetService(serviceReference);
}
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/loader/LoaderContentHandler.java b/core/src/main/java/org/apache/sling/testing/mock/sling/loader/LoaderContentHandler.java
index 0068d69..16a0d65 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/loader/LoaderContentHandler.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/loader/LoaderContentHandler.java
@@ -19,6 +19,7 @@
package org.apache.sling.testing.mock.sling.loader;
import javax.jcr.Node;
+
import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.Map;
@@ -66,28 +67,27 @@
}
try {
createResource(parentResource, name, properties);
- }
- catch (PersistenceException ex) {
+ } catch (PersistenceException ex) {
throw new RuntimeException("Unable to create resource at '" + fullPath + "'.", ex);
}
}
- private Resource createResource(@NotNull Resource parentResource, @NotNull String childName, @Nullable Map<String,Object> content) throws PersistenceException {
+ private Resource createResource(
+ @NotNull Resource parentResource, @NotNull String childName, @Nullable Map<String, Object> content)
+ throws PersistenceException {
// collect all properties first
boolean hasJcrData = false;
String referencedNodePath = null;
Map<String, Object> props = new HashMap<String, Object>();
if (content != null) {
- for (Map.Entry<String,Object> entry : content.entrySet()) {
+ for (Map.Entry<String, Object> entry : content.entrySet()) {
final String name = entry.getKey();
if (StringUtils.equals(name, JCR_DATA_PLACEHOLDER)) {
hasJcrData = true;
- }
- else if (StringUtils.equals(name, JCR_REFERENCE_PLACEHOLDER)) {
+ } else if (StringUtils.equals(name, JCR_REFERENCE_PLACEHOLDER)) {
referencedNodePath = (String) entry.getValue();
- }
- else {
+ } else {
props.put(name, entry.getValue());
}
}
@@ -99,11 +99,14 @@
ModifiableValueMap valueMap = resource.adaptTo(ModifiableValueMap.class);
if (valueMap != null) {
if (hasJcrData) {
- // we cannot import binary data here - but to avoid complaints by JCR we create it with empty binary data
+ // we cannot import binary data here - but to avoid complaints by JCR we create it with empty binary
+ // data
valueMap.put(JcrConstants.JCR_DATA, new ByteArrayInputStream(new byte[0]));
} else if (StringUtils.isNotBlank(referencedNodePath)) {
- // target reference has to be specified relative to linking node, as tests may apply a dynamic root directory
- Resource referencedNodeResource = resourceResolver.getResource(resource.getPath() + "/" + referencedNodePath);
+ // target reference has to be specified relative to linking node, as tests may apply a dynamic root
+ // directory
+ Resource referencedNodeResource =
+ resourceResolver.getResource(resource.getPath() + "/" + referencedNodePath);
if (referencedNodeResource != null) {
valueMap.put(JcrConstants.JCR_CONTENT, referencedNodeResource.adaptTo(Node.class));
}
@@ -112,5 +115,4 @@
return resource;
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeService.java b/core/src/main/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeService.java
index babbff1..2180201 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeService.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeService.java
@@ -54,48 +54,55 @@
// activate service in simulated OSGi environment (for MimeTypeService impl < 2.0.0)
try {
- Method bindLogServiceMethod = MimeTypeServiceImpl.class.getDeclaredMethod("bindLogService", LogService.class);
+ Method bindLogServiceMethod =
+ MimeTypeServiceImpl.class.getDeclaredMethod("bindLogService", LogService.class);
bindLogServiceMethod.invoke(this, MockOsgi.newLogService(getClass()));
- }
- catch (NoSuchMethodException ex) {
+ } catch (NoSuchMethodException ex) {
// ignore
- }
- catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
throw new RuntimeException("Unableo to set log service.", ex);
}
// call activate method of MimeTypeServiceImpl
- // via reflection because the method signature changed between org.apache.sling.commons.mime 2.1.8 and 2.1.10 and 2.2.0
+ // via reflection because the method signature changed between org.apache.sling.commons.mime 2.1.8 and
+ // 2.1.10 and 2.2.0
try {
Method activateMethod;
try {
- Class<?> mimeTypeServiceConfigClass = Class.forName(MimeTypeServiceImpl.class.getName() + "$Config");
- activateMethod = MimeTypeServiceImpl.class.getDeclaredMethod("activate", BundleContext.class, mimeTypeServiceConfigClass);
- Object configProxy = Proxy.newProxyInstance(getClass().getClassLoader(), new Class[] { mimeTypeServiceConfigClass }, new InvocationHandler() {
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- return null;
- }
- });
+ Class<?> mimeTypeServiceConfigClass =
+ Class.forName(MimeTypeServiceImpl.class.getName() + "$Config");
+ activateMethod = MimeTypeServiceImpl.class.getDeclaredMethod(
+ "activate", BundleContext.class, mimeTypeServiceConfigClass);
+ Object configProxy = Proxy.newProxyInstance(
+ getClass().getClassLoader(),
+ new Class[] {mimeTypeServiceConfigClass},
+ new InvocationHandler() {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ return null;
+ }
+ });
activateMethod.invoke(this, componentContext.getBundleContext(), configProxy);
- }
- catch (NoSuchMethodException | ClassNotFoundException ex1) {
+ } catch (NoSuchMethodException | ClassNotFoundException ex1) {
try {
- activateMethod = MimeTypeServiceImpl.class.getDeclaredMethod("activate", ComponentContext.class);
+ activateMethod =
+ MimeTypeServiceImpl.class.getDeclaredMethod("activate", ComponentContext.class);
activateMethod.invoke(this, componentContext);
- }
- catch (NoSuchMethodException ex2) {
+ } catch (NoSuchMethodException ex2) {
try {
- activateMethod = MimeTypeServiceImpl.class.getDeclaredMethod("activate", BundleContext.class, Map.class);
- activateMethod.invoke(this, componentContext.getBundleContext(), MapUtil.toMap(componentContext.getProperties()));
- }
- catch (NoSuchMethodException ex3) {
- throw new RuntimeException("Did not found activate method of MimeTypeServiceImpl with any matching signature.");
+ activateMethod = MimeTypeServiceImpl.class.getDeclaredMethod(
+ "activate", BundleContext.class, Map.class);
+ activateMethod.invoke(
+ this,
+ componentContext.getBundleContext(),
+ MapUtil.toMap(componentContext.getProperties()));
+ } catch (NoSuchMethodException ex3) {
+ throw new RuntimeException(
+ "Did not found activate method of MimeTypeServiceImpl with any matching signature.");
}
}
}
- }
- catch (SecurityException | InvocationTargetException | IllegalAccessException ex) {
+ } catch (SecurityException | InvocationTargetException | IllegalAccessException ex) {
throw new RuntimeException("Unable to activate MimeTypeServiceImpl.", ex);
}
}
@@ -124,5 +131,4 @@
lazyInitialization();
super.registerMimeType(mimeTabStream);
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingService.java b/core/src/main/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingService.java
index 0fcf1fa..4fcca9f 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingService.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingService.java
@@ -101,5 +101,4 @@
public int getBestRunModeMatchCountFromSpec(String spec) {
throw new UnsupportedOperationException();
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockHttpSession.java b/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockHttpSession.java
index 55db2d7..5a546b4 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockHttpSession.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockHttpSession.java
@@ -26,5 +26,4 @@
protected MockServletContext newMockServletContext() {
return new MockServletContext();
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockRequestPathInfo.java b/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockRequestPathInfo.java
index 8bcbf24..8395070 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockRequestPathInfo.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockRequestPathInfo.java
@@ -39,5 +39,4 @@
public MockRequestPathInfo(ResourceResolver resourceResolver) {
super(resourceResolver);
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java b/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
index 6ae24e4..ab78bee 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequest.java
@@ -47,7 +47,8 @@
* @param resourceResolver Resource resolver
* @param bundleContext Bundle context
*/
- public MockSlingHttpServletRequest(@NotNull ResourceResolver resourceResolver, @NotNull BundleContext bundleContext) {
+ public MockSlingHttpServletRequest(
+ @NotNull ResourceResolver resourceResolver, @NotNull BundleContext bundleContext) {
super(resourceResolver);
this.bundleContext = bundleContext;
}
@@ -65,9 +66,10 @@
public ResourceBundle getResourceBundle(String baseName, Locale locale) {
// check of ResourceBundleProvider is registered in mock OSGI context
ResourceBundle resourceBundle = null;
- ServiceReference<ResourceBundleProvider> serviceReference = bundleContext.getServiceReference(ResourceBundleProvider.class);
+ ServiceReference<ResourceBundleProvider> serviceReference =
+ bundleContext.getServiceReference(ResourceBundleProvider.class);
if (serviceReference != null) {
- ResourceBundleProvider provider = (ResourceBundleProvider)bundleContext.getService(serviceReference);
+ ResourceBundleProvider provider = (ResourceBundleProvider) bundleContext.getService(serviceReference);
resourceBundle = provider.getResourceBundle(baseName, locale);
}
// if no ResourceBundleProvider exists return empty bundle
@@ -76,5 +78,4 @@
}
return resourceBundle;
}
-
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java b/core/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
index 55bf8cf..e8ed7f9 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/spi/ResourceResolverTypeAdapter.java
@@ -39,7 +39,8 @@
* {@link #newSlingRepository()} has to return a value.
* @return Resource resolver factory instance or null
*/
- @Nullable ResourceResolverFactory newResourceResolverFactory();
+ @Nullable
+ ResourceResolverFactory newResourceResolverFactory();
/**
* Get SlingRepository instance. Can be null if a resource resolver factory
@@ -47,6 +48,6 @@
* {@link #newResourceResolverFactory()} has to return a value.
* @return Sling repository instance or null
*/
- @Nullable SlingRepository newSlingRepository();
-
+ @Nullable
+ SlingRepository newSlingRepository();
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepositoryTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepositoryTest.java
index af784dd..ab38743 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepositoryTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/MockJcrSlingRepositoryTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.testing.mock.sling;
-import static org.junit.Assert.assertNotNull;
-
import javax.jcr.RepositoryException;
import javax.jcr.Session;
@@ -30,6 +28,8 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+
public class MockJcrSlingRepositoryTest {
@Rule
@@ -56,5 +56,4 @@
assertNotNull(session);
session.logout();
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/MockResourceBundleProviderTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/MockResourceBundleProviderTest.java
index 6a23cb4..3671fab 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/MockResourceBundleProviderTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/MockResourceBundleProviderTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.testing.mock.sling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import java.util.Locale;
import java.util.ResourceBundle;
@@ -30,6 +26,10 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
public class MockResourceBundleProviderTest {
private static final String MY_NAME = "my-name";
@@ -41,32 +41,33 @@
public void testGetResourceBundleFromRequest() {
ResourceBundle bundle = context.request().getResourceBundle(Locale.CANADA_FRENCH);
assertEquals(Locale.CANADA_FRENCH, bundle.getLocale());
- assertNull(((MockResourceBundle)bundle).getBaseName());
+ assertNull(((MockResourceBundle) bundle).getBaseName());
}
@Test
public void testGetResourceBundleFromRequestWithBaseName() {
ResourceBundle bundle = context.request().getResourceBundle(MY_NAME, Locale.CANADA_FRENCH);
assertEquals(Locale.CANADA_FRENCH, bundle.getLocale());
- assertEquals(MY_NAME, ((MockResourceBundle)bundle).getBaseName());
+ assertEquals(MY_NAME, ((MockResourceBundle) bundle).getBaseName());
}
@Test
public void testDefaultLocale() {
- MockResourceBundleProvider bundleProvider = (MockResourceBundleProvider)context.getService(ResourceBundleProvider.class);
+ MockResourceBundleProvider bundleProvider =
+ (MockResourceBundleProvider) context.getService(ResourceBundleProvider.class);
assertNotNull(bundleProvider);
bundleProvider.setDefaultLocale(Locale.KOREA);
ResourceBundle bundle = context.request().getResourceBundle(null);
assertEquals(Locale.KOREA, bundle.getLocale());
- assertNull(((MockResourceBundle)bundle).getBaseName());
+ assertNull(((MockResourceBundle) bundle).getBaseName());
}
@Test
public void testCaching() {
ResourceBundle bundle = context.request().getResourceBundle(Locale.GERMAN);
- ((MockResourceBundle)bundle).put("key1", "value1");
+ ((MockResourceBundle) bundle).put("key1", "value1");
assertEquals("value1", bundle.getString("key1"));
ResourceBundle bundle_cached = context.request().getResourceBundle(Locale.GERMAN);
@@ -78,5 +79,4 @@
ResourceBundle bundle_otherbasename = context.request().getResourceBundle(MY_NAME, Locale.GERMAN);
assertEquals("key1", bundle_otherbasename.getString("key1"));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/MockResourceBundleTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/MockResourceBundleTest.java
index 2fedbd5..e2e7cee 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/MockResourceBundleTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/MockResourceBundleTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.testing.mock.sling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.util.Locale;
import java.util.Map;
import java.util.Set;
@@ -29,6 +25,10 @@
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
public class MockResourceBundleTest {
private static final String MY_NAME = "my-name";
@@ -51,7 +51,7 @@
@Test
public void testWithMappings() {
underTest.put("key1", "value1");
- underTest.putAll(Map.of("key2", "value2", "key3" ,"value3"));
+ underTest.putAll(Map.of("key2", "value2", "key3", "value3"));
assertEquals("value1", underTest.getString("key1"));
assertEquals("value2", underTest.getString("key2"));
@@ -60,5 +60,4 @@
assertEquals(Set.of("key1", "key2", "key3"), underTest.keySet());
assertTrue(underTest.getKeys().hasMoreElements());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/MockSlingScriptHelperTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/MockSlingScriptHelperTest.java
index 2716ec5..a3eca49 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/MockSlingScriptHelperTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/MockSlingScriptHelperTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.testing.mock.sling;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-
import java.util.Arrays;
import org.apache.sling.api.SlingHttpServletRequest;
@@ -36,6 +32,10 @@
import org.junit.Test;
import org.osgi.framework.BundleContext;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+
public class MockSlingScriptHelperTest {
private ResourceResolver resourceResolver;
@@ -77,7 +77,7 @@
@Test
public void testGetServices() {
- Integer[] services = new Integer[] { 1, 2, 3 };
+ Integer[] services = new Integer[] {1, 2, 3};
for (Integer service : services) {
this.bundleContext.registerService(Integer.class.getName(), service, null);
}
@@ -85,5 +85,4 @@
Arrays.sort(servicesResult);
assertArrayEquals(services, servicesResult);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScannerTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScannerTest.java
index 44d8291..c91285f 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScannerTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/NodeTypeDefinitionScannerTest.java
@@ -18,10 +18,9 @@
*/
package org.apache.sling.testing.mock.sling;
-import static org.junit.Assert.assertTrue;
-
import javax.jcr.Session;
import javax.jcr.nodetype.NodeTypeIterator;
+
import java.io.StringReader;
import java.util.HashSet;
import java.util.List;
@@ -30,6 +29,7 @@
import org.apache.sling.testing.mock.jcr.MockJcr;
import org.junit.Test;
+import static org.junit.Assert.assertTrue;
public class NodeTypeDefinitionScannerTest {
@@ -45,19 +45,22 @@
@Test
public void testRegistersNodeTypes() throws Exception {
Session session = MockJcr.newSession();
- MockJcr.loadNodeTypeDefs(session, new StringReader(
- "[nt:hierarchyNode] > nt:base\n" +
- "[nt:folder] > nt:hierarchyNode"));
+ MockJcr.loadNodeTypeDefs(
+ session, new StringReader("[nt:hierarchyNode] > nt:base\n" + "[nt:folder] > nt:hierarchyNode"));
NodeTypeDefinitionScanner.get().register(session, NodeTypeMode.NODETYPES_REQUIRED);
Set<String> nodeTypes = new HashSet<>();
- NodeTypeIterator nodeTypeIterator = session.getWorkspace().getNodeTypeManager().getAllNodeTypes();
+ NodeTypeIterator nodeTypeIterator =
+ session.getWorkspace().getNodeTypeManager().getAllNodeTypes();
while (nodeTypeIterator.hasNext()) {
nodeTypes.add(nodeTypeIterator.nextNodeType().getName());
}
- assertTrue(nodeTypes.containsAll(Set.of("sling:Folder", "sling:HierarchyNode", "sling:OrderedFolder",
- "sling:Resource", "sling:ResourceSuperType")));
+ assertTrue(nodeTypes.containsAll(Set.of(
+ "sling:Folder",
+ "sling:HierarchyNode",
+ "sling:OrderedFolder",
+ "sling:Resource",
+ "sling:ResourceSuperType")));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/XSSAPIImplTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/XSSAPIImplTest.java
index 55e7dd8..5feb286 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/XSSAPIImplTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/XSSAPIImplTest.java
@@ -18,15 +18,15 @@
*/
package org.apache.sling.testing.mock.sling;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.apache.sling.xss.XSSAPI;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
public class XSSAPIImplTest {
@Rule
@@ -41,28 +41,28 @@
@Test
public void testGetValidInteger() {
- assertEquals((Integer)123, underTest.getValidInteger("123", -1));
- assertEquals((Integer)(-123), underTest.getValidInteger("-123", -1));
- assertEquals((Integer)(-1), underTest.getValidInteger("invalid", -1));
- assertEquals((Integer)(-1), underTest.getValidInteger("", -1));
- assertEquals((Integer)(-1), underTest.getValidInteger(null, -1));
+ assertEquals((Integer) 123, underTest.getValidInteger("123", -1));
+ assertEquals((Integer) (-123), underTest.getValidInteger("-123", -1));
+ assertEquals((Integer) (-1), underTest.getValidInteger("invalid", -1));
+ assertEquals((Integer) (-1), underTest.getValidInteger("", -1));
+ assertEquals((Integer) (-1), underTest.getValidInteger(null, -1));
}
@Test
public void testGetValidLong() throws Exception {
- assertEquals((Long)123L, underTest.getValidLong("123", -1L));
- assertEquals((Long)(-123L), underTest.getValidLong("-123", -1L));
- assertEquals((Long)(-1L), underTest.getValidLong("invalid", -1L));
- assertEquals((Long)(-1L), underTest.getValidLong("", -1L));
- assertEquals((Long)(-1L), underTest.getValidLong(null, -1L));
+ assertEquals((Long) 123L, underTest.getValidLong("123", -1L));
+ assertEquals((Long) (-123L), underTest.getValidLong("-123", -1L));
+ assertEquals((Long) (-1L), underTest.getValidLong("invalid", -1L));
+ assertEquals((Long) (-1L), underTest.getValidLong("", -1L));
+ assertEquals((Long) (-1L), underTest.getValidLong(null, -1L));
}
@Test
public void testGetValidDouble() throws Exception {
- assertEquals((Double)1.23d, underTest.getValidDouble("1.23", -1d));
- assertEquals((Double)(-1d), underTest.getValidDouble("invalid", -1d));
- assertEquals((Double)(-1.5d), underTest.getValidDouble("", -1.5d));
- assertEquals((Double)(-1d), underTest.getValidDouble(null, -1d));
+ assertEquals((Double) 1.23d, underTest.getValidDouble("1.23", -1d));
+ assertEquals((Double) (-1d), underTest.getValidDouble("invalid", -1d));
+ assertEquals((Double) (-1.5d), underTest.getValidDouble("", -1.5d));
+ assertEquals((Double) (-1d), underTest.getValidDouble(null, -1d));
}
@Test
@@ -167,5 +167,4 @@
assertEquals("val", underTest.filterHTML("val"));
assertEquals("", underTest.filterHTML(null));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/builder/ContentBuilderTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/builder/ContentBuilderTest.java
index 52c085c..e7a0b51 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/builder/ContentBuilderTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/builder/ContentBuilderTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.builder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.Map;
import org.apache.sling.api.resource.Resource;
@@ -32,6 +28,10 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
public class ContentBuilderTest {
@Rule
@@ -47,9 +47,12 @@
@Test
public void testResourceWithProperties_Map() {
- Resource resource = context.create().resource("/content/test1/resource2", Map.<String,Object>of(
- "jcr:title", "Test Title",
- "stringProp", "value1"));
+ Resource resource = context.create()
+ .resource(
+ "/content/test1/resource2",
+ Map.<String, Object>of(
+ "jcr:title", "Test Title",
+ "stringProp", "value1"));
assertNotNull(resource);
assertEquals("resource2", resource.getName());
ValueMap props = ResourceUtil.getValueMap(resource);
@@ -59,9 +62,8 @@
@Test
public void testResourceWithProperties_ObjectArray() {
- Resource resource = context.create().resource("/content/test1/resource2",
- "jcr:title", "Test Title",
- "stringProp", "value1");
+ Resource resource = context.create()
+ .resource("/content/test1/resource2", "jcr:title", "Test Title", "stringProp", "value1");
assertNotNull(resource);
assertEquals("resource2", resource.getName());
ValueMap props = ResourceUtil.getValueMap(resource);
@@ -78,12 +80,10 @@
assertEquals("child1", child1.getName());
assertTrue(ResourceUtil.getValueMap(child1).isEmpty());
- Resource child2 = context.create().resource(resource, "/child2",
- "prop1", "value1");
+ Resource child2 = context.create().resource(resource, "/child2", "prop1", "value1");
assertNotNull(child2);
assertEquals("child2", child2.getName());
ValueMap props = ResourceUtil.getValueMap(child2);
assertEquals("value1", props.get("prop1", String.class));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/builder/ImmutableValueMapTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/builder/ImmutableValueMapTest.java
index 42119a5..bab1e23 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/builder/ImmutableValueMapTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/builder/ImmutableValueMapTest.java
@@ -18,11 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.builder;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-
import java.util.Map;
import org.apache.sling.api.resource.ValueMap;
@@ -30,11 +25,14 @@
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
public class ImmutableValueMapTest {
- private static final Map<String, Object> SAMPLE_PROPS = Map.<String, Object>of(
- "prop1", "value1",
- "prop2", 55);
+ private static final Map<String, Object> SAMPLE_PROPS = Map.<String, Object>of("prop1", "value1", "prop2", 55);
private ValueMap underTest;
@@ -141,9 +139,12 @@
@Test
public void testBuilder() {
- ValueMap map = ImmutableValueMap.builder().put("p1", "v1")
- .putAll(Map.<String, Object> of("p2", "v2", "p3", "v3"))
- .put(Map.<String, Object> of("p4", "v4").entrySet().iterator().next()).put("p5", "v5").build();
+ ValueMap map = ImmutableValueMap.builder()
+ .put("p1", "v1")
+ .putAll(Map.<String, Object>of("p2", "v2", "p3", "v3"))
+ .put(Map.<String, Object>of("p4", "v4").entrySet().iterator().next())
+ .put("p5", "v5")
+ .build();
assertEquals(5, map.size());
assertEquals("v1", map.get("p1"));
assertEquals("v2", map.get("p2"));
@@ -167,14 +168,22 @@
@Test
public void testEquals() {
- ValueMap map1 = ImmutableValueMap.builder().put("prop1", "value1").put("prop2", 55).build();
- ValueMap map2 = ImmutableValueMap.builder().put("prop1", "value1").put("prop2", 55).build();
- ValueMap map3 = ImmutableValueMap.builder().put("prop1", "value2").put("prop2", 55).build();
+ ValueMap map1 = ImmutableValueMap.builder()
+ .put("prop1", "value1")
+ .put("prop2", 55)
+ .build();
+ ValueMap map2 = ImmutableValueMap.builder()
+ .put("prop1", "value1")
+ .put("prop2", 55)
+ .build();
+ ValueMap map3 = ImmutableValueMap.builder()
+ .put("prop1", "value2")
+ .put("prop2", 55)
+ .build();
assertEquals(map1, map2);
assertEquals(map2, map1);
assertNotEquals(map1, map3);
assertNotEquals(map2, map3);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractModelAdapterFactoryUtilTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractModelAdapterFactoryUtilTest.java
index d8bd6ae..68e2c44 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractModelAdapterFactoryUtilTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractModelAdapterFactoryUtilTest.java
@@ -18,10 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.context;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import org.apache.sling.commons.mime.MimeTypeService;
import org.apache.sling.testing.mock.sling.context.models.OsgiServiceModel;
import org.apache.sling.testing.mock.sling.context.models.RequestAttributeModel;
@@ -30,6 +26,10 @@
import org.apache.sling.testing.mock.sling.services.MockMimeTypeService;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
@SuppressWarnings("null")
public abstract class AbstractModelAdapterFactoryUtilTest {
@@ -66,5 +66,4 @@
assertNotNull(model);
assertEquals("myValue", model.getPropValue());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
index 65e0b43..e140744 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/AbstractSlingContextImplTest.java
@@ -18,12 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.context;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
import java.util.Set;
import org.apache.sling.api.resource.Resource;
@@ -43,6 +37,12 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
@SuppressWarnings("null")
public abstract class AbstractSlingContextImplTest {
@@ -93,10 +93,13 @@
@Test
public void testSetCurrentResource() {
context.currentResource("/content/sample/en/jcr:content/par/colctrl");
- assertEquals("/content/sample/en/jcr:content/par/colctrl", context.currentResource().getPath());
+ assertEquals(
+ "/content/sample/en/jcr:content/par/colctrl",
+ context.currentResource().getPath());
context.currentResource(context.resourceResolver().getResource("/content/sample/en/jcr:content/par"));
- assertEquals("/content/sample/en/jcr:content/par", context.currentResource().getPath());
+ assertEquals(
+ "/content/sample/en/jcr:content/par", context.currentResource().getPath());
context.currentResource((Resource) null);
assertNull(context.request().getResource());
@@ -165,5 +168,4 @@
// so this should throw an IllegalStateException it this is detected
MockSling.newResourceResolver(context.bundleContext());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/FeatureFlagsTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/FeatureFlagsTest.java
index 67fceb2..a06061e 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/FeatureFlagsTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/FeatureFlagsTest.java
@@ -18,15 +18,15 @@
*/
package org.apache.sling.testing.mock.sling.context;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-
import org.apache.sling.featureflags.Features;
import org.apache.sling.featureflags.impl.ConfiguredFeature;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
public class FeatureFlagsTest {
@Rule
@@ -39,17 +39,13 @@
@Test
public void testFeatureFlag_Enabled() {
- context.registerInjectActivateService(new ConfiguredFeature(),
- "name", "feature.1",
- "enabled", true);
+ context.registerInjectActivateService(new ConfiguredFeature(), "name", "feature.1", "enabled", true);
assertEnabled("feature.1", true);
}
@Test
public void testFeatureFlag__Disabled() {
- context.registerInjectActivateService(new ConfiguredFeature(),
- "name", "feature.1",
- "enabled", false);
+ context.registerInjectActivateService(new ConfiguredFeature(), "name", "feature.1", "enabled", false);
assertEnabled("feature.1", false);
}
@@ -58,5 +54,4 @@
assertNotNull(features);
assertEquals("enabled", enabled, features.isEnabled("feature.1"));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilClassesTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilClassesTest.java
index f3b6c44..f7139db 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilClassesTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilClassesTest.java
@@ -38,15 +38,10 @@
@Before
public void setUp() throws Exception {
// add Model classes individually
- // although this is not supported before Sling Models Impl 1.3.4 in mocks this works even with older sling models versions
+ // although this is not supported before Sling Models Impl 1.3.4 in mocks this works even with older sling
+ // models versions
// because the class path scanning is implemented differently
- context.addModelsForClasses(
- OsgiServiceModel.class.getName()
- );
- context.addModelsForClasses(
- RequestAttributeModel.class,
- ServiceInterfaceImpl.class
- );
+ context.addModelsForClasses(OsgiServiceModel.class.getName());
+ context.addModelsForClasses(RequestAttributeModel.class, ServiceInterfaceImpl.class);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilPackagesTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilPackagesTest.java
index 3547d9a..806f0bd 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilPackagesTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/ModelAdapterFactoryUtilPackagesTest.java
@@ -36,9 +36,6 @@
public void setUp() throws Exception {
// scan for @Model classes
context.addModelsForPackage(
- "org.apache.sling.testing.mock.sling.context",
- "org.apache.sling.testing.mock.sling.context.models"
- );
+ "org.apache.sling.testing.mock.sling.context", "org.apache.sling.testing.mock.sling.context.models");
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/NoResourceResolverTypeTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/NoResourceResolverTypeTest.java
index 443404a..d6fa722 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/NoResourceResolverTypeTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/NoResourceResolverTypeTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.context;
-import static org.junit.Assert.assertTrue;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.SyntheticResource;
import org.apache.sling.spi.resource.provider.ResourceProvider;
@@ -31,6 +29,8 @@
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertTrue;
+
@RunWith(MockitoJUnitRunner.class)
public class NoResourceResolverTypeTest {
@@ -44,11 +44,9 @@
public void testRoot() {
// register dummy resource provider because otherwise ResourceResolverFactory get's not activated
// with latest sling resource resolver implementation
- context.registerService(ResourceProvider.class, resourceProvider,
- ResourceProvider.PROPERTY_ROOT, "/");
+ context.registerService(ResourceProvider.class, resourceProvider, ResourceProvider.PROPERTY_ROOT, "/");
Resource root = context.resourceResolver().getResource("/");
assertTrue(root instanceof SyntheticResource);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/NoSlingModelsRegistrationTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/NoSlingModelsRegistrationTest.java
index c7066cb..7ffb872 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/NoSlingModelsRegistrationTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/NoSlingModelsRegistrationTest.java
@@ -18,21 +18,20 @@
*/
package org.apache.sling.testing.mock.sling.context;
-import static org.junit.Assert.assertNull;
-
import org.apache.sling.testing.mock.sling.context.modelsautoreg.ClasspathRegisteredModel;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.apache.sling.testing.mock.sling.junit.SlingContextBuilder;
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertNull;
+
@SuppressWarnings("null")
public class NoSlingModelsRegistrationTest {
@Rule
- public SlingContext context = new SlingContextBuilder()
- .registerSlingModelsFromClassPath(false)
- .build();
+ public SlingContext context =
+ new SlingContextBuilder().registerSlingModelsFromClassPath(false).build();
@Test
public void testSlnigModelClasspathRegistered() {
@@ -41,5 +40,4 @@
// expect null because ClasspathRegisteredModel should not be registered automatically from classpath
assertNull(model);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/SlingBindingsTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/SlingBindingsTest.java
index 7a9495d..967930a 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/SlingBindingsTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/SlingBindingsTest.java
@@ -18,11 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.context;
-import static org.apache.sling.testing.mock.sling.context.MockSlingBindings.SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
import javax.script.Bindings;
import org.apache.sling.api.resource.Resource;
@@ -35,6 +30,11 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.apache.sling.testing.mock.sling.context.MockSlingBindings.SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
@SuppressWarnings("null")
public class SlingBindingsTest {
@@ -54,12 +54,16 @@
});
// setup another custom BindingsValuesProvider which should be ignored
- context.registerService(BindingsValuesProvider.class, new BindingsValuesProvider() {
- @Override
- public void addBindings(Bindings bindings) {
- bindings.put("custom-param-2", "value-2");
- }
- }, SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE, true);
+ context.registerService(
+ BindingsValuesProvider.class,
+ new BindingsValuesProvider() {
+ @Override
+ public void addBindings(Bindings bindings) {
+ bindings.put("custom-param-2", "value-2");
+ }
+ },
+ SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE,
+ true);
context.addModelsForClasses(SlingBindingsModel.class);
currentResource = context.create().resource("/content/testPage/testResource");
@@ -95,12 +99,11 @@
@Test
public void testCustomBindingsValuesProvider() {
- SlingBindings bindings = (SlingBindings)context.request().getAttribute(SlingBindings.class.getName());
+ SlingBindings bindings = (SlingBindings) context.request().getAttribute(SlingBindings.class.getName());
assertNotNull(bindings);
assertEquals(currentResource.getPath(), bindings.getResource().getPath());
assertEquals("value-1", bindings.get("custom-param-1"));
assertNull(bindings.get("custom-param-2"));
assertEquals("value-3", bindings.get("custom-param-3"));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/OsgiServiceModel.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/OsgiServiceModel.java
index add20e9..45173f5 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/OsgiServiceModel.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/OsgiServiceModel.java
@@ -32,5 +32,4 @@
@Inject
MimeTypeService getMimeTypeService();
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/RequestAttributeModel.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/RequestAttributeModel.java
index 958b67d..62b72aa 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/RequestAttributeModel.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/RequestAttributeModel.java
@@ -31,5 +31,4 @@
@Inject
String getProp1();
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ResourceModel.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ResourceModel.java
index 4ffb667..dab2d41 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ResourceModel.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ResourceModel.java
@@ -23,7 +23,7 @@
@Model(adaptables = Resource.class)
public class ResourceModel {
-
+
private final Resource resource;
public ResourceModel(Resource resource) {
@@ -33,5 +33,4 @@
public Resource getAdaptable() {
return resource;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterface.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterface.java
index d434f56..3b5fa91 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterface.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterface.java
@@ -24,5 +24,4 @@
public interface ServiceInterface {
String getPropValue();
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterfaceImpl.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterfaceImpl.java
index ef1a639..e743afd 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterfaceImpl.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/ServiceInterfaceImpl.java
@@ -36,5 +36,4 @@
public String getPropValue() {
return this.prop1;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/SlingBindingsModel.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/SlingBindingsModel.java
index 6a15464..f5499d2 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/SlingBindingsModel.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/models/SlingBindingsModel.java
@@ -61,5 +61,4 @@
@ScriptVariable(name = "custom-param-3", injectionStrategy = InjectionStrategy.OPTIONAL)
String getCustomParam3();
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/context/modelsautoreg/ClasspathRegisteredModel.java b/core/src/test/java/org/apache/sling/testing/mock/sling/context/modelsautoreg/ClasspathRegisteredModel.java
index b5c7f81..3a16eab 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/context/modelsautoreg/ClasspathRegisteredModel.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/context/modelsautoreg/ClasspathRegisteredModel.java
@@ -32,5 +32,4 @@
@Inject
String getProp1();
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/context/SlingContextImplTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/context/SlingContextImplTest.java
index 73b951c..b53f698 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/context/SlingContextImplTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/context/SlingContextImplTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderAutoCommitTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderAutoCommitTest.java
index bd76ee5..8cf5d24 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderAutoCommitTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderAutoCommitTest.java
@@ -23,7 +23,8 @@
public class ContentLoaderAutoCommitTest extends AbstractContentLoaderAutoCommitTest {
- @Override protected ResourceResolverType getResourceResolverType() {
+ @Override
+ protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
index f424d50..53f2d8b 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderBinaryTest.java
@@ -29,5 +29,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFileVaultXmlTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFileVaultXmlTest.java
index 6431531..9c855c0 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFileVaultXmlTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFileVaultXmlTest.java
@@ -26,5 +26,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFolderFileVaultXmlTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFolderFileVaultXmlTest.java
index b920628..1c4fb5e 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFolderFileVaultXmlTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFolderFileVaultXmlTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFolderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFolderJsonTest.java
index 4aaa87c..3f46247 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFolderJsonTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderFolderJsonTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
index ceb5b57..5b01045 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonDamTest.java
@@ -26,5 +26,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
index eaa297c..7b4acaf 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/loader/ContentLoaderJsonTest.java
@@ -26,5 +26,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/FindResourcesTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/FindResourcesTest.java
index 55a9bb7..ffafdbc 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/FindResourcesTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/FindResourcesTest.java
@@ -18,14 +18,14 @@
*/
package org.apache.sling.testing.mock.sling.jcrmock.resource;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
import javax.jcr.Node;
import javax.jcr.Session;
import javax.jcr.query.Query;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.jcr.MockJcr;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -38,32 +38,32 @@
@SuppressWarnings("null")
public class FindResourcesTest {
- @Rule
- public SlingContext context = new SlingContext(ResourceResolverType.JCR_MOCK);
+ @Rule
+ public SlingContext context = new SlingContext(ResourceResolverType.JCR_MOCK);
- @Before
- public void setUp() {
- Resource resource = context.create().resource(
- "/test",
- Map.<String, Object>of(
- "prop1", "value1",
- "prop2", "value2"));
- Node node = resource.adaptTo(Node.class);
- Session session = context.resourceResolver().adaptTo(Session.class);
+ @Before
+ public void setUp() {
+ Resource resource = context.create()
+ .resource(
+ "/test",
+ Map.<String, Object>of(
+ "prop1", "value1",
+ "prop2", "value2"));
+ Node node = resource.adaptTo(Node.class);
+ Session session = context.resourceResolver().adaptTo(Session.class);
- MockJcr.setQueryResult(session, Collections.singletonList(node));
- }
+ MockJcr.setQueryResult(session, Collections.singletonList(node));
+ }
- @Test
+ @Test
@SuppressWarnings("deprecation")
- public void testFindResources() {
- Resource resource = context.resourceResolver().getResource("/test");
- Assert.assertNotNull("Resource with name 'test' should be there", resource);
+ public void testFindResources() {
+ Resource resource = context.resourceResolver().getResource("/test");
+ Assert.assertNotNull("Resource with name 'test' should be there", resource);
Iterator<Resource> result = context.resourceResolver().findResources("/test", Query.XPATH);
- Assert.assertTrue("At least one result expected", result.hasNext());
- Assert.assertEquals("/test", result.next().getPath());
- Assert.assertFalse("At most one result expected", result.hasNext());
- }
-
+ Assert.assertTrue("At least one result expected", result.hasNext());
+ Assert.assertEquals("/test", result.next().getPath());
+ Assert.assertFalse("At most one result expected", result.hasNext());
+ }
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrNamespaceTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrNamespaceTest.java
index e1e3a4c..cc27848 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrNamespaceTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrNamespaceTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
index 9a7da28..c39c573 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/JcrResourceResolverTest.java
@@ -31,5 +31,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/MultipleResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/MultipleResourceResolverTest.java
index cc02db4..494ebc4 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/MultipleResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/MultipleResourceResolverTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
index b46da3e..f0a00bc 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/SlingCrudResourceResolverTest.java
@@ -31,5 +31,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java
index 73c6793..cc58051 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/UniqueRootTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.JCR_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java b/core/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
index f1d2f9f..6401cc6 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
@@ -83,7 +83,9 @@
* @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
* @param resourceResolverType Resource resolver type.
*/
- public <T extends OsgiContextImpl> SlingContext(@NotNull final ContextCallback<T> afterSetUpCallback, @NotNull final ResourceResolverType resourceResolverType) {
+ public <T extends OsgiContextImpl> SlingContext(
+ @NotNull final ContextCallback<T> afterSetUpCallback,
+ @NotNull final ResourceResolverType resourceResolverType) {
this(new ContextPlugins(afterSetUpCallback), null, resourceResolverType);
}
@@ -95,7 +97,8 @@
* @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
* @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
*/
- public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(@NotNull final ContextCallback<U> afterSetUpCallback,
+ public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(
+ @NotNull final ContextCallback<U> afterSetUpCallback,
@NotNull final ContextCallback<V> beforeTearDownCallback) {
this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, null);
}
@@ -108,7 +111,8 @@
* @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
* @param resourceResolverType Resource resolver type.
*/
- public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(@NotNull final ContextCallback<U> afterSetUpCallback,
+ public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(
+ @NotNull final ContextCallback<U> afterSetUpCallback,
@NotNull final ContextCallback<V> beforeTearDownCallback,
@NotNull final ResourceResolverType resourceResolverType) {
this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, resourceResolverType);
@@ -120,7 +124,8 @@
* @param resourceResolverFactoryActivatorProps Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
* @param resourceResolverType Resource resolver type.
*/
- SlingContext(@NotNull final ContextPlugins contextPlugins,
+ SlingContext(
+ @NotNull final ContextPlugins contextPlugins,
@Nullable final Map<String, Object> resourceResolverFactoryActivatorProps,
@Nullable final ResourceResolverType resourceResolverType) {
this(contextPlugins, resourceResolverFactoryActivatorProps, resourceResolverType, true);
@@ -133,7 +138,8 @@
* @param resourceResolverType Resource resolver type.
* @param registerSlingModelsFromClassPath Automatic registering of all Sling Models found in the classpath on startup.
*/
- SlingContext(@NotNull final ContextPlugins contextPlugins,
+ SlingContext(
+ @NotNull final ContextPlugins contextPlugins,
@Nullable final Map<String, Object> resourceResolverFactoryActivatorProps,
@Nullable final ResourceResolverType resourceResolverType,
final boolean registerSlingModelsFromClassPath) {
@@ -167,5 +173,4 @@
public Statement apply(final Statement base, final Description description) {
return this.delegate.apply(base, description);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java b/core/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
index 329b19b..bf6c69b 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
@@ -74,7 +74,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder plugin(@NotNull ContextPlugin<? extends OsgiContextImpl> @NotNull ... plugin) {
+ public final @NotNull SlingContextBuilder plugin(
+ @NotNull ContextPlugin<? extends OsgiContextImpl> @NotNull ... plugin) {
plugins.addPlugin(plugin);
return this;
}
@@ -85,7 +86,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder beforeSetUp(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeSetUpCallback) {
+ public final @NotNull SlingContextBuilder beforeSetUp(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeSetUpCallback) {
plugins.addBeforeSetUpCallback(beforeSetUpCallback);
return this;
}
@@ -96,7 +98,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder afterSetUp(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterSetUpCallback) {
+ public final @NotNull SlingContextBuilder afterSetUp(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterSetUpCallback) {
plugins.addAfterSetUpCallback(afterSetUpCallback);
return this;
}
@@ -107,7 +110,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder beforeTearDown(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeTearDownCallback) {
+ public final @NotNull SlingContextBuilder beforeTearDown(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeTearDownCallback) {
plugins.addBeforeTearDownCallback(beforeTearDownCallback);
return this;
}
@@ -118,7 +122,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder afterTearDown(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterTearDownCallback) {
+ public final @NotNull SlingContextBuilder afterTearDown(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterTearDownCallback) {
plugins.addAfterTearDownCallback(afterTearDownCallback);
return this;
}
@@ -129,8 +134,8 @@
* @return this
*/
public @NotNull SlingContextBuilder resourceResolverFactoryActivatorProps(@NotNull Map<String, Object> props) {
- this.resourceResolverFactoryActivatorProps = props;
- return this;
+ this.resourceResolverFactoryActivatorProps = props;
+ return this;
}
/**
@@ -139,18 +144,18 @@
* @return this
*/
public @NotNull SlingContextBuilder registerSlingModelsFromClassPath(boolean registerSlingModelsFromClassPath) {
- this.registerSlingModelsFromClassPath = registerSlingModelsFromClassPath;
- return this;
+ this.registerSlingModelsFromClassPath = registerSlingModelsFromClassPath;
+ return this;
}
/**
* @return Build {@link SlingContext} instance.
*/
public @NotNull SlingContext build() {
- return new SlingContext(this.plugins,
+ return new SlingContext(
+ this.plugins,
this.resourceResolverFactoryActivatorProps,
this.resourceResolverType,
this.registerSlingModelsFromClassPath);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderAutoCommitTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderAutoCommitTest.java
index b0df5fd..7a442fb 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderAutoCommitTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderAutoCommitTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.loader;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -30,14 +27,15 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
public abstract class AbstractContentLoaderAutoCommitTest {
private static String DEST_RES_NAME = "dest";
private static String MIME_TYPE_JSON = "application/json";
private static String CLP_CONTENT = "/json-import-samples/content.json";
- private static byte[] MEM_CONTENT = ("{"
- + "\"jcr:primaryType\":\"sling:Folder\""
- + "}").getBytes();
+ private static byte[] MEM_CONTENT = ("{" + "\"jcr:primaryType\":\"sling:Folder\"" + "}").getBytes();
private int destResCount = 1;
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
index 8887393..39eecb8 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderBinaryTest.java
@@ -18,11 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.loader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-
import java.io.IOException;
import java.io.InputStream;
@@ -39,6 +34,11 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
+
@RunWith(MockitoJUnitRunner.class)
@SuppressWarnings("null")
public abstract class AbstractContentLoaderBinaryTest {
@@ -118,5 +118,4 @@
assertNotNull(resource);
assertEquals(mimeType, ResourceUtil.getValueMap(resource).get(JcrConstants.JCR_MIMETYPE, String.class));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFileVaultXmlTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFileVaultXmlTest.java
index 4dd192c..0f31a95 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFileVaultXmlTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFileVaultXmlTest.java
@@ -18,15 +18,12 @@
*/
package org.apache.sling.testing.mock.sling.loader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-
-import java.util.List;
-
import javax.jcr.Node;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import java.util.List;
+
import org.apache.jackrabbit.JcrConstants;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
@@ -39,6 +36,9 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
@SuppressWarnings("null")
public abstract class AbstractContentLoaderFileVaultXmlTest {
@@ -54,15 +54,19 @@
path = context.uniqueRoot().content();
try {
- NodeTypeDefinitionScanner.get().register(context.resourceResolver().adaptTo(Session.class),
- List.of("SLING-INF/nodetypes/app.cnd"),
- getResourceResolverType().getNodeTypeMode());
- }
- catch (RepositoryException ex) {
+ NodeTypeDefinitionScanner.get()
+ .register(
+ context.resourceResolver().adaptTo(Session.class),
+ List.of("SLING-INF/nodetypes/app.cnd"),
+ getResourceResolverType().getNodeTypeMode());
+ } catch (RepositoryException ex) {
throw new RuntimeException("Unable to register namespaces.", ex);
}
- context.load().fileVaultXml("src/test/resources/xml-jcr-import-samples/content/samples/en/.content.xml", path + "/sample/en");
+ context.load()
+ .fileVaultXml(
+ "src/test/resources/xml-jcr-import-samples/content/samples/en/.content.xml",
+ path + "/sample/en");
}
@After
@@ -112,5 +116,4 @@
assertEquals(nodeType, props.get(JcrConstants.JCR_PRIMARYTYPE));
}
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderFileVaultXmlTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderFileVaultXmlTest.java
index bff494b..c0c9dab 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderFileVaultXmlTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderFileVaultXmlTest.java
@@ -18,11 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.loader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@@ -38,6 +33,11 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
@SuppressWarnings("null")
public abstract class AbstractContentLoaderFolderFileVaultXmlTest {
@@ -80,7 +80,8 @@
@Test
public void testBinaryResource() throws IOException {
- Resource fileResource = context.resourceResolver().getResource("/content/dam/talk.png/jcr:content/renditions/original");
+ Resource fileResource =
+ context.resourceResolver().getResource("/content/dam/talk.png/jcr:content/renditions/original");
try (InputStream is = fileResource.adaptTo(InputStream.class)) {
assertNotNull("InputSteam is null for " + fileResource.getPath(), is);
byte[] binaryData = IOUtils.toByteArray(is);
@@ -112,5 +113,4 @@
assertTrue(context.resourceResolver().isResourceType(resource, "app1/components/base"));
assertTrue(context.resourceResolver().isResourceType(resource, "core/components/superResource"));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderJsonTest.java
index 205d0d3..5d7a23c 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderJsonTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderFolderJsonTest.java
@@ -18,11 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.loader;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.IOException;
import java.util.List;
@@ -36,6 +31,11 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
@SuppressWarnings("null")
public abstract class AbstractContentLoaderFolderJsonTest {
@@ -113,16 +113,20 @@
context.load().folderJson("src/test/resources/test-content", root);
Resource parent = context.resourceResolver().getResource(root + "/parent");
- assertNotNull( "Expected to resolve the 'parent' resource.", parent);
+ assertNotNull("Expected to resolve the 'parent' resource.", parent);
assertNotNull("Expected to resolver the 'child' resource.", parent.getChild("child"));
Resource uniqueRoot = context.resourceResolver().getParent(parent);
assertNotNull("Expected to resolve the unique root.", uniqueRoot);
- assertEquals("The resolved unique root is not identical to the created unique root.", root, uniqueRoot.getPath());
+ assertEquals(
+ "The resolved unique root is not identical to the created unique root.", root, uniqueRoot.getPath());
- assertTrue("Expected to see a list of children.", context.resourceResolver().listChildren(parent).hasNext());
- assertTrue("Expected to get a list of children.", context.resourceResolver().getChildren(parent).iterator().hasNext());
+ assertTrue(
+ "Expected to see a list of children.",
+ context.resourceResolver().listChildren(parent).hasNext());
+ assertTrue(
+ "Expected to get a list of children.",
+ context.resourceResolver().getChildren(parent).iterator().hasNext());
assertTrue("Expected to see a list of children.", parent.hasChildren());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
index 843c54d..1fa7a92 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonDamTest.java
@@ -18,18 +18,13 @@
*/
package org.apache.sling.testing.mock.sling.loader;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
import org.apache.commons.io.IOUtils;
import org.apache.jackrabbit.JcrConstants;
import org.apache.sling.api.resource.Resource;
@@ -43,6 +38,11 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
@SuppressWarnings("null")
public abstract class AbstractContentLoaderJsonDamTest {
@@ -58,11 +58,12 @@
path = context.uniqueRoot().content() + "/dam";
try {
- NodeTypeDefinitionScanner.get().register(context.resourceResolver().adaptTo(Session.class),
- List.of("SLING-INF/nodetypes/app.cnd"),
- getResourceResolverType().getNodeTypeMode());
- }
- catch (RepositoryException ex) {
+ NodeTypeDefinitionScanner.get()
+ .register(
+ context.resourceResolver().adaptTo(Session.class),
+ List.of("SLING-INF/nodetypes/app.cnd"),
+ getResourceResolverType().getNodeTypeMode());
+ } catch (RepositoryException ex) {
throw new RuntimeException("Unable to register namespaces.", ex);
}
@@ -86,8 +87,13 @@
assertEquals((Integer) 595, props.get("tiff:ImageLength", Integer.class));
assertEquals(4.64385986328125d, props.get("dam:ApertureValue", Double.class), 0.00000000001d);
- assertArrayEquals(new String[] { "stockphotography:business/business_people", "properties:style/color",
- "properties:orientation/landscape" }, props.get("app:tags", String[].class));
+ assertArrayEquals(
+ new String[] {
+ "stockphotography:business/business_people",
+ "properties:style/color",
+ "properties:orientation/landscape"
+ },
+ props.get("app:tags", String[].class));
// validate that a binary data node is present, but empty
Resource binaryMetadata = context.resourceResolver()
@@ -98,5 +104,4 @@
byte[] binaryData = IOUtils.toByteArray(is);
assertEquals(0, binaryData.length);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
index fbb3542..30c2153 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/loader/AbstractContentLoaderJsonTest.java
@@ -18,19 +18,14 @@
*/
package org.apache.sling.testing.mock.sling.loader;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import java.util.Calendar;
import java.util.List;
import java.util.TimeZone;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
import org.apache.jackrabbit.JcrConstants;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceUtil;
@@ -43,6 +38,11 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
@SuppressWarnings("null")
public abstract class AbstractContentLoaderJsonTest {
@@ -58,11 +58,12 @@
path = context.uniqueRoot().content();
try {
- NodeTypeDefinitionScanner.get().register(context.resourceResolver().adaptTo(Session.class),
- List.of("SLING-INF/nodetypes/app.cnd"),
- getResourceResolverType().getNodeTypeMode());
- }
- catch (RepositoryException ex) {
+ NodeTypeDefinitionScanner.get()
+ .register(
+ context.resourceResolver().adaptTo(Session.class),
+ List.of("SLING-INF/nodetypes/app.cnd"),
+ getResourceResolverType().getNodeTypeMode());
+ } catch (RepositoryException ex) {
throw new RuntimeException("Unable to register namespaces.", ex);
}
@@ -109,9 +110,9 @@
assertEquals(1.2345d, props.get("decimalProp", Double.class), 0.00001d);
assertEquals(true, props.get("booleanProp", Boolean.class));
- assertArrayEquals(new Long[] { 1234567890123L, 55L }, props.get("longPropMulti", Long[].class));
- assertArrayEquals(new Double[] { 1.2345d, 1.1d }, props.get("decimalPropMulti", Double[].class));
- assertArrayEquals(new Boolean[] { true, false }, props.get("booleanPropMulti", Boolean[].class));
+ assertArrayEquals(new Long[] {1234567890123L, 55L}, props.get("longPropMulti", Long[].class));
+ assertArrayEquals(new Double[] {1.2345d, 1.1d}, props.get("decimalPropMulti", Double[].class));
+ assertArrayEquals(new Boolean[] {true, false}, props.get("booleanPropMulti", Boolean[].class));
}
@Test
@@ -191,7 +192,8 @@
@Test
public void testJcrUuid() {
- Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content/par/image/file/jcr:content");
+ Resource resource =
+ context.resourceResolver().getResource(path + "/sample/en/jcr:content/par/image/file/jcr:content");
ValueMap props = ResourceUtil.getValueMap(resource);
assertEquals("eda76d00-b2cd-4b59-878f-c33f71ceaddc", props.get(JcrConstants.JCR_UUID));
@@ -204,5 +206,4 @@
assertNotNull(props.get(JcrConstants.JCR_CREATED));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java
index 308aa9f..034ed9b 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrNamespaceTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.resource;
-import static org.junit.Assert.assertEquals;
-
import javax.jcr.RepositoryException;
import org.apache.sling.api.resource.Resource;
@@ -35,6 +33,8 @@
import org.junit.Test;
import org.osgi.framework.BundleContext;
+import static org.junit.Assert.assertEquals;
+
/**
* Validates correct registering and mapping of JCR namespaces, esp. the sling namespace.
*/
@@ -52,7 +52,8 @@
ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType(), bundleContext);
ContentLoader contentLoader = new ContentLoader(resolver);
- contentLoader.json("/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
+ contentLoader.json(
+ "/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
Resource resource = resolver.getResource(context.uniqueRoot().content() + "/foo");
@@ -68,7 +69,8 @@
ResourceResolver resolver = context.resourceResolver();
ContentLoader contentLoader = new ContentLoader(resolver);
- contentLoader.json("/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
+ contentLoader.json(
+ "/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
Resource resource = resolver.getResource(context.uniqueRoot().content() + "/foo");
@@ -76,5 +78,4 @@
assertEquals("fooType", props.get("sling:resourceType"));
assertEquals("fooType", resource.getResourceType());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
index 115aba9..503f80e 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractJcrResourceResolverTest.java
@@ -18,11 +18,9 @@
*/
package org.apache.sling.testing.mock.sling.resource;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -32,10 +30,6 @@
import java.util.List;
import java.util.Map;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.time.DateUtils;
@@ -51,6 +45,12 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Implements simple write and read resource and values test.
* JCR API is used to create the test data.
@@ -62,13 +62,13 @@
public SlingContext context = new SlingContext(getResourceResolverType());
private static final String STRING_VALUE = "value1";
- private static final String[] STRING_ARRAY_VALUE = new String[] { "value1", "value2" };
+ private static final String[] STRING_ARRAY_VALUE = new String[] {"value1", "value2"};
private static final int INTEGER_VALUE = 25;
private static final double DOUBLE_VALUE = 3.555d;
private static final boolean BOOLEAN_VALUE = true;
private static final Date DATE_VALUE = new Date(10000);
private static final Calendar CALENDAR_VALUE = Calendar.getInstance();
- private static final byte[] BINARY_VALUE = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+ private static final byte[] BINARY_VALUE = new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
private Session session;
protected Node testRoot;
@@ -108,14 +108,17 @@
*/
private Node getTestRootNode() throws RepositoryException {
if (this.testRoot == null) {
- this.testRoot = context.resourceResolver().getResource(context.uniqueRoot().content()).adaptTo(Node.class);
+ this.testRoot = context.resourceResolver()
+ .getResource(context.uniqueRoot().content())
+ .adaptTo(Node.class);
}
return testRoot;
}
@Test
public void testGetResourcesAndValues() throws IOException, RepositoryException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootNode().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootNode().getPath() + "/node1");
assertNotNull(resource1);
assertEquals("node1", resource1.getName());
@@ -126,7 +129,9 @@
assertEquals(DOUBLE_VALUE, props.get("doubleProp", Double.class), 0.0001);
assertEquals(BOOLEAN_VALUE, props.get("booleanProp", Boolean.class));
assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
- assertEquals(CALENDAR_VALUE.getTime(), props.get("calendarProp", Calendar.class).getTime());
+ assertEquals(
+ CALENDAR_VALUE.getTime(),
+ props.get("calendarProp", Calendar.class).getTime());
Resource binaryPropResource = resource1.getChild("binaryProp");
InputStream is = binaryPropResource.adaptTo(InputStream.class);
@@ -148,21 +153,32 @@
@Test
public void testCreateNodeWithPrimaryType() throws RepositoryException, PersistenceException {
- Resource parent = context.resourceResolver().getResource(getTestRootNode().getPath());
+ Resource parent =
+ context.resourceResolver().getResource(getTestRootNode().getPath());
- Resource child = context.resourceResolver().create(parent, "nodeTypeResource", Map.<String, Object>of(
- "sling:resourceType", JcrConstants.NT_UNSTRUCTURED));
+ Resource child = context.resourceResolver()
+ .create(
+ parent,
+ "nodeTypeResource",
+ Map.<String, Object>of("sling:resourceType", JcrConstants.NT_UNSTRUCTURED));
assertNotNull(child);
assertEquals(JcrConstants.NT_UNSTRUCTURED, child.getResourceType());
- assertEquals(JcrConstants.NT_UNSTRUCTURED, child.adaptTo(Node.class).getPrimaryNodeType().getName());
+ assertEquals(
+ JcrConstants.NT_UNSTRUCTURED,
+ child.adaptTo(Node.class).getPrimaryNodeType().getName());
}
@Test
public void testCreateNodeWithResourceType() throws RepositoryException, PersistenceException {
- Resource parent = context.resourceResolver().getResource(getTestRootNode().getPath());
+ Resource parent =
+ context.resourceResolver().getResource(getTestRootNode().getPath());
- Resource child = ResourceUtil.getOrCreateResource(context.resourceResolver(), parent.getPath() + "/intermediate/child",
- "sling/resource/type", JcrConstants.NT_UNSTRUCTURED, true);
+ Resource child = ResourceUtil.getOrCreateResource(
+ context.resourceResolver(),
+ parent.getPath() + "/intermediate/child",
+ "sling/resource/type",
+ JcrConstants.NT_UNSTRUCTURED,
+ true);
assertNotNull(child);
assertEquals("sling:OrderedFolder", parent.getResourceType());
assertEquals("sling/resource/type", child.getResourceType());
@@ -172,16 +188,16 @@
public void testPendingChangesCommit() throws Exception {
// skip this test for JCR_MOCK because it does not track pending changes
- if (getResourceResolverType()==ResourceResolverType.JCR_MOCK) {
+ if (getResourceResolverType() == ResourceResolverType.JCR_MOCK) {
return;
}
- Resource testRootResource = context.resourceResolver().getResource(getTestRootNode().getPath());
+ Resource testRootResource =
+ context.resourceResolver().getResource(getTestRootNode().getPath());
context.resourceResolver().delete(testRootResource);
assertTrue(session.hasPendingChanges());
context.resourceResolver().commit();
assertFalse(session.hasPendingChanges());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java
index 4270db7..4bf7831 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractMultipleResourceResolverTest.java
@@ -18,11 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.resource;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
import java.util.Collections;
import java.util.Map;
@@ -38,6 +33,11 @@
import org.junit.Test;
import org.osgi.framework.BundleContext;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Tests content access accross multiple resource resolvers.
*/
@@ -99,11 +99,14 @@
createResourceAndCheckResourceType(resourceResolver);
}
- private static void createResourceAndCheckResourceType(ResourceResolver serviceResolver) throws PersistenceException {
+ private static void createResourceAndCheckResourceType(ResourceResolver serviceResolver)
+ throws PersistenceException {
Resource root = serviceResolver.getResource("/");
- Resource resource = serviceResolver.create(root, "testResource", Collections.singletonMap("sling:resourceType", "testResourceType"));
+ Resource resource = serviceResolver.create(
+ root, "testResource", Collections.singletonMap("sling:resourceType", "testResourceType"));
assertTrue("is expected resource type 'testResourceType'", resource.isResourceType("testResourceType"));
- assertFalse("is not unexpected resource type 'anotherResourceType'", resource.isResourceType("anotherResourceType"));
+ assertFalse(
+ "is not unexpected resource type 'anotherResourceType'",
+ resource.isResourceType("anotherResourceType"));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
index 1cccf5f..0fd95c4 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractSlingCrudResourceResolverTest.java
@@ -18,12 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.resource;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -52,6 +46,12 @@
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
/**
* Implements simple write and read resource and values test. Sling CRUD API is
* used to create the test data.
@@ -63,7 +63,7 @@
public SlingContext context = new SlingContext(getResourceResolverType());
private static final String STRING_VALUE = "value1";
- private static final String[] STRING_ARRAY_VALUE = new String[] { "value1", "value2" };
+ private static final String[] STRING_ARRAY_VALUE = new String[] {"value1", "value2"};
private static final int INTEGER_VALUE = 25;
private static final long LONG_VALUE = 250L;
private static final double DOUBLE_VALUE = 3.555d;
@@ -71,9 +71,10 @@
private static final boolean BOOLEAN_VALUE = true;
private static final Date DATE_VALUE = new Date(10000);
private static final Calendar CALENDAR_VALUE = Calendar.getInstance();
- private static final byte[] BINARY_VALUE = new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
+ private static final byte[] BINARY_VALUE = new byte[] {0x01, 0x02, 0x03, 0x04, 0x05, 0x06};
protected Resource testRoot;
+
protected abstract ResourceResolverType getResourceResolverType();
@Before
@@ -96,8 +97,7 @@
props.put("binaryProp", new ByteArrayInputStream(BINARY_VALUE));
Resource node1 = context.resourceResolver().create(rootNode, "node1", props);
- context.resourceResolver().create(node1, "node11", Map.<String, Object>of(
- "stringProp11", STRING_VALUE));
+ context.resourceResolver().create(node1, "node11", Map.<String, Object>of("stringProp11", STRING_VALUE));
context.resourceResolver().create(node1, "node12", ValueMap.EMPTY);
context.resourceResolver().commit();
@@ -109,22 +109,24 @@
*/
protected Resource getTestRootResource() throws PersistenceException {
if (this.testRoot == null) {
- this.testRoot = context.resourceResolver().getResource(context.uniqueRoot().content());
+ this.testRoot =
+ context.resourceResolver().getResource(context.uniqueRoot().content());
}
return this.testRoot;
}
@Test
public void testSimpleProperties() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
assertNotNull(resource1);
assertEquals("node1", resource1.getName());
ValueMap props = ResourceUtil.getValueMap(resource1);
assertEquals(STRING_VALUE, props.get("stringProp", String.class));
assertArrayEquals(STRING_ARRAY_VALUE, props.get("stringArrayProp", String[].class));
- assertEquals((Integer)INTEGER_VALUE, props.get("integerProp", Integer.class));
- assertEquals((Long)LONG_VALUE, props.get("longProp", Long.class));
+ assertEquals((Integer) INTEGER_VALUE, props.get("integerProp", Integer.class));
+ assertEquals((Long) LONG_VALUE, props.get("longProp", Long.class));
assertEquals(DOUBLE_VALUE, props.get("doubleProp", Double.class), 0.0001);
assertEquals(BIGDECIMAL_VALUE, props.get("bigDecimalProp", BigDecimal.class));
assertEquals(BOOLEAN_VALUE, props.get("booleanProp", Boolean.class));
@@ -132,20 +134,25 @@
@Test
public void testSimpleProperties_IntegerLongConversion() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
- assertEquals((Integer)(int)LONG_VALUE, props.get("longProp", Integer.class));
- assertEquals((Long)(long)INTEGER_VALUE, props.get("integerProp", Long.class));
+ assertEquals((Integer) (int) LONG_VALUE, props.get("longProp", Integer.class));
+ assertEquals((Long) (long) INTEGER_VALUE, props.get("integerProp", Long.class));
}
@Test
public void testSimpleProperties_DecimalConversion() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
- assertEquals(new BigDecimal(DOUBLE_VALUE).doubleValue(), props.get("doubleProp", BigDecimal.class).doubleValue(), 0.0001d);
- assertEquals(BIGDECIMAL_VALUE.doubleValue() , props.get("bigDecimalProp", Double.class), 0.0001d);
+ assertEquals(
+ new BigDecimal(DOUBLE_VALUE).doubleValue(),
+ props.get("doubleProp", BigDecimal.class).doubleValue(),
+ 0.0001d);
+ assertEquals(BIGDECIMAL_VALUE.doubleValue(), props.get("bigDecimalProp", Double.class), 0.0001d);
}
@Test
@@ -157,8 +164,8 @@
ValueMap props = ResourceUtil.getValueMap(resource1);
assertEquals(STRING_VALUE, props.get("node1/stringProp", String.class));
assertArrayEquals(STRING_ARRAY_VALUE, props.get("node1/stringArrayProp", String[].class));
- assertEquals((Integer)INTEGER_VALUE, props.get("node1/integerProp", Integer.class));
- assertEquals((Long)LONG_VALUE, props.get("node1/longProp", Long.class));
+ assertEquals((Integer) INTEGER_VALUE, props.get("node1/integerProp", Integer.class));
+ assertEquals((Long) LONG_VALUE, props.get("node1/longProp", Long.class));
assertEquals(DOUBLE_VALUE, props.get("node1/doubleProp", Double.class), 0.0001);
assertEquals(BIGDECIMAL_VALUE, props.get("node1/bigDecimalProp", BigDecimal.class));
assertEquals(BOOLEAN_VALUE, props.get("node1/booleanProp", Boolean.class));
@@ -167,14 +174,16 @@
@Test
public void testDateProperty() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
assertEquals(DATE_VALUE, props.get("dateProp", Date.class));
}
@Test
public void testDatePropertyToCalendar() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
Calendar calendarValue = props.get("dateProp", Calendar.class);
assertNotNull(calendarValue);
@@ -183,14 +192,18 @@
@Test
public void testCalendarProperty() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
- assertEquals(CALENDAR_VALUE.getTime(), props.get("calendarProp", Calendar.class).getTime());
+ assertEquals(
+ CALENDAR_VALUE.getTime(),
+ props.get("calendarProp", Calendar.class).getTime());
}
@Test
public void testCalendarPropertyToDate() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
ValueMap props = ResourceUtil.getValueMap(resource1);
Date dateValue = props.get("calendarProp", Date.class);
assertNotNull(dateValue);
@@ -199,7 +212,8 @@
@Test
public void testListChildren() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
List<Resource> children = IteratorUtils.toList(resource1.listChildren());
assertEquals(2, children.size());
@@ -231,7 +245,8 @@
@Test
public void testBinaryData() throws IOException {
- Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource1 =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
Resource binaryPropResource = resource1.getChild("binaryProp");
InputStream is = binaryPropResource.adaptTo(InputStream.class);
@@ -249,13 +264,14 @@
@Test
public void testPrimaryTypeResourceType() throws PersistenceException {
- Resource resource = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
+ Resource resource =
+ context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
assertEquals(JcrConstants.NT_UNSTRUCTURED, resource.getResourceType());
}
@Test
public void testGetRootResourceByNullPath() {
- Resource rootResource = context.resourceResolver().resolve((String)null);
+ Resource rootResource = context.resourceResolver().resolve((String) null);
assertNotNull(rootResource);
assertEquals("/", rootResource.getPath());
}
@@ -280,7 +296,7 @@
public void testPendingChangesCommit() throws PersistenceException {
// skip this test for JCR_MOCK because it does not track pending changes
- if (getResourceResolverType()==ResourceResolverType.JCR_MOCK) {
+ if (getResourceResolverType() == ResourceResolverType.JCR_MOCK) {
return;
}
@@ -293,19 +309,19 @@
@Test
public void testCreateNestedResources() throws IOException {
- Resource nested = context.create().resource(getTestRootResource().getPath() + "/nested",
- new TreeMap<>(Map.<String,Object>of(
- "prop1", "value1",
- "child1", new TreeMap<>(Map.<String,Object>of(
- "prop2","value2",
- "child1a", Map.<String,Object>of(
- "prop3", "value3"),
- "child1b", Map.<String,Object>of(
- "prop4", "value4")
- )),
- "child2", Map.<String,Object>of(
- "prop5","value5"
- ))));
+ Resource nested = context.create()
+ .resource(
+ getTestRootResource().getPath() + "/nested",
+ new TreeMap<>(Map.<String, Object>of(
+ "prop1",
+ "value1",
+ "child1",
+ new TreeMap<>(Map.<String, Object>of(
+ "prop2", "value2",
+ "child1a", Map.<String, Object>of("prop3", "value3"),
+ "child1b", Map.<String, Object>of("prop4", "value4"))),
+ "child2",
+ Map.<String, Object>of("prop5", "value5"))));
assertNotNull(nested);
assertEquals("value1", nested.getValueMap().get("prop1", String.class));
@@ -335,7 +351,8 @@
@Test
public void testResourceWithoutResourceType() throws PersistenceException {
- Resource noResourceType = context.create().resource(getTestRootResource().getPath() + "/noResourceType");
+ Resource noResourceType =
+ context.create().resource(getTestRootResource().getPath() + "/noResourceType");
assertNotNull(noResourceType.getResourceType());
}
@@ -348,5 +365,4 @@
assertNotNull(model);
assertEquals(resource, model.getAdaptable());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java
index 771422d..edcd933 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/resource/AbstractUniqueRootTest.java
@@ -18,14 +18,14 @@
*/
package org.apache.sling.testing.mock.sling.resource;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.junit.SlingContext;
import org.junit.Rule;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
public abstract class AbstractUniqueRootTest {
@Rule
@@ -53,5 +53,4 @@
assertNotNull(context.resourceResolver().getResource(path));
assertTrue(path.matches("^/libs/[^/]+"));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/context/SlingContextImplTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/context/SlingContextImplTest.java
index 8cc858c..1a2e175 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/context/SlingContextImplTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/context/SlingContextImplTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderBinaryTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderBinaryTest.java
index 8ba3996..78e897d 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderBinaryTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderBinaryTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFileVaultXmlTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFileVaultXmlTest.java
index 376b2a7..636db89 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFileVaultXmlTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFileVaultXmlTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFolderFileVaultXmlTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFolderFileVaultXmlTest.java
index 3d48e81..e950b68 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFolderFileVaultXmlTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFolderFileVaultXmlTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFolderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFolderJsonTest.java
index 74666dd..fe2c88c 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFolderJsonTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderFolderJsonTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderJsonDamTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderJsonDamTest.java
index 0af6579..1513ded 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderJsonDamTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderJsonDamTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderJsonTest.java
index c64d6de..fe395f5 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderJsonTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/loader/ContentLoaderJsonTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/MultipleResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/MultipleResourceResolverTest.java
index ea55c37..7c953a3 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/MultipleResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/MultipleResourceResolverTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/SlingCrudResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/SlingCrudResourceResolverTest.java
index e9c629f..16b313e 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/SlingCrudResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/SlingCrudResourceResolverTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.rpmock.resource;
-import static org.junit.Assert.assertNotNull;
-
import java.lang.reflect.Method;
import java.util.List;
@@ -28,6 +26,8 @@
import org.apache.sling.testing.mock.sling.resource.AbstractSlingCrudResourceResolverTest;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+
public class SlingCrudResourceResolverTest extends AbstractSlingCrudResourceResolverTest {
@Override
@@ -36,15 +36,15 @@
}
@Test
- @SuppressWarnings({ "null", "unchecked" })
+ @SuppressWarnings({"null", "unchecked"})
public void testResourceResolverFactory_GetSearchPath() throws Exception {
- // ensure there is a method getSearchPaths in resource resolver factory, although it is not part of the API we are compiling against (keeping backward compatibility)
+ // ensure there is a method getSearchPaths in resource resolver factory, although it is not part of the API we
+ // are compiling against (keeping backward compatibility)
ResourceResolverFactory factory = context.getService(ResourceResolverFactory.class);
Class clazz = factory.getClass();
Method getSearchPathMethod = clazz.getMethod("getSearchPath");
getSearchPathMethod.setAccessible(true);
- List<String> searchPaths = (List)getSearchPathMethod.invoke(factory);
+ List<String> searchPaths = (List) getSearchPathMethod.invoke(factory);
assertNotNull(searchPaths);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/UniqueRootTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/UniqueRootTest.java
index 5a9a935..e1b20e5 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/UniqueRootTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rpmock/resource/UniqueRootTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCEPROVIDER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/context/SlingContextImplTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/context/SlingContextImplTest.java
index d1374e2..6661160 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/context/SlingContextImplTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/context/SlingContextImplTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCERESOLVER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
index fd5beb6..ae8ec8f 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderBinaryTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCERESOLVER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFileVaultXmlTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFileVaultXmlTest.java
index b3a87c7..c909c9a 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFileVaultXmlTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderFileVaultXmlTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCERESOLVER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
index bb84270..3affed5 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonDamTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCERESOLVER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
index 5397cb5..45b9972 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/loader/ContentLoaderJsonTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCERESOLVER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/MultipleResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/MultipleResourceResolverTest.java
index 64aab30..fe18422 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/MultipleResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/MultipleResourceResolverTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCERESOLVER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
index a0d65c6..ba41e0f 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/SlingCrudResourceResolverTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.rrmock.resource;
-import static org.junit.Assert.assertNotNull;
-
import java.lang.reflect.Method;
import java.util.List;
@@ -28,6 +26,8 @@
import org.apache.sling.testing.mock.sling.resource.AbstractSlingCrudResourceResolverTest;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+
public class SlingCrudResourceResolverTest extends AbstractSlingCrudResourceResolverTest {
@Override
@@ -36,15 +36,15 @@
}
@Test
- @SuppressWarnings({ "null", "unchecked" })
+ @SuppressWarnings({"null", "unchecked"})
public void testResourceResolverFactory_GetSearchPath() throws Exception {
- // ensure there is a method getSearchPaths in resource resolver factory, although it is not part of the API we are compiling against (keeping backward compatibility)
+ // ensure there is a method getSearchPaths in resource resolver factory, although it is not part of the API we
+ // are compiling against (keeping backward compatibility)
ResourceResolverFactory factory = context.getService(ResourceResolverFactory.class);
Class clazz = factory.getClass();
Method getSearchPathMethod = clazz.getMethod("getSearchPath");
getSearchPathMethod.setAccessible(true);
- List<String> searchPaths = (List)getSearchPathMethod.invoke(factory);
+ List<String> searchPaths = (List) getSearchPathMethod.invoke(factory);
assertNotNull(searchPaths);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java
index 879459d..a86f36a 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/rrmock/resource/UniqueRootTest.java
@@ -27,5 +27,4 @@
protected ResourceResolverType getResourceResolverType() {
return ResourceResolverType.RESOURCERESOLVER_MOCK;
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
index edd5b14..f244aca 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/services/MockMimeTypeServiceTest.java
@@ -18,12 +18,12 @@
*/
package org.apache.sling.testing.mock.sling.services;
-import static org.junit.Assert.assertEquals;
-
import org.apache.sling.commons.mime.MimeTypeService;
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
public class MockMimeTypeServiceTest {
private MimeTypeService mimeTypeService;
@@ -47,5 +47,4 @@
assertEquals("json", this.mimeTypeService.getExtension("application/json"));
assertEquals("jpeg", this.mimeTypeService.getExtension("image/jpeg"));
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
index 0e1bef9..1ad86b0 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/services/MockSlingSettingServiceTest.java
@@ -18,15 +18,15 @@
*/
package org.apache.sling.testing.mock.sling.services;
+import java.util.Set;
+
+import org.junit.Test;
+
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.util.Set;
-
-import org.junit.Test;
-
public class MockSlingSettingServiceTest {
@Test
@@ -54,5 +54,4 @@
public void slingId() {
assertThat(new MockSlingSettingService().getSlingId(), notNullValue());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockHttpSessionTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockHttpSessionTest.java
index 6a1eae5..ba5da9f 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockHttpSessionTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockHttpSessionTest.java
@@ -18,12 +18,12 @@
*/
package org.apache.sling.testing.mock.sling.servlet;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
public class MockHttpSessionTest {
private MockHttpSession httpSession;
@@ -38,5 +38,4 @@
assertNotNull(httpSession.getServletContext());
assertTrue(httpSession.getServletContext() instanceof MockServletContext);
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequestTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequestTest.java
index a9bdc38..01f4518 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequestTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletRequestTest.java
@@ -18,21 +18,12 @@
*/
package org.apache.sling.testing.mock.sling.servlet;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import javax.servlet.http.HttpSession;
import java.util.ListResourceBundle;
import java.util.Locale;
import java.util.ResourceBundle;
-import javax.servlet.http.HttpSession;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.i18n.ResourceBundleProvider;
@@ -47,14 +38,25 @@
import org.mockito.junit.MockitoJUnitRunner;
import org.osgi.framework.BundleContext;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
@RunWith(MockitoJUnitRunner.class)
@SuppressWarnings("null")
public class MockSlingHttpServletRequestTest {
@Mock
private ResourceResolver resourceResolver;
+
@Mock
private Resource resource;
+
private BundleContext bundleContext = MockOsgi.newBundleContext();
private MockSlingHttpServletRequest request;
@@ -106,9 +108,7 @@
when(provider.getResourceBundle("base1", Locale.US)).thenReturn(new ListResourceBundle() {
@Override
protected Object[][] getContents() {
- return new Object[][] {
- { "key1", "value1" }
- };
+ return new Object[][] {{"key1", "value1"}};
}
});
@@ -125,11 +125,10 @@
public void testGetSuffixResource() {
assertNull(request.getRequestPathInfo().getSuffixResource());
- ((MockRequestPathInfo)request.getRequestPathInfo()).setSuffix("/suffix");
+ ((MockRequestPathInfo) request.getRequestPathInfo()).setSuffix("/suffix");
Resource resource = mock(Resource.class);
when(resourceResolver.getResource("/suffix")).thenReturn(resource);
assertSame(resource, request.getRequestPathInfo().getSuffixResource());
}
-
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletResponseTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletResponseTest.java
index 2a32976..bfe59d9 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletResponseTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/sling/servlet/MockSlingHttpServletResponseTest.java
@@ -18,11 +18,11 @@
*/
package org.apache.sling.testing.mock.sling.servlet;
-import static org.junit.Assert.assertNull;
-
import org.junit.Before;
import org.junit.Test;
+import static org.junit.Assert.assertNull;
+
public class MockSlingHttpServletResponseTest {
private MockSlingHttpServletResponse response;
@@ -37,5 +37,4 @@
assertNull(response.getContentType());
assertNull(response.getCharacterEncoding());
}
-
}
diff --git a/junit4/pom.xml b/junit4/pom.xml
index 199180d..b06f27b 100644
--- a/junit4/pom.xml
+++ b/junit4/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
diff --git a/junit4/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java b/junit4/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
index 1dd3a3a..ad43b10 100644
--- a/junit4/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
+++ b/junit4/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContext.java
@@ -76,7 +76,9 @@
* @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
* @param resourceResolverType Resource resolver type.
*/
- public <T extends OsgiContextImpl> SlingContext(@NotNull final ContextCallback<T> afterSetUpCallback, @NotNull final ResourceResolverType resourceResolverType) {
+ public <T extends OsgiContextImpl> SlingContext(
+ @NotNull final ContextCallback<T> afterSetUpCallback,
+ @NotNull final ResourceResolverType resourceResolverType) {
this(new ContextPlugins(afterSetUpCallback), null, resourceResolverType);
}
@@ -88,7 +90,8 @@
* @param afterSetUpCallback Allows the application to register an own callback function that is called after the built-in setup rules are executed.
* @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
*/
- public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(@NotNull final ContextCallback<U> afterSetUpCallback,
+ public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(
+ @NotNull final ContextCallback<U> afterSetUpCallback,
@NotNull final ContextCallback<V> beforeTearDownCallback) {
this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, null);
}
@@ -101,7 +104,8 @@
* @param beforeTearDownCallback Allows the application to register an own callback function that is called before the built-in teardown rules are executed.
* @param resourceResolverType Resource resolver type.
*/
- public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(@NotNull final ContextCallback<U> afterSetUpCallback,
+ public <U extends OsgiContextImpl, V extends OsgiContextImpl> SlingContext(
+ @NotNull final ContextCallback<U> afterSetUpCallback,
@NotNull final ContextCallback<V> beforeTearDownCallback,
@NotNull final ResourceResolverType resourceResolverType) {
this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, resourceResolverType);
@@ -113,7 +117,8 @@
* @param resourceResolverFactoryActivatorProps Allows to override OSGi configuration parameters for the Resource Resolver Factory Activator service.
* @param resourceResolverType Resource resolver type.
*/
- SlingContext(@NotNull final ContextPlugins contextPlugins,
+ SlingContext(
+ @NotNull final ContextPlugins contextPlugins,
@Nullable final Map<String, Object> resourceResolverFactoryActivatorProps,
@Nullable final ResourceResolverType resourceResolverType) {
this(contextPlugins, resourceResolverFactoryActivatorProps, resourceResolverType, true);
@@ -126,7 +131,8 @@
* @param resourceResolverType Resource resolver type.
* @param registerSlingModelsFromClassPath Automatic registering of all Sling Models found in the classpath on startup.
*/
- SlingContext(@NotNull final ContextPlugins contextPlugins,
+ SlingContext(
+ @NotNull final ContextPlugins contextPlugins,
@Nullable final Map<String, Object> resourceResolverFactoryActivatorProps,
@Nullable final ResourceResolverType resourceResolverType,
final boolean registerSlingModelsFromClassPath) {
@@ -160,5 +166,4 @@
public Statement apply(final Statement base, final Description description) {
return this.delegate.apply(base, description);
}
-
}
diff --git a/junit4/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java b/junit4/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
index 289714b..987b480 100644
--- a/junit4/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
+++ b/junit4/src/main/java/org/apache/sling/testing/mock/sling/junit/SlingContextBuilder.java
@@ -66,7 +66,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder plugin(@NotNull ContextPlugin<? extends OsgiContextImpl> @NotNull ... plugin) {
+ public final @NotNull SlingContextBuilder plugin(
+ @NotNull ContextPlugin<? extends OsgiContextImpl> @NotNull ... plugin) {
plugins.addPlugin(plugin);
return this;
}
@@ -76,7 +77,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder beforeSetUp(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeSetUpCallback) {
+ public final @NotNull SlingContextBuilder beforeSetUp(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeSetUpCallback) {
plugins.addBeforeSetUpCallback(beforeSetUpCallback);
return this;
}
@@ -86,7 +88,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder afterSetUp(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterSetUpCallback) {
+ public final @NotNull SlingContextBuilder afterSetUp(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterSetUpCallback) {
plugins.addAfterSetUpCallback(afterSetUpCallback);
return this;
}
@@ -96,7 +99,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder beforeTearDown(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeTearDownCallback) {
+ public final @NotNull SlingContextBuilder beforeTearDown(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeTearDownCallback) {
plugins.addBeforeTearDownCallback(beforeTearDownCallback);
return this;
}
@@ -106,7 +110,8 @@
* @return this
*/
@SafeVarargs
- public final @NotNull SlingContextBuilder afterTearDown(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterTearDownCallback) {
+ public final @NotNull SlingContextBuilder afterTearDown(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterTearDownCallback) {
plugins.addAfterTearDownCallback(afterTearDownCallback);
return this;
}
@@ -117,8 +122,8 @@
* @return this
*/
public @NotNull SlingContextBuilder resourceResolverFactoryActivatorProps(@NotNull Map<String, Object> props) {
- this.resourceResolverFactoryActivatorProps = props;
- return this;
+ this.resourceResolverFactoryActivatorProps = props;
+ return this;
}
/**
@@ -127,18 +132,18 @@
* @return this
*/
public @NotNull SlingContextBuilder registerSlingModelsFromClassPath(boolean registerSlingModelsFromClassPath) {
- this.registerSlingModelsFromClassPath = registerSlingModelsFromClassPath;
- return this;
+ this.registerSlingModelsFromClassPath = registerSlingModelsFromClassPath;
+ return this;
}
/**
* @return Build {@link SlingContext} instance.
*/
public @NotNull SlingContext build() {
- return new SlingContext(this.plugins,
+ return new SlingContext(
+ this.plugins,
this.resourceResolverFactoryActivatorProps,
this.resourceResolverType,
this.registerSlingModelsFromClassPath);
}
-
}
diff --git a/junit4/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java b/junit4/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
index da3e281..a1c37e7 100644
--- a/junit4/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
+++ b/junit4/src/test/java/org/apache/sling/testing/mock/sling/junit/SlingContextTest.java
@@ -18,12 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.junit;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
import java.util.function.Function;
import org.apache.sling.api.adapter.AdapterFactory;
@@ -39,6 +33,12 @@
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
@RunWith(MockitoJUnitRunner.class)
@SuppressWarnings("null")
public class SlingContextTest {
@@ -51,15 +51,14 @@
// Run all unit tests for each resource resolver types listed here
@Rule
public SlingContext context = new SlingContextBuilder(ResourceResolverType.JCR_MOCK)
- .beforeSetUp(contextBeforeSetup)
- .afterSetUp(contextAfterSetup)
- .beforeTearDown(contextBeforeTeardown)
- .afterTearDown(contextAfterTeardown)
- .resourceResolverFactoryActivatorProps(ImmutableValueMap.of(
- "resource.resolver.searchpath", new String[] {"/apps","/libs","/testpath"},
- "resource.resolver.mapping", new String[] {"/:/", "/content/test/</"}
- ))
- .build();
+ .beforeSetUp(contextBeforeSetup)
+ .afterSetUp(contextAfterSetup)
+ .beforeTearDown(contextBeforeTeardown)
+ .afterTearDown(contextAfterTeardown)
+ .resourceResolverFactoryActivatorProps(ImmutableValueMap.of(
+ "resource.resolver.searchpath", new String[] {"/apps", "/libs", "/testpath"},
+ "resource.resolver.mapping", new String[] {"/:/", "/content/test/</"}))
+ .build();
@Before
public void setUp() throws Exception {
@@ -77,19 +76,23 @@
*/
@Test
public void testResourceResolverFactoryActivatorProps() {
- context.create().resource("/apps/node1");
+ context.create().resource("/apps/node1");
- context.create().resource("/libs/node1");
- context.create().resource("/libs/node2");
+ context.create().resource("/libs/node1");
+ context.create().resource("/libs/node2");
- context.create().resource("/testpath/node1");
- context.create().resource("/testpath/node2");
- context.create().resource("/testpath/node3");
+ context.create().resource("/testpath/node1");
+ context.create().resource("/testpath/node2");
+ context.create().resource("/testpath/node3");
- assertEquals("/apps/node1", context.resourceResolver().getResource("node1").getPath());
- assertEquals("/libs/node2", context.resourceResolver().getResource("node2").getPath());
- assertEquals("/testpath/node3", context.resourceResolver().getResource("node3").getPath());
- assertNull(context.resourceResolver().getResource("node4"));
+ assertEquals(
+ "/apps/node1", context.resourceResolver().getResource("node1").getPath());
+ assertEquals(
+ "/libs/node2", context.resourceResolver().getResource("node2").getPath());
+ assertEquals(
+ "/testpath/node3",
+ context.resourceResolver().getResource("node3").getPath());
+ assertNull(context.resourceResolver().getResource("node4"));
}
@Test
@@ -97,7 +100,7 @@
// prepare some adapter factories
context.registerAdapter(ResourceResolver.class, Integer.class, 5);
- context.registerAdapter(ResourceResolver.class, String.class, new Function<ResourceResolver,String>() {
+ context.registerAdapter(ResourceResolver.class, String.class, new Function<ResourceResolver, String>() {
@Override
public String apply(ResourceResolver input) {
return ">" + input.toString();
@@ -106,7 +109,9 @@
// test adaption
assertEquals(Integer.valueOf(5), context.resourceResolver().adaptTo(Integer.class));
- assertEquals(">" + context.resourceResolver().toString(), context.resourceResolver().adaptTo(String.class));
+ assertEquals(
+ ">" + context.resourceResolver().toString(),
+ context.resourceResolver().adaptTo(String.class));
assertNull(context.resourceResolver().adaptTo(Double.class));
}
@@ -140,10 +145,11 @@
@Test
public void testResourceBuilder() {
- context.build().resource("/test1", "prop1", "value1")
- .siblingsMode()
- .resource("a")
- .resource("b");
+ context.build()
+ .resource("/test1", "prop1", "value1")
+ .siblingsMode()
+ .resource("a")
+ .resource("b");
Resource test1 = context.resourceResolver().getResource("/test1");
assertNotNull(test1);
@@ -163,19 +169,21 @@
@SuppressWarnings("unchecked")
@Override
public <AdapterType> AdapterType getAdapter(@NotNull Object adaptable, @NotNull Class<AdapterType> type) {
- return (AdapterType)(((TestAdaptable)adaptable).getMessage() + "-initial");
+ return (AdapterType) (((TestAdaptable) adaptable).getMessage() + "-initial");
}
};
- context.registerService(AdapterFactory.class, adapterFactory, ImmutableValueMap.builder()
- .put(AdapterFactory.ADAPTABLE_CLASSES, new String[] { TestAdaptable.class.getName() })
- .put(AdapterFactory.ADAPTER_CLASSES, new String[] { String.class.getName() })
- .build());
+ context.registerService(
+ AdapterFactory.class,
+ adapterFactory,
+ ImmutableValueMap.builder()
+ .put(AdapterFactory.ADAPTABLE_CLASSES, new String[] {TestAdaptable.class.getName()})
+ .put(AdapterFactory.ADAPTER_CLASSES, new String[] {String.class.getName()})
+ .build());
// test initial adapter factory
assertEquals("testMessage1-initial", new TestAdaptable("testMessage1").adaptTo(String.class));
}
-
private static class TestAdaptable extends SlingAdaptable {
private final String message;
@@ -187,7 +195,5 @@
public String getMessage() {
return message;
}
-
}
-
}
diff --git a/junit5/pom.xml b/junit5/pom.xml
index a0fe4cc..b74240c 100644
--- a/junit5/pom.xml
+++ b/junit5/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -32,6 +32,20 @@
<name>Apache Sling Testing Sling Mock JUnit 5</name>
+ <dependencyManagement>
+ <dependencies>
+
+ <dependency>
+ <groupId>org.junit</groupId>
+ <artifactId>junit-bom</artifactId>
+ <version>5.10.1</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+
+ </dependencies>
+ </dependencyManagement>
+
<dependencies>
<dependency>
@@ -83,20 +97,6 @@
</dependencies>
- <dependencyManagement>
- <dependencies>
-
- <dependency>
- <groupId>org.junit</groupId>
- <artifactId>junit-bom</artifactId>
- <version>5.10.1</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
-
- </dependencies>
- </dependencyManagement>
-
<build>
<plugins>
@@ -117,7 +117,7 @@
<exclude>src/test/resources/**</exclude>
</excludes>
</configuration>
- </plugin>
+ </plugin>
</plugins>
</build>
diff --git a/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContext.java b/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContext.java
index b8bbed4..822aeef 100644
--- a/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContext.java
+++ b/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContext.java
@@ -46,7 +46,7 @@
* Initialize Sling context.
*/
public SlingContext() {
- this(new ContextPlugins(), null, MockSling.DEFAULT_RESOURCERESOLVER_TYPE, true);
+ this(new ContextPlugins(), null, MockSling.DEFAULT_RESOURCERESOLVER_TYPE, true);
}
/**
@@ -66,7 +66,8 @@
* Sling Models found in the classpath on startup.
* @param resourceResolverType Resource resolver type.
*/
- SlingContext(@NotNull final ContextPlugins contextPlugins,
+ SlingContext(
+ @NotNull final ContextPlugins contextPlugins,
@Nullable final Map<String, Object> resourceResolverFactoryActivatorProps,
@Nullable final ResourceResolverType resourceResolverType,
final boolean registerSlingModelsFromClassPath) {
@@ -100,5 +101,4 @@
boolean isSetUp() {
return this.isSetUp;
}
-
}
diff --git a/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextBuilder.java b/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextBuilder.java
index 81e53cd..5d23d14 100644
--- a/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextBuilder.java
+++ b/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextBuilder.java
@@ -81,7 +81,8 @@
* @return this
*/
@SafeVarargs
- public final SlingContextBuilder beforeSetUp(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeSetUpCallback) {
+ public final SlingContextBuilder beforeSetUp(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeSetUpCallback) {
plugins.addBeforeSetUpCallback(beforeSetUpCallback);
return this;
}
@@ -93,7 +94,8 @@
* @return this
*/
@SafeVarargs
- public final SlingContextBuilder afterSetUp(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterSetUpCallback) {
+ public final SlingContextBuilder afterSetUp(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterSetUpCallback) {
plugins.addAfterSetUpCallback(afterSetUpCallback);
return this;
}
@@ -105,7 +107,8 @@
* @return this
*/
@SafeVarargs
- public final SlingContextBuilder beforeTearDown(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeTearDownCallback) {
+ public final SlingContextBuilder beforeTearDown(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... beforeTearDownCallback) {
plugins.addBeforeTearDownCallback(beforeTearDownCallback);
return this;
}
@@ -117,7 +120,8 @@
* @return this
*/
@SafeVarargs
- public final SlingContextBuilder afterTearDown(@NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterTearDownCallback) {
+ public final SlingContextBuilder afterTearDown(
+ @NotNull ContextCallback<? extends OsgiContextImpl> @NotNull ... afterTearDownCallback) {
plugins.addAfterTearDownCallback(afterTearDownCallback);
return this;
}
@@ -149,8 +153,10 @@
* @return Build {@link SlingContext} instance.
*/
public @NotNull SlingContext build() {
- return new SlingContext(this.plugins, this.resourceResolverFactoryActivatorProps,
- this.resourceResolverType, this.registerSlingModelsFromClassPath);
+ return new SlingContext(
+ this.plugins,
+ this.resourceResolverFactoryActivatorProps,
+ this.resourceResolverType,
+ this.registerSlingModelsFromClassPath);
}
-
}
diff --git a/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextExtension.java b/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextExtension.java
index 2720eb3..0668851 100644
--- a/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextExtension.java
+++ b/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextExtension.java
@@ -35,8 +35,12 @@
* it) parameters in test methods, and ensures that the context is set up and
* teared down properly for each test method.
*/
-public final class SlingContextExtension implements ParameterResolver, TestInstancePostProcessor, BeforeEachCallback,
- AfterEachCallback, AfterTestExecutionCallback {
+public final class SlingContextExtension
+ implements ParameterResolver,
+ TestInstancePostProcessor,
+ BeforeEachCallback,
+ AfterEachCallback,
+ AfterTestExecutionCallback {
/**
* Checks if test class has a {@link SlingContext} or derived field. If it has
@@ -67,7 +71,8 @@
*/
@Override
public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) {
- return SlingContext.class.isAssignableFrom(parameterContext.getParameter().getType());
+ return SlingContext.class.isAssignableFrom(
+ parameterContext.getParameter().getType());
}
/**
@@ -110,8 +115,8 @@
}
private void applySlingContext(ExtensionContext extensionContext, Consumer<SlingContext> consumer) {
- SlingContext slingContext = SlingContextStore.getSlingContext(extensionContext,
- extensionContext.getRequiredTestInstance());
+ SlingContext slingContext =
+ SlingContextStore.getSlingContext(extensionContext, extensionContext.getRequiredTestInstance());
if (slingContext != null) {
consumer.accept(slingContext);
}
@@ -126,7 +131,9 @@
return null;
}
Field contextField = Arrays.stream(instanceClass.getDeclaredFields())
- .filter(field -> type.isAssignableFrom(field.getType())).findFirst().orElse(null);
+ .filter(field -> type.isAssignableFrom(field.getType()))
+ .findFirst()
+ .orElse(null);
if (contextField != null) {
contextField.setAccessible(true);
} else {
@@ -134,5 +141,4 @@
}
return contextField;
}
-
}
diff --git a/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextStore.java b/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextStore.java
index 74ba0d8..d78140f 100644
--- a/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextStore.java
+++ b/junit5/src/main/java/org/apache/sling/testing/mock/sling/junit5/SlingContextStore.java
@@ -75,7 +75,8 @@
* @param testInstance Test instance
* @param slingContext Sling context
*/
- public static void storeSlingContext(ExtensionContext extensionContext, Object testInstance, SlingContext slingContext) {
+ public static void storeSlingContext(
+ ExtensionContext extensionContext, Object testInstance, SlingContext slingContext) {
getStore(extensionContext).put(testInstance, slingContext);
}
@@ -88,5 +89,4 @@
slingContext.setUpContext();
return slingContext;
}
-
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/NoSlingModelsRegistrationTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/NoSlingModelsRegistrationTest.java
index 4123cf2..a15c79e 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/NoSlingModelsRegistrationTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/NoSlingModelsRegistrationTest.java
@@ -18,12 +18,12 @@
*/
package org.apache.sling.testing.mock.sling.junit5;
-import static org.junit.jupiter.api.Assertions.assertNull;
-
import org.apache.sling.testing.mock.sling.context.modelsautoreg.ClasspathRegisteredModel;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
/**
* Test with {@link SlingContext} which uses by default
* {@link ResourceResolverMockSlingContext}.
@@ -31,9 +31,8 @@
@ExtendWith(SlingContextExtension.class)
class NoSlingModelsRegistrationTest {
- private final SlingContext context = new SlingContextBuilder()
- .registerSlingModelsFromClassPath(false)
- .build();
+ private final SlingContext context =
+ new SlingContextBuilder().registerSlingModelsFromClassPath(false).build();
@Test
@SuppressWarnings("null")
@@ -44,5 +43,4 @@
// automatically from classpath
assertNull(model);
}
-
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberInstantiatedTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberInstantiatedTest.java
index d4a5dcc..d1ab0cf 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberInstantiatedTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberInstantiatedTest.java
@@ -18,9 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.junit5;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.resourceresolver.impl.ResourceResolverImpl;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -28,6 +25,9 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
/**
* Test with {@link SlingContext} as class member variable already instantiated.
*/
@@ -49,5 +49,4 @@
Resource resource = context.resourceResolver().getResource("/content/test");
assertEquals("value1", resource.getValueMap().get("prop1"));
}
-
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberSuperClassTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberSuperClassTest.java
index c3e412f..6983ca5 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberSuperClassTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberSuperClassTest.java
@@ -18,12 +18,12 @@
*/
package org.apache.sling.testing.mock.sling.junit5;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
import org.apache.sling.api.resource.Resource;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test with SlingContext member field in super class.
*/
@@ -36,5 +36,4 @@
Resource resource = context.resourceResolver().getResource("/content/test");
assertEquals("value1", resource.getValueMap().get("prop1"));
}
-
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberTest.java
index ff8d07c..784ed75 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextMemberTest.java
@@ -18,14 +18,14 @@
*/
package org.apache.sling.testing.mock.sling.junit5;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test with {@link SlingContext} as class member variable.
*/
@@ -47,5 +47,4 @@
Resource resource = context.resourceResolver().getResource("/content/test");
assertEquals("value1", resource.getValueMap().get("prop1"));
}
-
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextPluginTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextPluginTest.java
index 26ddded..a92f8ec 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextPluginTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextPluginTest.java
@@ -18,12 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.junit5;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
import java.util.Map;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
@@ -33,6 +27,12 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
/**
* Test with {@link SlingContext} with context plugins.
*/
@@ -50,8 +50,9 @@
.afterSetUp(contextAfterSetup)
.beforeTearDown(contextBeforeTeardown)
.afterTearDown(contextAfterTeardown)
- .resourceResolverFactoryActivatorProps(
- Map.<String, Object> of("resource.resolver.searchpath", new String[] { "/apps", "/libs", "/testpath", }))
+ .resourceResolverFactoryActivatorProps(Map.<String, Object>of("resource.resolver.searchpath", new String[] {
+ "/apps", "/libs", "/testpath",
+ }))
.build();
@BeforeEach
@@ -84,9 +85,13 @@
context.create().resource("/testpath/node2");
context.create().resource("/testpath/node3");
- assertEquals("/apps/node1", context.resourceResolver().getResource("node1").getPath());
- assertEquals("/libs/node2", context.resourceResolver().getResource("node2").getPath());
- assertEquals("/testpath/node3", context.resourceResolver().getResource("node3").getPath());
+ assertEquals(
+ "/apps/node1", context.resourceResolver().getResource("node1").getPath());
+ assertEquals(
+ "/libs/node2", context.resourceResolver().getResource("node2").getPath());
+ assertEquals(
+ "/testpath/node3",
+ context.resourceResolver().getResource("node3").getPath());
assertNull(context.resourceResolver().getResource("node4"));
}
@@ -101,5 +106,4 @@
public void tearDown() throws Exception {
verify(contextBeforeTeardown).execute(context);
}
-
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextTest.java
index 866cd0a..a63184a 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/sling/junit5/SlingContextTest.java
@@ -18,8 +18,6 @@
*/
package org.apache.sling.testing.mock.sling.junit5;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
import org.apache.sling.api.resource.Resource;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.context.modelsautoreg.ClasspathRegisteredModel;
@@ -28,6 +26,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
/**
* Test with {@link SlingContext} as test method parameter.
*/
@@ -62,5 +62,4 @@
context.resourceResolver().delete(resource);
}
-
}
diff --git a/parent/pom.xml b/parent/pom.xml
index cef6e4c..8b81261 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -34,269 +34,276 @@
<name>Apache Sling Testing Sling Mock Parent</name>
<description>Mock implementation of selected Sling APIs.</description>
+ <scm>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git</developerConnection>
+ <tag>org.apache.sling.testing.sling-mock.reactor-3.3.2</tag>
+ <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-testing-sling-mock.git</url>
+ </scm>
+
<properties>
<project.build.outputTimestamp>2024-04-09T15:46:12Z</project.build.outputTimestamp>
</properties>
<dependencyManagement>
- <dependencies>
+ <dependencies>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.osgi-mock.core</artifactId>
- <version>3.4.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.osgi-mock.junit4</artifactId>
- <version>3.4.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
- <version>1.6.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
- <version>1.4.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.testing.logging-mock</artifactId>
- <version>2.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.servlet-helpers</artifactId>
- <version>1.4.6</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.resourcebuilder</artifactId>
- <version>1.0.4</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.osgi-mock.core</artifactId>
+ <version>3.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.osgi-mock.junit4</artifactId>
+ <version>3.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.jcr-mock</artifactId>
+ <version>1.6.14</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.resourceresolver-mock</artifactId>
+ <version>1.4.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.testing.logging-mock</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.servlet-helpers</artifactId>
+ <version>1.4.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.resourcebuilder</artifactId>
+ <version>1.0.4</version>
+ </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.resource</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.util.converter</artifactId>
- <version>1.0.8</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.util.function</artifactId>
- <version>1.1.0</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.util.tracker</artifactId>
- <version>1.5.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.models.api</artifactId>
- <version>1.3.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.models.impl</artifactId>
- <version>1.4.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.api</artifactId>
- <version>2.22.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.resourceresolver</artifactId>
- <version>1.7.10</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.serviceusermapper</artifactId>
- <version>1.5.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.jcr.api</artifactId>
- <version>2.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.jcr.resource</artifactId>
- <version>3.0.18</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.scripting.api</artifactId>
- <version>2.2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.scripting.core</artifactId>
- <version>2.3.2</version>
- <exclusions>
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.compendium</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.mime</artifactId>
- <version>2.2.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <version>1.2.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.commons.classloader</artifactId>
- <version>1.4.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.settings</artifactId>
- <version>1.3.10</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.i18n</artifactId>
- <version>2.5.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.adapter</artifactId>
- <version>2.1.10</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.xss</artifactId>
- <version>2.2.16</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.featureflags</artifactId>
- <version>1.2.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-jackrabbit-api</artifactId>
- <version>1.22.15</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>oak-jcr</artifactId>
- <version>1.22.15</version>
- <exclusions>
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.service.metatype.annotations</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.annotation</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.resource</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.converter</artifactId>
+ <version>1.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.function</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.tracker</artifactId>
+ <version>1.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.models.api</artifactId>
+ <version>1.3.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.models.impl</artifactId>
+ <version>1.4.14</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.api</artifactId>
+ <version>2.22.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.resourceresolver</artifactId>
+ <version>1.7.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.serviceusermapper</artifactId>
+ <version>1.5.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.api</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.resource</artifactId>
+ <version>3.0.18</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.scripting.api</artifactId>
+ <version>2.2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.scripting.core</artifactId>
+ <version>2.3.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.mime</artifactId>
+ <version>2.2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <version>1.2.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.commons.classloader</artifactId>
+ <version>1.4.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.settings</artifactId>
+ <version>1.3.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.i18n</artifactId>
+ <version>2.5.14</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.adapter</artifactId>
+ <version>2.1.10</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.xss</artifactId>
+ <version>2.2.16</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.featureflags</artifactId>
+ <version>1.2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>oak-jackrabbit-api</artifactId>
+ <version>1.22.15</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>oak-jcr</artifactId>
+ <version>1.22.15</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-collections4</artifactId>
- <version>4.4</version>
- </dependency>
- <dependency>
- <groupId>commons-collections</groupId>
- <artifactId>commons-collections</artifactId>
- <version>3.2.2</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.11.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-lang3</artifactId>
- <version>3.13.0</version>
- </dependency>
- <dependency>
- <groupId>commons-fileupload</groupId>
- <artifactId>commons-fileupload</artifactId>
- <version>1.5</version>
- </dependency>
- <dependency>
- <groupId>jakarta.json</groupId>
- <artifactId>jakarta.json-api</artifactId>
- <version>2.0.2</version>
- </dependency>
- <dependency>
- <groupId>org.glassfish</groupId>
- <artifactId>jakarta.json</artifactId>
- <version>2.0.1</version>
- </dependency>
- <dependency>
- <groupId>org.owasp.encoder</groupId>
- <artifactId>encoder</artifactId>
- <version>1.2.3</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-collections4</artifactId>
+ <version>4.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ <version>3.2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.11.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.13.0</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <version>1.5</version>
+ </dependency>
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <version>2.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish</groupId>
+ <artifactId>jakarta.json</artifactId>
+ <version>2.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.owasp.encoder</groupId>
+ <artifactId>encoder</artifactId>
+ <version>1.2.3</version>
+ </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.contentparser.api</artifactId>
- <version>2.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.contentparser.json</artifactId>
- <version>2.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.contentparser.xml-jcr</artifactId>
- <version>2.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit.vault</groupId>
- <artifactId>org.apache.jackrabbit.vault</artifactId>
- <version>3.2.8</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.fsresource</artifactId>
- <version>2.2.0</version>
- </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.contentparser.api</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.contentparser.json</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.contentparser.xml-jcr</artifactId>
+ <version>2.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit.vault</groupId>
+ <artifactId>org.apache.jackrabbit.vault</artifactId>
+ <version>3.2.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.fsresource</artifactId>
+ <version>2.2.0</version>
+ </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
- <version>5.8.0</version>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-junit-jupiter</artifactId>
- <version>5.8.0</version>
- </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
+ <version>5.8.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-junit-jupiter</artifactId>
+ <version>5.8.0</version>
+ </dependency>
- </dependencies>
+ </dependencies>
</dependencyManagement>
<dependencies>
@@ -337,7 +344,7 @@
</pluginManagement>
</build>
- <profiles>
+ <profiles>
<profile>
<id>latest-dependency-versions</id>
<activation>
@@ -460,11 +467,4 @@
</profile>
</profiles>
- <scm>
- <tag>org.apache.sling.testing.sling-mock.reactor-3.3.2</tag>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git</developerConnection>
- <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-testing-sling-mock.git</url>
- </scm>
-
</project>
diff --git a/pom.xml b/pom.xml
index 3256848..09e42c4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -32,13 +32,6 @@
<name>Apache Sling Testing Sling Mock</name>
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git</developerConnection>
- <url>https://github.com/apache/sling-org-apache-sling-testing-sling-mock.git</url>
- <tag>org.apache.sling.testing.sling-mock.reactor-3.3.2</tag>
- </scm>
-
<modules>
<module>parent</module>
<module>core</module>
@@ -47,6 +40,13 @@
<module>relocate</module>
</modules>
+ <scm>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-sling-mock.git</developerConnection>
+ <tag>org.apache.sling.testing.sling-mock.reactor-3.3.2</tag>
+ <url>https://github.com/apache/sling-org-apache-sling-testing-sling-mock.git</url>
+ </scm>
+
<build>
<plugins>
diff --git a/relocate/pom.xml b/relocate/pom.xml
index 935ced9..5fe702a 100644
--- a/relocate/pom.xml
+++ b/relocate/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file