[
https://issues.apache.org/jira/browse/ARIES-1091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13725621#comment-13725621
]
james strachan edited comment on ARIES-1091 at 7/31/13 7:28 PM:
----------------------------------------------------------------
Actually given the way blueprint-web tends to find XML files, its maybe better
to use an annotation to specify the names of files to search for on the
classpath or something. e.g. in hawtio we tend to just use the name
"OSGI-INF/blueprint/blueprint.xml" and we search for all of those names to find
the blueprint resources to boot up. Or maybe we could use a static method to
find all the URLs to use; then folks could find the files however they like?
Here's an example of a test case for using blueprint-web where we using a base
class approach (rather than JUnitRunner and injection of values)
https://github.com/hawtio/hawtio/blob/master/hawtio-file-dynamic-jaxb/src/test/java/io/hawt/jaxb/dynamic/file/BlueprintTestSupport.java#L49-49
So it might be nice to annotate static methods on the test class which define
the list of URLs to load and the Map of properties to use for configuration
parameters (which could be loaded from resource files or be generated
programatically).
e.g. maybe something like this (which could be on the base class for a test
class)...
{code}
@RunWith(BlueprintJUnitTestRunner.class)
public class MyTest {
@Inject BlueprintContainer blueprintContainer;
@Inject Cheese cheese;
/** Provides the list of URLs to load in the container */
@BlueprintUrls
public static URL[] blueprintUrls() { return { ... } }
/**
* Provides the environment properties to inject
* into the blueprint container for ${foo.bar} values */
*/
@BlueprintProperties
public static Map<String,String blueprintProperties() { return { ... } }
@Test
public void doTest() {
// use the injected values
}
}
{code}
was (Author: jstrachan):
Actually given the way blueprint-web tends to find XML files, its maybe
better to use an annotation to specify the names of files to search for on the
classpath or something. e.g. in hawtio we tend to just use the name
"OSGI-INF/blueprint/blueprint.xml" and we search for all of those names to find
the blueprint resources to boot up. Or maybe we could use a static method to
find all the URLs to use; then folks could find the files however they like?
Here's an example of a test case for using blueprint-web where we using a base
class approach (rather than JUnitRunner and injection of values)
https://github.com/hawtio/hawtio/blob/master/hawtio-file-dynamic-jaxb/src/test/java/io/hawt/jaxb/dynamic/file/BlueprintTestSupport.java#L49-49
So it might be nice to annotate static methods on the test class which define
the list of URLs to load and the Map of properties to use for configuration
parameters (which could be loaded from resource files or be generated
programatically).
> have a JUnit runner for blueprint-web like the spring test runners that
> create a BlueprintContainer and inject values from the container into the
> test case
> -----------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: ARIES-1091
> URL: https://issues.apache.org/jira/browse/ARIES-1091
> Project: Aries
> Issue Type: Improvement
> Components: Blueprint
> Reporter: james strachan
>
> it'd be nice to be able to write simple stand alone JUnit test cases that
> take a blueprint.xml file (by default called $ClassName-blueprint.xml) and
> inject values from the container. e.g.
> {code}
> @RunWith(BlueprintJUnitTestRunner.class)
> public class MyTest {
> @Inject BlueprintContainer blueprintContainer;
> @Inject Cheese cheese;
> @Test
> public void doTest() {
> // use the injected values
> }
> }
> {code}
> using the @Inject annotations from JSR 330
> http://jcp.org/en/jsr/detail?id=330
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira