本文整理汇总了Java中org.mockftpserver.fake.UserAccount类的典型用法代码示例。如果您正苦于以下问题:Java UserAccount类的具体用法?Java UserAccount怎么用?Java UserAccount使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UserAccount类属于org.mockftpserver.fake包,在下文中一共展示了UserAccount类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startftp
import org.mockftpserver.fake.UserAccount; //导入依赖的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();
}
示例2: setup
import org.mockftpserver.fake.UserAccount; //导入依赖的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;
}
示例3: handleServeFile
import org.mockftpserver.fake.UserAccount; //导入依赖的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);
}
示例4: init
import org.mockftpserver.fake.UserAccount; //导入依赖的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();
}
示例5: starting
import org.mockftpserver.fake.UserAccount; //导入依赖的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);
}
示例6: init
import org.mockftpserver.fake.UserAccount; //导入依赖的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();
}
示例7: start
import org.mockftpserver.fake.UserAccount; //导入依赖的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;
}
示例8: main
import org.mockftpserver.fake.UserAccount; //导入依赖的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();
}
示例9: testExecuteWindows
import org.mockftpserver.fake.UserAccount; //导入依赖的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"));
}
示例10: start
import org.mockftpserver.fake.UserAccount; //导入依赖的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();
}
示例11: prepareProfile
import org.mockftpserver.fake.UserAccount; //导入依赖的package包/类
void prepareProfile(String syncType) throws Exception {
testingDst = tmpFolder.newFolder("destination");
testingDst.mkdirs();
testingSrc = tmpFolder.newFolder("source");
testingSrc.mkdirs();
synchronizer = new Synchronizer();
ConnectionDescription src = new ConnectionDescription(testingSrc.toURI());
src.setParameter("bufferStrategy", "");
String dstUrl = null;
if ("file".equals(filesystem)) {
dstUrl = testingDst.toURI().toString();
}
if ("ftp".equals(filesystem)) {
m_fakeServer = new FakeFtpServer();
m_fakeServer.setServerControlPort(TEST_FTP_PORT);
clearDirectory(testingDst);
m_fakeServer.addUserAccount(new UserAccount("SampleUser", "Sample", "/sampleuser"));
m_fakeServer.start();
dstUrl = "ftp://127.0.0.1:" + TEST_FTP_PORT + "/sampleuser";
}
if ("sftp".equals(filesystem)) {
System.setProperty("vfs.sftp.sshdir", new File("./tests/sshd-config/").getAbsolutePath());
testingDst.delete();
testingDst = m_sshServer.getUserHome();
dstUrl = "sftp://127.0.0.1:2222/";
}
ConnectionDescription dst = new ConnectionDescription(new URI(dstUrl));
dst.setParameter("bufferStrategy", "");
dst.setParameter("username", "SampleUser");
dst.setSecretParameter("password", "Sample");
profile = new Profile("TestProfile", src, dst, new SimplyfiedRuleSetDescriptor(true, null, false, null));
profile.setSynchronizationType(syncType);
profile.setDestination(dst);
}
示例12: testFtp
import org.mockftpserver.fake.UserAccount; //导入依赖的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();
}
示例13: testExecuteUnix
import org.mockftpserver.fake.UserAccount; //导入依赖的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);
}
示例14: testExecuteUnix
import org.mockftpserver.fake.UserAccount; //导入依赖的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);
}
示例15: testExecuteWindows
import org.mockftpserver.fake.UserAccount; //导入依赖的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();
}