-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
.../org/jboss/as/test/integration/ee/jndi/duplicate/DuplicateJNDIBindingCleanupTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023, 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.integration.ee.jndi.duplicate; | ||
|
||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; | ||
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployer; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.as.arquillian.api.ContainerResource; | ||
import org.jboss.as.arquillian.container.ManagementClient; | ||
import org.jboss.as.controller.PathAddress; | ||
import org.jboss.as.controller.PathElement; | ||
import org.jboss.as.controller.descriptions.ModelDescriptionConstants; | ||
import org.jboss.as.naming.management.JndiViewOperation; | ||
import org.jboss.dmr.ModelNode; | ||
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; | ||
|
||
/** | ||
* Deploy apps with same context to check if JNDI bindings are properly cleared on undeploy/failure. | ||
* | ||
* @author baranowb | ||
*/ | ||
@RunWith(Arquillian.class) | ||
@RunAsClient | ||
public class DuplicateJNDIBindingCleanupTestCase { | ||
private static final String APP1_ARCHIVE = "app-1"; | ||
private static final String APP2_ARCHIVE = "app-2"; | ||
|
||
@ArquillianResource | ||
private Deployer deployer; | ||
@ContainerResource | ||
ManagementClient managementClient; | ||
|
||
public static Archive<?> createDeployment(final String name) { | ||
final WebArchive war = ShrinkWrap.create(WebArchive.class, name + ".war"); | ||
war.addClasses(StatelessEJB.class, StatelessRemote.class); | ||
war.addAsWebInfResource(DuplicateJNDIBindingCleanupTestCase.class.getPackage(), "jboss-web.xml", "jboss-web.xml"); | ||
return war; | ||
} | ||
|
||
@Deployment(name = APP1_ARCHIVE, managed = false) | ||
public static Archive<?> createDeployment1() { | ||
return createDeployment(APP1_ARCHIVE); | ||
} | ||
|
||
@Deployment(name = APP2_ARCHIVE, managed = false) | ||
public static Archive<?> createDeployment2() { | ||
return createDeployment(APP2_ARCHIVE); | ||
} | ||
|
||
@Test | ||
public void testDeploy() throws Exception { | ||
deployer.deploy(APP1_ARCHIVE); | ||
try { | ||
deployer.deploy(APP2_ARCHIVE); | ||
} catch (Exception de) { | ||
} | ||
deployer.undeploy(APP1_ARCHIVE); | ||
deployer.undeploy(APP2_ARCHIVE); | ||
final ModelNode op = new ModelNode(); | ||
op.get(OP).set(JndiViewOperation.OPERATION_NAME); | ||
final ModelNode address = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, "naming")).toModelNode(); | ||
op.get(ModelDescriptionConstants.OP_ADDR).set(address); | ||
final ModelNode result = managementClient.getControllerClient().execute(op); | ||
// this should always be false, but lets test | ||
final ModelNode exported = result.get("result").get("java: contexts").get("java:jboss/exported"); | ||
Assert.assertFalse( | ||
"Failed to remove app exported context: " | ||
+ exported.keys(), | ||
exported.keys().contains(APP1_ARCHIVE)); | ||
Assert.assertFalse( | ||
"Failed to remove app exported context: " | ||
+ exported.keys(), | ||
exported.keys().contains(APP2_ARCHIVE)); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...ion/basic/src/test/java/org/jboss/as/test/integration/ee/jndi/duplicate/StatelessEJB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023, 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.integration.ee.jndi.duplicate; | ||
|
||
import jakarta.ejb.Stateless; | ||
|
||
@Stateless | ||
public class StatelessEJB implements StatelessRemote { | ||
public String hello(String name) { | ||
return "Hello " + name; | ||
} | ||
} | ||
|
29 changes: 29 additions & 0 deletions
29
.../basic/src/test/java/org/jboss/as/test/integration/ee/jndi/duplicate/StatelessRemote.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2023, 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.integration.ee.jndi.duplicate; | ||
|
||
import jakarta.ejb.Remote; | ||
|
||
@Remote | ||
public interface StatelessRemote { | ||
public String hello(String name); | ||
} |
4 changes: 4 additions & 0 deletions
4
...gration/basic/src/test/java/org/jboss/as/test/integration/ee/jndi/duplicate/jboss-web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<jboss-web> | ||
<context-root>app</context-root> | ||
</jboss-web> |