Skip to content

Commit

Permalink
Merge pull request #11809 from JiriOndrusek/JBEAP-15758_ignore-depend…
Browse files Browse the repository at this point in the history
…ency-does-not-work

[WFLY-11282] ignore-dependency in jboss-web.xml does not work
  • Loading branch information
kabir committed Nov 13, 2018
2 parents 31eccfa + ab23ee3 commit 6dff5bd
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ private List<BindingConfiguration> getResourceEnvRefEntries(final DeploymentUnit
return bindings;
}
for (ResourceEnvironmentReferenceMetaData resourceEnvRef : resourceEnvRefs) {
if(resourceEnvRef.isDependencyIgnored()) {
continue;
}
final String name;
if (resourceEnvRef.getName().startsWith("java:")) {
name = resourceEnvRef.getName();
Expand Down Expand Up @@ -139,6 +142,9 @@ private List<BindingConfiguration> getResourceRefEntries(final DeploymentUnit de
return bindings;
}
for (final ResourceReferenceMetaData resourceRef : resourceRefs) {
if(resourceRef.isDependencyIgnored()) {
continue;
}
final String name;
if (resourceRef.getName().startsWith("java:")) {
name = resourceRef.getName();
Expand Down Expand Up @@ -225,6 +231,9 @@ private List<BindingConfiguration> getEnvironmentEntries(final DeploymentDescrip
return bindings;
}
for (final EnvironmentEntryMetaData envEntry : envEntries) {
if(envEntry.isDependencyIgnored()) {
continue;
}
final String name;
if (envEntry.getName().startsWith("java:")) {
name = envEntry.getName();
Expand Down Expand Up @@ -310,6 +319,9 @@ private List<BindingConfiguration> getMessageDestinationRefs(final DeploymentDes
return bindings;
}
for (final MessageDestinationReferenceMetaData messageRef : messageDestinationReferences) {
if(messageRef.isDependencyIgnored()) {
continue;
}
final String name;
if (messageRef.getName().startsWith("java:")) {
name = messageRef.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.net.URL;

import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import javax.naming.NamingException;
import javax.sql.DataSource;

Expand Down Expand Up @@ -64,6 +65,7 @@ public static Archive<?> deployment() {

WebArchive war = ShrinkWrap.create(WebArchive.class, "managed-bean.war");
war.addAsWebInfResource(ResourceRefTestCase.class.getPackage(),"web.xml", "web.xml");
war.addAsWebInfResource(ResourceRefTestCase.class.getPackage(),"jboss-web.xml", "jboss-web.xml");
war.addClasses(ResourceRefTestCase.class, DatasourceManagedBean.class, CreateQueueSetupTask.class);

JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "resource-ref-test.jar");
Expand All @@ -84,6 +86,12 @@ public void testCorrectBinding() throws NamingException {
Assert.assertTrue(result instanceof DataSource);
}

@Test(expected = NameNotFoundException.class)
public void testIgnoredDependency() throws NamingException {
InitialContext context = new InitialContext();
context.lookup("java:module/env/ds-ignored");
}

@Test
public void testInjection() throws NamingException {
InitialContext context = new InitialContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/j2ee/schema/jboss-web_7_2.xsd"
version="7.2">

<resource-ref>
<res-ref-name>ds-ignored</res-ref-name>
<ignore-dependency/>
</resource-ref>

</jboss-web>

Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@
</injection-target>
</resource-ref>

<resource-ref>
<res-ref-name>ds-ignored</res-ref-name>
<lookup-name>java:jboss/datasources/ExampleDS</lookup-name>
</resource-ref>

</web-app>

0 comments on commit 6dff5bd

Please sign in to comment.