-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Fixes #1622] Working Aries-CDI + JSF + Pax Web WAB scenario for Jett…
…y, Tomcat and Undertow
- Loading branch information
Showing
24 changed files
with
558 additions
and
225 deletions.
There are no files selected for viewing
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
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
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
69 changes: 69 additions & 0 deletions
69
...main/java/org/ops4j/pax/web/itest/container/war/jsf/AbstractWarJSFCdiIntegrationTest.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,69 @@ | ||
/* | ||
* Copyright 2021 OPS4J. | ||
* | ||
* Licensed 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.ops4j.pax.web.itest.container.war.jsf; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.ops4j.pax.web.itest.container.AbstractContainerTestBase; | ||
import org.ops4j.pax.web.itest.utils.client.HttpTestClientFactory; | ||
import org.ops4j.pax.web.service.spi.model.events.EventListenerEventData; | ||
import org.ops4j.pax.web.service.spi.model.events.WebElementEvent; | ||
|
||
public class AbstractWarJSFCdiIntegrationTest extends AbstractContainerTestBase { | ||
|
||
@Before | ||
public void setUp() { | ||
// simple waiting for deployment is not enough, because war-jsf23-cdi bundle is subject to CDI extension | ||
// as well. And because org.apache.aries.cdi.extension.servlet.weld whiteboard-registers | ||
// additional listener (org.jboss.weld.module.web.servlet.WeldInitialListener), the /war-jsf23-cdi | ||
// will be restarted | ||
configureAndWait(() -> { | ||
installAndStartBundle(sampleWarURI("war-jsf23-cdi")); | ||
}, events -> { | ||
// when the WAB is starting, the context will be deployed together with all the listeners and SCIs | ||
// but at the same time Aries CDI will be extending our WAB as well, registering a context listener | ||
// we can assume tha | ||
LOG.info("~~~ events: {}", events.size()); | ||
for (WebElementEvent ev : events) { | ||
if (ev.getType() == WebElementEvent.State.DEPLOYED && ev.getData() instanceof EventListenerEventData) { | ||
EventListenerEventData eled = (EventListenerEventData) ev.getData(); | ||
LOG.info("~~~ evd: {}/{} ({})", eled.getListener(), eled.getElementReference(), eled.getOriginBundle()); | ||
} | ||
} | ||
if (events.stream().filter(e -> e.getType() == WebElementEvent.State.DEPLOYED).count() >= 4) { | ||
// give it one more second... After all, we've only detected listener registrations | ||
try { | ||
Thread.sleep(1000); | ||
} catch (InterruptedException e) { | ||
LOG.error(e.getMessage(), e); | ||
Thread.currentThread().interrupt(); | ||
throw new RuntimeException(e.getMessage(), e); | ||
} | ||
return true; | ||
} | ||
return false; | ||
}); | ||
} | ||
|
||
@Test | ||
public void testCdi() throws Exception { | ||
HttpTestClientFactory.createDefaultTestClient() | ||
.withResponseAssertion("Response must contain 'hello from working JSF 2.3/CDI 2.0 example, org.ops4j.pax.url.commons.handler.HandlerActivator$Handler'", | ||
resp -> resp.contains("hello from working JSF 2.3/CDI 2.0 example, org.ops4j.pax.url.commons.handler.HandlerActivator$Handler")) | ||
.doGETandExecuteTest("http://127.0.0.1:8181/war-jsf23-cdi/"); | ||
} | ||
|
||
} |
29 changes: 0 additions & 29 deletions
29
...main/java/org/ops4j/pax/web/itest/container/war/jsf/AbstractWarJsfCdiIntegrationTest.java
This file was deleted.
Oops, something went wrong.
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
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
46 changes: 46 additions & 0 deletions
46
...tomcat/src/test/java/org/ops4j/pax/web/itest/tomcat/war/jsf/WarJSFCdiIntegrationTest.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,46 @@ | ||
/* | ||
* Copyright 2021 OPS4J. | ||
* | ||
* Licensed 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.ops4j.pax.web.itest.tomcat.war.jsf; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.ops4j.pax.exam.Configuration; | ||
import org.ops4j.pax.exam.Option; | ||
import org.ops4j.pax.exam.junit.PaxExam; | ||
import org.ops4j.pax.web.itest.container.war.jsf.AbstractWarJSFCdiIntegrationTest; | ||
|
||
import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackage; | ||
import static org.ops4j.pax.exam.CoreOptions.systemPackage; | ||
import static org.ops4j.pax.exam.OptionUtils.combine; | ||
|
||
@RunWith(PaxExam.class) | ||
public class WarJSFCdiIntegrationTest extends AbstractWarJSFCdiIntegrationTest { | ||
|
||
@Configuration | ||
public Option[] configure() { | ||
Option[] serverOptions = combine(baseConfigure(), paxWebTomcat()); | ||
// myfaces-core-api doesn't import javax.inject and I'm getting | ||
// WELD-001111: interface javax.faces.annotation.FlowMap defined on org.apache.myfaces.cdi.JsfArtifactFlowMapProducer@2143ca58 is not a qualifier | ||
// if javax.inject is available only as bundle (== is excluded from maven-failsafe-plugin test classpath) | ||
Option[] tweakOptions1 = combine(serverOptions, bootDelegationPackage("javax.inject")); | ||
Option[] tweakOptions2 = combine(tweakOptions1, systemPackage("javax.inject;version=\"1.0\"")); | ||
Option[] osgiOptions = combine(tweakOptions2, configAdmin()); | ||
Option[] whiteboardOptions = combine(osgiOptions, paxWebExtenderWhiteboard()); | ||
Option[] jspOptions = combine(whiteboardOptions, paxWebJsp()); | ||
Option[] cdiOptions = combine(jspOptions, ariesCdiAndMyfaces()); | ||
return combine(cdiOptions, paxWebExtenderWar()); | ||
} | ||
|
||
} |
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
46 changes: 46 additions & 0 deletions
46
...rtow/src/test/java/org/ops4j/pax/web/itest/undertow/war/jsf/WarJSFCdiIntegrationTest.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,46 @@ | ||
/* | ||
* Copyright 2021 OPS4J. | ||
* | ||
* Licensed 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.ops4j.pax.web.itest.undertow.war.jsf; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.ops4j.pax.exam.Configuration; | ||
import org.ops4j.pax.exam.Option; | ||
import org.ops4j.pax.exam.junit.PaxExam; | ||
import org.ops4j.pax.web.itest.container.war.jsf.AbstractWarJSFCdiIntegrationTest; | ||
|
||
import static org.ops4j.pax.exam.CoreOptions.bootDelegationPackage; | ||
import static org.ops4j.pax.exam.CoreOptions.systemPackage; | ||
import static org.ops4j.pax.exam.OptionUtils.combine; | ||
|
||
@RunWith(PaxExam.class) | ||
public class WarJSFCdiIntegrationTest extends AbstractWarJSFCdiIntegrationTest { | ||
|
||
@Configuration | ||
public Option[] configure() { | ||
Option[] serverOptions = combine(baseConfigure(), paxWebUndertow()); | ||
// myfaces-core-api doesn't import javax.inject and I'm getting | ||
// WELD-001111: interface javax.faces.annotation.FlowMap defined on org.apache.myfaces.cdi.JsfArtifactFlowMapProducer@2143ca58 is not a qualifier | ||
// if javax.inject is available only as bundle (== is excluded from maven-failsafe-plugin test classpath) | ||
Option[] tweakOptions1 = combine(serverOptions, bootDelegationPackage("javax.inject")); | ||
Option[] tweakOptions2 = combine(tweakOptions1, systemPackage("javax.inject;version=\"1.0\"")); | ||
Option[] osgiOptions = combine(tweakOptions2, configAdmin()); | ||
Option[] whiteboardOptions = combine(osgiOptions, paxWebExtenderWhiteboard()); | ||
Option[] jspOptions = combine(whiteboardOptions, paxWebJsp()); | ||
Option[] cdiOptions = combine(jspOptions, ariesCdiAndMyfaces()); | ||
return combine(cdiOptions, paxWebExtenderWar()); | ||
} | ||
|
||
} |
Oops, something went wrong.