ReadResourceを作成
1 parent 595ec46 commit e2e17c839befceda855a36c96047a99e8dafeb7a
y-ota authored on 6 Dec 2018
Showing 3 changed files
View
21
src/main/Main.java
static ArrayList<RestParam> queryParam = new ArrayList<>();
static ArrayList<RestParam> formParam = new ArrayList<>();
static ArrayList<String> pathParam = new ArrayList<>();
static TestGETCactus get = new TestGETCactus();
static TestPOSTCactus post = new TestPOSTCactus("f","f","f");
static TestPUTCactus put = new TestPUTCactus("f","f");
static TestPOSTCactus post = new TestPOSTCactus("f", "f", "f");
static TestPUTCactus put = new TestPUTCactus("f", "f");
static TestDELETECactus delete = new TestDELETECactus("qF9bgKYZmw8P");
 
public static void main(String[] args) {
// post.start();
// post.start();
init();
api.jsonAcquisition("src/main/you.json");
api.doRestTest();
System.out.println(api.getResults());
// System.out.println(api.getBeforeResults());
// System.out.println(api.getJudgeResult());
// System.out.println(api.getBeforeResults());
// System.out.println(api.getJudgeResult());
}
 
static private void init() {
api.setAccount("https://www.googleapis.com/youtube/v3");
// queryParam.add(new RestParam("key", "AIzaSyD5EI71SqPZhgdpwzlV0XTisGuKKtH5p6I"));
// queryParam.add(new RestParam("id", "7lCDEYXw3mM"));
// queryParam.add(new RestParam("key",
// "AIzaSyD5EI71SqPZhgdpwzlV0XTisGuKKtH5p6I"));
// queryParam.add(new RestParam("id", "7lCDEYXw3mM"));
queryParam.add(new RestParam("part", "snippet"));
queryParam.add(new RestParam("access_token", "ya29.GltoBgshDGc5-hOiCBnKcrpu5vZvEOy-wSBhul7wyzcg8XpFWMWhymWADANBsx0FoG643I8DD855hYVUCMw8beOgGc4WyA0HQwfPcNQZR0nuYREsXOIj6O2UymPi"));
queryParam.add(new RestParam("access_token",
"ya29.GltqBt15-zkpMQ_Moqbt1ccsFh-KFFKcWHNB9LiDYlAOBdOW-gqHCexRJUfJN-G2j_2W2GfNT1HrRC5b0N9sl7RYcmXb28-lHjbtu0mWP7PHU0FhzJ-MnymdbnVJ"));
pathParam.add("playlists");
api.setupRestTest(Method.POST, queryParam, formParam, pathParam);
}
 
View
4
src/org/ntlab/radishforandroidstudio/framework/network/HttpAsyncConnection.java
 
public void setRequestPropertie(String key, String value) {
keys.add(key);
values.add(value);
}
 
public void setJson(String Json) {
this.Json = Json;
}
 
// request
public void doAnything() {
View
42
src/restfulchecker/RestChecker.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
 
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
private ArrayList<String> pathParam;
private String judgeResult;
private String method;
private String token, token_name;
private String jstr;
 
public static final int ACCOUNT_NUM = 5;
 
public String getToken() {
if (type == null) {
System.out.println("not Selected Method");
return;
}
RestAccount first = new RestAccount(accounts.get(0).getUrl());
first.doGet();
addParam(first);
first.doAnything();
beforeResults.add(first.doReceive());
ReadResource(beforeResults);
for (RestAccount account : accounts) {
switch (type) {
case GET:
account.doGet();
method = "DELETE";
break;
}
addParam(account);
account.setJson(jstr);
account.doAnything();
responses.add(account.getResponseCode());
receives.add(account.doReceive());
RestAccount second = new RestAccount(accounts.get(0).getUrl());
second.doGet();
addParam(second);
second.doAnything();
results.add(second.doReceive());
first = new RestAccount(accounts.get(0).getUrl());
first.doGet();
addParam(first);
first.doAnything();
beforeResults.add(first.doReceive());
ReadResource(results);
ReadResource(beforeResults);
}
judgeMethod();
}
 
System.out.println("WARNING!! Perhaps:" + judgeResult);
}
}
private void ReadResource(ArrayList<String> results) {
RestAccount account = new RestAccount(accounts.get(0).getUrl());
account.doGet();
account.doAnything();
results.add(account.doReceive());
}
public void jsonAcquisition(String path) {
ObjectMapper mapper = new ObjectMapper();
try {
BufferedReader reader = new BufferedReader(new FileReader(new File(path)));
StringBuilder builder = new StringBuilder();
while ((line = reader.readLine()) != null) {
builder.append(line);
}
builder.toString();
jstr = builder.toString();
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {