当前位置: 首页>>代码示例>>Java>>正文


Java Status类代码示例

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


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

示例1: checkThatUnboundRoutesAreTheSame

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void checkThatUnboundRoutesAreTheSame() throws Exception {
    HttpResponse<String> response = post("/corsTests/unbound").header(ORIGIN, "http://localhost").asString();
    assertThat(response.code()).isEqualTo(Status.NOT_FOUND);
    assertThat(response.header(ACCESS_CONTROL_ALLOW_ORIGIN)).isNull();
    assertThat(response.header(ACCESS_CONTROL_ALLOW_HEADERS)).isNull();

    response = new HttpRequestWithBody(HttpMethod.OPTIONS, getHttpURl("/corsTests/unbound"))
            .header(ORIGIN, "http://localhost").header(ACCESS_CONTROL_REQUEST_METHOD, "POST").asString();
    assertThat(response.code()).isEqualTo(Status.NOT_FOUND);
    assertThat(response.header(ACCESS_CONTROL_ALLOW_ORIGIN)).isNull();
    assertThat(response.header(ACCESS_CONTROL_ALLOW_HEADERS)).isNull();

    response = new HttpRequestWithBody(HttpMethod.OPTIONS, getHttpURl("/corsTests/unbound")).asString();
    assertThat(response.code()).isEqualTo(Status.NOT_FOUND);
    assertThat(response.header(ACCESS_CONTROL_ALLOW_ORIGIN)).isNull();
    assertThat(response.header(ACCESS_CONTROL_ALLOW_HEADERS)).isNull();
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:19,代码来源:CorsFilterIT.java

示例2: checkRoundRobin

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void checkRoundRobin() throws Exception {
    HttpResponse<String> response = get("/balancer").asString();
    assertThat(response.code()).isEqualTo(Status.OK);
    assertThat(response.body()).contains("Perdu").contains("Internet");

    boolean perdus = false;
    if (response.body().contains("Perdus sur Internet")) {
        perdus = true;
    }

    response = get("/balancer").asString();
    assertThat(response.code()).isEqualTo(Status.OK);
    if (perdus) {
        // Should be perdu now
        assertThat(response.body()).contains("Perdu sur l'Internet ?");
    } else {
        // Should be perdus
        assertThat(response.body()).contains("Perdus sur Internet ?");
    }
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:22,代码来源:BalancerFilterIT.java

示例3: testThatTheTCCLIsCorrectlyMigrated

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void testThatTheTCCLIsCorrectlyMigrated()
        throws ExecutionException, InterruptedException, MalformedURLException {
    final URLClassLoader loader = new URLClassLoader(new URL[]{
            new File("").toURI().toURL()
    });
    Callable<Result> computation = new Callable<Result>() {
        @Override
        public Result call() throws Exception {
            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            System.out.println(classLoader);
            if (classLoader == loader) {
                return Results.ok();
            }
            return Results.badRequest();
        }
    };

    Thread.currentThread().setContextClassLoader(loader);
    Future<Result> future = service.submit(computation);

    assertThat(future.get().getStatusCode()).isEqualTo(Status.OK);
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:24,代码来源:TCCLExecutionContextServiceTest.java

示例4: testThatWeCanRetrieveBundles

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void testThatWeCanRetrieveBundles() throws Exception {
    String bundle = get("/i18n/bundles/Messages_fr.properties").asString().body();
    assertThat(bundle)
            .contains("welcome=bonjour")
            .contains("lang=français");

    // No Locale
    bundle = get("/i18n/bundles/Messages.properties").asString().body();
    assertThat(bundle)
            .contains("welcome=hello")
            .contains("lang=english");

    // Not provided locale
    HttpResponse<String> response = get("/i18n/bundles/.properties").asString();
    assertThat(response.code()).isEqualTo(Status.NOT_FOUND);


    // Not provided locale
    response = get("/i18n/bundles/.properties").asString();
    assertThat(response.code()).isEqualTo(Status.NOT_FOUND);
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:23,代码来源:I18NControllerIT.java

示例5: testWelcome

import org.wisdom.api.http.Status; //导入依赖的package包/类
/**
 * Checks that your controller is returning OK.
 */
@Test
public void testWelcome() throws Exception {
    WelcomeController controller = new WelcomeController();
    // Use a mock to simulate the template.
    // You can do this for every service and template your controller is using.
    controller.welcome = mock(Template.class);
    Result result = controller.welcome();
    assertThat(result.getStatusCode()).isEqualTo(Status.OK);
    Result listDb = controller.listDb();
    assertThat(result.getStatusCode()).isEqualTo(Status.OK);
}
 
开发者ID:mackristof,项目名称:follow-me-wisdom,代码行数:15,代码来源:UnitTest.java

示例6: shouldAuthorizeWithTokenAsParameter

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldAuthorizeWithTokenAsParameter() throws Exception {
    Map<String, List<String>> values = new HashMap<>();
    values.put("access_token", singletonList(TOKEN));
    when(request.parameters()).thenReturn(values);

    RequiredScopesInterceptor interceptor = new RequiredScopesInterceptor(introspectionService, "test");
    Result result = interceptor.call(scopes, context);

    assertThat(result.getStatusCode()).isEqualTo(Status.OK);
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:12,代码来源:RequiredScopesInterceptorTest.java

示例7: shouldAuthorizeWithTokenAsHeader

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldAuthorizeWithTokenAsHeader() throws Exception {
    Map<String, List<String>> values = new HashMap<>();
    values.put(AUTHORIZATION, singletonList(format("Bearer %s", TOKEN)));
    when(request.headers()).thenReturn(values);

    RequiredScopesInterceptor interceptor = new RequiredScopesInterceptor(introspectionService, "test");
    Result result = interceptor.call(scopes, context);

    assertThat(result.getStatusCode()).isEqualTo(Status.OK);
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:12,代码来源:RequiredScopesInterceptorTest.java

示例8: shouldNotAuthorizeBecauseOfMissingToken

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldNotAuthorizeBecauseOfMissingToken() throws Exception {
    RequiredScopesInterceptor interceptor = new RequiredScopesInterceptor(introspectionService, "test");
    Result result = interceptor.call(scopes, context);

    assertThat(result.getStatusCode()).isEqualTo(Status.UNAUTHORIZED);
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:8,代码来源:RequiredScopesInterceptorTest.java

示例9: shouldNotAuthorizeBecauseOfInvalidToken

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldNotAuthorizeBecauseOfInvalidToken() throws Exception {
    Map<String, List<String>> values = new HashMap<>();
    values.put("access_token", singletonList(TOKEN_INVALID));
    when(request.parameters()).thenReturn(values);

    RequiredScopesInterceptor interceptor = new RequiredScopesInterceptor(introspectionService, "test");
    Result result = interceptor.call(scopes, context);

    assertThat(result.getStatusCode()).isEqualTo(Status.UNAUTHORIZED);
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:12,代码来源:RequiredScopesInterceptorTest.java

示例10: shouldNotAuthorizeBecauseOfMultipleQueryToken

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldNotAuthorizeBecauseOfMultipleQueryToken() throws Exception {
    Map<String, List<String>> values = new HashMap<>();
    values.put("access_token", asList(TOKEN, TOKEN_INVALID));
    when(request.parameters()).thenReturn(values);

    RequiredScopesInterceptor interceptor = new RequiredScopesInterceptor(introspectionService, "test");
    Result result = interceptor.call(scopes, context);

    assertThat(result.getStatusCode()).isEqualTo(Status.BAD_REQUEST);
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:12,代码来源:RequiredScopesInterceptorTest.java

示例11: shouldNotAuthorizeBecauseOfMultipleHeaderToken

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldNotAuthorizeBecauseOfMultipleHeaderToken() throws Exception {
    Map<String, List<String>> values = new HashMap<>();
    values.put(AUTHORIZATION, asList(format("Bearer %s", TOKEN), format("Bearer %s", TOKEN_INVALID)));
    when(request.headers()).thenReturn(values);

    RequiredScopesInterceptor interceptor = new RequiredScopesInterceptor(introspectionService, "test");
    Result result = interceptor.call(scopes, context);

    assertThat(result.getStatusCode()).isEqualTo(Status.BAD_REQUEST);
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:12,代码来源:RequiredScopesInterceptorTest.java

示例12: shouldNotAuthorizeBecauseOfNonBearerHeaderToken

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldNotAuthorizeBecauseOfNonBearerHeaderToken() throws Exception {
    Map<String, List<String>> values = new HashMap<>();
    values.put(AUTHORIZATION, singletonList("Basic alzt7jh3itua=="));
    when(request.headers()).thenReturn(values);

    RequiredScopesInterceptor interceptor = new RequiredScopesInterceptor(introspectionService, "test");
    Result result = interceptor.call(scopes, context);

    assertThat(result.getStatusCode()).isEqualTo(Status.BAD_REQUEST);
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:12,代码来源:RequiredScopesInterceptorTest.java

示例13: shouldNotAuthorizeBecauseOfMissingScopes

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldNotAuthorizeBecauseOfMissingScopes() throws Exception {
    Map<String, List<String>> values = new HashMap<>();
    values.put("access_token", singletonList(TOKEN_MISSING_SCOPES));
    when(request.parameters()).thenReturn(values);

    RequiredScopesInterceptor interceptor = new RequiredScopesInterceptor(introspectionService, "test");
    Result result = interceptor.call(scopes, context);

    assertThat(result.getStatusCode()).isEqualTo(Status.FORBIDDEN);
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:12,代码来源:RequiredScopesInterceptorTest.java

示例14: shouldExecuteActionWithTokenInQuery

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldExecuteActionWithTokenInQuery() throws Exception {
    HttpResponse<String> page = get("/protected")
            .field("access_token", TOKEN)
            .asString();

    assertThat(page.code()).isEqualTo(Status.OK);
    assertThat(page.body()).isEqualTo("Good");
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:10,代码来源:OAuth2ProtectionBlackBoxIT.java

示例15: shouldExecuteActionWithTokenInHeader

import org.wisdom.api.http.Status; //导入依赖的package包/类
@Test
public void shouldExecuteActionWithTokenInHeader() throws Exception {
    HttpResponse<String> page = get("/protected")
            .header(AUTHORIZATION, format("Bearer %s", TOKEN))
            .asString();

    assertThat(page.code()).isEqualTo(Status.OK);
    assertThat(page.body()).isEqualTo("Good");
}
 
开发者ID:sauthieg,项目名称:wisdom-oauth2-protection,代码行数:10,代码来源:OAuth2ProtectionBlackBoxIT.java


注:本文中的org.wisdom.api.http.Status类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。