@Test
  public void testPostEmployee() {
    if (null == cookie) {
      fail("cannot login!!!");
    }
    Employee ep1 = generateEmployee();

    try {
      ResteasyClient client = new ResteasyClientBuilder().build();

      WebTarget target = client.target(baseUrl + "/rest/ag/employee");
      client.register(new CookieRequestFilter(cookie));

      Response response = target.request().post(Entity.entity(ep1, "application/json"));

      if (response.getStatus() != 200) {
        throw new RuntimeException("Failed : HTTP error code : " + response.getStatus());
      }

      Employee value = response.readEntity(Employee.class);
      System.out.println("Server response : \n");
      System.out.println(value.toString());

      assertEquals("same first name", "Special", value.getFirstName());

      client.close();

    } catch (Exception e) {

      e.printStackTrace();
    }
  }
예제 #2
0
 @Test
 public void testMe() throws Exception {
   ResteasyClient client = new ResteasyClient();
   MyTest proxy = client.target(TestPortProvider.generateURL("")).proxy(MyTest.class);
   try {
     proxy.postIt("hello");
     Assert.fail();
   } catch (NotAuthorizedException e) {
     Assert.assertEquals(401, e.getResponse().getStatus());
   }
   client.close();
 }
예제 #3
0
 @After
 public void tearDown() throws Exception {
   if (client != null) {
     client.close();
   }
 }
예제 #4
0
 @After
 public void after() {
   client.close();
   client = null;
 }
예제 #5
0
 @After
 public void after() throws Exception {
   client.close();
   client = null;
 }
 @AfterClass
 public static void shutdown() throws Exception {
   client.close();
   EmbeddedContainer.stop();
   deployment = null;
 }