getting something to work

4 views
Skip to first unread message

William la Forge

unread,
May 18, 2013, 12:16:56 AM5/18/13
to AgileWikiDevelopers
I started stripping out code until the test would run. This was the critical piece that had to be removed:

        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>jactor-test-iface</artifactId>
            <version>${project.version}</version>
        </dependency>

Say what?


William la Forge

unread,
May 18, 2013, 12:26:32 AM5/18/13
to AgileWikiDevelopers
OK, so if the test sleeps long enough, a test can run. My plan now is to have a test driver bundle and in the test method, wait for that bundle to close.

Here's the test during sleep code. It runs at least:

@RunWith(JUnit4TestRunner.class)
@ExamReactorStrategy(AllConfinedStagedReactorFactory.class)
public class KarafWithBundleTest {

    @Inject
    private BundleContext bundleContext;

    @Configuration
    public Option[] config() {
        return new Option[]{karafDistributionConfiguration().frameworkUrl(
                maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("zip").versionAsInProject())
                .karafVersion("2.2.4").name("Apache Karaf"),

                logLevel(LogLevelOption.LogLevel.INFO),
                mavenBundle("org.agilewiki.jactor", "jactor-api", "0.0.1-SNAPSHOT"),
                mavenBundle("org.agilewiki.jactor", "jactor-impl", "0.0.1-SNAPSHOT"),
                mavenBundle("org.agilewiki.jactor", "jactor-util", "0.0.1-SNAPSHOT"),
                mavenBundle("org.agilewiki.jactor", "jactor-test-iface", "0.0.1-SNAPSHOT"),
                mavenBundle("org.agilewiki.jactor", "jactor-test-service", "0.0.1-SNAPSHOT")
        };
    }

    @Test
    public void test() throws Exception {
        System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbb");
        Thread.sleep(10000);
        System.out.println("ccccccccccccccccccccccccccc");
    }
}

William la Forge

unread,
May 18, 2013, 3:02:03 AM5/18/13
to AgileWikiDevelopers
Our test now completes when the jactor-test-service bundle stops. The next step will be to distinguish between a successful test and a failed test. Below is the current code. --b

    @Test
    public void test() throws Exception {
        System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbb");
        bundleContext.addBundleListener(this);
        synchronized(this) {
            wait(10000);
        }
        System.out.println("ccccccccccccccccccccccccccc");
    }

    @Override
    public void bundleChanged(BundleEvent bundleEvent) {
        if ( bundleEvent.getType() == BundleEvent.STOPPED) {
            if (bundleEvent.getBundle().getSymbolicName().equals("jactor-test-service")) {
                System.out.println("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz " + bundleEvent.getBundle().getSymbolicName());
                synchronized(this) {
                    this.notify();
                }
            }
        }
    }

Reply all
Reply to author
Forward
0 new messages