Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added config replacers tests to client config test
* more config test clean up
- Loading branch information
1 parent
0da3d02
commit 9ae11da
Showing
5 changed files
with
235 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.hazelcast; | ||
|
||
import java.io.File; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.util.function.Function; | ||
|
||
public class IOUtils { | ||
@SuppressWarnings("ResultOfMethodCallIgnored") | ||
public static File createConfigFile(String filename, String suffix) throws IOException { | ||
File file = File.createTempFile(filename, suffix); | ||
file.setWritable(true); | ||
file.deleteOnExit(); | ||
return file; | ||
} | ||
|
||
public static void writeStringToStreamAndClose(FileOutputStream os, String string) throws IOException { | ||
os.write(string.getBytes()); | ||
os.flush(); | ||
os.close(); | ||
} | ||
|
||
public static String createFileWithContent(String filename, String suffix, String content) throws IOException { | ||
File file = createConfigFile(filename, suffix); | ||
FileOutputStream os = new FileOutputStream(file); | ||
writeStringToStreamAndClose(os, content); | ||
return file.getAbsolutePath(); | ||
} | ||
|
||
public static String createFilesWithCycleImports(Function<String, String> fileContentWithImportResource, String... paths) throws Exception { | ||
for (int i = 1; i < paths.length; i++) { | ||
createFileWithDependencyImport(paths[i - 1], paths[i], fileContentWithImportResource); | ||
} | ||
return createFileWithDependencyImport(paths[0], paths[1], fileContentWithImportResource); | ||
} | ||
|
||
private static String createFileWithDependencyImport( | ||
String dependent, | ||
String pathToDependency, | ||
Function<String, String> fileContentWithImportResource) throws Exception { | ||
final String xmlContent = fileContentWithImportResource.apply(pathToDependency); | ||
IOUtils.writeStringToStreamAndClose(new FileOutputStream(dependent), xmlContent); | ||
return xmlContent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.