Repository: deltaspike Updated Branches: refs/heads/master 043f33ebc -> 2c9a79d8b
DELTASPIKE-593 improved handling of internal packages Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/2c9a79d8 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/2c9a79d8 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/2c9a79d8 Branch: refs/heads/master Commit: 2c9a79d8b1bc6d5018032fd7fa95cb76f32c3803 Parents: 043f33e Author: gpetracek <[email protected]> Authored: Sat May 17 15:16:05 2014 +0200 Committer: gpetracek <[email protected]> Committed: Sat May 17 15:16:05 2014 +0200 ---------------------------------------------------------------------- deltaspike/modules/test-control/impl/pom.xml | 6 ++++ .../impl/mock/DefaultMockFilter.java | 9 +++++- .../InternalTestClassDeactivator.java | 33 ++++++++++++++++++++ .../testcontrol/InternalTestMockFilter.java | 3 +- .../META-INF/apache-deltaspike.properties | 18 +++++++++++ 5 files changed, 66 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2c9a79d8/deltaspike/modules/test-control/impl/pom.xml ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/pom.xml b/deltaspike/modules/test-control/impl/pom.xml index 8edb707..46514b2 100644 --- a/deltaspike/modules/test-control/impl/pom.xml +++ b/deltaspike/modules/test-control/impl/pom.xml @@ -106,6 +106,12 @@ <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> </dependency> + + <dependency> + <groupId>org.apache.deltaspike.core</groupId> + <artifactId>deltaspike-core-impl</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2c9a79d8/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java index 68c9f1e..71b215a 100644 --- a/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java +++ b/deltaspike/modules/test-control/impl/src/main/java/org/apache/deltaspike/testcontrol/impl/mock/DefaultMockFilter.java @@ -26,6 +26,7 @@ import javax.enterprise.inject.spi.AnnotatedType; public class DefaultMockFilter implements MockFilter { + private static final String DS_BASE_PACKAGE = "org.apache.deltaspike."; private static final String OWB_BASE_PACKAGE = "org.apache.webbeans."; private static final String WELD_BASE_PACKAGE = "org.jboss.weld."; @@ -48,6 +49,12 @@ public class DefaultMockFilter implements MockFilter protected boolean isInternalPackage(String packageName) { - return packageName.startsWith(OWB_BASE_PACKAGE) || packageName.startsWith(WELD_BASE_PACKAGE); + return packageName.startsWith(OWB_BASE_PACKAGE) || packageName.startsWith(WELD_BASE_PACKAGE) || + isDeltaSpikePackage(packageName); + } + + protected boolean isDeltaSpikePackage(String packageName) + { + return packageName.startsWith(DS_BASE_PACKAGE); } } http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2c9a79d8/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestClassDeactivator.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestClassDeactivator.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestClassDeactivator.java new file mode 100644 index 0000000..4474be5 --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestClassDeactivator.java @@ -0,0 +1,33 @@ +/* + * 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.deltaspike.test.testcontrol; + +import org.apache.deltaspike.core.spi.activation.ClassDeactivator; +import org.apache.deltaspike.core.spi.activation.Deactivatable; +import org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter; + +//just needed because the internal test-packages need to be handled differently +public class InternalTestClassDeactivator implements ClassDeactivator +{ + @Override + public Boolean isActivated(Class<? extends Deactivatable> targetClass) + { + return !DefaultMockFilter.class.equals(targetClass); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2c9a79d8/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestMockFilter.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestMockFilter.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestMockFilter.java index 1478293..242fbcf 100644 --- a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestMockFilter.java +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/InternalTestMockFilter.java @@ -22,11 +22,10 @@ import org.apache.deltaspike.testcontrol.impl.mock.DefaultMockFilter; public class InternalTestMockFilter extends DefaultMockFilter { - private static final String DS_BASE_PACKAGE = "org.apache.deltaspike."; private static final String DS_TEST_BASE_PACKAGE = "org.apache.deltaspike.test.testcontrol.mock."; protected boolean isInternalPackage(String packageName) { - return (packageName.startsWith(DS_BASE_PACKAGE) && !packageName.startsWith(DS_TEST_BASE_PACKAGE)); + return super.isInternalPackage(packageName) && !packageName.startsWith(DS_TEST_BASE_PACKAGE); } } http://git-wip-us.apache.org/repos/asf/deltaspike/blob/2c9a79d8/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties new file mode 100644 index 0000000..d299861 --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties @@ -0,0 +1,18 @@ +# 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. + +org.apache.deltaspike.core.spi.activation.ClassDeactivator=org.apache.deltaspike.test.testcontrol.InternalTestClassDeactivator
