mirror of
https://github.com/owncloud/android-library.git
synced 2025-06-07 16:06:08 +00:00
Fix unit test
This commit is contained in:
parent
87582c4a8e
commit
43f6fe93e6
@ -27,4 +27,5 @@
|
||||
<string name="server_base_url"></string>
|
||||
<string name="username"></string>
|
||||
<string name="password"></string>
|
||||
<string name ="user_agent">Android-ownCloud</string>
|
||||
</resources>
|
||||
|
@ -79,7 +79,8 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
mHandler = new Handler();
|
||||
|
||||
Uri serverUri = Uri.parse(getString(R.string.server_base_url));
|
||||
mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true);
|
||||
mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true,
|
||||
getString(R.string.user_agent));
|
||||
mClient.setCredentials(
|
||||
OwnCloudCredentialsFactory.newBasicCredentials(
|
||||
getString(R.string.username),
|
||||
@ -149,7 +150,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
|
||||
private void startRefresh() {
|
||||
ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR);
|
||||
refreshOperation.execute(mClient, this, mHandler);
|
||||
refreshOperation.execute(mClient, getString(R.string.user_agent), this, mHandler);
|
||||
}
|
||||
|
||||
private void startUpload() {
|
||||
@ -159,7 +160,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
String mimeType = getString(R.string.sample_file_mimetype);
|
||||
UploadRemoteFileOperation uploadOperation = new UploadRemoteFileOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType);
|
||||
uploadOperation.addDatatransferProgressListener(this);
|
||||
uploadOperation.execute(mClient, this, mHandler);
|
||||
uploadOperation.execute(mClient, getString(R.string.user_agent), this, mHandler);
|
||||
}
|
||||
|
||||
private void startRemoteDeletion() {
|
||||
@ -167,7 +168,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
File fileToUpload = upFolder.listFiles()[0];
|
||||
String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
|
||||
RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath);
|
||||
removeOperation.execute(mClient, this, mHandler);
|
||||
removeOperation.execute(mClient, getString(R.string.user_agent), this, mHandler);
|
||||
}
|
||||
|
||||
private void startDownload() {
|
||||
@ -178,7 +179,7 @@ public class MainActivity extends Activity implements OnRemoteOperationListener,
|
||||
String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
|
||||
DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remotePath, downFolder.getAbsolutePath());
|
||||
downloadOperation.addDatatransferProgressListener(this);
|
||||
downloadOperation.execute(mClient, this, mHandler);
|
||||
downloadOperation.execute(mClient, getString(R.string.user_agent), this, mHandler);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -28,4 +28,5 @@
|
||||
<string name="server_base_url"></string>
|
||||
<string name="username"></string>
|
||||
<string name="password"></string>
|
||||
<string name ="user_agent">Android-ownCloud</string>
|
||||
</resources>
|
||||
|
@ -72,6 +72,7 @@ public class TestActivity extends Activity {
|
||||
private String mServerUri;
|
||||
private String mUser;
|
||||
private String mPass;
|
||||
private static String mUserAgent;
|
||||
|
||||
private static final int BUFFER_SIZE = 1024;
|
||||
|
||||
@ -90,6 +91,7 @@ public class TestActivity extends Activity {
|
||||
mServerUri = getString(R.string.server_base_url);
|
||||
mUser = getString(R.string.username);
|
||||
mPass = getString(R.string.password);
|
||||
mUserAgent = getString(R.string.user_agent);
|
||||
|
||||
Protocol pr = Protocol.getProtocol("https");
|
||||
if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
|
||||
@ -104,7 +106,8 @@ public class TestActivity extends Activity {
|
||||
}
|
||||
}
|
||||
|
||||
mClient = new OwnCloudClient(Uri.parse(mServerUri), NetworkUtils.getMultiThreadedConnManager());
|
||||
mClient = new OwnCloudClient(Uri.parse(mServerUri), NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
mClient.setDefaultTimeouts(
|
||||
OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT,
|
||||
OwnCloudClientFactory.DEFAULT_CONNECTION_TIMEOUT);
|
||||
@ -156,7 +159,7 @@ public class TestActivity extends Activity {
|
||||
|
||||
CreateRemoteFolderOperation createOperation =
|
||||
new CreateRemoteFolderOperation(remotePath, createFullPath);
|
||||
RemoteOperationResult result = createOperation.execute(client);
|
||||
RemoteOperationResult result = createOperation.execute(client, mUserAgent);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -174,7 +177,7 @@ public class TestActivity extends Activity {
|
||||
public RemoteOperationResult renameFile(String oldName, String oldRemotePath, String newName, boolean isFolder) {
|
||||
|
||||
RenameRemoteFileOperation renameOperation = new RenameRemoteFileOperation(oldName, oldRemotePath, newName, isFolder);
|
||||
RemoteOperationResult result = renameOperation.execute(mClient);
|
||||
RemoteOperationResult result = renameOperation.execute(mClient, mUserAgent);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -187,7 +190,7 @@ public class TestActivity extends Activity {
|
||||
*/
|
||||
public RemoteOperationResult removeFile(String remotePath) {
|
||||
RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath);
|
||||
RemoteOperationResult result = removeOperation.execute(mClient);
|
||||
RemoteOperationResult result = removeOperation.execute(mClient, mUserAgent);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -199,7 +202,7 @@ public class TestActivity extends Activity {
|
||||
*/
|
||||
public static RemoteOperationResult removeFile(String remotePath, OwnCloudClient client) {
|
||||
RemoveRemoteFileOperation removeOperation = new RemoveRemoteFileOperation(remotePath);
|
||||
RemoteOperationResult result = removeOperation.execute(client);
|
||||
RemoteOperationResult result = removeOperation.execute(client, mUserAgent);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -213,7 +216,7 @@ public class TestActivity extends Activity {
|
||||
public RemoteOperationResult readFile(String remotePath) {
|
||||
|
||||
ReadRemoteFolderOperation readOperation= new ReadRemoteFolderOperation(remotePath);
|
||||
RemoteOperationResult result = readOperation.execute(mClient);
|
||||
RemoteOperationResult result = readOperation.execute(mClient, mUserAgent);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -232,7 +235,7 @@ public class TestActivity extends Activity {
|
||||
folder.mkdirs();
|
||||
|
||||
DownloadRemoteFileOperation downloadOperation = new DownloadRemoteFileOperation(remoteFile.getRemotePath(), folder.getAbsolutePath());
|
||||
RemoteOperationResult result = downloadOperation.execute(mClient);
|
||||
RemoteOperationResult result = downloadOperation.execute(mClient, mUserAgent);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -273,7 +276,7 @@ public class TestActivity extends Activity {
|
||||
);
|
||||
}
|
||||
|
||||
RemoteOperationResult result = uploadOperation.execute(client);
|
||||
RemoteOperationResult result = uploadOperation.execute(client, mUserAgent);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -284,7 +287,7 @@ public class TestActivity extends Activity {
|
||||
public RemoteOperationResult getShares(){
|
||||
|
||||
GetRemoteSharesOperation getOperation = new GetRemoteSharesOperation();
|
||||
RemoteOperationResult result = getOperation.execute(mClient);
|
||||
RemoteOperationResult result = getOperation.execute(mClient, mUserAgent);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -312,7 +315,7 @@ public class TestActivity extends Activity {
|
||||
String password, int permissions){
|
||||
|
||||
CreateRemoteShareOperation createOperation = new CreateRemoteShareOperation(path, shareType, shareWith, publicUpload, password, permissions);
|
||||
RemoteOperationResult result = createOperation.execute(mClient);
|
||||
RemoteOperationResult result = createOperation.execute(mClient, mUserAgent);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -326,7 +329,7 @@ public class TestActivity extends Activity {
|
||||
|
||||
public RemoteOperationResult removeShare(int idShare) {
|
||||
RemoveRemoteShareOperation removeOperation = new RemoveRemoteShareOperation(idShare);
|
||||
RemoteOperationResult result = removeOperation.execute(mClient);
|
||||
RemoteOperationResult result = removeOperation.execute(mClient, mUserAgent);
|
||||
|
||||
return result;
|
||||
|
||||
|
@ -26,5 +26,6 @@
|
||||
<resources>
|
||||
|
||||
<string name="app_name">Oc_framework-testTest</string>
|
||||
<string name ="user_agent">Android-ownCloud</string>
|
||||
|
||||
</resources>
|
||||
|
@ -279,7 +279,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FILE_1,
|
||||
false
|
||||
);
|
||||
RemoteOperationResult result = moveOperation.execute(mClient);
|
||||
RemoteOperationResult result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move & rename file, different location
|
||||
@ -288,7 +289,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FILE_2_RENAMED,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move & rename file, same location (rename file)
|
||||
@ -297,7 +299,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + SRC_PATH_TO_FILE_3_RENAMED,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move empty folder
|
||||
@ -306,7 +309,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_EMPTY_FOLDER,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move non-empty folder
|
||||
@ -315,7 +319,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FULL_FOLDER_1,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move & rename folder, different location
|
||||
@ -324,7 +329,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FULL_FOLDER_2_RENAMED,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move & rename folder, same location (rename folder)
|
||||
@ -333,7 +339,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_3_RENAMED,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move for nothing (success, but no interaction with network)
|
||||
@ -342,7 +349,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + SRC_PATH_TO_FILE_4,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move overwriting
|
||||
@ -351,7 +359,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4,
|
||||
true
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
|
||||
@ -363,7 +372,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_NON_EXISTENT_FILE,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.getCode() == ResultCode.FILE_NOT_FOUND);
|
||||
|
||||
// folder to move into does no exist
|
||||
@ -372,7 +382,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.getHttpCode() == HttpStatus.SC_CONFLICT);
|
||||
|
||||
// target location (renaming) has invalid characters
|
||||
@ -381,7 +392,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_RENAMED_WITH_INVALID_CHARS,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||
|
||||
// name collision
|
||||
@ -390,7 +402,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.getCode() == ResultCode.INVALID_OVERWRITE);
|
||||
|
||||
// move a folder into a descendant
|
||||
@ -399,7 +412,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + SRC_PATH_TO_EMPTY_FOLDER,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
assertTrue(result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT);
|
||||
|
||||
}
|
||||
@ -436,7 +450,8 @@ public class MoveFileTest extends RemoteTest {
|
||||
|
||||
mClient = new OwnCloudClient(
|
||||
Uri.parse(mServerUri),
|
||||
NetworkUtils.getMultiThreadedConnManager()
|
||||
NetworkUtils.getMultiThreadedConnManager(),
|
||||
getContext().getString(R.string.user_agent)
|
||||
);
|
||||
mClient.setDefaultTimeouts(
|
||||
OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT,
|
||||
|
@ -64,6 +64,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
private Uri mServerUri;
|
||||
private String mUsername;
|
||||
private String mPassword;
|
||||
private String mUserAgent;
|
||||
|
||||
public OwnCloudClientTest() {
|
||||
super();
|
||||
@ -90,12 +91,14 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
mServerUri = Uri.parse(getContext().getString(R.string.server_base_url));
|
||||
mUsername = getContext().getString(R.string.username);
|
||||
mPassword = getContext().getString(R.string.password);
|
||||
mUserAgent = getContext().getString(R.string.user_agent);
|
||||
}
|
||||
|
||||
|
||||
public void testConstructor() {
|
||||
try {
|
||||
new OwnCloudClient(null, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(null, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
throw new AssertionFailedError("Accepted NULL parameter");
|
||||
|
||||
} catch(Exception e) {
|
||||
@ -104,7 +107,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
}
|
||||
|
||||
try {
|
||||
new OwnCloudClient(mServerUri, null);
|
||||
new OwnCloudClient(mServerUri, null, mUserAgent);
|
||||
throw new AssertionFailedError("Accepted NULL parameter");
|
||||
|
||||
} catch(Exception e) {
|
||||
@ -113,17 +116,19 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
}
|
||||
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
assertNotNull("OwnCloudClient instance not built", client);
|
||||
assertEquals("Wrong user agent",
|
||||
client.getParams().getParameter(HttpMethodParams.USER_AGENT),
|
||||
OwnCloudClient.USER_AGENT);
|
||||
mUserAgent);
|
||||
}
|
||||
|
||||
|
||||
public void testGetSetCredentials() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
|
||||
assertNotNull("Returned NULL credentials", client.getCredentials());
|
||||
assertEquals("Not instanced without credentials",
|
||||
@ -146,7 +151,8 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testExecuteMethodWithTimeouts() throws HttpException, IOException {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
int connectionTimeout = client.getConnectionTimeout();
|
||||
int readTimeout = client.getDataTimeout();
|
||||
|
||||
@ -194,7 +200,8 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testExecuteMethod() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
HeadMethod head = new HeadMethod(client.getWebdavUri() + "/");
|
||||
int status = -1;
|
||||
try {
|
||||
@ -215,7 +222,8 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testExhaustResponse() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
|
||||
PropFindMethod propfind = null;
|
||||
try {
|
||||
@ -257,7 +265,8 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testGetSetDefaultTimeouts() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
|
||||
int oldDataTimeout = client.getDataTimeout();
|
||||
int oldConnectionTimeout = client.getConnectionTimeout();
|
||||
@ -297,7 +306,8 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testGetWebdavUri() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
client.setCredentials(OwnCloudCredentialsFactory.newBearerCredentials("fakeToken"));
|
||||
Uri webdavUri = client.getWebdavUri();
|
||||
assertTrue("WebDAV URI does not point to the right entry point for OAuth2 " +
|
||||
@ -335,7 +345,8 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testGetSetBaseUri() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
assertEquals("Returned base URI different that URI passed to constructor",
|
||||
mServerUri, client.getBaseUri());
|
||||
|
||||
|
@ -95,13 +95,16 @@ public class SimpleFactoryManagerTest extends AndroidTestCase {
|
||||
|
||||
public void testGetClientFor() {
|
||||
try {
|
||||
OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext());
|
||||
OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
|
||||
assertNotSame("Got same client instances for same account",
|
||||
client, mSFMgr.getClientFor(mValidAccount, getContext()));
|
||||
client, mSFMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
|
||||
assertNotSame("Got same client instances for different accounts",
|
||||
client, mSFMgr.getClientFor(mAnonymousAccount, getContext()));
|
||||
client, mSFMgr.getClientFor(mAnonymousAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
|
||||
@ -111,10 +114,12 @@ public class SimpleFactoryManagerTest extends AndroidTestCase {
|
||||
|
||||
public void testRemoveClientFor() {
|
||||
try {
|
||||
OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext());
|
||||
OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
mSFMgr.removeClientFor(mValidAccount);
|
||||
assertNotSame("Got same client instance after removing it from manager",
|
||||
client, mSFMgr.getClientFor(mValidAccount, getContext()));
|
||||
client, mSFMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
|
||||
|
@ -94,13 +94,16 @@ public class SingleSessionManagerTest extends AndroidTestCase {
|
||||
|
||||
public void testGetClientFor() {
|
||||
try {
|
||||
OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext());
|
||||
OwnCloudClient client2 = mSSMgr.getClientFor(mAnonymousAccount, getContext());
|
||||
OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
OwnCloudClient client2 = mSSMgr.getClientFor(mAnonymousAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
|
||||
assertNotSame("Got same client instances for different accounts",
|
||||
client1, client2);
|
||||
assertSame("Got different client instances for same account",
|
||||
client1, mSSMgr.getClientFor(mValidAccount, getContext()));
|
||||
client1, mSSMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
|
||||
@ -111,10 +114,12 @@ public class SingleSessionManagerTest extends AndroidTestCase {
|
||||
|
||||
public void testRemoveClientFor() {
|
||||
try {
|
||||
OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext());
|
||||
OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
mSSMgr.removeClientFor(mValidAccount);
|
||||
assertNotSame("Got same client instance after removing it from manager",
|
||||
client1, mSSMgr.getClientFor(mValidAccount, getContext()));
|
||||
client1, mSSMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
} catch (Exception e) {
|
||||
throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user