44import java .io .FileInputStream ;
55import java .io .IOException ;
66import java .io .InputStream ;
7- import java .io .Reader ;
87import java .util .Properties ;
98
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 {
3010
3111 private static Properties testProperties ;
3212 static {
@@ -39,17 +19,23 @@ public static String getReaderContentAsString(Reader reader) throws IOException
3919 basedir = basedir .substring (0 , basedir .length () - 15 );
4020 }
4121
42- File propertiesFile = new File (basedir , "test-gitlab4j.properties" );
22+ File propertiesFile = new File (( String ) System . getProperties (). get ( "user.home" ) , "test-gitlab4j.properties" );
4323 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" );
4525 }
4626
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 ());
4830
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" );
5339 }
5440 }
5541
0 commit comments