Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

# Build
build/
*.iml
\.idea/

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
11 changes: 7 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ env:
- TEST_DIR=joda-time-joda-time
- TEST_DIR=org.joda-joda-primitives
- TEST_DIR=org.apache.commons-commons-lang3
- TEST_DIR=com.fasterxml.jackson.core

# Uncomment to add a library that should fail to build, along with documentation on why.
# matrix:
# allow_failures:
# # Blocked on (github issue url)
# - env: TEST_DIR=libraryBuilds/com.example-library
matrix:
allow_failures:
# Blocked on (github issue url)
# - env: TEST_DIR=com.example-library
# Blocked on: update of j2objc with this issue fixed: https://github.com/google/j2objc/issues/639
- env: TEST_DIR=com.fasterxml.jackson.core

branches:
only:
Expand Down
1 change: 1 addition & 0 deletions libraryBuilds/com.fasterxml.jackson.core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
compile project(':com.fasterxml.jackson.core-jackson-core')
j2objcTranslation 'com.fasterxml.jackson.core:jackson-annotations:2.5.3:sources'
}

j2objcConfig {
autoConfigureDeps true

// Almost always there are no tests provided in an external source jar.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried that you don't have autoConfigureDeps true in here.

testMinExpectedTests 0
finalConfigure()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
j2objcTranslation 'com.fasterxml.jackson.core:jackson-core:2.5.3:sources'
}

j2objcConfig {
translateArgs '--segmented-headers' // import loops

testMinExpectedTests 0
finalConfigure()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
compile project(':com.fasterxml.jackson.core-jackson-core')
compile project(':com.fasterxml.jackson.core-jackson-annotations')
j2objcTranslation 'com.fasterxml.jackson.core:jackson-databind:2.5.3:sources'
testCompile 'junit:junit:4.11'
}

j2objcConfig {

translateArgs '--segmented-headers'
translateArgs '--extract-unsequenced'

autoConfigureDeps true

translatePattern {
exclude '**/fasterxml/jackson/databind/ext/DOMSerializer.java'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment, or actually likely a TODO: about what fix is needed.

}
finalConfigure()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/*
* Copyright (c) 2015 the authors of j2objc-common-libs-e2e-test
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.j2objccontrib.j2objcgradle;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Assert;
import org.junit.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class CoreJacksonDataBindMarshallingTest {

private static String jsonValue = "{\n" +
" \"addressList\": [\n" +
" {\n" +
" \"zipcode\": 12345,\n" +
" \"street\": \"Stenhammer Drive\"\n" +
" },\n" +
" {\n" +
" \"zipcode\": 7986,\n" +
" \"street\": \"Market Street\"\n" +
" }\n" +
" ],\n" +
" \"singleAddress\": {\n" +
" \"zipcode\": 7986,\n" +
" \"street\": \"Market Street\"\n" +
" }\n" +
"}" ;

@Test
public void testMarshalling() throws IOException {
Address homeAddress = new Address(12345, "Stenhammer Drive");
Address workAddress = new Address(7986, "Market Street");
ArrayList<Address> addressList = new ArrayList<>();
addressList.add(homeAddress);
addressList.add(workAddress);
Person person = new Person(addressList);
person.setSingleAddress(workAddress);

ObjectMapper objectMapper = new ObjectMapper();
String value = objectMapper.writeValueAsString(person);

JsonNode expected = objectMapper.readTree(jsonValue);
JsonNode actual = objectMapper.readTree(value);
Assert.assertEquals(expected, actual);

}

@Test
public void testDemarshallingWithEmbeddedObject() throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
Person personValue = objectMapper.readValue(jsonValue, Person.class);
Assert.assertTrue(personValue.getSingleAddress() instanceof Address);
Assert.assertEquals(7986, personValue.singleAddress.zipcode);
Assert.assertEquals("Market Street", personValue.singleAddress.street);
}

// This test is expected to fail until j2objc is updated to a version where
// this issue is fixed: https://github.com/google/j2objc/issues/639
@Test
public void testDemarshallingListField() throws IOException {
ObjectMapper objectMapper = new ObjectMapper();
Person personValue = objectMapper.readValue(jsonValue, Person.class);

List<Address> addresses = personValue.getAddressList();
Assert.assertEquals(2, addresses.size());
Address firstAddress = addresses.get(0);
Assert.assertTrue(firstAddress instanceof Address);

Assert.assertEquals(12345, firstAddress.zipcode);
Assert.assertEquals("Stenhammer Drive", firstAddress.street);
}

public static class Person {

private ArrayList<Address> addressList;
private Address singleAddress;

public Person(ArrayList<Address> addressList) {
this.addressList = addressList;
}

Person() {
}

public List<Address> getAddressList() {
return addressList;
}

public void setAddressList(ArrayList<Address> addressList) {
this.addressList = addressList;
}

public Address getSingleAddress() {
return singleAddress;
}

public void setSingleAddress(Address singleAddress) {
this.singleAddress = singleAddress;
}
}

public static class Address {

private int zipcode;
private String street;

Address() {
}

public Address(int zipcode,
String street) {
this.zipcode = zipcode;
this.street = street;
}

public int getZipcode() {
return zipcode;
}

public String getStreet() {
return street;
}

public void setZipcode(int zipcode) {
this.zipcode = zipcode;
}

public void setStreet(String street) {
this.street = street;
}
}
}
1 change: 1 addition & 0 deletions libraryBuilds/com.fasterxml.jackson.core/gradlew
1 change: 1 addition & 0 deletions libraryBuilds/com.fasterxml.jackson.core/local.properties
1 change: 1 addition & 0 deletions libraryBuilds/com.fasterxml.jackson.core/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include ':com.fasterxml.jackson.core-jackson-core',':com.fasterxml.jackson.core-jackson-annotations',':com.fasterxml.jackson.core-jackson-databind'
8 changes: 8 additions & 0 deletions libraryBuilds/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ subprojects {
repositories {
jcenter()
}

test {
testLogging {
// Provide full exception info on failure, instead
// of just pointing to an HTML file.
exceptionFormat 'full'
}
}
}
1 change: 1 addition & 0 deletions run-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ set -euv
./run-test.sh libraryBuilds/joda-time-joda-time
./run-test.sh libraryBuilds/org.joda-joda-primitives
./run-test.sh libraryBuilds/org.apache.commons-commons-lang3
./run-test.sh libraryBuilds/com.fasterxml.jackson.core