-
Notifications
You must be signed in to change notification settings - Fork 5
Added jackson libraries with a custom failing test #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
saruye
wants to merge
1
commit into
j2objc-contrib:master
Choose a base branch
from
saruye:feature/jackson
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
|
||
# Build | ||
build/ | ||
*.iml | ||
\.idea/ | ||
|
||
# Ignore Gradle GUI config | ||
gradle-app.setting | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../common/build.gradle |
31 changes: 31 additions & 0 deletions
31
...ds/com.fasterxml.jackson.core/com.fasterxml.jackson.core-jackson-annotations/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
testMinExpectedTests 0 | ||
finalConfigure() | ||
} |
29 changes: 29 additions & 0 deletions
29
...aryBuilds/com.fasterxml.jackson.core/com.fasterxml.jackson.core-jackson-core/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
38 changes: 38 additions & 0 deletions
38
...uilds/com.fasterxml.jackson.core/com.fasterxml.jackson.core-jackson-databind/build.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add comment, or actually likely a |
||
} | ||
finalConfigure() | ||
} |
150 changes: 150 additions & 0 deletions
150
...c/test/java/com/github/j2objccontrib/j2objcgradle/CoreJacksonDataBindMarshallingTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../j2objc-gradle/gradlew |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../common/local.properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.