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 885ef6e cosmetic: eliminate usage of deprecated code
885ef6e is described below
commit 885ef6eaa977226633052c6e8cb89b900fc90817
Author: Stefan Seifert <[email protected]>
AuthorDate: Tue Mar 3 15:28:12 2026 +0100
cosmetic: eliminate usage of deprecated code
---
.../sling/testing/mock/osgi/MockBundleContext.java | 3 ++-
.../sling/testing/mock/osgi/OsgiMetadataUtil.java | 15 ++++++++-------
.../sling/testing/mock/osgi/OsgiServiceUtil.java | 19 +++++++++----------
.../osgi/testsvc/osgiserviceutil/ServiceFactory1.java | 3 ++-
4 files changed, 21 insertions(+), 19 deletions(-)
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 4b10057..d64af71 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
@@ -41,6 +41,7 @@ import java.util.concurrent.ConcurrentSkipListSet;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Strings;
import org.apache.felix.framework.FilterImpl;
import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.DynamicReference;
import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.Reference;
@@ -528,7 +529,7 @@ class MockBundleContext implements BundleContext {
@Override
public Bundle getBundle(String location) {
- if (StringUtils.equals(location, Constants.SYSTEM_BUNDLE_LOCATION)) {
+ if (Strings.CS.equals(location, Constants.SYSTEM_BUNDLE_LOCATION)) {
return systemBundle;
}
// otherwise return null - no bundle found
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 10b6683..9801218 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
@@ -48,6 +48,7 @@ import java.util.regex.Pattern;
import org.apache.commons.collections4.BidiMap;
import org.apache.commons.collections4.bidimap.TreeBidiMap;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Strings;
import org.apache.felix.framework.FilterImpl;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
@@ -297,11 +298,11 @@ final class OsgiMetadataUtil {
String name = getAttributeValue(node, "name");
String value = getAttributeValue(node, "value");
String type = getAttributeValue(node, "type");
- if (StringUtils.equals("Integer", type)) {
+ if (Strings.CS.equals("Integer", type)) {
props.put(name, Integer.parseInt(value));
- } else if (StringUtils.equals("Long", type)) {
+ } else if (Strings.CS.equals("Long", type)) {
props.put(name, Long.parseLong(value));
- } else if (StringUtils.equals("Boolean", type)) {
+ } else if (Strings.CS.equals("Boolean", type)) {
props.put(name, Boolean.parseBoolean(value));
} else {
props.put(name, value);
@@ -594,7 +595,7 @@ final class OsgiMetadataUtil {
private static ReferenceCardinality toCardinality(String value) {
for (ReferenceCardinality item : ReferenceCardinality.values()) {
- if (StringUtils.equals(item.getCardinalityString(), value)) {
+ if (Strings.CS.equals(item.getCardinalityString(), value)) {
return item;
}
}
@@ -603,7 +604,7 @@ final class OsgiMetadataUtil {
private static ReferencePolicy toPolicy(String value) {
for (ReferencePolicy item : ReferencePolicy.values()) {
- if (StringUtils.equalsIgnoreCase(item.name(), value)) {
+ if (Strings.CI.equals(item.name(), value)) {
return item;
}
}
@@ -612,7 +613,7 @@ final class OsgiMetadataUtil {
private static ReferencePolicyOption toPolicyOption(String value) {
for (ReferencePolicyOption item : ReferencePolicyOption.values()) {
- if (StringUtils.equalsIgnoreCase(item.name(), value)) {
+ if (Strings.CI.equals(item.name(), value)) {
return item;
}
}
@@ -621,7 +622,7 @@ final class OsgiMetadataUtil {
private static FieldCollectionType toFieldCollectionType(String value)
{
for (FieldCollectionType item : FieldCollectionType.values()) {
- if (StringUtils.equalsIgnoreCase(item.name(), value)) {
+ if (Strings.CI.equals(item.name(), value)) {
return item;
}
}
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 ff58a53..20755ca 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
@@ -41,6 +41,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.Strings;
import org.apache.felix.scr.impl.inject.internal.Annotations;
import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.DynamicReference;
import org.apache.sling.testing.mock.osgi.OsgiMetadataUtil.FieldCollectionType;
@@ -290,7 +291,7 @@ final class OsgiServiceUtil {
private static Method getMethod(Class clazz, String methodName, Class<?>[]
types) {
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
- if (StringUtils.equals(method.getName(), methodName) &&
method.getParameterTypes().length == types.length) {
+ if (Strings.CS.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])
@@ -310,7 +311,7 @@ final class OsgiServiceUtil {
private static Method getMethodWithAssignableTypes(Class clazz, String
methodName, Class<?>[] types) {
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
- if (StringUtils.equals(method.getName(), methodName) &&
method.getParameterTypes().length == types.length) {
+ if (Strings.CS.equals(method.getName(), methodName) &&
method.getParameterTypes().length == types.length) {
boolean foundMismatch = false;
for (int i = 0; i < types.length; i++) {
if
(!method.getParameterTypes()[i].isAssignableFrom(types[i])) {
@@ -330,7 +331,7 @@ final class OsgiServiceUtil {
private static Method getMethodWithAnyCombinationArgs(Class clazz, String
methodName, Class<?>[] types) {
Method[] methods = clazz.getDeclaredMethods();
for (Method method : methods) {
- if (StringUtils.equals(method.getName(), methodName) &&
method.getParameterTypes().length > 1) {
+ if (Strings.CS.equals(method.getName(), methodName) &&
method.getParameterTypes().length > 1) {
boolean foundMismatch = false;
for (Class<?> parameterType : method.getParameterTypes()) {
boolean foundAnyMatch = false;
@@ -395,8 +396,7 @@ final class OsgiServiceUtil {
private static Field getField(Class clazz, String fieldName, Class<?>
type) {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
- if (StringUtils.equals(field.getName(), fieldName)
- && field.getType().equals(type)) {
+ if (Strings.CS.equals(field.getName(), fieldName) &&
field.getType().equals(type)) {
return field;
}
}
@@ -411,8 +411,7 @@ final class OsgiServiceUtil {
private static Field getFieldWithAssignableType(Class clazz, String
fieldName, Class<?> type) {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
- if (StringUtils.equals(field.getName(), fieldName)
- && field.getType().isAssignableFrom(type)) {
+ if (Strings.CS.equals(field.getName(), fieldName) &&
field.getType().isAssignableFrom(type)) {
return field;
}
}
@@ -427,7 +426,7 @@ final class OsgiServiceUtil {
private static Field getCollectionField(Class clazz, String fieldName) {
Field[] fields = clazz.getDeclaredFields();
for (Field field : fields) {
- if (StringUtils.equals(field.getName(), fieldName) &&
Collection.class.isAssignableFrom(field.getType())) {
+ if (Strings.CS.equals(field.getName(), fieldName) &&
Collection.class.isAssignableFrom(field.getType())) {
return field;
}
}
@@ -957,7 +956,7 @@ final class OsgiServiceUtil {
}
if (reference.getPolicy() == ReferencePolicy.DYNAMIC) {
for (String serviceInterface :
registration.getClasses()) {
- if (StringUtils.equals(serviceInterface,
reference.getInterfaceType())) {
+ if (Strings.CS.equals(serviceInterface,
reference.getInterfaceType())) {
references.add(new
ReferenceInfo(existingRegistration, reference));
}
}
@@ -987,7 +986,7 @@ final class OsgiServiceUtil {
if (reference.getPolicy() == ReferencePolicy.STATIC
&& reference.getPolicyOption() ==
ReferencePolicyOption.GREEDY) {
for (String serviceInterface :
registration.getClasses()) {
- if (StringUtils.equals(serviceInterface,
reference.getInterfaceType())) {
+ if (Strings.CS.equals(serviceInterface,
reference.getInterfaceType())) {
references.add(new
ReferenceInfo(existingRegistration, reference));
}
}
diff --git
a/test-services/src/main/java/org/apache/sling/testing/mock/osgi/testsvc/osgiserviceutil/ServiceFactory1.java
b/test-services/src/main/java/org/apache/sling/testing/mock/osgi/testsvc/osgiserviceutil/ServiceFactory1.java
index 8540f49..4bcfec0 100644
---
a/test-services/src/main/java/org/apache/sling/testing/mock/osgi/testsvc/osgiserviceutil/ServiceFactory1.java
+++
b/test-services/src/main/java/org/apache/sling/testing/mock/osgi/testsvc/osgiserviceutil/ServiceFactory1.java
@@ -19,6 +19,7 @@
package org.apache.sling.testing.mock.osgi.testsvc.osgiserviceutil;
import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.ServiceScope;
-@Component(service = ServiceFactory1.class, servicefactory = true)
+@Component(service = ServiceFactory1.class, scope = ServiceScope.PROTOTYPE)
public class ServiceFactory1 {}