Examples of FileEntry


Examples of org.ngrinder.script.model.FileEntry


  @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

Examples of org.ngrinder.script.model.FileEntry

  }

  @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

Examples of org.ngrinder.script.model.FileEntry

  }

  @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

Examples of org.ngrinder.script.model.FileEntry

  @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

Examples of org.ngrinder.script.model.FileEntry

    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

Examples of org.ngrinder.script.model.FileEntry

  }

  @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

Examples of org.ngrinder.script.model.FileEntry

    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

Examples of org.ngrinder.script.model.FileEntry

    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

Examples of org.onesocialweb.openfire.model.FileEntry

    if (fileId == null || fileId.isEmpty()) {
      throw new MissingParameterException("fileId");
    }

    // Get the file entry
    FileEntry fileEntry = UploadManager.getInstance().getFile(fileId);
    if (fileEntry == null) {
      throw new FileNotFoundException(fileId);
    }

    // Open the file
    File file = new File(getUploadFolder(), fileEntry.getId());
    if (!file.exists()) {
      throw new FileNotFoundException(fileEntry.getName());
    }

    // Process the file
    String pSize = request.getParameter("size");
    if (pSize != null) {
    }
     
    DataInputStream is = new DataInputStream(new FileInputStream(file));

    // Send the headers
    response.setContentType(fileEntry.getType());
    response.setContentLength((int) fileEntry.getSize());
    //response.setHeader("Content-Disposition", "attachment; filename=\"" + fileEntry.getName() + "\"");

    // Stream the file
    final byte[] bbuf = new byte[BUFFSIZE];
    final OutputStream os = response.getOutputStream();
View Full Code Here

Examples of org.rhq.common.drift.FileEntry

                try {
                    if (log.isInfoEnabled()) {
                        log.info("Detected added file for " + schedule + " --> " + file.getAbsolutePath());
                    }

                    FileEntry addedFileEntry = getAddedFileEntry(basedir, file);
                    if (null != addedFileEntry) {
                        addedEntries.add(addedFileEntry);
                    }

                } catch (Throwable t) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.