Package org.springframework.mock.web

Examples of org.springframework.mock.web.MockMultipartFile


                categoryForm.setName(category.getName());
                categoryForm.setStorageConfigurationId(category.getStorageConfiguration().getId());

                AppFile icon = category.getIcon();
                if (icon != null) {
                    MockMultipartFile iconMultipartFile = new MockMultipartFile(category.getIcon().getName(), category.getIcon().getName(), category.getIcon().getType(), new byte[0]);
                    categoryForm.setIcon(iconMultipartFile);
                }

                model.addAttribute("category", categoryForm);
            }
View Full Code Here


            StorageService storageService = storageServiceFactory.getStorageService(application.getStorageConfiguration().getStorageType());

            AppFile icon = application.getIcon();
            if (icon != null) {
                MockMultipartFile iconMultipartFile = new MockMultipartFile(application.getIcon().getName(), application.getIcon().getName(), application.getIcon().getType(), new byte[0]);
                applicationForm.setIcon(iconMultipartFile);
                model.addAttribute("icon", appFileService.createImageModel(icon));
            }

            List<AppFile> screenShots = application.getScreenshots();
            List<MultipartFile> screenShotMultipartFiles = new ArrayList<MultipartFile>();
            List<ImageModel> screenshotImageModels = new ArrayList<ImageModel>();
            for (AppFile screenShot : screenShots) {
                MockMultipartFile screenShotMultipartFile = new MockMultipartFile(screenShot.getName(), screenShot.getName(), screenShot.getType(), storageService.getInputStream(screenShot));
                screenShotMultipartFiles.add(screenShotMultipartFile);
                screenshotImageModels.add(appFileService.createImageModel(screenShot));
            }
            applicationForm.setScreenshots(screenShotMultipartFiles);
            model.addAttribute("screenshots", screenshotImageModels);
View Full Code Here

            applicationVersionForm.setVersionName(version.getVersionName());
            applicationVersionForm.setParentId(parentId);
            applicationVersionForm.setAppState(version.getAppState());

            if (version.getInstallationFile() != null) {
                MockMultipartFile multipartFile = new MockMultipartFile(version.getInstallationFile().getName(), version.getInstallationFile().getName(), version.getInstallationFile().getType(), new byte[0]);
                applicationVersionForm.setAppFile(multipartFile);
            }

            if (version.getProvisioningProfile() != null) {
                MockMultipartFile multipartFile = new MockMultipartFile(version.getProvisioningProfile().getName(), version.getProvisioningProfile().getName(), version.getProvisioningProfile().getType(), new byte[0]);
                applicationVersionForm.setProvisioningProfile(multipartFile);
            }

            model.addAttribute("version", applicationVersionForm);
View Full Code Here

    @Test
    public void saveAndDeleteAppFileTest() {
        Organization organization = getOrganization();
        String content = "Test Content";
        String uuid = UUID.randomUUID().toString();
        MultipartFile multipartFile = new MockMultipartFile("TestFile", "TestFile.txt", "text/plain", content.getBytes());

        StorageService storageService = storageServiceFactory.getStorageService(StorageType.LOCAL);
        AppFile appFile = storageService.save(multipartFile, "test", organization.getOrgStorageConfig().getId(), organization.getOrgStorageConfig().getStorageConfigurations().get(0).getId(), uuid);
        appFile.setStorable(organization.getCategories().get(0));
        appFileService.add(appFile);
View Full Code Here

    @Test
    public void saveAndDeleteIconTest() {
        Organization organization = getOrganization();
        String content = "Test Content";
        String uuid = UUID.randomUUID().toString();
        MultipartFile multipartFile = new MockMultipartFile("TestFile", "TestFile.txt", "text/plain", content.getBytes());

        StorageService storageService = storageServiceFactory.getStorageService(StorageType.LOCAL);
        AppFile appFile = storageService.save(multipartFile, AppFileType.ICON.getPathName(), organization.getOrgStorageConfig().getId(), organization.getOrgStorageConfig().getStorageConfigurations().get(0).getId(), uuid);
        appFile.setStorable(organization.getCategories().get(0));
        appFileService.add(appFile);
View Full Code Here

   */
  @Test
  public void testCopyMultipartFile() throws IOException {
    String content = FileUtil.readFile("test/resources/testing.txt");
    InputStream is = FileUtil.getFileStream("test/resources/testing.txt");
    MockMultipartFile mfile = new MockMultipartFile("testing.txt", is);
    File dest = new File("copy.txt");
    FileUtil.copyMultipartFile(mfile, dest);
    String copied = FileUtil.readFile(dest);
    Assert.assertEquals(content, copied);   
  }
View Full Code Here

    }

    @Test
    public void uploadLogoForOperaAndIEShouldReturnPreviewInResponce()
            throws IOException, ImageProcessException {
        MultipartFile file = new MockMultipartFile("qqfile", validImage);

        ResponseEntity<String> actualResponseEntity = administrationController.uploadLogo(file);

        verify(logoControllerUtils).prepareResponse(eq(file), any(HttpHeaders.class), any(HashMap.class));
    }
View Full Code Here

    }

    @Test
    public void uploadIconForOperaAndIEShouldReturnPreviewInResponce()
            throws IOException, ImageProcessException {
        MultipartFile file = new MockMultipartFile("qqfile", validImage);

        administrationController.uploadFavIcon(file);

        verify(favIconPngControllerUtils).prepareResponse(eq(file), any(HttpHeaders.class), any(HashMap.class));
    }
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    public void uploadAvatarForOperaAndIEShouldReturnPreviewInResponce()
            throws IOException, ImageProcessException {
        MultipartFile file = new MockMultipartFile("qqfile", validAvatar);

        ResponseEntity<String> actualResponseEntity = avatarController.uploadAvatar(file);

        verify(imageControllerUtils).prepareResponse(eq(file), any(HttpHeaders.class), any(HashMap.class));
    }
View Full Code Here

    @Test(dataProvider = "parameterResizeImage")
    public void testResizeImage(int maxWidth, int maxHeight, int imageType, String format) throws IOException {
        int expectedWidth = 4;
        int expectedHeight = 4;
        imageConverter = new ImageConverter(format, imageType, maxWidth, maxHeight);
        BufferedImage originalImage = ImageIO.read(new MockMultipartFile("test_image", "test_image", "image/png",
                originalImageByteArray).getInputStream());
        Image modifiedImage = imageConverter.resizeImage(originalImage, imageType);
        assertEquals(modifiedImage.getWidth(null), expectedWidth);
        assertEquals(modifiedImage.getHeight(null), expectedHeight);
    }
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.