3 Replies Latest reply on Apr 12, 2008 2:18 AM by Adrien Adrien

    How to test rich:fileUpload with jsfunit

    Adrien Adrien Apprentice

      There are someone who has an example of how to test fileUpload with jsfunit?
      What are the componentid of each button?
      What are the parameter need for test ?
      Thanks for your help.


        • 1. Re: How to test rich:fileUpload with jsfunit
          Stan Silvert Master

          I haven't looked at the new components that shipped with RichFaces 3.2. As far as I know, nobody has tried fileUpload yet. Hopefully, it's something I can get to soon. If you figure it out please let us know.

          Stan

          • 2. Re: How to test rich:fileUpload with jsfunit
            Laurent Nonnenmacher Newbie

            Here is an example of what I tested:


            public void setFileParameter(String id, String filename)
            throws SAXException
            {
            if (filename == null) {
            return;
            }
            File f = new File(filename);
            if (!f.exists()) {
            System.out.println("Page.setFileParameter: file does not exist: " + f.toString());
            return;
            }
            WebForm forms[] = client.getWebResponse().getForms();

            WebForm webForm = null;
            for (int i = 0; i < forms.length; i++) {
            if (client.getClientIDs().isAncestor(id, forms.getID())) {
            webForm = forms
            ;
            }
            }

            if (webForm == null) {
            throw new ComponentIDNotFoundException("form not found");
            }
            UploadFileSpec[] uploadFileSpec = new UploadFileSpec[1];
            InputStream stream = null;
            try {
            stream = new FileInputStream(f);
            } catch (FileNotFoundException e) {
            e.printStackTrace();
            }
            uploadFileSpec[0] =
            new UploadFileSpec(filename, stream, getContentType(filename));


            webForm.setParameter(id, uploadFileSpec);
            Element element = DOMUtil.findElementWithID(id, client.getUpdatedDOM());
            element.setAttribute("value", filename);

            }


            Laurent

            • 3. Re: How to test rich:fileUpload with jsfunit
              Adrien Adrien Apprentice

              Thanks Laurent. It was not simple..I m going to try your solution