Java Code Examples for org.testng.reporters.Files#readFile()

The following examples show how to use org.testng.reporters.Files#readFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FHIRCliTest.java    From FHIR with Apache License 2.0 5 votes vote down vote up
private void verifyFileContents(String fname, String... expectedMsgs) throws Exception {
    String fileContents = Files.readFile(new FileInputStream(dirPrefix(fname)));
    for (int i = 0; i < expectedMsgs.length; i++) {
        if (!fileContents.contains(expectedMsgs[i])) {
            fail("File contents didn't contain: '" + expectedMsgs[i] + "'");
        }
    }
}
 
Example 2
Source File: AbstractIntegrationTest.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Test(enabled = false)
public void generatesCorrectDirectoryStructure() throws IOException {
    DefaultGenerator codeGen = new DefaultGenerator();
    codeGen.setGenerateMetadata(generateMetadata);
    for (Map.Entry<String, String> propertyOverride : globalPropertyOverrides.entrySet()) {
        codeGen.setGeneratorPropertyDefault(propertyOverride.getKey(), propertyOverride.getValue());
    }

    IntegrationTestPathsConfig integrationTestPathsConfig = getIntegrationTestPathsConfig();

    String specContent = Files.readFile(integrationTestPathsConfig.getSpecPath().toFile());
    OpenAPI openAPI = TestUtils.parseContent(specContent);


    CodegenConfig codegenConfig = getCodegenConfig();
    codegenConfig.setOutputDir(integrationTestPathsConfig.getOutputPath().toString());
    codegenConfig.setIgnoreFilePathOverride(integrationTestPathsConfig.getIgnoreFilePath().toFile().toString());
    ClientOptInput opts = new ClientOptInput()
            .config(codegenConfig)
            .openAPI(openAPI);

    codegenConfig.additionalProperties().putAll(configProperties());

    codeGen.opts(opts).generate();

    assertPathEqualsRecursively(integrationTestPathsConfig.getExpectedPath(), integrationTestPathsConfig.getOutputPath());
}
 
Example 3
Source File: JsonConfigLoader.java    From extentreports-java with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public void apply() {
    final Gson gson = new GsonBuilder().registerTypeAdapter(instance.getClass(), creator).create();
    try {
        String json = f != null ? Files.readFile(f) : this.json;
        instance = (T) gson.fromJson(json, instance.getClass());
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
Example 4
Source File: DevfileIntegrityValidatorTest.java    From che with Eclipse Public License 2.0 5 votes vote down vote up
@BeforeClass
public void setUp() throws Exception {
  Map<String, ComponentIntegrityValidator> componentValidators = new HashMap<>();
  componentValidators.put(KUBERNETES_COMPONENT_TYPE, dummyComponentValidator);
  componentValidators.put(OPENSHIFT_COMPONENT_TYPE, dummyComponentValidator);
  componentValidators.put(PLUGIN_COMPONENT_TYPE, dummyComponentValidator);
  componentValidators.put(EDITOR_COMPONENT_TYPE, dummyComponentValidator);

  integrityValidator = new DevfileIntegrityValidator(componentValidators);
  String devFileYamlContent =
      Files.readFile(getClass().getClassLoader().getResourceAsStream("devfile/devfile.yaml"));
  initialDevfile = objectMapper.readValue(devFileYamlContent, DevfileImpl.class);
}
 
Example 5
Source File: OpenAPIV3ParserTest.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
@Test(description = "A string example should not be over quoted when parsing a yaml node")
public void readingSpecNodeShouldNotOverQuotingStringExample() throws Exception {
    String yaml = Files.readFile(new File("src/test/resources/over-quoted-example.yaml"));
    JsonNode rootNode = Yaml.mapper().readValue(yaml, JsonNode.class);
    OpenAPIV3Parser parser = new OpenAPIV3Parser();
    OpenAPI openAPI = (parser.parseJsonNode(null, rootNode)).getOpenAPI();

    Map<String, Schema> definitions = openAPI.getComponents().getSchemas();
    assertEquals("NoQuotePlease", definitions.get("CustomerType").getExample());
}
 
Example 6
Source File: KubernetesEnvironmentProvisionerTest.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
private String getResource(String resourceName) throws IOException {
  return Files.readFile(getClass().getClassLoader().getResourceAsStream(resourceName));
}
 
Example 7
Source File: KubernetesComponentToWorkspaceApplierTest.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
private String getResource(String resourceName) throws IOException {
  return Files.readFile(getClass().getClassLoader().getResourceAsStream(resourceName));
}
 
Example 8
Source File: DevfileSchemaValidatorTest.java    From che with Eclipse Public License 2.0 4 votes vote down vote up
private String getResource(String name) throws IOException {
  return Files.readFile(
      getClass().getClassLoader().getResourceAsStream("devfile/schema_test/" + name));
}