cosmetic: remove training whitespaces
diff --git a/core/pom.xml b/core/pom.xml
index 9a6be20..edb5ff4 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -210,13 +210,13 @@
<version>1.8.3</version>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-atinject_1.0_spec</artifactId>
@@ -230,13 +230,13 @@
<version>1.0</version>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
<scope>compile</scope>
</dependency>
-
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
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 e8d4a83..5a51d6c 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
@@ -316,7 +316,7 @@
props));
}
}
-
+
static String getPackageName(String clazz) {
final int lastDot = clazz.lastIndexOf('.');
return lastDot <= 0 ? "" : clazz.substring(0, lastDot);
@@ -325,7 +325,7 @@
/**
* Check that the package containing the class is exported or is a java.*
* class.
- *
+ *
* @param packageAdmin the PackageAdmin service
* @param clazz the class name
* @return true if the package is exported
@@ -333,7 +333,7 @@
// DISABLED IN THIS COPY OF CLASS
/*
static boolean checkPackage(PackageAdmin packageAdmin, String clazz) {
- final String packageName = getPackageName(clazz);
+ final String packageName = getPackageName(clazz);
if (packageName.startsWith("java.")) {
return true;
}
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 e3073cd..21f6b54 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
@@ -39,7 +39,7 @@
public final class MockJcrSlingRepository implements SlingRepository {
private Repository repository;
-
+
@Activate
protected void activate(ComponentContext componentContext) {
repository = MockJcr.newRepository();
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 8d01887..0a0b1c4 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
@@ -73,7 +73,7 @@
*/
public String getBaseName() {
return baseName;
- }
+ }
/**
* Add translation.
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 dec6bf4..a57885c 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
@@ -95,11 +95,11 @@
public @NotNull SlingScript getScript() {
return this.script;
}
-
+
public void setScript(@NotNull SlingScript script) {
this.script = script;
}
-
+
// --- unsupported operations ---
@Override
public void dispose() {
diff --git a/core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSAPIImpl.java b/core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSAPIImpl.java
index dcf9fce..db3cf16 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSAPIImpl.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/sling/MockXSSAPIImpl.java
@@ -34,7 +34,7 @@
public final class MockXSSAPIImpl implements XSSAPI {
private static final Pattern PATTERN_AUTO_DIMENSION = Pattern.compile("['\"]?auto['\"]?");
-
+
@Override
public @Nullable Integer getValidInteger(@Nullable String integer, int defaultValue) {
if (StringUtils.isNotBlank(integer)) {
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 63ed2ed..db3f39c 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
@@ -53,22 +53,22 @@
/**
* Singleton class that fetches all node type definitions from OSGi bundle MANIFEST.MF files
* with "Sling-Nodetypes" definitions in the classpath.
- * Additionally it support registering them to a JCR repository.
+ * Additionally it support registering them to a JCR repository.
*/
public final class NodeTypeDefinitionScanner {
-
+
private static final NodeTypeDefinitionScanner SINGLETON = new NodeTypeDefinitionScanner();
-
+
private static final int MAX_ITERATIONS = 5;
private static final Logger log = LoggerFactory.getLogger(NodeTypeDefinitionScanner.class);
-
+
private final List<String> nodeTypeDefinitions;
-
+
private NodeTypeDefinitionScanner() {
nodeTypeDefinitions = findeNodeTypeDefinitions();
}
-
+
/**
* @return Node type definitions found in classpath as registered in OSGi bundle headers
*/
@@ -86,7 +86,7 @@
List<String> nodeTypeResources = getNodeTypeDefinitions();
register(session, nodeTypeResources, nodeTypeMode);
}
-
+
/**
* Registers node types found in classpath in JCR repository.
* @param session Session
@@ -109,7 +109,7 @@
throw new IllegalArgumentException("Node type mode not supported: " + nodeTypeMode);
}
}
-
+
/**
* Registers only the namespaces found in node type definitions in classpath in JCR repository.
* @param session Session
@@ -131,7 +131,7 @@
}
try {
Reader reader = new InputStreamReader(is);
- CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry> cndReader
+ CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry> cndReader
= new CompactNodeTypeDefReader<NodeTypeTemplate, NamespaceRegistry>(reader, nodeTypeResource, factory);
NamespaceRegistry mapping = cndReader.getNamespaceMapping();
for (int i=0; i<mapping.getURIs().length; i++) {
@@ -152,9 +152,9 @@
IOUtils.closeQuietly(is);
}
}
-
+
}
-
+
/**
* Registers node types found in classpath in JCR repository.
* @param session Session
@@ -181,7 +181,7 @@
registerNodeTypesAndRemoveSucceeds(remainingNodeTypeResources, classLoader, nodeTypeManager, namespaceRegistry, valueFactory, true);
}
}
-
+
/**
* Register node types found in classpath in JCR repository, and remove those that succeeded to register from the list.
* @param nodeTypeResources List of nodetype classpath resources
@@ -216,7 +216,7 @@
}
}
}
-
+
/**
* Find all node type definition classpath paths by searching all MANIFEST.MF files in the classpath and reading
* the paths from the "Sling-Nodetypes" entry.
@@ -227,12 +227,12 @@
private static List<String> findeNodeTypeDefinitions() {
return new ArrayList<String>(ManifestScanner.getValues("Sling-Nodetypes"));
}
-
+
public static NodeTypeDefinitionScanner get() {
return SINGLETON;
}
-
-
+
+
/**
* Some dummy classes to allow usage of CompactNodeTypeDefReader with underlying JCR mock
*/
@@ -288,7 +288,7 @@
public void unregisterNodeTypes(String[] names) {
}
}
-
+
private static class DummyNodeTypeTemplate implements NodeTypeTemplate {
@Override
public String getName() {
@@ -354,9 +354,9 @@
@Override
public List getNodeDefinitionTemplates() {
return new ArrayList();
- }
+ }
}
-
+
private static class DummyNodeDefinitionTemplate implements NodeDefinitionTemplate {
@Override
public NodeType[] getRequiredPrimaryTypes() {
@@ -427,7 +427,7 @@
public void setSameNameSiblings(boolean allowSameNameSiblings) {
}
}
-
+
private static class DummyPropertyDefinitionTemplate implements PropertyDefinitionTemplate {
@Override
public int getRequiredType() {
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 9587feb..9b60bdc 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
@@ -27,15 +27,15 @@
* Neither registration of namespaces or node types required (no underlying JCR).
*/
NOT_SUPPORTED,
-
+
/**
* Namespaces have to be registered, but nodetypes are not supported.
*/
NAMESPACES_ONLY,
-
+
/**
* Nodetypes including namespaces have to be registered.
*/
NODETYPES_REQUIRED
-
+
}
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 85865ee..b9457a1 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
@@ -59,16 +59,16 @@
* @param bundleContext Bundle context
*/
@SuppressWarnings("null")
- public static @NotNull ResourceResolverFactory setUp(@Nullable SlingRepository slingRepository,
+ public static @NotNull ResourceResolverFactory setUp(@Nullable SlingRepository slingRepository,
@NotNull BundleContext bundleContext, @NotNull NodeTypeMode nodeTypeMode) {
-
+
if (slingRepository != null) {
// register sling repository as OSGi service
registerServiceIfNotPresent(bundleContext, SlingRepository.class, slingRepository);
-
+
// register JCR node types found in classpath
registerJcrNodeTypes(slingRepository, nodeTypeMode);
-
+
// initialize JCR resource provider
ensureJcrResourceProviderDependencies(bundleContext);
initializeJcrResourceProvider(bundleContext);
@@ -102,19 +102,19 @@
try {
Field pathMapperLoggerField = pathMapperClass.getDeclaredField("log");
pathMapperLoggerField.setAccessible(true);
- pathMapperLoggerField.set(pathMapper, Proxy.newProxyInstance(Logger.class.getClassLoader(),
+ 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) {
// ignore - service was removed in org.apache.sling.jcr.resource 3.0.0
}
}
-
+
/**
* Initialize JCR resource provider.
* @param bundleContext Bundle context
@@ -135,14 +135,14 @@
Dictionary<String, Object> config = new Hashtable<String, Object>();
config.put("user.mapping", bundleContext.getBundle().getSymbolicName() + "=admin");
registerServiceIfNotPresent(bundleContext, ServiceUserMapper.class, new ServiceUserMapperImpl(), config);
-
+
registerServiceIfNotPresent(bundleContext, ResourceAccessSecurityTracker.class, new ResourceAccessSecurityTracker());
registerServiceIfNotPresent(bundleContext, EventAdmin.class, new MockEventAdmin());
// dependency required since resourceresolver 1.7.0
registerServiceIfNotPresentByName(bundleContext, "org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProvider",
"org.apache.sling.resourceresolver.impl.mapping.StringInterpolationProviderImpl");
}
-
+
/**
* Initialize resource resolver factory activator.
* @param bundleContext Bundle context
@@ -177,7 +177,7 @@
* @param serviceClass Service class
* @param instance Service instance
*/
- private static <T> void registerServiceIfNotPresent(@NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass,
+ private static <T> void registerServiceIfNotPresent(@NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass,
@NotNull T instance) {
registerServiceIfNotPresent(bundleContext, serviceClass, instance, new Hashtable<String, Object>());
}
@@ -190,7 +190,7 @@
* @param instance Service instance
* @param config OSGi config
*/
- private static <T> void registerServiceIfNotPresent(@NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass,
+ private static <T> void registerServiceIfNotPresent(@NotNull BundleContext bundleContext, @NotNull Class<T> serviceClass,
@NotNull T instance, Dictionary<String, Object> config) {
if (bundleContext.getServiceReference(serviceClass.getName()) == null) {
MockOsgi.injectServices(instance, bundleContext);
@@ -204,7 +204,7 @@
* @param slingRepository Sling repository
*/
@SuppressWarnings("deprecation")
- private static void registerJcrNodeTypes(final SlingRepository slingRepository,
+ private static void registerJcrNodeTypes(final SlingRepository slingRepository,
final NodeTypeMode nodeTypeMode) {
Session session = null;
try {
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 11132c9..cacd0a1 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
@@ -63,13 +63,13 @@
* implementation.</li>
* <li>The JCR repository is started on first access, this may take some
* seconds.</li>
- * <li>The <code>MemoryNodeStore</code> implementation is used, with no
+ * <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),
-
+
/**
* Provides resource resolver environment without any ResourceProvider.
* You have to register one yourself to do anything useful with it.
@@ -80,12 +80,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,
@NotNull final String artifactCoordinates,
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 9d88d6f..0342108 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
@@ -64,12 +64,12 @@
AdapterManagerBundleContextFactory adapterManager = THREAD_LOCAL.get();
adapterManager.clearBundleContext();
}
-
-
+
+
private static class AdapterManagerBundleContextFactory {
-
+
private BundleContext bundleContext;
-
+
public void setBundleContext(@NotNull final BundleContext bundleContext) {
this.bundleContext = bundleContext;
@@ -84,7 +84,7 @@
public void clearBundleContext() {
this.bundleContext = null;
}
-
+
@SuppressWarnings("null")
public synchronized AdapterManager getAdapterManager() {
if (bundleContext == null) {
@@ -98,7 +98,7 @@
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 567f95f..23cd9b2 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
@@ -71,7 +71,7 @@
if (parentPath == null) {
throw new IllegalArgumentException("Path has no parent: " + path);
}
-
+
// check if properties map contains maps representing child resources
Map<String,Object> propertiesWihtoutChildren;
Map<String,Map<String,Object>> children = getChildMaps(properties);
@@ -86,7 +86,7 @@
else {
propertiesWihtoutChildren = properties;
}
-
+
// create resource
Resource parentResource = ensureResourceExists(parentPath);
String name = ResourceUtil.getName(path);
@@ -96,15 +96,15 @@
} catch (PersistenceException ex) {
throw new RuntimeException("Unable to create resource at " + path, ex);
}
-
+
// create child resources
for (Map.Entry<String,Map<String,Object>> entry : children.entrySet()) {
resource(newResource, entry.getKey(), entry.getValue());
}
-
+
return newResource;
}
-
+
@SuppressWarnings("unchecked")
private Map<String,Map<String,Object>> getChildMaps(Map<String,Object> properties) {
Map<String,Map<String,Object>> result = new LinkedHashMap<>();
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 8bcb9d8..3aea292 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
@@ -34,20 +34,20 @@
/**
* Mock extension of {@link SlingBindings} that dynamically evaluates properties read from SlingBindings from the current mock context.
* Normally the SlingBingings are set statically for each script execution, but in mocks where no script is really executed
- * it's easier to evaluate them from current context.
+ * it's easier to evaluate them from current context.
*/
class MockSlingBindings extends SlingBindings implements EventHandler {
private static final long serialVersionUID = 1L;
private static final String PROP_CURRENT_NODE = "currentNode";
private static final String PROP_CURRENT_SESSION = "currentSession";
-
+
/**
* OSGi service property to set to "true" on BindingsValuesProvider implementations that should be ignored
* when populating the "non-dynamic" bindings properties.
*/
static final String SERVICE_PROPERTY_MOCK_SLING_BINDINGS_IGNORE = "MockSlingBindings-ignore";
-
+
private final SlingContextImpl context;
public MockSlingBindings(SlingContextImpl context) {
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 6331ce6..794a2d1 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
@@ -56,16 +56,16 @@
* Helper methods for registering Sling Models from the classpath.
*/
final class ModelAdapterFactoryUtil {
-
+
private static final @NotNull String PACKAGE_HEADER = "Sling-Model-Packages";
private static final @NotNull String CLASSES_HEADER = "Sling-Model-Classes";
-
+
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>>();
-
+
static {
// suppress log entries from Reflections library
Reflections.log = null;
@@ -74,7 +74,7 @@
MODELS_PACKAGES_FROM_MANIFEST = toArray(ManifestScanner.getValues(PACKAGE_HEADER));
MODELS_CLASSES_FROM_MANIFEST = toArray(ManifestScanner.getValues(CLASSES_HEADER));
}
-
+
private ModelAdapterFactoryUtil() {
// static methods only
}
@@ -82,7 +82,7 @@
private static @NotNull String @NotNull [] toArray(@NotNull Collection<String> values) {
return values.toArray(new String[values.size()]);
}
-
+
/**
* Search classpath for given java package names (and sub packages) to scan for and
* register all classes with @Model annotation.
@@ -118,7 +118,7 @@
}
addModelsForClasses(bundleContext, classNames);
}
-
+
/**
* Scan MANIFEST.MF in the classpath and automatically register all sling model classes found.
* @param bundleContext Bundle context
@@ -131,7 +131,7 @@
addModelsForClasses(bundleContext, MODELS_CLASSES_FROM_MANIFEST);
}
}
-
+
/**
* Get model classes in list of packages (and subpackages), and cache result in static map.
* @param packageNames Package names
@@ -154,7 +154,7 @@
}
return urls;
}
-
+
/**
* Get model classes in list of class names, and cache result in static map.
* @param packageNames Class names
@@ -180,7 +180,7 @@
}
return urls;
}
-
+
private static URL classToUrl(Class clazz) {
try {
return new URL("file:/" + clazz.getName().replace('.', '/') + ".class");
@@ -192,7 +192,7 @@
private static class RegisterModelsBundle implements Bundle {
-
+
private static final String MAGIC_STRING = "MOCKS-YOU-KNOW-WHAT-TO-SCAN";
private final BundleContext bundleContext;
@@ -206,7 +206,7 @@
this.packageNames = normalizeValueList(packageNames);
this.classNames = normalizeValueList(classNames);
}
-
+
private String normalizeValueList(String[] values) {
if (values == null || values.length == 0) {
return null;
@@ -237,7 +237,7 @@
}
return urls.elements();
}
-
+
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
return getClass().getClassLoader().loadClass(name);
@@ -368,7 +368,7 @@
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 4d0cad5..10b67df 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
@@ -80,7 +80,7 @@
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";
-
+
protected ResourceResolverFactory resourceResolverFactory;
protected ResourceResolverType resourceResolverType;
protected ResourceResolver resourceResolver;
@@ -92,7 +92,7 @@
protected ContentBuilder contentBuilder;
protected ResourceBuilder resourceBuilder;
protected UniqueRoot uniqueRoot;
-
+
private Map<String, Object> resourceResolverFactoryActivatorProps;
private boolean registerSlingModelsFromClassPath = true;
@@ -111,7 +111,7 @@
protected void setResourceResolverFactoryActivatorProps(@Nullable Map<String, Object> props) {
this.resourceResolverFactoryActivatorProps = props;
}
-
+
protected void setRegisterSlingModelsFromClassPath(boolean registerSlingModelsFromClassPath) {
this.registerSlingModelsFromClassPath = registerSlingModelsFromClassPath;
}
@@ -122,21 +122,21 @@
protected void setUp() {
super.setUp();
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);
}
-
+
// automatically register resource resolver factory when ResourceResolverType != NONE,
// so the ResourceResolverFactory is available as OSGi service immediately
if (resourceResolverType != ResourceResolverType.NONE) {
resourceResolverFactory();
}
-
+
registerDefaultServices();
}
-
+
/**
* Initialize mocked resource resolver factory.
* @return Resource resolver factory
@@ -144,7 +144,7 @@
protected @NotNull ResourceResolverFactory newResourceResolverFactory() {
return ContextResourceResolverFactory.get(this.resourceResolverType, bundleContext());
}
-
+
private @NotNull ResourceResolverFactory resourceResolverFactory() {
if (this.resourceResolverFactory == null) {
this.resourceResolverFactory = newResourceResolverFactory();
@@ -162,7 +162,7 @@
"org.apache.sling.scripting.core.impl.ScriptEngineManagerFactory",
"org.apache.sling.scripting.core.impl.jsr223.SlingScriptEngineManager");
registerInjectActivateService(new BindingsValuesProvidersByContextImpl());
-
+
// sling models
registerInjectActivateService(new ModelAdapterFactory());
registerInjectActivateServiceByClassName(
@@ -190,13 +190,13 @@
registerInjectActivateService(new MockResourceBundleProvider());
registerInjectActivateService(new MockXSSAPIImpl());
registerInjectActivateService(new FeatureManager());
-
+
// scan for models defined via bundle headers in classpath
if (registerSlingModelsFromClassPath) {
ModelAdapterFactoryUtil.addModelsForManifestEntries(this.bundleContext());
}
}
-
+
@SuppressWarnings("null")
private void registerInjectActivateServiceByClassName(@NotNull String @NotNull ... classNames) {
for (String className : classNames) {
@@ -213,9 +213,9 @@
* Teardown actions after test method execution
*/
protected void tearDown() {
-
+
if (this.resourceResolver != null) {
-
+
// revert potential unsaved changes in resource resolver/JCR session
try {
this.resourceResolver.revert();
@@ -232,12 +232,12 @@
// ignore - this may happen when jcr-mock is used
}
}
-
+
// remove unique roots
if (this.uniqueRoot != null) {
this.uniqueRoot.cleanUp();
}
-
+
// close resource resolver
this.resourceResolver.close();
}
@@ -252,10 +252,10 @@
this.resourceBuilder = null;
this.uniqueRoot = null;
this.resourceResolverFactory = null;
-
+
super.tearDown();
- MockSling.clearAdapterManagerBundleContext();
+ MockSling.clearAdapterManagerBundleContext();
}
/**
@@ -264,7 +264,7 @@
public final @NotNull ResourceResolverType resourceResolverType() {
return this.resourceResolverType;
}
-
+
/**
* Returns the singleton resource resolver bound to this context.
* It is automatically closed after the test.
@@ -281,7 +281,7 @@
}
return this.resourceResolver;
}
-
+
/**
* @return Sling request
*/
@@ -291,16 +291,16 @@
// initialize sling bindings
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.request.setAttribute(SlingBindings.class.getName(), bindings);
}
return this.request;
}
-
+
/**
* Dynamically resolve property request for current request {@link SlingBindings}.
* @param property Property key
@@ -388,7 +388,7 @@
}
return this.contentBuilder;
}
-
+
/**
* Creates a {@link ResourceBuilder} object for easily creating test content.
* This is a separate API which can be used inside sling mocks or in a running instance.
@@ -484,7 +484,7 @@
slingSettings.setRunModes(newRunModes);
}
}
-
+
/**
* Create unique root paths for unit tests (and clean them up after the test run automatically).
* @return Unique root path helper
@@ -495,7 +495,7 @@
}
return uniqueRoot;
}
-
+
/**
* Create a Sling AdapterFactory on the fly which can adapt from <code>adaptableClass</code>
* to <code>adapterClass</code> and just returns the given value as result.
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 373d2eb..88ebcf0 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
@@ -33,29 +33,29 @@
/**
* Manages unique root paths in JCR repository.
- * This is important for resource resolver types like JCR_JACKRABBIT
+ * This is important for resource resolver types like JCR_JACKRABBIT
* where the repository is not cleaned for each test run. This class provides
* unique root paths for each run, and cleans them up when done.
*/
@ConsumerType
public class UniqueRoot {
-
+
private final SlingContextImpl context;
-
+
protected final String uniquePathPart;
-
+
private Resource contentRoot;
private Resource appsRoot;
private Resource libsRoot;
-
+
private static final Logger log = LoggerFactory.getLogger(UniqueRoot.class);
-
+
protected UniqueRoot(@NotNull SlingContextImpl context) {
this.context = context;
// generate unique path part by using a UUID
uniquePathPart = UUID.randomUUID().toString();
}
-
+
/**
* Get or create resource with given JCR primary type
* @param path Path
@@ -64,7 +64,7 @@
*/
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);
}
@@ -72,7 +72,7 @@
throw new RuntimeException("Unable to create resource at " + path + ": " + ex.getMessage(), ex);
}
}
-
+
/**
* Gets (and creates if required) a unique path at <code>/content/xxx</code>.
* The path (incl. all children) is automatically removed when the unit test completes.
@@ -84,7 +84,7 @@
}
return contentRoot.getPath();
}
-
+
/**
* Gets (and creates if required) a unique path at <code>/apps/xxx</code>.
* The path (incl. all children) is automatically removed when the unit test completes.
@@ -96,7 +96,7 @@
}
return appsRoot.getPath();
}
-
+
/**
* Gets (and creates if required) a unique path at <code>/libs/xxx</code>.
* The path (incl. all children) is automatically removed when the unit test completes.
@@ -108,7 +108,7 @@
}
return libsRoot.getPath();
}
-
+
/**
* Cleanup is called when the unit test rule completes a unit test run.
* All resources created have to be removed.
@@ -116,7 +116,7 @@
protected void cleanUp() {
deleteResources(contentRoot, appsRoot, libsRoot);
}
-
+
/**
* Deletes the given set of resources and commits afterwards.
* @param resources Resources to be deleted
@@ -138,7 +138,7 @@
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 fdb46d7..d0f0c6a 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
@@ -64,20 +64,20 @@
"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))
.collect(Collectors.toSet());
-
+
// 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))
- .collect(Collectors.toSet());
-
+ .collect(Collectors.toSet());
+
private final ResourceResolver resourceResolver;
private final BundleContext bundleContext;
private final boolean autoCommit;
@@ -129,7 +129,7 @@
// JSONContentParser is an OSGi service - for sake of simplicity in this mock environment instantiate it directly
this.jsonParser = new JSONContentParser();
}
-
+
private final Set<String> getIgnoredNamesForResourceResolverType(ResourceResolverType resourceResolverType) {
if (resourceResolverType == null || resourceResolverType == ResourceResolverType.JCR_OAK) {
return OAK_IGNORED_NAMES;
@@ -208,7 +208,7 @@
try {
String parentPath = ResourceUtil.getParent(destPath);
String childName = ResourceUtil.getName(destPath);
-
+
if (parentPath == null) {
throw new IllegalArgumentException("Path has no parent: " + destPath);
}
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 4c7c7d4..0068d69 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
@@ -41,7 +41,7 @@
private final @NotNull String rootPath;
private final @NotNull ResourceResolver resourceResolver;
-
+
public LoaderContentHandler(@NotNull String rootPath, @NotNull ResourceResolver resourceResolver) {
this.rootPath = rootPath;
this.resourceResolver = resourceResolver;
@@ -55,25 +55,25 @@
}
String parentPath = ResourceUtil.getParent(fullPath);
String name = ResourceUtil.getName(fullPath);
-
+
if (parentPath == null) {
throw new IllegalArgumentException("Path has no parent: " + fullPath);
}
-
+
Resource parentResource = resourceResolver.getResource(parentPath);
if (parentResource == null) {
throw new RuntimeException("Parent resource '" + parentPath + "' not found.");
}
try {
createResource(parentResource, name, properties);
- }
+ }
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 {
-
+
// collect all properties first
boolean hasJcrData = false;
String referencedNodePath = null;
@@ -92,7 +92,7 @@
}
}
}
-
+
// create resource
Resource resource = resourceResolver.create(parentResource, childName, props);
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 cfe7a23..babbff1 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
@@ -49,7 +49,7 @@
private void lazyInitialization() {
if (!this.initialized) {
this.initialized = true;
-
+
ComponentContext componentContext = MockOsgi.newComponentContext();
// activate service in simulated OSGi environment (for MimeTypeService impl < 2.0.0)
@@ -63,7 +63,7 @@
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
try {
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 26c4b6e..55db2d7 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
@@ -22,9 +22,9 @@
* Mock {@link javax.servlet.http.HttpSession} implementation.
*/
public final class MockHttpSession extends org.apache.sling.servlethelpers.MockHttpSession {
-
+
protected MockServletContext newMockServletContext() {
return new MockServletContext();
}
-
-}
\ No newline at end of file
+
+}
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 ffe68b6..cc47581 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
@@ -26,7 +26,7 @@
public final class MockRequestPathInfo extends org.apache.sling.servlethelpers.MockRequestPathInfo {
/**
- * @deprecated Use @link {@link #MockRequestPathInfo(ResourceResolver)} instead.
+ * @deprecated Use @link {@link #MockRequestPathInfo(ResourceResolver)} instead.
*/
@Deprecated
public MockRequestPathInfo() {
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 be4fd11..6ae24e4 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
@@ -59,7 +59,7 @@
protected @NotNull MockHttpSession newMockHttpSession() {
return new MockHttpSession();
}
-
+
@Override
@SuppressWarnings("null")
public ResourceBundle getResourceBundle(String baseName, Locale locale) {
@@ -69,7 +69,7 @@
if (serviceReference != null) {
ResourceBundleProvider provider = (ResourceBundleProvider)bundleContext.getService(serviceReference);
resourceBundle = provider.getResourceBundle(baseName, locale);
- }
+ }
// if no ResourceBundleProvider exists return empty bundle
if (resourceBundle == null) {
resourceBundle = EMPTY_RESOURCE_BUNDLE;
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 cf078af..af784dd 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
@@ -34,14 +34,14 @@
@Rule
public SlingContext context = new SlingContext();
-
+
private SlingRepository repository;
@Before
public void setUp() {
this.repository = context.registerInjectActivateService(new MockJcrSlingRepository());
}
-
+
@SuppressWarnings("deprecation")
@Test
public void testLoginAdministrative() throws RepositoryException {
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 c83efba..6a23cb4 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
@@ -33,7 +33,7 @@
public class MockResourceBundleProviderTest {
private static final String MY_NAME = "my-name";
-
+
@Rule
public SlingContext context = new SlingContext();
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 462044d..2716ec5 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
@@ -52,7 +52,7 @@
this.response = new MockSlingHttpServletResponse();
this.scriptHelper = MockSling.newSlingScriptHelper(this.request, this.response, this.bundleContext);
}
-
+
@After
public void tearDown() {
this.resourceResolver.close();
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 032129b..07df1cb 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
@@ -30,7 +30,7 @@
@Test
public void testGetNodeTypeDefinitions() throws Exception {
List<String> definitions = NodeTypeDefinitionScanner.get().getNodeTypeDefinitions();
-
+
// ensure some node types from jcr.resource exist
assertTrue(definitions.contains("SLING-INF/nodetypes/folder.cnd"));
assertTrue(definitions.contains("SLING-INF/nodetypes/resource.cnd"));
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 d92d374..ac65cda 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
@@ -73,12 +73,12 @@
@Test
public void testChildResource() {
Resource resource = context.create().resource("/content/test1/resource1");
-
+
Resource child1 = context.create().resource(resource, "child1");
assertNotNull(child1);
assertEquals("child1", child1.getName());
assertTrue(ResourceUtil.getValueMap(child1).isEmpty());
-
+
Resource child2 = context.create().resource(resource, "/child2",
"prop1", "value1");
assertNotNull(child2);
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 2b53c75..d8bd6ae 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
@@ -32,7 +32,7 @@
@SuppressWarnings("null")
public abstract class AbstractModelAdapterFactoryUtilTest {
-
+
protected abstract SlingContext context();
@Test
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 97f6d24..ec483ec 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
@@ -54,13 +54,13 @@
assertEquals(1, context.getServices(ResourceResolverFactory.class, null).length);
context.addModelsForPackage("org.apache.sling.testing.mock.sling.context.models");
-
+
ContentLoader contentLoader = this.context.load();
contentLoader.json("/json-import-samples/content.json", "/content/sample/en");
}
protected abstract ResourceResolverType getResourceResolverType();
-
+
@Test
public void testContextObjects() {
assertNotNull(context.componentContext());
@@ -149,5 +149,5 @@
assertTrue(newRunModes.contains("mode1"));
assertTrue(newRunModes.contains("mode2"));
}
-
+
}
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 9c2e50d..67fceb2 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
@@ -52,7 +52,7 @@
"enabled", false);
assertEnabled("feature.1", false);
}
-
+
private void assertEnabled(String featureFlag, boolean enabled) {
Features features = context.getService(Features.class);
assertNotNull(features);
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 f576075..f3b6c44 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
@@ -29,7 +29,7 @@
@Rule
public SlingContext context = new SlingContext();
-
+
@Override
protected SlingContext context() {
return context;
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 204d40e..3547d9a 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
@@ -26,7 +26,7 @@
@Rule
public SlingContext context = new SlingContext();
-
+
@Override
protected SlingContext context() {
return context;
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 87c545e..443404a 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
@@ -36,19 +36,19 @@
@Rule
public SlingContext context = new SlingContext(ResourceResolverType.NONE);
-
+
@Mock
private ResourceProvider<?> resourceProvider;
-
+
@Test
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, "/");
-
+
Resource root = context.resourceResolver().getResource("/");
assertTrue(root instanceof SyntheticResource);
}
-
+
}
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 838179c..5b4f520 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
@@ -39,31 +39,31 @@
@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",
- ImmutableMap.<String, Object> builder().put("prop1", "value1")
- .put("prop2", "value2").build());
- Node node = resource.adaptTo(Node.class);
- Session session = context.resourceResolver().adaptTo(Session.class);
-
- MockJcr.setQueryResult(session, Collections.singletonList(node));
- }
+ @Before
+ public void setUp() {
+ Resource resource = context.create().resource(
+ "/test",
+ ImmutableMap.<String, Object> builder().put("prop1", "value1")
+ .put("prop2", "value2").build());
+ Node node = resource.adaptTo(Node.class);
+ Session session = context.resourceResolver().adaptTo(Session.class);
- @Test
+ MockJcr.setQueryResult(session, Collections.singletonList(node));
+ }
+
+ @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/MultipleResourceResolverTest.java b/core/src/test/java/org/apache/sling/testing/mock/sling/jcrmock/resource/MultipleResourceResolverTest.java
index 2b12d79..cc02db4 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,5 @@
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 241acfa..f1d2f9f 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
@@ -99,7 +99,7 @@
@NotNull final ContextCallback<V> beforeTearDownCallback) {
this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, null);
}
-
+
/**
* Initialize Sling context with resource resolver type.
* @param <U> context type
@@ -113,7 +113,7 @@
@NotNull final ResourceResolverType resourceResolverType) {
this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, resourceResolverType);
}
-
+
/**
* Initialize Sling context with resource resolver type.
* @param contextPlugins Context plugins
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 24e8d29..babe912 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
@@ -40,17 +40,17 @@
*/
@ProviderType
public final class SlingContextBuilder {
-
+
private final @NotNull ContextPlugins plugins = new ContextPlugins();
private ResourceResolverType resourceResolverType;
private Map<String, Object> resourceResolverFactoryActivatorProps;
private boolean registerSlingModelsFromClassPath = true;
-
+
/**
* Create builder with default resource resolver type.
*/
public SlingContextBuilder() {}
-
+
/**
* Create builder with given resource resolver type.
* @param resourceResolverType Resource resolver type.
@@ -58,7 +58,7 @@
public SlingContextBuilder(@NotNull ResourceResolverType resourceResolverType) {
this.resourceResolverType(resourceResolverType);
}
-
+
/**
* @param resourceResolverType Resource resolver type.
* @return this
@@ -67,7 +67,7 @@
this.resourceResolverType = resourceResolverType;
return this;
}
-
+
/**
* @param <T> context type
* @param plugin Context plugin which listens to context lifecycle events.
@@ -152,5 +152,5 @@
this.resourceResolverType,
this.registerSlingModelsFromClassPath);
}
-
+
}
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 1be23aa..d6babba 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
@@ -43,14 +43,14 @@
public abstract class AbstractContentLoaderBinaryTest {
private static final int SAMPLE_IMAGE_FILESIZE = 62;
-
+
@Rule
public SlingContext context = new SlingContext(getResourceResolverType());
protected abstract ResourceResolverType getResourceResolverType();
-
+
protected String path;
-
+
@Before
public void setUp() {
path = context.uniqueRoot().content();
@@ -61,7 +61,7 @@
// make sure all changes from ContentLoader are committed
assertFalse(context.resourceResolver().hasChanges());
}
-
+
@Test
public void testBinaryFile() throws IOException {
context.load().binaryFile("/sample-image.gif", path + "/sample-image.gif");
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 aecf49f..7fb2b6f 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
@@ -53,13 +53,13 @@
protected abstract ResourceResolverType getResourceResolverType();
protected String path;
-
+
@Before
public void setUp() {
path = context.uniqueRoot().content() + "/dam";
try {
- NodeTypeDefinitionScanner.get().register(context.resourceResolver().adaptTo(Session.class),
+ NodeTypeDefinitionScanner.get().register(context.resourceResolver().adaptTo(Session.class),
ImmutableList.of("SLING-INF/nodetypes/app.cnd"),
getResourceResolverType().getNodeTypeMode());
}
@@ -75,7 +75,7 @@
// make sure all changes from ContentLoader are committed
assertFalse(context.resourceResolver().hasChanges());
}
-
+
@Test
public void testDamAssetMetadata() throws IOException {
Resource assetMetadata = context.resourceResolver()
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 9abdbf2..5e767f6 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
@@ -51,7 +51,7 @@
public SlingContext context = new SlingContext(getResourceResolverType());
protected abstract ResourceResolverType getResourceResolverType();
-
+
protected String path;
@Before
@@ -59,7 +59,7 @@
path = context.uniqueRoot().content();
try {
- NodeTypeDefinitionScanner.get().register(context.resourceResolver().adaptTo(Session.class),
+ NodeTypeDefinitionScanner.get().register(context.resourceResolver().adaptTo(Session.class),
ImmutableList.of("SLING-INF/nodetypes/app.cnd"),
getResourceResolverType().getNodeTypeMode());
}
@@ -75,7 +75,7 @@
// make sure all changes from ContentLoader are committed
assertFalse(context.resourceResolver().hasChanges());
}
-
+
@Test
public void testPageResourceType() {
Resource resource = context.resourceResolver().getResource(path + "/sample/en");
@@ -162,7 +162,7 @@
assertEquals(11, calendar.get(Calendar.MINUTE));
assertEquals(24, calendar.get(Calendar.SECOND));
}
-
+
@Test
public void testCalendarISO8601Format() {
Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content");
@@ -172,7 +172,7 @@
assertNotNull(calendar);
calendar.setTimeZone(TimeZone.getTimeZone("GMT+2"));
-
+
assertEquals(2014, calendar.get(Calendar.YEAR));
assertEquals(4, calendar.get(Calendar.MONTH) + 1);
assertEquals(22, calendar.get(Calendar.DAY_OF_MONTH));
@@ -181,29 +181,29 @@
assertEquals(11, calendar.get(Calendar.MINUTE));
assertEquals(24, calendar.get(Calendar.SECOND));
}
-
+
@Test
public void testUTF8Chars() {
Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content");
ValueMap props = ResourceUtil.getValueMap(resource);
-
+
assertEquals("äöü߀", props.get("utf8Property"));
}
-
+
@Test
public void testJcrUuid() {
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));
}
-
+
@Test
public void testJcrCreated() {
Resource resource = context.resourceResolver().getResource(path + "/sample/en/jcr:content/par/image/file");
ValueMap props = ResourceUtil.getValueMap(resource);
-
+
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 75e4f31..308aa9f 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
@@ -36,42 +36,42 @@
import org.osgi.framework.BundleContext;
/**
- * Validates correct registering and mapping of JCR namespaces, esp. the sling namespace.
+ * Validates correct registering and mapping of JCR namespaces, esp. the sling namespace.
*/
@SuppressWarnings("null")
public abstract class AbstractJcrNamespaceTest {
-
+
@Rule
public SlingContext context = new SlingContext(getResourceResolverType());
protected abstract ResourceResolverType getResourceResolverType();
-
+
@Test
public void testSling4362() throws RepositoryException {
BundleContext bundleContext = MockOsgi.newBundleContext();
ResourceResolver resolver = MockSling.newResourceResolver(getResourceResolverType(), bundleContext);
-
+
ContentLoader contentLoader = new ContentLoader(resolver);
contentLoader.json("/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
Resource resource = resolver.getResource(context.uniqueRoot().content() + "/foo");
-
+
ValueMap props = ResourceUtil.getValueMap(resource);
assertEquals("fooType", props.get("sling:resourceType"));
assertEquals("fooType", resource.getResourceType());
-
+
MockOsgi.shutdown(bundleContext);
}
@Test
public void testSling4362_ViaContextRule() throws RepositoryException {
ResourceResolver resolver = context.resourceResolver();
-
+
ContentLoader contentLoader = new ContentLoader(resolver);
contentLoader.json("/json-import-samples/SLING-4362.json", context.uniqueRoot().content() + "/foo");
Resource resource = resolver.getResource(context.uniqueRoot().content() + "/foo");
-
+
ValueMap props = ResourceUtil.getValueMap(resource);
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 8590e46..ed12ce2 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
@@ -61,7 +61,7 @@
@Rule
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 int INTEGER_VALUE = 25;
@@ -157,7 +157,7 @@
assertEquals(JcrConstants.NT_UNSTRUCTURED, child.getResourceType());
assertEquals(JcrConstants.NT_UNSTRUCTURED, child.adaptTo(Node.class).getPrimaryNodeType().getName());
}
-
+
@Test
public void testCreateNodeWithResourceType() throws RepositoryException, PersistenceException {
Resource parent = context.resourceResolver().getResource(getTestRootNode().getPath());
@@ -171,16 +171,16 @@
@Test
public void testPendingChangesCommit() throws Exception {
-
+
// skip this test for JCR_MOCK because it does not track pending changes
if (getResourceResolverType()==ResourceResolverType.JCR_MOCK) {
return;
}
-
+
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 cf6b167..5808a78 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
@@ -40,38 +40,38 @@
public abstract class AbstractMultipleResourceResolverTest {
private final BundleContext bundleContext = MockOsgi.newBundleContext();
-
+
protected abstract ResourceResolverType getResourceResolverType();
-
+
protected ResourceResolverFactory newResourceResolerFactory() {
return MockSling.newResourceResolverFactory(getResourceResolverType(), bundleContext);
}
-
+
@After
public void tearDown() {
MockOsgi.shutdown(bundleContext);
}
-
+
@SuppressWarnings("deprecation")
@Test
public void testMultipleResourceResolver() throws Exception {
ResourceResolverFactory factory = newResourceResolerFactory();
ResourceResolver resolver1 = factory.getAdministrativeResourceResolver(null);
ResourceResolver resolver2 = factory.getAdministrativeResourceResolver(null);
-
+
// add a resource in resolver 1
Resource root = resolver1.getResource("/");
resolver1.create(root, "test", ImmutableMap.<String, Object>of());
resolver1.commit();
-
+
// try to get resource in resolver 2
Resource testResource2 = resolver2.getResource("/test");
assertNotNull(testResource2);
-
+
// delete resource and make sure it is removed in resolver 1 as well
resolver2.delete(testResource2);
resolver2.commit();
-
+
assertNull(resolver1.getResource("/test"));
}
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 84fee00..c97c660 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
@@ -58,7 +58,7 @@
*/
@SuppressWarnings("null")
public abstract class AbstractSlingCrudResourceResolverTest {
-
+
@Rule
public SlingContext context = new SlingContext(getResourceResolverType());
@@ -165,7 +165,7 @@
assertEquals(BOOLEAN_VALUE, props.get("node1/booleanProp", Boolean.class));
assertEquals(STRING_VALUE, props.get("node1/node11/stringProp11", String.class));
}
-
+
@Test
public void testDateProperty() throws IOException {
Resource resource1 = context.resourceResolver().getResource(getTestRootResource().getPath() + "/node1");
@@ -220,7 +220,7 @@
assertFalse(children.isEmpty());
assertTrue(containsResource(children, getTestRootResource().getParent()));
}
-
+
private boolean containsResource(List<Resource> children, Resource resource) {
for (Resource child : children) {
if (StringUtils.equals(child.getPath(), resource.getPath())) {
@@ -279,22 +279,22 @@
@Test
public void testPendingChangesCommit() throws PersistenceException {
-
+
// skip this test for JCR_MOCK because it does not track pending changes
if (getResourceResolverType()==ResourceResolverType.JCR_MOCK) {
return;
}
-
+
context.resourceResolver().delete(getTestRootResource());
assertTrue(context.resourceResolver().hasChanges());
-
+
context.resourceResolver().commit();
assertFalse(context.resourceResolver().hasChanges());
}
@Test
public void testCreateNestedResources() throws IOException {
- Resource nested = context.create().resource(getTestRootResource().getPath() + "/nested",
+ Resource nested = context.create().resource(getTestRootResource().getPath() + "/nested",
ImmutableMap.<String,Object>of(
"prop1", "value1",
"child1", ImmutableMap.<String,Object>of(
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 0ddd658..771422d 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
@@ -27,7 +27,7 @@
import org.junit.Test;
public abstract class AbstractUniqueRootTest {
-
+
@Rule
public SlingContext context = new SlingContext(getResourceResolverType());
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 6a17feb..a9bdc38 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
@@ -63,7 +63,7 @@
public void setUp() throws Exception {
request = new MockSlingHttpServletRequest(resourceResolver, bundleContext);
}
-
+
@After
public void tearDown() {
MockOsgi.shutdown(bundleContext);
@@ -110,8 +110,8 @@
{ "key1", "value1" }
};
}
- });
-
+ });
+
ResourceBundle bundle = request.getResourceBundle("base1", Locale.US);
assertNotNull(bundle);
assertEquals("value1", bundle.getString("key1"));
@@ -124,11 +124,11 @@
@Test
public void testGetSuffixResource() {
assertNull(request.getRequestPathInfo().getSuffixResource());
-
+
((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/resources/json-import-samples/SLING-4362.json b/core/src/test/resources/json-import-samples/SLING-4362.json
index 7870490..9a23e8c 100644
--- a/core/src/test/resources/json-import-samples/SLING-4362.json
+++ b/core/src/test/resources/json-import-samples/SLING-4362.json
@@ -1,5 +1,5 @@
{
- "jcr:primaryType":"nt:unstructured",
- "sling:resourceType": "fooType",
- "thisIs": "child"
+ "jcr:primaryType":"nt:unstructured",
+ "sling:resourceType": "fooType",
+ "thisIs": "child"
}
diff --git a/junit4/pom.xml b/junit4/pom.xml
index 45ae74b..08e0463 100644
--- a/junit4/pom.xml
+++ b/junit4/pom.xml
@@ -75,7 +75,7 @@
<build>
<plugins>
-
+
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
@@ -84,7 +84,7 @@
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-baseline-maven-plugin</artifactId>
</plugin>
-
+
</plugins>
</build>
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 9ceda62..1dd3a3a 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
@@ -92,7 +92,7 @@
@NotNull final ContextCallback<V> beforeTearDownCallback) {
this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, null);
}
-
+
/**
* Initialize Sling context with resource resolver type.
* @param <U> context type
@@ -106,7 +106,7 @@
@NotNull final ResourceResolverType resourceResolverType) {
this(new ContextPlugins(afterSetUpCallback, beforeTearDownCallback), null, resourceResolverType);
}
-
+
/**
* Initialize Sling context with resource resolver type.
* @param contextPlugins Context plugins
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 afe5cb5..762e07e 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
@@ -33,17 +33,17 @@
*/
@ProviderType
public final class SlingContextBuilder {
-
+
private final @NotNull ContextPlugins plugins = new ContextPlugins();
private ResourceResolverType resourceResolverType;
private Map<String, Object> resourceResolverFactoryActivatorProps;
private boolean registerSlingModelsFromClassPath = true;
-
+
/**
* Create builder with default resource resolver type.
*/
public SlingContextBuilder() {}
-
+
/**
* Create builder with given resource resolver type.
* @param resourceResolverType Resource resolver type.
@@ -51,7 +51,7 @@
public SlingContextBuilder(@NotNull ResourceResolverType resourceResolverType) {
this.resourceResolverType(resourceResolverType);
}
-
+
/**
* @param resourceResolverType Resource resolver type.
* @return this
@@ -60,7 +60,7 @@
this.resourceResolverType = resourceResolverType;
return this;
}
-
+
/**
* @param <T> context type
* @param plugin Context plugin which listens to context lifecycle events.
@@ -145,5 +145,5 @@
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 6005625..abacb39 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
@@ -91,10 +91,10 @@
assertEquals("/testpath/node3", context.resourceResolver().getResource("node3").getPath());
assertNull(context.resourceResolver().getResource("node4"));
}
-
+
@Test
public void testRegisterAdapter() {
-
+
// prepare some adapter factories
context.registerAdapter(ResourceResolver.class, Integer.class, 5);
context.registerAdapter(ResourceResolver.class, String.class, new Function<ResourceResolver,String>() {
@@ -103,7 +103,7 @@
return ">" + input.toString();
}
});
-
+
// test adaption
assertEquals(Integer.valueOf(5), context.resourceResolver().adaptTo(Integer.class));
assertEquals(">" + context.resourceResolver().toString(), context.resourceResolver().adaptTo(String.class));
@@ -113,7 +113,7 @@
@Test
public void testRegisterAdapterOverlayStatic() {
prepareInitialAdapterFactory();
-
+
// register overlay adapter with static adaption
context.registerAdapter(TestAdaptable.class, String.class, "static-adaption");
@@ -124,7 +124,7 @@
@Test
public void testRegisterAdapterOverlayDynamic() {
prepareInitialAdapterFactory();
-
+
// register overlay adapter with dynamic adaption
context.registerAdapter(TestAdaptable.class, String.class, new Function<TestAdaptable, String>() {
@Override
@@ -136,28 +136,28 @@
// test overlay adapter with dynamic adaption
assertEquals("testMessage3-dynamic", new TestAdaptable("testMessage3").adaptTo(String.class));
}
-
+
@Test
public void testResourceBuilder() {
-
+
context.build().resource("/test1", "prop1", "value1")
.siblingsMode()
.resource("a")
.resource("b");
-
+
Resource test1 = context.resourceResolver().getResource("/test1");
assertNotNull(test1);
assertEquals("value1", test1.getValueMap().get("prop1", String.class));
assertNotNull(test1.getChild("a"));
assertNotNull(test1.getChild("b"));
}
-
+
@Test
public void testUrlMapping() {
assertEquals("/foo", context.resourceResolver().map("/content/test/foo"));
}
-
-
+
+
private void prepareInitialAdapterFactory() {
// register "traditional" adapter factory without specific service ranking
AdapterFactory adapterFactory = new AdapterFactory() {
@@ -171,14 +171,14 @@
.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));
+ assertEquals("testMessage1-initial", new TestAdaptable("testMessage1").adaptTo(String.class));
}
private static class TestAdaptable extends SlingAdaptable {
-
+
private final String message;
public TestAdaptable(String message) {
@@ -188,7 +188,7 @@
public String getMessage() {
return message;
}
-
+
}
}
diff --git a/junit5/pom.xml b/junit5/pom.xml
index fca923e..f51b83e 100644
--- a/junit5/pom.xml
+++ b/junit5/pom.xml
@@ -85,7 +85,7 @@
<dependencyManagement>
<dependencies>
-
+
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
@@ -93,7 +93,7 @@
<type>pom</type>
<scope>import</scope>
</dependency>
-
+
</dependencies>
</dependencyManagement>
diff --git a/parent/pom.xml b/parent/pom.xml
index 281e7b0..ba23079 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -33,7 +33,7 @@
<name>Apache Sling Testing Sling Mock Parent</name>
<description>Mock implementation of selected Sling APIs.</description>
-
+
<properties>
<osgi-mock.version>3.0.1-SNAPSHOT</osgi-mock.version>
@@ -73,7 +73,7 @@
</dependency>
</dependencies>
-
+
<dependencyManagement>
<dependencies>
@@ -213,7 +213,7 @@
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
-
+
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>