DELTASPIKE-479 added test
Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/c956c99b Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/c956c99b Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/c956c99b Branch: refs/heads/master Commit: c956c99b96f93d318a93a5c0961b73c7318d9ecb Parents: f93b669 Author: gpetracek <[email protected]> Authored: Thu Dec 26 00:08:24 2013 +0100 Committer: gpetracek <[email protected]> Committed: Thu Dec 26 00:23:38 2013 +0100 ---------------------------------------------------------------------- .../impl/jmx/SimpleRegistrationEarFileTest.java | 43 ++++++++++++++++++ .../core/impl/jmx/SimpleRegistrationTest.java | 23 +--------- .../impl/jmx/SimpleRegistrationWarFileTest.java | 47 ++++++++++++++++++++ 3 files changed, 91 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c956c99b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationEarFileTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationEarFileTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationEarFileTest.java new file mode 100644 index 0000000..2221363 --- /dev/null +++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationEarFileTest.java @@ -0,0 +1,43 @@ +/* + * 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.jmx; + +import org.apache.deltaspike.test.category.EnterpriseArchiveProfileCategory; +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.spec.EnterpriseArchive; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +@Category(EnterpriseArchiveProfileCategory.class) +public class SimpleRegistrationEarFileTest extends SimpleRegistrationTest +{ + @Deployment + public static EnterpriseArchive deployEar() + { + //workaround for tomee - the ear-file needs to have the same name as the war-file + String simpleName = SimpleRegistrationWarFileTest.class.getSimpleName(); + String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); + + return ShrinkWrap.create(EnterpriseArchive.class, archiveName + ".ear") + .addAsModule(SimpleRegistrationWarFileTest.deploy()); + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c956c99b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java index 800b6f7..db4005a 100644 --- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java +++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationTest.java @@ -18,15 +18,7 @@ */ package org.apache.deltaspike.test.core.impl.jmx; -import org.apache.deltaspike.test.util.ArchiveUtils; -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.JavaArchive; -import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; -import org.junit.runner.RunWith; import javax.inject.Inject; import javax.management.*; @@ -37,25 +29,12 @@ import java.util.Collection; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -@RunWith(Arquillian.class) -public class SimpleRegistrationTest { +public abstract class SimpleRegistrationTest { private static MBeanServer server = ManagementFactory.getPlatformMBeanServer(); @Inject private MyMBean myMBean; - @Deployment - public static WebArchive war() { - JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "simpleRegistrationTest.jar") - .addPackage(SimpleRegistrationTest.class.getPackage()) - .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); - - return ShrinkWrap.create(WebArchive.class, "simpleRegistrationTest.war") - .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) - .addAsLibraries(testJar) - .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); - } - @Test public void checkMBean() throws Exception { assertEquals(0, myMBean.getCounter()); http://git-wip-us.apache.org/repos/asf/deltaspike/blob/c956c99b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationWarFileTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationWarFileTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationWarFileTest.java new file mode 100644 index 0000000..813d88f --- /dev/null +++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/jmx/SimpleRegistrationWarFileTest.java @@ -0,0 +1,47 @@ +/* + * 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.jmx; + +import org.apache.deltaspike.test.util.ArchiveUtils; +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.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.junit.runner.RunWith; + +@RunWith(Arquillian.class) +public class SimpleRegistrationWarFileTest extends SimpleRegistrationTest +{ + @Deployment + public static WebArchive deploy() { + String simpleName = SimpleRegistrationWarFileTest.class.getSimpleName(); + String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1); + + JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, "simpleRegistrationTest.jar") + .addPackage(SimpleRegistrationWarFileTest.class.getPackage()) + .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); + + return ShrinkWrap.create(WebArchive.class, archiveName + ".war") + .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive()) + .addAsLibraries(testJar) + .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); + } +}
