This is an automated email from the ASF dual-hosted git repository.
veithen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git
The following commit(s) were added to refs/heads/master by this push:
new 6d937a0 Remove FilterExpression in favor of the LDAP like expressions
in OSGi
6d937a0 is described below
commit 6d937a03233d98841a621595e78320c8fffa161f
Author: Andreas Veithen <[email protected]>
AuthorDate: Thu Dec 24 15:12:12 2020 +0000
Remove FilterExpression in favor of the LDAP like expressions in OSGi
---
modules/osgi/pom.xml | 1 -
modules/transport/testkit/pom.xml | 9 ++-
.../axis2/transport/testkit/ManagedTestSuite.java | 14 ++--
.../testkit/TransportTestSuiteBuilder.java | 4 +-
.../transport/testkit/filter/AndExpression.java | 42 ------------
.../testkit/filter/EqualityExpression.java | 39 -----------
.../transport/testkit/filter/FilterExpression.java | 35 ----------
.../testkit/filter/FilterExpressionParser.java | 75 ----------------------
.../transport/testkit/filter/NotExpression.java | 37 -----------
.../transport/testkit/filter/OrExpression.java | 42 ------------
.../testkit/filter/PresenceExpression.java | 37 -----------
.../transport/testkit/filter/package-info.java | 30 ---------
pom.xml | 5 ++
13 files changed, 20 insertions(+), 350 deletions(-)
diff --git a/modules/osgi/pom.xml b/modules/osgi/pom.xml
index e261377..c1c3f79 100644
--- a/modules/osgi/pom.xml
+++ b/modules/osgi/pom.xml
@@ -163,7 +163,6 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
- <version>1.10.0</version>
<scope>provided</scope>
</dependency>
<dependency>
diff --git a/modules/transport/testkit/pom.xml
b/modules/transport/testkit/pom.xml
index db0662d..3caf52c 100644
--- a/modules/transport/testkit/pom.xml
+++ b/modules/transport/testkit/pom.xml
@@ -60,9 +60,12 @@
<artifactId>junit</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.directory.shared</groupId>
- <artifactId>shared-ldap</artifactId>
- <version>0.9.11</version>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.framework</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java
index c7ad5c6..245153e 100644
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java
+++
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/ManagedTestSuite.java
@@ -19,7 +19,6 @@
package org.apache.axis2.transport.testkit;
-import java.text.ParseException;
import java.util.Enumeration;
import java.util.LinkedList;
import java.util.List;
@@ -29,17 +28,18 @@ import junit.framework.Test;
import junit.framework.TestResult;
import junit.framework.TestSuite;
-import org.apache.axis2.transport.testkit.filter.FilterExpression;
-import org.apache.axis2.transport.testkit.filter.FilterExpressionParser;
import org.apache.axis2.transport.testkit.tests.TestResourceSet;
import org.apache.axis2.transport.testkit.tests.TestResourceSetTransition;
import org.apache.axis2.transport.testkit.tests.ManagedTestCase;
import org.apache.axis2.transport.testkit.util.TestKitLogManager;
import org.apache.commons.lang.StringUtils;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.InvalidSyntaxException;
public class ManagedTestSuite extends TestSuite {
private final Class<?> testClass;
- private final List<FilterExpression> excludes = new
LinkedList<FilterExpression>();
+ private final List<Filter> excludes = new LinkedList<Filter>();
private final boolean reuseResources;
private boolean invertExcludes;
private int nextId = 1;
@@ -57,8 +57,8 @@ public class ManagedTestSuite extends TestSuite {
return testClass;
}
- public void addExclude(String filter) throws ParseException {
- excludes.add(FilterExpressionParser.parse(filter));
+ public void addExclude(String filter) throws InvalidSyntaxException {
+ excludes.add(FrameworkUtil.createFilter(filter));
}
public void setInvertExcludes(boolean invertExcludes) {
@@ -71,7 +71,7 @@ public class ManagedTestSuite extends TestSuite {
ManagedTestCase ttest = (ManagedTestCase)test;
Map<String,String> map = ttest.getNameComponents();
boolean excluded = false;
- for (FilterExpression exclude : excludes) {
+ for (Filter exclude : excludes) {
if (exclude.matches(map)) {
excluded = true;
break;
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
index e57bc45..db0f059 100644
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
+++
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
@@ -21,7 +21,6 @@ package org.apache.axis2.transport.testkit;
import static org.apache.axis2.transport.testkit.AdapterUtils.adapt;
-import java.text.ParseException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -49,6 +48,7 @@ import
org.apache.axis2.transport.testkit.tests.async.SwATestCase;
import org.apache.axis2.transport.testkit.tests.async.TextPlainTestCase;
import org.apache.axis2.transport.testkit.tests.async.XMLAsyncMessageTestCase;
import
org.apache.axis2.transport.testkit.tests.echo.XMLRequestResponseMessageTestCase;
+import org.osgi.framework.InvalidSyntaxException;
public class TransportTestSuiteBuilder {
static class ResourceRelation<T> {
@@ -130,7 +130,7 @@ public class TransportTestSuiteBuilder {
try {
// We only want tests with client and/or endpoint based on Axis
suite.addExclude("(&(client=*)(endpoint=*)(!(|(client=axis)(endpoint=axis))))");
- } catch (ParseException ex) {
+ } catch (InvalidSyntaxException ex) {
throw new Error(ex);
}
}
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/AndExpression.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/AndExpression.java
deleted file mode 100644
index 08b7130..0000000
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/AndExpression.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>and</em> (<tt>&</tt>) operator.
- */
-public class AndExpression implements FilterExpression {
- private final FilterExpression[] operands;
-
- public AndExpression(FilterExpression[] operands) {
- this.operands = operands;
- }
-
- public boolean matches(Map<String,String> map) {
- for (FilterExpression operand : operands) {
- if (!operand.matches(map)) {
- return false;
- }
- }
- return true;
- }
-}
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/EqualityExpression.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/EqualityExpression.java
deleted file mode 100644
index afc254b..0000000
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/EqualityExpression.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>equal</em> (<tt>=</tt>) operator.
- */
-public class EqualityExpression implements FilterExpression {
- private final String key;
- private final String value;
-
- public EqualityExpression(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- public boolean matches(Map<String,String> map) {
- return value.equals(map.get(key));
- }
-}
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpression.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpression.java
deleted file mode 100644
index 647a78c..0000000
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpression.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Interface representing an abstract filter expression.
- */
-public interface FilterExpression {
- /**
- * Evaluate the filter expression.
- *
- * @param map the data on which the filter expression is evaluated
- * @return true if the data matches the filter represented by this object
- */
- boolean matches(Map<String,String> map);
-}
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpressionParser.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpressionParser.java
deleted file mode 100644
index 7671ff4..0000000
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/FilterExpressionParser.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.text.ParseException;
-import java.util.List;
-
-import org.apache.directory.shared.ldap.filter.AndNode;
-import org.apache.directory.shared.ldap.filter.EqualityNode;
-import org.apache.directory.shared.ldap.filter.ExprNode;
-import org.apache.directory.shared.ldap.filter.FilterParser;
-import org.apache.directory.shared.ldap.filter.NotNode;
-import org.apache.directory.shared.ldap.filter.OrNode;
-import org.apache.directory.shared.ldap.filter.PresenceNode;
-
-/**
- * Parser for LDAP filter expressions.
- */
-public class FilterExpressionParser {
- private FilterExpressionParser() {}
-
- private static FilterExpression[] buildExpressions(List<ExprNode> nodes) {
- FilterExpression[] result = new FilterExpression[nodes.size()];
- int i = 0;
- for (ExprNode node : nodes) {
- result[i++] = buildExpression(node);
- }
- return result;
- }
-
- private static FilterExpression buildExpression(ExprNode node) {
- if (node instanceof AndNode) {
- return new
AndExpression(buildExpressions(((AndNode)node).getChildren()));
- } else if (node instanceof OrNode) {
- return new
OrExpression(buildExpressions(((OrNode)node).getChildren()));
- } else if (node instanceof NotNode) {
- return new
NotExpression(buildExpression(((NotNode)node).getFirstChild()));
- } else if (node instanceof EqualityNode) {
- EqualityNode equalityNode = (EqualityNode)node;
- return new EqualityExpression(equalityNode.getAttribute(),
equalityNode.getValue().toString());
- } else if (node instanceof PresenceNode) {
- return new PresenceExpression(((PresenceNode)node).getAttribute());
- } else {
- throw new UnsupportedOperationException("Node type " +
node.getClass().getSimpleName() + " not supported");
- }
- }
-
- /**
- * Parse an LDAP filter expression.
- *
- * @param filter an LDAP filter as defined by <a
href="http://www.ietf.org/rfc/rfc2254.txt">RFC2254</a>
- * @return the parsed filter
- * @throws ParseException if the filter is syntactically incorrect
- */
- public static FilterExpression parse(String filter) throws ParseException {
- return buildExpression(FilterParser.parse(filter));
- }
-}
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/NotExpression.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/NotExpression.java
deleted file mode 100644
index ccaf475..0000000
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/NotExpression.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>not</em> (<tt>!</tt>) operator.
- */
-public class NotExpression implements FilterExpression {
- private final FilterExpression operand;
-
- public NotExpression(FilterExpression operand) {
- this.operand = operand;
- }
-
- public boolean matches(Map<String,String> map) {
- return !operand.matches(map);
- }
-}
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/OrExpression.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/OrExpression.java
deleted file mode 100644
index 77d74c4..0000000
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/OrExpression.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>or</em> (<tt>|</tt>) operator.
- */
-public class OrExpression implements FilterExpression {
- private final FilterExpression[] operands;
-
- public OrExpression(FilterExpression[] operands) {
- this.operands = operands;
- }
-
- public boolean matches(Map<String,String> map) {
- for (FilterExpression operand : operands) {
- if (operand.matches(map)) {
- return true;
- }
- }
- return false;
- }
-}
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/PresenceExpression.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/PresenceExpression.java
deleted file mode 100644
index ccd6ef9..0000000
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/PresenceExpression.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.axis2.transport.testkit.filter;
-
-import java.util.Map;
-
-/**
- * Implementation of the <em>present</em> (<tt>=*</tt>) operator.
- */
-public class PresenceExpression implements FilterExpression {
- private final String key;
-
- public PresenceExpression(String key) {
- this.key = key;
- }
-
- public boolean matches(Map<String,String> map) {
- return map.containsKey(key);
- }
-}
diff --git
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/package-info.java
b/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/package-info.java
deleted file mode 100644
index 0a8c652..0000000
---
a/modules/transport/testkit/src/main/java/org/apache/axis2/transport/testkit/filter/package-info.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Provides classes to evaluate LDAP filters against {@link java.util.Map}
objects.
- * <p>
- * LDAP filter expressions are parsed using
- * {@link
org.apache.axis2.transport.testkit.filter.FilterExpressionParser#parse(String)}.
- * The resulting {@link
org.apache.axis2.transport.testkit.filter.FilterExpression} object can
- * then be used to evaluate the filter against a given {@link java.util.Map}
object.
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2254.txt">RFC2254: The String
Representation of LDAP Search Filters</a>
- */
-package org.apache.axis2.transport.testkit.filter;
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 0e77f73b..4938277 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1108,6 +1108,11 @@
<artifactId>javax.transaction-api</artifactId>
<version>1.3</version>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.framework</artifactId>
+ <version>1.10.0</version>
+ </dependency>
<dependency>
<groupId>commons-cli</groupId>