| | /* |
---|
| | * Created on Nov 3, 2004 |
---|
| | * |
---|
| | * TODO To change the template for this generated file go to |
---|
| | * Window - Preferences - Java - Code Style - Code Templates |
---|
| | */ |
---|
| | package uk.org.floop.collabunit; |
---|
| | |
---|
| | import java.io.PrintStream; |
---|
| | import java.util.Enumeration; |
---|
| | |
---|
| | import junit.framework.TestCase; |
---|
| | import junit.framework.TestFailure; |
---|
| | import junit.framework.TestResult; |
---|
| | import simple.http.Request; |
---|
| | import simple.http.Response; |
---|
| | import simple.http.load.BasicService; |
---|
| | import simple.http.serve.Context; |
---|
| | |
---|
| | /** |
---|
| | * @author alex |
---|
| | * |
---|
| | * TODO To change the template for this generated type comment go to |
---|
| | * Window - Preferences - Java - Code Style - Code Templates |
---|
| | */ |
---|
| | public class TestResultsService extends BasicService { |
---|
| | |
---|
| | static private TestResult results; |
---|
| | |
---|
| | static public void setResults(TestResult results) { |
---|
| | TestResultsService.results = results; |
---|
| | } |
---|
| | |
---|
| | public TestResultsService(Context context) { |
---|
| | super(context); |
---|
| | } |
---|
| | |
---|
| | |
---|
| | /* (non-Javadoc) |
---|
| | * @see simple.http.serve.BasicResource#process(simple.http.Request, simple.http.Response) |
---|
| | */ |
---|
| | protected void process(Request request, Response response) throws Exception { |
---|
| | request.set("Content-Type", "application/rdf+xml"); |
---|
| | PrintStream out = response.getPrintStream(); |
---|
| | out.println("<rdf:RDF xmlns='http://www.floop.org.uk/ontoloties/2004/11/collabunit#'>"); |
---|
| | if (results != null) { |
---|
| | for (Enumeration i = results.errors(); i.hasMoreElements();) { |
---|
| | TestFailure failure = (TestFailure)i.nextElement(); |
---|
| | if (failure.failedTest() instanceof TestCase) { |
---|
| | out.println(" <TestError rdf:about='urn:testerror:" + failure.failedTest().getClass().getName() + ":" + ((TestCase)failure.failedTest()).getName() + "'>"); |
---|
| | out.println(" <reason>" + failure.exceptionMessage() + "</reason>"); |
---|
| | out.println(" </TestError>"); |
---|
| | } |
---|
| | } |
---|
| | for (Enumeration j = results.failures(); j.hasMoreElements();) { |
---|
| | TestFailure failure = (TestFailure)j.nextElement(); |
---|
| | if (failure.failedTest() instanceof TestCase) { |
---|
| | out.println(" <TestFailure rdf:about='urn:testfailure:" + failure.failedTest().getClass().getName() + ":" + ((TestCase)failure.failedTest()).getName() + "'>"); |
---|
| | out.println(" <reason>" + failure.exceptionMessage() + "</reason>"); |
---|
| | out.println(" </TestFailure>"); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| | out.println("</rdf:RDF>"); |
---|
| | out.close(); |
---|
| | } |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |