You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2019/10/17 14:05:37 UTC

[sling-org-apache-sling-feature-analyser] branch master updated: SLING-8784 : Move api regions analysers to api regions extension

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-analyser.git


The following commit(s) were added to refs/heads/master by this push:
     new f635bb3  SLING-8784 : Move api regions analysers to api regions extension
f635bb3 is described below

commit f635bb3286fb8ec0fa24c4f396b294a0caa51b59
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Thu Oct 17 15:26:58 2019 +0200

    SLING-8784 : Move api regions analysers to api regions extension
---
 .../task/impl/AbstractApiRegionsAnalyserTask.java  |  68 --------
 .../analyser/task/impl/CheckApiRegions.java        |  82 ---------
 .../task/impl/CheckApiRegionsDependencies.java     |  92 ----------
 .../task/impl/CheckApiRegionsDuplicates.java       |  82 ---------
 .../analyser/task/impl/CheckApiRegionsOrder.java   | 128 --------------
 .../scanner/impl/ApiRegionsExtensionScanner.java   |  56 ------
 ...apache.sling.feature.analyser.task.AnalyserTask |   4 -
 ...ache.sling.feature.scanner.spi.ExtensionScanner |   1 -
 .../impl/AbstractApiRegionsAnalyserTaskTest.java   | 191 ---------------------
 .../task/impl/AnalyzerTaskProviderTest.java        |  36 +---
 .../task/impl/CheckApiRegionsDependenciesTest.java |  59 -------
 .../task/impl/CheckApiRegionsDuplicatesTest.java   |  46 -----
 .../task/impl/CheckApiRegionsOrderTest.java        | 156 -----------------
 .../analyser/task/impl/CheckApiRegionsTest.java    |  49 ------
 .../task/impl/CheckBundleExportsImportsTest.java   |  29 ++--
 15 files changed, 23 insertions(+), 1056 deletions(-)

diff --git a/src/main/java/org/apache/sling/feature/analyser/task/impl/AbstractApiRegionsAnalyserTask.java b/src/main/java/org/apache/sling/feature/analyser/task/impl/AbstractApiRegionsAnalyserTask.java
deleted file mode 100644
index d6b1d80..0000000
--- a/src/main/java/org/apache/sling/feature/analyser/task/impl/AbstractApiRegionsAnalyserTask.java
+++ /dev/null
@@ -1,68 +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.sling.feature.analyser.task.impl;
-
-import javax.json.stream.JsonParsingException;
-
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Extensions;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.analyser.task.AnalyserTask;
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-
-public abstract class AbstractApiRegionsAnalyserTask implements AnalyserTask {
-
-    protected static final String API_REGIONS_KEY = "api-regions";
-
-    @Override
-    public final void execute(AnalyserTaskContext ctx) throws Exception {
-        Feature feature = ctx.getFeature();
-
-        // extract and check the api-regions
-
-        Extensions extensions = feature.getExtensions();
-        Extension apiRegionsExtension = extensions.getByName(API_REGIONS_KEY);
-        if (apiRegionsExtension == null) {
-            // no need to be analyzed
-            return;
-        }
-
-        String jsonRepresentation = apiRegionsExtension.getJSON();
-        if (jsonRepresentation == null || jsonRepresentation.isEmpty()) {
-            // no need to be analyzed
-            return;
-        }
-
-        // read the api-regions and create a Sieve data structure for checks
-
-        ApiRegions apiRegions;
-        try {
-            apiRegions = ApiRegions.fromJson(jsonRepresentation);
-        } catch (JsonParsingException e) {
-            ctx.reportError("API Regions '"
-                    + jsonRepresentation
-                    + "' does not represent a valid JSON 'api-regions': "
-                    + e.getMessage());
-            return;
-        }
-
-        execute(apiRegions, ctx);
-    }
-
-    protected abstract void execute(ApiRegions apiRegions, AnalyserTaskContext ctx) throws Exception;
-
-}
diff --git a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegions.java b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegions.java
deleted file mode 100644
index 6ea7f82..0000000
--- a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegions.java
+++ /dev/null
@@ -1,82 +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.sling.feature.analyser.task.impl;
-
-import java.util.Collection;
-import java.util.Formatter;
-import java.util.Set;
-
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-import org.apache.sling.feature.scanner.BundleDescriptor;
-import org.apache.sling.feature.scanner.FeatureDescriptor;
-import org.apache.sling.feature.scanner.PackageInfo;
-
-public class CheckApiRegions extends AbstractApiRegionsAnalyserTask {
-
-    @Override
-    public String getId() {
-        return API_REGIONS_KEY;
-    }
-
-    @Override
-    public String getName() {
-        return "Api Regions analyser task";
-    }
-
-    @Override
-    protected void execute(ApiRegions apiRegions, AnalyserTaskContext ctx) throws Exception {
-        // for each bundle, get the Export-Package and process the packages
-
-        FeatureDescriptor featureDescriptor = ctx.getFeatureDescriptor();
-        for (BundleDescriptor bundleDescriptor : featureDescriptor.getBundleDescriptors()) {
-            for (PackageInfo packageInfo : bundleDescriptor.getExportedPackages()) {
-                String exportedPackage = packageInfo.getName();
-                // use the Sieve technique: remove bundle exported packages from the api-regions
-                apiRegions.remove(exportedPackage);
-            }
-        }
-
-        // final evaluation: if the Sieve is not empty, not all declared packages are exported by bundles of the same feature
-        if (!apiRegions.isEmpty()) {
-            // track a single error for each region
-            for (String region : apiRegions.getRegions()) {
-                Set<String> apis = apiRegions.getApis(region);
-                if (!apis.isEmpty()) {
-                    Formatter formatter = new Formatter();
-                    formatter.format("Region '%s' defined in feature '%s' declares %s package%s which %s not exported by any bundle:%n",
-                                     region,
-                                     ctx.getFeature().getId(),
-                                     apis.size(),
-                                     getExtension(apis, "", "s"),
-                                     getExtension(apis, "is", "are"));
-                    apis.forEach(api -> formatter.format(" * %s%n", api));
-
-                    ctx.reportError(formatter.toString());
-
-                    formatter.close();
-                }
-            }
-        }
-    }
-
-    // utility methods
-
-    private static <T> String getExtension(Collection<T> collection, String singular, String plural) {
-        return collection.size() > 1 ? plural : singular;
-    }
-
-}
diff --git a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependencies.java b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependencies.java
deleted file mode 100644
index 7d4f049..0000000
--- a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependencies.java
+++ /dev/null
@@ -1,92 +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.sling.feature.analyser.task.impl;
-
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-import org.apache.sling.feature.scanner.BundleDescriptor;
-import org.apache.sling.feature.scanner.FeatureDescriptor;
-import org.apache.sling.feature.scanner.PackageInfo;
-import org.osgi.framework.Constants;
-
-import java.util.List;
-import java.util.Set;
-
-public class CheckApiRegionsDependencies extends AbstractApiRegionsAnalyserTask {
-
-    @Override
-    public String getId() {
-        return API_REGIONS_KEY + "-dependencies";
-    }
-
-    @Override
-    public String getName() {
-        return "Api Regions dependecies analyser task";
-    }
-
-    @Override
-    protected void execute(ApiRegions apiRegions, AnalyserTaskContext ctx) throws Exception {
-        List<String> regions = apiRegions.getRegions();
-
-        for (int i=0; i < regions.size(); i++) {
-            for (int j=i+1; j < regions.size(); j++) {
-                execute(ctx, apiRegions, regions.get(i), regions.get(j));
-            }
-        }
-    }
-
-    private void execute(AnalyserTaskContext ctx, ApiRegions apiRegions, String exportingApisName, String hidingApisName) {
-        Set<String> exportingApis = apiRegions.getApis(exportingApisName);
-        Set<String> hidingApis = apiRegions.getApis(hidingApisName);
-
-        FeatureDescriptor featureDescriptor = ctx.getFeatureDescriptor();
-        for (BundleDescriptor bundleDescriptor : featureDescriptor.getBundleDescriptors()) {
-            for (PackageInfo packageInfo : bundleDescriptor.getExportedPackages()) {
-                String exportedPackage = packageInfo.getName();
-
-                if (exportingApis.contains(exportedPackage)) {
-                    if (hidingApis.contains(exportedPackage)) {
-                        String errorMessage = String.format(
-                                "Bundle '%s' (defined in feature '%s') declares '%s' in the '%s' header that is enlisted in both exporting '%s' and hiding '%s' APIs regions, please adjust Feature settings",
-                                bundleDescriptor.getArtifact().getId(),
-                                ctx.getFeature().getId(),
-                                exportedPackage,
-                                Constants.EXPORT_PACKAGE,
-                                exportingApisName,
-                                hidingApisName);
-                        ctx.reportError(errorMessage);
-                    } else {
-                        for (String uses : packageInfo.getUses()) {
-                            if (hidingApis.contains(uses)) {
-                                String errorMessage = String.format(
-                                        "Bundle '%s' (defined in feature '%s') declares '%s' in the '%s' header, enlisted in the '%s' region, which uses '%s' package that is in the '%s' region",
-                                        bundleDescriptor.getArtifact().getId(),
-                                        ctx.getFeature().getId(),
-                                        exportedPackage,
-                                        Constants.EXPORT_PACKAGE,
-                                        exportingApisName,
-                                        uses,
-                                        hidingApisName);
-                                ctx.reportError(errorMessage);
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-}
diff --git a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDuplicates.java b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDuplicates.java
deleted file mode 100644
index 4ab2bbd..0000000
--- a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDuplicates.java
+++ /dev/null
@@ -1,82 +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.sling.feature.analyser.task.impl;
-
-import java.util.ArrayList;
-import java.util.Formatter;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-
-public class CheckApiRegionsDuplicates extends AbstractApiRegionsAnalyserTask {
-
-    @Override
-    public String getId() {
-        return API_REGIONS_KEY + "-duplicates";
-    }
-
-    @Override
-    public String getName() {
-        return "Api Regions duplicates analyser task";
-    }
-
-    @Override
-    protected void execute(ApiRegions apiRegions, AnalyserTaskContext ctx) throws Exception {
-        List<String> sourceRegions = new ArrayList<>(apiRegions.getRegions());
-
-        for (int i = 0; i < sourceRegions.size(); i++) {
-            String sourceRegion = sourceRegions.get(i);
-            List<String> targetRegions = sourceRegions.subList(i + 1, sourceRegions.size());
-
-            for (String targetRegion : targetRegions) {
-                if (sourceRegion.equals(targetRegion)) {
-                    continue;
-                }
-
-                Set<String> intersection = calculateIntersection(apiRegions.getApis(sourceRegion), apiRegions.getApis(targetRegion));
-                if (!intersection.isEmpty()) {
-                    Formatter formatter = new Formatter();
-                    formatter.format("Regions '%s' and '%s' defined in feature '%s' declare both %s package(s):%n",
-                                     sourceRegion,
-                                     targetRegion,
-                                     ctx.getFeature().getId(),
-                                     intersection.size());
-                    intersection.forEach(api -> formatter.format(" * %s%n", api));
-
-                    ctx.reportError(formatter.toString());
-
-                    formatter.close();
-                }
-            }
-        }
-    }
-
-    private static Set<String> calculateIntersection(Set<String> source, Set<String> target) {
-        final Set<String> intersection = new HashSet<>();
-
-        for (String packageName : source) {
-            if (target.contains(packageName)) {
-                intersection.add(packageName);
-            }
-        }
-
-        return intersection;
-    }
-
-}
diff --git a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsOrder.java b/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsOrder.java
deleted file mode 100644
index cc9408b..0000000
--- a/src/main/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsOrder.java
+++ /dev/null
@@ -1,128 +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.sling.feature.analyser.task.impl;
-
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Extensions;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.analyser.task.AnalyserTask;
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.json.Json;
-import javax.json.stream.JsonParser;
-import javax.json.stream.JsonParser.Event;
-
-public class CheckApiRegionsOrder implements AnalyserTask {
-    protected static final String API_REGIONS_KEY = "api-regions";
-
-    @Override
-    public String getId() {
-        return "api-regions-check-order";
-    }
-
-    @Override
-    public String getName() {
-        return "Api Regions check order analyser task";
-    }
-
-    @Override
-    public final void execute(AnalyserTaskContext ctx) throws Exception {
-        String order = ctx.getConfiguration().get("order");
-        Feature feature = ctx.getFeature();
-        if (feature == null) {
-            reportError(ctx, "No feature found. Illegal Analyser State.");
-            return;
-        }
-
-        if (order == null) {
-            reportError(ctx, "This analyser task must be configured: " + getId() + " for feature " + feature.getId());
-            reportError(ctx, "Must specify configuration key 'order'.");
-            return;
-        }
-
-        String[] sl = order.split("[,]");
-        List<String> prescribedOrder = new ArrayList<>();
-        for (String s : sl) {
-            s = s.trim();
-            if (s.length() > 0)
-                prescribedOrder.add(s);
-        }
-        if (prescribedOrder.size() == 0) {
-            reportError(ctx, "No regions declared in the 'order' configuration");
-            return;
-        }
-
-        // extract and check the api-regions
-        Extensions extensions = feature.getExtensions();
-        Extension apiRegionsExtension = extensions.getByName(API_REGIONS_KEY);
-        if (apiRegionsExtension == null) {
-            // no need to be analyzed
-            return;
-        }
-
-        String jsonRepresentation = apiRegionsExtension.getJSON();
-        if (jsonRepresentation == null || jsonRepresentation.isEmpty()) {
-            // no need to be analyzed
-            return;
-        }
-
-        int regionIdx = 0;
-        JsonParser parser = Json.createParser(new StringReader(jsonRepresentation));
-        while (parser.hasNext()) {
-            Event event = parser.next();
-            if (Event.KEY_NAME == event) {
-                switch (parser.getString()) {
-                case "name":
-                    parser.next();
-                    String name = parser.getString();
-                    if (!prescribedOrder.contains(name)) {
-                        reportError(ctx, "Region found with undeclared name: " + name);
-                        return;
-                    }
-                    int prevIdx = regionIdx;
-                    regionIdx = validateRegion(regionIdx, prescribedOrder, name);
-                    if (regionIdx < 0) {
-                        reportError(ctx, "Region '" + name + "' appears in the wrong order. It appears after '"
-                                + prescribedOrder.get(prevIdx) + "'. Order of regions should be " + prescribedOrder);
-                        return;
-                    }
-                }
-            }
-        }
-    }
-
-    private int validateRegion(int regionIdx, List<String> order, String name) {
-        for (int i=regionIdx; i<order.size(); i++) {
-            if (name.equals(order.get(i))) {
-                return i;
-            }
-        }
-        return -1;
-    }
-
-    private String getPrefix() {
-        return getId() + ": ";
-    }
-
-    private void reportError(AnalyserTaskContext ctx, String err) {
-        ctx.reportError(getPrefix() + err);
-    }
-}
diff --git a/src/main/java/org/apache/sling/feature/scanner/impl/ApiRegionsExtensionScanner.java b/src/main/java/org/apache/sling/feature/scanner/impl/ApiRegionsExtensionScanner.java
deleted file mode 100644
index 0483854..0000000
--- a/src/main/java/org/apache/sling/feature/scanner/impl/ApiRegionsExtensionScanner.java
+++ /dev/null
@@ -1,56 +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.sling.feature.scanner.impl;
-
-import java.io.IOException;
-import java.net.URL;
-
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.builder.ArtifactProvider;
-import org.apache.sling.feature.scanner.BundleDescriptor;
-import org.apache.sling.feature.scanner.ContainerDescriptor;
-import org.apache.sling.feature.scanner.FeatureDescriptor;
-import org.apache.sling.feature.scanner.spi.ExtensionScanner;
-
-public class ApiRegionsExtensionScanner implements ExtensionScanner {
-
-    @Override
-    public String getId() {
-        return "api-regions";
-    }
-
-    @Override
-    public String getName() {
-        return "Api Regions extention scanner";
-    }
-
-    @Override
-    public ContainerDescriptor scan(Feature feature, Extension extension, ArtifactProvider provider) throws IOException {
-        FeatureDescriptor featureDescriptor = new FeatureDescriptorImpl(feature);
-
-        for (Artifact artifact : feature.getBundles()) {
-            URL file = provider.provide(artifact.getId());
-            BundleDescriptor bundleDescriptor = new BundleDescriptorImpl(artifact, file, artifact.getStartOrder());
-            featureDescriptor.getBundleDescriptors().add(bundleDescriptor);
-        }
-
-        return featureDescriptor;
-    }
-
-}
diff --git a/src/main/resources/META-INF/services/org.apache.sling.feature.analyser.task.AnalyserTask b/src/main/resources/META-INF/services/org.apache.sling.feature.analyser.task.AnalyserTask
index 42c29dd..0da2434 100644
--- a/src/main/resources/META-INF/services/org.apache.sling.feature.analyser.task.AnalyserTask
+++ b/src/main/resources/META-INF/services/org.apache.sling.feature.analyser.task.AnalyserTask
@@ -3,8 +3,4 @@ org.apache.sling.feature.analyser.task.impl.CheckBundlesForConnect
 org.apache.sling.feature.analyser.task.impl.CheckBundlesForInitialContent
 org.apache.sling.feature.analyser.task.impl.CheckBundlesForResources
 org.apache.sling.feature.analyser.task.impl.CheckRequirementsCapabilities
-org.apache.sling.feature.analyser.task.impl.CheckApiRegions
-org.apache.sling.feature.analyser.task.impl.CheckApiRegionsDependencies
-org.apache.sling.feature.analyser.task.impl.CheckApiRegionsDuplicates
-org.apache.sling.feature.analyser.task.impl.CheckApiRegionsOrder
 org.apache.sling.feature.analyser.task.impl.CheckContentPackagesDependencies
diff --git a/src/main/resources/META-INF/services/org.apache.sling.feature.scanner.spi.ExtensionScanner b/src/main/resources/META-INF/services/org.apache.sling.feature.scanner.spi.ExtensionScanner
index 528834d..ab52792 100644
--- a/src/main/resources/META-INF/services/org.apache.sling.feature.scanner.spi.ExtensionScanner
+++ b/src/main/resources/META-INF/services/org.apache.sling.feature.scanner.spi.ExtensionScanner
@@ -1,3 +1,2 @@
 org.apache.sling.feature.scanner.impl.ContentPackagesExtensionScanner
 org.apache.sling.feature.scanner.impl.RepoInitScanner
-org.apache.sling.feature.scanner.impl.ApiRegionsExtensionScanner
diff --git a/src/test/java/org/apache/sling/feature/analyser/task/impl/AbstractApiRegionsAnalyserTaskTest.java b/src/test/java/org/apache/sling/feature/analyser/task/impl/AbstractApiRegionsAnalyserTaskTest.java
deleted file mode 100644
index b67fcb8..0000000
--- a/src/test/java/org/apache/sling/feature/analyser/task/impl/AbstractApiRegionsAnalyserTaskTest.java
+++ /dev/null
@@ -1,191 +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.sling.feature.analyser.task.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-import java.net.URL;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.jar.Manifest;
-
-import org.apache.sling.feature.Artifact;
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.Extensions;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.analyser.task.AnalyserTask;
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-import org.apache.sling.feature.scanner.BundleDescriptor;
-import org.apache.sling.feature.scanner.FeatureDescriptor;
-import org.apache.sling.feature.scanner.PackageInfo;
-import org.apache.sling.feature.scanner.impl.FeatureDescriptorImpl;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
-
-public abstract class AbstractApiRegionsAnalyserTaskTest<T extends AbstractApiRegionsAnalyserTask> {
-
-    protected abstract T newTask();
-
-    private AnalyserTask analyserTask;
-
-    @Before
-    public void setUp() {
-        analyserTask = newTask();
-    }
-
-    @After
-    public void tearDown() {
-        analyserTask = null;
-    }
-
-    @Test
-    public void testNoApiRegionsExtension() throws Exception {
-        List<String> errors = execute((Extension) null);
-        assertTrue(errors.isEmpty());
-    }
-
-    @Test
-    public void testNullApiRegionsJSON() throws Exception {
-        List<String> errors = execute((String) null);
-        assertTrue(errors.isEmpty());
-    }
-
-    @Test
-    public void testEmptyApiRegionsJSON() throws Exception {
-        List<String> errors = execute("");
-        assertTrue(errors.isEmpty());
-    }
-
-    @Test
-    public void testApiRegionsIsNotJSON() throws Exception {
-        List<String> errors = execute("this is not a JSON string");
-
-        assertFalse(errors.isEmpty());
-        assertTrue(errors.iterator().next().contains("does not represent a valid JSON 'api-regions'"));
-    }
-
-    protected final List<String> execute(String apiRegionJSON) throws Exception {
-        Extension extension = mock(Extension.class);
-        when(extension.getJSON()).thenReturn(apiRegionJSON);
-
-        return execute(extension);
-    }
-
-    protected final List<String> execute(Extension extension) throws Exception {
-        Extensions extensions = mock(Extensions.class);
-        when(extensions.getByName("api-regions")).thenReturn(extension);
-
-        Feature feature = mock(Feature.class);
-        when(feature.getId()).thenReturn(new ArtifactId("org.apache.sling.testing",
-                                                        "org.apache.sling.testing.apiregions",
-                                                        "1.0.0",
-                                                        null,
-                                                        null));
-        when(feature.getExtensions()).thenReturn(extensions);
-
-        AnalyserTaskContext ctx = mock(AnalyserTaskContext.class);
-        when(ctx.getFeature()).thenReturn(feature);
-        @SuppressWarnings("unchecked")
-        Map<String,String> cfg = Mockito.mock(Map.class);
-        when(ctx.getConfiguration()).thenReturn(cfg);
-        when(cfg.getOrDefault(anyString(), anyString())).thenAnswer(new Answer<String>() {
-
-            @Override
-            public String answer(InvocationOnMock invocation) throws Throwable {
-                Object[] args = invocation.getArguments();
-                return (String) args[1];
-            }
-
-        });
-
-        PackageInfo packageInfo = new PackageInfo("org.osgi.util.function", "1.0", false, Collections.singleton("org.objectweb.asm"));
-
-        BundleDescriptor bundleDescriptor = new TestBundleDescriptor();
-        bundleDescriptor.getExportedPackages().add(packageInfo);
-
-        FeatureDescriptor featureDescriptor = new FeatureDescriptorImpl(feature);
-        featureDescriptor.getBundleDescriptors().add(bundleDescriptor);
-
-        when(ctx.getFeatureDescriptor()).thenReturn(featureDescriptor);
-
-        List<String> errors = new LinkedList<>();
-        doAnswer(invocation -> {
-            String error = invocation.getArgument(0);
-            errors.add(error);
-            return null;
-        }).when(ctx).reportError(anyString());
-
-        analyserTask.execute(ctx);
-
-        return errors;
-    }
-
-    private static final class TestBundleDescriptor extends BundleDescriptor {
-        TestBundleDescriptor() {
-            super("org.osgi:org.osgi.util.function:1.0.0");
-        }
-
-        @Override
-        public URL getArtifactFile() {
-            // do nothing
-            return null;
-        }
-
-        @Override
-        public Artifact getArtifact() {
-            return new Artifact(ArtifactId.fromMvnId("org.osgi:org.osgi.util.function:1.0.0"));
-        }
-
-        @Override
-        public Manifest getManifest() {
-            // do nothing
-            return null;
-        }
-
-        @Override
-        public String getBundleVersion() {
-            // do nothing
-            return null;
-        }
-
-        @Override
-        public String getBundleSymbolicName() {
-            // do nothing
-            return null;
-        }
-
-        @Override
-        public int getBundleStartLevel() {
-            // do nothing
-            return 0;
-        }
-
-    }
-
-}
diff --git a/src/test/java/org/apache/sling/feature/analyser/task/impl/AnalyzerTaskProviderTest.java b/src/test/java/org/apache/sling/feature/analyser/task/impl/AnalyzerTaskProviderTest.java
index ad29369..cec3f0a 100644
--- a/src/test/java/org/apache/sling/feature/analyser/task/impl/AnalyzerTaskProviderTest.java
+++ b/src/test/java/org/apache/sling/feature/analyser/task/impl/AnalyzerTaskProviderTest.java
@@ -18,18 +18,18 @@
  */
 package org.apache.sling.feature.analyser.task.impl;
 
-import org.apache.sling.feature.analyser.task.AnalyserTask;
-import org.junit.Test;
+import static org.apache.sling.feature.analyser.task.AnalyzerTaskProvider.getTasks;
+import static org.apache.sling.feature.analyser.task.AnalyzerTaskProvider.getTasksByClassName;
+import static org.apache.sling.feature.analyser.task.AnalyzerTaskProvider.getTasksByIds;
+import static org.junit.Assert.assertEquals;
 
 import java.io.IOException;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.ServiceLoader;
 
-import static org.apache.sling.feature.analyser.task.AnalyzerTaskProvider.getTasks;
-import static org.apache.sling.feature.analyser.task.AnalyzerTaskProvider.getTasksByClassName;
-import static org.apache.sling.feature.analyser.task.AnalyzerTaskProvider.getTasksByIds;
-import static org.junit.Assert.assertEquals;
+import org.apache.sling.feature.analyser.task.AnalyserTask;
+import org.junit.Test;
 
 public final class AnalyzerTaskProviderTest {
 
@@ -59,30 +59,10 @@ public final class AnalyzerTaskProviderTest {
     }
 
     @Test
-    public void loadCheckApiRegionsonly() throws Exception {
-        int expected = 1;
-        int actual = getTasksByClassName("org.apache.sling.feature.analyser.task.impl.CheckApiRegions").length;
-        assertEquals(expected, actual);
-    }
-
-    @Test
-    public void includeCheckApiRegionsonly() throws Exception {
-        int expected = 1;
-        int actual = getTasksByIds(Collections.singleton("api-regions"), null).length;
-        assertEquals(expected, actual);
-    }
-
-    @Test
-    public void excludeCheckApiRegionsonly() throws Exception {
-        int expected = allTasks() - 1;
-        int actual = getTasksByIds(null, Collections.singleton("api-regions")).length;
-        assertEquals(expected, actual);
-    }
-
-    @Test
     public void doesNotincludeAnything() throws Exception {
         int expected = 0;
-        int actual = getTasksByIds(Collections.singleton("api-regions"), Collections.singleton("api-regions")).length;
+        int actual = getTasksByIds(Collections.singleton("bundle-packages"),
+                Collections.singleton("bundle-packages")).length;
         assertEquals(expected, actual);
     }
 
diff --git a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependenciesTest.java b/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependenciesTest.java
deleted file mode 100644
index 617408c..0000000
--- a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDependenciesTest.java
+++ /dev/null
@@ -1,59 +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.sling.feature.analyser.task.impl;
-
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class CheckApiRegionsDependenciesTest extends AbstractApiRegionsAnalyserTaskTest<CheckApiRegionsDependencies> {
-
-    @Override
-    protected CheckApiRegionsDependencies newTask() {
-        return new CheckApiRegionsDependencies();
-    }
-
-    @Test
-    public void testNotValidApiRegionJson() throws Exception {
-        List<String> errors = execute("[{\"name\": \"global\",\"exports\": [\"org.osgi.util.function\"]},{\"name\": \"deprecated\",\"exports\": [\"org.objectweb.asm\"]}]");
-
-        assertFalse(errors.isEmpty());
-        assertTrue(errors.iterator()
-                .next()
-                .equals("Bundle 'org.osgi:org.osgi.util.function:1.0.0' (defined in feature 'org.apache.sling.testing:org.apache.sling.testing.apiregions:1.0.0') declares 'org.osgi.util.function' in the 'Export-Package' header, enlisted in the 'global' region, which uses 'org.objectweb.asm' package that is in the 'deprecated' region"));
-    }
-
-    @Test
-    public void testPackageEnlistedInBothRegions() throws Exception {
-        List<String> errors = execute("[{\"name\": \"global\",\"exports\": [\"org.osgi.util.function\"]},{\"name\": \"deprecated\",\"exports\": [\"org.osgi.util.function\"]}]");
-
-        assertFalse(errors.isEmpty());
-        assertTrue(errors.iterator()
-                .next()
-                .equals("Bundle 'org.osgi:org.osgi.util.function:1.0.0' (defined in feature 'org.apache.sling.testing:org.apache.sling.testing.apiregions:1.0.0') declares 'org.osgi.util.function' in the 'Export-Package' header that is enlisted in both exporting 'global' and hiding 'deprecated' APIs regions, please adjust Feature settings"));
-    }
-
-    @Test
-    public void testValidApiRegionJson() throws Exception {
-        List<String> errors = execute("[{\"name\": \"global\",\"exports\": [\"org.osgi.util.function\"]}]");
-        assertTrue(errors.isEmpty());
-    }
-
-}
diff --git a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDuplicatesTest.java b/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDuplicatesTest.java
deleted file mode 100644
index 77ddea7..0000000
--- a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsDuplicatesTest.java
+++ /dev/null
@@ -1,46 +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.sling.feature.analyser.task.impl;
-
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class CheckApiRegionsDuplicatesTest extends AbstractApiRegionsAnalyserTaskTest<CheckApiRegionsDuplicates> {
-
-    @Override
-    protected CheckApiRegionsDuplicates newTask() {
-        return new CheckApiRegionsDuplicates();
-    }
-
-    @Test
-    public void testDetectDuplicates() throws Exception {
-        List<String> errors = execute("[{\"name\": \"global\",\"exports\": [\"org.osgi.util.function\"]},{\"name\": \"deprecated\",\"exports\": [\"org.osgi.util.function\"]}]");
-
-        assertFalse(errors.isEmpty());
-        assertEquals(1, errors.size());
-        System.out.println(errors);
-        assertTrue(errors.iterator()
-                .next()
-                .startsWith("Regions 'global' and 'deprecated' defined in feature 'org.apache.sling.testing:org.apache.sling.testing.apiregions:1.0.0' declare both 1 package(s)"));
-    }
-
-}
diff --git a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsOrderTest.java b/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsOrderTest.java
deleted file mode 100644
index 65a7d88..0000000
--- a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsOrderTest.java
+++ /dev/null
@@ -1,156 +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.sling.feature.analyser.task.impl;
-
-import org.apache.sling.feature.ArtifactId;
-import org.apache.sling.feature.Extension;
-import org.apache.sling.feature.ExtensionType;
-import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
-import org.junit.Test;
-import org.mockito.Mockito;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class CheckApiRegionsOrderTest  {
-    @Test
-    public void testValidOrder() throws Exception {
-        CheckApiRegionsOrder caro = new CheckApiRegionsOrder();
-
-        Extension e = new Extension(ExtensionType.JSON, "api-regions", false);
-        e.setJSON("[{\"name\":\"deprecated\","
-                + "\"exports\": [\"a.b.c\"]},"
-                + "{\"name\":\"internal\","
-                + "\"exports\": [\"d.e.f\"]},"
-                + "{\"name\":\"internal\","
-                + "\"exports\": [\"g.h.i\"]}]");
-
-        Feature f = new Feature(ArtifactId.fromMvnId("a:b:1"));
-        f.getExtensions().add(e);
-
-        Map<String, String> cfgMap = new HashMap<>();
-        cfgMap.put("order", "deprecated, internal ");
-
-        AnalyserTaskContext ctx = Mockito.mock(AnalyserTaskContext.class);
-        Mockito.when(ctx.getConfiguration()).thenReturn(cfgMap);
-        Mockito.when(ctx.getFeature()).thenReturn(f);
-
-        caro.execute(ctx);
-        Mockito.verify(ctx, Mockito.never()).reportError(Mockito.anyString());
-    }
-
-    @Test
-    public void testInvalidOrder() throws Exception {
-        CheckApiRegionsOrder caro = new CheckApiRegionsOrder();
-
-        Extension e = new Extension(ExtensionType.JSON, "api-regions", false);
-        e.setJSON("[{\"name\":\"deprecated\","
-                + "\"exports\": [\"a.b.c\"]},"
-                + "{\"name\":\"internal\","
-                + "\"exports\": [\"d.e.f\"]},"
-                + "{\"name\":\"deprecated\","
-                + "\"exports\": [\"g.h.i\"]}]");
-
-        Feature f = new Feature(ArtifactId.fromMvnId("a:b:1"));
-        f.getExtensions().add(e);
-
-        Map<String, String> cfgMap = new HashMap<>();
-        cfgMap.put("order", "deprecated, internal ");
-
-        AnalyserTaskContext ctx = Mockito.mock(AnalyserTaskContext.class);
-        Mockito.when(ctx.getConfiguration()).thenReturn(cfgMap);
-        Mockito.when(ctx.getFeature()).thenReturn(f);
-
-        caro.execute(ctx);
-        Mockito.verify(ctx).reportError(Mockito.contains("wrong order"));
-    }
-
-    @Test
-    public void testInvalidRegion() throws Exception {
-        CheckApiRegionsOrder caro = new CheckApiRegionsOrder();
-
-        Extension e = new Extension(ExtensionType.JSON, "api-regions", false);
-        e.setJSON("[{\"name\":\"foo\"}]");
-
-        Feature f = new Feature(ArtifactId.fromMvnId("a:b:1"));
-        f.getExtensions().add(e);
-
-        Map<String, String> cfgMap = new HashMap<>();
-        cfgMap.put("order", "bar");
-
-        AnalyserTaskContext ctx = Mockito.mock(AnalyserTaskContext.class);
-        Mockito.when(ctx.getConfiguration()).thenReturn(cfgMap);
-        Mockito.when(ctx.getFeature()).thenReturn(f);
-
-        caro.execute(ctx);
-        Mockito.verify(ctx).reportError(Mockito.contains("undeclared"));
-    }
-
-    @Test
-    public void testNoExtensionsIsValid() throws Exception {
-        CheckApiRegionsOrder caro = new CheckApiRegionsOrder();
-
-        Map<String, String> cfgMap = new HashMap<>();
-        cfgMap.put("order", "deprecated, internal ");
-
-        AnalyserTaskContext ctx = Mockito.mock(AnalyserTaskContext.class);
-        Mockito.when(ctx.getConfiguration()).thenReturn(cfgMap);
-        Mockito.when(ctx.getFeature()).thenReturn(new Feature(ArtifactId.fromMvnId("a:b:1")));
-
-        caro.execute(ctx);
-        Mockito.verify(ctx, Mockito.never()).reportError(Mockito.anyString());
-    }
-
-    @Test
-    public void testEmptyOrder() throws Exception {
-        CheckApiRegionsOrder caro = new CheckApiRegionsOrder();
-
-        Map<String, String> cfgMap = new HashMap<>();
-        cfgMap.put("order", " ");
-
-        AnalyserTaskContext ctx = Mockito.mock(AnalyserTaskContext.class);
-        Mockito.when(ctx.getConfiguration()).thenReturn(cfgMap);
-        Mockito.when(ctx.getFeature()).thenReturn(new Feature(ArtifactId.fromMvnId("a:b:1")));
-
-        caro.execute(ctx);
-        Mockito.verify(ctx).reportError(Mockito.contains("No regions"));
-    }
-
-    @Test
-    public void testNoFeature() throws Exception {
-        CheckApiRegionsOrder caro = new CheckApiRegionsOrder();
-
-        AnalyserTaskContext ctx = Mockito.mock(AnalyserTaskContext.class);
-        Mockito.when(ctx.getConfiguration()).thenReturn(new HashMap<>());
-
-        caro.execute(ctx);
-        Mockito.verify(ctx).reportError(Mockito.contains("No feature"));
-    }
-
-    @Test
-    public void testNoOrderConfig() throws Exception {
-        CheckApiRegionsOrder caro = new CheckApiRegionsOrder();
-
-        AnalyserTaskContext ctx = Mockito.mock(AnalyserTaskContext.class);
-        Mockito.when(ctx.getConfiguration()).thenReturn(new HashMap<>());
-        Mockito.when(ctx.getFeature()).thenReturn(new Feature(ArtifactId.fromMvnId("a:b:1")));
-
-        caro.execute(ctx);
-        Mockito.verify(ctx).reportError(Mockito.contains("'order'"));
-    }
-}
diff --git a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsTest.java b/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsTest.java
deleted file mode 100644
index ab73570..0000000
--- a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckApiRegionsTest.java
+++ /dev/null
@@ -1,49 +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.sling.feature.analyser.task.impl;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.junit.Test;
-
-public class CheckApiRegionsTest extends AbstractApiRegionsAnalyserTaskTest<CheckApiRegions> {
-
-    @Override
-    protected CheckApiRegions newTask() {
-        return new CheckApiRegions();
-    }
-
-    @Test
-    public void testNotValidApiRegionJson() throws Exception {
-        List<String> errors = execute("[{\"name\": \"global\",\"exports\": [\"org.osgi.util.function.doesnotexist\"]}]");
-
-        assertFalse(errors.isEmpty());
-        assertTrue(errors.iterator()
-                .next()
-                .startsWith("Region 'global' defined in feature 'org.apache.sling.testing:org.apache.sling.testing.apiregions:1.0.0' declares 1 package which is not exported by any bundle"));
-    }
-
-    @Test
-    public void testValidApiRegionJson() throws Exception {
-        List<String> errors = execute("[{\"name\": \"global\",\"exports\": [\"org.osgi.util.function\"]}]");
-        assertTrue(errors.isEmpty());
-    }
-
-}
diff --git a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImportsTest.java b/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImportsTest.java
index 8a89863..3cb451a 100644
--- a/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImportsTest.java
+++ b/src/test/java/org/apache/sling/feature/analyser/task/impl/CheckBundleExportsImportsTest.java
@@ -18,9 +18,18 @@
  */
 package org.apache.sling.feature.analyser.task.impl;
 
+import static org.junit.Assert.assertEquals;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.sling.feature.Artifact;
 import org.apache.sling.feature.ArtifactId;
 import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.ExtensionState;
 import org.apache.sling.feature.ExtensionType;
 import org.apache.sling.feature.Feature;
 import org.apache.sling.feature.analyser.task.AnalyserTaskContext;
@@ -32,14 +41,6 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.Mockito;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
 public class CheckBundleExportsImportsTest {
     private static File resourceRoot;
 
@@ -135,7 +136,7 @@ public class CheckBundleExportsImportsTest {
         CheckBundleExportsImports t = new CheckBundleExportsImports();
 
         Feature f = new Feature(ArtifactId.fromMvnId("f:f:1"));
-        Extension ex = new Extension(ExtensionType.JSON, "api-regions", false);
+        Extension ex = new Extension(ExtensionType.JSON, "api-regions", ExtensionState.OPTIONAL);
         ex.setJSON(exJson);
         f.getExtensions().add(ex);
 
@@ -168,7 +169,7 @@ public class CheckBundleExportsImportsTest {
         CheckBundleExportsImports t = new CheckBundleExportsImports();
 
         Feature f = new Feature(ArtifactId.fromMvnId("f:f:1"));
-        Extension ex = new Extension(ExtensionType.JSON, "api-regions", false);
+        Extension ex = new Extension(ExtensionType.JSON, "api-regions", ExtensionState.OPTIONAL);
         ex.setJSON(exJson);
         f.getExtensions().add(ex);
 
@@ -206,7 +207,7 @@ public class CheckBundleExportsImportsTest {
         CheckBundleExportsImports t = new CheckBundleExportsImports();
 
         Feature f = new Feature(ArtifactId.fromMvnId("f:f:1"));
-        Extension ex = new Extension(ExtensionType.JSON, "api-regions", false);
+        Extension ex = new Extension(ExtensionType.JSON, "api-regions", ExtensionState.OPTIONAL);
         ex.setJSON(exJson);
         f.getExtensions().add(ex);
 
@@ -241,7 +242,7 @@ public class CheckBundleExportsImportsTest {
         CheckBundleExportsImports t = new CheckBundleExportsImports();
 
         Feature f = new Feature(ArtifactId.fromMvnId("f:f:2"));
-        Extension ex = new Extension(ExtensionType.JSON, "api-regions", false);
+        Extension ex = new Extension(ExtensionType.JSON, "api-regions", ExtensionState.OPTIONAL);
         ex.setJSON(exJson);
         f.getExtensions().add(ex);
 
@@ -274,7 +275,7 @@ public class CheckBundleExportsImportsTest {
         CheckBundleExportsImports t = new CheckBundleExportsImports();
 
         Feature f = new Feature(ArtifactId.fromMvnId("f:f:1"));
-        Extension ex = new Extension(ExtensionType.JSON, "api-regions", false);
+        Extension ex = new Extension(ExtensionType.JSON, "api-regions", ExtensionState.OPTIONAL);
         ex.setJSON(exJson);
         f.getExtensions().add(ex);
 
@@ -306,7 +307,7 @@ public class CheckBundleExportsImportsTest {
         CheckBundleExportsImports t = new CheckBundleExportsImports();
 
         Feature f = new Feature(ArtifactId.fromMvnId("f:f:1"));
-        Extension ex = new Extension(ExtensionType.JSON, "api-regions", false);
+        Extension ex = new Extension(ExtensionType.JSON, "api-regions", ExtensionState.OPTIONAL);
         ex.setJSON(exJson);
         f.getExtensions().add(ex);