• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java RamlLoaders类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中guru.nidi.ramltester.RamlLoaders的典型用法代码示例。如果您正苦于以下问题:Java RamlLoaders类的具体用法?Java RamlLoaders怎么用?Java RamlLoaders使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

RamlLoaders类属于guru.nidi.ramltester包,在下文中一共展示了RamlLoaders类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: init

点赞 3

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
/**
 * Method called to initialize basic resources after the object is created.
 */
@PostConstruct
public void init() {
  mockExternalAuthorization();

  RestAssured.baseURI = BASE_URL;
  RestAssured.port = serverPort;
  RestAssured.config = RestAssuredConfig.config().objectMapperConfig(
      new ObjectMapperConfig().jackson2ObjectMapperFactory((clazz, charset) -> objectMapper)
  );

  RamlDefinition ramlDefinition = RamlLoaders.fromClasspath()
      .load("api-definition-raml.yaml").ignoringXheaders();

  restAssured = ramlDefinition.createRestAssured();
}
 

开发者ID:OpenLMIS,
项目名称:openlmis-stockmanagement,
代码行数:19,
代码来源:BaseWebIntegrationTest.java

示例2: testVersion

点赞 3

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void testVersion(TestContext context) {
  logger.info("testVersion starting");
  async = context.async();
  RestAssuredClient c;
  Response r;

  RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml")
    .assumingBaseUri("https://okapi.cloud");

  c = api.createRestAssured();
  r = c.given().get("/_/version").then().statusCode(200).log().ifValidationFails().extract().response();

  Assert.assertTrue("raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());
  async.complete();
}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:18,
代码来源:ModuleTest.java

示例3: test1

点赞 3

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void test1() {
  RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml")            .assumingBaseUri("https://okapi.cloud");

  RestAssuredClient c;

  c = api.createRestAssured();
  c.given().port(port1).get("/_/version").then().statusCode(200);
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  c = api.createRestAssured();
  c.given().port(port2).get("/_/version").then().statusCode(200);
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  c = api.createRestAssured();
  c.given().port(port2)
    .header("Content-Type", "application/json")
    .body("{ bad json").post("/_/proxy/pull/modules")
    .then().statusCode(400).log().ifValidationFails();

}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:24,
代码来源:PullTest.java

示例4: testOkapiRaml

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void testOkapiRaml() {
  RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml");

  // Don't check Validation.DESCRIPTION
  RamlValidator v = api.validator().withChecks(Validation.URI_PARAMETER, Validation.PARAMETER, Validation.EMPTY);

  Assert.assertThat(v.validate(), validates());
}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:10,
代码来源:RamlTest.java

示例5: setUp

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Before
public void setUp(TestContext context) {
  logger.debug("starting MainClusterTest");

  // can't set Verticle options so we set a property instead
  System.setProperty("port", Integer.toString(port));
  async = context.async();
  api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml");
  RestAssured.port = port;
  async.complete();
}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:12,
代码来源:MainDeployTest.java

示例6: testManyModules

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void testManyModules(TestContext context) {
  async = context.async();

  RestAssuredClient c;
  RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml")
    .assumingBaseUri("https://okapi.cloud");
  Response r;

  int i;
  for (i = 0; i < 10; i++) {
    String docSampleModule = "{" + LS
      + "  \"id\" : \"sample-1.2." + Integer.toString(i) + "\"," + LS
      + "  \"name\" : \"sample module " + Integer.toString(i) + "\"," + LS
      + "  \"requires\" : [ ]" + LS
      + "}";
    c = api.createRestAssured();
    c.given()
      .header("Content-Type", "application/json")
      .body(docSampleModule)
      .post("/_/proxy/modules")
      .then()
      .statusCode(201)
      .log().ifValidationFails();
    Assert.assertTrue("raml: " + c.getLastReport().toString(),
      c.getLastReport().isEmpty());
  }
  c = api.createRestAssured();
  r = c.given()
    .get("/_/proxy/modules")
    .then()
    .statusCode(200).log().ifValidationFails().extract().response();
  Assert.assertTrue(c.getLastReport().isEmpty());

  async.complete();
}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:37,
代码来源:ModuleTest.java

示例7: testHealthCheck

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void testHealthCheck() {
  RestAssured.port = port;

  RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml")
          .assumingBaseUri("https://okapi.cloud");

  RestAssuredClient c;

  c = api.createRestAssured();
  c.given().get("/_/proxy/health").then().assertThat().statusCode(200);
  Assert.assertTrue("raml report: " + c.getLastReport().toString(), c.getLastReport().isEmpty());

  given().get("/_/proxy/health2").then().assertThat().statusCode(404);
}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:16,
代码来源:HealthCheckTest.java

示例8: init

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    api = RamlLoaders
            .fromClasspath(getClass())
            .load("api.raml")
            .assumingBaseUri("http://guru.nidi/raml/simple/v1");
}
 

开发者ID:nidi3,
项目名称:raml-tester-uc-servlet,
代码行数:8,
代码来源:RamlFilter.java

示例9: testInvalidResource

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test(expected = RamlViolationException.class)
public void testInvalidResource() {
    RestAssured.baseURI = "http://test.server/path";
    RamlDefinition api = RamlLoaders.fromClasspath(getClass()).load("api.yaml");
    Assert.assertThat(api.validate(), validates());

    RestAssuredClient restAssured = api.failFast().createRestAssured();
    restAssured.given().get("/wrong/path").andReturn();
    fail("Should throw RamlViolationException");
}
 

开发者ID:nidi3,
项目名称:raml-tester,
代码行数:11,
代码来源:FailFastTest.java

示例10: testRequest

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void testRequest() throws IOException {
    RamlDefinition api = RamlLoaders.fromClasspath(getClass()).load("api.yaml");
    Assert.assertThat(api.validate(), validates());

    RamlHttpClient client = api.createHttpClient();
    HttpGet get = new HttpGet("http://test.server/path");
    HttpResponse response = client.execute(get);

    Assert.assertThat(client.getLastReport(), checks());
}
 

开发者ID:nidi3,
项目名称:raml-tester,
代码行数:12,
代码来源:HttpComponentsTest.java

示例11: testWithRestAssured

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void testWithRestAssured() {
    RestAssured.baseURI = "http://test.server/path";
    RamlDefinition api = RamlLoaders.fromClasspath(getClass()).load("api.yaml");
    Assert.assertThat(api.validate(), validates());

    RestAssuredClient restAssured = api.createRestAssured();
    restAssured.given().get("/base/data").andReturn();
    Assert.assertTrue(restAssured.getLastReport().isEmpty());
}
 

开发者ID:nidi3,
项目名称:raml-tester,
代码行数:11,
代码来源:RestAssuredTest.java

示例12: testUiModule

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void testUiModule(TestContext context) {
  async = context.async();
  Response r;

  RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml")
    .assumingBaseUri("https://okapi.cloud");

  final String docUiModuleInput = "{" + LS
    + "  \"id\" : \"ui-1\"," + LS
    + "  \"name\" : \"sample-ui\"," + LS
    + "  \"uiDescriptor\" : {" + LS
    + "    \"npm\" : \"name-of-module-in-npm\"" + LS
    + "  }" + LS
    + "}";

  final String docUiModuleOutput = "{" + LS
    + "  \"id\" : \"ui-1\"," + LS
    + "  \"name\" : \"sample-ui\"," + LS
    + "  \"uiDescriptor\" : {" + LS
    + "    \"npm\" : \"name-of-module-in-npm\"" + LS
    + "  }" + LS
    + "}";

  RestAssuredClient c;

  c = api.createRestAssured();
  r = c.given()
    .header("Content-Type", "application/json")
    .body(docUiModuleInput).post("/_/proxy/modules").then().statusCode(201)
    .body(equalTo(docUiModuleOutput)).extract().response();
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  String location = r.getHeader("Location");

  c = api.createRestAssured();
  c.given()
    .get(location)
    .then().statusCode(200).body(equalTo(docUiModuleOutput));
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  given().delete(location)
    .then().statusCode(204);
  checkDbIsEmpty("testUiModule done", context);

  async.complete();
}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:50,
代码来源:ModuleTest.java

示例13: testSemVer

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void testSemVer(TestContext context) {
  async = context.async();

  RestAssuredClient c;
  Response r;
  RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml")
    .assumingBaseUri("https://okapi.cloud");

  c = api.createRestAssured();

  String docSampleModule = "{" + LS
    + "  \"id\" : \"sample-1.2.3-alpha.1\"," + LS
    + "  \"name\" : \"sample module 3\"" + LS
    + "}";

  c = api.createRestAssured();
  r = c.given()
    .header("Content-Type", "application/json")
    .body(docSampleModule)
    .post("/_/proxy/modules")
    .then()
    .statusCode(201)
    .log().ifValidationFails()
    .extract().response();
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  docSampleModule = "{" + LS
    + "  \"id\" : \"sample-1.2.3-SNAPSHOT.5\"," + LS
    + "  \"name\" : \"sample module 3\"" + LS
    + "}";

  c = api.createRestAssured();
  r = c.given()
    .header("Content-Type", "application/json")
    .body(docSampleModule)
    .post("/_/proxy/modules")
    .then()
    .statusCode(201)
    .log().ifValidationFails()
    .extract().response();
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  docSampleModule = "{" + LS
    + "  \"id\" : \"sample-1.2.3-alpha.1+2017\"," + LS
    + "  \"name\" : \"sample module 3\"" + LS
    + "}";

  c = api.createRestAssured();
  r = c.given()
    .header("Content-Type", "application/json")
    .body(docSampleModule)
    .post("/_/proxy/modules")
    .then()
    .statusCode(201)
    .log().ifValidationFails()
    .extract().response();
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  async.complete();
}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:65,
代码来源:ModuleTest.java

示例14: test1

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void test1() {
  RestAssured.port = port;

  RamlDefinition api = RamlLoaders.fromFile("src/main/raml").load("okapi.raml")
          .assumingBaseUri("https://okapi.cloud");

  RestAssuredClient c;
  Response r;

  c = api.createRestAssured();
  c.given().get("/_/env").then().statusCode(200).body(equalTo("[ ]"));
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
          c.getLastReport().isEmpty());

  c = api.createRestAssured();
  c.given().get("/_/env/name1").then().statusCode(404);
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
          c.getLastReport().isEmpty());

  final String badDoc = "{" + LS
    + "  \"name\" : \"BADJSON\"," + LS // the comma here makes it bad json!
    + "}";
  c = api.createRestAssured();
  c.given()
          .header("Content-Type", "application/json")
          .body(badDoc).post("/_/env")
          .then().statusCode(400);

  final String doc = "{" + LS
          + "  \"name\" : \"name1\"," + LS
          + "  \"value\" : \"value1\"" + LS
          + "}";

  c = api.createRestAssured();
  r = c.given()
          .header("Content-Type", "application/json")
          .body(doc).post("/_/env")
          .then()
          .statusCode(201)
          .body(equalTo(doc))
          .extract().response();
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
          c.getLastReport().isEmpty());
  String locationName1 = r.getHeader("Location");

  c = api.createRestAssured();
  c.given().get(locationName1)
          .then()
          .statusCode(200)
          .body(equalTo(doc));
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
          c.getLastReport().isEmpty());

  c = api.createRestAssured();
  c.given().get("/_/env").then().statusCode(200);
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
          c.getLastReport().isEmpty());

  c = api.createRestAssured();
  c.given().delete(locationName1)
          .then()
          .statusCode(204);
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
          c.getLastReport().isEmpty());

  c = api.createRestAssured();
  c.given().get(locationName1).then().statusCode(404);
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
          c.getLastReport().isEmpty());

  c = api.createRestAssured();
  c.given().get("/_/env").then().statusCode(200).body(equalTo("[ ]"));
  Assert.assertTrue("raml: " + c.getLastReport().toString(),
          c.getLastReport().isEmpty());

}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:78,
代码来源:EnvTest.java

示例15: test3

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Test
public void test3() {
  RamlDefinition api
    = RamlLoaders.fromFile("src/main/raml").load("okapi.raml").assumingBaseUri("https://okapi.cloud");
  RestAssuredClient c;

  // pull frome dummy server
  final String pullPort3 = "{" + LS
    + "\"urls\" : [" + LS
    + "  \"http://localhost:" + port3 + "\"" + LS
    + "  ]" + LS
    + "}";
  c = api.createRestAssured();
  c.given().port(port2)
    .header("Content-Type", "application/json")
    .body(pullPort3).post("/_/proxy/pull/modules").then().statusCode(400).log().ifValidationFails();
  Assert.assertTrue(
    "raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  // pull from non-existing server
  final String pullPort4 = "{" + LS
    + "\"urls\" : [" + LS
    + "  \"http://localhost:" + port4 + "\"" + LS
    + "  ]" + LS
    + "}";
  c = api.createRestAssured();
  c.given().port(port2)
    .header("Content-Type", "application/json")
    .body(pullPort4).post("/_/proxy/pull/modules").then().statusCode(404).log().ifValidationFails();
  Assert.assertTrue(
    "raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  // first non-existing, then dummy
  final String pullBoth1 = "{" + LS
    + "\"urls\" : [" + LS
    + "  \"http://localhost:" + port3 + "\"," + LS
    + "  \"http://localhost:" + port4 + "\"" + LS
    + "  ]" + LS
    + "}";

  // pull from from both
  c = api.createRestAssured();
  c.given().port(port2)
    .header("Content-Type", "application/json")
    .body(pullBoth1).post("/_/proxy/pull/modules").then().statusCode(400).log().ifValidationFails();
  Assert.assertTrue(
    "raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());

  // first dummy, then non-existing
  final String pullBoth2 = "{" + LS
    + "\"urls\" : [" + LS
    + "  \"http://localhost:" + port4 + "\"," + LS
    + "  \"http://localhost:" + port3 + "\"" + LS
    + "  ]" + LS
    + "}";

  // pull from from both
  c = api.createRestAssured();
  c.given().port(port2)
    .header("Content-Type", "application/json")
    .body(pullBoth2).post("/_/proxy/pull/modules").then().statusCode(400).log().ifValidationFails();
  Assert.assertTrue(
    "raml: " + c.getLastReport().toString(),
    c.getLastReport().isEmpty());
}
 

开发者ID:folio-org,
项目名称:okapi,
代码行数:69,
代码来源:PullTest.java

示例16: init

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
@Override
public void init(FilterConfig filterConfig) throws ServletException {
    api = RamlLoaders.fromClasspath(getClass()).load("api.yaml");
    log.info(api.validate().toString());
}
 

开发者ID:nidi3,
项目名称:raml-tester,
代码行数:6,
代码来源:RamlFilter.java

示例17: fetchRamlDefinition

点赞 2

import guru.nidi.ramltester.RamlLoaders; //导入依赖的package包/类
public RamlDefinition fetchRamlDefinition() {
    return RamlLoaders.fromFile(".")
            .load(getRamlUri())
            .ignoringXheaders(isIgnoreXheaders())
            .assumingBaseUri(getBaseOrTargetUri());
}
 

开发者ID:nidi3,
项目名称:raml-tester-proxy,
代码行数:7,
代码来源:ServerOptions.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)