Exemplo n.º 1
0
 @When("^I read json string from a file$")
 public void i_read_json_string_from_a_file() throws Throwable {
   FileInputStream fin =
       new FileInputStream(
           new File(System.getProperty("user.dir") + "//src//test//resources//sample.json"));
   InputStreamReader in = new InputStreamReader(fin);
   BufferedReader bufferedReader = new BufferedReader(in);
   StringBuilder sb = new StringBuilder();
   String line;
   while ((line = bufferedReader.readLine()) != null) {
     sb.append(line);
   }
   json = sb.toString();
 }
Exemplo n.º 2
0
 @When("^I read the json data file \"(.*?)\"$")
 public void i_read_the_json_data_file(String arg1) throws Throwable {
   FileInputStream fin =
       new FileInputStream(
           new File(System.getProperty("user.dir") + "//src//test//resources//" + arg1));
   InputStreamReader in = new InputStreamReader(fin);
   BufferedReader bufferedReader = new BufferedReader(in);
   StringBuilder sb = new StringBuilder();
   String line;
   while ((line = bufferedReader.readLine()) != null) {
     sb.append(line);
   }
   json = sb.toString();
   System.out.println(json);
 }