Package servletunit.frame2

Examples of servletunit.frame2.RequestStream


      Object[] fileParms, String eventName) throws Exception {
    Configuration config = new Configuration(
        "org/megatome/frame2/front/test-config.xml"); //$NON-NLS-1$

    NVPair[] hdrs = new NVPair[1];
    Frame2HttpServletRequestSimulator request = (Frame2HttpServletRequestSimulator) getRequest();

    NVPair[] opts;
    opts = new NVPair[formParms.length];
    for (int i = 0; i < formParms.length; i++) {
      Map<String, String> parm = (HashMap<String, String>) formParms[i];
      for (Entry<String, String> entry : parm.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        opts[i] = new NVPair(key, value);
      }
    }

    NVPair[] file;
    file = new NVPair[fileParms.length];
    for (int i = 0; i < fileParms.length; i++) {
      Map<String, String> parm = (HashMap<String, String>) fileParms[i];
      for (Entry<String, String> entry : parm.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        URL configFile = getContext().getResource(value);
        file[i] = new NVPair(key, configFile.getFile());
      }
    }

    try {
      byte[] data = Codecs.mpFormDataEncode(opts, file, hdrs);
      String rawData = new String(data);
      System.out.println(rawData);
      InputStream is = new ByteArrayInputStream(data);
      request.setDataInputStream(data.length, is);
      request.setContentType(hdrs[0].getValue());
      request.setHeader(HttpRequestProcessor.CONTENT_TYPE, hdrs[0]
          .getValue());
      is.close();
    } catch (IOException e) {
      fail();
    }
View Full Code Here


  @SuppressWarnings("unchecked")
  private void prepareMultipartUpload(Object[] formParms, Object[] fileParms,
      String eventName) throws Exception {
    NVPair[] hdrs = new NVPair[1];
    Frame2HttpServletRequestSimulator request = (Frame2HttpServletRequestSimulator) getRequest();

    NVPair[] opts;
    opts = new NVPair[formParms.length];
    for (int i = 0; i < formParms.length; i++) {
      Map<String, String> parm = (HashMap<String, String>) formParms[i];
      for (Entry<String, String> entry : parm.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        opts[i] = new NVPair(key, value);
      }
    }

    NVPair[] file;
    file = new NVPair[fileParms.length];
    for (int i = 0; i < fileParms.length; i++) {
      Map<String, String> parm = (HashMap<String, String>) fileParms[i];
      for (Entry<String, String> entry : parm.entrySet()) {
        String key = entry.getKey();
        String value = entry.getValue();
        URL configFile = getContext().getResource(value);
        file[i] = new NVPair(key, configFile.getFile());
      }
    }

    try {
      byte[] data = Codecs.mpFormDataEncode(opts, file, hdrs);
      String rawData = new String(data);
      System.out.println(rawData);
      InputStream is = new ByteArrayInputStream(data);
      request.setDataInputStream(data.length, is);
      request.setContentType(hdrs[0].getValue());
      request.setHeader(HttpRequestProcessor.CONTENT_TYPE, hdrs[0]
          .getValue());
      is.close();
    } catch (IOException e) {
      fail();
    }
View Full Code Here

TOP

Related Classes of servletunit.frame2.RequestStream

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.