Package com.sun.jersey.samples.storageservice

Examples of com.sun.jersey.samples.storageservice.Container


  public void testUpdateItem3() throws Exception {
    WebClient wc = WebClient.create(Main.BASE_URI);
    int createdResponse = Response.Status.CREATED.getStatusCode();

    // Create a child resource for the container "quotes"
    Container quotesContainer = new Container("quotes", Main.BASE_URI + "/quotes");

    // PUT the container "quotes"
    Response response = wc.path("containers/quotes").put(quotesContainer);

    // PUT the items to be added to the "quotes" container
View Full Code Here


  @Test
  public void testDeleteItem3AndSearchForKing() {
    WebClient wc = WebClient.create(Main.BASE_URI);

    // Create a child resource for the container "quotes"
    Container quotesContainer = new Container("quotes", Main.BASE_URI + "/quotes");

    // PUT the container "quotes"
    Response response = wc.path("containers/quotes").put(quotesContainer);
    response = wc.path("1").type(MediaType.TEXT_PLAIN)
        .put("Something is rotten in the state of Denmark");
    response = wc.back(false).path("2").type(MediaType.TEXT_PLAIN).put("I could be bounded in a nutshell");
    response = wc.back(false).path("3").type(MediaType.TEXT_PLAIN).put("catch the conscience of the king");
    response = wc.back(false).path("4").type(MediaType.TEXT_PLAIN).put("Get thee to a nunnery");

    // delete item 3
    wc.back(false).path("3").delete();

    // search the container for all items containing the word "king"
    wc.back(true).path("containers/quotes").query("search", "king");
    Container container = wc.accept(MediaType.APPLICATION_XML).get(Container.class);
    int numberOfItems = (container.getItem() == null) ? 0 : container.getItem().size();
    int expectedNumber = 0;
    assertEquals("Expected: " + expectedNumber
        + " items which pass the search criterion, Seeing: " + numberOfItems,
        expectedNumber, numberOfItems);
  }
View Full Code Here

  @Test
  public void testDeleteContainerQuotes() {
    WebClient wc = WebClient.create(Main.BASE_URI);

    // Create a child resource for the container "quotes"
    Container quotesContainer = new Container("quotes", Main.BASE_URI + "/quotes");

    // PUT the container "quotes"
    Response response = wc.path("containers/quotes").put(quotesContainer);

    // delete the container
View Full Code Here

        Item ii = MemoryStore.MS.createOrUpdateItem(container, i, data);
        if (ii == null) {
            // Create the container if one has not been created
            URI containerUri = uriInfo.getAbsolutePathBuilder().path("..").
                    build().normalize();
            Container c = new Container(container, containerUri.toString());
            MemoryStore.MS.createContainer(c);
            i = MemoryStore.MS.createOrUpdateItem(container, i, data);
            if (i == null)
                throw new NotFoundException("Container not found");
        }
View Full Code Here

   
    @GET
    public Container getContainer(@QueryParam("search") String search) {
        System.out.println("GET CONTAINER " + container + ", search = " + search);

        Container c = MemoryStore.MS.getContainer(container);
        if (c == null)
            throw new NotFoundException("Container not found");
       
       
        if (search != null) {
            c = c.clone();
            Iterator<Item> i = c.getItem().iterator();
            byte[] searchBytes = search.getBytes();
            while (i.hasNext()) {
                if (!match(searchBytes, container, i.next().getName()))
                    i.remove();
            }
View Full Code Here

    @PUT
    public Response putContainer() {
        System.out.println("PUT CONTAINER " + container);
       
        URI uri =  uriInfo.getAbsolutePath();
        Container c = new Container(container, uri.toString());
       
        Response r;
        if (!MemoryStore.MS.hasContainer(c)) {
            r = Response.created(uri).build();
        } else {
View Full Code Here

   
    @DELETE
    public void deleteContainer() {
        System.out.println("DELETE CONTAINER " + container);
       
        Container c = MemoryStore.MS.deleteContainer(container);
        if (c == null)
            throw new NotFoundException("Container not found");
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.samples.storageservice.Container

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.