You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2012/01/09 23:20:04 UTC
git commit: DELTASPIKE-25 tests for Deactivatable
Updated Branches:
refs/heads/master 2891d7bf0 -> e96fb016b
DELTASPIKE-25 tests for Deactivatable
Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/e96fb016
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/e96fb016
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/e96fb016
Branch: refs/heads/master
Commit: e96fb016bf233cfde72aa68027f980a8e95b24ef
Parents: 2891d7b
Author: gpetracek <gp...@apache.org>
Authored: Mon Jan 9 23:19:00 2012 +0100
Committer: gpetracek <gp...@apache.org>
Committed: Mon Jan 9 23:19:00 2012 +0100
----------------------------------------------------------------------
.../test/core/impl/activation/ActivatedClass.java | 26 +++++
.../core/impl/activation/DeactivatedClass.java | 26 +++++
.../impl/activation/TestClassDeactivation.java | 78 +++++++++++++++
.../core/impl/activation/TestClassDeactivator.java | 37 +++++++
.../META-INF/apache-deltaspike.properties | 3 +-
deltaspike/core/integration-test/pom.xml | 1 +
.../core/impl/activation/ActivatedClass.java | 26 +++++
.../core/impl/activation/DeactivatedClass.java | 26 +++++
.../impl/activation/TestClassDeactivation.java | 76 ++++++++++++++
.../core/impl/activation/TestClassDeactivator.java | 37 +++++++
10 files changed, 335 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java
new file mode 100644
index 0000000..4eb5fe7
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java
@@ -0,0 +1,26 @@
+/*
+ * 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.core.impl.activation;
+
+/**
+ * Class which isn't deactivated
+ */
+public class ActivatedClass
+{
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java
new file mode 100644
index 0000000..a8f1a62
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java
@@ -0,0 +1,26 @@
+/*
+ * 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.core.impl.activation;
+
+/**
+ * Class which is deactivated
+ */
+public class DeactivatedClass
+{
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java
new file mode 100644
index 0000000..fca5b45
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java
@@ -0,0 +1,78 @@
+/*
+ * 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.core.impl.activation;
+
+import org.apache.deltaspike.core.impl.util.ClassDeactivation;
+import org.apache.deltaspike.test.core.api.provider.TestBean;
+import org.apache.deltaspike.test.core.api.temptestutil.ShrinkWrapArchiveUtil;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * Test for {@link org.apache.deltaspike.core.api.activation.ClassDeactivator}
+ */
+@RunWith(Arquillian.class)
+public class TestClassDeactivation
+{
+ /**
+ *X TODO creating a WebArchive is only a workaround because JavaArchive cannot contain other archives.
+ */
+ @Deployment
+ public static WebArchive deploy()
+ {
+ URL fileUrl = TestClassDeactivation.class.getClassLoader()
+ .getResource("META-INF/apache-deltaspike.properties");
+
+ return ShrinkWrap.create(WebArchive.class)
+ .addAsLibraries(ShrinkWrapArchiveUtil.getArchives(null,
+ "META-INF/beans.xml",
+ new String[]{"org.apache.deltaspike.test.core.impl.activation"},
+ null))
+ .addClass(TestBean.class)
+ .addAsResource(new File(fileUrl.getFile()))
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ /**
+ * Tests if a class of the added package is active
+ */
+ @Test
+ public void testActivatedClass()
+ {
+ Assert.assertTrue(ClassDeactivation.isClassActivated(ActivatedClass.class));
+ }
+
+ /**
+ * Tests if the class deactivated by {@link TestClassDeactivator} is recognized as such
+ */
+ @Test
+ public void testDeactivatedClass()
+ {
+ Assert.assertFalse(ClassDeactivation.isClassActivated(DeactivatedClass.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java
new file mode 100644
index 0000000..2d7557f
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java
@@ -0,0 +1,37 @@
+/*
+ * 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.core.impl.activation;
+
+import org.apache.deltaspike.core.api.activation.AbstractClassDeactivator;
+
+/**
+ * Test {@link org.apache.deltaspike.core.api.activation.ClassDeactivator}
+ * which is needed to test {@link org.apache.deltaspike.core.impl.util.ClassDeactivation}
+ */
+public class TestClassDeactivator extends AbstractClassDeactivator
+{
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void deactivateClasses()
+ {
+ addDeactivatedClass(DeactivatedClass.class);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
index 48b9ad8..8ccced1 100644
--- a/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
+++ b/deltaspike/core/impl/src/test/resources/META-INF/apache-deltaspike.properties
@@ -15,4 +15,5 @@
#specific language governing permissions and limitations
#under the License.
-testProperty03=test_value_03
\ No newline at end of file
+testProperty03=test_value_03
+org.apache.deltaspike.core.api.activation.ClassDeactivator=org.apache.deltaspike.test.core.impl.activation.TestClassDeactivator
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/integration-test/pom.xml
----------------------------------------------------------------------
diff --git a/deltaspike/core/integration-test/pom.xml b/deltaspike/core/integration-test/pom.xml
index 905ca96..f580a38 100644
--- a/deltaspike/core/integration-test/pom.xml
+++ b/deltaspike/core/integration-test/pom.xml
@@ -53,6 +53,7 @@
<groupId>org.apache.deltaspike.core</groupId>
<artifactId>deltaspike-core-impl</artifactId>
<version>${project.version}</version>
+ <scope>compile</scope>
</dependency>
</dependencies>
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/ActivatedClass.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/ActivatedClass.java b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/ActivatedClass.java
new file mode 100644
index 0000000..8745463
--- /dev/null
+++ b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/ActivatedClass.java
@@ -0,0 +1,26 @@
+/*
+ * 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.integration.core.impl.activation;
+
+/**
+ * Class which isn't deactivated
+ */
+public class ActivatedClass
+{
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/DeactivatedClass.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/DeactivatedClass.java b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/DeactivatedClass.java
new file mode 100644
index 0000000..9868863
--- /dev/null
+++ b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/DeactivatedClass.java
@@ -0,0 +1,26 @@
+/*
+ * 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.integration.core.impl.activation;
+
+/**
+ * Class which is deactivated
+ */
+public class DeactivatedClass
+{
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/TestClassDeactivation.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/TestClassDeactivation.java b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/TestClassDeactivation.java
new file mode 100644
index 0000000..2d7dcff
--- /dev/null
+++ b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/TestClassDeactivation.java
@@ -0,0 +1,76 @@
+/*
+ * 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.integration.core.impl.activation;
+
+import org.apache.deltaspike.core.impl.util.ClassDeactivation;
+import org.apache.deltaspike.integration.testutil.ShrinkWrapArchiveUtil;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.io.File;
+import java.net.URL;
+
+/**
+ * Test for {@link org.apache.deltaspike.core.api.activation.ClassDeactivator}
+ */
+@RunWith(Arquillian.class)
+public class TestClassDeactivation
+{
+ /**
+ *X TODO creating a WebArchive is only a workaround because JavaArchive cannot contain other archives.
+ */
+ @Deployment
+ public static WebArchive deploy()
+ {
+ URL fileUrl = TestClassDeactivation.class.getClassLoader()
+ .getResource("META-INF/apache-deltaspike.properties");
+
+ return ShrinkWrap.create(WebArchive.class)
+ .addAsLibraries(ShrinkWrapArchiveUtil.getArchives(null,
+ "META-INF/beans.xml",
+ new String[]{"org.apache.deltaspike.test.core.impl.activation"},
+ null))
+ .addAsResource(new File(fileUrl.getFile()))
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ /**
+ * Tests if a class of the added package is active
+ */
+ @Test
+ public void testActivatedClass()
+ {
+ Assert.assertTrue(ClassDeactivation.isClassActivated(ActivatedClass.class));
+ }
+
+ /**
+ * Tests if the class deactivated by {@link TestClassDeactivator} is recognized as such
+ */
+ @Test
+ public void testDeactivatedClass()
+ {
+ Assert.assertFalse(ClassDeactivation.isClassActivated(DeactivatedClass.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e96fb016/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/TestClassDeactivator.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/TestClassDeactivator.java b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/TestClassDeactivator.java
new file mode 100644
index 0000000..09db7ff
--- /dev/null
+++ b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/impl/activation/TestClassDeactivator.java
@@ -0,0 +1,37 @@
+/*
+ * 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.integration.core.impl.activation;
+
+import org.apache.deltaspike.core.api.activation.AbstractClassDeactivator;
+
+/**
+ * Test {@link org.apache.deltaspike.core.api.activation.ClassDeactivator}
+ * which is needed to test {@link org.apache.deltaspike.core.impl.util.ClassDeactivation}
+ */
+public class TestClassDeactivator extends AbstractClassDeactivator
+{
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void deactivateClasses()
+ {
+ addDeactivatedClass(DeactivatedClass.class);
+ }
+}