Skip to content

Instantly share code, notes, and snippets.

@mkempka
mkempka / FileResource
Created March 6, 2015 12:46
A Rule that eases working with files during test execution in OSGi environments. See http://eclipsesource.com/blogs/?p=22765
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
import org.apache.commons.io.IOUtils;
import org.jdom.input.DOMBuilder;
@mkempka
mkempka / Manifold.java
Created May 22, 2013 11:59
A rule runs a test case many times in parallel. Can be used for load tests. If more than one of the parallel executions fails, only the first fail is reported. Example: To run each test method in the class 5 times, add @rule public Manifold runParallel = new Manifold(5); to the class
import java.util.concurrent.CountDownLatch;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
/**
* A rule runs each test case many times in parallel. Can be used for load tests. If more than one
* of the parallel executions fails, only the first fail is reported. Example: To run each test
* method in the class 5 times, add <code> @Rule