コード例 #1
0
ファイル: CredentialsTest.java プロジェクト: mrjonny2/grendel
 @Test
 public void itThrowsAn401() throws Exception {
   try {
     creds.buildSession(userDAO, "whee");
     fail("should have thrown an auth challenge, but didn't");
   } catch (WebApplicationException e) {
     assertThat(e.getResponse().getStatus()).isEqualTo(Status.FORBIDDEN.getStatusCode());
   }
 }
コード例 #2
0
 @Test
 public void gettingAResourceByAnUnauthorizedUser() {
   denieAuthorizationToUsers();
   try {
     getAt(aResourceURI(), getWebEntityClass());
     fail("An unauthorized user shouldn't access the resource");
   } catch (WebApplicationException ex) {
     int receivedStatus = ex.getResponse().getStatus();
     int forbidden = Status.FORBIDDEN.getStatusCode();
     assertThat(receivedStatus, is(forbidden));
   }
 }
コード例 #3
0
 @Test
 public void updateOfResourceByANonAuthorizedUser() {
   denieAuthorizationToUsers();
   try {
     putAt(aResourceURI(), aResource());
     fail("An unauthorized user shouldn't update a resource");
   } catch (WebApplicationException ex) {
     int receivedStatus = ex.getResponse().getStatus();
     int forbidden = Status.FORBIDDEN.getStatusCode();
     assertThat(receivedStatus, is(forbidden));
   }
 }
コード例 #4
0
public class CustomStatusTypesTest {

  private final CustomStatusTypes customStatusTypes =
      new CustomStatusTypes(Family.INFORMATIONAL, Status.FORBIDDEN.ordinal(), "Unknown Reason");

  @Test
  public void testGetFamily() {
    // TODO Auto-generated method stub
    Assert.assertEquals(0, Family.INFORMATIONAL.compareTo(customStatusTypes.getFamily()));
  }

  @Test
  public void testGetReasonPhrase() {
    // TODO Auto-generated method stub
    Assert.assertEquals("Unknown Reason", customStatusTypes.getReasonPhrase());
  }

  @Test
  public void testGetStatusCode() {
    // TODO Auto-generated method stub
    Assert.assertEquals(Status.FORBIDDEN.ordinal(), customStatusTypes.getStatusCode());
  }
}
コード例 #5
0
 @Test
 public void testGetStatusCode() {
   // TODO Auto-generated method stub
   Assert.assertEquals(Status.FORBIDDEN.ordinal(), customStatusTypes.getStatusCode());
 }