Running DbEnvironmentFactoryTest in Eclipse

143 views
Skip to first unread message

Pralhad Kamath

unread,
May 24, 2013, 12:28:09 PM5/24/13
to db...@googlegroups.com
Hi,

I am using Win7 and Eclipse  Juno Service Release 2

I am not able to run directly my SybaseIQDbEnvironmentFactoyTest. ( I am porting Dbfit for Sybase IQ database) I get the following error.

java.lang.IllegalArgumentException: DB Environment not supported:SybaseIQ
    at dbfit.api.DbEnvironmentFactory.createEnvironmentInstance(DbEnvironmentFactory.java:99)
    at dbfit.api.DbEnvironmentFactory.newEnvironmentInstance(DbEnvironmentFactory.java:106)
    at dbfit.environment.SybaseIQDbEnvironmentFactoryTest.newDbEnvironmentTest(SybaseIQDbEnvironmentFactoryTest.java:11)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
...

A internet search revealed a configuration needs to be changes for org.atteo.evo.classindex.ClassIndex to work properly. I changed the same in my Project --> Properties --> Java Compiler --> Annotation Processing --> Factory Path.

I now have 3 jars and in this order:

1. evo-classindex-1.4.jar
2. guava-13.0.1.jar
3. org.eclipse.jst.ws.annotations.core


To circumvent the same I have made the following changes in DbEnvironmentFactory.java

    private void initDefaultEnvironments() {
      /* for (Class<?> c: ClassIndex.getAnnotated(DatabaseEnvironment.class)) {
            DatabaseEnvironment envAnnotation =
                c.getAnnotation(DatabaseEnvironment.class);
            registerEnv(envAnnotation.name(), envAnnotation.driver());
        } */
        registerEnv ("SybaseIQ", "com.sybase.jdbc4.jdbc.SybDriver");
    }

1. Is there any better way of doing this?

2.  Is there any way of running FlowModeTest.java or StandaloneFixturesTest.java from eclipse?

I am getting this error right now:

java.lang.IllegalStateException: java.lang.NullPointerException
    at fitnesse.junit.FitNesseSuite.<init>(FitNesseSuite.java:137)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:525)
    at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:33)
    at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:33)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:48)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.NullPointerException
    at fitnesse.junit.FitNesseSuite.initChildren(FitNesseSuite.java:145)
    at fitnesse.junit.FitNesseSuite.<init>(FitNesseSuite.java:135)
    ... 18 more




Yavor Nikolov

unread,
May 25, 2013, 7:09:29 PM5/25/13
to db...@googlegroups.com
Hi,

Here are my thoughts. (I cannot share my own experience since I'm in general not using Eclipse when working with DbFit. (And I'm building from command line).

Are you building with gradle from Eclipse (maybe via some of these plugins or something else: http://www.gradle.org/docs/current/userguide/eclipse_plugin.html, https://github.com/SpringSource/eclipse-integration-gradle/)?


(1) As you found - some special steps are needed to make Eclipse work when using Evo ClassIndex library (https://github.com/atteo/evo-classindex).
Is the described workaround helping or you still cannot get the build running without modifying the *Factory class?

The general idea was to avoid changing the *Factory class when new *Environment adapter is added.

(2) Running DbFit acceptance tests from Eclipse is in general a question about running FitNesse tests under Eclipse (http://fitnesse.org/FitNesse.UserGuide.RunningFromJunit).

I'm not sure if there is anything else special but one thing under my mind is that the relative path to tests root folder may be pointing to something else when running under Eclipse.
- What happens if you hard-code @FitnesseDir directory (should point to parent of FitnesseRoot)?
- Is the issue still present if you have Gradle integrated with Eclipse?

Regards,
Yavor



I've been always building DbFit via it's built-in build scripts (presently based on gradle).

* Seems there is some conflict between ev classindex annotations processing library and another line which ships with Eclipse.


The build runs fine from command line.







--
You received this message because you are subscribed to the Google Groups "dbfit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dbfit+un...@googlegroups.com.
To post to this group, send email to db...@googlegroups.com.
Visit this group at http://groups.google.com/group/dbfit?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jake Benilov

unread,
May 28, 2013, 4:10:58 AM5/28/13
to db...@googlegroups.com
Hi Pralhad,

I can confirm that current implementation of the integration tests needs to be launched from a specific execution path (namely dbfit-java/<database-name>). This is the FitNesse IDE integration relies on having a relative path to the wiki pages, for example:


hope that helps,
Jake

Pralhad Kamath

unread,
May 28, 2013, 10:40:17 PM5/28/13
to db...@googlegroups.com
Hi Jake,

This helped.

But the problem is I get an output something like this:

FitNesse (v20130321) Started...
    port:              1234
    root page:         fitnesse.wiki.FileSystemPage at ../../FitNesseRoot
    logger:            none
    authenticator:     fitnesse.authentication.PromiscuousAuthenticator
    page factory:      fitnesse.responders.PageFactory
    page theme:        fitnesse_straight
    page version expiration set to 0 days.
Executing command: DbFit.AcceptanceTests.JavaTests.SybaseIqTests.FlowMode.OrderedQuery?suite&debug=true&nohistory=true&format=java
-----Command Output-----
HTTP/1.1 200 OK
Connection: close
Server: FitNesse-v20130321
Transfer-Encoding: chunked
Content-Type: java

DbFit.AcceptanceTests.JavaTests.SybaseIqTests.FlowMode.OrderedQuery r 0 w 0 4 0.014 seconds
--complete: 1.655 seconds--
0
Exit-Code: 0

-----Command Complete-----

I guess r 0 means all wrong. How do I fix this?

Here is my test class:

public class SybaseRegressionTest {

    private JUnitHelper helper;

    // private NetworkServerControl serverControl;

    /*
     * @Before public void setUp() throws Exception { helper = new
     * JUnitHelper("../..", new
     * File(System.getProperty("java.io.tmpdir"),"fitnesse").getAbsolutePath());
     * helper.setPort(1234);
     *
     * serverControl = new NetworkServerControl(); serverControl.start(new
     * PrintWriter(System.out, true)); }
     */

    @Test
    public void flowMode() throws Exception {
        helper = new JUnitHelper("../..",
                new File(System.getProperty("java.io.tmpdir"), "fitnesse")
                        .getAbsolutePath());
        helper.setPort(1234);
        helper.setDebugMode(true);
        helper.assertSuitePasses("DbFit.AcceptanceTests.JavaTests.SybaseIqTests.FlowMode.OrderedQuery");

    }

    /*
     * @After public void tearDown() throws Exception {
     * serverControl.shutdown(); }
     */
}

 

Jake Benilov

unread,
Jun 3, 2013, 7:09:14 AM6/3/13
to db...@googlegroups.com
If you are looking for the output of the tests run in this way, have a look in <your system's temp folder>/fitnesse to find the output HTML. This is what's configured by the call to JUnitHelper.

It's a bit annoying to have to do this, but if you have the output page for a test open in your browser, you can just refresh it after another test run, because the JUnitHelper will replace the result after each run.
Reply all
Reply to author
Forward
0 new messages