You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2021/03/08 10:09:52 UTC
[sling-org-apache-sling-testing-osgi-mock] 02/02: cosmetic: remove
training whitespaces
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-testing-osgi-mock.git
commit 1265ada6870340999ce4b01e644edde2bce780bf
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Mon Mar 8 11:06:36 2021 +0100
cosmetic: remove training whitespaces
---
core/pom.xml | 2 +-
.../testing/mock/osgi/ComponentContextBuilder.java | 16 ++---
.../sling/testing/mock/osgi/ManifestScanner.java | 6 +-
.../sling/testing/mock/osgi/MapMergeUtil.java | 16 ++---
.../apache/sling/testing/mock/osgi/MapUtil.java | 6 +-
.../apache/sling/testing/mock/osgi/MockBundle.java | 30 ++++----
.../sling/testing/mock/osgi/MockBundleContext.java | 26 +++----
.../testing/mock/osgi/MockComponentContext.java | 2 +-
.../sling/testing/mock/osgi/MockConfiguration.java | 8 +--
.../sling/testing/mock/osgi/MockEventAdmin.java | 26 +++----
.../apache/sling/testing/mock/osgi/MockOsgi.java | 16 ++---
.../testing/mock/osgi/MockServiceReference.java | 4 +-
.../testing/mock/osgi/MockServiceRegistration.java | 6 +-
.../sling/testing/mock/osgi/OsgiMetadataUtil.java | 42 +++++------
.../sling/testing/mock/osgi/OsgiServiceUtil.java | 82 +++++++++++-----------
.../mock/osgi/context/AbstractContextPlugin.java | 2 +-
.../testing/mock/osgi/context/ContextPlugins.java | 22 +++---
.../testing/mock/osgi/context/OsgiContextImpl.java | 6 +-
.../sling/testing/mock/osgi/MapUtilTest.java | 14 ++--
...ckBundleContextDynamicReferencesOsgiR6Test.java | 62 ++++++++--------
.../MockBundleContextDynamicReferencesTest.java | 40 +++++------
...ockBundleContextStaticGreedyReferencesTest.java | 44 ++++++------
.../testing/mock/osgi/MockBundleContextTest.java | 56 +++++++--------
.../sling/testing/mock/osgi/MockBundleTest.java | 42 +++++------
.../mock/osgi/MockComponentContextTest.java | 2 +-
.../mock/osgi/MockConfigurationAdminTest.java | 6 +-
.../testing/mock/osgi/MockEventAdminTest.java | 24 +++----
.../mock/osgi/MockServiceReferencesSortTest.java | 18 ++---
.../testing/mock/osgi/OsgiServiceRegisterTest.java | 8 +--
.../OsgiServiceUtilActivateDeactivateTest.java | 62 ++++++++--------
.../testing/mock/osgi/OsgiServiceUtilTest.java | 12 ++--
.../mock/osgi/context/ContextPluginsTest.java | 46 ++++++------
.../mock/osgi/context/OsgiContextImplTest.java | 4 +-
.../mock/osgi/junit/OsgiContextBuilder.java | 8 +--
.../mock/osgi/junit/OsgiContextCallback.java | 2 +-
core/src/test/resources/META-INF/test.txt | 2 +-
...sting.mock.osgi.context.OsgiContextImplTest.xml | 2 +-
.../src/test/resources/bundleData/nested/first.txt | 2 +-
.../test/resources/bundleData/nested/second.txt | 2 +-
junit4/pom.xml | 2 +-
.../mock/osgi/junit/OsgiContextBuilder.java | 8 +--
.../mock/osgi/junit/OsgiContextCallback.java | 2 +-
junit5/pom.xml | 6 +-
.../junit5/OsgiContextMemberInstantiatedTest.java | 2 +-
.../junit5/OsgiContextMemberSuperClassTest.java | 2 +-
.../mock/osgi/junit5/OsgiContextMemberTest.java | 2 +-
.../testing/mock/osgi/junit5/OsgiContextTest.java | 2 +-
parent/pom.xml | 4 +-
pom.xml | 2 +-
49 files changed, 404 insertions(+), 404 deletions(-)
diff --git a/core/pom.xml b/core/pom.xml
index 1c5732c..38b301e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -171,7 +171,7 @@
<build>
<plugins>
-
+
<!-- Publish test artifact -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/ComponentContextBuilder.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/ComponentContextBuilder.java
index 72c7344..e1d2d8c 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/ComponentContextBuilder.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/ComponentContextBuilder.java
@@ -36,36 +36,36 @@ public final class ComponentContextBuilder {
private BundleContext bundleContext;
private Dictionary<String, Object> properties;
private Bundle usingBundle;
-
+
ComponentContextBuilder() {
// constructor package-scope only
}
-
+
public @NotNull ComponentContextBuilder bundleContext(@NotNull BundleContext bundleContext) {
this.bundleContext = bundleContext;
return this;
}
-
+
public @NotNull ComponentContextBuilder properties(@Nullable Dictionary<String, Object> properties) {
this.properties = properties;
return this;
}
-
+
public @NotNull ComponentContextBuilder properties(@Nullable Map<String, Object> properties) {
this.properties = MapUtil.toDictionary(properties);
return this;
}
-
+
public @NotNull ComponentContextBuilder properties(@NotNull Object @NotNull ... properties) {
this.properties = MapUtil.toDictionary(properties);
return this;
}
-
+
public @NotNull ComponentContextBuilder usingBundle(@NotNull Bundle usingBundle) {
this.usingBundle = usingBundle;
return this;
}
-
+
public @NotNull ComponentContext build() {
if (bundleContext == null) {
bundleContext = MockOsgi.newBundleContext();
@@ -75,5 +75,5 @@ public final class ComponentContextBuilder {
}
return new MockComponentContext((MockBundleContext)bundleContext, properties, usingBundle);
}
-
+
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/ManifestScanner.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/ManifestScanner.java
index 5244d26..16814b6 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/ManifestScanner.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/ManifestScanner.java
@@ -38,9 +38,9 @@ import org.slf4j.LoggerFactory;
* Scan METAINF/MANIFEST.MF files.
*/
public final class ManifestScanner {
-
+
private static final Logger log = LoggerFactory.getLogger(ManifestScanner.class);
-
+
private ManifestScanner() {
// static methods only
}
@@ -88,7 +88,7 @@ public final class ManifestScanner {
catch (IOException ex) {
log.warn("Unable to read JAR manifests.", ex);
}
- return values;
+ return values;
}
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MapMergeUtil.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MapMergeUtil.java
index d2f71d5..3201921 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MapMergeUtil.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MapMergeUtil.java
@@ -38,7 +38,7 @@ final class MapMergeUtil {
private MapMergeUtil() {
// static methods only
}
-
+
/**
* Merge service properties from three sources (with this precedence):
* 1. Properties defined in calling unit test code
@@ -49,12 +49,12 @@ final class MapMergeUtil {
* @param properties Properties from unit test code or null if none where passed
* @return Merged properties
*/
- static Dictionary<String, Object> propertiesMergeWithOsgiMetadata(Object target,
- ConfigurationAdmin configAdmin,
+ static Dictionary<String, Object> propertiesMergeWithOsgiMetadata(Object target,
+ ConfigurationAdmin configAdmin,
Dictionary<String, Object> properties) {
return toDictionary(propertiesMergeWithOsgiMetadata(target, configAdmin, toMap(properties)));
}
-
+
/**
* Merge service properties from three sources (with this precedence):
* 1. Properties defined in calling unit test code
@@ -69,7 +69,7 @@ final class MapMergeUtil {
ConfigurationAdmin configAdmin,
Map<String, Object> properties) {
Map<String, Object> mergedProperties = new HashMap<String, Object>();
-
+
OsgiMetadata metadata = OsgiMetadataUtil.getMetadata(target.getClass());
if (metadata != null) {
Map<String,Object> metadataProperties = metadata.getProperties();
@@ -92,13 +92,13 @@ final class MapMergeUtil {
}
}
}
-
+
// merge with properties from calling unit test code
if (properties != null) {
mergedProperties.putAll(properties);
}
-
+
return mergedProperties;
}
-
+
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
index 000d13c..fbf27a5 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MapUtil.java
@@ -33,7 +33,7 @@ import org.jetbrains.annotations.Nullable;
* Map util methods.
*/
public final class MapUtil {
-
+
private MapUtil() {
// static methods only
}
@@ -86,7 +86,7 @@ public final class MapUtil {
public static @Nullable Dictionary<String, Object> toDictionary(@NotNull Object @NotNull ... args) {
return toDictionary(toMap(args));
}
-
+
/**
* Convert key/value pairs to map
* @param args Key/value pairs
@@ -118,5 +118,5 @@ public final class MapUtil {
}
return result;
}
-
+
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
index 16d037c..5e36191 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundle.java
@@ -80,7 +80,7 @@ public final class MockBundle implements Bundle {
@Override
public URL getEntry(final String name) {
-
+
String nameToQuery = name.startsWith("/") ? name : "/" + name;
return getClass().getResource(nameToQuery);
@@ -101,7 +101,7 @@ public final class MockBundle implements Bundle {
// localziation not supported, always return default headers
return getHeaders();
}
-
+
/**
* Set headers for mock bundle
* @param value Header map
@@ -127,27 +127,27 @@ public final class MockBundle implements Bundle {
public long getLastModified() {
return lastModified;
}
-
+
/**
- * Set the last modified value for the mock bundle
+ * Set the last modified value for the mock bundle
* @param lastModified last modified
*/
public void setLastModified(long lastModified) {
this.lastModified = lastModified;
}
-
+
@Override
public Enumeration<String> getEntryPaths(final String path) {
-
+
String queryPath = path.startsWith("/") ? path : "/" + path;
-
+
URL res = getClass().getResource(queryPath);
if ( res == null ) {
return null;
}
-
+
Vector<String> matching = new Vector<String>();
-
+
try {
File file = new File(res.toURI());
if ( file.isDirectory()) {
@@ -161,29 +161,29 @@ public final class MockBundle implements Bundle {
} catch ( RuntimeException e) {
throw new RuntimeException("Failed opening file from " + res , e);
}
-
+
if ( matching.isEmpty() ) {
return null;
}
-
+
return matching.elements();
}
private String relativeWithTrailingSlash(String queryPath) {
-
+
// make relative
if ( queryPath.startsWith("/")) {
queryPath = queryPath.substring(1, queryPath.length());
}
-
+
// remove trailing slash
if ( !queryPath.isEmpty() && !queryPath.endsWith("/") ) {
queryPath = queryPath +"/";
}
-
+
return queryPath;
}
-
+
@Override
public String getLocation() {
if (bundleId == Constants.SYSTEM_BUNDLE_ID) {
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
index 9900d6d..5c48ad4 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java
@@ -73,13 +73,13 @@ class MockBundleContext implements BundleContext {
private final Queue<BundleListener> bundleListeners = new ConcurrentLinkedQueue<BundleListener>();
private final ConfigurationAdmin configAdmin = new MockConfigurationAdmin(this);
private File dataFileBaseDir;
-
+
private final Bundle systemBundle;
public MockBundleContext() {
this.systemBundle = new MockBundle(this, Constants.SYSTEM_BUNDLE_ID);
this.bundle = new MockBundle(this);
-
+
// register configuration admin by default
registerService(ConfigurationAdmin.class.getName(), configAdmin, null);
}
@@ -127,20 +127,20 @@ class MockBundleContext implements BundleContext {
notifyServiceListeners(ServiceEvent.REGISTERED, registration.getReference());
return registration;
}
-
+
@SuppressWarnings("unchecked")
@Override
public <S> ServiceRegistration<S> registerService(Class<S> clazz, ServiceFactory<S> factory, Dictionary<String, ?> properties) {
return registerService(clazz.getName(), factory, properties);
}
-
+
/**
* Check for already registered services that may be affected by the service registration - either
* adding by additional optional references, or creating a conflict in the dependencies.
* @param registration
*/
private void handleRefsUpdateOnRegister(MockServiceRegistration registration) {
-
+
// handle DYNAMIC references to this registration
List<ReferenceInfo> affectedDynamicReferences = OsgiServiceUtil.getMatchingDynamicReferences(registeredServices, registration);
for (ReferenceInfo referenceInfo : affectedDynamicReferences) {
@@ -185,23 +185,23 @@ class MockBundleContext implements BundleContext {
}
}
}
-
+
void unregisterService(MockServiceRegistration registration) {
this.registeredServices.remove(registration);
handleRefsUpdateOnUnregister(registration);
notifyServiceListeners(ServiceEvent.UNREGISTERING, registration.getReference());
}
-
+
@SuppressWarnings({ "unchecked", "null" })
void restartService(MockServiceRegistration registration) {
// get current service properties
Class<?> serviceClass = registration.getService().getClass();
Map<String,Object> properties = MapUtil.toMap(registration.getProperties());
-
+
// deactivate & unregister service
MockOsgi.deactivate(registration.getService(), this);
unregisterService(registration);
-
+
// newly create and register service
Object newService;
try {
@@ -215,7 +215,7 @@ class MockBundleContext implements BundleContext {
}
MockOsgi.injectServices(newService, this);
MockOsgi.activate(newService, this, properties);
-
+
String[] serviceInterfaces = (String[])registration.getClasses().toArray(new String[registration.getClasses().size()]);
registerService(serviceInterfaces, newService, MapUtil.toDictionary(properties));
}
@@ -263,7 +263,7 @@ class MockBundleContext implements BundleContext {
}
}
}
-
+
@SuppressWarnings("unchecked")
@Override
public ServiceReference getServiceReference(final String clazz) {
@@ -414,7 +414,7 @@ class MockBundleContext implements BundleContext {
// no mock implementation, simulate that no property is found and return null
return null;
}
-
+
@Override
public File getDataFile(final String path) {
if (path == null) {
@@ -429,7 +429,7 @@ class MockBundleContext implements BundleContext {
}
}
}
- if (path.isEmpty()) {
+ if (path.isEmpty()) {
return dataFileBaseDir;
}
else {
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockComponentContext.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockComponentContext.java
index a240ea9..98c150d 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockComponentContext.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockComponentContext.java
@@ -35,7 +35,7 @@ class MockComponentContext implements ComponentContext {
private final Dictionary<String, Object> properties;
private final Bundle usingBundle;
- public MockComponentContext(final MockBundleContext mockBundleContext,
+ public MockComponentContext(final MockBundleContext mockBundleContext,
final Dictionary<String, Object> properties, final Bundle usingBundle) {
this.bundleContext = mockBundleContext;
this.properties = properties;
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockConfiguration.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockConfiguration.java
index cfc249c..62e6322 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockConfiguration.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockConfiguration.java
@@ -31,10 +31,10 @@ import org.osgi.service.cm.Configuration;
* Mock implementation of {@link Configuration}.
*/
class MockConfiguration implements Configuration {
-
+
private final String pid;
private Dictionary<String, Object> props;
-
+
/**
* @param pid PID
*/
@@ -74,7 +74,7 @@ class MockConfiguration implements Configuration {
// just clear the props map
props = newConfig(pid);
}
-
+
@Override
public String toString() {
return props.toString();
@@ -87,7 +87,7 @@ class MockConfiguration implements Configuration {
}
// --- unsupported operations ---
-
+
@Override
public void setBundleLocation(String bundleLocation) {
throw new UnsupportedOperationException();
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
index fa16f44..65594f4 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockEventAdmin.java
@@ -44,20 +44,20 @@ import org.slf4j.LoggerFactory;
/**
* Mock implementation of {@link EventAdmin}.
- * From {@link EventConstants} currently only {@link EventConstants#EVENT_TOPIC} is supported.
+ * From {@link EventConstants} currently only {@link EventConstants#EVENT_TOPIC} is supported.
*/
@Component(immediate = true, service = EventAdmin.class)
public final class MockEventAdmin implements EventAdmin {
-
+
@Reference(name="eventHandler", service=EventHandler.class,
cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC,
bind="bindEventHandler", unbind="unbindEventHandler")
private final Map<Object, EventHandlerItem> eventHandlers = new TreeMap<Object, EventHandlerItem>();
private ExecutorService asyncHandler;
-
+
private static final Logger log = LoggerFactory.getLogger(MockEventAdmin.class);
-
+
@Activate
protected void activate(ComponentContext componentContext) {
asyncHandler = Executors.newCachedThreadPool();
@@ -88,7 +88,7 @@ public final class MockEventAdmin implements EventAdmin {
public void sendEvent(final Event event) {
distributeEvent(event);
}
-
+
private void distributeEvent(Event event) {
synchronized (eventHandlers) {
for (EventHandlerItem item : eventHandlers.values()) {
@@ -103,7 +103,7 @@ public final class MockEventAdmin implements EventAdmin {
}
}
}
-
+
protected void bindEventHandler(EventHandler eventHandler, Map<String, Object> props) {
synchronized (eventHandlers) {
eventHandlers.put(ServiceUtil.getComparableForServiceRanking(props, Order.DESCENDING), new EventHandlerItem(eventHandler, props));
@@ -115,19 +115,19 @@ public final class MockEventAdmin implements EventAdmin {
eventHandlers.remove(ServiceUtil.getComparableForServiceRanking(props, Order.DESCENDING));
}
}
-
+
private static class EventHandlerItem {
-
+
private final EventHandler eventHandler;
private final Pattern[] topicPatterns;
private static final Pattern WILDCARD_PATTERN = Pattern.compile("[^*]+|(\\*)");
-
+
public EventHandlerItem(EventHandler eventHandler, Map<String, Object> props) {
this.eventHandler = eventHandler;
topicPatterns = generateTopicPatterns(props.get(EventConstants.EVENT_TOPIC));
}
-
+
public boolean matches(Event event) {
if (topicPatterns.length == 0) {
return true;
@@ -142,7 +142,7 @@ public final class MockEventAdmin implements EventAdmin {
}
return false;
}
-
+
public EventHandler getEventHandler() {
return eventHandler;
}
@@ -167,7 +167,7 @@ public final class MockEventAdmin implements EventAdmin {
}
return patterns;
}
-
+
/**
* Converts a wildcard string with * to a regex pattern (from http://stackoverflow.com/questions/24337657/wildcard-matching-in-java)
* @param wildcard
@@ -183,7 +183,7 @@ public final class MockEventAdmin implements EventAdmin {
matcher.appendTail(result);
return Pattern.compile(result.toString());
}
-
+
}
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
index 12766ab..3b868d9 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockOsgi.java
@@ -129,7 +129,7 @@ public final class MockOsgi {
public static @NotNull ComponentContextBuilder componentContext() {
return new ComponentContextBuilder();
}
-
+
/**
* @param loggerContext Context class for logging
* @return Mocked {@link LogService} instance
@@ -276,7 +276,7 @@ public final class MockOsgi {
ComponentContext componentContext = newComponentContext(bundleContext, mergedProperties);
return OsgiServiceUtil.modified(target, componentContext, mergedProperties);
}
-
+
/**
* Simulate configuration modification of service instance. Invokes the @Modified annotated method.
* @param target Service instance.
@@ -287,7 +287,7 @@ public final class MockOsgi {
public static boolean modified(@NotNull Object target, @NotNull BundleContext bundleContext, @NotNull Object @NotNull ... properties) {
return modified(target, bundleContext, toDictionary(properties));
}
-
+
/**
* Set configuration via ConfigurationAdmin service in bundle context for component with given pid.
* @param bundleContext Bundle context
@@ -297,7 +297,7 @@ public final class MockOsgi {
public static void setConfigForPid(@NotNull BundleContext bundleContext, @NotNull String pid, @Nullable Map<String,Object> properties) {
setConfigForPid(bundleContext, pid, toDictionary(properties));
}
-
+
/**
* Set configuration via ConfigurationAdmin service in bundle context for component with given pid.
* @param bundleContext Bundle context
@@ -307,7 +307,7 @@ public final class MockOsgi {
public static void setConfigForPid(@NotNull BundleContext bundleContext, @NotNull String pid, @NotNull Object @NotNull ... properties) {
setConfigForPid(bundleContext, pid, toDictionary(properties));
}
-
+
private static void setConfigForPid(@NotNull BundleContext bundleContext, @NotNull String pid, @Nullable Dictionary<String, Object> properties) {
ConfigurationAdmin configAdmin = getConfigAdmin(bundleContext);
if (configAdmin == null) {
@@ -321,7 +321,7 @@ public final class MockOsgi {
throw new RuntimeException("Unable to update configuration for pid '" + pid + "'.", ex);
}
}
-
+
/**
* Deactivates all bundles registered in the mocked bundle context.
* @param bundleContext Bundle context
@@ -329,7 +329,7 @@ public final class MockOsgi {
public static void shutdown(@NotNull BundleContext bundleContext) {
((MockBundleContext)bundleContext).shutdown();
}
-
+
/**
* Get configuration admin.
* @param bundleContext Bundle context
@@ -342,5 +342,5 @@ public final class MockOsgi {
}
return null;
}
-
+
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceReference.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceReference.java
index ed01402..65a6143 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceReference.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceReference.java
@@ -42,13 +42,13 @@ class MockServiceReference<T> implements ServiceReference<T> {
this.serviceRegistration = serviceRegistration;
this.comparable = buildComparable();
}
-
+
private Comparable<Object> buildComparable() {
Map<String,Object> props = MapUtil.toMap(serviceRegistration.getProperties());
// use ascending order as defined in ServiceReference#compareTo()
return ServiceUtil.getComparableForServiceRanking(props, Order.ASCENDING);
}
-
+
@Override
public Bundle getBundle() {
return this.bundle;
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
index 79b433c..70e52a2 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/MockServiceRegistration.java
@@ -55,7 +55,7 @@ class MockServiceRegistration<T> implements ServiceRegistration<T>, Comparable<M
final Dictionary<String, Object> properties, MockBundleContext bundleContext) {
this.serviceId = ++serviceCounter;
this.clazzes = new HashSet<String>(Arrays.asList(clazzes));
-
+
if (service instanceof ServiceFactory) {
this.service = ((ServiceFactory<T>)service).getService(bundleContext.getBundle(), this);
}
@@ -108,7 +108,7 @@ class MockServiceRegistration<T> implements ServiceRegistration<T>, Comparable<M
return (clazz == null || this.clazzes.contains(clazz))
&& (filter == null || new FilterImpl(filter).match(properties));
}
-
+
Set<String> getClasses() {
return clazzes;
}
@@ -123,7 +123,7 @@ class MockServiceRegistration<T> implements ServiceRegistration<T>, Comparable<M
return this.service;
}
}
-
+
@Override
public boolean equals(Object obj) {
if (!(obj instanceof MockServiceRegistration)) {
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java
index fee6e7b..85bd6a4 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiMetadataUtil.java
@@ -66,7 +66,7 @@ import org.xml.sax.SAXException;
final class OsgiMetadataUtil {
private static final Logger log = LoggerFactory.getLogger(OsgiMetadataUtil.class);
-
+
private static final String METADATA_PATH = "OSGI-INF";
private static final String METADATA_METATYPE_PATH = "OSGI-INF/metatype/";
@@ -87,7 +87,7 @@ final class OsgiMetadataUtil {
}
private static final OsgiMetadata NULL_METADATA = new OsgiMetadata();
-
+
private static final NamespaceContext NAMESPACE_CONTEXT = new NamespaceContext() {
@Override
public String getNamespaceURI(String prefix) {
@@ -115,7 +115,7 @@ final class OsgiMetadataUtil {
private OsgiMetadataUtil() {
// static methods only
}
-
+
/**
* Try to read OSGI-metadata from /OSGI-INF and read all implemented interfaces and service properties.
* The metadata is cached after initial read, so it's no problem to call this method multiple time for the same class.
@@ -137,14 +137,14 @@ final class OsgiMetadataUtil {
return metadata;
}
}
-
+
/**
* Reads all SCR metadata XML documents located at OSGI-INF/ and caches them with quick access by implementation class.
* @return Cache map
*/
private static Map<String,Document> initMetadataDocumentCache() {
Map<String,Document> cacheMap = new HashMap<>();
-
+
XPath xpath = XPATH_FACTORY.newXPath();
xpath.setNamespaceContext(NAMESPACE_CONTEXT);
XPathExpression xpathExpression;
@@ -159,16 +159,16 @@ final class OsgiMetadataUtil {
Reflections reflections = new Reflections(METADATA_PATH, new ResourcesScanner());
Pattern xmlFilesPattern = Pattern.compile("^.*\\.xml$");
Set<String> paths = reflections.getResources(xmlFilesPattern);
-
+
// filter out OSGi metatype files and parse all found XML documents
Pattern metatypeFilesPattern = Pattern.compile("^" + Pattern.quote(METADATA_METATYPE_PATH )+ ".*$");
paths.stream()
.filter(path -> !metatypeFilesPattern.matcher(path).matches())
.forEach(path -> parseMetadataDocuments(cacheMap, path, xpathExpression));
-
+
return cacheMap;
}
-
+
private static void parseMetadataDocuments(Map<String,Document> cacheMap, String resourcePath, XPathExpression xpathExpression) {
try {
Enumeration<URL> resourceUrls = OsgiMetadataUtil.class.getClassLoader().getResources(resourcePath);
@@ -183,7 +183,7 @@ final class OsgiMetadataUtil {
log.warn("Error reading SCR metadata XML document from " + resourcePath, ex);
}
}
-
+
private static void parseMetadataDocument(Map<String,Document> cacheMap, String resourcePath,
InputStream fileStream, XPathExpression xpathExpression) throws XPathExpressionException {
Document metadata = toXmlDocument(fileStream, resourcePath);
@@ -196,7 +196,7 @@ final class OsgiMetadataUtil {
cacheMap.put(implementationClass, metadata);
}
}
- }
+ }
}
private static String getImplementationClassName(Node componentNode) {
@@ -233,7 +233,7 @@ final class OsgiMetadataUtil {
}
}
}
-
+
/**
* @param clazz OSGi component
* @return XPath query fragment to find matching XML node in SCR metadata
@@ -242,7 +242,7 @@ final class OsgiMetadataUtil {
String className = cleanupClassName(clazz.getName());
return "//*[implementation/@class='" + className + "' or @name='" + className + "']";
}
-
+
/**
* Remove extensions from class names added e.g. by mockito.
* @param className Class name
@@ -251,7 +251,7 @@ final class OsgiMetadataUtil {
public static final String cleanupClassName(String className) {
return StringUtils.substringBefore(StringUtils.substringBefore(className, "$MockitoMock$"), "$$Enhancer");
}
-
+
private static String getComponentName(Class clazz, Document metadata) {
String query = getComponentXPathQuery(clazz);
NodeList nodes = queryNodes(metadata, query);
@@ -420,11 +420,11 @@ final class OsgiMetadataUtil {
public Class<?> getServiceClass() {
return clazz;
}
-
+
public String getName() {
return name;
}
-
+
public String getPID() {
String pid = null;
if (properties != null) {
@@ -540,7 +540,7 @@ final class OsgiMetadataUtil {
public ReferenceCardinality getCardinality() {
return this.cardinality;
}
-
+
public boolean isCardinalityMultiple() {
return this.cardinality == ReferenceCardinality.OPTIONAL_MULTIPLE
|| this.cardinality == ReferenceCardinality.MANDATORY_MULTIPLE;
@@ -570,18 +570,18 @@ final class OsgiMetadataUtil {
public String getField() {
return this.field;
}
-
+
public String getTarget() {
return this.target;
}
-
+
public boolean matchesTargetFilter(ServiceReference<?> serviceReference) {
if (targetFilter == null) {
return true;
}
return targetFilter.match(serviceReference);
}
-
+
public FieldCollectionType getFieldCollectionType() {
return this.fieldCollectionType;
}
@@ -758,8 +758,8 @@ final class OsgiMetadataUtil {
PROPERTIES,
/**
- * An unmodifiable Map.Entry whose key is an unmodifiable Map containing the
- * service properties of the bound service, as above, and whose value is the
+ * An unmodifiable Map.Entry whose key is an unmodifiable Map containing the
+ * service properties of the bound service, as above, and whose value is the
* bound service object. This Map.Entry must implement Comparable.
*/
TUPLE;
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
index 8adb41b..59e4234 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtil.java
@@ -86,15 +86,15 @@ final class OsgiServiceUtil {
}
// try to find matching activate/deactivate method and execute it
- if (invokeLifecycleMethod(target, targetClass, methodName, !activate,
+ if (invokeLifecycleMethod(target, targetClass, methodName, !activate,
componentContext, MapUtil.toMap(componentContext.getProperties()))) {
return true;
}
-
+
if (fallbackDefaultName) {
return false;
}
-
+
throw new RuntimeException("No matching " + (activate ? "activation" : "deactivation") + " method with name '" + methodName + "' "
+ " found in class " + targetClass.getName());
}
@@ -117,7 +117,7 @@ final class OsgiServiceUtil {
if (StringUtils.isEmpty(methodName)) {
return false;
}
-
+
// try to find matching modified method and execute it
if (invokeLifecycleMethod(target, targetClass, methodName, false, componentContext, properties)) {
return true;
@@ -126,7 +126,7 @@ final class OsgiServiceUtil {
throw new RuntimeException("No matching modified method with name '" + methodName + "' "
+ " found in class " + targetClass.getName());
}
-
+
/**
* Invokes a lifecycle method (activation, deactivation or modified) with variable method arguments.
* @param target Target object
@@ -137,7 +137,7 @@ final class OsgiServiceUtil {
* @param properties Component properties
* @return true if a method was found and invoked
*/
- private static boolean invokeLifecycleMethod(Object target, Class<?> targetClass,
+ private static boolean invokeLifecycleMethod(Object target, Class<?> targetClass,
String methodName, boolean allowIntegerArgument,
ComponentContext componentContext, Map<String,Object> properties) {
@@ -147,30 +147,30 @@ final class OsgiServiceUtil {
invokeMethod(target, method, new Object[] { componentContext });
return true;
}
-
+
// 2. bundleContext
method = getMethod(targetClass, methodName, new Class<?>[] { BundleContext.class });
if (method != null) {
invokeMethod(target, method, new Object[] { componentContext.getBundleContext() });
return true;
}
-
+
// 3. map
method = getMethod(targetClass, methodName, new Class<?>[] { Map.class });
if (method != null) {
invokeMethod(target, method, new Object[] { MapUtil.toMap(componentContext.getProperties()) });
return true;
}
-
+
// 4. Component property type (annotation lass)
method = getMethod(targetClass, methodName, new Class<?>[] { Annotation.class });
if (method != null) {
invokeMethod(target, method, new Object[] { Annotations.toObject(method.getParameterTypes()[0],
- MapUtil.toMap(componentContext.getProperties()),
+ MapUtil.toMap(componentContext.getProperties()),
componentContext.getBundleContext().getBundle(), false) });
return true;
}
-
+
// 5. int (deactivation only)
if (allowIntegerArgument) {
method = getMethod(targetClass, methodName, new Class<?>[] { int.class });
@@ -179,7 +179,7 @@ final class OsgiServiceUtil {
return true;
}
}
-
+
// 6. Integer (deactivation only)
if (allowIntegerArgument) {
method = getMethod(targetClass, methodName, new Class<?>[] { Integer.class });
@@ -188,7 +188,7 @@ final class OsgiServiceUtil {
return true;
}
}
-
+
// 7. mixed arguments
Class<?>[] mixedArgsAllowed = allowIntegerArgument ?
new Class<?>[] { ComponentContext.class, BundleContext.class, Map.class, Annotation.class, int.class, Integer.class }
@@ -208,7 +208,7 @@ final class OsgiServiceUtil {
}
else if (method.getParameterTypes()[i].isAnnotation()) {
args[i] = Annotations.toObject(method.getParameterTypes()[i],
- MapUtil.toMap(componentContext.getProperties()),
+ MapUtil.toMap(componentContext.getProperties()),
componentContext.getBundleContext().getBundle(), false);
}
else if (method.getParameterTypes()[i] == int.class || method.getParameterTypes()[i] == Integer.class) {
@@ -224,8 +224,8 @@ final class OsgiServiceUtil {
if (method != null) {
invokeMethod(target, method, new Object[0]);
return true;
- }
-
+ }
+
return false;
}
@@ -235,7 +235,7 @@ final class OsgiServiceUtil {
if (StringUtils.equals(method.getName(), methodName) && method.getParameterTypes().length==types.length) {
boolean foundMismatch = false;
for (int i=0; i<types.length; i++) {
- if (!((method.getParameterTypes()[i]==types[i])
+ if (!((method.getParameterTypes()[i]==types[i])
|| (types[i]==Annotation.class && method.getParameterTypes()[i].isAnnotation()))) {
foundMismatch = true;
break;
@@ -253,7 +253,7 @@ final class OsgiServiceUtil {
}
return null;
}
-
+
private static Method getMethodWithAssignableTypes(Class clazz, String methodName, Class<?>[] types) {
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
@@ -277,7 +277,7 @@ final class OsgiServiceUtil {
}
return null;
}
-
+
private static Method getMethodWithAnyCombinationArgs(Class clazz, String methodName, Class<?>[] types) {
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
@@ -286,7 +286,7 @@ final class OsgiServiceUtil {
for (Class<?> parameterType : method.getParameterTypes()) {
boolean foundAnyMatch = false;
for (int i=0; i<types.length; i++) {
- if ((parameterType==types[i])
+ if ((parameterType==types[i])
|| (types[i]==Annotation.class && parameterType.isAnnotation())) {
foundAnyMatch = true;
break;
@@ -309,7 +309,7 @@ final class OsgiServiceUtil {
}
return null;
}
-
+
private static void invokeMethod(Object target, Method method, Object[] args) {
try {
method.setAccessible(true);
@@ -340,7 +340,7 @@ final class OsgiServiceUtil {
}
return null;
}
-
+
private static Field getFieldWithAssignableType(Class clazz, String fieldName, Class<?> type) {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
@@ -383,7 +383,7 @@ final class OsgiServiceUtil {
+ target.getClass().getName(), ex);
}
}
-
+
/**
* Simulate OSGi service dependency injection. Injects direct references and
* multiple references.
@@ -435,7 +435,7 @@ final class OsgiServiceUtil {
throw new ReferenceViolationException("Unable to inject mandatory reference '" + reference.getName() + "' for class " + targetClass.getName() + " : no matching services were found.");
}
if (reference.isCardinalityMultiple()) {
- // make sure at least empty array is set
+ // make sure at least empty array is set
invokeBindUnbindMethod(reference, target, null, true);
}
}
@@ -450,28 +450,28 @@ final class OsgiServiceUtil {
invokeBindUnbindMethod(reference, target, matchingService, true);
}
}
-
+
private static void invokeBindUnbindMethod(Reference reference, Object target, ServiceInfo serviceInfo, boolean bind) {
Class<?> targetClass = target.getClass();
// try to invoke bind method
String methodName = bind ? reference.getBind() : reference.getUnbind();
String fieldName = reference.getField();
-
+
if (StringUtils.isEmpty(methodName) && StringUtils.isEmpty(fieldName)) {
throw new RuntimeException("No bind/unbind method name or file name defined "
+ "for reference '" + reference.getName() + "' for class " + targetClass.getName());
}
if (StringUtils.isNotEmpty(methodName) && serviceInfo != null) {
-
+
// 1. ServiceReference
Method method = getMethod(targetClass, methodName, new Class<?>[] { ServiceReference.class });
if (method != null) {
invokeMethod(target, method, new Object[] { serviceInfo.getServiceReference() });
return;
}
-
+
// 2. assignable from service instance
Class<?> interfaceType = reference.getInterfaceTypeAsClass();
method = getMethodWithAssignableTypes(targetClass, methodName, new Class<?>[] { interfaceType });
@@ -479,7 +479,7 @@ final class OsgiServiceUtil {
invokeMethod(target, method, new Object[] { serviceInfo.getServiceInstance() });
return;
}
-
+
// 3. assignable from service instance plus map
method = getMethodWithAssignableTypes(targetClass, methodName, new Class<?>[] { interfaceType, Map.class });
if (method != null) {
@@ -497,10 +497,10 @@ final class OsgiServiceUtil {
throw new RuntimeException((bind ? "Bind" : "Unbind") + " method with name " + methodName + " not found "
+ "for reference '" + reference.getName() + "' for class " + targetClass.getName());
}
-
+
// in OSGi declarative services 1.3 there are no bind/unbind methods - modify the field directly
else if (StringUtils.isNotEmpty(fieldName)) {
-
+
// check for field with list/collection reference
if (reference.isCardinalityMultiple()) {
switch (reference.getFieldCollectionType()) {
@@ -529,7 +529,7 @@ final class OsgiServiceUtil {
+ "for reference '" + reference.getName() + "' for class " + targetClass.getName());
}
}
-
+
// check for single field reference
else {
// 1. assignable from service instance
@@ -539,7 +539,7 @@ final class OsgiServiceUtil {
setField(target, field, bind && serviceInfo != null ? serviceInfo.getServiceInstance() : null);
return;
}
-
+
// 2. ServiceReference
field = getField(targetClass, fieldName, ServiceReference.class);
if (field != null) {
@@ -550,7 +550,7 @@ final class OsgiServiceUtil {
}
}
-
+
@SuppressWarnings("unchecked")
private static void addToCollection(Object target, Field field, Object item) {
try {
@@ -563,7 +563,7 @@ final class OsgiServiceUtil {
collection.add(item);
}
field.set(target, collection);
-
+
} catch (IllegalAccessException | IllegalArgumentException | InstantiationException ex) {
throw new RuntimeException("Unable to set field '" + field.getName() + "' for class "
+ target.getClass().getName(), ex);
@@ -582,7 +582,7 @@ final class OsgiServiceUtil {
collection.remove(item);
}
field.set(target, collection);
-
+
} catch (IllegalAccessException | IllegalArgumentException | InstantiationException ex) {
throw new RuntimeException("Unable to set field '" + field.getName() + "' for class "
+ target.getClass().getName(), ex);
@@ -613,7 +613,7 @@ final class OsgiServiceUtil {
public static void invokeBindMethod(Reference reference, Object target, ServiceInfo serviceInfo) {
invokeBindUnbindMethod(reference, target, serviceInfo, true);
}
-
+
/**
* Directly invoke unbind method on service for the given reference.
* @param reference Reference metadata
@@ -623,7 +623,7 @@ final class OsgiServiceUtil {
public static void invokeUnbindMethod(Reference reference, Object target, ServiceInfo serviceInfo) {
invokeBindUnbindMethod(reference, target, serviceInfo, false);
}
-
+
private static List<ServiceInfo> getMatchingServices(Class<?> type, BundleContext bundleContext, String filter) {
List<ServiceInfo> matchingServices = new ArrayList<ServiceInfo>();
try {
@@ -671,7 +671,7 @@ final class OsgiServiceUtil {
}
return references;
}
-
+
/**
* Collects all references of any registered service that match with any of the exported interfaces of the given service registration
* and are defined as STATIC + GREEDY.
@@ -698,7 +698,7 @@ final class OsgiServiceUtil {
}
return references;
}
-
+
static class ServiceInfo {
private final Object serviceInstance;
@@ -736,7 +736,7 @@ final class OsgiServiceUtil {
private final MockServiceRegistration serviceRegistration;
private final Reference reference;
-
+
public ReferenceInfo(MockServiceRegistration serviceRegistration, Reference reference) {
this.serviceRegistration = serviceRegistration;
this.reference = reference;
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/AbstractContextPlugin.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/AbstractContextPlugin.java
index 50d20a6..8d70595 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/AbstractContextPlugin.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/AbstractContextPlugin.java
@@ -47,5 +47,5 @@ public abstract class AbstractContextPlugin<T extends OsgiContextImpl> implement
public void afterTearDown(@NotNull T context) throws Exception {
// can be overridden by subclasses
}
-
+
}
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugins.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugins.java
index f341819..45e79b1 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugins.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/ContextPlugins.java
@@ -30,7 +30,7 @@ import org.osgi.annotation.versioning.ProviderType;
*/
@ProviderType
public final class ContextPlugins {
-
+
private final @NotNull List<ContextPlugin<? extends OsgiContextImpl>> plugins = new ArrayList<>();
/**
@@ -39,7 +39,7 @@ public final class ContextPlugins {
public ContextPlugins() {
// empty list
}
-
+
/**
* Start with some callbacks.
* @param <T> context type
@@ -48,7 +48,7 @@ public final class ContextPlugins {
public <T extends OsgiContextImpl> ContextPlugins(@NotNull final ContextCallback<T> afterSetUpCallback) {
addAfterSetUpCallback(afterSetUpCallback);
}
-
+
/**
* Start with some callbacks.
* @param <U> context type
@@ -57,12 +57,12 @@ public final class ContextPlugins {
* @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> ContextPlugins(
- @NotNull final ContextCallback<U> afterSetUpCallback,
+ @NotNull final ContextCallback<U> afterSetUpCallback,
@NotNull final ContextCallback<V> beforeTearDownCallback) {
addAfterSetUpCallback(afterSetUpCallback);
addBeforeTearDownCallback(beforeTearDownCallback);
}
-
+
/**
* Add plugin
* @param <T> context type
@@ -78,7 +78,7 @@ public final class ContextPlugins {
plugins.add(item);
}
}
-
+
/**
* Add callback
* @param <T> context type
@@ -103,7 +103,7 @@ public final class ContextPlugins {
});
}
}
-
+
/**
* Add callback
* @param <T> context type
@@ -128,7 +128,7 @@ public final class ContextPlugins {
});
}
}
-
+
/**
* Add callback
* @param <T> context type
@@ -153,7 +153,7 @@ public final class ContextPlugins {
});
}
}
-
+
/**
* Add callback
* @param <T> context type
@@ -178,14 +178,14 @@ public final class ContextPlugins {
});
}
}
-
+
/**
* @return All plugins
*/
public @NotNull Collection<ContextPlugin<? extends OsgiContextImpl>> getPlugins() {
return plugins;
}
-
+
/**
* Execute all before setup callbacks.
* @param <T> context type
diff --git a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
index e21e846..0314430 100644
--- a/core/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
+++ b/core/src/main/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImpl.java
@@ -48,7 +48,7 @@ public class OsgiContextImpl {
protected void setUp() {
registerDefaultServices();
}
-
+
/**
* Teardown actions after test method execution
*/
@@ -67,7 +67,7 @@ public class OsgiContextImpl {
private void registerDefaultServices() {
registerInjectActivateService(new MockEventAdmin());
}
-
+
/**
* @return OSGi component context
*/
@@ -131,7 +131,7 @@ public class OsgiContextImpl {
public final @NotNull <T> T registerService(@Nullable final Class<T> serviceClass, @NotNull final T service, @NotNull final Object @NotNull ... properties) {
return registerService(serviceClass, service, MapUtil.toMap(properties));
}
-
+
/**
* Injects dependencies, activates and registers a service in the mocked
* OSGi environment.
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MapUtilTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MapUtilTest.java
index 369abdf..6631414 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MapUtilTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MapUtilTest.java
@@ -32,26 +32,26 @@ public class MapUtilTest {
@Test
public void testMapDictionary() {
Map<String,Object> map = ImmutableMap.<String, Object>of("param1", "var1", "param2", 123, "param3", true);
-
+
Dictionary<String, Object> dict = MapUtil.toDictionary(map);
Map<String,Object> convertedMap = MapUtil.toMap(dict);
-
+
assertEquals(map, convertedMap);
}
-
+
@Test
public void testMapObjectVarargs() {
Map<String, Object> convertedMap = MapUtil.toMap("param1", "var1", "param2", 123, "param3", true);
-
+
assertEquals(ImmutableMap.<String, Object>of("param1", "var1", "param2", 123, "param3", true), convertedMap);
}
-
+
@Test
public void testDictionaryObjectVarargs() {
Dictionary<String, Object> dict = MapUtil.toDictionary("param1", "var1", "param2", 123, "param3", true);
Map<String,Object> convertedMap = MapUtil.toMap(dict);
-
+
assertEquals(ImmutableMap.<String, Object>of("param1", "var1", "param2", 123, "param3", true), convertedMap);
}
-
+
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
index a5da281..79f2a99 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesOsgiR6Test.java
@@ -46,7 +46,7 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
private Service3OsgiR6 service;
private ServiceRegistration reg1a;
private ServiceRegistration reg2a;
-
+
@Mock
private ServiceInterface1 dependency1a;
@Mock
@@ -69,16 +69,16 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
@Before
public void setUp() {
bundleContext = MockOsgi.newBundleContext();
-
+
// setup service instance with only minimum mandatory references
reg1a = bundleContext.registerService(ServiceInterface1.class.getName(), dependency1a, null);
reg2a = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2a, null);
-
+
service = new Service3OsgiR6();
MockOsgi.injectServices(service, bundleContext);
MockOsgi.activate(service, bundleContext);
bundleContext.registerService(Service3OsgiR6.class.getName(), service, MapUtil.toDictionary(ImmutableMap.<String,Object>of("reference3DynamicFiltered.target","(prop1=def)")));
-
+
assertDependency1(dependency1a);
assertDependency1Optional(null);
assertDependencies2(dependency2a);
@@ -89,32 +89,32 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
public void testAddRemoveOptionalUnaryService() {
ServiceRegistration reg1aOptional = bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1aOptional, null);
assertDependency1Optional(dependency1aOptional);
-
+
reg1aOptional.unregister();
assertDependency1Optional(null);
}
-
+
public void testAddOptionalUnaryService_TooMany() {
bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1aOptional, null);
assertDependency1Optional(dependency1aOptional);
-
+
// in real OSGi this should fail - but this is not covered by the current implementation. so test the real implementation here.
bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1bOptional, null);
assertDependency1Optional(dependency1bOptional);
}
-
+
@Test
public void testAddMandatoryUnaryService_TooMany() {
// should not throw an exception although mandatory unary reference is already set
bundleContext.registerService(ServiceInterface1.class.getName(), dependency1b, null);
}
-
+
@Test
public void testRemoveMandatoryUnaryService_TooMany() {
// this should check if the mandatory references is no longer set - but this is currently not implemented
reg1a.unregister();
}
-
+
@Test
public void testAddRemoveOptionalMultipleService() {
ServiceRegistration reg3a = bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a, null);
@@ -125,11 +125,11 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
reg3a.unregister();
assertDependencies3(dependency3b);
-
+
reg3b.unregister();
assertDependencies3();
}
-
+
@Test
public void testAddRemoveMandatoryMultipleService() {
ServiceRegistration reg2b = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2b, null);
@@ -137,38 +137,38 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
reg2b.unregister();
assertDependencies2(dependency2a);
-
+
// in real OSGi this should fail - but this is not covered by the current implementation. so test the real implementation here.
reg2a.unregister();
assertDependencies2();
}
-
+
@Test
public void testReferenceWithTargetFilter() {
assertDependencies3Filtered();
-
- bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a,
+
+ bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a,
MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "abc")));
- bundleContext.registerService(ServiceInterface3.class.getName(), dependency3b,
+ bundleContext.registerService(ServiceInterface3.class.getName(), dependency3b,
MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "def")));
-
+
assertDependencies3Filtered(dependency3a);
}
-
+
@Test
public void testReferenceWithDynamicTargetFilter() {
assertDependencies3DynamicFiltered(null);
-
- bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a,
+
+ bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a,
MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "abc")));
- bundleContext.registerService(ServiceInterface3.class.getName(), dependency3b,
+ bundleContext.registerService(ServiceInterface3.class.getName(), dependency3b,
MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "def")));
- bundleContext.registerService(ServiceInterface3.class.getName(), dependency3c,
+ bundleContext.registerService(ServiceInterface3.class.getName(), dependency3c,
MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "hij")));
-
+
assertDependencies3DynamicFiltered(dependency3b);
}
@@ -180,7 +180,7 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
assertSame(instance, service.getReference1());
}
}
-
+
private void assertDependency1Optional(ServiceInterface1Optional instance) {
if (instance == null) {
assertNull(service.getReference1Optional());
@@ -189,19 +189,19 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
assertSame(instance, service.getReference1Optional());
}
}
-
+
private void assertDependencies2(ServiceInterface2... instances) {
- assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
+ assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
ImmutableSet.<ServiceInterface2>copyOf(service.getReferences2()));
}
-
+
private void assertDependencies3(ServiceSuperInterface3... instances) {
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
+ assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3()));
}
-
+
private void assertDependencies3Filtered(ServiceSuperInterface3... instances) {
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
+ assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3Filtered()));
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
index 47b3c0c..b7e6be5 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextDynamicReferencesTest.java
@@ -45,7 +45,7 @@ public class MockBundleContextDynamicReferencesTest {
private Service3 service;
private ServiceRegistration reg1a;
private ServiceRegistration reg2a;
-
+
@Mock
private ServiceInterface1 dependency1a;
@Mock
@@ -66,16 +66,16 @@ public class MockBundleContextDynamicReferencesTest {
@Before
public void setUp() {
bundleContext = MockOsgi.newBundleContext();
-
+
// setup service instance with only minimum mandatory references
reg1a = bundleContext.registerService(ServiceInterface1.class.getName(), dependency1a, null);
reg2a = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2a, null);
-
+
service = new Service3();
MockOsgi.injectServices(service, bundleContext);
MockOsgi.activate(service, bundleContext);
bundleContext.registerService(Service3.class.getName(), service, null);
-
+
assertDependency1(dependency1a);
assertDependency1Optional(null);
assertDependencies2(dependency2a);
@@ -86,32 +86,32 @@ public class MockBundleContextDynamicReferencesTest {
public void testAddRemoveOptionalUnaryService() {
ServiceRegistration reg1aOptional = bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1aOptional, null);
assertDependency1Optional(dependency1aOptional);
-
+
reg1aOptional.unregister();
assertDependency1Optional(null);
}
-
+
public void testAddOptionalUnaryService_TooMany() {
bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1aOptional, null);
assertDependency1Optional(dependency1aOptional);
-
+
// in real OSGi this should fail - but this is not covered by the current implementation. so test the real implementation here.
bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1bOptional, null);
assertDependency1Optional(dependency1bOptional);
}
-
+
@Test
public void testAddMandatoryUnaryService_TooMany() {
// should not throw an exception although mandatory unary reference is already set
bundleContext.registerService(ServiceInterface1.class.getName(), dependency1b, null);
}
-
+
@Test
public void testRemoveMandatoryUnaryService_TooMany() {
// this should check if the mandatory references is no longer set - but this is currently not implemented
reg1a.unregister();
}
-
+
@Test
public void testAddRemoveOptionalMultipleService() {
ServiceRegistration reg3a = bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a, null);
@@ -122,11 +122,11 @@ public class MockBundleContextDynamicReferencesTest {
reg3a.unregister();
assertDependencies3(dependency3b);
-
+
reg3b.unregister();
assertDependencies3();
}
-
+
@Test
public void testAddRemoveMandatoryMultipleService() {
ServiceRegistration reg2b = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2b, null);
@@ -134,12 +134,12 @@ public class MockBundleContextDynamicReferencesTest {
reg2b.unregister();
assertDependencies2(dependency2a);
-
+
// in real OSGi this should fail - but this is not covered by the current implementation. so test the real implementation here.
reg2a.unregister();
assertDependencies2();
}
-
+
private void assertDependency1(ServiceInterface1 instance) {
if (instance == null) {
assertNull(service.getReference1());
@@ -148,7 +148,7 @@ public class MockBundleContextDynamicReferencesTest {
assertSame(instance, service.getReference1());
}
}
-
+
private void assertDependency1Optional(ServiceInterface1Optional instance) {
if (instance == null) {
assertNull(service.getReference1Optional());
@@ -157,15 +157,15 @@ public class MockBundleContextDynamicReferencesTest {
assertSame(instance, service.getReference1Optional());
}
}
-
+
private void assertDependencies2(ServiceInterface2... instances) {
- assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
+ assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
ImmutableSet.<ServiceInterface2>copyOf(service.getReferences2()));
}
-
+
private void assertDependencies3(ServiceSuperInterface3... instances) {
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
+ assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3()));
}
-
+
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
index 117bb27..80c527d 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyReferencesTest.java
@@ -46,7 +46,7 @@ public class MockBundleContextStaticGreedyReferencesTest {
private BundleContext bundleContext;
private ServiceRegistration reg1a;
private ServiceRegistration reg2a;
-
+
@Mock
private ServiceInterface1 dependency1a;
@Mock
@@ -67,16 +67,16 @@ public class MockBundleContextStaticGreedyReferencesTest {
@Before
public void setUp() {
bundleContext = MockOsgi.newBundleContext();
-
+
// setup service instance with only minimum mandatory references
reg1a = bundleContext.registerService(ServiceInterface1.class.getName(), dependency1a, null);
reg2a = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2a, null);
-
+
Service3StaticGreedy service = new Service3StaticGreedyImpl();
MockOsgi.injectServices(service, bundleContext);
MockOsgi.activate(service, bundleContext);
bundleContext.registerService(Service3StaticGreedy.class.getName(), service, null);
-
+
assertDependency1(dependency1a);
assertDependency1Optional(null);
assertDependencies2(dependency2a);
@@ -87,31 +87,31 @@ public class MockBundleContextStaticGreedyReferencesTest {
public void testAddRemoveOptionalUnaryService() {
ServiceRegistration reg1aOptional = bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1aOptional, null);
assertDependency1Optional(dependency1aOptional);
-
+
reg1aOptional.unregister();
assertDependency1Optional(null);
}
-
+
public void testAddOptionalUnaryService_TooMany() {
bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1aOptional, null);
assertDependency1Optional(dependency1aOptional);
-
+
// in real OSGi this should fail - but this is not covered by the current implementation. so test the real implementation here.
bundleContext.registerService(ServiceInterface1Optional.class.getName(), dependency1bOptional, null);
assertDependency1Optional(dependency1bOptional);
}
-
+
@Test
public void testAddMandatoryUnaryService_TooMany() {
// should not throw an exception although mandatory unary reference is already set
bundleContext.registerService(ServiceInterface1.class.getName(), dependency1b, null);
}
-
+
@Test(expected = ReferenceViolationException.class)
public void testRemoveMandatoryUnaryService_TooMany() {
reg1a.unregister();
}
-
+
@Test
public void testAddRemoveOptionalMultipleService() {
ServiceRegistration reg3a = bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a, null);
@@ -122,11 +122,11 @@ public class MockBundleContextStaticGreedyReferencesTest {
reg3a.unregister();
assertDependencies3(dependency3b);
-
+
reg3b.unregister();
assertDependencies3();
}
-
+
@Test
public void testAddRemoveMandatoryMultipleService() {
ServiceRegistration reg2b = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2b, null);
@@ -135,7 +135,7 @@ public class MockBundleContextStaticGreedyReferencesTest {
reg2b.unregister();
assertDependencies2(dependency2a);
}
-
+
@Test(expected = ReferenceViolationException.class)
public void testAddRemoveMandatoryMultipleService_FailReg2aUnregister() {
ServiceRegistration reg2b = bundleContext.registerService(ServiceInterface2.class.getName(), dependency2b, null);
@@ -143,11 +143,11 @@ public class MockBundleContextStaticGreedyReferencesTest {
reg2b.unregister();
assertDependencies2(dependency2a);
-
+
// this should fail
reg2a.unregister();
}
-
+
private void assertDependency1(ServiceInterface1 instance) {
Service3StaticGreedy service = getService();
if (instance == null) {
@@ -157,7 +157,7 @@ public class MockBundleContextStaticGreedyReferencesTest {
assertSame(instance, service.getReference1());
}
}
-
+
private void assertDependency1Optional(ServiceInterface1Optional instance) {
Service3StaticGreedy service = getService();
if (instance == null) {
@@ -167,22 +167,22 @@ public class MockBundleContextStaticGreedyReferencesTest {
assertSame(instance, service.getReference1Optional());
}
}
-
+
private void assertDependencies2(ServiceInterface2... instances) {
Service3StaticGreedy service = getService();
- assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
+ assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
ImmutableSet.<ServiceInterface2>copyOf(service.getReferences2()));
}
-
+
private void assertDependencies3(ServiceSuperInterface3... instances) {
Service3StaticGreedy service =getService();
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
+ assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3()));
}
-
+
private Service3StaticGreedy getService() {
ServiceReference<?> serviceRef = bundleContext.getServiceReference(Service3StaticGreedy.class.getName());
return (Service3StaticGreedy)bundleContext.getService(serviceRef);
}
-
+
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
index 9f9680a..293cd8c 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextTest.java
@@ -127,7 +127,7 @@ public class MockBundleContextTest {
bundleContext.ungetService(refsString[1]);
bundleContext.ungetService(refInteger);
}
-
+
@Test
public void testModifyServiceRegistration() throws InvalidSyntaxException {
// register test services
@@ -139,10 +139,10 @@ public class MockBundleContextTest {
final List<ServiceEvent> events = new ArrayList<>();
final ServiceListener listener = new ServiceListener(){
- @Override
- public void serviceChanged(ServiceEvent event) {
- events.add(event);
- }
+ @Override
+ public void serviceChanged(ServiceEvent event) {
+ events.add(event);
+ }
};
bundleContext.addServiceListener(listener);
ServiceRegistration<String> reg1 = bundleContext.registerService(String.class, service1, properties1);
@@ -158,14 +158,14 @@ public class MockBundleContextTest {
assertEquals(1, events.size());
assertEquals(ServiceEvent.REGISTERED, events.get(0).getType());
assertSame(reg1.getReference(), events.get(0).getServiceReference());
-
+
// update properties
Dictionary<String, Object> properties2 = new Hashtable<>();
properties2.put("a", "1");
properties2.put("c", "3");
reg1.setProperties(properties2);
- // check properties
+ // check properties
assertEquals(4, reg1.getReference().getPropertyKeys().length);
assertNotNull(reg1.getReference().getProperty(Constants.SERVICE_ID));
assertNotNull(reg1.getReference().getProperty(Constants.OBJECTCLASS));
@@ -176,7 +176,7 @@ public class MockBundleContextTest {
assertEquals(2, events.size());
assertEquals(ServiceEvent.MODIFIED, events.get(1).getType());
assertSame(reg1.getReference(), events.get(1).getServiceReference());
-
+
// unregister
reg1.unregister();
@@ -209,7 +209,7 @@ public class MockBundleContextTest {
assertSame(service, bundleContext.getService(ref));
bundleContext.ungetService(ref);
}
-
+
@Test
public void testNoServiceReferences() throws InvalidSyntaxException {
ServiceReference<?>[] refs = bundleContext.getServiceReferences(String.class.getName(), null);
@@ -219,7 +219,7 @@ public class MockBundleContextTest {
assertNotNull(refCol);
assertTrue(refCol.isEmpty());
}
-
+
@Test
public void testServiceUnregistration() {
// prepare test services
@@ -227,14 +227,14 @@ public class MockBundleContextTest {
Object service1 = new Object();
Dictionary<String, Object> properties1 = ranking(null);
ServiceRegistration reg1 = bundleContext.registerService(clazz1, service1, properties1);
-
+
assertNotNull(bundleContext.getServiceReference(clazz1));
reg1.unregister();
assertNull(bundleContext.getServiceReference(clazz1));
}
-
+
@Test
public void testGetBundles() throws Exception {
@@ -281,24 +281,24 @@ public class MockBundleContextTest {
public void testGetProperty() {
assertNull(bundleContext.getProperty("anyProperty"));
}
-
+
@Test
public void testObjectClassFilterMatches() throws InvalidSyntaxException {
-
+
Filter filter = bundleContext.createFilter("(" + Constants.OBJECTCLASS + "=" + Integer.class.getName() + ")");
-
+
ServiceRegistration serviceRegistration = bundleContext.registerService(Integer.class.getName(), Integer.valueOf(1), null);
-
+
assertTrue(filter.match(serviceRegistration.getReference()));
}
@Test
public void testObjectClassFilterDoesNotMatch() throws InvalidSyntaxException {
-
+
Filter filter = bundleContext.createFilter("(" + Constants.OBJECTCLASS + "=" + Integer.class.getName() + ")");
-
+
ServiceRegistration serviceRegistration = bundleContext.registerService(Long.class.getName(), Long.valueOf(1), null);
-
+
assertFalse(filter.match(serviceRegistration.getReference()));
}
@@ -306,10 +306,10 @@ public class MockBundleContextTest {
public void testGetDataFile() {
File rootFile = bundleContext.getDataFile("");
assertNotNull(rootFile);
-
+
File childFile = bundleContext.getDataFile("child");
assertNotNull(childFile);
-
+
assertEquals(childFile.getParentFile(), rootFile);
}
@@ -336,12 +336,12 @@ public class MockBundleContextTest {
bundleContext.registerService(String.class, "service1", ranking(10));
bundleContext.registerService(String.class, "service2", ranking(20));
bundleContext.registerService(String.class, "service3", ranking(5));
-
+
// should return service with highest ranking
ServiceReference<String> ref = bundleContext.getServiceReference(String.class);
String service = bundleContext.getService(ref);
assertEquals("service2", service);
-
+
bundleContext.ungetService(ref);
}
@@ -350,21 +350,21 @@ public class MockBundleContextTest {
bundleContext.registerService(String.class, "service1", ranking(null));
bundleContext.registerService(String.class, "service2", ranking(null));
bundleContext.registerService(String.class, "service3", ranking(null));
-
+
// should return service with lowest service id = which was registered first
ServiceReference<String> ref = bundleContext.getServiceReference(String.class);
String service = bundleContext.getService(ref);
assertEquals("service1", service);
-
+
bundleContext.ungetService(ref);
}
-
+
@Test
public void testGetServicesWithNoClassOnlyFilter() throws InvalidSyntaxException {
bundleContext.registerService(String.class, "service1", testProperty());
bundleContext.registerService(Long.class, new Long(2), testProperty());
bundleContext.registerService(Integer.class, new Integer(9), testProperty());
-
+
// should return service with lowest service id = which was registered first
ServiceReference[] refs = bundleContext.getServiceReferences((String)null, "(prop1=value1)");
assertNotNull(refs);
@@ -378,7 +378,7 @@ public class MockBundleContextTest {
}
return props;
}
-
+
private static Dictionary<String, Object> testProperty() {
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put("prop1", "value1");
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
index c6c7063..633974c 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleTest.java
@@ -84,42 +84,42 @@ public class MockBundleTest {
bundle.setLastModified(42);
assertEquals(42, bundle.getLastModified());
}
-
+
@Test
public void getEntryPaths_noMatches() {
assertNull(bundle.getEntryPaths("resources"));
- }
-
+ }
+
@Test
public void getEntryPaths() {
-
+
Enumeration<String> entryPaths = bundle.getEntryPaths("bundleData");
-
+
List<String> paths = Collections.list(entryPaths);
-
+
assertThat(paths.size(), CoreMatchers.is(1));
assertTrue(paths.contains("bundleData/nested/"));
}
@Test
public void getEntryPaths_leadingSlash() {
-
+
Enumeration<String> entryPaths = bundle.getEntryPaths("bundleData");
-
+
List<String> paths = Collections.list(entryPaths);
-
+
assertThat(paths.size(), CoreMatchers.is(1));
assertTrue(paths.contains("bundleData/nested/"));
}
@Test
public void getEntryPaths_slash() {
-
+
Enumeration<String> entryPaths = bundle.getEntryPaths("/");
-
+
List<String> paths = Collections.list(entryPaths);
-
- // intentionally less precise as we don't want to be broken when e.g. test resources change
+
+ // intentionally less precise as we don't want to be broken when e.g. test resources change
assertTrue(paths.size() >= 2);
assertTrue("Expect OSGI-INF/ in " + paths, paths.contains("OSGI-INF/"));
assertTrue("Expect META-INF/ in " + paths, paths.contains("META-INF/"));
@@ -127,20 +127,20 @@ public class MockBundleTest {
@Test
public void getEntryPaths_empty() {
-
+
Enumeration<String> entryPaths = bundle.getEntryPaths("");
-
+
List<String> paths = Collections.list(entryPaths);
-
- // intentionally less precise as we don't want to be broken when e.g. test resources change
+
+ // intentionally less precise as we don't want to be broken when e.g. test resources change
assertTrue(paths.size() >= 2);
assertTrue("Expect OSGI-INF/ in " + paths, paths.contains("OSGI-INF/"));
assertTrue("Expect META-INF/ in " + paths, paths.contains("META-INF/"));
}
-
+
@Test
public void getEntryPaths_noMatch() {
-
+
assertNull(bundle.getEntryPaths("/EMPTY"));
assertNull(bundle.getEntryPaths("EMPTY"));
}
@@ -149,9 +149,9 @@ public class MockBundleTest {
public void getEntryPaths_Nested() {
Enumeration<String> entryPaths = bundle.getEntryPaths("bundleData/nested");
-
+
List<String> paths = Collections.list(entryPaths);
-
+
assertThat(paths.size(), CoreMatchers.is(2));
assertTrue(paths.contains("bundleData/nested/first.txt"));
assertTrue(paths.contains("bundleData/nested/second.txt"));
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
index 7e5ef2b..ffe5df7 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockComponentContextTest.java
@@ -89,7 +89,7 @@ public class MockComponentContextTest {
public void testGetUsingBundle() {
// test context without using bundle
assertNull(underTest.getUsingBundle());
-
+
// test context with using bundle
Bundle usingBundle = mock(Bundle.class);
ComponentContext contextWithUsingBundle = MockOsgi.componentContext().usingBundle(usingBundle).build();
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
index 145432f..4cb6574 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockConfigurationAdminTest.java
@@ -38,7 +38,7 @@ import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
public class MockConfigurationAdminTest {
-
+
private static final String[] TEST_ADAPTABLES = new String[] {
"adaptable1",
"adaptable2"
@@ -53,12 +53,12 @@ public class MockConfigurationAdminTest {
Constants.SERVICE_RANKING, 3000,
"adaptables", TEST_ADAPTABLES,
"prop2", 2);
-
+
context.registerInjectActivateService(new ServiceWithMetadata(), ImmutableMap.<String, Object>builder()
.put(Constants.SERVICE_RANKING, 4000)
.put("prop1", 1)
.build());
-
+
ServiceReference reference = context.bundleContext().getServiceReference(Comparable.class.getName());
// values passed over when registering service has highest precedence
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
index 74c2b39..4328f2f 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockEventAdminTest.java
@@ -39,24 +39,24 @@ import com.google.common.collect.ImmutableMap;
@SuppressWarnings("null")
public class MockEventAdminTest {
-
+
private static final String TOPIC_SAMPLE_1 = "sample/topic1";
private static final String TOPIC_SAMPLE_2 = "sample/topic2";
private static final String TOPIC_SAMPLE_ALL = "sample/*";
private static final String TOPIC_OTHER_3 = "other/topic3";
-
+
private static final Event EVENT_SAMPLE_1 = new Event(TOPIC_SAMPLE_1, (Dictionary<String,?>)null);
private static final Event EVENT_SAMPLE_2 = new Event(TOPIC_SAMPLE_2, (Dictionary<String,?>)null);
private static final Event EVENT_OTHER_3 = new Event(TOPIC_OTHER_3, (Dictionary<String,?>)null);
-
+
@Rule
public OsgiContext context = new OsgiContext();
-
+
private DummyEventHandler eventHandler1;
private DummyEventHandler eventHandler12;
private DummyEventHandler eventHandlerSampleAll;
private DummyEventHandler eventHandlerAll;
-
+
@Before
public void setUp() {
eventHandler1 = (DummyEventHandler)context.registerService(EventHandler.class, new DummyEventHandler(),
@@ -67,12 +67,12 @@ public class MockEventAdminTest {
ImmutableMap.<String, Object>of(EventConstants.EVENT_TOPIC, TOPIC_SAMPLE_ALL));
eventHandlerAll = (DummyEventHandler)context.registerService(EventHandler.class, new DummyEventHandler());
}
-
+
@Test
public void testSendEvent_Sample1() {
EventAdmin eventAdmin = context.getService(EventAdmin.class);
eventAdmin.sendEvent(EVENT_SAMPLE_1);
-
+
assertEquals(ImmutableList.of(EVENT_SAMPLE_1), eventHandler1.getReceivedEvents());
assertEquals(ImmutableList.of(EVENT_SAMPLE_1), eventHandler12.getReceivedEvents());
assertEquals(ImmutableList.of(EVENT_SAMPLE_1), eventHandlerSampleAll.getReceivedEvents());
@@ -83,7 +83,7 @@ public class MockEventAdminTest {
public void testSendEvent_Sample2() {
EventAdmin eventAdmin = context.getService(EventAdmin.class);
eventAdmin.sendEvent(EVENT_SAMPLE_2);
-
+
assertEquals(ImmutableList.of(), eventHandler1.getReceivedEvents());
assertEquals(ImmutableList.of(EVENT_SAMPLE_2), eventHandler12.getReceivedEvents());
assertEquals(ImmutableList.of(EVENT_SAMPLE_2), eventHandlerSampleAll.getReceivedEvents());
@@ -94,7 +94,7 @@ public class MockEventAdminTest {
public void testSendEvent_Other3() {
EventAdmin eventAdmin = context.getService(EventAdmin.class);
eventAdmin.sendEvent(EVENT_OTHER_3);
-
+
assertEquals(ImmutableList.of(), eventHandler1.getReceivedEvents());
assertEquals(ImmutableList.of(), eventHandler12.getReceivedEvents());
assertEquals(ImmutableList.of(), eventHandlerSampleAll.getReceivedEvents());
@@ -106,7 +106,7 @@ public class MockEventAdminTest {
EventAdmin eventAdmin = context.getService(EventAdmin.class);
eventAdmin.postEvent(EVENT_SAMPLE_2);
eventAdmin.postEvent(EVENT_OTHER_3);
-
+
// wait until result is as expected (with timeout)
boolean expectedResult = false;
while (!expectedResult) {
@@ -118,7 +118,7 @@ public class MockEventAdminTest {
}
private static class DummyEventHandler implements EventHandler {
-
+
private final List<Event> receivedEvents = new ArrayList<Event>();
@Override
@@ -129,7 +129,7 @@ public class MockEventAdminTest {
public List<Event> getReceivedEvents() {
return ImmutableList.copyOf(receivedEvents);
}
-
+
}
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
index d639f66..8e321c3 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockServiceReferencesSortTest.java
@@ -34,12 +34,12 @@ import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-/**
+/**
* Test the service-ranking based sorting of mock service references
*/
@SuppressWarnings("null")
public class MockServiceReferencesSortTest {
-
+
private BundleContext bundleContext;
@Before
@@ -59,7 +59,7 @@ public class MockServiceReferencesSortTest {
registerStringServiceWithRanking("C", 4);
registerStringServiceWithRanking("D", 1);
registerStringServiceWithRanking("E", 2);
-
+
assertEquals("DEACB", getSortedServicesString());
assertEquals("B", bundleContext.getService(bundleContext.getServiceReference(String.class)));
}
@@ -71,7 +71,7 @@ public class MockServiceReferencesSortTest {
registerStringServiceWithoutRanking("C");
registerStringServiceWithoutRanking("D");
registerStringServiceWithoutRanking("E");
-
+
assertEquals("EDCBA", getSortedServicesString());
assertEquals("A", bundleContext.getService(bundleContext.getServiceReference(String.class)));
}
@@ -83,7 +83,7 @@ public class MockServiceReferencesSortTest {
registerStringServiceWithoutRanking("C");
registerStringServiceWithRanking("D", 10);
registerStringServiceWithoutRanking("E");
-
+
assertEquals("ECABD", getSortedServicesString());
assertEquals("D", bundleContext.getService(bundleContext.getServiceReference(String.class)));
}
@@ -97,8 +97,8 @@ public class MockServiceReferencesSortTest {
props.put(Constants.SERVICE_RANKING, new Integer(index));
return bundleContext.registerService(String.class, serviceValue, props);
}
-
- /** Register services with a specific ranking, sort their references and
+
+ /** Register services with a specific ranking, sort their references and
* return their concatenated toString() values.
* Use to test service references sorting.
*/
@@ -112,13 +112,13 @@ public class MockServiceReferencesSortTest {
}
assertNotNull("Expecting our service references", refs);
Arrays.sort(refs);
-
+
final StringBuilder sb = new StringBuilder();
for(ServiceReference<?> ref : refs) {
sb.append(bundleContext.getService(ref).toString());
bundleContext.ungetService(ref);
}
-
+
return sb.toString();
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceRegisterTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceRegisterTest.java
index a206e7b..9405869 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceRegisterTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceRegisterTest.java
@@ -40,7 +40,7 @@ public class OsgiServiceRegisterTest {
@Test
public void testRegisterClassesFromMetadata() {
context.registerInjectActivateService(new Service2());
-
+
assertEquals(1, context.getServices(ServiceInterface2.class, null).length);
assertEquals(1, context.getServices(ServiceInterface3.class, null).length);
}
@@ -78,19 +78,19 @@ public class OsgiServiceRegisterTest {
assertEquals(1, context.getServices(ServiceInterface2.class, null).length);
assertEquals(1, context.getServices(ServiceInterface3.class, null).length);
}
-
+
@Test
@SuppressWarnings("null")
public void testInjectMandatoryUnaryReferenceOutOfMultipleServices() {
context.registerService(ServiceInterface2.class, mock(ServiceInterface2.class));
-
+
ServiceInterface1 service1_ranking100 = mock(ServiceInterface1.class);
context.registerService(ServiceInterface1.class, service1_ranking100, Constants.SERVICE_RANKING, 100);
ServiceInterface1 service1_ranking200 = mock(ServiceInterface1.class);
context.registerService(ServiceInterface1.class, service1_ranking200, Constants.SERVICE_RANKING, 200);
ServiceInterface1 service1_ranking10 = mock(ServiceInterface1.class);
context.registerService(ServiceInterface1.class, service1_ranking10, Constants.SERVICE_RANKING, 10);
-
+
// register service with unary mandatory reference to ServiceInterface1
Service3 service3 = context.registerInjectActivateService(new Service3());
assertSame(service1_ranking200, service3.getReference1());
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java
index d174bf1..0bcaa9a 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilActivateDeactivateTest.java
@@ -42,15 +42,15 @@ public class OsgiServiceUtilActivateDeactivateTest {
"prop2.with.periods", "value2",
"prop3-with-hyphens", "value3");
private BundleContext bundleContext = MockOsgi.newBundleContext();
-
+
@Test
public void testService1() {
Service1 service = new Service1();
-
+
assertTrue(MockOsgi.activate(service, bundleContext, map));
assertTrue(service.isActivated());
assertSame(bundleContext, service.getComponentContext().getBundleContext());
-
+
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
}
@@ -58,11 +58,11 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Test
public void testService2() {
Service2 service = new Service2();
-
+
assertTrue(MockOsgi.activate(service, bundleContext, "prop1", "value1"));
assertTrue(service.isActivated());
assertSame(bundleContext, service.getBundleContext());
-
+
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
}
@@ -70,11 +70,11 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Test
public void testService3() {
Service3 service = new Service3();
-
+
assertTrue(MockOsgi.activate(service, bundleContext, map));
assertTrue(service.isActivated());
assertEquals("value1", service.getMap().get("prop1"));
-
+
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
}
@@ -82,7 +82,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Test
public void testService4() {
Service4 service = new Service4();
-
+
assertTrue(MockOsgi.activate(service, bundleContext, map));
assertTrue(service.isActivated());
assertEquals(map, ImmutableMap.copyOf(service.getMap()));
@@ -94,10 +94,10 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Test
public void testService5() {
Service5 service = new Service5();
-
+
assertTrue(MockOsgi.activate(service, bundleContext, map));
assertTrue(service.isActivated());
-
+
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
}
@@ -105,21 +105,21 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Test
public void testService6() {
Service6 service = new Service6();
-
+
assertTrue(MockOsgi.activate(service, bundleContext, map));
assertTrue(service.isActivated());
assertSame(bundleContext, service.getComponentContext().getBundleContext());
assertSame(bundleContext, service.getBundleContext());
assertEquals("value1", service.getMap().get("prop1"));
-
+
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
}
-
+
@Test
public void testService7() {
Service7 service = new Service7();
-
+
assertTrue(MockOsgi.activate(service, bundleContext, map));
assertTrue(service.isActivated());
assertSame(bundleContext, service.getComponentContext().getBundleContext());
@@ -129,8 +129,8 @@ public class OsgiServiceUtilActivateDeactivateTest {
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
}
-
-
+
+
public @interface ServiceConfig {
String prop1();
String prop2_with_periods();
@@ -145,7 +145,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Component
public static class Service1 {
-
+
private boolean activated;
private ComponentContext componentContext;
@@ -160,7 +160,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
this.activated = false;
this.componentContext = null;
}
-
+
public boolean isActivated() {
return activated;
}
@@ -173,7 +173,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Component
public static class Service2 {
-
+
private boolean activated;
private BundleContext bundleContext;
@@ -188,7 +188,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
this.activated = false;
this.bundleContext = null;
}
-
+
public boolean isActivated() {
return activated;
}
@@ -201,7 +201,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Component
public static class Service3 {
-
+
private boolean activated;
private Map<String, Object> map;
@@ -216,7 +216,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
this.activated = false;
this.map = null;
}
-
+
public boolean isActivated() {
return activated;
}
@@ -229,7 +229,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Component
public static class Service4 {
-
+
private boolean activated;
private Map<String, Object> map;
@@ -243,7 +243,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
private void deactivate(int value) {
this.activated = false;
}
-
+
public boolean isActivated() {
return activated;
}
@@ -251,12 +251,12 @@ public class OsgiServiceUtilActivateDeactivateTest {
public Map<String, Object> getMap() {
return map;
}
-
+
}
@Component
public static class Service5 {
-
+
private boolean activated;
@Activate
@@ -268,7 +268,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
private void deactivate(Integer value) {
this.activated = false;
}
-
+
public boolean isActivated() {
return activated;
}
@@ -277,7 +277,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Component
public static class Service6 {
-
+
private boolean activated;
private ComponentContext componentContext;
private BundleContext bundleContext;
@@ -298,7 +298,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
this.bundleContext = null;
this.map = null;
}
-
+
public boolean isActivated() {
return activated;
}
@@ -319,7 +319,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
@Component
public static class Service7 {
-
+
private boolean activated;
private ComponentContext componentContext;
private BundleContext bundleContext;
@@ -340,7 +340,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
this.bundleContext = null;
this.map = null;
}
-
+
public boolean isActivated() {
return activated;
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
index e5939b3..7a847d7 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilTest.java
@@ -68,7 +68,7 @@ public class OsgiServiceUtilTest {
bundleContext.registerService(ServiceInterface2.class.getName(), service2, null);
bundleContext.registerService(ServiceInterface3.class.getName(), service2, null);
}
-
+
@After
public void tearDown() {
MockOsgi.shutdown(bundleContext);
@@ -212,7 +212,7 @@ public class OsgiServiceUtilTest {
@Test
public void testServiceFactoryViaScr() {
ServiceFactory1 serviceFactory1 = new ServiceFactory1();
-
+
MockOsgi.injectServices(serviceFactory1, bundleContext);
MockOsgi.activate(serviceFactory1, bundleContext, (Dictionary<String, Object>) null);
bundleContext.registerService(ServiceFactory1.class.getName(), serviceFactory1, null);
@@ -224,7 +224,7 @@ public class OsgiServiceUtilTest {
@Test
public void testServiceFactoryViaManualRegistration() {
final ServiceFactory1 serviceFactory1 = new ServiceFactory1();
-
+
bundleContext.registerService(ServiceFactory1.class.getName(), new ServiceFactory() {
@Override
public Object getService(Bundle bundle, ServiceRegistration registration) {
@@ -240,7 +240,7 @@ public class OsgiServiceUtilTest {
bundleContext.getServiceReference(ServiceFactory1.class.getName())));
}
-
+
public interface ServiceInterface1 {
// no methods
}
@@ -622,7 +622,7 @@ public class OsgiServiceUtilTest {
@Component(service = ServiceFactory1.class, servicefactory = true)
public static class ServiceFactory1 {
-
+
}
-
+
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/context/ContextPluginsTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/context/ContextPluginsTest.java
index e3983fb..8f96c47 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/context/ContextPluginsTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/context/ContextPluginsTest.java
@@ -32,7 +32,7 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
@SuppressWarnings({"unchecked","null"})
public class ContextPluginsTest {
-
+
private OsgiContext context = new OsgiContext();
@Mock
@@ -43,24 +43,24 @@ public class ContextPluginsTest {
private ContextCallback callback1;
@Mock
private ContextCallback callback2;
-
+
@Test
public void testConstructorSetUp() throws Exception {
ContextPlugins underTest = new ContextPlugins(callback1);
-
+
assertEquals(1, underTest.getPlugins().size());
-
+
underTest.executeAfterSetUpCallback(context);
-
+
verify(callback1, times(1)).execute(context);
}
@Test
public void testConstructorSetUpTearDown() throws Exception {
ContextPlugins underTest = new ContextPlugins(callback1, callback2);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeAfterSetUpCallback(context);
underTest.executeBeforeTearDownCallback(context);
@@ -72,9 +72,9 @@ public class ContextPluginsTest {
public void testExecuteBeforeSetUpCallback() throws Exception {
ContextPlugins underTest = new ContextPlugins();
underTest.addPlugin(plugin1, plugin2, null);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeBeforeSetUpCallback(context);
verify(plugin1, times(1)).beforeSetUp(context);
verify(plugin2, times(1)).beforeSetUp(context);
@@ -86,9 +86,9 @@ public class ContextPluginsTest {
public void testExecuteAfterSetUpCallback() throws Exception {
ContextPlugins underTest = new ContextPlugins();
underTest.addPlugin(plugin1, plugin2, null);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeAfterSetUpCallback(context);
verify(plugin1, times(1)).afterSetUp(context);
verify(plugin2, times(1)).afterSetUp(context);
@@ -100,9 +100,9 @@ public class ContextPluginsTest {
public void testExecuteBeforeTearDownCallback() throws Exception {
ContextPlugins underTest = new ContextPlugins();
underTest.addPlugin(plugin1, plugin2, null);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeBeforeTearDownCallback(context);
verify(plugin1, times(1)).beforeTearDown(context);
verify(plugin2, times(1)).beforeTearDown(context);
@@ -114,9 +114,9 @@ public class ContextPluginsTest {
public void testExecuteAfterTearDownCallback() throws Exception {
ContextPlugins underTest = new ContextPlugins();
underTest.addPlugin(plugin1, plugin2, null);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeAfterTearDownCallback(context);
verify(plugin1, times(1)).afterTearDown(context);
verify(plugin2, times(1)).afterTearDown(context);
@@ -128,9 +128,9 @@ public class ContextPluginsTest {
public void testAddBeforeSetUpCallback() throws Exception {
ContextPlugins underTest = new ContextPlugins();
underTest.addBeforeSetUpCallback(callback1, callback2, null);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeBeforeSetUpCallback(context);
verify(callback1, times(1)).execute(context);
verify(callback2, times(1)).execute(context);
@@ -140,9 +140,9 @@ public class ContextPluginsTest {
public void testAddAfterSetUpCallback() throws Exception {
ContextPlugins underTest = new ContextPlugins();
underTest.addAfterSetUpCallback(callback1, callback2, null);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeAfterSetUpCallback(context);
verify(callback1, times(1)).execute(context);
verify(callback2, times(1)).execute(context);
@@ -152,9 +152,9 @@ public class ContextPluginsTest {
public void testAddBeforeTearDownCallback() throws Exception {
ContextPlugins underTest = new ContextPlugins();
underTest.addBeforeTearDownCallback(callback1, callback2, null);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeBeforeTearDownCallback(context);
verify(callback1, times(1)).execute(context);
verify(callback2, times(1)).execute(context);
@@ -164,9 +164,9 @@ public class ContextPluginsTest {
public void testAddAfterTearDownCallback() throws Exception {
ContextPlugins underTest = new ContextPlugins();
underTest.addAfterTearDownCallback(callback1, callback2, null);
-
+
assertEquals(2, underTest.getPlugins().size());
-
+
underTest.executeAfterTearDownCallback(context);
verify(callback1, times(1)).execute(context);
verify(callback2, times(1)).execute(context);
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
index b3e80e1..caeba0f 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/context/OsgiContextImplTest.java
@@ -55,7 +55,7 @@ public class OsgiContextImplTest {
public void tearDown() throws Exception {
this.context.tearDown();
}
-
+
@Test
public void testContextObjects() {
assertNotNull(context.componentContext());
@@ -105,7 +105,7 @@ public class OsgiContextImplTest {
context.registerService(Set.class, myService1);
Set<String> myService2 = new HashSet<String>();
context.registerService(Set.class, myService2);
-
+
assertSame(myService1, context.getService(Set.class));
// expected: ascending order because ordering ascending by service ID
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
index ea29c87..ab01823 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
@@ -37,14 +37,14 @@ import org.osgi.annotation.versioning.ProviderType;
*/
@ProviderType
public final class OsgiContextBuilder {
-
+
private final @NotNull ContextPlugins plugins = new ContextPlugins();
-
+
/**
* Create builder with default resource resolver type.
*/
public OsgiContextBuilder() {}
-
+
/**
* @param <T> context type
* @param plugin Context plugin which listens to context lifecycle events.
@@ -106,5 +106,5 @@ public final class OsgiContextBuilder {
public @NotNull OsgiContext build() {
return new OsgiContext(plugins);
}
-
+
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
index c37a583..127fffc 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
@@ -36,5 +36,5 @@ import org.osgi.annotation.versioning.ConsumerType;
public interface OsgiContextCallback extends ContextCallback<OsgiContext> {
// specialized version of ContextCallback
-
+
}
diff --git a/core/src/test/resources/META-INF/test.txt b/core/src/test/resources/META-INF/test.txt
index af27ff4..6de7b8c 100644
--- a/core/src/test/resources/META-INF/test.txt
+++ b/core/src/test/resources/META-INF/test.txt
@@ -1 +1 @@
-This is a test file.
\ No newline at end of file
+This is a test file.
diff --git a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.context.OsgiContextImplTest.xml b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.context.OsgiContextImplTest.xml
index d6b9d1c..60037ea 100644
--- a/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.context.OsgiContextImplTest.xml
+++ b/core/src/test/resources/OSGI-INF/org.apache.sling.testing.mock.osgi.context.OsgiContextImplTest.xml
@@ -24,4 +24,4 @@
<provide interface="org.apache.sling.testing.mock.osgi.context.OsgiContextImplTest$MyService"/>
</service>
</scr:component>
-</components>
\ No newline at end of file
+</components>
diff --git a/core/src/test/resources/bundleData/nested/first.txt b/core/src/test/resources/bundleData/nested/first.txt
index fe4f02a..9c59e24 100644
--- a/core/src/test/resources/bundleData/nested/first.txt
+++ b/core/src/test/resources/bundleData/nested/first.txt
@@ -1 +1 @@
-first
\ No newline at end of file
+first
diff --git a/core/src/test/resources/bundleData/nested/second.txt b/core/src/test/resources/bundleData/nested/second.txt
index 2147e41..e019be0 100644
--- a/core/src/test/resources/bundleData/nested/second.txt
+++ b/core/src/test/resources/bundleData/nested/second.txt
@@ -1 +1 @@
-second
\ No newline at end of file
+second
diff --git a/junit4/pom.xml b/junit4/pom.xml
index 1766100..3c74a67 100644
--- a/junit4/pom.xml
+++ b/junit4/pom.xml
@@ -33,7 +33,7 @@
<name>Apache Sling Testing OSGi Mock JUnit 4</name>
<dependencies>
-
+
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.osgi-mock.core</artifactId>
diff --git a/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java b/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
index cdd293e..bdb72dd 100644
--- a/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
+++ b/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextBuilder.java
@@ -30,14 +30,14 @@ import org.osgi.annotation.versioning.ProviderType;
*/
@ProviderType
public final class OsgiContextBuilder {
-
+
private final @NotNull ContextPlugins plugins = new ContextPlugins();
-
+
/**
* Create builder.
*/
public OsgiContextBuilder() {}
-
+
/**
* @param <T> context type
* @param plugin Context plugin which listens to context lifecycle events.
@@ -99,5 +99,5 @@ public final class OsgiContextBuilder {
public @NotNull OsgiContext build() {
return new OsgiContext(plugins);
}
-
+
}
diff --git a/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java b/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
index 710b65d..6f005da 100644
--- a/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
+++ b/junit4/src/main/java/org/apache/sling/testing/mock/osgi/junit/OsgiContextCallback.java
@@ -29,5 +29,5 @@ import org.osgi.annotation.versioning.ConsumerType;
public interface OsgiContextCallback extends ContextCallback<OsgiContext> {
// specialized version of ContextCallback
-
+
}
diff --git a/junit5/pom.xml b/junit5/pom.xml
index 120d07c..c40073c 100644
--- a/junit5/pom.xml
+++ b/junit5/pom.xml
@@ -82,10 +82,10 @@
</dependency>
</dependencies>
-
+
<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/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberInstantiatedTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberInstantiatedTest.java
index d9b2c0d..a503393 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberInstantiatedTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberInstantiatedTest.java
@@ -34,7 +34,7 @@ class OsgiContextMemberInstantiatedTest {
@Test
void testSimpleService() {
context.registerService(Integer.class, new Integer(5));
-
+
Integer service = context.getService(Integer.class);
assertEquals((Integer)5, service);
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberSuperClassTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberSuperClassTest.java
index 97ab38f..4d7a236 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberSuperClassTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberSuperClassTest.java
@@ -32,7 +32,7 @@ class OsgiContextMemberSuperClassTest extends OsgiContextMemberTest {
@Test
void testSimpleService() {
context.registerService(Integer.class, new Integer(5));
-
+
Integer service = context.getService(Integer.class);
assertEquals((Integer)5, service);
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberTest.java
index 70d65d9..74c92b7 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextMemberTest.java
@@ -34,7 +34,7 @@ class OsgiContextMemberTest {
@Test
void testSimpleService() {
context.registerService(Integer.class, new Integer(5));
-
+
Integer service = context.getService(Integer.class);
assertEquals((Integer)5, service);
}
diff --git a/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextTest.java b/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextTest.java
index 6501e12..78ba805 100644
--- a/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextTest.java
+++ b/junit5/src/test/java/org/apache/sling/testing/mock/osgi/junit5/OsgiContextTest.java
@@ -32,7 +32,7 @@ class OsgiContextTest {
@Test
void testSimpleService(OsgiContext context) {
context.registerService(Integer.class, new Integer(5));
-
+
Integer service = context.getService(Integer.class);
assertEquals((Integer)5, service);
}
diff --git a/parent/pom.xml b/parent/pom.xml
index 85d5b58..c8b61ec 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -55,7 +55,7 @@
</dependency>
</dependencies>
-
+
<dependencyManagement>
<dependencies>
@@ -124,7 +124,7 @@
</dependencies>
</dependencyManagement>
-
+
<build>
<pluginManagement>
<plugins>
diff --git a/pom.xml b/pom.xml
index 0d8ee44..bb10401 100644
--- a/pom.xml
+++ b/pom.xml
@@ -38,7 +38,7 @@
<url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-testing-osgi-mock.git</url>
<tag>HEAD</tag>
</scm>
-
+
<modules>
<module>parent</module>
<module>core</module>