Announcement Announcement Module
Collapse
No announcement yet.
JUnit testing & spring dm server Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JUnit testing & spring dm server

    Hi,

    I am trying to find a testing guide for spring dm server. Currently I tried adapting greenpages.jpa testcases to my code or spring dm without any luck. Same goes for springdm AbstractConfigurableBundleCreatorTests which I wasn't able to make it work and also I find very complex.

    My first attempt:

    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = { "classpath:/META-INF/spring/module-context.xml" })
    @TestExecutionListeners(value = DependencyInjectionTestExecutionListener.class)
    public class TestGroovyManager
    {
    @Autowired
    protected GroovyManager groovyManager;

    @Test
    public void loadClass()
    {
    final GroovyClass gc = groovyManager.load("MyClass");
    assertNotNull(gc);
    }
    }

    I am able to run this within eclipse but it throws a stackoverflow during startup because it recursively tries to get an instance of the logger (I am using slf4j). The GroovyManager currently is a dummy class which doesn't do anything at all.

    This seems the easy way to do tests within a bundle but I wonder what will happen if the test is cross-bundles...

    Also in order to make this work, I had to include a couple of dependences ONLY on my maven configuration, and already using maven along with the manifest.mf of the bundle feels weird.

    Am I doing something terribly wrong?

    My maven file:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.rits.groovy</groupId>
    <artifactId>com.rits.groovy</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>groovy</name>
    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.8.1</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>com.springsource.org.codehaus.groovy </artifactId>
    <version>1.7.0</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>org.springframework.test</artifactId>
    <version>3.0.2.RELEASE</version>
    <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>com.springsource.slf4j.org.apache.comm ons.logging</artifactId>
    <version>1.5.10</version>
    <scope>provided</scope>
    </dependency>
    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>com.springsource.slf4j.jcl</artifactId>
    <version>1.5.10</version>
    <scope>provided</scope>
    </dependency>

    <!--
    <dependency>
    <groupId>org.springframework.osgi</groupId>
    <artifactId>org.springframework.osgi.test</artifactId>
    <version>1.2.1</version>
    <scope>test</scope>
    </dependency>
    -->
    </dependencies>
    <build>
    <plugins>
    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    </plugin>
    <plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
    <source>1.6</source>
    <target>1.6</target>
    </configuration>
    </plugin>
    </plugins>
    </build>
    <repositories>
    <repository>
    <id>com.springsource.repository.bundles.release</id>
    <name>SpringSource Bundle Releases</name>
    <url>http://repository.springsource.com/maven/bundles/release</url>
    </repository>
    <repository>
    <id>com.springsource.repository.bundles.external </id>
    <name>SpringSource External Bundle Releases</name>
    <url>http://repository.springsource.com/maven/bundles/external</url>
    </repository>
    </repositories>
    </project>
Working...
X