Examples of FileProtocolHandler


Examples of com.xuggle.xuggler.io.FileProtocolHandler

    retval = handler.open(url, flags);
    assertTrue(retval == 0);

    // try creating the handler without the factory
    handler = new FileProtocolHandler();
    retval = handler.open(null, flags);
    // should fail because we have no way of knowing the file
    assertTrue(retval == -1);

    // and should succeed because now we know the url.
    retval = handler.open(url, flags);
    assertTrue(retval == 0);

    // try creating the handler by letting the constructor
    // know the file, but not the open
    handler = new FileProtocolHandler(url);
    retval = handler.open(null, flags);
    assertTrue(retval == 0);

    retval = handler.open(url, flags);
    assertTrue(retval == 0);
View Full Code Here

Examples of com.xuggle.xuggler.io.FileProtocolHandler

  @Test
  public void testInvalidFileOpenForWriting()
  {
    String badWriteFile = "/notavalidrootdir/garbage-file-k200cski2loiudjhsl2";
    handler = new FileProtocolHandler(badWriteFile);

    int retval = 0;

    retval = handler.open(null, IURLProtocolHandler.URL_WRONLY_MODE);
    assertTrue(retval == -1);
View Full Code Here

Examples of com.xuggle.xuggler.io.FileProtocolHandler

  @Test
  public void testFileRead()
  {
    // open our file
    handler = new FileProtocolHandler();

    int retval = 0;
    retval = handler.open(fileProtocolString + ":" + sampleFile,
        IURLProtocolHandler.URL_RDONLY_MODE);
    assertTrue(retval >= 0);
View Full Code Here

Examples of com.xuggle.xuggler.io.FileProtocolHandler

  @Test
  public void testFileWrite()
  {
    String copyFile = "file:"+this.getClass().getName()+"_"+this.getName()+".flv";

    handler = new FileProtocolHandler();
    int retval = 0;

    // First, open the write handler.
    retval = handler.open(copyFile, IURLProtocolHandler.URL_WRONLY_MODE);
    assertTrue(retval >= 0);

    // Now, create and open a read handler.
    // note that without a protocol string, should default to file:
    IURLProtocolHandler reader = new FileProtocolHandler(sampleFile);
    retval = reader.open(null, IURLProtocolHandler.URL_RDONLY_MODE);

    long bytesWritten = 0;
    long totalBytes = reader.seek(0, IURLProtocolHandler.SEEK_SIZE);

    byte[] buffer = new byte[1024];
    while ((retval = reader.read(buffer, buffer.length)) > 0)
    {
      // Write the output.
      retval = handler.write(buffer, retval);
      assertTrue(retval >= 0);
      bytesWritten += retval;
    }
    assertTrue(bytesWritten == totalBytes);

    // close each file
    retval = reader.close();
    assertTrue(retval >= 0);

    retval = handler.close();
    assertTrue(retval >= 0);
View Full Code Here

Examples of com.xuggle.xuggler.io.FileProtocolHandler

    assertTrue("url_close failed: " + retval, retval >= 0);
  }

  private static long getFileSize(String filename)
  {
    IURLProtocolHandler handler = new FileProtocolHandler();

    int retval = 0;
    retval = handler.open(filename, IURLProtocolHandler.URL_RDONLY_MODE);
    assertTrue(retval >= 0);

    long totalBytes = handler.seek(0, IURLProtocolHandler.SEEK_SIZE);
    assertTrue(totalBytes >= 0);

    // and close
    retval = handler.close();
    assertTrue(retval >= 0);
    return totalBytes;
  }
View Full Code Here

Examples of org.openbel.framework.core.protocol.handler.FileProtocolHandler

        }

        ProtocolHandler protocolHandler = null;
        switch (supportedProtocol) {
        case FILE:
            protocolHandler = new FileProtocolHandler();
            break;
        case HTTP:
            protocolHandler = new HttpProtocolHandler();
            break;
        case HTTPS:
View Full Code Here

Examples of org.openbel.framework.core.protocol.handler.FileProtocolHandler

     */
    @Test
    public void testRelativeFilePath() {
        try {
            File f =
                    new FileProtocolHandler().downloadResource("file:"
                            + TEST_FILE_PATH, "test.belns");
            tempFiles.add(f);
        } catch (Exception e) {
            Assert.fail("Error reading relative file path: " + e.getMessage());
        }
View Full Code Here

Examples of org.openbel.framework.core.protocol.handler.FileProtocolHandler

    @Test
    public void testAbsoluteFilePath() {
        try {
            String canonicalPath = new File(".").getCanonicalPath();
            File f =
                    new FileProtocolHandler().downloadResource("file:"
                            + canonicalPath + "/" + TEST_FILE_PATH,
                            "test.belns");
            tempFiles.add(f);
        } catch (Exception e) {
            Assert.fail("Error reading relative file path: " + e.getMessage());
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.