felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre De Rop <pierre.de...@gmail.com>
Subject pax exam and temporary files ...
Date Wed, 24 Feb 2010 07:54:00 GMT
Hello everyone,

I am facing a little issue with pax-exams and Junit4TestRunner test classes,
and I would like to know if someone else got caught by the same problem:
When I launch a "mvn test" command, and once the test is done,  some
temporary files are left in* /tmp/tb/ *directory ... So, the temp file
system grows ineluctably and I would like to avoid that problem.

In order to work around, I have found the two following solutions:

1) make a base class which is inherited by all unit tests: this base class
just ensures that the bundle's location file is cleaned once the jvm exits:

public class Base {
    /**
     * Always cleanup our bundle's location file
     */
    @After
    public void tearDown(BundleContext context) {
        try {
            File f = new File(new
URL(context.getBundle().getLocation()).getPath());
            f.deleteOnExit();
        } catch (Throwable t) {
            t.printStackTrace();
        }
    }
}


... And then, my unit tests just inherit the Base class like this:


@RunWith(JUnit4TestRunner.class)
public class MyTest extends Base
{
    @Configuration
    public static Option[] configuration()
    {
        return options(
            provision(

mavenBundle().groupId("org.osgi").artifactId("org.osgi.compendium").version("4.1.0"),
                // ..


2) the other consists in just setting the* java.io.tmpdir* parameter to my
target's project like this:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.4.3</version>
        <configuration>
          <systemProperties>
            <property>
              <name>java.io.tmpdir</name>
              <value>${basedir}/target/temp</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>

-> So, the tb directory is stored in my maven project's target/temp
directory, which is cleaned when I type "mvn clean"
The drawbak of this second solution is that the felix fwk, as well as
pax-exams bundles are always downloaded each time I type "mvn clean test"
...


So, I will use the solution 1) for now, but I would like to know if there is
a better/simpler way to resolve this problem ?
Is there a pax-exams configuration property which allows to ensure that the
/tmp/tb/*.bin temp files are cleaned after jvm exits ?


thanks in advance;
/pierre

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message