File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed
kmip/src/test/java/org/bouncycastle/test Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .bouncycastle .test ;
2+
3+
4+ import java .util .Enumeration ;
5+
6+ import junit .framework .TestResult ;
7+
8+ public class PrintTestResult
9+ {
10+ public static void printResult (TestResult result )
11+ {
12+ Enumeration e = result .failures ();
13+ if (e != null )
14+ {
15+ while (e .hasMoreElements ())
16+ {
17+ System .out .println (e .nextElement ());
18+ }
19+ }
20+
21+ e = result .errors ();
22+ if (e != null )
23+ {
24+ while (e .hasMoreElements ())
25+ {
26+ System .out .println (e .nextElement ());
27+ }
28+ }
29+
30+ if (!result .wasSuccessful ())
31+ {
32+ System .exit (1 );
33+ }
34+ }
35+ }
36+
Original file line number Diff line number Diff line change 1+ package org .bouncycastle .test ;
2+
3+ import java .io .File ;
4+ import java .io .FileInputStream ;
5+ import java .io .FileNotFoundException ;
6+ import java .io .InputStream ;
7+
8+ public class TestResourceFinder
9+ {
10+ private static final String dataDirName = "bc-test-data" ;
11+
12+ /**
13+ * We search starting at the working directory looking for the bc-test-data directory.
14+ *
15+ * @throws FileNotFoundException
16+ */
17+ public static InputStream findTestResource (String homeDir , String fileName )
18+ throws FileNotFoundException
19+ {
20+ String wrkDirName = System .getProperty ("user.dir" );
21+ String separator = System .getProperty ("file.separator" );
22+ File wrkDir = new File (wrkDirName );
23+ File dataDir = new File (wrkDir , dataDirName );
24+ while (!dataDir .exists () && wrkDirName .length () > 1 )
25+ {
26+ wrkDirName = wrkDirName .substring (0 , wrkDirName .lastIndexOf (separator ));
27+ wrkDir = new File (wrkDirName );
28+ dataDir = new File (wrkDir , dataDirName );
29+ }
30+
31+ if (!dataDir .exists ())
32+ {
33+ String ln = System .getProperty ("line.separator" );
34+ throw new FileNotFoundException ("Test data directory " + dataDirName + " not found." + ln + "Test data available from: https://github.com/bcgit/bc-test-data.git" );
35+ }
36+
37+ return new FileInputStream (new File (dataDir , homeDir + separator + fileName ));
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments