コード例 #1
0
 @BeforeClass
 public static void initExecutionContext() throws IOException, RestException {
   String[] specPaths = resolvePathsProperty(REST_TESTS_SPEC, DEFAULT_SPEC_PATH);
   RestSpec restSpec = RestSpec.parseFrom(DEFAULT_SPEC_PATH, specPaths);
   validateSpec(restSpec);
   restTestExecutionContext = new RestTestExecutionContext(restSpec);
 }
コード例 #2
0
 private static void validateSpec(RestSpec restSpec) {
   boolean validateSpec = RandomizedTest.systemPropertyAsBoolean(REST_TESTS_VALIDATE_SPEC, true);
   if (validateSpec) {
     StringBuilder errorMessage = new StringBuilder();
     for (RestApi restApi : restSpec.getApis()) {
       if (restApi.getMethods().contains("GET") && restApi.isBodySupported()) {
         if (!restApi.getMethods().contains("POST")) {
           errorMessage
               .append("\n- ")
               .append(restApi.getName())
               .append(" supports GET with a body but doesn't support POST");
         }
       }
     }
     if (errorMessage.length() > 0) {
       throw new IllegalArgumentException(errorMessage.toString());
     }
   }
 }