4
4
import java .io .FileInputStream ;
5
5
import java .io .IOException ;
6
6
import java .io .InputStream ;
7
- import java .io .Reader ;
8
7
import java .util .Properties ;
9
8
10
- public class TestUtils {
11
-
12
- /**
13
- * Reads the content of a Reader instance and returns it as a String.
14
- *
15
- * @param reader
16
- * @return the content of a Reader instance as a String
17
- * @throws IOException
18
- */
19
- public static String getReaderContentAsString (Reader reader ) throws IOException {
20
-
21
- int count ;
22
- final char [] buffer = new char [2048 ];
23
- final StringBuilder out = new StringBuilder ();
24
- while ((count = reader .read (buffer , 0 , buffer .length )) >= 0 ) {
25
- out .append (buffer , 0 , count );
26
- }
27
-
28
- return (out .toString ());
29
- }
9
+ public class HelperUtils {
30
10
31
11
private static Properties testProperties ;
32
12
static {
@@ -39,17 +19,23 @@ public static String getReaderContentAsString(Reader reader) throws IOException
39
19
basedir = basedir .substring (0 , basedir .length () - 15 );
40
20
}
41
21
42
- File propertiesFile = new File (basedir , "test-gitlab4j.properties" );
22
+ File propertiesFile = new File (( String ) System . getProperties (). get ( "user.home" ) , "test-gitlab4j.properties" );
43
23
if (!propertiesFile .exists ()) {
44
- propertiesFile = new File (( String ) System . getProperties (). get ( "user.home" ) , "test-gitlab4j.properties" );
24
+ propertiesFile = new File (basedir , "src/test/gitlab/ test-gitlab4j.properties" );
45
25
}
46
26
47
- System .out .println ("test-gitlab4j.properties location: " + propertiesFile .getAbsolutePath ());
27
+ if (propertiesFile .exists ()) {
28
+
29
+ System .out .println ("test-gitlab4j.properties location: " + propertiesFile .getAbsolutePath ());
48
30
49
- testProperties = new Properties ();
50
- try (InputStream input = new FileInputStream (propertiesFile )) {
51
- testProperties .load (input );
52
- } catch (IOException ioe ) {
31
+ testProperties = new Properties ();
32
+ try (InputStream input = new FileInputStream (propertiesFile )) {
33
+ testProperties .load (input );
34
+ } catch (IOException ioe ) {
35
+ }
36
+
37
+ } else {
38
+ System .out .println ("No test-gitlab4j.properties file found" );
53
39
}
54
40
}
55
41
0 commit comments