KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > junit > internal > requests > FilterRequest


1 /**
2  *
3  */

4 package org.junit.internal.requests;
5
6 import org.junit.runner.Request;
7 import org.junit.runner.Runner;
8 import org.junit.runner.manipulation.Filter;
9 import org.junit.runner.manipulation.NoTestsRemainException;
10
11 /**
12  * A filtered {@link Request}.
13  */

14 public final class FilterRequest extends Request {
15     private final Request fRequest;
16     private final Filter fFilter;
17
18     /**
19      * Creates a filtered Request
20      * @param classRequest a {@link Request} describing your Tests
21      * @param filter {@link Filter} to apply to the Tests described in
22      * <code>classRequest</code>
23      */

24     public FilterRequest(Request classRequest, Filter filter) {
25         fRequest= classRequest;
26         fFilter= filter;
27     }
28
29     /** @inheritDoc */
30     @Override JavaDoc
31     public Runner getRunner() {
32         try {
33             Runner runner= fRequest.getRunner();
34             fFilter.apply(runner);
35             return runner;
36         } catch (NoTestsRemainException e) {
37             return Request.errorReport(Filter.class, new Exception JavaDoc(String
38                     .format("No tests found matching %s from %s", fFilter
39                             .describe(), fRequest.toString()))).getRunner();
40         }
41     }
42 }
Popular Tags