Package org.apache.oodt.cas.protocol

Examples of org.apache.oodt.cas.protocol.ProtocolFile


            }}).when(ftpProtocol).connect("localhost", auth);

        Mockito.doAnswer(new Answer() {
            public Object answer(InvocationOnMock invocation) {
                return null;
            }}).when(ftpProtocol).cd(new ProtocolFile("testdata", true));



        ftpProtocol.connect("localhost", auth);


    ftpProtocol.cd(new ProtocolFile("testdata", true));

    List<ProtocolFile> lsResults = ftpProtocol.ls();
    assertTrue(lsResults.contains(new ProtocolFile(ftpProtocol.pwd(), "users.properties", false)));
  }
View Full Code Here


    File bogusFile = File.createTempFile("bogus", "bogus");
    final File tmpFile = new File(bogusFile.getParentFile(), "TestJschSftpProtocol");
    bogusFile.delete();
    tmpFile.mkdirs();
        mockc.cd(new ProtocolFile("sshTestDir", true));
    File testDownloadFile = new File(tmpFile, "testDownloadFile");

        Mockito.doAnswer(new Answer(){
            public Object answer(InvocationOnMock invocationOnMock) throws IOException {

                PrintWriter writer = new PrintWriter(tmpFile+"/testDownloadFile", "UTF-8");
                writer.print(readFile("src/testdata/sshTestDir/sshTestFile"));
                writer.close();

                return null;
            }
        }).when(mockc).get(new ProtocolFile("sshTestFile", false), testDownloadFile);


        mockc.get(new ProtocolFile("sshTestFile", false), testDownloadFile);

    assertTrue(FileUtils.contentEquals(new File("src/testdata/sshTestDir/sshTestFile"), testDownloadFile));

    FileUtils.forceDelete(tmpFile);
  }
View Full Code Here

   @Override
   public void execute(ActionMessagePrinter printer)
         throws CmdLineActionException {
      try {
         usedProtocol = createProtocol(getProtocolManager());
         ProtocolFile fromFile = createProtocolFile();
         String toFilename = fromFile.equals(ProtocolFile.SEPARATOR)
               || fromFile.getName().isEmpty() ? uri.getHost() : fromFile
               .getName();
         File toFile = (toDir != null) ? new File(toDir, toFilename)
               : new File(toFilename);
         usedProtocol.get(fromFile, toFile.getAbsoluteFile());
      } catch (Exception e) {
View Full Code Here

   protected Protocol getUsedProtocol() {
      return usedProtocol;
   }

   protected ProtocolFile createProtocolFile() throws URISyntaxException {
      return new ProtocolFile(uri.getPath(), false);
   }
View Full Code Here

    if (urlString == null)
      throw new Exception("Must specify a url to download: --url <url>");

    URL url = new URL(urlString);
    ProtocolFile urlFile = new HttpFile(url.getPath(), false, url);
    File toFile = new File(downloadToDir, urlFile.getName());
    toFile = toFile.getAbsoluteFile();
    toFile.createNewFile();
    new HttpProtocol().get(urlFile, toFile);
  }
View Full Code Here

 
  public void testLSandCD() throws ProtocolException, InstantiationException {
    HttpProtocol httpProtocol = new HttpProtocol();
    httpProtocol.connect("svn.apache.org", new NoAuthentication());
    assertTrue(httpProtocol.connected());
    httpProtocol.cd(new ProtocolFile("repos/asf/oodt/trunk/protocol/http/src/main/java/org/apache/oodt/cas/protocol/http", true));
    List<ProtocolFile> files = httpProtocol.ls();
    boolean foundFile = false;
    for (ProtocolFile file : files) {
      if (file.getName().equals("HttpProtocol.java")) {
        foundFile = true;
View Full Code Here

 
  public void testPWD() throws ProtocolException {
    HttpProtocol httpProtocol = new HttpProtocol();
    httpProtocol.connect("svn.apache.org", new NoAuthentication());
    assertTrue(httpProtocol.connected());
    ProtocolFile gotoDir = new ProtocolFile(httpProtocol.pwd(), "repos/asf/oodt/trunk/protocol/http/src/test/org/apache/oodt/cas/protocol/http", true);
    httpProtocol.cd(gotoDir);
    ProtocolFile currentDir = httpProtocol.pwd();
    System.out.println(gotoDir.getAbsoluteFile());
    System.out.println(currentDir.getAbsoluteFile());
    assertEquals(gotoDir, currentDir);
  }
View Full Code Here

 
  public void testGET() throws ProtocolException, IOException {
    HttpProtocol httpProtocol = new HttpProtocol();
    httpProtocol.connect("svn.apache.org", new NoAuthentication());
    assertTrue(httpProtocol.connected());
    httpProtocol.cd(new ProtocolFile("repos/asf/oodt/trunk/protocol/http/src/test/org/apache/oodt/cas/protocol/http", true));
    File bogus = File.createTempFile("bogus", "bogus");
    File tmpDir = new File(bogus.getParentFile(), "TestHttpProtocol");
    bogus.delete();
    tmpDir.mkdirs();
    File toFile = new File(tmpDir, "TestHttpProtocol.java");
    httpProtocol.get(new ProtocolFile("TestHttpProtocol.java", false), toFile);
    assertTrue(toFile.exists());
    assertNotSame(0, toFile.length());
   
    String fileContent = "";
    Scanner scanner = new Scanner(toFile);
View Full Code Here

    }
  }

  public synchronized void cdRoot() throws ProtocolException {
    try {
      cd(new ProtocolFile("/", true));
    } catch (Exception e) {
      throw new ProtocolException("Failed to cd to root : " + e.getMessage(), e);
    }
  }
View Full Code Here

    }
  }
 
  public synchronized void cdHome() throws ProtocolException {
    try {
      cd(new ProtocolFile("", true));
    } catch (Exception e) {
      throw new ProtocolException("Failed to cd to home : " + e.getMessage(), e);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.oodt.cas.protocol.ProtocolFile

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.