파일 업로드를 위해 FTP 클라이언트 기능을 테스트하기 위해 간단한 FTPServer를 유닛 테스트에 포함하려고합니다. 나는 Apache FTPServer (ftpserver-core-1.0.6.jar)를 시도했다.Windows 용 UnitTest 용 내장 FTPServer : FileUpload 551 오류
220 Service ready for new user.
USER *******
331 Guest login okay, send your complete e-mail address as password.
PASS *******
230 User logged in, proceed.
SYST
215 UNIX Type: Apache FtpServer
TYPE I
200 Command TYPE okay.
:
FtpServerFactory serverFactory = new FtpServerFactory();
BaseUser user = new BaseUser();
user.setName("anonymous");
user.setPassword(System.getProperty("user.name") + "@" + InetAddress.getLocalHost().getHostName());
user.setHomeDirectory(TEST_TARGET_DIR_LOCAL);
List<Authority> authorities = new ArrayList<Authority>();
authorities.add(new WritePermission());
user.setAuthorities(authorities);
UserManager userManager = serverFactory.getUserManager();
userManager.save(user);
myServer = serverFactory.createServer();
myServer.start();
이에 연결하고 로깅을 위해 완벽하게 작동합니다 :
파일 업로드가 여기에
551 /C:/<correctDestinationPath>/myFile.txt: Error on output file.
서버를 설정하는 내 코드와 함께 실패 생산적 코드는 다음과 같이 FTPClient를 호출합니다.
myFtpClient.storeFile("C:\<correctDestinationPath>\myFile.txt", anInputStream);
이것은 내 Windows 컴퓨터의 올바른 경로입니다. 하지만 FTPServer는 유닉스와 비슷한 경로 인 "/C:/correctDestinationPath/myFile.txt"를 스크램블합니다.
Windows에서도 작동하는 FTPServer를 어떻게 구성 할 수 있습니까? 단위 테스트 자체는 물론 OS 중립적이어야합니다.