Package org.wiztools.restclient.bean

Examples of org.wiztools.restclient.bean.Response


    public void testWriteResponseXML() throws Exception {
        System.out.println("writeResponseXML");
        ResponseBean bean = getDefaultResponseBean();
        File f = File.createTempFile("prefix", ".rcs");
        XMLUtil.writeResponseXML(bean, f);
        Response expResult = XMLUtil.getResponseFromXMLFile(f);
        assertEquals(expResult, bean);
    }
View Full Code Here


        System.out.println("getResponseFromXMLFile");
        File f = new File("src/test/resources/resFromXml.rcs");

        ResponseBean expResult = getDefaultResponseBean();
       
        Response result = XMLUtil.getResponseFromXMLFile(f);
        assertEquals(expResult, result);
    }
View Full Code Here

    }
   
    private void jb_nextAction(){
        try{
            Request request = null;
            Response response = null;
            if(jrb_archive.isSelected()){
                if(archiveFile == null){
                    JOptionPane.showMessageDialog(ui.getFrame(),
                            "Please select a file!", "Error", JOptionPane.ERROR_MESSAGE);
                    return;
View Full Code Here

            catch(IllegalStateException ex) {
                view.showError(Util.getStackTrace(ex));
            }
        }
        else if(type == FileChooserType.SAVE_RESPONSE){
            Response response = view.getLastResponse();
            if(response == null){
                JOptionPane.showMessageDialog(view.getContainer(),
                        "No last response available.",
                        "No Response",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            Response uiResponse = view.getResponseFromUI();
            if(!response.equals(uiResponse)){
                if(!doSaveEvenIfUIChanged(DO_SAVE_UI_RESPONSE)){
                    return;
                }
            }
            File f = getSaveFile(FileChooserType.SAVE_RESPONSE);
            if(f != null){
                try{
                    XMLUtil.writeResponseXML(response, f);
                    recentFilesHelper.openedFile(f);
                }
                catch(IOException ex){
                    view.showError(Util.getStackTrace(ex));
                }
                catch(XMLException ex){
                    view.showError(Util.getStackTrace(ex));
                }
            }
        }
        else if(type == FileChooserType.SAVE_RESPONSE_BODY){
            Response response = view.getLastResponse();
            if(response == null){
                JOptionPane.showMessageDialog(view.getContainer(),
                        "No last response available.",
                        "No Response",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            if(response.getResponseBody() == null) {
                JOptionPane.showMessageDialog(view.getContainer(),
                        "Last response does not have body.",
                        "No Body in Response",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            File f = getSaveFile(FileChooserType.SAVE_RESPONSE_BODY);
            if(f != null){
                try{
                    FileUtil.writeBytes(f, response.getResponseBody());
                }
                catch(IOException ex){
                    view.showError(Util.getStackTrace(ex));
                }
            }
        }
        else if(type == FileChooserType.SAVE_ARCHIVE){
            Request request = view.getLastRequest();
            Response response = view.getLastResponse();
            if(request == null || response == null){
                JOptionPane.showMessageDialog(view.getContainer(),
                        "No last request/response available.",
                        "No Request/Response",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }
            try {
                Request uiRequest = view.getRequestFromUI();
                Response uiResponse = view.getResponseFromUI();
                if((!request.equals(uiRequest)) || (!response.equals(uiResponse))){
                    if(!doSaveEvenIfUIChanged(DO_SAVE_UI_ARCHIVE)){
                        return;
                    }
                }
View Full Code Here

    }
   
    public static void openResponse(final RESTView view, final File f) {
        Exception e = null;
        try{
            Response response = XMLUtil.getResponseFromXMLFile(f);
            view.setUIFromResponse(response);
        }
        catch(IOException | XMLException ex){
            e = ex;
        }
View Full Code Here

    public static void openArchive(final RESTView view, final File f) {
        Exception e = null;
        try{
            ReqResBean encp = Util.getReqResArchive(f);
            Request request = encp.getRequestBean();
            Response response = encp.getResponseBean();
            if(request != null && response != null){
                view.setUIFromRequest(request);
                view.setUIFromResponse(response);
            }
            else{
View Full Code Here

                        Request reqBean = XMLUtil.getRequestFromXMLFile(tmpFile);
                        encpBean.setRequestBean(reqBean);
                        isReqRead = true;
                    }
                    else if(entry.getName().equals("response.rcs")){
                        Response resBean = XMLUtil.getResponseFromXMLFile(tmpFile);
                        encpBean.setResponseBean(resBean);
                        isResRead = true;
                    }
                }
                finally{
View Full Code Here

TOP

Related Classes of org.wiztools.restclient.bean.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.