当前位置: 首页>>代码示例>>Java>>正文


Java FileEntry类代码示例

本文整理汇总了Java中org.mockftpserver.fake.filesystem.FileEntry的典型用法代码示例。如果您正苦于以下问题:Java FileEntry类的具体用法?Java FileEntry怎么用?Java FileEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FileEntry类属于org.mockftpserver.fake.filesystem包,在下文中一共展示了FileEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startftp

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@BeforeClass
 protected void startftp() throws Exception
 {
    fakeFtpServer = new FakeFtpServer();
    fakeFtpServer.setServerControlPort(8089);  // use any free port

    FileSystem fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new FileEntry("/data/s1-level-1-calibration.xsd", "<schema/>"));
    fileSystem.add(new FileEntry("/data/s1-object-types.xsd", "<schema/>"));
    fileSystem.add(new FileEntry("/data/GOM_EXT_2PNPDE20070312_232536_000000542056_00202_26308_1271.N1", "GOMOS DATA!"));
    fileSystem.add(new FileEntry ("/data/S1A_IW_SLC__1SDV_20141003T054235_20141003T054304_002661_002F66_D5C8.SAFE/manifest.safe", "<XFDU/>"));
    fileSystem.add(new FileEntry ("/data/S1A_EW_GRDH_1SSH_20120101T022934_20120101T022945_001770_000001_AF02.SAFE/manifest.safe", "<XFDU/>"));
    fileSystem.add(new FileEntry("/data/manifest.safe", "<XFDU/>"));
    
    fakeFtpServer.setFileSystem(fileSystem);

    UserAccount userAccount = new UserAccount("user", "password", "/");
    fakeFtpServer.addUserAccount(userAccount);
    
    fakeFtpServer.start();
}
 
开发者ID:SentinelDataHub,项目名称:dhus-core,代码行数:22,代码来源:ScannerFactoryTest.java

示例2: setup

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
public static FakeFtpServer setup() {

        server = new FakeFtpServer();
        server.addUserAccount(new UserAccount("user", "password", "/tmp"));
        server.setServerControlPort(0);

        FileSystem fileSystem = new UnixFakeFileSystem();
        fileSystem.add(new DirectoryEntry("/tmp"));
        fileSystem.add(new FileEntry("/tmp/file1.txt", "hello world"));
        fileSystem.add(new FileEntry("/tmp/file2.txt", "hello world"));
        fileSystem.add(new FileEntry("/tmp/file3.txt", "hello world"));

        server.setFileSystem(fileSystem);
        server.start();

        return server;
    }
 
开发者ID:linuxserver,项目名称:davos,代码行数:18,代码来源:FakeFTPServerFactory.java

示例3: init

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@BeforeClass
public void init() {
    ftpServer = new FakeFtpServer();
    ftpServer.setServerControlPort(0);
    ftpServer.addUserAccount(new UserAccount(username, password, rootFolder));
    fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry(rootFolder));
    fileSystem.add(new FileEntry("/home/wso2/file1.txt", content));
    fileSystem.add(new FileEntry("/home/wso2/file10.txt", content));
    fileSystem.add(new FileEntry("/home/wso2/file11.txt", content));
    fileSystem.add(new FileEntry("/home/wso2/file2.txt"));
    fileSystem.add(new DirectoryEntry("/home/wso2/move"));
    fileSystem.add(new DirectoryEntry("/home/wso2/copy"));
    ftpServer.setFileSystem(fileSystem);
    ftpServer.start();
    serverPort = ftpServer.getServerControlPort();
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:18,代码来源:RemoteFileSystemClientConnectorTestCase.java

示例4: fileContentWriteTestCase

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@Test(description = "Check file content.")
public void fileContentWriteTestCase() throws ServerConnectorException, InterruptedException {
    String newContent = "Sample text";
    Map<String, String> parameters = new HashMap<>();
    parameters.put(Constants.URI, buildConnectionURL() + "/file2.txt");
    parameters.put(Constants.ACTION, Constants.WRITE);
    parameters.put(Constants.PROTOCOL, Constants.PROTOCOL_FTP);
    parameters.put(Constants.FTP_PASSIVE_MODE, Boolean.TRUE.toString());
    CountDownLatch latch = new CountDownLatch(1);
    RemoteFileSystemConnectorFactory connectorFactory = new RemoteFileSystemConnectorFactoryImpl();
    TestReadActionListener fileSystemListener = new TestReadActionListener(latch);
    VFSClientConnector clientConnector =
            connectorFactory.createVFSClientConnector(parameters, fileSystemListener);
    RemoteFileSystemMessage message = new RemoteFileSystemMessage(ByteBuffer.wrap(newContent.getBytes()));
    clientConnector.send(message);
    latch.await(3, TimeUnit.SECONDS);
    FileEntry entry = (FileEntry) fileSystem.getEntry("/home/wso2/file2.txt");
    InputStream inputStream = entry.createInputStream();
    String fileContent = new BufferedReader(new InputStreamReader(inputStream)).lines().
            collect(Collectors.joining("\n"));
    Assert.assertEquals(fileContent, newContent, "File content invalid.");
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:23,代码来源:RemoteFileSystemClientConnectorTestCase.java

示例5: writeContentToNewFileTestCase

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@Test(description = "Write content by creating new file")
public void writeContentToNewFileTestCase() throws ServerConnectorException, InterruptedException {
    String newContent = "Sample text";
    Map<String, String> parameters = new HashMap<>();
    parameters.put(Constants.URI, buildConnectionURL() + "/file4.txt");
    parameters.put(Constants.ACTION, Constants.WRITE);
    parameters.put(Constants.PROTOCOL, Constants.PROTOCOL_FTP);
    parameters.put(Constants.FTP_PASSIVE_MODE, Boolean.TRUE.toString());
    CountDownLatch latch = new CountDownLatch(1);
    RemoteFileSystemConnectorFactory connectorFactory = new RemoteFileSystemConnectorFactoryImpl();
    TestReadActionListener fileSystemListener = new TestReadActionListener(latch);
    VFSClientConnector clientConnector =
            connectorFactory.createVFSClientConnector(parameters, fileSystemListener);
    RemoteFileSystemMessage message = new RemoteFileSystemMessage(ByteBuffer.wrap(newContent.getBytes()));
    clientConnector.send(message);
    latch.await(3, TimeUnit.SECONDS);
    FileEntry entry = (FileEntry) fileSystem.getEntry("/home/wso2/file4.txt");
    InputStream inputStream = entry.createInputStream();
    String fileContent = new BufferedReader(new InputStreamReader(inputStream)).lines().
            collect(Collectors.joining("\n"));
    Assert.assertEquals(fileContent, newContent, "File content invalid.");
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:23,代码来源:RemoteFileSystemClientConnectorTestCase.java

示例6: fileContentAppendTestCase

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@Test(description = "Check file content append.", dependsOnMethods = "fileContentReadTestCase")
public void fileContentAppendTestCase() throws ServerConnectorException, InterruptedException {
    String newContent = " Sample text";
    Map<String, String> parameters = new HashMap<>();
    parameters.put(Constants.URI, buildConnectionURL() + "/file1.txt");
    parameters.put(Constants.ACTION, Constants.WRITE);
    parameters.put(Constants.APPEND, String.valueOf(true));
    parameters.put(Constants.PROTOCOL, Constants.PROTOCOL_FTP);
    parameters.put(Constants.FTP_PASSIVE_MODE, Boolean.TRUE.toString());
    CountDownLatch latch = new CountDownLatch(1);
    RemoteFileSystemConnectorFactory connectorFactory = new RemoteFileSystemConnectorFactoryImpl();
    TestReadActionListener fileSystemListener = new TestReadActionListener(latch);
    VFSClientConnector clientConnector =
            connectorFactory.createVFSClientConnector(parameters, fileSystemListener);
    RemoteFileSystemMessage message = new RemoteFileSystemMessage(ByteBuffer.wrap(newContent.getBytes()));
    clientConnector.send(message);
    latch.await(3, TimeUnit.SECONDS);
    FileEntry entry = (FileEntry) fileSystem.getEntry("/home/wso2/file1.txt");
    InputStream inputStream = entry.createInputStream();
    String fileContent = new BufferedReader(new InputStreamReader(inputStream)).lines().
            collect(Collectors.joining("\n"));
    Assert.assertEquals(fileContent, content + newContent, "File content invalid.");
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:24,代码来源:RemoteFileSystemClientConnectorTestCase.java

示例7: retrieveFileListTestCase

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@Test(description = "Testing whether correctly getting the file path.")
public void retrieveFileListTestCase() throws ServerConnectorException, InterruptedException {
    int expectedEventCount = 3;
    Map<String, String> parameters = getPropertyMap("NONE", false);
    CountDownLatch latch = new CountDownLatch(1);
    RemoteFileSystemConnectorFactory connectorFactory = new RemoteFileSystemConnectorFactoryImpl();
    TestServerRemoteFileSystemListener fileSystemListener = new TestServerRemoteFileSystemListener(latch,
            expectedEventCount);
    RemoteFileSystemServerConnector testConnector =
            connectorFactory.createServerConnector("TestService", parameters, fileSystemListener);
    testConnector.start();
    fileSystem.add(new FileEntry("/home/wso2/file2.txt"));
    latch.await(1, TimeUnit.MINUTES);
    List<String> eventList = fileSystemListener.getEventList();
    if (eventList.size() == 0) {
        Assert.fail("File event didn't triggered.");
    }
    Assert.assertEquals(eventList.size(), expectedEventCount, "Generated events count mismatch " +
            "with the expected.");
    Assert.assertTrue(eventList.contains(buildConnectionURL() + "/exe/run.exe"));
    Assert.assertTrue(eventList.contains(buildConnectionURL() + "/file1.txt"));
    Assert.assertTrue(eventList.contains(buildConnectionURL() + "/file2.txt"));
    testConnector.stop();
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:25,代码来源:RemoteFileSystemServerConnectorTestCase.java

示例8: addDirectoryWithNameAndNumberOfFiles

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
public static void addDirectoryWithNameAndNumberOfFiles(String name, int numberOfFiles) {

        server.getFileSystem().add(new DirectoryEntry("/tmp/" + name));

        int i;
        for (i = 0; i < numberOfFiles; i++)
            server.getFileSystem().add(new FileEntry("/tmp/" + name + "/file" + i));
    }
 
开发者ID:linuxserver,项目名称:davos,代码行数:9,代码来源:FakeFTPServerFactory.java

示例9: starting

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@Override
protected void starting(org.junit.runner.Description description)
{
  UnixFakeFileSystem fileSystem = new UnixFakeFileSystem();
  DirectoryEntry homeDirectory = new DirectoryEntry("/home/test");
  fileSystem.add(homeDirectory);
  fileSystem.add(new FileEntry(homeDirectory.getPath() + "/1.txt", "1\n10\n"));
  fileSystem.add(new FileEntry(homeDirectory.getPath() + "/2.txt", "2\n20\n"));

  fakeFtpServer = new FakeFtpServer();
  fakeFtpServer.setServerControlPort(0);
  fakeFtpServer.addUserAccount(new UserAccount("testUser", "test", homeDirectory.getPath()));


  fakeFtpServer.setFileSystem(fileSystem);
  fakeFtpServer.start();

  ftpOperator = new FTPStringInputOperator();
  ftpOperator.setHost("localhost");
  ftpOperator.setPort(fakeFtpServer.getServerControlPort());
  ftpOperator.setUserName("testUser");
  ftpOperator.setPassword("test");

  ftpOperator.setDirectory(homeDirectory.getPath());
  ftpOperator.setup(mockOperatorContext(11, new Attribute.AttributeMap.DefaultAttributeMap()));

  sink = new CollectorTestSink<>();
  ftpOperator.output.setSink(sink);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:30,代码来源:FTPStringInputOperatorTest.java

示例10: init

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@BeforeClass
public void init() {
    ftpServer = new FakeFtpServer();
    ftpServer.setServerControlPort(0);
    ftpServer.addUserAccount(new UserAccount(username, password, rootFolder));

    fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry(rootFolder));
    fileSystem.add(new FileEntry("/home/wso2/file1.txt", "some content 1234567890"));
    fileSystem.add(new FileEntry("/home/wso2/exe/run.exe", "Test Value"));
    ftpServer.setFileSystem(fileSystem);
    ftpServer.start();
    serverPort = ftpServer.getServerControlPort();
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:15,代码来源:RemoteFileSystemServerConnectorTestCase.java

示例11: retrieveFileListAndDeleteTestCase

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@Test(description = "Testing whether correctly move files.", dependsOnMethods = "retrieveFileListAndMoveTestCase")
public void retrieveFileListAndDeleteTestCase() throws ServerConnectorException, InterruptedException {
    int expectedEventCount = 2;
    FileSystem fileSystem = new UnixFakeFileSystem();
    fileSystem.add(new DirectoryEntry(rootFolder));
    fileSystem.add(new FileEntry("/home/wso2/del1.txt"));
    fileSystem.add(new FileEntry("/home/wso2/del2.txt"));
    ftpServer.setFileSystem(fileSystem);

    Map<String, String> parameters = getPropertyMap("DELETE", false);
    CountDownLatch latch = new CountDownLatch(1);
    RemoteFileSystemConnectorFactory connectorFactory = new RemoteFileSystemConnectorFactoryImpl();
    TestServerRemoteFileSystemListener fileSystemListener =
            new TestServerRemoteFileSystemListener(latch, expectedEventCount);
    RemoteFileSystemServerConnector testConnector =
            connectorFactory.createServerConnector("TestService", parameters, fileSystemListener);
    testConnector.start();
    latch.await(1, TimeUnit.MINUTES);
    List<String> eventList = fileSystemListener.getEventList();
    if (eventList.size() == 0) {
        Assert.fail("File event didn't triggered.");
    }
    Assert.assertEquals(eventList.size(), expectedEventCount, "Generated events count mismatch " +
            "with the expected.");
    Assert.assertTrue(eventList.contains(buildConnectionURL() + "/del1.txt"));
    Assert.assertTrue(eventList.contains(buildConnectionURL() + "/del2.txt"));
    testConnector.stop();
}
 
开发者ID:wso2,项目名称:carbon-transports,代码行数:29,代码来源:RemoteFileSystemServerConnectorTestCase.java

示例12: main

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
public static void main(String[] args) {
    FakeFtpServer fakeFtpServer = new FakeFtpServer();
    fakeFtpServer.addUserAccount(new UserAccount("user", "pwd", "c:\\data"));

    FileSystem fileSystem = new WindowsFakeFileSystem();
    fileSystem.add(new DirectoryEntry("c:\\data"));
    fileSystem.add(new FileEntry("c:\\data\\file1.txt", "abcdef 1234567890"));
    fileSystem.add(new FileEntry("c:\\data\\run.exe"));
    fakeFtpServer.setFileSystem(fileSystem);
    fakeFtpServer.setServerControlPort(21);
    fakeFtpServer.start();
}
 
开发者ID:edgar615,项目名称:javase-study,代码行数:13,代码来源:MockFtp.java

示例13: testExecuteWindows

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@Test
public void testExecuteWindows() throws Exception {
	FakeFtpServer aFakeFtpServer = new FakeFtpServer();
	aFakeFtpServer.setServerControlPort(0);
	aFakeFtpServer.addUserAccount(new UserAccount("user", "password", "c:\\"));
	
	FileSystem aFileSystem = new WindowsFakeFileSystem();
	aFileSystem.add(new DirectoryEntry("c:\\data"));
	aFileSystem.add(new FileEntry("c:\\data\\file1.txt", "file1"));
	aFileSystem.add(new FileEntry("c:\\data\\file2.html", "file2"));
	aFileSystem.add(new FileEntry("c:\\data\\file3.html", "file3"));
	aFakeFtpServer.setFileSystem(aFileSystem);

	aFakeFtpServer.start();
	int aPort = aFakeFtpServer.getServerControlPort();
	
	assertFalse(aFileSystem.exists("c:\\data\\input.csv"));
	assertFalse(aFileSystem.exists("c:\\data\\input1000.csv"));
	assertFalse(aFileSystem.exists("c:\\data\\mixedindex.csv"));
	
	FTPUploadTasklet aTasklet = new FTPUploadTasklet();
	DefaultFtpClientFactory aFtpClientFactory = new DefaultFtpClientFactory();
	aFtpClientFactory.setHost("localhost");
	aFtpClientFactory.setPort(aPort);
	aFtpClientFactory.setUsername("user");
	aFtpClientFactory.setPassword("password");
	aFtpClientFactory.setSystemKey("WINDOWS");
	
	aTasklet.setFtpClientFactory(aFtpClientFactory);
	
	aTasklet.setLocalBaseDir("src/test/resources/testFiles");
	aTasklet.setRemoteBaseDir("c:/data/");
	aTasklet.setRegexFilename(".*\\.csv");
	
	aTasklet.execute(null, null);
	
	assertTrue(aFileSystem.exists("c:\\data\\input.csv"));
	assertTrue(aFileSystem.exists("c:\\data\\input1000.csv"));
	assertTrue(aFileSystem.exists("c:\\data\\mixedindex.csv"));
}
 
开发者ID:acxio,项目名称:AGIA,代码行数:41,代码来源:FTPUploadTaskletTest.java

示例14: start

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
@Override
public void start(String content) {
	ftpServer = new FakeFtpServer();
	ftpServer.setServerControlPort(8083);
	ftpServer.addUserAccount(new UserAccount("user", "pass", "/"));
	FileSystem fileSystem = new UnixFakeFileSystem();
	fileSystem.add(new DirectoryEntry("/"));
	fileSystem.add(new FileEntry("/" + FILE_NAME, content));
	ftpServer.setFileSystem(fileSystem);
	ftpServer.start();
}
 
开发者ID:jvalue,项目名称:open-data-service,代码行数:12,代码来源:FtpServer.java

示例15: createNewFileWithContents

import org.mockftpserver.fake.filesystem.FileEntry; //导入依赖的package包/类
protected void createNewFileWithContents(File dir, String filename, long lm, String content) throws IOException {
	if ((dir == testingDst) && "ftp".equals(filesystem)) {
		FileEntry file = new FileEntry("/sampleuser/" + filename, content);
		file.setLastModified(new Date(lm));
		m_fakeServer.getFileSystem().add(file);
	}
	else {
		try (PrintStream out = createNewFile(dir, filename)) {
			out.print(content);
		}
		File f = new File(dir, filename);
		assertTrue("File.setLastModified failed for: " + f.getAbsolutePath(), f.setLastModified(lm));
	}
}
 
开发者ID:fullsync,项目名称:fullsync,代码行数:15,代码来源:FilesystemTest.java


注:本文中的org.mockftpserver.fake.filesystem.FileEntry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。