@@ -53,17 +53,17 @@ public class ResourceHarness {
5353 File folderDontUseDirectly ;
5454
5555 /** Returns the root folder (canonicalized to fix OS X issue) */
56- protected File rootFolder () {
56+ public File rootFolder () {
5757 return Errors .rethrow ().get (() -> folderDontUseDirectly .getCanonicalFile ());
5858 }
5959
6060 /** Returns a new child of the root folder. */
61- protected File newFile (String subpath ) {
61+ public File newFile (String subpath ) {
6262 return new File (rootFolder (), subpath );
6363 }
6464
6565 /** Creates and returns a new child-folder of the root folder. */
66- protected File newFolder (String subpath ) throws IOException {
66+ public File newFolder (String subpath ) throws IOException {
6767 File targetDir = newFile (subpath );
6868 if (!targetDir .mkdir ()) {
6969 throw new IOException ("Failed to create " + targetDir );
@@ -77,7 +77,7 @@ protected File newFolder(String subpath) throws IOException {
7777 * @return the list of resources in that directory on the classpath, unix-style file separators
7878 * @throws IOException
7979 */
80- protected List <String > listTestResources (String path ) throws IOException {
80+ public List <String > listTestResources (String path ) throws IOException {
8181 // add leading slash if required, otherwise resources won't be found
8282 if (!path .startsWith ("/" )) {
8383 path = path + "/" ;
@@ -102,19 +102,19 @@ protected List<String> listTestResources(String path) throws IOException {
102102 return filenames ;
103103 }
104104
105- protected String relativeToRoot (String path ) {
105+ public String relativeToRoot (String path ) {
106106 return new File (path ).toPath ().relativize (rootFolder ().toPath ()).toString ();
107107 }
108108
109- protected String read (String path ) throws IOException {
109+ public String read (String path ) throws IOException {
110110 return read (newFile (path ).toPath (), StandardCharsets .UTF_8 );
111111 }
112112
113- protected String read (Path path , Charset encoding ) throws IOException {
113+ public String read (Path path , Charset encoding ) throws IOException {
114114 return new String (Files .readAllBytes (path ), encoding );
115115 }
116116
117- protected void replace (String path , String toReplace , String replaceWith ) throws IOException {
117+ public void replace (String path , String toReplace , String replaceWith ) throws IOException {
118118 String before = read (path );
119119 String after = before .replace (toReplace , replaceWith );
120120 if (before .equals (after )) {
@@ -124,15 +124,15 @@ protected void replace(String path, String toReplace, String replaceWith) throws
124124 }
125125
126126 /** Returns the contents of the given file from the src/test/resources directory. */
127- protected static String getTestResource (String filename ) {
127+ public static String getTestResource (String filename ) {
128128 Optional <URL > resourceUrl = getTestResourceUrl (filename );
129129 if (resourceUrl .isPresent ()) {
130130 return ThrowingEx .get (() -> LineEnding .toUnix (Resources .toString (resourceUrl .get (), StandardCharsets .UTF_8 )));
131131 }
132132 throw new IllegalArgumentException ("No such resource " + filename );
133133 }
134134
135- protected static boolean existsTestResource (String filename ) {
135+ public static boolean existsTestResource (String filename ) {
136136 return getTestResourceUrl (filename ).isPresent ();
137137 }
138138
@@ -142,7 +142,7 @@ private static Optional<URL> getTestResourceUrl(String filename) {
142142 }
143143
144144 /** Returns Files (in a temporary folder) which has the contents of the given file from the src/test/resources directory. */
145- protected List <File > createTestFiles (String ... filenames ) {
145+ public List <File > createTestFiles (String ... filenames ) {
146146 List <File > files = new ArrayList <>(filenames .length );
147147 for (String filename : filenames ) {
148148 files .add (createTestFile (filename ));
@@ -151,15 +151,15 @@ protected List<File> createTestFiles(String... filenames) {
151151 }
152152
153153 /** Returns a File (in a temporary folder) which has the contents of the given file from the src/test/resources directory. */
154- protected File createTestFile (String filename ) {
154+ public File createTestFile (String filename ) {
155155 return createTestFile (filename , UnaryOperator .identity ());
156156 }
157157
158158 /**
159159 * Returns a File (in a temporary folder) which has the contents, possibly processed, of the given file from the
160160 * src/test/resources directory.
161161 */
162- protected File createTestFile (String filename , UnaryOperator <String > fileContentsProcessor ) {
162+ public File createTestFile (String filename , UnaryOperator <String > fileContentsProcessor ) {
163163 int lastSlash = filename .lastIndexOf ('/' );
164164 String name = lastSlash >= 0 ? filename .substring (lastSlash ) : filename ;
165165 File file = newFile (name );
@@ -169,12 +169,12 @@ protected File createTestFile(String filename, UnaryOperator<String> fileContent
169169 }
170170
171171 @ CheckReturnValue
172- protected ReadAsserter assertFile (String path ) {
172+ public ReadAsserter assertFile (String path ) {
173173 return new ReadAsserter (newFile (path ));
174174 }
175175
176176 @ CheckReturnValue
177- protected ReadAsserter assertFile (File file ) {
177+ public ReadAsserter assertFile (File file ) {
178178 return new ReadAsserter (file );
179179 }
180180
@@ -207,7 +207,7 @@ public void matches(Consumer<AbstractCharSequenceAssert<?, String>> conditions)
207207 }
208208 }
209209
210- protected WriteAsserter setFile (String path ) {
210+ public WriteAsserter setFile (String path ) {
211211 return new WriteAsserter (newFile (path ));
212212 }
213213
0 commit comments