Package org.ngrinder.script.model

Examples of org.ngrinder.script.model.FileEntry$FileEntrySerializer


    User user = new User("my", "my", "password", Role.ADMIN);
    FileEntryRepository serviceMock = mock(FileEntryRepository.class);
    when(serviceMock.hasOne(user, "/hello/world/pom.xml")).thenReturn(true);
    handler.setFileEntryRepository(serviceMock);

    FileEntry entry = new FileEntry();
    entry.setPath("/hello/world/src/main/java/wow/Global.groovy");
    entry.setCreatedUser(user);
    assertThat(handler.canHandle(entry)).isTrue();

    entry.setPath("/hello/world/src/main/wow/Global.groovy");
    assertThat(handler.canHandle(entry)).isFalse();

    entry.setPath("/hello/world/src/main/java/Global.py");
    assertThat(handler.canHandle(entry)).isFalse();

    when(serviceMock.hasOne(user, "/hello/world/pom.xml")).thenReturn(false);
    entry.setPath("/hello/world/src/main/java/Global.groovy");
    assertThat(handler.canHandle(entry)).isFalse();
  }
View Full Code Here


    assertThat(findAll.size(), is(0));
  }

  @Test
  public void testRecursiveDirSave() throws IOException {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setContent("HELLO WORLD2");
    fileEntry.setEncoding("UTF-8");
    fileEntry.setPath("/myworld/www/hello.zip");
    fileEntry.setEncoding(null);
    fileEntry.setFileType(FileType.UNKNOWN);
    byte[] byteArray = IOUtils.toByteArray(new ClassPathResource("TEST_USER.zip").getInputStream());
    fileEntry.setContentBytes(byteArray);
    repo.save(getTestUser(), fileEntry, null);
  }
View Full Code Here

    testUserRoot.mkdirs();
    CompressionUtils.unzip(new ClassPathResource("TEST_USER.zip").getFile(), testUserRoot);
    testUserRoot.deleteOnExit();

    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath("test1.py");
    String worldString = IOUtils.toString(new ClassPathResource("world.py").getInputStream());
    if (fileEntry.getFileType().isEditable()) {
      fileEntry.setContent(worldString);
    } else {
      fileEntry.setContentBytes(worldString.getBytes());
    }
    fileEntityRepository.save(getTestUser(), fileEntry, "UTF-8");

    clearAllPerfTest();
    perfTest = createPerfTest("test1", Status.READY, null);
View Full Code Here

  private void prepareUserRepo() throws IOException {
    File userRepoDirectory = fileEntityRepository.getUserRepoDirectory(null);
    FileUtils.deleteQuietly(userRepoDirectory);
    CompressionUtils.unzip(new ClassPathResource("TEST_USER.zip").getFile(), userRepoDirectory.getParentFile());
    FileEntry fileEntryDir = new FileEntry();
    fileEntryDir.setPath("/hello");
    fileEntryDir.setFileType(FileType.DIR);
    fileEntityRepository.save(getTestUser(), fileEntryDir, null);

    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath("/hello/world.py");
    String worldString = IOUtils.toString(new ClassPathResource("world.py").getInputStream());
    fileEntry.setContent(worldString);
    fileEntry.setFileType(FileType.PYTHON_SCRIPT);
    fileEntityRepository.save(getTestUser(), fileEntry, "UTF-8");
  }
View Full Code Here

   *
   * @param basePath base path
   * @return quick test file
   */
  public FileEntry getDefaultQuickTestFilePath(String basePath) {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath(PathUtils.join(basePath, "TestRunner." + getExtension()));
    return fileEntry;
  }
View Full Code Here

    }
    return false;
  }

  private void createLibraryDirectory(User user, String path) {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath(path + "/lib");
    fileEntry.setFileType(FileType.DIR);
    fileEntry.setDescription("put private libraries here");
    getFileEntryRepository().save(user, fileEntry, null);
  }
View Full Code Here

        String subpath = each.getPath().substring(scriptTemplateDir.getPath().length());
        String fileContent = FileUtils.readFileToString(each, "UTF8");
        fileContent = fileContent.replace("${userName}", user.getUserName());
        fileContent = fileContent.replace("${name}", name);
        fileContent = fileContent.replace("${url}", url);
        FileEntry fileEntry = new FileEntry();
        fileEntry.setContent(fileContent);
        fileEntry.setPath(FilenameUtils.normalize(PathUtils.join(path, subpath), true));
        fileEntry.setDescription("create groovy maven project");
        String hostName = UrlUtils.getHost(url);
        if (StringUtils.isNotEmpty(hostName)
            && fileEntry.getFileType().getFileCategory() == FileCategory.SCRIPT) {
          Map<String, String> properties = newHashMap();
          properties.put("targetHosts", UrlUtils.getHost(url));
          fileEntry.setProperties(properties);
        }
        getFileEntryRepository().save(user, fileEntry, "UTF8");
      } catch (IOException e) {
        throw processException("Error while saving " + each.getName(), e);
      }
View Full Code Here

      }
    }
  }

  private void createBaseDirectory(User user, String path) {
    FileEntry dirEntry = new FileEntry();
    dirEntry.setPath(path);
    // Make it eclipse default folder ignored.
    dirEntry.setProperties(buildMap("svn:ignore", ".project\n.classpath\n.settings\ntarget"));
    dirEntry.setFileType(FileType.DIR);
    dirEntry.setDescription("create groovy maven project");
    getFileEntryRepository().save(user, dirEntry, null);
  }
View Full Code Here

    }
  }

  @Override
  public FileEntry getDefaultQuickTestFilePath(String path) {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath(path + JAVA + "TestRunner.groovy");
    return fileEntry;
  }
View Full Code Here

   *
   * @param basePath base path
   * @return quick test file
   */
  public FileEntry getDefaultQuickTestFilePath(String basePath) {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath(PathUtils.join(basePath, "TestRunner." + getExtension()));
    return fileEntry;
  }
View Full Code Here

TOP

Related Classes of org.ngrinder.script.model.FileEntry$FileEntrySerializer

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.