4

Hi : This is a two part question - First - Im noticing JUnit 4.7 build errors , and found that JUnit is , in fact, not backwards compatible :

Testing Solr via Embedded Server

Thus,

Is it possible to use Junit 4.7 for certain tests in an otherwise up todate (using the latest Junit)8 build ?

Of course - i'd also like to know wether, in general, JUnit is backwards compatible ? In my instance, it appears that SOLR's base unit test class relies on some fanciful tricks which were possible in JUnit 4.7, which are no longer supported.

Community
  • 1
  • 1
jayunit100
  • 17,388
  • 22
  • 92
  • 167
  • 1
    In general, JUnit is backwards compatible. If you could mention a specific problem that you have with the upgrade from 4.7 to 4.8, it would be helpful, so that we can tell you if something got broken, or if it's something in Solr. – Matthew Farwell Feb 02 '12 at 20:07
  • Okay ... maybe I will try to make a simple, reproducible version of this bug and report it. – jayunit100 Feb 03 '12 at 16:19

1 Answers1

0

commun bug

Your bug is very commun, and the official blog is explaining it clearly. Take care with Solr embedded Server, it's not recommanded by SOLR itself!!!

As said on the official solr embbeded uri:

The simplest, safest, way to use Solr is via Solr's standard HTTP interfaces. Embedding Solr is less flexible, harder to support, not as well tested, and should be reserved for special circumstances.

A question of choice : "Keep running unit test server" or run it "on the fly"

I suggest you to do the same thing as we are doing in order to unit test, - run a dedicated solr server, or - run one on the fly

To run a solr server inside the maven build, you can use CARGO: - To launch the build and unit test we are using maven - we lauch test automaticaly on Solr - we lauch on startup of the test a solr instance "on the fly" and closes it using the conainMaven Cargo - At the end of the junit we close Cargo ! :)

Easy and clean ! Enjoy :)

Exemple of cargo maven code :

<plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>1.4.8</version>
            <executions>
                <execution>
                    <id>start-container</id>
                    <phase>process-test-resources</phase>
                    <goals>
                        <goal>start</goal>
                    </goals>
                </execution>
                <execution>
                    <id>stop-container</id>
                    <phase>package</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <configuration>
                    <properties>
                        <cargo.servlet.port>8966</cargo.servlet.port>
                    </properties>
                </configuration>

                <container>
                    <containerId>jetty7x</containerId>
                    <type>embedded</type>
                    <systemProperties>
                        <solr.solr.home>${basedir}/target/solr</solr.solr.home>
                        <!-- log4j.configuration>file://${basedir}/src/test/resources/log4j.properties</log4j.configuration -->
                        <log4j.debug>true</log4j.debug>
                        <net.sourceforge.cobertura.datafile>target/cobertura/cobertura.ser</net.sourceforge.cobertura.datafile>
                    </systemProperties>
                    <dependencies>
                        <!-- SLF4J -->
                        <dependency>
                            <groupId>org.slf4j</groupId>
                            <artifactId>slf4j-api</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.slf4j</groupId>
                            <artifactId>jcl-over-slf4j</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.slf4j</groupId>
                            <artifactId>jul-to-slf4j</artifactId>
                        </dependency>
                        <dependency>
                            <groupId>org.slf4j</groupId>
                            <artifactId>slf4j-log4j12</artifactId>
                        </dependency>
                        <!-- Log4j -->
                        <dependency>
                            <groupId>log4j</groupId>
                            <artifactId>log4j</artifactId>
                        </dependency>
                    </dependencies>
                </container>
                <deployables>
                    <deployable>
                        <groupId>org.apache.solr</groupId>
                        <artifactId>solr</artifactId>
                        <type>war</type>
                        <properties>
                            <context>/solr</context>
                        </properties>
                    </deployable>
                </deployables>
            </configuration>
        </plugin>
jeorfevre
  • 2,286
  • 1
  • 17
  • 27