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 2023/08/14 14:12:01 UTC
[sling-org-apache-sling-testing-osgi-mock] branch master updated: SLING-12000 Update to sling-bundle-parent 52, switch to Java 11 also get rid of guava testing dependencies
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
The following commit(s) were added to refs/heads/master by this push:
new 49e5931 SLING-12000 Update to sling-bundle-parent 52, switch to Java 11 also get rid of guava testing dependencies
49e5931 is described below
commit 49e5931966da3a4dbcc2a2b77241a1ac97e39530
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Mon Aug 14 15:16:21 2023 +0200
SLING-12000 Update to sling-bundle-parent 52, switch to Java 11
also get rid of guava testing dependencies
---
core/pom.xml | 6 ---
.../sling/testing/mock/osgi/MapUtilTest.java | 8 ++--
...ckBundleContextDynamicReferencesOsgiR6Test.java | 30 +++++++--------
.../MockBundleContextDynamicReferencesTest.java | 12 +++---
...ckBundleContextServiceVsSuperinterfaceTest.java | 5 +--
...icGreedyConstructorInjectionReferencesTest.java | 12 +++---
...ockBundleContextStaticGreedyReferencesTest.java | 22 +++++------
.../sling/testing/mock/osgi/MockBundleTest.java | 11 +++---
.../mock/osgi/MockConfigurationAdminTest.java | 20 ++++------
.../testing/mock/osgi/MockEventAdminTest.java | 45 +++++++++++-----------
.../OsgiServiceUtilActivateDeactivateTest.java | 14 +++----
.../mock/osgi/OsgiServiceUtilBindUnbindTest.java | 13 +++----
.../testing/mock/osgi/OsgiServiceUtilTest.java | 10 ++---
parent/pom.xml | 2 +-
14 files changed, 95 insertions(+), 115 deletions(-)
diff --git a/core/pom.xml b/core/pom.xml
index 25eb36c..82d24f4 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -159,12 +159,6 @@
<version>1.3</version>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>15.0</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.logging-mock</artifactId>
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 6631414..0d78fd9 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
@@ -25,13 +25,11 @@ import java.util.Map;
import org.junit.Test;
-import com.google.common.collect.ImmutableMap;
-
public class MapUtilTest {
@Test
public void testMapDictionary() {
- Map<String,Object> map = ImmutableMap.<String, Object>of("param1", "var1", "param2", 123, "param3", true);
+ Map<String,Object> map = Map.<String, Object>of("param1", "var1", "param2", 123, "param3", true);
Dictionary<String, Object> dict = MapUtil.toDictionary(map);
Map<String,Object> convertedMap = MapUtil.toMap(dict);
@@ -43,7 +41,7 @@ public class MapUtilTest {
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);
+ assertEquals(Map.<String, Object>of("param1", "var1", "param2", 123, "param3", true), convertedMap);
}
@Test
@@ -51,7 +49,7 @@ public class MapUtilTest {
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);
+ assertEquals(Map.<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 db6d6d1..6ce9b61 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
@@ -22,6 +22,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.Service3OsgiR6;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.Service3OsgiR6Impl;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface1;
@@ -37,9 +40,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
@RunWith(MockitoJUnitRunner.class)
public class MockBundleContextDynamicReferencesOsgiR6Test {
@@ -78,7 +78,7 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
service = newService3OsgiR6();
MockOsgi.injectServices(service, bundleContext);
MockOsgi.activate(service, bundleContext);
- bundleContext.registerService(Service3OsgiR6.class.getName(), service, MapUtil.toDictionary(ImmutableMap.<String,Object>of("reference3DynamicFiltered.target","(prop1=def)")));
+ bundleContext.registerService(Service3OsgiR6.class.getName(), service, MapUtil.toDictionary(Map.<String,Object>of("reference3DynamicFiltered.target","(prop1=def)")));
assertDependency1(dependency1a);
assertDependency1Optional(null);
@@ -153,10 +153,10 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
assertDependencies3Filtered();
bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a,
- MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "abc")));
+ MapUtil.toDictionary(Map.<String, Object>of("prop1", "abc")));
bundleContext.registerService(ServiceInterface3.class.getName(), dependency3b,
- MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "def")));
+ MapUtil.toDictionary(Map.<String, Object>of("prop1", "def")));
assertDependencies3Filtered(dependency3a);
}
@@ -166,13 +166,13 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
assertDependencies3DynamicFiltered(null);
bundleContext.registerService(ServiceSuperInterface3.class.getName(), dependency3a,
- MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "abc")));
+ MapUtil.toDictionary(Map.<String, Object>of("prop1", "abc")));
bundleContext.registerService(ServiceSuperInterface3.class.getName(), dependency3b,
- MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "def")));
+ MapUtil.toDictionary(Map.<String, Object>of("prop1", "def")));
bundleContext.registerService(ServiceSuperInterface3.class.getName(), dependency3c,
- MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "hij")));
+ MapUtil.toDictionary(Map.<String, Object>of("prop1", "hij")));
assertDependencies3DynamicFiltered(dependency3b);
}
@@ -196,18 +196,18 @@ public class MockBundleContextDynamicReferencesOsgiR6Test {
}
private void assertDependencies2(ServiceInterface2... instances) {
- assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
- ImmutableSet.<ServiceInterface2>copyOf(service.getReferences2()));
+ assertEquals(Set.<ServiceInterface2>of(instances),
+ Set.<ServiceInterface2>copyOf(service.getReferences2()));
}
private void assertDependencies3(ServiceSuperInterface3... instances) {
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
- ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3()));
+ assertEquals(Set.<ServiceSuperInterface3>of(instances),
+ Set.<ServiceSuperInterface3>copyOf(service.getReferences3()));
}
private void assertDependencies3Filtered(ServiceSuperInterface3... instances) {
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
- ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3Filtered()));
+ assertEquals(Set.<ServiceSuperInterface3>of(instances),
+ Set.<ServiceSuperInterface3>copyOf(service.getReferences3Filtered()));
}
private void assertDependencies3DynamicFiltered(ServiceSuperInterface3 instance) {
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 3381b52..5635d6a 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
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import java.util.Set;
+
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.Service3;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface1;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface1Optional;
@@ -36,8 +38,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import com.google.common.collect.ImmutableSet;
-
@RunWith(MockitoJUnitRunner.class)
public class MockBundleContextDynamicReferencesTest {
@@ -159,13 +159,13 @@ public class MockBundleContextDynamicReferencesTest {
}
private void assertDependencies2(ServiceInterface2... instances) {
- assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
- ImmutableSet.<ServiceInterface2>copyOf(service.getReferences2()));
+ assertEquals(Set.<ServiceInterface2>of(instances),
+ Set.<ServiceInterface2>copyOf(service.getReferences2()));
}
private void assertDependencies3(ServiceSuperInterface3... instances) {
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
- ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3()));
+ assertEquals(Set.<ServiceSuperInterface3>of(instances),
+ Set.<ServiceSuperInterface3>copyOf(service.getReferences3()));
}
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextServiceVsSuperinterfaceTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextServiceVsSuperinterfaceTest.java
index fa051bd..af87948 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextServiceVsSuperinterfaceTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextServiceVsSuperinterfaceTest.java
@@ -21,6 +21,7 @@ package org.apache.sling.testing.mock.osgi;
import static org.junit.Assert.assertEquals;
import java.util.List;
+import java.util.Set;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.Service7ServiceVsSuperInterface;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface3;
@@ -33,8 +34,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import com.google.common.collect.ImmutableSet;
-
@RunWith(MockitoJUnitRunner.class)
public class MockBundleContextServiceVsSuperinterfaceTest {
@@ -93,7 +92,7 @@ public class MockBundleContextServiceVsSuperinterfaceTest {
@SafeVarargs
private static void assertDeps(List<?> actual, Object... expected) {
- assertEquals(ImmutableSet.copyOf(expected), ImmutableSet.copyOf(actual));
+ assertEquals(Set.of(expected), Set.copyOf(actual));
}
}
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyConstructorInjectionReferencesTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyConstructorInjectionReferencesTest.java
index ce0bebf..71535c3 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyConstructorInjectionReferencesTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/MockBundleContextStaticGreedyConstructorInjectionReferencesTest.java
@@ -22,6 +22,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import java.util.Set;
+
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.Service3StaticGreedy;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.Service3StaticGreedyConstructorInjectionImpl;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface1;
@@ -38,8 +40,6 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-import com.google.common.collect.ImmutableSet;
-
@RunWith(MockitoJUnitRunner.class)
public class MockBundleContextStaticGreedyConstructorInjectionReferencesTest {
@@ -172,14 +172,14 @@ public class MockBundleContextStaticGreedyConstructorInjectionReferencesTest {
private void assertDependencies2(ServiceInterface2... instances) {
Service3StaticGreedy service = getService();
- assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
- ImmutableSet.<ServiceInterface2>copyOf(service.getReferences2()));
+ assertEquals(Set.<ServiceInterface2>of(instances),
+ Set.<ServiceInterface2>copyOf(service.getReferences2()));
}
private void assertDependencies3(ServiceSuperInterface3... instances) {
Service3StaticGreedy service =getService();
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
- ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3()));
+ assertEquals(Set.<ServiceSuperInterface3>of(instances),
+ Set.<ServiceSuperInterface3>copyOf(service.getReferences3()));
}
private Service3StaticGreedy getService() {
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 a99afb1..58ac28c 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
@@ -22,6 +22,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import java.util.Map;
+import java.util.Set;
+
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.Service3StaticGreedy;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.Service3StaticGreedyImpl;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface1;
@@ -38,9 +41,6 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
@RunWith(MockitoJUnitRunner.class)
public class MockBundleContextStaticGreedyReferencesTest {
@@ -154,10 +154,10 @@ public class MockBundleContextStaticGreedyReferencesTest {
assertDependencies3Filtered();
bundleContext.registerService(ServiceInterface3.class.getName(), dependency3a,
- MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "abc")));
+ MapUtil.toDictionary(Map.<String, Object>of("prop1", "abc")));
bundleContext.registerService(ServiceInterface3.class.getName(), dependency3b,
- MapUtil.toDictionary(ImmutableMap.<String, Object>of("prop1", "def")));
+ MapUtil.toDictionary(Map.<String, Object>of("prop1", "def")));
assertDependencies3Filtered(dependency3a);
}
@@ -184,14 +184,14 @@ public class MockBundleContextStaticGreedyReferencesTest {
private void assertDependencies2(ServiceInterface2... instances) {
Service3StaticGreedy service = getService();
- assertEquals(ImmutableSet.<ServiceInterface2>copyOf(instances),
- ImmutableSet.<ServiceInterface2>copyOf(service.getReferences2()));
+ assertEquals(Set.<ServiceInterface2>of(instances),
+ Set.<ServiceInterface2>copyOf(service.getReferences2()));
}
private void assertDependencies3(ServiceSuperInterface3... instances) {
Service3StaticGreedy service = getService();
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
- ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3()));
+ assertEquals(Set.<ServiceSuperInterface3>of(instances),
+ Set.<ServiceSuperInterface3>copyOf(service.getReferences3()));
}
private Service3StaticGreedy getService() {
@@ -201,8 +201,8 @@ public class MockBundleContextStaticGreedyReferencesTest {
private void assertDependencies3Filtered(ServiceSuperInterface3... instances) {
Service3StaticGreedy service = getService();
- assertEquals(ImmutableSet.<ServiceSuperInterface3>copyOf(instances),
- ImmutableSet.<ServiceSuperInterface3>copyOf(service.getReferences3Filtered()));
+ assertEquals(Set.<ServiceSuperInterface3>of(instances),
+ Set.<ServiceSuperInterface3>copyOf(service.getReferences3Filtered()));
}
}
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 b87426a..7abf399 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
@@ -26,14 +26,13 @@ import static org.junit.Assert.assertTrue;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
+import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.Version;
-import com.google.common.collect.ImmutableMap;
-
public class MockBundleTest {
private MockBundle bundle;
@@ -67,7 +66,7 @@ public class MockBundleTest {
@Test
public void testGetHeaders() {
- bundle.setHeaders(ImmutableMap.of("prop1", "value1"));
+ bundle.setHeaders(Map.of("prop1", "value1"));
assertEquals("value1", bundle.getHeaders().get("prop1"));
assertEquals("value1", bundle.getHeaders("en").get("prop1"));
}
@@ -155,16 +154,16 @@ public class MockBundleTest {
assertTrue(paths.contains("bundleData/nested/first.txt"));
assertTrue(paths.contains("bundleData/nested/second.txt"));
}
-
+
@Test
public void getVersion_default() {
assertEquals(Version.emptyVersion, bundle.getVersion());
}
-
+
@Test
public void getVersion_custom() {
bundle.setVersion(new Version(3, 2, 1));
assertEquals("3.2.1", bundle.getVersion().toString());
}
-
+
}
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 7b2d13f..a941ead 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
@@ -29,6 +29,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.Dictionary;
import java.util.Hashtable;
+import java.util.Map;
import org.apache.sling.testing.mock.osgi.OsgiMetadataUtilTest.ServiceWithMetadata;
import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
@@ -41,8 +42,6 @@ import org.osgi.framework.ServiceReference;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
-import com.google.common.collect.ImmutableMap;
-
public class MockConfigurationAdminTest {
private static final String[] TEST_ADAPTABLES = new String[] {
@@ -67,10 +66,9 @@ public class MockConfigurationAdminTest {
"adaptables", TEST_ADAPTABLES,
"prop2", 2);
- context.registerInjectActivateService(new ServiceWithMetadata(), ImmutableMap.<String, Object>builder()
- .put(Constants.SERVICE_RANKING, 4000)
- .put("prop1", 1)
- .build());
+ context.registerInjectActivateService(new ServiceWithMetadata(), Map.<String, Object>of(
+ Constants.SERVICE_RANKING, 4000,
+ "prop1", 1));
ServiceReference reference = context.bundleContext().getServiceReference(Comparable.class.getName());
@@ -92,9 +90,8 @@ public class MockConfigurationAdminTest {
MockOsgi.setConfigForPid(context.bundleContext(), ServiceWithConfigurationPID.class.getSimpleName(),
"prop1", 1);
- context.registerInjectActivateService(new ServiceWithConfigurationPID(), ImmutableMap.<String, Object>builder()
- .put("prop2", 2)
- .build());
+ context.registerInjectActivateService(new ServiceWithConfigurationPID(), Map.<String, Object>of(
+ "prop2", 2));
ServiceReference reference = context.bundleContext().getServiceReference(Comparable.class.getName());
@@ -109,9 +106,8 @@ public class MockConfigurationAdminTest {
MockOsgi.setConfigForPid(context.bundleContext(), "Configuration2",
"prop1", 2);
- context.registerInjectActivateService(new ServiceWithMultipleConfigurationPID(), ImmutableMap.<String, Object>builder()
- .put("prop2", 2)
- .build());
+ context.registerInjectActivateService(new ServiceWithMultipleConfigurationPID(), Map.<String, Object>of(
+ "prop2", 2));
ServiceReference reference = context.bundleContext().getServiceReference(Comparable.class.getName());
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 4328f2f..a546efa 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
@@ -21,8 +21,10 @@ package org.apache.sling.testing.mock.osgi;
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Dictionary;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import org.apache.sling.testing.mock.osgi.junit.OsgiContext;
@@ -34,9 +36,6 @@ import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
@SuppressWarnings("null")
public class MockEventAdminTest {
@@ -60,11 +59,11 @@ public class MockEventAdminTest {
@Before
public void setUp() {
eventHandler1 = (DummyEventHandler)context.registerService(EventHandler.class, new DummyEventHandler(),
- ImmutableMap.<String, Object>of(EventConstants.EVENT_TOPIC, TOPIC_SAMPLE_1));
+ Map.<String, Object>of(EventConstants.EVENT_TOPIC, TOPIC_SAMPLE_1));
eventHandler12 = (DummyEventHandler)context.registerService(EventHandler.class, new DummyEventHandler(),
- ImmutableMap.<String, Object>of(EventConstants.EVENT_TOPIC, new String[] { TOPIC_SAMPLE_1, TOPIC_SAMPLE_2 }));
+ Map.<String, Object>of(EventConstants.EVENT_TOPIC, new String[] { TOPIC_SAMPLE_1, TOPIC_SAMPLE_2 }));
eventHandlerSampleAll = (DummyEventHandler)context.registerService(EventHandler.class, new DummyEventHandler(),
- ImmutableMap.<String, Object>of(EventConstants.EVENT_TOPIC, TOPIC_SAMPLE_ALL));
+ Map.<String, Object>of(EventConstants.EVENT_TOPIC, TOPIC_SAMPLE_ALL));
eventHandlerAll = (DummyEventHandler)context.registerService(EventHandler.class, new DummyEventHandler());
}
@@ -73,10 +72,10 @@ public class MockEventAdminTest {
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());
- assertEquals(ImmutableList.of(EVENT_SAMPLE_1), eventHandlerAll.getReceivedEvents());
+ assertEquals(List.of(EVENT_SAMPLE_1), eventHandler1.getReceivedEvents());
+ assertEquals(List.of(EVENT_SAMPLE_1), eventHandler12.getReceivedEvents());
+ assertEquals(List.of(EVENT_SAMPLE_1), eventHandlerSampleAll.getReceivedEvents());
+ assertEquals(List.of(EVENT_SAMPLE_1), eventHandlerAll.getReceivedEvents());
}
@Test
@@ -84,10 +83,10 @@ public class MockEventAdminTest {
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());
- assertEquals(ImmutableList.of(EVENT_SAMPLE_2), eventHandlerAll.getReceivedEvents());
+ assertEquals(List.of(), eventHandler1.getReceivedEvents());
+ assertEquals(List.of(EVENT_SAMPLE_2), eventHandler12.getReceivedEvents());
+ assertEquals(List.of(EVENT_SAMPLE_2), eventHandlerSampleAll.getReceivedEvents());
+ assertEquals(List.of(EVENT_SAMPLE_2), eventHandlerAll.getReceivedEvents());
}
@Test
@@ -95,10 +94,10 @@ public class MockEventAdminTest {
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());
- assertEquals(ImmutableList.of(EVENT_OTHER_3), eventHandlerAll.getReceivedEvents());
+ assertEquals(List.of(), eventHandler1.getReceivedEvents());
+ assertEquals(List.of(), eventHandler12.getReceivedEvents());
+ assertEquals(List.of(), eventHandlerSampleAll.getReceivedEvents());
+ assertEquals(List.of(EVENT_OTHER_3), eventHandlerAll.getReceivedEvents());
}
@Test(timeout = 3000)
@@ -110,10 +109,10 @@ public class MockEventAdminTest {
// wait until result is as expected (with timeout)
boolean expectedResult = false;
while (!expectedResult) {
- expectedResult = Objects.equals(ImmutableList.of(), eventHandler1.getReceivedEvents())
- && Objects.equals(ImmutableList.of(EVENT_SAMPLE_2), eventHandler12.getReceivedEvents())
- && Objects.equals(ImmutableList.of(EVENT_SAMPLE_2), eventHandlerSampleAll.getReceivedEvents())
- && Objects.equals(ImmutableList.of(EVENT_SAMPLE_2, EVENT_OTHER_3), eventHandlerAll.getReceivedEvents());
+ expectedResult = Objects.equals(List.of(), eventHandler1.getReceivedEvents())
+ && Objects.equals(List.of(EVENT_SAMPLE_2), eventHandler12.getReceivedEvents())
+ && Objects.equals(List.of(EVENT_SAMPLE_2), eventHandlerSampleAll.getReceivedEvents())
+ && Objects.equals(List.of(EVENT_SAMPLE_2, EVENT_OTHER_3), eventHandlerAll.getReceivedEvents());
}
}
@@ -127,7 +126,7 @@ public class MockEventAdminTest {
}
public List<Event> getReceivedEvents() {
- return ImmutableList.copyOf(receivedEvents);
+ return Collections.unmodifiableList(receivedEvents);
}
}
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 e1aed2c..96246bc 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
@@ -47,14 +47,12 @@ import org.junit.Assert;
import org.junit.Test;
import org.osgi.framework.BundleContext;
-import com.google.common.collect.ImmutableMap;
-
/**
* Test different variants of activate/deactivate methods with varying signatures.
*/
public class OsgiServiceUtilActivateDeactivateTest {
- private Map<String,Object> map = ImmutableMap.<String, Object>of("prop1", "value1",
+ private Map<String,Object> map = Map.<String, Object>of("prop1", "value1",
"prop2.with.periods", "value2",
"prop3-with-hyphens", "value3");
private BundleContext bundleContext = MockOsgi.newBundleContext();
@@ -137,7 +135,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
assertTrue(MockOsgi.activate(service, bundleContext, map));
assertTrue(service.isActivated());
- assertEquals(map, ImmutableMap.copyOf(service.getMap()));
+ assertEquals(map, Map.copyOf(service.getMap()));
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
@@ -149,7 +147,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
assertNotNull(service);
assertTrue(service.isActivated());
- assertEquals(map, ImmutableMap.copyOf(service.getMap()));
+ assertEquals(map, Map.copyOf(service.getMap()));
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
@@ -213,7 +211,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
assertTrue(service.isActivated());
assertSame(bundleContext, service.getComponentContext().getBundleContext());
assertSame(bundleContext, service.getBundleContext());
- assertEquals(map, ImmutableMap.copyOf(service.getMap()));
+ assertEquals(map, Map.copyOf(service.getMap()));
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
@@ -227,7 +225,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
assertTrue(service.isActivated());
assertSame(bundleContext, service.getComponentContext().getBundleContext());
assertSame(bundleContext, service.getBundleContext());
- assertEquals(map, ImmutableMap.copyOf(service.getMap()));
+ assertEquals(map, Map.copyOf(service.getMap()));
assertTrue(MockOsgi.deactivate(service, bundleContext, map));
assertFalse(service.isActivated());
@@ -247,7 +245,7 @@ public class OsgiServiceUtilActivateDeactivateTest {
/**
* SLING-11860 verify OsgiServiceUtil#activateDeactivate invokes the correct activate and deactivate methods
*/
- @Test
+ @Test
public void testService9ActivateDeactivate() {
Service9 service = MockOsgi.activateInjectServices(Service9.class, bundleContext, map);
assertEquals(Service9.class, service.getActivateFromClass());
diff --git a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilBindUnbindTest.java b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilBindUnbindTest.java
index 7a4dc7d..4bce611 100644
--- a/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilBindUnbindTest.java
+++ b/core/src/test/java/org/apache/sling/testing/mock/osgi/OsgiServiceUtilBindUnbindTest.java
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertEquals;
import java.util.Dictionary;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.stream.Collectors;
import org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil.ServiceInterface1;
@@ -40,9 +41,6 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-
/**
* Test different variants of bind/unbind methods with varying signatures.
*/
@@ -155,14 +153,15 @@ public class OsgiServiceUtilBindUnbindTest {
@SafeVarargs
private final <T> void assertItems(List<T> actual, T... expected) {
- assertEquals(ImmutableSet.copyOf(expected), ImmutableSet.copyOf(actual));
+ assertEquals(Set.of(expected), Set.copyOf(actual));
}
@SafeVarargs
- @SuppressWarnings("null")
private final <T> void assertMaps(List<Map<String,Object>> actual, Map<String,Object>... expected) {
List<Map<String,Object>> actualFiltered = actual.stream()
- .map(actualItem -> Maps.filterEntries(actualItem, item -> item.getKey().equals("prop1")))
+ .map(actualItem -> actualItem.entrySet().stream()
+ .filter(entry -> entry.getKey().equals("prop1"))
+ .collect(Collectors.toMap(entry -> entry.getKey(), entry -> entry.getValue())))
.collect(Collectors.toList());
assertItems(actualFiltered, expected);
}
@@ -171,7 +170,7 @@ public class OsgiServiceUtilBindUnbindTest {
/**
* SLING-11860 verify OsgiServiceUtil#invokeBindUnbindMethod invokes the correct bind and unbind methods
*/
- @Test
+ @Test
public void testService9BindUnbind() {
Service9 service9 = registerInjectService(new Service9());
assertEquals(Service9.class, service9.getBindSvc1FromClass());
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 36db246..4cd9c76 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
@@ -56,8 +56,6 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
-import com.google.common.collect.ImmutableMap;
-
public class OsgiServiceUtilTest {
private BundleContext bundleContext = MockOsgi.newBundleContext();
@@ -157,17 +155,17 @@ public class OsgiServiceUtilTest {
public void testService3_Config() {
BundleContext bundleContext = MockOsgi.newBundleContext();
- Map<String,Object> initialProperites = ImmutableMap.<String, Object>of("prop1", "value1");
+ Map<String,Object> initialProperites = Map.<String, Object>of("prop1", "value1");
Service3 service3 = new Service3();
MockOsgi.activate(service3, bundleContext, initialProperites);
assertEquals(initialProperites.get("prop1"), service3.getConfig().get("prop1"));
- Map<String,Object> newProperties = ImmutableMap.<String, Object>of("prop2", "value2");
+ Map<String,Object> newProperties = Map.<String, Object>of("prop2", "value2");
MockOsgi.modified(service3, bundleContext, newProperties);
assertEquals(newProperties.get("prop2"), service3.getConfig().get("prop2"));
- newProperties = ImmutableMap.<String, Object>of("prop3", "value3");
+ newProperties = Map.<String, Object>of("prop3", "value3");
Dictionary<String,Object> newPropertiesDictonary = new Hashtable<String,Object>(newProperties);
MockOsgi.modified(service3, bundleContext, newPropertiesDictonary);
assertEquals(newProperties.get("prop3"), service3.getConfig().get("prop3"));
@@ -217,7 +215,7 @@ public class OsgiServiceUtilTest {
@Test(expected=NoScrMetadataException.class)
public void testModifiedNoMetadata() {
- MockOsgi.modified(new Object(), MockOsgi.newBundleContext(), ImmutableMap.<String,Object>of());
+ MockOsgi.modified(new Object(), MockOsgi.newBundleContext(), Map.<String,Object>of());
}
@Test
diff --git a/parent/pom.xml b/parent/pom.xml
index 625c06d..d8aa559 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.apache.sling</groupId>
<artifactId>sling-bundle-parent</artifactId>
- <version>49</version>
+ <version>52</version>
<relativePath />
</parent>