mirror of
https://github.com/owncloud/android-library.git
synced 2026-08-11 16:33:03 +00:00
Refactor parameter user_agent out of RemoteOperation and children
This commit is contained in:
+15
-30
@@ -279,8 +279,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FILE_1,
|
||||
false
|
||||
);
|
||||
RemoteOperationResult result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
RemoteOperationResult result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move & rename file, different location
|
||||
@@ -289,8 +288,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FILE_2_RENAMED,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move & rename file, same location (rename file)
|
||||
@@ -299,8 +297,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + SRC_PATH_TO_FILE_3_RENAMED,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move empty folder
|
||||
@@ -309,8 +306,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_EMPTY_FOLDER,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move non-empty folder
|
||||
@@ -319,8 +315,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FULL_FOLDER_1,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move & rename folder, different location
|
||||
@@ -329,8 +324,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FULL_FOLDER_2_RENAMED,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move & rename folder, same location (rename folder)
|
||||
@@ -339,8 +333,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + SRC_PATH_TO_FULL_FOLDER_3_RENAMED,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move for nothing (success, but no interaction with network)
|
||||
@@ -349,8 +342,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + SRC_PATH_TO_FILE_4,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
// move overwriting
|
||||
@@ -359,8 +351,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_ALREADY_EXISTENT_EMPTY_FOLDER_4,
|
||||
true
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.isSuccess());
|
||||
|
||||
|
||||
@@ -372,8 +363,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_NON_EXISTENT_FILE,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.getCode() == ResultCode.FILE_NOT_FOUND);
|
||||
|
||||
// folder to move into does no exist
|
||||
@@ -382,8 +372,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_FILE_5_INTO_NON_EXISTENT_FOLDER,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.getHttpCode() == HttpStatus.SC_CONFLICT);
|
||||
|
||||
// target location (renaming) has invalid characters
|
||||
@@ -392,8 +381,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_RENAMED_WITH_INVALID_CHARS,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
|
||||
|
||||
// name collision
|
||||
@@ -402,8 +390,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + TARGET_PATH_TO_ALREADY_EXISTENT_FILE_7,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.getCode() == ResultCode.INVALID_OVERWRITE);
|
||||
|
||||
// move a folder into a descendant
|
||||
@@ -412,8 +399,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
mBaseFolderPath + SRC_PATH_TO_EMPTY_FOLDER,
|
||||
false
|
||||
);
|
||||
result = moveOperation.execute(mClient,
|
||||
getContext().getString(R.string.user_agent));
|
||||
result = moveOperation.execute(mClient);
|
||||
assertTrue(result.getCode() == ResultCode.INVALID_MOVE_INTO_DESCENDANT);
|
||||
|
||||
}
|
||||
@@ -450,8 +436,7 @@ public class MoveFileTest extends RemoteTest {
|
||||
|
||||
mClient = new OwnCloudClient(
|
||||
Uri.parse(mServerUri),
|
||||
NetworkUtils.getMultiThreadedConnManager(),
|
||||
getContext().getString(R.string.user_agent)
|
||||
NetworkUtils.getMultiThreadedConnManager()
|
||||
);
|
||||
mClient.setDefaultTimeouts(
|
||||
OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT,
|
||||
|
||||
+10
-19
@@ -97,8 +97,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testConstructor() {
|
||||
try {
|
||||
new OwnCloudClient(null, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(null, NetworkUtils.getMultiThreadedConnManager());
|
||||
throw new AssertionFailedError("Accepted NULL parameter");
|
||||
|
||||
} catch(Exception e) {
|
||||
@@ -107,7 +106,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
}
|
||||
|
||||
try {
|
||||
new OwnCloudClient(mServerUri, null, mUserAgent);
|
||||
new OwnCloudClient(mServerUri, null);
|
||||
throw new AssertionFailedError("Accepted NULL parameter");
|
||||
|
||||
} catch(Exception e) {
|
||||
@@ -116,8 +115,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
}
|
||||
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
assertNotNull("OwnCloudClient instance not built", client);
|
||||
assertEquals("Wrong user agent",
|
||||
client.getParams().getParameter(HttpMethodParams.USER_AGENT),
|
||||
@@ -127,8 +125,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testGetSetCredentials() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
|
||||
assertNotNull("Returned NULL credentials", client.getCredentials());
|
||||
assertEquals("Not instanced without credentials",
|
||||
@@ -151,8 +148,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testExecuteMethodWithTimeouts() throws HttpException, IOException {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
int connectionTimeout = client.getConnectionTimeout();
|
||||
int readTimeout = client.getDataTimeout();
|
||||
|
||||
@@ -200,8 +196,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testExecuteMethod() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
HeadMethod head = new HeadMethod(client.getWebdavUri() + "/");
|
||||
int status = -1;
|
||||
try {
|
||||
@@ -222,8 +217,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testExhaustResponse() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
|
||||
PropFindMethod propfind = null;
|
||||
try {
|
||||
@@ -265,8 +259,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testGetSetDefaultTimeouts() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
|
||||
int oldDataTimeout = client.getDataTimeout();
|
||||
int oldConnectionTimeout = client.getConnectionTimeout();
|
||||
@@ -306,8 +299,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testGetWebdavUri() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
client.setCredentials(OwnCloudCredentialsFactory.newBearerCredentials("fakeToken"));
|
||||
Uri webdavUri = client.getWebdavUri();
|
||||
assertTrue("WebDAV URI does not point to the right entry point for OAuth2 " +
|
||||
@@ -345,8 +337,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
|
||||
|
||||
public void testGetSetBaseUri() {
|
||||
OwnCloudClient client =
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager(),
|
||||
mUserAgent);
|
||||
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
|
||||
assertEquals("Returned base URI different that URI passed to constructor",
|
||||
mServerUri, client.getBaseUri());
|
||||
|
||||
|
||||
+5
-10
@@ -95,16 +95,13 @@ public class SimpleFactoryManagerTest extends AndroidTestCase {
|
||||
|
||||
public void testGetClientFor() {
|
||||
try {
|
||||
OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext());
|
||||
|
||||
assertNotSame("Got same client instances for same account",
|
||||
client, mSFMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
client, mSFMgr.getClientFor(mValidAccount, getContext()));
|
||||
|
||||
assertNotSame("Got same client instances for different accounts",
|
||||
client, mSFMgr.getClientFor(mAnonymousAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
client, mSFMgr.getClientFor(mAnonymousAccount, getContext()));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
|
||||
@@ -114,12 +111,10 @@ public class SimpleFactoryManagerTest extends AndroidTestCase {
|
||||
|
||||
public void testRemoveClientFor() {
|
||||
try {
|
||||
OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
OwnCloudClient client = mSFMgr.getClientFor(mValidAccount, getContext());
|
||||
mSFMgr.removeClientFor(mValidAccount);
|
||||
assertNotSame("Got same client instance after removing it from manager",
|
||||
client, mSFMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
client, mSFMgr.getClientFor(mValidAccount, getContext()));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
|
||||
|
||||
+5
-10
@@ -94,16 +94,13 @@ public class SingleSessionManagerTest extends AndroidTestCase {
|
||||
|
||||
public void testGetClientFor() {
|
||||
try {
|
||||
OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
OwnCloudClient client2 = mSSMgr.getClientFor(mAnonymousAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext());
|
||||
OwnCloudClient client2 = mSSMgr.getClientFor(mAnonymousAccount, getContext());
|
||||
|
||||
assertNotSame("Got same client instances for different accounts",
|
||||
client1, client2);
|
||||
assertSame("Got different client instances for same account",
|
||||
client1, mSSMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
client1, mSSMgr.getClientFor(mValidAccount, getContext()));
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
|
||||
@@ -114,12 +111,10 @@ public class SingleSessionManagerTest extends AndroidTestCase {
|
||||
|
||||
public void testRemoveClientFor() {
|
||||
try {
|
||||
OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent));
|
||||
OwnCloudClient client1 = mSSMgr.getClientFor(mValidAccount, getContext());
|
||||
mSSMgr.removeClientFor(mValidAccount);
|
||||
assertNotSame("Got same client instance after removing it from manager",
|
||||
client1, mSSMgr.getClientFor(mValidAccount, getContext(),
|
||||
getContext().getString(R.string.user_agent)));
|
||||
client1, mSSMgr.getClientFor(mValidAccount, getContext()));
|
||||
} catch (Exception e) {
|
||||
throw new AssertionFailedError("Exception getting client for account: " + e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user