From 2d3dfbe60bf09dc94a0db66d85bcb22a2e08b170 Mon Sep 17 00:00:00 2001 From: Marinolino <45514278+Marinolino@users.noreply.github.com> Date: Sun, 22 Mar 2020 14:32:27 +0100 Subject: [PATCH 01/16] Increased Branch Coverage --- build.gradle | 2 ++ ...RetrieveAvailableFormsFailedEventTest.java | 21 ++++++++++++ .../model/ServerConnectionInfoTest.java | 34 +++++++++++++++++++ .../reused/http/CommonsHttpTest.java | 9 +++++ 4 files changed, 66 insertions(+) create mode 100644 test/java/org/opendatakit/briefcase/model/RetrieveAvailableFormsFailedEventTest.java create mode 100644 test/java/org/opendatakit/briefcase/model/ServerConnectionInfoTest.java diff --git a/build.gradle b/build.gradle index 728582817..ef00fe800 100755 --- a/build.gradle +++ b/build.gradle @@ -79,6 +79,8 @@ dependencies { jacocoTestReport { reports { xml.enabled = true + csv.enabled = true + csv.destination file("${buildDir}/jacocoCSV") } } diff --git a/test/java/org/opendatakit/briefcase/model/RetrieveAvailableFormsFailedEventTest.java b/test/java/org/opendatakit/briefcase/model/RetrieveAvailableFormsFailedEventTest.java new file mode 100644 index 000000000..0b7158dd3 --- /dev/null +++ b/test/java/org/opendatakit/briefcase/model/RetrieveAvailableFormsFailedEventTest.java @@ -0,0 +1,21 @@ +package org.opendatakit.briefcase.model; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class RetrieveAvailableFormsFailedEventTest { + + @Test + public void getReason_unknown() { + RetrieveAvailableFormsFailedEvent testEvent = new RetrieveAvailableFormsFailedEvent(null); + assertEquals("unknown", testEvent.getReason()); + } + + @Test + public void getReason_exception() { + Exception e = new Exception("fail"); + RetrieveAvailableFormsFailedEvent testEvent = new RetrieveAvailableFormsFailedEvent(e); + assertEquals("Exception: fail", testEvent.getReason()); + } +} \ No newline at end of file diff --git a/test/java/org/opendatakit/briefcase/model/ServerConnectionInfoTest.java b/test/java/org/opendatakit/briefcase/model/ServerConnectionInfoTest.java new file mode 100644 index 000000000..162161491 --- /dev/null +++ b/test/java/org/opendatakit/briefcase/model/ServerConnectionInfoTest.java @@ -0,0 +1,34 @@ +package org.opendatakit.briefcase.model; + +import org.junit.Test; + +import static org.junit.Assert.*; + +public class ServerConnectionInfoTest { + + @Test + public void testEquals_False() { + char[] testPassword = {'a'}; + ServerConnectionInfo testInfo = new ServerConnectionInfo("testURL", "testName", testPassword); + Object o = new Object(); + + assertFalse(testInfo.equals(o)); + } + + @Test + public void testEquals_True() { + char[] testPassword = {'a'}; + ServerConnectionInfo testInfo = new ServerConnectionInfo("testURL", "testName", testPassword); + ServerConnectionInfo testInfo2 = new ServerConnectionInfo("testURL", "testName", testPassword); + + assertTrue(testInfo.equals(testInfo2)); + } + + @Test + public void testEquals_True_Itself() { + char[] testPassword = {'a'}; + ServerConnectionInfo testInfo = new ServerConnectionInfo("testURL", "testName", testPassword); + assertTrue(testInfo.equals(testInfo)); + } + +} \ No newline at end of file diff --git a/test/java/org/opendatakit/briefcase/reused/http/CommonsHttpTest.java b/test/java/org/opendatakit/briefcase/reused/http/CommonsHttpTest.java index c9aba299b..765f9df73 100644 --- a/test/java/org/opendatakit/briefcase/reused/http/CommonsHttpTest.java +++ b/test/java/org/opendatakit/briefcase/reused/http/CommonsHttpTest.java @@ -33,6 +33,7 @@ import static com.github.dreamhead.moco.Runner.running; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import static org.opendatakit.briefcase.matchers.ExceptionMatchers.throwsException; import static org.opendatakit.briefcase.reused.http.Http.MAX_HTTP_CONNECTIONS; @@ -156,4 +157,12 @@ public void can_handle_3xx_errors() throws Exception { assertThat(response.isSuccess(), is(false)); }); } + + @Test + public void the_factories_accept_max_http_connections_with_Proxy(){ + assertEquals(CommonsHttp.class, CommonsHttp.of(MAX_HTTP_CONNECTIONS, null).getClass()); + } + + + } From 17c1c107bad32aafea65a6bca72af958e3814c32 Mon Sep 17 00:00:00 2001 From: Hugo Roussaffa Date: Sat, 14 Mar 2020 01:31:42 +1100 Subject: [PATCH 02/16] Fix for issue #854 (#855) On pushToAggregate request header "X-OpenRosa-Version -> 1.0" is set twice and give a java Error under aggregate cause it parsing it as double "1.0, 1,0" --- src/org/opendatakit/briefcase/reused/http/CommonsHttp.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java b/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java index b63b62b56..d510765df 100644 --- a/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java +++ b/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java @@ -113,7 +113,9 @@ private Response uncheckedExecute(Request request, Executor executor) // Add the declared headers // TODO v2.0 remove this header, since this is not a concern of this class - commonsRequest.addHeader("X-OpenRosa-Version", "1.0"); + if(!request.headers.containsKey("X-OpenRosa-Version")){ + commonsRequest.addHeader("X-OpenRosa-Version", "1.0"); + } request.headers.forEach(commonsRequest::addHeader); // Set the request's body if it's a POST request From 223de3712d6f50c12ba53fc8264647a898aa093c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Guti=C3=A9rrez?= Date: Fri, 13 Mar 2020 15:32:30 +0100 Subject: [PATCH 03/16] Make HTTP post requests repeatable by wrapping entities into a repeatable entity (#856) --- .../briefcase/reused/http/CommonsHttp.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java b/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java index d510765df..02f91af38 100644 --- a/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java +++ b/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java @@ -21,6 +21,7 @@ import static org.opendatakit.briefcase.reused.http.RequestMethod.POST; import java.io.IOException; +import java.io.InputStream; import java.io.UncheckedIOException; import java.net.SocketTimeoutException; import java.net.URL; @@ -30,6 +31,7 @@ import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.HttpHostConnectException; import org.apache.http.entity.BasicHttpEntity; +import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.InputStreamBody; @@ -128,10 +130,9 @@ private Response uncheckedExecute(Request request, Executor executor) part.getName(), new InputStreamBody(part.getBody(), ContentType.create(part.getContentType()), part.getAttachmentName()) ); - body = bodyBuilder.build(); + body = makeRepeatable(bodyBuilder.build()); } else { - body = new BasicHttpEntity(); - ((BasicHttpEntity) body).setContent(request.getBody()); + body = makeRepeatable(buildBasicEntity(request.getBody())); } commonsRequest.body(body); } @@ -149,6 +150,20 @@ private Response uncheckedExecute(Request request, Executor executor) } } + private BasicHttpEntity buildBasicEntity(InputStream contents) { + BasicHttpEntity entity = new BasicHttpEntity(); + entity.setContent(contents); + return entity; + } + + private BufferedHttpEntity makeRepeatable(HttpEntity entity) { + try { + return new BufferedHttpEntity(entity); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + private static org.apache.http.client.fluent.Request getCommonsRequest(Request request) { switch (request.getMethod()) { case GET: From 818ce9256837256638ed00cb6291aeee851fe635 Mon Sep 17 00:00:00 2001 From: Elliott Wallace Date: Sun, 22 Mar 2020 16:58:25 +0100 Subject: [PATCH 04/16] Added Unit Test for XmlManipulationUtils --- .../util/XmlManipulationUtilsTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java diff --git a/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java b/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java new file mode 100644 index 000000000..e12f0c61e --- /dev/null +++ b/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java @@ -0,0 +1,47 @@ +package org.opendatakit.briefcase.util; + +import static org.junit.Assert.assertTrue; +import static org.opendatakit.briefcase.util.XmlManipulationUtils.*; + +import org.junit.Before; + +import org.junit.Test; +import org.kxml2.kdom.Element; +import org.kxml2.kdom.Node; + +public class XmlManipulationUtilsTest { + + private static final String ROOT_URI = "http://www.w3.org/2002/xforms"; + private static final String OPEN_ROSA_NAMESPACE = "http://openrosa.org/xforms"; + private static final String OPEN_ROSA_METADATA_TAG = "meta"; + private static final String OPEN_ROSA_INSTANCE_ID = "instanceID"; + private static final String NAMESPACE_ATTRIBUTE = "xmlns"; + private Element tree; + + @Before + public void setUp(){ + tree = new Element().createElement(null, "html"); + tree.setAttribute(null, NAMESPACE_ATTRIBUTE, ROOT_URI); + Element head = new Element().createElement(null, "head"); + Element title = new Element().createElement(null, "title"); + Element model = new Element().createElement(null, "model"); + Element instance = new Element().createElement(null, "instance"); + Element data = new Element().createElement(null, "data"); + Element meta = new Element().createElement(OPEN_ROSA_NAMESPACE, OPEN_ROSA_METADATA_TAG); + Element instanceId = new Element().createElement(OPEN_ROSA_NAMESPACE, OPEN_ROSA_INSTANCE_ID); + tree.addChild(Node.ELEMENT, head); + head.addChild(Node.ELEMENT, title); + head.addChild(Node.ELEMENT, model); + model.addChild(Node.ELEMENT, instance); + instance.addChild(Node.ELEMENT, data); + data.addChild(Node.ELEMENT, meta); + meta.addChild(Node.ELEMENT, instanceId); + } + + @Test + public void find_meta_tag_successful() { + FormInstanceMetadata metadata = getFormInstanceMetadata(tree); + assertTrue(metadata != null); + } + +} From 722ba46434e43b5c6b1601dd2b817631536471e5 Mon Sep 17 00:00:00 2001 From: Elliott Wallace Date: Mon, 23 Mar 2020 09:07:05 +0100 Subject: [PATCH 05/16] Add tests for TranferForms --- .../briefcase/transfer/TransferFormsTest.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/java/org/opendatakit/briefcase/transfer/TransferFormsTest.java b/test/java/org/opendatakit/briefcase/transfer/TransferFormsTest.java index 532616abf..1bf81057c 100644 --- a/test/java/org/opendatakit/briefcase/transfer/TransferFormsTest.java +++ b/test/java/org/opendatakit/briefcase/transfer/TransferFormsTest.java @@ -16,14 +16,34 @@ package org.opendatakit.briefcase.transfer; +import static java.nio.file.Paths.get; import static java.util.Collections.singletonList; import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import org.junit.Before; import org.junit.Test; +import org.opendatakit.briefcase.model.FormStatus; import org.opendatakit.briefcase.model.FormStatusBuilder; +import org.opendatakit.briefcase.model.TestFormDefinition; public class TransferFormsTest { + + private List forms; + private Path briefcaseDir; + + @Before + public void setUp() { + briefcaseDir = get("/storage/directory"); + forms = new ArrayList(); + forms = FormStatusBuilder.buildFormStatusList(10); + } + @Test public void empty_forms_can_merge_forms() { // What we are really testing is that no UnsupportedOperationException @@ -42,4 +62,27 @@ public void forms_from_varargs_factory_can_be_cleared() { forms.clear(); assertThat(forms.isEmpty(), is(true)); } + + @Test + public void loads_all_forms() { + TransferForms transferForms = TransferForms.empty(); + transferForms.load(forms); + assertEquals(10, transferForms.size()); + } + + @Test + public void test_select_all() { + TransferForms transferForms = TransferForms.from(forms); + transferForms.selectAll(); + assertTrue(transferForms.allSelected()); + assertTrue(transferForms.someSelected()); + } + + @Test + public void get_selected_forms() { + TransferForms transferForms = TransferForms.from(forms); + transferForms.selectAll(); + transferForms.getSelectedForms(); + assertEquals(10, transferForms.size()); + } } From 90ab11987b0ba012fc3be58a2c0edfb98934c5b0 Mon Sep 17 00:00:00 2001 From: Marinolino <45514278+Marinolino@users.noreply.github.com> Date: Mon, 23 Mar 2020 10:01:25 +0100 Subject: [PATCH 06/16] Removed csv report --- build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle b/build.gradle index ef00fe800..728582817 100755 --- a/build.gradle +++ b/build.gradle @@ -79,8 +79,6 @@ dependencies { jacocoTestReport { reports { xml.enabled = true - csv.enabled = true - csv.destination file("${buildDir}/jacocoCSV") } } From 411c92b801f0ff61b695d68392bfe851132616f9 Mon Sep 17 00:00:00 2001 From: Elliott Wallace Date: Mon, 23 Mar 2020 11:22:06 +0100 Subject: [PATCH 07/16] added request body test for RequestBuilder --- .../briefcase/reused/http/RequestBuilderTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/java/org/opendatakit/briefcase/reused/http/RequestBuilderTest.java b/test/java/org/opendatakit/briefcase/reused/http/RequestBuilderTest.java index c643a6c11..672c0c402 100644 --- a/test/java/org/opendatakit/briefcase/reused/http/RequestBuilderTest.java +++ b/test/java/org/opendatakit/briefcase/reused/http/RequestBuilderTest.java @@ -20,6 +20,7 @@ import static org.junit.Assert.assertThat; import static org.opendatakit.briefcase.reused.http.RequestBuilder.url; +import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -29,6 +30,8 @@ public class RequestBuilderTest { + private static final String TEST_BODY = "{\"query\": \"some-text\" }"; + @Test public void can_compose_multiple_path_parts() { List baseUrls = Arrays.asList("http://foo.com", "http://foo.com/"); @@ -86,4 +89,11 @@ public void can_resolve_paths() { is(url("http://foo.com/bar/baz")) ); } + + @Test + public void can_resolve_body(){ + Request request = RequestBuilder.get("http://foo.com").withBody(TEST_BODY).build(); + String body = RequestSpy.read(request.getBody()); + assertThat(body, is(TEST_BODY)); + } } From 8af120afdd3dc5c94d91c8eda3dd364265ab1cd1 Mon Sep 17 00:00:00 2001 From: Patrick R <45533939+pareichlin@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:05:12 +0100 Subject: [PATCH 08/16] Increased Branch Coverage in AggregateAttachment --- .../aggregate/AggregateAttachmentTest.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/test/java/org/opendatakit/briefcase/pull/aggregate/AggregateAttachmentTest.java b/test/java/org/opendatakit/briefcase/pull/aggregate/AggregateAttachmentTest.java index b0043c5ba..e054a57ba 100644 --- a/test/java/org/opendatakit/briefcase/pull/aggregate/AggregateAttachmentTest.java +++ b/test/java/org/opendatakit/briefcase/pull/aggregate/AggregateAttachmentTest.java @@ -1,14 +1,16 @@ package org.opendatakit.briefcase.pull.aggregate; -import static org.junit.Assert.assertThat; - import java.io.IOException; +import java.net.MalformedURLException; import java.net.URISyntaxException; +import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; import org.hamcrest.Matchers; import org.junit.Test; +import static org.junit.Assert.*; + public class AggregateAttachmentTest { @Test public void computes_the_string_MD5_hash_of_a_file() throws URISyntaxException, IOException { @@ -16,4 +18,22 @@ public void computes_the_string_MD5_hash_of_a_file() throws URISyntaxException, String expectedHash = "E79C0D4AD451003BA8CFDC1183AC89E9"; assertThat(AggregateAttachment.md5(file), Matchers.is(expectedHash)); } + + @Test + public void gets_download_url() throws URISyntaxException, MalformedURLException { + AggregateAttachment testAttachment = AggregateAttachment.of("file_1", "123456", "file://org/opendatakit/briefcase/pull/aggregate/lorem-ipsum-40k.txt"); + URL expectedUrl = new URL("file://org/opendatakit/briefcase/pull/aggregate/lorem-ipsum-40k.txt"); + assertEquals(expectedUrl, testAttachment.getDownloadUrl()); + } + + @Test + public void checks_equality_of_attachment() throws URISyntaxException, MalformedURLException { + AggregateAttachment testAttachment = AggregateAttachment.of("file_1", "123456", "file://org/opendatakit/briefcase/pull/aggregate/lorem-ipsum-40k.txt"); + AggregateAttachment testAttachment2 = AggregateAttachment.of("file_1", "123456", "file://org/opendatakit/briefcase/pull/aggregate/lorem-ipsum-40k.txt"); + AggregateAttachment testAttachment3 = AggregateAttachment.of("file_3", "1234567", "file://org/opendatakit/briefcase/lorem-ipsum-40k.txt"); + assertFalse(testAttachment.equals(null)); + assertTrue(testAttachment.equals(testAttachment)); + assertTrue(testAttachment.equals(testAttachment2)); + assertFalse(testAttachment.equals(testAttachment3)); + } } From 698b3f2368b70b94000b52eb2ac43a65cfef2dcd Mon Sep 17 00:00:00 2001 From: Patrick R <45533939+pareichlin@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:09:16 +0100 Subject: [PATCH 09/16] Increased branch coverage of FormKey --- .../briefcase/model/form/FormKeyTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/java/org/opendatakit/briefcase/model/form/FormKeyTest.java b/test/java/org/opendatakit/briefcase/model/form/FormKeyTest.java index 9d6e48221..f5597377c 100644 --- a/test/java/org/opendatakit/briefcase/model/form/FormKeyTest.java +++ b/test/java/org/opendatakit/briefcase/model/form/FormKeyTest.java @@ -2,6 +2,7 @@ import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; import static org.opendatakit.briefcase.ui.pull.FormInstallerTest.getPath; import static org.opendatakit.briefcase.util.StringUtils.stripIllegalChars; @@ -9,6 +10,7 @@ import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Path; +import org.junit.Assert; import org.junit.Test; import org.opendatakit.briefcase.model.BriefcaseFormDefinition; import org.opendatakit.briefcase.model.FormStatus; @@ -27,4 +29,18 @@ public void regression_wrong_form_name_when_creating_keys_from_briefcase_form_de FormKey key2 = FormKey.from(new FormStatus(BriefcaseFormDefinition.resolveAgainstBriefcaseDefn(formFile.toFile(), false, briefcaseFolder.toFile()))); assertThat(key1, is(key2)); } + + @Test + public void different_and_same_key_check_if_equal() { + FormKey key1 = FormKey.of("Key_1", "1", "v1.0"); + FormKey key2 = FormKey.of("Key_1", "2", "v2.0"); + FormKey key3 = FormKey.of("Key_1", "1", "v1.0"); + String keyString = "key_4"; + FormKey keyNull = null; + Assert.assertFalse(key1.equals(key2)); + assertTrue(key1.equals(key1)); + assertTrue(key1.equals(key3)); + Assert.assertFalse(key1.equals(keyString)); + Assert.assertFalse(key1.equals(keyNull)); + } } From ddd556f24b4a6f6de208e4c49cfda638cf7c4063 Mon Sep 17 00:00:00 2001 From: Patrick R <45533939+pareichlin@users.noreply.github.com> Date: Mon, 23 Mar 2020 12:13:40 +0100 Subject: [PATCH 10/16] Increased branch coverage of FormStatus --- .../opendatakit/briefcase/model/FormStatusTest.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/java/org/opendatakit/briefcase/model/FormStatusTest.java b/test/java/org/opendatakit/briefcase/model/FormStatusTest.java index 74345a11c..56f6dc825 100644 --- a/test/java/org/opendatakit/briefcase/model/FormStatusTest.java +++ b/test/java/org/opendatakit/briefcase/model/FormStatusTest.java @@ -5,6 +5,8 @@ import static org.junit.Assert.assertThat; import java.nio.file.Path; +import java.util.Optional; +import org.junit.Assert; import org.junit.Test; public class FormStatusTest { @@ -43,4 +45,14 @@ public void knows_how_to_build_paths_to_assets_inside_the_storage_directory() { ); } + @Test + public void gets_manifest_url_from_remoteform() { + FormStatus form = new FormStatus(null); + String supposedManifestUrl = "manifest/test/url"; + RemoteFormDefinition remoteForm = new RemoteFormDefinition("name", "1","v1", + "manifest/test/url", "/download/test/url"); + Assert.assertEquals(supposedManifestUrl, remoteForm.getManifestUrl()); + Assert.assertEquals(Optional.empty(), form.getManifestUrl()); + } + } From 4de5f69a746c2b9e8aea9e5939a0463afc49fa13 Mon Sep 17 00:00:00 2001 From: Marinolino <45514278+Marinolino@users.noreply.github.com> Date: Mon, 23 Mar 2020 20:16:49 +0100 Subject: [PATCH 11/16] Covered all branches in BriefcaseVersionManager class --- .../util/BriefcaseVersionManagerTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/java/org/opendatakit/briefcase/util/BriefcaseVersionManagerTest.java b/test/java/org/opendatakit/briefcase/util/BriefcaseVersionManagerTest.java index 5f55b650b..cfe7f59d7 100644 --- a/test/java/org/opendatakit/briefcase/util/BriefcaseVersionManagerTest.java +++ b/test/java/org/opendatakit/briefcase/util/BriefcaseVersionManagerTest.java @@ -57,4 +57,18 @@ public void knows_if_we_are_not_up_to_date() { assertThat(versionManager.isUpToDate(), is(false)); } + + @Test + public void version_contains_hyphen(){ + FakeHttp http = new FakeHttp(); + + http.stub( + get(url("https://api.github.com/repos/opendatakit/briefcase/releases/latest")).build(), + ResponseHelpers.ok("{\"tag_name\":\"v2.0.0\"}") + ); + + BriefcaseVersionManager versionManager = new BriefcaseVersionManager(http, "v2.0.0-test"); + + assertThat(versionManager.isUpToDate(), is(true)); + } } From 8449c3ed9205c0a0307710756519c8372febb84b Mon Sep 17 00:00:00 2001 From: Elliott Wallace Date: Mon, 23 Mar 2020 21:21:01 +0100 Subject: [PATCH 12/16] adjustment --- .../opendatakit/briefcase/util/XmlManipulationUtilsTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java b/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java index e12f0c61e..2cb347147 100644 --- a/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java +++ b/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java @@ -1,5 +1,6 @@ package org.opendatakit.briefcase.util; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.opendatakit.briefcase.util.XmlManipulationUtils.*; @@ -41,7 +42,7 @@ public void setUp(){ @Test public void find_meta_tag_successful() { FormInstanceMetadata metadata = getFormInstanceMetadata(tree); - assertTrue(metadata != null); + assertNotNull(metadata); } } From 0d8e7417008aa5b60cd419c85b5246f14e8d0ebd Mon Sep 17 00:00:00 2001 From: Marinolino <45514278+Marinolino@users.noreply.github.com> Date: Fri, 29 May 2020 15:45:28 +0200 Subject: [PATCH 13/16] Revert "adjustment" This reverts commit 8449c3ed9205c0a0307710756519c8372febb84b. --- .../opendatakit/briefcase/util/XmlManipulationUtilsTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java b/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java index 2cb347147..e12f0c61e 100644 --- a/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java +++ b/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java @@ -1,6 +1,5 @@ package org.opendatakit.briefcase.util; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.opendatakit.briefcase.util.XmlManipulationUtils.*; @@ -42,7 +41,7 @@ public void setUp(){ @Test public void find_meta_tag_successful() { FormInstanceMetadata metadata = getFormInstanceMetadata(tree); - assertNotNull(metadata); + assertTrue(metadata != null); } } From 8c18a1a60b359bbf441b54e152ee9552d007dce4 Mon Sep 17 00:00:00 2001 From: Marinolino <45514278+Marinolino@users.noreply.github.com> Date: Fri, 29 May 2020 16:16:26 +0200 Subject: [PATCH 14/16] Revert "Make HTTP post requests repeatable by wrapping entities into a repeatable entity (#856)" This reverts commit 9bffa68c63041b0c1ac7132b7bdbd83bed9eff86. --- .../briefcase/reused/http/CommonsHttp.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java b/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java index 02f91af38..d510765df 100644 --- a/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java +++ b/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java @@ -21,7 +21,6 @@ import static org.opendatakit.briefcase.reused.http.RequestMethod.POST; import java.io.IOException; -import java.io.InputStream; import java.io.UncheckedIOException; import java.net.SocketTimeoutException; import java.net.URL; @@ -31,7 +30,6 @@ import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.HttpHostConnectException; import org.apache.http.entity.BasicHttpEntity; -import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.InputStreamBody; @@ -130,9 +128,10 @@ private Response uncheckedExecute(Request request, Executor executor) part.getName(), new InputStreamBody(part.getBody(), ContentType.create(part.getContentType()), part.getAttachmentName()) ); - body = makeRepeatable(bodyBuilder.build()); + body = bodyBuilder.build(); } else { - body = makeRepeatable(buildBasicEntity(request.getBody())); + body = new BasicHttpEntity(); + ((BasicHttpEntity) body).setContent(request.getBody()); } commonsRequest.body(body); } @@ -150,20 +149,6 @@ private Response uncheckedExecute(Request request, Executor executor) } } - private BasicHttpEntity buildBasicEntity(InputStream contents) { - BasicHttpEntity entity = new BasicHttpEntity(); - entity.setContent(contents); - return entity; - } - - private BufferedHttpEntity makeRepeatable(HttpEntity entity) { - try { - return new BufferedHttpEntity(entity); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - private static org.apache.http.client.fluent.Request getCommonsRequest(Request request) { switch (request.getMethod()) { case GET: From 076788ef30c5918e2cb627d26dc56716c0a338f1 Mon Sep 17 00:00:00 2001 From: Marinolino <45514278+Marinolino@users.noreply.github.com> Date: Fri, 29 May 2020 16:46:29 +0200 Subject: [PATCH 15/16] Revert "Revert "adjustment"" This reverts commit 0d8e7417008aa5b60cd419c85b5246f14e8d0ebd. --- .../opendatakit/briefcase/util/XmlManipulationUtilsTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java b/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java index e12f0c61e..2cb347147 100644 --- a/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java +++ b/test/java/org/opendatakit/briefcase/util/XmlManipulationUtilsTest.java @@ -1,5 +1,6 @@ package org.opendatakit.briefcase.util; +import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.opendatakit.briefcase.util.XmlManipulationUtils.*; @@ -41,7 +42,7 @@ public void setUp(){ @Test public void find_meta_tag_successful() { FormInstanceMetadata metadata = getFormInstanceMetadata(tree); - assertTrue(metadata != null); + assertNotNull(metadata); } } From 7733176f54495642f7d113bfb18785be29c533c1 Mon Sep 17 00:00:00 2001 From: Marinolino <45514278+Marinolino@users.noreply.github.com> Date: Fri, 29 May 2020 16:46:36 +0200 Subject: [PATCH 16/16] Revert "Revert "Make HTTP post requests repeatable by wrapping entities into a repeatable entity (#856)"" This reverts commit 8c18a1a60b359bbf441b54e152ee9552d007dce4. --- .../briefcase/reused/http/CommonsHttp.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java b/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java index d510765df..02f91af38 100644 --- a/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java +++ b/src/org/opendatakit/briefcase/reused/http/CommonsHttp.java @@ -21,6 +21,7 @@ import static org.opendatakit.briefcase.reused.http.RequestMethod.POST; import java.io.IOException; +import java.io.InputStream; import java.io.UncheckedIOException; import java.net.SocketTimeoutException; import java.net.URL; @@ -30,6 +31,7 @@ import org.apache.http.conn.ConnectTimeoutException; import org.apache.http.conn.HttpHostConnectException; import org.apache.http.entity.BasicHttpEntity; +import org.apache.http.entity.BufferedHttpEntity; import org.apache.http.entity.ContentType; import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.entity.mime.content.InputStreamBody; @@ -128,10 +130,9 @@ private Response uncheckedExecute(Request request, Executor executor) part.getName(), new InputStreamBody(part.getBody(), ContentType.create(part.getContentType()), part.getAttachmentName()) ); - body = bodyBuilder.build(); + body = makeRepeatable(bodyBuilder.build()); } else { - body = new BasicHttpEntity(); - ((BasicHttpEntity) body).setContent(request.getBody()); + body = makeRepeatable(buildBasicEntity(request.getBody())); } commonsRequest.body(body); } @@ -149,6 +150,20 @@ private Response uncheckedExecute(Request request, Executor executor) } } + private BasicHttpEntity buildBasicEntity(InputStream contents) { + BasicHttpEntity entity = new BasicHttpEntity(); + entity.setContent(contents); + return entity; + } + + private BufferedHttpEntity makeRepeatable(HttpEntity entity) { + try { + return new BufferedHttpEntity(entity); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + private static org.apache.http.client.fluent.Request getCommonsRequest(Request request) { switch (request.getMethod()) { case GET: