Package javax.ws.rs.core

Examples of javax.ws.rs.core.Response


   }

   @Test
   public void testContentLocationQueryString()
   {
      Response r = builder.location(URI.create("/res?query")).build();
      String actualUri = r.getMetadata().getFirst("Location").toString();

      Assert.assertEquals("http://localhost/res?query", actualUri);
   }
View Full Code Here


   }

   @Test
   public void testContentLocationFragment()
   {
      Response r = builder.contentLocation(URI.create("/res#frag")).build();
      String actualUri = r.getMetadata().getFirst("Content-Location").toString();

      Assert.assertEquals("http://localhost/res#frag", actualUri);
   }
View Full Code Here

         return "hello world";
      }

      public String error()
      {
         Response r = Response.status(404).type("text/plain").entity("there was an error").build();
         throw new NoLogWebApplicationException(r);
      }
View Full Code Here

            {
               try
               {
                  System.out.println("STARTED!!!!");
                  Thread.sleep(1000);
                  Response jaxrs = Response.ok("hello").type(MediaType.TEXT_PLAIN).build();
                  response.setResponse(jaxrs);
               }
               catch (Exception e)
               {
                  e.printStackTrace();
View Full Code Here

         }
         else
         {
            base = createURI("/" + abs + "/new/one");
         }
         Response response = Response.temporaryRedirect(URI.create("new/one")).build();
         URI uri = (URI) response.getMetadata().getFirst(HttpHeaderNames.LOCATION);
         System.out.println("Location uri: " + uri);
         Assert.assertEquals(base.getPath(), uri.getPath());
         return "CONTENT";
      }
View Full Code Here

      m.setVersionMajor("4");
      m.setVersionMinor("1");
      IMessageTFMResource client = ProxyFactory.create(
              IMessageTFMResource.class,
              generateBaseUrl());
      Response r = client.saveMessage(m);
      Assert.assertEquals(r.getStatus(), 201);
   }
View Full Code Here

    }

    @GET
    @Path("method2/{p}")
    public Response method2(@PathParam("p") String path) {
        Response res = Response.ok("ClassC Method2;" + path).build();
        return res;
    }
View Full Code Here

        Bus springBus = bf.createBus(busFile.toString());
        bean.setBus(springBus);

        WebClient wc = bean.createWebClient();
        wc.header("Authorization", "SAML invalid_grant");
        Response r = wc.get();
        assertEquals(401, r.getStatus());
    }
View Full Code Here

        }
       
    }
    private void reportError(String message, Exception ex, int status) {
        LOG.warning(message);
        Response response = JAXRSUtils.toResponseBuilder(status).type("text/plain").entity(message).build();
        throw ExceptionUtils.toHttpException(ex, response);
    }
View Full Code Here

        // technically speaking, for these test cases, the client should return an error
        // however, servers do send bad data from time to time so we try to be forgiving
        for (int i = 0; i < 3; i++) {
            WebClient wc = WebClient.create(endpointAddress);
            WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split", true);
            Response r = wc.query("type", Integer.toString(i)).get();
            assertEquals(responses[i], r.getMetadata().get("SomeHeader" + i).get(0));
        }

        // this test currently returns the WRONG result per RFC2616, however it is correct
        // per the discussion in CXF-3518
        WebClient wc = WebClient.create(endpointAddress);
        WebClient.getConfig(wc).getRequestContext().put("org.apache.cxf.http.header.split", true);
        Response r3 = wc.query("type", "3").get();
        List<Object> r3values = r3.getMetadata().get("SomeHeader3");
        assertEquals(4, r3values.size());
        assertEquals("some text", r3values.get(0));
        assertEquals("\"other quoted\"", r3values.get(1));
        assertEquals("text", r3values.get(2));
        assertEquals("blah", r3values.get(3));
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.Response

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.