Package com.sun.jersey.api.core

Examples of com.sun.jersey.api.core.HttpContext


      @Override
      public String getName() {
        return "bar";
      }
    });
    HttpContext context = Mockito.mock(HttpContext.class);
    Mockito.when(context.getRequest()).thenReturn(request);
    UserProvider up = new UserProvider();
    Assert.assertEquals(up.getValue(context).getName(), "bar");
    Assert.assertEquals(MDC.get("user"), "bar");
  }
View Full Code Here


    HttpRequestContext request = Mockito.mock(HttpRequestContext.class);
    Mockito.when(request.getUserPrincipal()).thenReturn(null);
    MultivaluedMap map = Mockito.mock(MultivaluedMap.class);
    Mockito.when(map.getFirst(UserProvider.USER_NAME_PARAM)).thenReturn(null);
    Mockito.when(request.getQueryParameters()).thenReturn(map);
    HttpContext context = Mockito.mock(HttpContext.class);
    Mockito.when(context.getRequest()).thenReturn(request);
    UserProvider up = new UserProvider();
    assertNull(up.getValue(context));
    assertNull(MDC.get("user"));
  }
View Full Code Here

    HttpRequestContext request = Mockito.mock(HttpRequestContext.class);
    Mockito.when(request.getUserPrincipal()).thenReturn(null);
    MultivaluedMap map = Mockito.mock(MultivaluedMap.class);
    Mockito.when(map.getFirst(UserProvider.USER_NAME_PARAM)).thenReturn("foo");
    Mockito.when(request.getQueryParameters()).thenReturn(map);
    HttpContext context = Mockito.mock(HttpContext.class);
    Mockito.when(context.getRequest()).thenReturn(request);
    UserProvider up = new UserProvider();
    assertEquals(up.getValue(context).getName(), "foo");
    assertEquals(MDC.get("user"), "foo");
  }
View Full Code Here

      @Override
      public String getName() {
        return "bar";
      }
    });
    HttpContext context = Mockito.mock(HttpContext.class);
    Mockito.when(context.getRequest()).thenReturn(request);
    UserProvider up = new UserProvider();
    assertEquals(up.getValue(context).getName(), "bar");
    assertEquals(MDC.get("user"), "bar");
  }
View Full Code Here

    HttpRequestContext request = Mockito.mock(HttpRequestContext.class);
    Mockito.when(request.getUserPrincipal()).thenReturn(null);
    MultivaluedMap map = Mockito.mock(MultivaluedMap.class);
    Mockito.when(map.getFirst(UserProvider.USER_NAME_PARAM)).thenReturn(null);
    Mockito.when(request.getQueryParameters()).thenReturn(map);
    HttpContext context = Mockito.mock(HttpContext.class);
    Mockito.when(context.getRequest()).thenReturn(request);
    UserProvider up = new UserProvider();
    assertNull(up.getValue(context));
    assertNull(MDC.get("user"));
  }
View Full Code Here

    HttpRequestContext request = Mockito.mock(HttpRequestContext.class);
    Mockito.when(request.getUserPrincipal()).thenReturn(null);
    MultivaluedMap map = Mockito.mock(MultivaluedMap.class);
    Mockito.when(map.getFirst(UserProvider.USER_NAME_PARAM)).thenReturn("foo");
    Mockito.when(request.getQueryParameters()).thenReturn(map);
    HttpContext context = Mockito.mock(HttpContext.class);
    Mockito.when(context.getRequest()).thenReturn(request);
    UserProvider up = new UserProvider();
    assertEquals(up.getValue(context).getName(), "foo");
    assertEquals(MDC.get("user"), "foo");
  }
View Full Code Here

      @Override
      public String getName() {
        return "bar";
      }
    });
    HttpContext context = Mockito.mock(HttpContext.class);
    Mockito.when(context.getRequest()).thenReturn(request);
    UserProvider up = new UserProvider();
    assertEquals(up.getValue(context).getName(), "bar");
    assertEquals(MDC.get("user"), "bar");
  }
View Full Code Here

    @Test
    public void itInjectsTheFirstAcceptableLanguageFromTheRequest() throws Exception {
      final HttpRequestContext request = mock(HttpRequestContext.class);
      when(request.getAcceptableLanguages()).thenReturn(ImmutableList.of(Locale.CANADA, Locale.GERMANY));
     
      final HttpContext context = mock(HttpContext.class);
      when(context.getRequest()).thenReturn(request);
     
      assertThat(provider.getValue(context), is(Locale.CANADA));
    }
View Full Code Here

    @Test
    public void itInjectsTheDefaultLocaleIfNoLanguagesAreGiven() throws Exception {
      final HttpRequestContext request = mock(HttpRequestContext.class);
      when(request.getAcceptableLanguages()).thenReturn(ImmutableList.<Locale>of());
     
      final HttpContext context = mock(HttpContext.class);
      when(context.getRequest()).thenReturn(request);
     
      assertThat(provider.getValue(context), is(Locale.getDefault()));
    }
View Full Code Here

    @Test
    public void itInjectsTheDefaultLocaleIfAllLanguagesAreAcceptable() throws Exception {
      final HttpRequestContext request = mock(HttpRequestContext.class);
      when(request.getAcceptableLanguages()).thenReturn(ImmutableList.of(new Locale("*")));
     
      final HttpContext context = mock(HttpContext.class);
      when(context.getRequest()).thenReturn(request);
     
      assertThat(provider.getValue(context), is(Locale.getDefault()));
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.api.core.HttpContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.