DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
Overview
Other MyFaces Extensions
- ExtVal
- Ext-Script
- [Orchestra]
- [Portlet Bridge]
Community
Development
Sponsorship
Your browser does not support iframes
DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
...
...
...
...
...
...
If
...
just
...
plain
...
unit
...
testing
...
is
...
needed
...
without
...
JEE
...
APIs
...
it's
...
possible
...
to
...
use
...
the AbstractCdiAwareTest
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
{{AbstractCdiAwareTest}} {code:java|title=Simple JUnit 4 test with dependency injection} @RunWith(JUnit4.class) public class SimpleJUnitTest extends org.apache.myfaces.extensions.cdi.test.junit4.AbstractCdiAwareTest { @Inject private Logger logger; @Test public void testLogger() { assertNotNull(this.logger); this.logger.info("I'm a JUnit test-case and I can use dependency injection!"); } } {code} h1. JUnit 4 for CDI |
...
...
If
...
it's
...
required
...
to
...
test
...
e.g.
...
request
...
scoped
...
beans
...
it's
...
possible
...
to
...
use
...
the AbstractServletAwareTest
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
{{AbstractServletAwareTest}} {code:java|title=Simple JUnit 4 test with dependency injection for the Servlet API} @RunWith(JUnit4.class) public class SimpleJUnitTest extends org.apache.myfaces.extensions.cdi.test.junit4.AbstractServletAwareTest { @Inject private RequestScopedBean requestScopedBean; @Test public void testLogger() { assertNotNull(this.requestScopedBean.getValue()); } } {code} |
If
...
it's
...
required
...
to
...
test
...
e.g.
...
grouped
...
conversation
...
scoped
...
beans
...
it's
...
possible
...
to
...
use
...
the AbstractServletAwareTest
| Code Block | ||||||
|---|---|---|---|---|---|---|
| ||||||
{{AbstractServletAwareTest}} {code:java|title=Simple JUnit 4 test with dependency injection for the JSF API} @RunWith(JUnit4.class) public class SimpleJUnitTest extends org.apache.myfaces.extensions.cdi.test.junit4.AbstractJsfAwareTest { @Inject private ViewAccessScopedBean viewAccessScopedBean; @Test public void testLogger() { assertNotNull(this.viewAccessScopedBean.getValue()); } } {code} h1. Needed modules and dependencies Because the |
Because the unit-test
...
modules
...
will
...
never
...
be
...
needed
...
in
...
production
...
builds,
...
you
...
have
...
to
...
add
...
the
...
CODI-test
...
modules
...
manually,
...
even
...
if
...
you
...
are
...
using
...
one
...
of
...
the
...
all-in-one
...
packages.
...
You'll
...
need
...
at
...
least
...
the
...
myfaces-extcdi-junit-support-module
...
for
...
general
...
JUnit
...
support.
...
And
...
depending
...
on
...
your
...
needs,
...
you'll
...
also
...
need
...
the
...
myfaces-extcdi-owb-support-module
...
and
...
myfaces-extcdi-jsf-support-module
...
.
...
Don't
...
forget
...
to
...
also
...
include
...
the
...
needed
...
(test)modules
...
of
...
the
...
CDI
...
implementation.
...
In
...
case
...
of
...
OWB,
...
you'll
...
need
...
cditest
...
and
...
cditest-owb
...
from
...
the
...
org.apache.openwebbeans.test
...
group.
...
For
...
convenience,
...
here's
...
a
...
pom-snippet
...
to
...
pick
...
the
...
needed
...
dependencies
...
from:
| Code Block | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
{code:xml|title=Snippet from {{
| }}
|
|
| ||||||||||
} <!-- JUnit --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> <version>${junit-version}</version> </dependency> <!-- CODI test modules --> <dependency> <groupId>org.apache.myfaces.extensions.cdi.test</groupId> <artifactId>myfaces-extcdi-junit-support-module</artifactId> <version>${myfaces.codi.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.myfaces.extensions.cdi.test</groupId> <artifactId>myfaces-extcdi-owb-support-module</artifactId> <version>${myfaces.codi.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.myfaces.extensions.cdi.test</groupId> <artifactId>myfaces-extcdi-jsf-support-module</artifactId> <version>${myfaces.codi.version}</version> <scope>test</scope> </dependency> <!-- the CODI myfaces-extcdi-jsf-support-module depends on myfaces-test --> <dependency> <groupId>org.apache.myfaces.test</groupId> <artifactId>myfaces-test12</artifactId> <version>1.0.0</version> <scope>test</scope> </dependency> <!-- needed by myfaces test --> <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.1.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.geronimo.specs</groupId> <artifactId>geronimo-el_1.0_spec</artifactId> <version>1.0.2</version> <scope>test</scope> </dependency> <!-- OWB test --> <dependency> <groupId>org.apache.openwebbeans.test</groupId> <artifactId>cditest</artifactId> <version>${owb.version}</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.openwebbeans.test</groupId> <artifactId>cditest-owb</artifactId> <version>${owb.version}</version> <scope>test</scope> </dependency> {code} h1. Examples An example is available [here|http://code.google.com/a/apache-extras.org/p/myfaces-codi-examples/source/browse/#hg%2Ftemplate] |
An example is available here.