Improve tests

pull/2/head
Ricki Hirner 8 years ago
parent 2c5b93ce43
commit 593d907e3a

@ -7,33 +7,34 @@
*/
package at.bitfire.davdroid;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.assertTrue;
public class ArrayUtilsTest {
@Test
public void testPartition() {
// n == 0
Assert.assertTrue(Arrays.deepEquals(
assertTrue(Arrays.deepEquals(
new Long[0][0],
ArrayUtils.partition(new Long[] {}, 5)));
// n < max
Assert.assertTrue(Arrays.deepEquals(
assertTrue(Arrays.deepEquals(
new Long[][] { { 1l, 2l } },
ArrayUtils.partition(new Long[] { 1l, 2l }, 5)));
// n == max
Assert.assertTrue(Arrays.deepEquals(
assertTrue(Arrays.deepEquals(
new Long[][] { { 1l, 2l }, { 3l, 4l } },
ArrayUtils.partition(new Long[] { 1l, 2l, 3l, 4l }, 2)));
// n > max
Assert.assertTrue(Arrays.deepEquals(
assertTrue(Arrays.deepEquals(
new Long[][] { { 1l, 2l, 3l, 4l, 5l }, { 6l, 7l, 8l, 9l, 10l }, { 11l } },
ArrayUtils.partition(new Long[] { 1l, 2l, 3l, 4l, 5l, 6l, 7l, 8l, 9l, 10l, 11l }, 5)));
}

@ -8,7 +8,9 @@
package at.bitfire.davdroid;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
@ -19,12 +21,15 @@ import okhttp3.Request;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
public class HttpClientTest extends TestCase {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
public class HttpClientTest {
MockWebServer server;
OkHttpClient httpClient;
@Override
@Before
public void setUp() throws IOException {
httpClient = HttpClient.create(null);
@ -32,11 +37,13 @@ public class HttpClientTest extends TestCase {
server.start(30000);
}
@Override
@After
public void tearDown() throws IOException {
server.shutdown();
}
@Test
public void testCookies() throws IOException, InterruptedException, URISyntaxException {
HttpUrl url = server.url("/test");

@ -8,19 +8,20 @@
package at.bitfire.davdroid;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TestDavUtils {
private static final String exampleURL = "http://example.com/";
@Test
public void testLastSegmentOfUrl() {
Assert.assertEquals("/", DavUtils.lastSegmentOfUrl(exampleURL));
Assert.assertEquals("dir", DavUtils.lastSegmentOfUrl(exampleURL + "dir"));
Assert.assertEquals("dir", DavUtils.lastSegmentOfUrl(exampleURL + "dir/"));
Assert.assertEquals("file.html", DavUtils.lastSegmentOfUrl(exampleURL + "dir/file.html"));
assertEquals("/", DavUtils.lastSegmentOfUrl(exampleURL));
assertEquals("dir", DavUtils.lastSegmentOfUrl(exampleURL + "dir"));
assertEquals("dir", DavUtils.lastSegmentOfUrl(exampleURL + "dir/"));
assertEquals("file.html", DavUtils.lastSegmentOfUrl(exampleURL + "dir/file.html"));
}
}

@ -1 +1 @@
Subproject commit d5fae5d695edbaba9da230679a8313e238f34bf4
Subproject commit 489056f740ba8d7ccddaa99d29162e11651116bb

@ -1 +1 @@
Subproject commit 05065af8ef4a73f831b51bc7766af885cc4735d3
Subproject commit 4e550cdcda7c2b3c969d20f1a99770deafafd6e8

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip

@ -1,2 +0,0 @@
#!/bin/bash
./gradlew -i check mergeAndroidReports --continue

@ -0,0 +1,18 @@
#!/bin/sh
./gradlew -i --continue check mergeAndroidReports
echo
echo View lint report:
echo -n file://
realpath app/build/outputs/lint-results-gplayDebug.html
echo
echo View local unit test reports:
echo -n file://
realpath app/build/reports/tests/testStandardReleaseUnitTest/standardRelease/index.html
echo
echo "View merged Android test reports (debug):"
echo -n file://
realpath build/reports/androidTests/index.html

@ -1 +1 @@
Subproject commit 95a2761006f1c605ee277fa36b0d1aaa083c86bc
Subproject commit 788eedf46672b6266fabe65e42cf07e0396627bf
Loading…
Cancel
Save