Package org.apache.wicket.util.file

Examples of org.apache.wicket.util.file.File


    assertNotNull(domainObject);
    assertNull(domainObject.getText());


    FormTester formTester = tester.newFormTester("form");
    formTester.setFile("file", new File("pom.xml"), "text/xml");
    formTester.setValue("text", "Mock value");
    formTester.submit();


    assertNotNull(domainObject);
View Full Code Here


    assertNotNull(domainObject);
    assertNull(domainObject.getText());


    FormTester formTester = tester.newFormTester("form");
    formTester.setFile("file", new File(getBasedir() +
      "src/test/java/org/apache/wicket/util/tester/bg.jpg"), "image/jpeg");
    formTester.setValue("text", "Mock value");
    formTester.submit();

View Full Code Here

   */
  private void watchForModifications(Class<?> clz)
  {
    // Watch class in the future
    Iterator<URL> locationsIterator = urls.iterator();
    File clzFile = null;
    while (locationsIterator.hasNext())
    {
      // FIXME only works for directories, but JARs etc could be checked
      // as well
      URL location = locationsIterator.next();
      String clzLocation = location.getFile() + clz.getName().replaceAll("\\.", "/") +
        ".class";
      log.debug("clzLocation=" + clzLocation);
      clzFile = new File(clzLocation);
      final File finalClzFile = clzFile;
      if (clzFile.exists())
      {
        log.info("Watching changes of class " + clzFile);
        watcher.add(clzFile, new IChangeListener()
        {
View Full Code Here

    assertNotNull(domainObject);
    assertNull(domainObject.getText());


    FormTester formTester = tester.newFormTester("form");
    formTester.setFile("file", new File("pom.xml"), "text/xml");
    formTester.setValue("text", "Mock value");
    formTester.submit();


    assertNotNull(domainObject);
View Full Code Here

    assertNotNull(domainObject);
    assertNull(domainObject.getText());


    FormTester formTester = tester.newFormTester("form");
    formTester.setFile("file", new File(getBasedir() +
      "src/test/java/org/apache/wicket/util/tester/bg.jpg"), "image/jpeg");
    formTester.setValue("text", "Mock value");
    formTester.submit();

View Full Code Here

   */
  public void testWriteToTempFile() throws IOException
  {
    tester.startPage(TestPage.class);

    File tmp = null;
    try
    {
      tmp = FileUploadFieldTest.writeTestFile(1);
      FormTester formtester = tester.newFormTester("form");
      formtester.setFile("upload", tmp, "text/plain");
      formtester.submit();

      TestPage page = (TestPage)tester.getLastRenderedPage();
      assertNotNull(page.testFile);
    }
    finally
    {
      if (tmp != null && tmp.exists())
      {
        tmp.delete();
      }
    }
  }
View Full Code Here

      {
        return page;
      }
    });

    File tmp = null;
    try
    {
      // Write out a large text file. We need to make this file reasonably sizable,
      // because things get handled using input streams, and we want to check to make
      // sure they're closed properly if we abort mid-request.

      // We create a temp file because we don't want to depend on a file we might not
      // know the path of (e.g. the big DTD this test used previously). This enables
      // us to run the test out of a JAR file if need be, and also with an unknown
      // running directory (e.g. when run from wicket-parent).
      tmp = new File(java.io.File.createTempFile(this.getClass().getName(), ".txt"));
      OutputStream os = new BufferedOutputStream(new FileOutputStream(tmp));
      for (int i = 0; i < 1000; i++)
      {
        os.write("test test test test test\n".getBytes());
      }
      os.close();

      // Let's upload the dtd file. It's large enough to avoid being in memory.
      FormTester formtester = tester.newFormTester("form");
      formtester.setFile("upload", tmp, "text/plain");
      formtester.submit();

      // Get the file upload
      FileUpload fileUpload = page.getFileUpload();

      assertNotNull(fileUpload);

      // Get an input stream from the file upload
      InputStream is = fileUpload.getInputStream();

      // We should be able to read a byte
      assertTrue(is.read() != -1);

      fileUpload.closeStreams();

      // The input stream should be closed so we shouldn't be able to read any more bytes
      try
      {
        is.read();
        fail("The input stream should be closed so we shouldn't be able to read any more bytes");
      }
      catch (IOException e)
      {
        // Expected
      }
      catch (Exception e)
      {
        fail();
      }
    }
    finally
    {
      if (tmp != null && tmp.exists())
      {
        tmp.delete();
      }
    }
  }
View Full Code Here

   */
  private void watchForModifications(Class clz)
  {
    // Watch class in the future
    Iterator locationsIterator = urls.iterator();
    File clzFile = null;
    while (locationsIterator.hasNext())
    {
      // FIXME only works for directories, but JARs etc could be checked
      // as well
      URL location = (URL)locationsIterator.next();
      String clzLocation = location.getFile() + clz.getName().replaceAll("\\.", "/") +
          ".class";
      log.debug("clzLocation=" + clzLocation);
      clzFile = new File(clzLocation);
      final File finalClzFile = clzFile;
      if (clzFile.exists())
      {
        log.info("Watching changes of class " + clzFile);
        watcher.add(clzFile, new IChangeListener()
        {
View Full Code Here

   * @param file
   *            {@link java.io.File} containing resource
   */
  public FileResourceStream(final java.io.File file)
  {
    this.file = new File(file);
  }
View Full Code Here

      }

      for (int i = 0; i < files.length; i++)
      {
        log.debug("Adding: " + files[i]);
        FileInputStream fi = new FileInputStream(new File(dir, files[i]));
        origin = new BufferedInputStream(fi, BUFFER);
        ZipEntry entry = new ZipEntry(files[i]);
        out.putNextEntry(entry);
        int count;
        while ((count = origin.read(data, 0, BUFFER)) != -1)
View Full Code Here

TOP

Related Classes of org.apache.wicket.util.file.File

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.