*/
public void testCreateFolder() {
+ String folderName = "testCreateFolder" + mCurrentDate;
String remotePath = "/testCreateFolder" + mCurrentDate;
boolean createFullPath = true;
- RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
+ RemoteOperationResult result = mActivity.createFolder(folderName, remotePath, createFullPath);
+ assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
+
+ // Create Subfolder
+ folderName = "testCreateFolder" + mCurrentDate;
+ remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
+ createFullPath = true;
+
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
}
+
/**
* Test to Create Folder with special characters
*/
public void testCreateFolderSpecialCharacters() {
boolean createFullPath = true;
+ String folderName = "testSpecialCharacters_//" + mCurrentDate;
String remotePath = "/testSpecialCharacters_//" + mCurrentDate;
- RemoteOperationResult result = mActivity.createFolder(remotePath, createFullPath);
+ RemoteOperationResult result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ folderName = "testSpecialCharacters_\\" + mCurrentDate;
remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ folderName = "testSpecialCharacters_<" + mCurrentDate;
remotePath = "/testSpecialCharacters_<" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ folderName = "testSpecialCharacters_>" + mCurrentDate;
remotePath = "/testSpecialCharacters_>" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ folderName = "testSpecialCharacters_:" + mCurrentDate;
remotePath = "/testSpecialCharacters_:" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ folderName = "testSpecialCharacters_\"" + mCurrentDate;
remotePath = "/testSpecialCharacters_\"" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ folderName = "testSpecialCharacters_|" + mCurrentDate;
remotePath = "/testSpecialCharacters_|" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ folderName = "testSpecialCharacters_?" + mCurrentDate;
remotePath = "/testSpecialCharacters_?" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+ folderName = "testSpecialCharacters_*" + mCurrentDate;
remotePath = "/testSpecialCharacters_*" + mCurrentDate;
- result = mActivity.createFolder(remotePath, createFullPath);
+ result = mActivity.createFolder(folderName, remotePath, createFullPath);
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
}
private static final int CONNECTION_TIMEOUT = 5000;
-
+ protected String mFolderName;
protected String mRemotePath;
protected boolean mCreateFullPath;
/**
* Constructor
*
+ * @param folderName Name of new directory
* @param remotePath Full path to the new directory to create in the remote server.
* @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet.
*/
- public CreateRemoteFolderOperation(String remotePath, boolean createFullPath) {
+ public CreateRemoteFolderOperation(String folderName, String remotePath, boolean createFullPath) {
+ mFolderName = folderName;
mRemotePath = remotePath;
mCreateFullPath = createFullPath;
}
RemoteOperationResult result = null;
MkColMethod mkcol = null;
- boolean noInvalidChars = FileUtils.validateName(mRemotePath);
+ boolean noInvalidChars = FileUtils.validateName(mFolderName);
if (noInvalidChars) {
try {
mkcol = new MkColMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath));
private RemoteOperationResult createParentFolder(String parentPath, WebdavClient client) {
- RemoteOperation operation = new CreateRemoteFolderOperation( parentPath,
+ RemoteOperation operation = new CreateRemoteFolderOperation("", parentPath,
mCreateFullPath);
return operation.execute(client);
}
private static final String TAG = CreateFolderOperation.class.getSimpleName();
+ protected String mFolderName;
protected String mRemotePath;
protected boolean mCreateFullPath;
protected FileDataStorageManager mStorageManager;
* @param createFullPath 'True' means that all the ancestor folders should be created if don't exist yet.
* @param storageManager Reference to the local database corresponding to the account where the file is contained.
*/
- public CreateFolderOperation(String remotePath, boolean createFullPath, FileDataStorageManager storageManager) {
+ public CreateFolderOperation(String folderName, String remotePath, boolean createFullPath, FileDataStorageManager storageManager) {
+ mFolderName = folderName;
mRemotePath = remotePath;
mCreateFullPath = createFullPath;
mStorageManager = storageManager;
@Override
protected RemoteOperationResult run(WebdavClient client) {
- CreateRemoteFolderOperation operation = new CreateRemoteFolderOperation(mRemotePath, mCreateFullPath);
+ CreateRemoteFolderOperation operation = new CreateRemoteFolderOperation(mFolderName, mRemotePath, mCreateFullPath);
RemoteOperationResult result = operation.execute(client);
if (result.isSuccess()) {