Package org.ngrinder.script.model

Examples of org.ngrinder.script.model.FileEntry


    scriptController.addFolder(getTestUser(), "", path, model);
    // create
    scriptController.createForm(getTestUser(), path, "test.com", "new_file.py", "jython", false,
            new RedirectAttributesModelMap(), model);

    FileEntry script = (FileEntry) model.get("file");
    script.setContent(script.getContent() + "#test comment");
    scriptController.save(getTestUser(), script, null, "", false, model);
    scriptController.validate(getTestUser(), script, "test.com");
    // save and get
    model.clear();
    scriptController.getOne(getTestUser(), script.getPath(), -1L, model);
    FileEntry newScript = (FileEntry) model.get("file");
    assertThat(newScript.getFileName(), is(script.getFileName()));
    assertThat(newScript.getContent(), is(script.getContent()));

    // List<Long> versionList = newScript.getRevisions();
    // reversion list is not implemented yet.
    // assertThat(versionList.size(), is(2));
    model.clear();
View Full Code Here


    // add folder
    scriptController.addFolder(getTestUser(), "", path, model);
    // create
    scriptController.createForm(getTestUser(), path, "test.com", "file-for-search.py", "jython", false,
            new RedirectAttributesModelMap(), model);
    FileEntry script = (FileEntry) model.get("file");
    scriptController.save(getTestUser(), script, null, "", false, model);

    // save another script
    model.clear();
    script.setPath(script.getPath().replace("file-for-search", "new-file-for-search"));
    scriptController.save(getTestUser(), script, null, "", false, model);
    // save and get
    model.clear();
    scriptController.getOne(getTestUser(), script.getPath(), -1L, model);

    model.clear();
    scriptController.search(getTestUser(), "file-for-search", model);
    Collection<FileEntry> searchResult = (Collection<FileEntry>) model.get("files");
    assertThat(searchResult.size(), is(2));
View Full Code Here

    String fileName = "download_file.py";
    scriptController.addFolder(getTestUser(), "", path, model);
    RedirectAttributesModelMap attrMap = new RedirectAttributesModelMap();
    scriptController.createForm(getTestUser(), path, "test.com", fileName, "jython", false, attrMap, model);

    FileEntry script = (FileEntry) model.get("file");
    script.setContent(script.getContent() + "#test comment");
    scriptController.save(getTestUser(), script, null, "", false, model);

    scriptController.createForm(getTestUser(), path, "", fileName, "", false, attrMap, model);

    MockHttpServletResponse response = new MockHttpServletResponse();
View Full Code Here


  @Test(timeout = 30000)
  public void testInfiniteScriptValidation() throws EngineException, DirectoryException, IOException {
    String script = IOUtils.toString(new ClassPathResource("/validation/script_loop.py").getInputStream());
    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath("/script.py");
    fileEntry.setContent(script);
    String validateScript = scriptValidationService.validate(getTestUser(), fileEntry, false, "");
  }
View Full Code Here

  }

  @Test
  public void testNormalScriptValidation() throws EngineException, DirectoryException, IOException {
    String script = IOUtils.toString(new ClassPathResource("/validation/script_1time.py").getInputStream());
    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath("/script2.py");
    fileEntry.setContent(script);
    String validateScript = scriptValidationService.validate(getTestUser(), fileEntry, false, "");
    assertThat(validateScript, not(containsString("Validation should be performed within")));
    assertThat(validateScript.length(), lessThan(10000));
  }
View Full Code Here

  }

  @Test
  public void testScriptValidationWithSvnScript() throws EngineException, DirectoryException, IOException {
    String script = IOUtils.toString(new ClassPathResource("/validation/script_1time.py").getInputStream());
    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath("/script2.py");
    fileEntry.setContent(script);
    fileEntryService.save(getTestUser(), fileEntry);
    fileEntry.setContent("");
    String validateScript = scriptValidationService.validate(getTestUser(), fileEntry, true, "");
    assertThat(validateScript, not(containsString("Validation should be performed")));
    assertThat(validateScript.length(), lessThan(10000));
  }
View Full Code Here

  @Autowired
  private ScriptHandlerFactory factory;

  @Test
  public void testFactoryCreation() {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setPath("/hello/world.groovy");
    fileEntry.setCreatedUser(getTestUser());
    assertThat(factory.getHandler(fileEntry)).isInstanceOf(GroovyScriptHandler.class);
    fileEntry.setPath("/hello/world.py");
    assertThat(factory.getHandler(fileEntry)).isInstanceOf(JythonScriptHandler.class);
  }
View Full Code Here

    repo.setUserRepository(new File(file, getTestUser().getUserId()));
  }

  @Test
  public void testFileEntitySaveAndDelete() {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setContent("HELLO WORLD2");
    fileEntry.setEncoding("UTF-8");
    fileEntry.setPath("helloworld.txt");
    fileEntry.setDescription("WOW");
    fileEntry.getProperties().put("hello", "world");

    int size = repo.findAll(getTestUser()).size();
    repo.save(getTestUser(), fileEntry, fileEntry.getEncoding());

    FileEntry findOne = repo.findOne(getTestUser(), "helloworld.txt", SVNRevision.HEAD);
    assertThat(findOne.getProperties().get("hello"), is("world"));

    fileEntry.setPath("www");
    fileEntry.setFileType(FileType.DIR);
    repo.save(getTestUser(), fileEntry, null);
    fileEntry.setPath("www/aa.py");
View Full Code Here

  }

  @Test
  public void testBinarySaveAndLoad() throws IOException {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setContent("HELLO WORLD2");
    fileEntry.setEncoding("UTF-8");
    fileEntry.setPath("helloworld.txt");
    fileEntry.setFileType(FileType.TXT);
    fileEntry.setDescription("WOW");
    repo.save(getTestUser(), fileEntry, fileEntry.getEncoding());
    fileEntry.setPath("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);
    List<FileEntry> findAll = repo.findAll(getTestUser(), "hello.zip", null);
    FileEntry foundEntry = findAll.get(0);
    assertThat(foundEntry.getFileSize(), is((long) byteArray.length));
    // commit again
    repo.save(getTestUser(), fileEntry, null);
    findAll = repo.findAll(getTestUser(), "hello.zip", null);
    assertThat(foundEntry.getFileSize(), is((long) byteArray.length));
  }
View Full Code Here

    assertThat(foundEntry.getFileSize(), is((long) byteArray.length));
  }

  @Test
  public void testBinarySaveAndLoadWithFindOne() throws IOException {
    FileEntry fileEntry = new FileEntry();
    fileEntry.setContent("HELLO WORLD2");
    fileEntry.setEncoding("UTF-8");
    fileEntry.setPath("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);
    FileEntry foundEntry = repo.findOne(getTestUser(), "hello.zip", SVNRevision.HEAD);
    assertThat(foundEntry.getFileSize(), is((long) byteArray.length));
  }
View Full Code Here

TOP

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

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.