Revision 41502854
Added by Andreas Müller over 2 years ago
cdmlib-remote-webapp/src/test/java/eu/etaxonomy/cdm/remote/SwaggerStaticIT.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.io.File; |
12 | 12 |
import java.io.IOException; |
13 |
import java.nio.charset.Charset; |
|
13 | 14 |
|
14 | 15 |
import org.apache.commons.io.FileUtils; |
15 | 16 |
import org.apache.log4j.Logger; |
... | ... | |
51 | 52 |
try { |
52 | 53 |
File targetFile = new File(staticResourcesFolder + path + StaticSwaggerApiDoc.JSON); |
53 | 54 |
new File(targetFile.getParent()).mkdirs(); |
54 |
FileUtils.write(targetFile, response); |
|
55 |
FileUtils.write(targetFile, response, Charset.defaultCharset());
|
|
55 | 56 |
logger.info(response.length() + " characters of swagger-resources written to " + targetFile.getAbsolutePath()); |
56 | 57 |
} catch (IOException e) { |
57 | 58 |
logger.error(e); |
58 | 59 |
} |
59 | 60 |
} |
60 |
|
|
61 | 61 |
} |
62 | 62 |
|
63 |
|
|
64 | 63 |
@Test |
65 | 64 |
public void fetchSwaggerGroups(){ |
66 | 65 |
|
67 | 66 |
String swagger2Endpoint= "/v2/api-docs"; |
68 |
|
|
69 |
|
|
70 | 67 |
String staticApiDocFolder = "./target/classes/"+ StaticSwaggerApiDoc.SWAGGER_STATIC + "/api-docs/"; |
71 | 68 |
|
72 | 69 |
staticApiDocFolder = staticApiDocFolder.replace("/", File.separator); |
73 | 70 |
|
74 |
|
|
75 | 71 |
for(SwaggerGroupsConfig group : SwaggerGroupsConfig.values()) { |
76 | 72 |
logger.info(group.groupName()); |
77 | 73 |
String response = httpGetJson(swagger2Endpoint, "group=" + group.groupName()); |
78 | 74 |
response = response.replaceAll(",\"host\":\"([^\"]*)", ",\"host\":\"" + StaticSwaggerApiDoc.HOST); |
79 | 75 |
response = response.replaceAll(",\"basePath\":\"([^\"]*)", ",\"basePath\":\"" + StaticSwaggerApiDoc.BASE_PATH); |
80 | 76 |
try { |
81 |
FileUtils.write(new File(staticApiDocFolder + group.name() + StaticSwaggerApiDoc.JSON), response); |
|
77 |
FileUtils.write(new File(staticApiDocFolder + group.name() + StaticSwaggerApiDoc.JSON), response, Charset.defaultCharset());
|
|
82 | 78 |
} catch (IOException e) { |
83 | 79 |
// TODO Auto-generated catch block |
84 | 80 |
e.printStackTrace(); |
... | ... | |
88 | 84 |
// File pwd = new File("pom.xml"); |
89 | 85 |
// System.err.println(pwd.getAbsolutePath()); |
90 | 86 |
} |
91 |
|
|
92 |
} |
|
87 |
} |
Also available in: Unified diff
cleanup