mirror of
https://github.com/etesync/android
synced 2025-02-16 17:42:03 +00:00
Adapted tests
This commit is contained in:
parent
e2f154c963
commit
a02b8a1b1e
@ -11,6 +11,14 @@
|
|||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
# Add any project specific keep options here:
|
||||||
|
-dontusemixedcaseclassnames
|
||||||
|
-dontskipnonpubliclibraryclassmembers
|
||||||
|
|
||||||
|
-dontwarn edu.emory.mathcs.backport.**
|
||||||
|
-dontwarn ezvcard.**
|
||||||
|
-dontwarn net.fortuna.**
|
||||||
|
-dontwarn org.apache.**
|
||||||
|
-dontwarn org.simpleframework.xml.**
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
# If your project uses WebView with JS, uncomment the following
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
@ -10,17 +10,19 @@ import java.util.List;
|
|||||||
import lombok.Cleanup;
|
import lombok.Cleanup;
|
||||||
|
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.http.HttpException;
|
|
||||||
|
|
||||||
import android.content.res.AssetManager;
|
import android.content.res.AssetManager;
|
||||||
import android.test.InstrumentationTestCase;
|
import android.test.InstrumentationTestCase;
|
||||||
import at.bitfire.davdroid.webdav.DavException;
|
import at.bitfire.davdroid.webdav.DavException;
|
||||||
|
import at.bitfire.davdroid.webdav.DavHttpClient;
|
||||||
import at.bitfire.davdroid.webdav.DavMultiget;
|
import at.bitfire.davdroid.webdav.DavMultiget;
|
||||||
|
import at.bitfire.davdroid.webdav.HttpException;
|
||||||
import at.bitfire.davdroid.webdav.HttpPropfind;
|
import at.bitfire.davdroid.webdav.HttpPropfind;
|
||||||
import at.bitfire.davdroid.webdav.NotFoundException;
|
import at.bitfire.davdroid.webdav.NotFoundException;
|
||||||
import at.bitfire.davdroid.webdav.PreconditionFailedException;
|
import at.bitfire.davdroid.webdav.PreconditionFailedException;
|
||||||
import at.bitfire.davdroid.webdav.WebDavResource;
|
import at.bitfire.davdroid.webdav.WebDavResource;
|
||||||
import at.bitfire.davdroid.webdav.WebDavResource.PutMode;
|
import at.bitfire.davdroid.webdav.WebDavResource.PutMode;
|
||||||
|
import ch.boye.httpclientandroidlib.impl.client.CloseableHttpClient;
|
||||||
|
|
||||||
// tests require running robohydra!
|
// tests require running robohydra!
|
||||||
|
|
||||||
@ -29,26 +31,35 @@ public class WebDavResourceTest extends InstrumentationTestCase {
|
|||||||
static byte[] SAMPLE_CONTENT = new byte[] { 1, 2, 3, 4, 5 };
|
static byte[] SAMPLE_CONTENT = new byte[] { 1, 2, 3, 4, 5 };
|
||||||
|
|
||||||
AssetManager assetMgr;
|
AssetManager assetMgr;
|
||||||
|
CloseableHttpClient httpClient;
|
||||||
|
|
||||||
WebDavResource simpleFile,
|
WebDavResource simpleFile,
|
||||||
davCollection, davNonExistingFile, davExistingFile,
|
davCollection, davNonExistingFile, davExistingFile,
|
||||||
davInvalid;
|
davInvalid;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception {
|
protected void setUp() throws Exception {
|
||||||
|
httpClient = DavHttpClient.create();
|
||||||
|
|
||||||
assetMgr = getInstrumentation().getContext().getResources().getAssets();
|
assetMgr = getInstrumentation().getContext().getResources().getAssets();
|
||||||
|
|
||||||
simpleFile = new WebDavResource(new URI(ROBOHYDRA_BASE + "assets/test.random"), false);
|
simpleFile = new WebDavResource(httpClient, new URI(ROBOHYDRA_BASE + "assets/test.random"), false);
|
||||||
|
|
||||||
davCollection = new WebDavResource(new URI(ROBOHYDRA_BASE + "dav"), true);
|
davCollection = new WebDavResource(httpClient, new URI(ROBOHYDRA_BASE + "dav"), true);
|
||||||
davNonExistingFile = new WebDavResource(davCollection, "collection/new.file");
|
davNonExistingFile = new WebDavResource(davCollection, "collection/new.file");
|
||||||
davExistingFile = new WebDavResource(davCollection, "collection/existing.file");
|
davExistingFile = new WebDavResource(davCollection, "collection/existing.file");
|
||||||
|
|
||||||
davInvalid = new WebDavResource(new URI(ROBOHYDRA_BASE + "dav-invalid"), true);
|
davInvalid = new WebDavResource(httpClient, new URI(ROBOHYDRA_BASE + "dav-invalid"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void tearDown() throws Exception {
|
||||||
|
httpClient.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* test resource name handling */
|
/* test resource name handling */
|
||||||
|
|
||||||
public void testGetName() {
|
public void testGetName() {
|
||||||
// collection names should have a trailing slash
|
// collection names should have a trailing slash
|
||||||
assertEquals("dav", davCollection.getName());
|
assertEquals("dav", davCollection.getName());
|
||||||
@ -85,7 +96,7 @@ public class WebDavResourceTest extends InstrumentationTestCase {
|
|||||||
assert(davCollection.supportsDAV(capability));
|
assert(davCollection.supportsDAV(capability));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPropfindCurrentUserPrincipal() throws IOException, HttpException {
|
public void testPropfindCurrentUserPrincipal() throws IOException, HttpException, DavException {
|
||||||
davCollection.propfind(HttpPropfind.Mode.CURRENT_USER_PRINCIPAL);
|
davCollection.propfind(HttpPropfind.Mode.CURRENT_USER_PRINCIPAL);
|
||||||
assertEquals("/dav/principals/users/test", davCollection.getCurrentUserPrincipal());
|
assertEquals("/dav/principals/users/test", davCollection.getCurrentUserPrincipal());
|
||||||
|
|
||||||
@ -97,14 +108,14 @@ public class WebDavResourceTest extends InstrumentationTestCase {
|
|||||||
assertNull(simpleFile.getCurrentUserPrincipal());
|
assertNull(simpleFile.getCurrentUserPrincipal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPropfindHomeSets() throws IOException, HttpException {
|
public void testPropfindHomeSets() throws IOException, HttpException, DavException {
|
||||||
WebDavResource dav = new WebDavResource(davCollection, "principals/users/test");
|
WebDavResource dav = new WebDavResource(davCollection, "principals/users/test");
|
||||||
dav.propfind(HttpPropfind.Mode.HOME_SETS);
|
dav.propfind(HttpPropfind.Mode.HOME_SETS);
|
||||||
assertEquals("/dav/addressbooks/test", dav.getAddressbookHomeSet());
|
assertEquals("/dav/addressbooks/test", dav.getAddressbookHomeSet());
|
||||||
assertEquals("/dav/calendars/test/", dav.getCalendarHomeSet());
|
assertEquals("/dav/calendars/test/", dav.getCalendarHomeSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPropfindAddressBooks() throws IOException, HttpException {
|
public void testPropfindAddressBooks() throws IOException, HttpException, DavException {
|
||||||
WebDavResource dav = new WebDavResource(davCollection, "addressbooks/test", true);
|
WebDavResource dav = new WebDavResource(davCollection, "addressbooks/test", true);
|
||||||
dav.propfind(HttpPropfind.Mode.MEMBERS_COLLECTIONS);
|
dav.propfind(HttpPropfind.Mode.MEMBERS_COLLECTIONS);
|
||||||
assertEquals(2, dav.getMembers().size());
|
assertEquals(2, dav.getMembers().size());
|
||||||
@ -117,7 +128,7 @@ public class WebDavResourceTest extends InstrumentationTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPropfindCalendars() throws IOException, HttpException {
|
public void testPropfindCalendars() throws IOException, HttpException, DavException {
|
||||||
WebDavResource dav = new WebDavResource(davCollection, "calendars/test", true);
|
WebDavResource dav = new WebDavResource(davCollection, "calendars/test", true);
|
||||||
dav.propfind(HttpPropfind.Mode.MEMBERS_COLLECTIONS);
|
dav.propfind(HttpPropfind.Mode.MEMBERS_COLLECTIONS);
|
||||||
assertEquals(3, dav.getMembers().size());
|
assertEquals(3, dav.getMembers().size());
|
||||||
@ -134,16 +145,12 @@ public class WebDavResourceTest extends InstrumentationTestCase {
|
|||||||
|
|
||||||
/* test normal HTTP/WebDAV */
|
/* test normal HTTP/WebDAV */
|
||||||
|
|
||||||
public void testDontFollowRedirections() throws URISyntaxException, IOException {
|
public void testFollowGetRedirections() throws URISyntaxException, IOException, DavException, HttpException {
|
||||||
WebDavResource redirection = new WebDavResource(new URI(ROBOHYDRA_BASE + "redirect"), false);
|
WebDavResource redirection = new WebDavResource(httpClient, new URI(ROBOHYDRA_BASE + "redirect"), false);
|
||||||
try {
|
redirection.get();
|
||||||
redirection.get();
|
|
||||||
fail();
|
|
||||||
} catch (HttpException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGet() throws URISyntaxException, IOException, HttpException {
|
public void testGet() throws URISyntaxException, IOException, HttpException, DavException {
|
||||||
simpleFile.get();
|
simpleFile.get();
|
||||||
@Cleanup InputStream is = assetMgr.open("test.random", AssetManager.ACCESS_STREAMING);
|
@Cleanup InputStream is = assetMgr.open("test.random", AssetManager.ACCESS_STREAMING);
|
||||||
byte[] expected = IOUtils.toByteArray(is);
|
byte[] expected = IOUtils.toByteArray(is);
|
||||||
@ -201,7 +208,7 @@ public class WebDavResourceTest extends InstrumentationTestCase {
|
|||||||
|
|
||||||
/* special test */
|
/* special test */
|
||||||
|
|
||||||
public void testInvalidURLs() throws IOException, HttpException {
|
public void testInvalidURLs() throws IOException, HttpException, DavException {
|
||||||
WebDavResource dav = new WebDavResource(davInvalid, "addressbooks/user%40domain/");
|
WebDavResource dav = new WebDavResource(davInvalid, "addressbooks/user%40domain/");
|
||||||
dav.propfind(HttpPropfind.Mode.MEMBERS_COLLECTIONS);
|
dav.propfind(HttpPropfind.Mode.MEMBERS_COLLECTIONS);
|
||||||
List<WebDavResource> members = dav.getMembers();
|
List<WebDavResource> members = dav.getMembers();
|
||||||
|
Loading…
Reference in New Issue
Block a user