Package com.sun.jersey.samples.jmaki.beans

Examples of com.sun.jersey.samples.jmaki.beans.Printer


     * Test checks GET on resource "printers/ids" based on id.
     */
    @Test
    public void doTestGetPrinterBasedOnId() {
        WebResource webResource = resource();
        Printer printer = webResource.path("printers").path("ids").path("P01").accept(MediaType.APPLICATION_JSON).get(Printer.class);
        Assert.assertEquals("Method: doTestGetPrinterBasedOnId \nMessage: ID of the retrieved printer " +
                "doesn't match the search value", "P01", printer.id);
    }
View Full Code Here


    @Test
    public void doTestPutPrinterBasedOnId() {
        WebResource webResource = resource();
        LoggingFilter loggingFilter = new LoggingFilter();
        webResource.addFilter(loggingFilter);
        Printer printer = webResource.path("printers").path("ids").path("P01").accept(MediaType.APPLICATION_JSON).get(Printer.class);
        String printerModel = printer.model;
        String printerLocation = printer.location;
        String printerUrl = printer.url;
        printer = new Printer("P01", "Xerox", printerLocation, printerUrl);
        ClientResponse response = webResource.path("printers").path("ids").path("P01").type(MediaType.APPLICATION_JSON).put(ClientResponse.class, printer);
        Assert.assertEquals("Method: doTestPutPrinterBasedOnId \nMessage: Response status doesn't match the expected value.",
                Response.Status.NO_CONTENT, response.getResponseStatus());
        printer = webResource.path("printers").path("ids").path("P01").accept(MediaType.APPLICATION_JSON).get(Printer.class);
        Assert.assertNotSame("Method: doTestPutPrinterBasedOnId \nMessage: Printer holds the old model inspite of update.", printerModel, printer.model);
View Full Code Here

    }

    public Map<String, Printer> getPrinters() {
        if (null == printers) {
            printers = new HashMap<String, Printer>();
            printers.put("P01", new Printer("P01", "OKI123", "lpd://p01", "room 1"));
            printers.put("P02", new Printer("P02", "OKI123", "lpd://p02", "room 12"));
            printers.put("P03", new Printer("P03", "OKI123", "lpd://p03", "room 133"));
            printers.put("P05", new Printer("P05", "Xerox345", "lpd://p05", "room 543"));
            printers.put("P06", new Printer("P06", "Xerox345", "lpd://p06", "room 203"));
        }
        return printers;
    }
View Full Code Here

TOP

Related Classes of com.sun.jersey.samples.jmaki.beans.Printer

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.