本文整理汇总了Java中org.mockftpserver.fake.filesystem.FileSystem类的典型用法代码示例。如果您正苦于以下问题:Java FileSystem类的具体用法?Java FileSystem怎么用?Java FileSystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FileSystem类属于org.mockftpserver.fake.filesystem包,在下文中一共展示了FileSystem类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: startftp
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的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.FileSystem; //导入依赖的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: handleServeFile
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的package包/类
@Override
protected void handleServeFile(String fs, String path, long timeout) {
FileSystem fileSystem = fakeFtpServer.getFileSystem();
String root = new File(path).getParent();
String userName = StringUtils.randomString(8);
String password = StringUtils.randomString(8);
UserAccount userAccount = new UserAccount(userName, password, root);
if (fileSystem.getEntry(root) == null) {
DirectoryEntry directoryEntry = new DirectoryEntry(root);
directoryEntry.setPermissionsFromString("r-xr-xr-x");
fileSystem.add(directoryEntry);
}
if (fileSystem.getEntry(path) == null) {
FxFileEntity fileEntry = new FxFileEntity(path);
fileSystem.add(fileEntry);
}
fakeFtpServer.addUserAccount(userAccount);
notifyServeApply("ftp", userName, password, NetUtils.getLocalIpAddress(this), fakeFtpServer.getServerControlPort(), path);
}
开发者ID:muyuballs,项目名称:FxExplorer,代码行数:20,代码来源:FtpFileService.java
示例4: clearDirectory
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的package包/类
/**
* recursively delete directory and all contained files.
*
* @param dir directory to clear
*/
protected void clearDirectory(final File dir) {
if ((testingDst == dir) && "ftp".equals(filesystem)) {
FileSystem fs = new UnixFakeFileSystem();
fs.add(new DirectoryEntry("/sampleuser"));
m_fakeServer.setFileSystem(fs);
}
else {
File[] children = dir.listFiles();
if (null != children) {
for (File file : children) {
if (file.isDirectory()) {
clearDirectory(file);
}
assertTrue("File.delete failed for: " + file.getAbsolutePath(), file.delete());
}
}
}
}
开发者ID:fullsync,项目名称:fullsync,代码行数:24,代码来源:FilesystemTest.java
示例5: retrieveFileListAndDeleteTestCase
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的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
示例6: start
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的package包/类
/**
* 启动FTP
*/
private void start() {
queue = new LinkedBlockingDeque<>();
fakeFtpServer = new FakeFtpServer();
fakeFtpServer.addUserAccount(new UserAccount(USERNAME, PASSWORD, HOME_DIR));
FileSystem fileSystem = new WindowsFakeFileSystem();
fileSystem.add(new DirectoryEntry(HOME_DIR));
fakeFtpServer.setFileSystem(fileSystem);
fakeFtpServer.setServerControlPort(21);
fakeFtpServer.start();
int port = fakeFtpServer.getServerControlPort();
ftpPath = "ftp://" + USERNAME + ":" + PASSWORD + "@127.0.0.1:" + port;
}
开发者ID:edgar615,项目名称:javase-study,代码行数:18,代码来源:Main.java
示例7: main
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的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
示例8: testExecuteWindows
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的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
示例9: start
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的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
示例10: handleRemoveFile
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的package包/类
@Override
protected void handleRemoveFile(String path) {
FileSystem fileSystem = fakeFtpServer.getFileSystem();
fileSystem.delete(path);
}
开发者ID:muyuballs,项目名称:FxExplorer,代码行数:6,代码来源:FtpFileService.java
示例11: testFtp
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的package包/类
@Test
public void testFtp() throws Exception {
FakeFtpServer fakeFtpServer = new FakeFtpServer();
fakeFtpServer.setServerControlPort(0);
FileSystem fileSystem = new UnixFakeFileSystem();
File file =
new File(currentThread().getContextClassLoader().getResource("remote-download-source/parseNoError").getFile())
.listFiles()[0];
String value = FileUtils.readFileToString(file);
fileSystem.add(new FileEntry("/testfile", value));
fakeFtpServer.setFileSystem(fileSystem);
UserAccount userAccount = new UserAccount("testuser", "pass", "/");
fakeFtpServer.addUserAccount(userAccount);
fakeFtpServer.start();
int port = fakeFtpServer.getServerControlPort();
RemoteDownloadSource origin =
new RemoteDownloadSource(getBean(
"ftp://localhost:" + String.valueOf(port) + "/",
true,
"testuser",
"pass",
null,
null,
null,
true,
DataFormat.JSON,
null,
false,
"*"
));
SourceRunner runner = new SourceRunner.Builder(RemoteDownloadDSource.class, origin)
.addOutputLane("lane")
.build();
runner.runInit();
List<Record> expected = getExpectedRecords();
String offset = RemoteDownloadSource.NOTHING_READ;
StageRunner.Output op = runner.runProduce(offset, 1000);
List<Record> actual = op.getRecords().get("lane");
Assert.assertEquals(expected.size(), actual.size());
for (int i = 0; i < 2; i++) {
Assert.assertEquals(expected.get(i).get(), actual.get(i).get());
}
runner.runDestroy();
}
开发者ID:streamsets,项目名称:datacollector,代码行数:47,代码来源:TestRemoteDownloadSource.java
示例12: testExecuteUnix
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的package包/类
@Test
public void testExecuteUnix() throws Exception {
FakeFtpServer aFakeFtpServer = new FakeFtpServer();
aFakeFtpServer.setServerControlPort(0);
aFakeFtpServer.addUserAccount(new UserAccount("user", "password", "/"));
FileSystem aFileSystem = new UnixFakeFileSystem();
aFileSystem.add(new DirectoryEntry("/data"));
aFileSystem.add(new FileEntry("/data/file1.txt", "file1"));
aFileSystem.add(new FileEntry("/data/file2.html", "file2"));
aFileSystem.add(new FileEntry("/data/file3.html", "file3"));
aFakeFtpServer.setFileSystem(aFileSystem);
aFakeFtpServer.start();
int aPort = aFakeFtpServer.getServerControlPort();
assertFalse(aFileSystem.exists("/data/input.csv"));
assertFalse(aFileSystem.exists("/data/input1000.csv"));
assertFalse(aFileSystem.exists("/data/mixedindex.csv"));
FTPUploadTasklet aTasklet = new FTPUploadTasklet();
DefaultFtpClientFactory aFtpClientFactory = new DefaultFtpClientFactory();
aFtpClientFactory.setHost("localhost");
aFtpClientFactory.setPort(aPort);
aFtpClientFactory.setUsername("user");
aFtpClientFactory.setPassword("password");
aTasklet.setFtpClientFactory(aFtpClientFactory);
aTasklet.setLocalBaseDir("src/test/resources/testFiles");
aTasklet.setRemoteBaseDir("/data/");
aTasklet.setRegexFilename(".*\\.csv");
StepContribution aStepContribution = mock(StepContribution.class);
aTasklet.execute(aStepContribution, null);
assertTrue(aFileSystem.exists("/data/input.csv"));
assertTrue(aFileSystem.exists("/data/input1000.csv"));
assertTrue(aFileSystem.exists("/data/mixedindex.csv"));
verify(aStepContribution, times(3)).incrementReadCount();
verify(aStepContribution, times(3)).incrementWriteCount(1);
}
开发者ID:acxio,项目名称:AGIA,代码行数:45,代码来源:FTPUploadTaskletTest.java
示例13: testExecuteUnix
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的package包/类
@Test
public void testExecuteUnix() throws Exception {
assertFalse(new File("target/file2.zip").exists());
assertFalse(new File("target/file3.zip").exists());
FakeFtpServer aFakeFtpServer = new FakeFtpServer();
aFakeFtpServer.setServerControlPort(0);
aFakeFtpServer.addUserAccount(new UserAccount("user", "password", "/"));
FileSystem aFileSystem = new UnixFakeFileSystem();
aFileSystem.add(new DirectoryEntry("/data"));
aFileSystem.add(new FileEntry("/data/file1.txt", "file1"));
aFileSystem.add(new FileEntry("/data/file2.zip", "file2"));
aFileSystem.add(new FileEntry("/data/file3.zip", "file3"));
aFakeFtpServer.setFileSystem(aFileSystem);
aFakeFtpServer.start();
int aPort = aFakeFtpServer.getServerControlPort();
FTPDownloadTasklet aTasklet = new FTPDownloadTasklet();
DefaultFtpClientFactory aFtpClientFactory = new DefaultFtpClientFactory();
aFtpClientFactory.setHost("localhost");
aFtpClientFactory.setPort(aPort);
aFtpClientFactory.setUsername("user");
aFtpClientFactory.setPassword("password");
aFtpClientFactory.setFileTransferMode(2);
aFtpClientFactory.setFileType(2);
aFtpClientFactory.setBufferSize(100000);
aTasklet.setFtpClientFactory(aFtpClientFactory);
aTasklet.setLocalBaseDir("target");
aTasklet.setRemoteBaseDir("/data/");
aTasklet.setRegexFilename(".*\\.zip");
StepContribution aStepContribution = mock(StepContribution.class);
aTasklet.execute(aStepContribution, null);
assertTrue(new File("target/file2.zip").exists());
assertTrue(new File("target/file3.zip").exists());
new File("target/file2.zip").delete();
new File("target/file3.zip").delete();
verify(aStepContribution, times(2)).incrementReadCount();
verify(aStepContribution, times(2)).incrementWriteCount(1);
}
开发者ID:acxio,项目名称:AGIA,代码行数:50,代码来源:FTPDownloadTaskletTest.java
示例14: testExecuteWindows
import org.mockftpserver.fake.filesystem.FileSystem; //导入依赖的package包/类
@Test
public void testExecuteWindows() throws Exception {
assertFalse(new File("target/file2.zip").exists());
assertFalse(new File("target/file3.zip").exists());
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.zip", "file2"));
aFileSystem.add(new FileEntry("c:\\data\\file3.zip", "file3"));
aFakeFtpServer.setFileSystem(aFileSystem);
aFakeFtpServer.start();
int aPort = aFakeFtpServer.getServerControlPort();
FTPDownloadTasklet aTasklet = new FTPDownloadTasklet();
DefaultFtpClientFactory aFtpClientFactory = new DefaultFtpClientFactory();
aFtpClientFactory.setHost("localhost");
aFtpClientFactory.setPort(aPort);
aFtpClientFactory.setUsername("user");
aFtpClientFactory.setPassword("password");
aFtpClientFactory.setSystemKey("WINDOWS");
aFtpClientFactory.setFileTransferMode(2);
aFtpClientFactory.setFileType(2);
aFtpClientFactory.setBufferSize(100000);
aTasklet.setFtpClientFactory(aFtpClientFactory);
aTasklet.setLocalBaseDir("target");
aTasklet.setRemoteBaseDir("c:/data/");
aTasklet.setRegexFilename(".*\\.zip");
aTasklet.execute(null, null);
assertTrue(new File("target/file2.zip").exists());
assertTrue(new File("target/file3.zip").exists());
new File("target/file2.zip").delete();
new File("target/file3.zip").delete();
}
开发者ID:acxio,项目名称:AGIA,代码行数:46,代码来源:FTPDownloadTaskletTest.java
注:本文中的org.mockftpserver.fake.filesystem.FileSystem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论