1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-08 00:16:09 +00:00

Added test to unit tests for OwnCloudClient

This commit is contained in:
David A. Velasco 2014-06-25 17:03:16 +02:00
parent a57be36925
commit 4c8f31df2f
3 changed files with 25 additions and 18 deletions

View File

@ -284,6 +284,9 @@ public class OwnCloudClient extends HttpClient {
* @param uri * @param uri
*/ */
public void setBaseUri(Uri uri) { public void setBaseUri(Uri uri) {
if (uri == null) {
throw new IllegalArgumentException("URI cannot be NULL");
}
mBaseUri = uri; mBaseUri = uri;
} }

View File

@ -281,7 +281,6 @@ public abstract class RemoteOperation implements Runnable {
/** DEPRECATED BLOCK - will be removed at version 1.0 ; don't trust in this code /** DEPRECATED BLOCK - will be removed at version 1.0 ; don't trust in this code
* to trigger authentication update */ * to trigger authentication update */
if (mCallerActivity != null && mAccount != null && mContext != null && !result.isSuccess() && if (mCallerActivity != null && mAccount != null && mContext != null && !result.isSuccess() &&
// (result.getCode() == ResultCode.UNAUTHORIZED || (result.isTemporalRedirection() && result.isIdPRedirection()))) {
(result.getCode() == ResultCode.UNAUTHORIZED || result.isIdPRedirection())) { (result.getCode() == ResultCode.UNAUTHORIZED || result.isIdPRedirection())) {
/// possible fail due to lack of authorization in an operation performed in foreground /// possible fail due to lack of authorization in an operation performed in foreground
OwnCloudCredentials cred = mClient.getCredentials(); OwnCloudCredentials cred = mClient.getCredentials();

View File

@ -303,6 +303,9 @@ public class OwnCloudClientTest extends AndroidTestCase {
assertTrue("WebDAV URI does not point to the right entry point for OAuth2 " + assertTrue("WebDAV URI does not point to the right entry point for OAuth2 " +
"authenticated servers", "authenticated servers",
webdavUri.getPath().endsWith(AccountUtils.ODAV_PATH)); webdavUri.getPath().endsWith(AccountUtils.ODAV_PATH));
assertTrue("WebDAV URI is not a subpath of base URI",
webdavUri.getAuthority().equals(mServerUri.getAuthority()) &&
webdavUri.getPath().startsWith(mServerUri.getPath()));
client.setCredentials(OwnCloudCredentialsFactory.newBasicCredentials( client.setCredentials(OwnCloudCredentialsFactory.newBasicCredentials(
mUsername, mPassword)); mUsername, mPassword));
@ -331,21 +334,24 @@ public class OwnCloudClientTest extends AndroidTestCase {
public void testGetSetBaseUri() { public void testGetSetBaseUri() {
// TODO implement test body OwnCloudClient client =
/** new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
* Sets the root URI to the ownCloud server. assertEquals("Returned base URI different that URI passed to constructor",
* mServerUri, client.getBaseUri());
* Use with care.
* Uri otherUri = Uri.parse("https://whatever.com/basePath/here");
* @param uri client.setBaseUri(otherUri);
*-/ assertEquals("Returned base URI different that URI passed to constructor",
public void setBaseUri(Uri uri) { otherUri, client.getBaseUri());
mBaseUri = uri;
try {
client.setBaseUri(null);
throw new AssertionFailedError("Accepted NULL parameter");
} catch(Exception e) {
assertTrue("Unexpected exception passing NULL base URI",
(e instanceof IllegalArgumentException));
} }
public Uri getBaseUri() {
return mBaseUri;
}
*/
} }
@ -368,8 +374,7 @@ public class OwnCloudClientTest extends AndroidTestCase {
public void testSetFollowRedirects() { public void testSetFollowRedirects() {
// TODO implement test body // TODO - to implement this test we need a redirected server
// to implement this we need a redirected server
} }