Package net.sourceforge.squirrel_sql.fw.util

Examples of net.sourceforge.squirrel_sql.fw.util.FileWrapper


    */
   @Test
   public void testCopyFile_scenario1() throws IOException {

     // setup source mock file
     FileWrapper fromFile = mockHelper.createMock("fromFile", FileWrapper.class);
     expect(fromFile.exists()).andReturn(true);
     expect(fromFile.getAbsolutePath()).andReturn("/path/to/from/file").atLeastOnce();
     expect(mockIOUtilities.getCheckSum(fromFile)).andReturn(1000L);
    
     // setup dest mock file
     FileWrapper toFile = mockHelper.createMock("toFile", FileWrapper.class);
     expect(toFile.isDirectory()).andReturn(false);
     expect(toFile.exists()).andReturn(true);
     expect(toFile.getAbsolutePath()).andReturn("/path/to/to/file").atLeastOnce();
     expect(mockIOUtilities.getCheckSum(toFile)).andReturn(1000L);
    
     mockHelper.replayAll();
    underTest.copyFile(fromFile, toFile);
     mockHelper.verifyAll();
View Full Code Here


   }
  
   @Test
   public void testCheckDir_exists() {

     FileWrapper mockUpdateCoreDirectory = mockHelper.createMock(FileWrapper.class);
     expect(mockUpdateCoreDirectory.exists()).andReturn(true);
    
     expect(mockFileWrapperFactory.create(mockUpdateDirectory, UpdateUtil.CORE_ARTIFACT_ID));
     expectLastCall().andReturn(mockUpdateCoreDirectory);
    
     mockHelper.replayAll();
View Full Code Here

   }
  
   @Test
   public void testCheckDir_notexists() {

     FileWrapper mockUpdateCoreDirectory = mockHelper.createMock(FileWrapper.class);
     expect(mockUpdateCoreDirectory.exists()).andReturn(false);
     expect(mockUpdateCoreDirectory.mkdir()).andReturn(true);
    
     expect(mockFileWrapperFactory.create(mockUpdateDirectory, UpdateUtil.CORE_ARTIFACT_ID));
     expectLastCall().andReturn(mockUpdateCoreDirectory);
    
    
View Full Code Here

   }

   @Test
   public void testCheckDir_notexists_failure() {

     FileWrapper mockUpdateCoreDirectory = mockHelper.createMock(FileWrapper.class);
     expect(mockUpdateCoreDirectory.exists()).andReturn(false);
     expect(mockUpdateCoreDirectory.mkdir()).andReturn(false);
     expect(mockUpdateCoreDirectory.getAbsolutePath()).andReturn("/path/to/directory/that/was/not/made");
    
     expect(mockFileWrapperFactory.create(mockUpdateDirectory, UpdateUtil.CORE_ARTIFACT_ID));
     expectLastCall().andReturn(mockUpdateCoreDirectory);
    
    
View Full Code Here

   public void testLoadUpdateFromFileSystem() throws IOException {

     String pathToDirectoryThatContainsReleaseXml = "/path/to/release.xml/file";
     String releaseXmlFilePath = "/path/to/release.xml/file/release.xml";
    
     FileWrapper releaseXmlFileDir = getDirectoryMock("releaseXmlFileDir");
     FileWrapper releaseXmlFile = getFileMock("releaseXmlFile", releaseXmlFilePath);

     expect(mockFileWrapperFactory.create(pathToDirectoryThatContainsReleaseXml));
     expectLastCall().andReturn(releaseXmlFileDir);
     expect(mockFileWrapperFactory.create(releaseXmlFileDir, UpdateUtil.RELEASE_XML_FILENAME));
     expectLastCall().andReturn(releaseXmlFile);
View Full Code Here

     expect(status.getType()).andStubReturn(UpdateUtil.PLUGIN_ARTIFACT_ID);
     expect(status.getName()).andReturn(pluginFilename);
    expect(status.getChecksum()).andReturn(pluginFileCheckSum);
    expect(status.getSize()).andReturn(pluginFileByteSize);
   
     FileWrapper fileInDownlodDir = mockHelper.createMock("fileInDownlodDir", FileWrapper.class);    
    expect(fileInDownlodDir.getAbsolutePath()).andReturn(pluginFileAbsPath);
     expect(fileInDownlodDir.exists()).andReturn(true);
     expect(fileInDownlodDir.length()).andReturn(pluginFileByteSize);
     expect(mockFileWrapperFactory.create(mockDownloadsPluginDirectory, pluginFilename));
     expectLastCall().andReturn(fileInDownlodDir);
     expect(mockIOUtilities.getCheckSum(fileInDownlodDir)).andReturn(pluginFileCheckSum);
    
     mockHelper.replayAll();
View Full Code Here

   }  
  
   @Test
   public void testCopyDir() throws Exception {
     FileWrapper[] listOfFiles = new FileWrapper[1];
     FileWrapper mockFwJarFileWrapper = mockHelper.createMock("mockFwJarFileWrapper",FileWrapper.class);
     listOfFiles[0] = mockFwJarFileWrapper;
     expect(mockFwJarFileWrapper.exists()).andStubReturn(true);
     expect(mockFwJarFileWrapper.getName()).andReturn("fw.jar");
     expect(mockFwJarFileWrapper.getAbsolutePath()).andStubReturn("/squirrellibdir/test/path/fw.jar");
     expect(mockSquiirelLibDir.listFiles()).andStubReturn(listOfFiles);
    
     FileWrapper mockFwJarFileInDownloadsWrapper =
       mockHelper.createMock("mockFwJarFileInDownloadsWrapper", FileWrapper.class);
     expect(mockFwJarFileInDownloadsWrapper.getAbsolutePath()).andStubReturn("/downloads/test/path/fw.jar");
     expect(mockFwJarFileInDownloadsWrapper.exists()).andReturn(false);
    
     expect(mockFileWrapperFactory.create(mockDownloadsCoreDirectory, "fw.jar"));
     expectLastCall().andReturn(mockFwJarFileInDownloadsWrapper);
    
     mockIOUtilities.copyFile(mockFwJarFileWrapper, mockFwJarFileInDownloadsWrapper);
View Full Code Here

     mockHelper.verifyAll();
   }
  
   @Test (expected = IllegalArgumentException.class)
   public void testCopyDir_fromDirNotADir() throws Exception {
     FileWrapper mockFromDir = mockHelper.createMock("mockFromFile", FileWrapper.class);
     expect(mockFromDir.getAbsolutePath()).andStubReturn("/absolute/path/to/mockFromFile");
    FileWrapper mockToDir = mockHelper.createMock("mockToDir", FileWrapper.class);
    expect(mockToDir.getAbsolutePath()).andStubReturn("/absolute/path/to/mockToDir");
   
     expect(mockFromDir.isDirectory()).andStubReturn(false);
   
     mockHelper.replayAll();
    underTest.copyDir(mockFromDir, mockToDir);
View Full Code Here

    mockHelper.verifyAll();
   }

   @Test (expected = IllegalArgumentException.class)
   public void testCopyDir_ToDirNotADir() throws Exception {
     FileWrapper mockFromDir = mockHelper.createMock("mockFromFile", FileWrapper.class);
     expect(mockFromDir.getAbsolutePath()).andStubReturn("/absolute/path/to/mockFromFile");
    FileWrapper mockToDir = mockHelper.createMock("mockToDir", FileWrapper.class);
    expect(mockToDir.getAbsolutePath()).andStubReturn("/absolute/path/to/mockToDir");
   
     expect(mockFromDir.isDirectory()).andStubReturn(true);
     expect(mockToDir.isDirectory()).andStubReturn(false);
   
     mockHelper.replayAll();
    underTest.copyDir(mockFromDir, mockToDir);
    mockHelper.verifyAll();
   }
View Full Code Here

   
    expect(mockIOUtilities.constructHttpUrl(host, port, fileToGet)).andReturn(url);
   
    
     expect(mockPathUtils.getFileFromPath(fileToGet)).andReturn(fileFromPath);
     FileWrapper destFile = mockHelper.createMock(FileWrapper.class);
     expect(destFile.getAbsolutePath()).andReturn(absPath);
     expect(mockFileWrapperFactory.create(destDir, fileFromPath)).andReturn(destFile);
     if (simulateSuccess) {
       expect(mockIOUtilities.downloadHttpFile(url, destFile, mockProxySettings)).andReturn(fileSize);
     } else {
       expect(mockIOUtilities.downloadHttpFile(url, destFile, mockProxySettings)).andReturn(fileSize-1);
View Full Code Here

TOP

Related Classes of net.sourceforge.squirrel_sql.fw.util.FileWrapper

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.