org.jboss.arquillian.api.Deployment



API Populatity

1 Client projects

Project: org.jboss

Project wildfly/wildfly in file ...r.EarJbossStructureExtendedVisibilityTestCase.java (2011-04-05)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.testsuite.integration.deployment.classloading.ear;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests the extended-class-visibility option in jboss-structure.xml
+ *
+ * By default ejb-jar's should not be visible to each other, with this option enabled they are.
+ *
+ */
+@RunWith(Arquillian.class)
+public class EarJbossStructureExtendedVisibilityTestCase {
+
+    @Deployment
+    public static Archive<?> deploy() {
+
+        EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class);
+
+        WebArchive war = ShrinkWrap.create(WebArchive.class,"test.war");
+        war.addClasses(TestAA.class);
+        ear.addModule(war);
+
+        JavaArchive ejb = ShrinkWrap.create(JavaArchive.class, "ejb1.jar");
+        ejb.addClasses(MyEjb.class, EarJbossStructureExtendedVisibilityTestCase.class);
+        ear.addModule(ejb);
+
+        ejb = ShrinkWrap.create(JavaArchive.class, "ejb2.jar");
+        ejb.addClasses(MyEjb2.class);
+        ear.addModule(ejb);
+
+        ear.addManifestResource(new StringAsset(
+               "<jboss-deployment-structure><extended-class-visibility>true</extended-class-visibility></jboss-deployment-structure>"),
+                "jboss-deployment-structure.xml");
+
+        return ear;
+    }
+
+    @Test(expected = ClassNotFoundException.class)
+    public void testWarModuleStillNotAccessible() throws ClassNotFoundException {
+        loadClass("org.jboss.as.testsuite.integration.deployment.classloading.ear.TestAA",getClass().getClassLoader());
+    }
+
+    @Test
+    public void testOtherEjbJarAcessible() throws ClassNotFoundException {
+        loadClass("org.jboss.as.testsuite.integration.deployment.classloading.ear.MyEjb2",getClass().getClassLoader());
+    }
+
+
+    private static Class<?> loadClass(String name, ClassLoader cl) throws ClassNotFoundException {
+        if (cl != null) {
+            return Class.forName(name, false, cl);
+        } else
+            return Class.forName(name);
+    }
+}
Project wildfly/wildfly in file ...urce.superclass.BindingsOnInterceptorTestCase.java (2011-03-30)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.as.testsuite.integration.injection.resource.superclass;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * Tests that @Resource bindings on interceptors that are applied to multiple
+ * components without their own naming context work properly, and do not try
+ * and create two duplicate bindings in the same namespace.
+ *
+ * @author Stuart Douglas
+ */
+@RunWith(Arquillian.class)
+public class BindingsOnInterceptorTestCase {
+
+    @Deployment
+    public static Archive<?> deployment() {
+        WebArchive war = ShrinkWrap.create(WebArchive.class, "multiple-bindings-superclass.war");
+        war.addClasses(Bean1.class, Bean2.class, BindingsOnInterceptorTestCase.class, SuperBean.class, SimpleManagedBean.class);
+        return war;
+    }
+
+    @Test
+    public void testCorrectBinding() throws NamingException {
+        InitialContext context = new InitialContext();
+        Object result = context.lookup("java:module/env/" + SuperBean.class.getName() + "/simpleManagedBean");
+        Assert.assertTrue(result instanceof SimpleManagedBean);
+    }
+
+
+    @Test
+    public void testSubClass1Injected() throws NamingException {
+        InitialContext context = new InitialContext();
+        Bean1 result = (Bean1) context.lookup("java:module/bean1");
+        Assert.assertTrue(result.getBean() instanceof SimpleManagedBean);
+    }
+
+    @Test
+    public void testSubClass2Injected() throws NamingException {
+        InitialContext context = new InitialContext();
+        Bean2 result = (Bean2) context.lookup("java:module/bean2");
+        Assert.assertTrue(result.getBean() instanceof SimpleManagedBean);
+    }
+
+
+}
Project wildfly/wildfly in file ...bedded.mgmt.DataSourcesOperationsUnitTestCase.java (2011-05-31)
@@ -0,0 +1,176 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.test.embedded.mgmt;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ATTRIBUTES;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DESCRIPTION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILED;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_DESCRIPTION_OPERATION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import junit.framework.Assert;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.api.Run;
+import org.jboss.arquillian.api.RunModeType;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.protocol.StreamUtils;
+import org.jboss.as.test.modular.utils.ShrinkWrapUtils;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.Property;
+import org.jboss.shrinkwrap.api.Archive;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Basic management operation unit test.
+ * @author Emanuel Muckenhuber
+ */
+@RunWith(Arquillian.class)
+@Run(RunModeType.AS_CLIENT)
+public class DataSourcesOperationsUnitTestCase {
+
+    private ModelControllerClient client;
+
+    @Deployment
+    public static Archive<?> getDeployment() {
+        return ShrinkWrapUtils.createEmptyJavaArchive("dummy");
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        this.client = ModelControllerClient.Factory.create(InetAddress.getByName("localhost"), 9999);
+    }
+
+    @After
+    public void tearDown() {
+        StreamUtils.safeClose(client);
+    }
+
+    @Test
+    public void testReadChildrenResources() throws IOException {
+
+        final ModelNode address = new ModelNode();
+        address.add("subsystem", "datasources");
+        address.protect();
+
+        final ModelNode operation = new ModelNode();
+        operation.get(OP).set("read-children-resources");
+        operation.get("child-type").set("data-source");
+        operation.get(OP_ADDR).set(address);
+
+        final ModelNode result = client.execute(operation);
+        Assert.assertTrue(result.hasDefined(RESULT));
+        Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+        final Map<String, ModelNode> children = getChildren(result.get(RESULT));
+        Assert.assertFalse(children.isEmpty());
+        for (final Entry<String, ModelNode> child : children.entrySet()) {
+            Assert.assertTrue(child.getKey() != null);
+            Assert.assertTrue(child.getValue().hasDefined("connection-url"));
+            Assert.assertTrue(child.getValue().hasDefined("jndi-name"));
+            Assert.assertTrue(child.getValue().hasDefined("driver-name"));
+        }
+    }
+
+    @Test
+    public void testAddDsAndTestConnection() throws IOException {
+
+        final ModelNode address = new ModelNode();
+        address.add("subsystem", "datasources");
+        address.add("data-source", "MyNewDs");
+        address.protect();
+
+        final ModelNode operation = new ModelNode();
+        operation.get(OP).set("add");
+        operation.get(OP_ADDR).set(address);
+
+        operation.get("name").set("MyNewDs");
+        operation.get("jndi-name").set("java:/MyNewDs");
+        operation.get("enabled").set(true);
+
+        operation.get("driver-name").set("h2");
+        operation.get("pool-name").set("MyNewDs_Pool");
+
+        operation.get("connection-url").set("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
+        operation.get("user-name").set("sa");
+        operation.get("password").set("sa");
+
+        final ModelNode result = client.execute(operation);
+        Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+
+        final ModelNode address2 = new ModelNode();
+        address2.add("subsystem", "datasources");
+        address2.add("data-source", "MyNewDs");
+        address2.protect();
+
+        final ModelNode operation2 = new ModelNode();
+        operation2.get(OP).set("test-connection-in-pool");
+        operation2.get(OP_ADDR).set(address2);
+
+        final ModelNode result2 = client.execute(operation2);
+        Assert.assertEquals(SUCCESS, result2.get(OUTCOME).asString());
+
+    }
+
+    static void assertSuccessful(final ModelNode result) {
+        Assert.assertEquals(SUCCESS, result.get(OUTCOME).asString());
+        Assert.assertTrue(result.hasDefined(RESULT));
+    }
+
+    static ModelNode createReadAttributeOperation(final ModelNode address, final String attributeName) {
+        final ModelNode operation = new ModelNode();
+        operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
+        operation.get(OP_ADDR).set(address);
+        operation.get(NAME).set(attributeName);
+        return operation;
+    }
+
+    protected static Map<String, ModelNode> getChildren(final ModelNode result) {
+        Assert.assertTrue(result.isDefined());
+        final Map<String, ModelNode> steps = new HashMap<String, ModelNode>();
+        for (final Property property : result.asPropertyList()) {
+            steps.put(property.getName(), property.getValue());
+        }
+        return steps;
+    }
+
+}