You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by ant elder <an...@gmail.com> on 2008/12/10 14:29:58 UTC
Re: Testcase templates? was: Re: Activities in Trunk - was: svn commit: r723136 - in /tuscany/java/sca: distribution/core/pom.xml modules/pom.xml
A simple easy way to create a started node, what a great idea ;)
Would be good to add something like this to the API instead of needing a
helper. Maybe we could consider the current node APIs more of an SPI and
create an easy to use client API.
...ant
On Wed, Dec 10, 2008 at 1:48 AM, Raymond Feng <en...@gmail.com> wrote:
> Hi,
>
> It might be a good idea to define a set of templates to shield the test
> cases from the environment-specific node configuration and lifecycle. This
> way, the test cases can be simpler and it's possible to run them with
> different environment (JSE or OSGi) by switching the base.
>
> We could define two modules tuscany-test and tuscany-test-equinox to host
> the base test cases. Other itests can add them as test dependencies in
> pom.xml.
>
> The following code is something I tried locally. But I have some issues
> getting the @BeforeClass and @AfterClass version going as JUNIT tries to run
> these methods even before the static initializer of a class is called.
>
> Thanks,
> Raymond
>
> /**
> * Base Node API based test case
> */
> public abstract class NodeTestCase {
> protected final Logger logger = Logger.getLogger(getClass().getName());
> protected String compositeResource;
> protected Node node;
>
> protected NodeTestCase(String compositeResource) {
> super();
> this.compositeResource = compositeResource;
> }
>
> @Before
> public void setUp() throws Exception {
> try {
> String location =
> ContributionLocationHelper.getContributionLocation(compositeResource);
> Contribution contribution = new Contribution(location, location);
> NodeFactory factory = NodeFactory.newInstance();
> node = factory.createNode(compositeResource, contribution);
> node.start();
> } catch (Exception e) {
> logger.log(Level.SEVERE, e.getMessage(), e);
> throw e;
> }
> }
>
> @After
> public void tearDown() throws Exception {
> if (node != null) {
> node.stop();
> }
> }
> }
>
> --------------------------------------------------
> From: "Mike Edwards" <mi...@gmail.com>
> Sent: Friday, December 05, 2008 1:06 PM
> To: <de...@tuscany.apache.org>
> Subject: Activities in Trunk - was: svn commit: r723136 - in
> /tuscany/java/sca: distribution/core/pom.xml modules/pom.xml
>
> [[SNIP]]
>
>
>> So far, it is mostly a case of tweak, tweak, tweak, adjusting dependencies
>> and OSGi MANIFEST files, but in a few cases, the 2.0 APIs are different from
>> the 1.x APIs and some changes are needed - this often affects testcases more
>> than mainline module code. One lesson from this is that I think we should
>> consider creating a tests-utils module to contain some of the sequences that
>> tests seem to need commonly - and to hide the testcase code from changes in
>> the base platform.
>>
>>
>> Yours, Mike.
>>
>
>