Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockMultipartFile


    context.putRequestParameter("_eventId", "submit");
    context.putRequestParameter("stringProperty", "foo");
    context.putRequestParameter("integerProperty", "5");
    context.putRequestParameter("dateProperty", "2007-01-01");
    context.putRequestParameter("beanProperty.name", "foo");
    context.putRequestParameter("multipartFile", new MockMultipartFile("foo", new byte[0]));
    context.putRequestParameter("stringArrayProperty", new String[] { "foo", "bar", "baz" });
    context.putRequestParameter("integerArrayProperty", new String[] { "1", "2", "3" });
    context.putRequestParameter("primitiveArrayProperty", new String[] { "1", "2", "3" });
    context.putRequestParameter("listProperty", new String[] { "1", "2", "3" });
    BindBean bindBean = new BindBean();
View Full Code Here


   
    DBCentro dbCentro = new DBCentro();
    dbCentro.preparaDb();
   
    byte[] bytes = IOUtils.toByteArray((new ServletContextResource(_ctx.getServletContext(),"/logo.png")).getInputStream());
    MultipartFile file = new MockMultipartFile("file","logo.png","image/png",bytes);
    _reqMock.addFile(file);
    _reqMock.setMethod("POST");

    _reqMock.setRequestURI("/upload.page");
    _reqMock.getSession().setAttribute(Constant.ID_CENTRO_SESSIONE, 46l);
View Full Code Here

    assertFalse(request.getFileNames().hasNext());
    assertNull(request.getFile("file1"));
    assertNull(request.getFile("file2"));
    assertTrue(request.getFileMap().isEmpty());

    request.addFile(new MockMultipartFile("file1", "myContent1".getBytes()));
    request.addFile(new MockMultipartFile("file2", "myOrigFilename", "text/plain", "myContent2".getBytes()));
    doTestMultipartHttpServletRequest(request);
  }
View Full Code Here

    doTestMultipartHttpServletRequest(request);
  }

  public void testMockMultipartHttpServletRequestWithInputStream() throws IOException {
    MockMultipartHttpServletRequest request = new MockMultipartHttpServletRequest();
    request.addFile(new MockMultipartFile("file1", new ByteArrayInputStream("myContent1".getBytes())));
    request.addFile(new MockMultipartFile("file2", "myOrigFilename", "text/plain", new ByteArrayInputStream("myContent2".getBytes())));
    doTestMultipartHttpServletRequest(request);
  }
View Full Code Here

    public void innerSetUp() throws Exception {

        //
        multipartRequest = new MockMultipartHttpServletRequest();
        multipartRequest.setMethod("POST");
        file1 = new MockMultipartFile("file1", "originalFileName1", "application/oct-stream",
                new byte[] { 1, 2 });
        file2 = new MockMultipartFile("file2", "originalFileName2", "application/oct-stream",
                new byte[] { 3, 4 });
        multipartRequest.addFile(file1);
        multipartRequest.addFile(file2);
    }
View Full Code Here

    context.putRequestParameter("_eventId", "submit");
    context.putRequestParameter("stringProperty", "foo");
    context.putRequestParameter("integerProperty", "5");
    context.putRequestParameter("dateProperty", "2007-01-01");
    context.putRequestParameter("beanProperty.name", "foo");
    context.putRequestParameter("multipartFile", new MockMultipartFile("foo", new byte[0]));
    context.putRequestParameter("stringArrayProperty", new String[] { "foo", "bar", "baz" });
    context.putRequestParameter("integerArrayProperty", new String[] { "1", "2", "3" });
    context.putRequestParameter("primitiveArrayProperty", new String[] { "1", "2", "3" });
    context.putRequestParameter("listProperty", new String[] { "1", "2", "3" });
    BindBean bindBean = new BindBean();
View Full Code Here

    context.putRequestParameter("_eventId", "submit");
    context.putRequestParameter("stringProperty", "foo");
    context.putRequestParameter("integerProperty", "5");
    context.putRequestParameter("dateProperty", "2007-01-01");
    context.putRequestParameter("beanProperty.name", "foo");
    context.putRequestParameter("multipartFile", new MockMultipartFile("foo", new byte[0]));
    context.putRequestParameter("stringArrayProperty", new String[] { "foo", "bar", "baz" });
    context.putRequestParameter("integerArrayProperty", new String[] { "1", "2", "3" });
    context.putRequestParameter("primitiveArrayProperty", new String[] { "1", "2", "3" });
    context.putRequestParameter("listProperty", new String[] { "1", "2", "3" });
    Expression modelObject = new Expression() {
View Full Code Here

   *
   * @param name the name of the file
   * @param content the content of the file
   */
  public MockMultipartHttpServletRequestBuilder file(String name, byte[] content) {
    this.files.add(new MockMultipartFile(name, content));
    return this;
  }
View Full Code Here

        doNothing().when(mockApplicationVersionValidator).validateRecentChanges(any(Errors.class), any(ApplicationVersionForm.class));
        doNothing().when(mockApplicationVersionValidator).validateOrganizationLimits(any(Errors.class), any(ApplicationVersionForm.class), any(Application.class), any(Organization.class));
        doNothing().when(mockApplicationVersionValidator).validateInstallFile(any(Errors.class), any(ApplicationVersionForm.class), any(ApplicationType.class));
        doNothing().when(mockApplicationVersionValidator).validateResign(any(ApplicationVersionForm.class), any(Group.class), any(ApplicationType.class), any(Errors.class));

        MockMultipartFile screenShot1 = mock(MockMultipartFile.class);
        MockMultipartFile screenShot2 = mock(MockMultipartFile.class);
        MockMultipartFile screenShot3 = mock(MockMultipartFile.class);

        applicationForm.setApplicationType(ApplicationType.ANDROID);
        applicationForm.setCategoryId(1L);
        applicationForm.setDescription("test description");
        applicationForm.setName("name");
View Full Code Here

                orgForm.setStoragePrefix(existingOrg.getOrgStorageConfig().getPrefix());

                if (existingOrg.getCustomBranding() != null) {
                    AppFile logo = existingOrg.getCustomBranding().getLogo();
                    if (logo != null) {
                        MockMultipartFile logoMultipartFile = new MockMultipartFile(logo.getName(), logo.getName(), logo.getType(), new byte[0]);
                        orgForm.setLogo(logoMultipartFile);
                    }
                    orgForm.setEmailHeader(existingOrg.getCustomBranding().getEmailHeader());
                    orgForm.setEmailFooter(existingOrg.getCustomBranding().getEmailFooter());
                    orgForm.setSubdomain(existingOrg.getCustomBranding().getSubdomain());
View Full Code Here

TOP

Related Classes of org.springframework.mock.web.MockMultipartFile

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.