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:
parent
a57be36925
commit
4c8f31df2f
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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();
|
||||||
|
@ -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 {
|
||||||
public Uri getBaseUri() {
|
client.setBaseUri(null);
|
||||||
return mBaseUri;
|
throw new AssertionFailedError("Accepted NULL parameter");
|
||||||
}
|
|
||||||
*/
|
} catch(Exception e) {
|
||||||
|
assertTrue("Unexpected exception passing NULL base URI",
|
||||||
|
(e instanceof IllegalArgumentException));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user