Package org.wiztools.restclient.bean

Examples of org.wiztools.restclient.bean.Request


    public void testWriteRequestXML() throws Exception {
        System.out.println("writeRequestXML");
        RequestBean bean = getDefaultRequestBean();
        File f = File.createTempFile("prefix", ".rcq");
        XMLUtil.writeRequestXML(bean, f);
        Request expResult = XMLUtil.getRequestFromXMLFile(f);
        assertEquals(expResult, bean);
    }
View Full Code Here


        System.out.println("getRequestFromXMLFile");
        File f = new File("src/test/resources/reqFromXml.rcq");

        RequestBean expResult = getDefaultRequestBean();
       
        Request result = XMLUtil.getRequestFromXMLFile(f);
        assertEquals(expResult, result);
    }
View Full Code Here

     * @throws java.lang.Exception
     */
    @Test
    public void testIntegrityOfTestScript() throws Exception{
        File f = new File("src/test/resources/resTestScriptIntegrity.rcq");
        Request req = XMLUtil.getRequestFromXMLFile(f);
        File outFile = File.createTempFile("abc", "xyz");
        XMLUtil.writeRequestXML(req, outFile);
        Request req1 = XMLUtil.getRequestFromXMLFile(outFile);
        assertEquals(req.getTestScript(), req1.getTestScript());
    }
View Full Code Here

        else{
            for(String param: params){
                File f = new File(param);
                if(f.canRead()){
                    try{
                        Request request = XMLUtil.getRequestFromXMLFile(f);
                        View view = new CliView(outDir, f, command.saveResponseBody);
                        // Execute:
                        RequestExecuter executer = ServiceLocator.getInstance(RequestExecuter.class);
                        executer.execute(request, view);
                    }
View Full Code Here

        SSLReqBean ssl = new SSLReqBean();
        ssl.setTrustSelfSignedCert(true);
        ssl.setHostNameVerifier(SSLHostnameVerifier.ALLOW_ALL);
        expResult.setSslReq(ssl);
       
        Request actual = XMLUtil.getRequestFromXMLFile(new File("src/test/resources/reqSsl.rcq"));
       
        assertEquals(expResult, actual);
    }
View Full Code Here

        this.pack();
    }
   
    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);
View Full Code Here

            @Override
            public void actionPerformed(ActionEvent e) {
                // Verify if most recent history needs to be shown:
                if(historyManager.isMostRecent()) {
                    try {
                        Request reqFromUi = view.getRequestFromUI();
                        if(!reqFromUi.equals(historyManager.current())) {
                            view.setUIFromRequest(historyManager.current());
                            return;
                        }
                    }
                    catch(IllegalStateException ex) {
                        if(historyManager.current() != null) {
                            view.setUIFromRequest(historyManager.current());
                            return;
                        }
                    }
                }
               
                // Normal logic, cursor-1 history:
                if(!historyManager.isOldest()) {
                    Request request = historyManager.back();
                    if(request != null) {
                        view.setUIFromRequest(request);
                    }
                }
                else {
                    view.setStatusMessage("Already in oldest");
                }
            }
        });
        jm_history.add(jmi_back);
       
        final JMenuItem jmi_forward = new JMenuItem("Forward");
        jmi_forward.setAccelerator(KeyStroke.getKeyStroke(
                KeyEvent.VK_RIGHT, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
        jmi_forward.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                if(!historyManager.isMostRecent()) {
                    Request request = historyManager.forward();
                    if(request != null) {
                        view.setUIFromRequest(request);
                    }
                }
                else {
View Full Code Here

        return true;
    }
   
    private void actionSave(final FileChooserType type){
        if(type == FileChooserType.SAVE_REQUEST){
            Request request = view.getLastRequest();

            if(request == null){
                JOptionPane.showMessageDialog(view.getContainer(),
                        "No last request available.",
                        "No Request",
                        JOptionPane.ERROR_MESSAGE);
                return;
            }

            try {
                Request uiRequest = view.getRequestFromUI();
                if(!request.equals(uiRequest)){
                    if(!doSaveEvenIfUIChanged(DO_SAVE_UI_REQUEST)){
                        return;
                    }
                }

                File f = getSaveFile(FileChooserType.SAVE_REQUEST);
                if(f != null){
                    try{
                        XMLUtil.writeRequestXML(request, f);
                        recentFilesHelper.openedFile(f);
                    }
                    catch(IOException ex){
                        view.showError(Util.getStackTrace(ex));
                    }
                    catch(XMLException ex){
                        view.showError(Util.getStackTrace(ex));
                    }
                }
            }
            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

    private FileOpenUtil() {}
   
    public static void openRequest(RESTView view, File f) {
        Exception e = null;
        try{
            Request request = XMLUtil.getRequestFromXMLFile(f);
            view.setUIFromRequest(request);
        }
        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);
            }
View Full Code Here

TOP

Related Classes of org.wiztools.restclient.bean.Request

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.