Copybara import of the project: - fa918ff33f8e7cf00d527328b3b4bdf85e783b90 Initial contribution by Dmitry Kornilov <dmitry.kornilov@oracle.com> - c0e17511f5a89075629e7354b34d557bbf344bd4 Merge pull request #83 from eclipse-ee4j/notice_contribut... by Dmitry Kornilov <maiden168@gmail.com> - 6d6f8a5c42c68d71ebeaab584d317c43dab27f10 Changed groupId and artifactId. Fixes #91 (#92) by Guillermo González de Agüero <ggam@users.noreply.github.com> - 851e55c5ca70a235560fc48aca057459e9edff15 spec-version-maven-plugin update to the latest version (#... by Dmitry Kornilov <maiden168@gmail.com> - ceb13aaba8edeb949609ae98f0fabf931ed11f47 JDK 11 preparation and jakarta uptake. (#101) by Tomáš Kraus <tomas.kraus@oracle.com> - 0f3fcc9ad63f44687a60da7b69f1e56c9a4829de Fixed Export-Package OSGI header. (#103) by Tomáš Kraus <tomas.kraus@oracle.com> - 431d4bdba7d1478161696a1647e6d48fad6fc9d6 Merge pull request #106 from Tomas-Kraus/master by Roman Grigoriadi <bravehorsie@gmail.com> - 9f3f0c49a31d4c11ae3a46ea21dcf97e453fb6dd Update readme by Andrew Guibert <andy.guibert@gmail.com> - 25a9a71ce56c86eb21bdef3cd2fd269d793206ed Update README.md by Dmitry Kornilov <dmitry.kornilov@oracle.com> - 7c095dd272e7ebf969d570cf77b4e366b9a1fd57 Fix javadoc failure since JDK 11.0.2, update checkstyle p... by Roman Grigoriadi <roman.grigoriadi@oracle.com> - 92c89c5a237261c3dbd8ec22000708c776889728 User's guide (#132) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - 466645654a5c2b95c1aa5a27d9292bb56018db44 Merge pull request #139 from m0mus/gitignore by Andrew Guibert <andy.guibert@gmail.com> - c211532612b5ac026e2e1227b8cfe6d1e389b580 Added JDK11 build support (#138) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - d0dd0aa83482a01e6648604c6fa62824763d45c3 Boilerplate spec (#144) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - c02dc37c4357d0402cbb3df0d6f6e65c9818b34e Spec name and references fixed (#142) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - 7fcf4882fe6756876068eea761184c3121bdd3d8 Project name changed in various text files (#145) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - 08e84327b74d717f74c653c4036b047a8bcd5916 Update README.md by Dmitry Kornilov <dmitry.kornilov@oracle.com> - f4e275e108983456a81c74624991bc316e62537f Updated boilerplate spec template, minor fixes (#152) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - ee71e515d12c3d823e9649ff26361cf364cd6909 Fixed copyright plugin setup. by Tomas Kraus <Tomas.Kraus@oracle.com> - ccc03f16817af3e5c38218e1cf4cfa5a23abe01a Fixed enforcer plugin setup. by Tomas Kraus <Tomas.Kraus@oracle.com> - 3b715994b2594645b315522a0575cb1106a14ae5 JSON-P API dependency updated to 1.1.6 (#156) by Tomáš Kraus <tomas.kraus@oracle.com> - e84c8be88b968b44e0e4bf53fba263b15d364be8 Spec status propagation (#159) (#162) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - df773b773618929a169ff9b5ee0187910f635095 JDK links in javadoc fixed (#163) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - 9d6fcdcb881f31b97f3e71c6267710155e53b9b7 Rolling back to JSONP 1.1.5 (#166) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - b29bc1edff86b66f2b57476b394e5da19f47ac40 Copyright is upated to Eclipse Foundation (#174) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - dea2d2c89bc9d9e024b639ff42094241c61bffe7 Merge pull request #194 from mkarg/GH-193 by Andrew Guibert <andy.guibert@gmail.com> - 1aaa616ac8d51a1b2a12c3c5653726417275c0a3 Merge pull request #203 from aguibert/readme-badges by Andrew Guibert <andy.guibert@gmail.com> - 6b0f745c0a0749c59e55fc3024f113df9257e964 Merge pull request #202 from aguibert/spec-initial by Andrew Guibert <andy.guibert@gmail.com> - b22baa619443b6aca0ff100dbc2af51199d07a48 Merge pull request #208 from moghaddam/master by Andrew Guibert <andy.guibert@gmail.com> - 419c2876ead42a45ce22b0c7cbef00d7e14468e2 Merge pull request #216 from aguibert/readme-jakarta-links by Andrew Guibert <andy.guibert@gmail.com> - f950c0f163a93aa551c45160218fa10d8b7174ea Merge pull request #210 from aguibert/propNamingStrat-doc... by Andrew Guibert <andy.guibert@gmail.com> - 32caa549925a24d2162f21864deea61033a2823c Package renamed: javax -> jakarta by Tomas Kraus <Tomas.Kraus@oracle.com> - f931164600d712b6067bf8279d7124e8723c9dc4 Updated jsonp and parent pom versions. by Tomas Kraus <Tomas.Kraus@oracle.com> - 8f4334836e3029be27a2692c4925fdcc8855e5e0 Specification and documentation versions update. by Tomas Kraus <Tomas.Kraus@oracle.com> - c84e58545a4dfeeeabd67f5a5e195687f6e5ec0a Oops, spec has only 2 digits versioning. by Tomas Kraus <Tomas.Kraus@oracle.com> - 9c248fe914349d8d1dae7d9f172bb33feb2b9aea Merge pull request #221 from aguibert/tck by Andrew Guibert <andy.guibert@gmail.com> - 70a607f500828317ae1b4767d3c948abe1e00eac Merge pull request #226 from aguibert/copyright-build-error by Andrew Guibert <andy.guibert@gmail.com> - 599481cab6ecccf9eae3b6ab33bef174ec3c11ef Merge pull request #227 from aguibert/tck-javadoc-fix by Andrew Guibert <andy.guibert@gmail.com> - 5a461c9ad59598c0a2ac54d0f44d4218d61f49ba Merge pull request #242 from jGauravGupta/jsonb-api-export by Andrew Guibert <andy.guibert@gmail.com> - 9f4d42f07e88644addb4d12a7dff0a387fab0a4e Merge pull request #245 from jGauravGupta/fix-spec-version by David Král <david.k.kral@oracle.com> - ab7d16dbd62427b948a1052b527135470f0fd6e8 Merge pull request #247 from aguibert/tck-jakarta-inject-2 by Andrew Guibert <andy.guibert@gmail.com> - f127e35c67bb3bbfd69cc4a83289d10f04ce6c2f Merge pull request #248 from mcserra/update-EFSL-for-spec... by Andrew Guibert <andy.guibert@gmail.com> - 78489bc313d0862710b921f1f4adca5a2de35a44 Merge pull request #254 from m0mus/updake_jsonp_2_0 by Andrew Guibert <andy.guibert@gmail.com> - 3555fc0718bebb25cf938dc5d8d0c6146c3bb5f9 Merge pull request #258 from dblevins/javax-renames by Andrew Guibert <andy.guibert@gmail.com> - f14b0c86e5860780e095cd075542d317c014b8c4 Spec version and javadocs copyright year updated (#259) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - 53ea9c460662bcc395dc2d0e1af3635c12c474ca Copyright year change (#260) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - cc5273d2b0ff06f778747428fb672830844337be Merge pull request #263 from eclipse-ee4j/dependabot/mave... by Andrew Guibert <andy.guibert@gmail.com> - 87321051ddd85e9848606d978110d42a2c3549b3 Update API version of jakarta.json.bind:jakarta.json.bind... by Eclipse JSON-B Bot <jsonb-bot@eclipse.org> - c74a6f215b054c3f8f72c2b5b6c2b4afd43c857c Update API version of jakarta.json.bind:jakarta.json.bind... by Eclipse JSON-B Bot <jsonb-bot@eclipse.org> - ad33b9fb649998b37b1f8a39881e06c52697fa6b Bump junit from 4.12 to 4.13.1 in /api by dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> - ab1b70d3d105dfc80680316f116570f3ba84d260 Bump checkstyle from 8.18 to 8.29 in /api by dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> - b249b4a488b802f323ddce4e3d3a626b85f89fe7 Null value deserialization into the JsonValue.NULL (#273) by David Král <david.k.kral@oracle.com> - e9ae2968e15b219edbdb77117f46fd9df55e14a6 TCK test UntypedMappingTest.testArrayMapping fixed (#275) by David Král <david.k.kral@oracle.com> - 2aaadf8df6b026781f54ef625c09bdbbee609e7b JsonbProperty.nillable deprecated in favour of JsonbNilla... by David Král <david.k.kral@oracle.com> - 12d5b6e3bb618a276195c4d659c2c5e7ede5024e JsonbTypeDeserializer annotation is now supported on crea... by David Král <david.k.kral@oracle.com> - de9d2bccd29d3996b65dbd4cd63b582a4df081d8 Fix of the new TCK test for deserializer on the JsonbCrea... by David Král <david.k.kral@oracle.com> - 2afb4d421bb6ff361a83fc924bfb461e0f13ea99 JSON-B 3.0.0 and github actions (#288) by David Král <david.k.kral@oracle.com> - 6e9cff260e5f29f9042a3a6f3180176196b9941f Optional creator parameters (#285) by David Král <david.k.kral@oracle.com> - 20353730149154575bc0fb4c14f5f65929b3b3f3 JsonbCreator optional parameter TCK fix (#290) by David Král <david.k.kral@oracle.com> - 21809d76cdeb74cc31507c85049995d8788d4dbb JsonbTypeAdapter is now allowed on the creator paramters ... by David Král <david.k.kral@oracle.com> - f215fe725fa35085b92f6a636778f60291afdfd8 Readme version update (#293) by David Král <david.k.kral@oracle.com> - 28f0ee878078826597f5436b6bc27c1a13be0ecb JsonbCreator parameter optionality changed (#294) by David Král <david.k.kral@oracle.com> - 7b383bc79979f6f019abbe89b38d8143d9ca81a9 Optional creator parameter tck test fix (#295) by David Král <david.k.kral@oracle.com> - d742983ef9e93568fc83b755053cfedf97e4458a Updating User's Guide link (#297) by Dmitry Kornilov <dmitry.kornilov@oracle.com> - 34327df5d7f0f5465a7b6eceaef60a50869106bf Jsonb polymorphism support (#284) by David Král <david.k.kral@oracle.com> - 3f6d7d40d1f33551e8699198bd3b1af4db8a7b05 More polymorphism TCKs added (#300) by David Král <david.k.kral@oracle.com> - 703826016ebd5aa439d56d272c073e1961415ad4 Wrapping object and class name handling removed (#303) by David Král <david.k.kral@oracle.com> - 46a30c12cf16bbbf863e8f40e845aef81e16852a TCK reworked to JUnit 5 and reformatted (#276) by David Král <david.k.kral@oracle.com> - 189b0d379fc809da9f93cb6cb3d54e76dda411ae Copyright year changed (#308) by David Král <david.k.kral@oracle.com> - ee9043e8039bea2891b746b0d1d82b9ffdfce4eb jsonb documentation moved and updated by Alwin Joseph <44426046+alwin-joseph@users.noreply.github.com> - 2a48519ebcd1f674fcebc1dd52d26a085d68595a correct version/copyrights/dates by Alwin Joseph <44426046+alwin-joseph@users.noreply.github.com> - 4515415835825469917c813ac40dbfce71b77711 jsonb signature test migration. by gurunandan.rao@oracle.com <gurunandan.rao@oracle.com> - 89839321c4432059446cb8da1a0cee90267d5b1f jsonb tck bundle generation (#309) by Gurunandan Rao <gurunandan.rao@oracle.com> - 052e17c91d50018cfe814f10d009bffb0852c249 Fixing up number tck test (#311) by David Král <david.k.kral@oracle.com> - 87bafc0b0426fbfd84d1090b98e4983320808457 SNAPSHOT version returned to the jsonb tck version (#312) by David Král <david.k.kral@oracle.com> - b9ea7b61f5c91c7db56a78055d827f9e0706e114 technical merge of 3.0.0-RC1 into master (release tag) by David Král <david.k.kral@oracle.com> - b916884ee1ec6c8b9077c29ab92bc60613d5525b add pom.xml for dist generation. (#315) by Gurunandan Rao <gurunandan.rao@oracle.com> - 362c22e7bca4d8dd354370401cda38bc74a44cec minor wording changes (#316) by David Král <david.k.kral@oracle.com> - 54c42c9d21c6d18a3b1e8b9d6385af8cdec9a1a4 Number of standalone tck tests updated (#317) by David Král <david.k.kral@oracle.com> - c1d3b7710f71b2bdef1597fd7cf7043d91675c2b javadoc assertion files for 3.0 (#320) by Alwin Joseph <44426046+alwin-joseph@users.noreply.github.com> - ad73dd30ee850536fe45ef88e809b5b157af06cf Userguide updates (#321) by David Král <david.k.kral@oracle.com> - 29a2568fd15bb03d72e97ea1cfc176e982c68317 userguide and tck dist eftl bundle tuning (#322) by David Král <david.k.kral@oracle.com> - 7340b84ec2a5bbdeb492d425eccee6d65443e97c tck dist update (#323) by David Král <david.k.kral@oracle.com> - 0c6e3084154d5841d0e8e4e51cc2a51a97447631 use classpath for jakarta api libraries. by Gurunandan Rao <gurunandan.rao@oracle.com> - 8c9444e1bd02ea920a8669b27e936807fdb003fa Merge pull request #354 from jakartaee/3.0.0-BRANCH by David Král <david.k.kral@oracle.com> - 5dfc190c3ed24ada3b29b5665d5577a01b5836dc Merge pull request #339 from mkarg/patch-1 by David Král <david.k.kral@oracle.com> - 1ec8fa1fca70f52eaac627997c29af7fae3241a3 Merge pull request #249 from mcserra/#237 by David Král <david.k.kral@oracle.com> - f3a2332cc1a58b8da1767c6541ea86be3923b733 Before 3.0.1 release (#355) by David Král <david.k.kral@oracle.com> - 2f3154010a16cb4569595c3c16125661f9407038 Update API version of jakarta.json.bind:jakarta.json.bind... by Eclipse JSON-B Bot <jsonb-bot@eclipse.org> GitOrigin-RevId: 2f3154010a16cb4569595c3c16125661f9407038 Change-Id: I6a3789935952418f4477c665f9295ed9bca19e65
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..d8feb9b --- /dev/null +++ b/.github/workflows/maven.yml
@@ -0,0 +1,55 @@ +# +# Copyright (c) 2021, 2024 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +name: JSON-B API + +on: [push, pull_request] + +permissions: + security-events: read + contents: write + actions: read + id-token: write + checks: write + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: JSON-B API compilation + runs-on: ubuntu-latest + + steps: + - name: Checkout for build + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up compile JDK + uses: actions/setup-java@v4 + with: + distribution: 'adopt' + java-version: 11 + cache: 'maven' + - name: API compilation + run: cd api && mvn clean install -Pstaging -B + - name: TCK test compilation + run: cd tck && mvn clean install -Pstaging -B + - name: Javadoc compilation + run: cd docs && mvn clean install -Pstaging -B + - name: Generating specification + run: cd spec && mvn clean install -Pstaging -B
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b815be --- /dev/null +++ b/.gitignore
@@ -0,0 +1,23 @@ +# Maven noise +target/ + +# OSX noise +.DS_Store + +# IntelliJ Idea noise +.idea +*.iws +*.ipr +*.iml + +# Eclipse noise +.settings/ +.classpath +.project + +# NetBeans noise +nbproject/ + +# Java noise +*.class +*err_pid*.log
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..dd6225f --- /dev/null +++ b/CONTRIBUTING.md
@@ -0,0 +1,81 @@ +# Contributing to Jakarta JSON Binding + +Thanks for your interest in this project. + +## Project description + +Jakarta JSON Binding™ is a standard binding layer for converting Java objects +to/from JSON messages. It defines a default mapping algorithm for converting +existing Java classes to JSON, while enabling developers to customize the +mapping process through the use of Java annotations. + +* https://projects.eclipse.org/projects/ee4j.jsonb + +## Terms of Use + +This repository is subject to the Terms of Use of the Eclipse Foundation + +* https://www.eclipse.org/legal/termsofuse.php + +## Developer resources + +Information regarding source code management, builds, coding standards, and +more. + +* https://projects.eclipse.org/projects/ee4j.jsonb/developer + +The project maintains the following source code repositories + +* https://github.com/jakartaee/jsonb-api + +## Eclipse Development Process + +This Eclipse Foundation open project is governed by the Eclipse Foundation +Development Process and operates under the terms of the Eclipse IP Policy. + +The Jakarta EE Specification Committee has adopted the Jakarta EE Specification +Process (JESP) in accordance with the Eclipse Foundation Specification Process +v1.2 (EFSP) to ensure that the specification process is complied with by all +Jakarta EE specification projects. + +* https://eclipse.org/projects/dev_process +* https://www.eclipse.org/org/documents/Eclipse_IP_Policy.pdf +* https://jakarta.ee/about/jesp/ +* https://www.eclipse.org/legal/efsp_non_assert.php + +## Eclipse Contributor Agreement + +In order to be able to contribute to Eclipse Foundation projects you must +electronically sign the Eclipse Contributor Agreement (ECA). + +* https://www.eclipse.org/legal/ECA.php + +The ECA provides the Eclipse Foundation with a permanent record that you agree +that each of your contributions will comply with the commitments documented in +the Developer Certificate of Origin (DCO). Having an ECA on file associated with +the email address matching the "Author" field of your contribution's Git commits +fulfills the DCO's requirement that you sign-off on your contributions. + +For more information, please see the Eclipse Committer Handbook: +https://www.eclipse.org/projects/handbook/#resources-commit + +## Eclipse Development Process + +This Eclipse Foundation open project is governed by the Eclipse Foundation +Development Process and operates under the terms of the Eclipse IP Policy. + +The Jakarta EE Specification Committee has adopted the Jakarta EE Specification +Process (JESP) in accordance with the Eclipse Foundation Specification Process +v1.2 (EFSP) to ensure that the specification process is complied with by all +Jakarta EE specification projects. + +* https://eclipse.org/projects/dev_process +* https://www.eclipse.org/org/documents/Eclipse_IP_Policy.pdf +* https://jakarta.ee/about/jesp/ +* https://www.eclipse.org/legal/efsp_non_assert.php + +## Contact + +Contact the project developers via the project's "dev" list. + +* https://accounts.eclipse.org/mailing-list/jsonb-dev
diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..5de3d1b --- /dev/null +++ b/LICENSE.md
@@ -0,0 +1,637 @@ +# Eclipse Public License - v 2.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION + OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + + 1. DEFINITIONS + + "Contribution" means: + + a) in the case of the initial Contributor, the initial content + Distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + where such changes and/or additions to the Program originate from + and are Distributed by that particular Contributor. A Contribution + "originates" from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include changes or additions to the Program that + are not Modified Works. + + "Contributor" means any person or entity that Distributes the Program. + + "Licensed Patents" mean patent claims licensable by a Contributor which + are necessarily infringed by the use or sale of its Contribution alone + or when combined with the Program. + + "Program" means the Contributions Distributed in accordance with this + Agreement. + + "Recipient" means anyone who receives the Program under this Agreement + or any Secondary License (as applicable), including Contributors. + + "Derivative Works" shall mean any work, whether in Source Code or other + form, that is based on (or derived from) the Program and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. + + "Modified Works" shall mean any work in Source Code or other form that + results from an addition to, deletion from, or modification of the + contents of the Program, including, for purposes of clarity any new file + in Source Code form that contains any contents of the Program. Modified + Works shall not include works that contain only declarations, + interfaces, types, classes, structures, or files of the Program solely + in each case in order to link to, bind by name, or subclass the Program + or Modified Works thereof. + + "Distribute" means the acts of a) distributing or b) making available + in any manner that enables the transfer of a copy. + + "Source Code" means the form of a Program preferred for making + modifications, including but not limited to software source code, + documentation source, and configuration files. + + "Secondary License" means either the GNU General Public License, + Version 2.0, or any later versions of that license, including any + exceptions or additional permissions as identified by the initial + Contributor. + + 2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free copyright + license to reproduce, prepare Derivative Works of, publicly display, + publicly perform, Distribute and sublicense the Contribution of such + Contributor, if any, and such Derivative Works. + + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free patent + license under Licensed Patents to make, use, sell, offer to sell, + import and otherwise transfer the Contribution of such Contributor, + if any, in Source Code or other form. This patent license shall + apply to the combination of the Contribution and the Program if, at + the time the Contribution is added by the Contributor, such addition + of the Contribution causes such combination to be covered by the + Licensed Patents. The patent license shall not apply to any other + combinations which include the Contribution. No hardware per se is + licensed hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the + rights and licenses granted hereunder, each Recipient hereby + assumes sole responsibility to secure any other intellectual + property rights needed, if any. For example, if a third party + patent license is required to allow Recipient to Distribute the + Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + + d) Each Contributor represents that to its knowledge it has + sufficient copyright rights in its Contribution, if any, to grant + the copyright license set forth in this Agreement. + + e) Notwithstanding the terms of any Secondary License, no + Contributor makes additional grants to any Recipient (other than + those set forth in this Agreement) as a result of such Recipient's + receipt of the Program under the terms of a Secondary License + (if permitted under the terms of Section 3). + + 3. REQUIREMENTS + + 3.1 If a Contributor Distributes the Program in any form, then: + + a) the Program must also be made available as Source Code, in + accordance with section 3.2, and the Contributor must accompany + the Program with a statement that the Source Code for the Program + is available under this Agreement, and informs Recipients how to + obtain it in a reasonable manner on or through a medium customarily + used for software exchange; and + + b) the Contributor may Distribute the Program under a license + different than this Agreement, provided that such license: + i) effectively disclaims on behalf of all other Contributors all + warranties and conditions, express and implied, including + warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness + for a particular purpose; + + ii) effectively excludes on behalf of all other Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) does not attempt to limit or alter the recipients' rights + in the Source Code under section 3.2; and + + iv) requires any subsequent distribution of the Program by any + party to be under a license that satisfies the requirements + of this section 3. + + 3.2 When the Program is Distributed as Source Code: + + a) it must be made available under this Agreement, or if the + Program (i) is combined with other material in a separate file or + files made available under a Secondary License, and (ii) the initial + Contributor attached to the Source Code the notice described in + Exhibit A of this Agreement, then the Program may be made available + under the terms of such Secondary Licenses, and + + b) a copy of this Agreement must be included with each copy of + the Program. + + 3.3 Contributors may not remove or alter any copyright, patent, + trademark, attribution notices, disclaimers of warranty, or limitations + of liability ("notices") contained within the Program from any copy of + the Program which they Distribute, provided that Contributors may add + their own appropriate notices. + + 4. COMMERCIAL DISTRIBUTION + + Commercial distributors of software may accept certain responsibilities + with respect to end users, business partners and the like. While this + license is intended to facilitate the commercial use of the Program, + the Contributor who includes the Program in a commercial product + offering should do so in a manner which does not create potential + liability for other Contributors. Therefore, if a Contributor includes + the Program in a commercial product offering, such Contributor + ("Commercial Contributor") hereby agrees to defend and indemnify every + other Contributor ("Indemnified Contributor") against any losses, + damages and costs (collectively "Losses") arising from claims, lawsuits + and other legal actions brought by a third party against the Indemnified + Contributor to the extent caused by the acts or omissions of such + Commercial Contributor in connection with its distribution of the Program + in a commercial product offering. The obligations in this section do not + apply to any claims or Losses relating to any actual or alleged + intellectual property infringement. In order to qualify, an Indemnified + Contributor must: a) promptly notify the Commercial Contributor in + writing of such claim, and b) allow the Commercial Contributor to control, + and cooperate with the Commercial Contributor in, the defense and any + related settlement negotiations. The Indemnified Contributor may + participate in any such claim at its own expense. + + For example, a Contributor might include the Program in a commercial + product offering, Product X. That Contributor is then a Commercial + Contributor. If that Commercial Contributor then makes performance + claims, or offers warranties related to Product X, those performance + claims and warranties are such Commercial Contributor's responsibility + alone. Under this section, the Commercial Contributor would have to + defend claims against the other Contributors related to those performance + claims and warranties, and if a court requires any other Contributor to + pay any damages as a result, the Commercial Contributor must pay + those damages. + + 5. NO WARRANTY + + EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT + PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR + IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF + TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + PURPOSE. Each Recipient is solely responsible for determining the + appropriateness of using and distributing the Program and assumes all + risks associated with its exercise of rights under this Agreement, + including but not limited to the risks and costs of program errors, + compliance with applicable laws, damage to or loss of data, programs + or equipment, and unavailability or interruption of operations. + + 6. DISCLAIMER OF LIABILITY + + EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT + PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS + SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST + PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE + EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + + 7. GENERAL + + If any provision of this Agreement is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this Agreement, and without further + action by the parties hereto, such provision shall be reformed to the + minimum extent necessary to make such provision valid and enforceable. + + If Recipient institutes patent litigation against any entity + (including a cross-claim or counterclaim in a lawsuit) alleging that the + Program itself (excluding combinations of the Program with other software + or hardware) infringes such Recipient's patent(s), then such Recipient's + rights granted under Section 2(b) shall terminate as of the date such + litigation is filed. + + All Recipient's rights under this Agreement shall terminate if it + fails to comply with any of the material terms or conditions of this + Agreement and does not cure such failure in a reasonable period of + time after becoming aware of such noncompliance. If all Recipient's + rights under this Agreement terminate, Recipient agrees to cease use + and distribution of the Program as soon as reasonably practicable. + However, Recipient's obligations under this Agreement and any licenses + granted by Recipient relating to the Program shall continue and survive. + + Everyone is permitted to copy and distribute copies of this Agreement, + but in order to avoid inconsistency the Agreement is copyrighted and + may only be modified in the following manner. The Agreement Steward + reserves the right to publish new versions (including revisions) of + this Agreement from time to time. No one other than the Agreement + Steward has the right to modify this Agreement. The Eclipse Foundation + is the initial Agreement Steward. The Eclipse Foundation may assign the + responsibility to serve as the Agreement Steward to a suitable separate + entity. Each new version of the Agreement will be given a distinguishing + version number. The Program (including Contributions) may always be + Distributed subject to the version of the Agreement under which it was + received. In addition, after a new version of the Agreement is published, + Contributor may elect to Distribute the Program (including its + Contributions) under the new version. + + Except as expressly stated in Sections 2(a) and 2(b) above, Recipient + receives no rights or licenses to the intellectual property of any + Contributor under this Agreement, whether expressly, by implication, + estoppel or otherwise. All rights in the Program not expressly granted + under this Agreement are reserved. Nothing in this Agreement is intended + to be enforceable by any entity that is not a Contributor or Recipient. + No third-party beneficiary rights are created under this Agreement. + + Exhibit A - Form of Secondary Licenses Notice + + "This Source Code may also be made available under the following + Secondary Licenses when the conditions for such availability set forth + in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), + version(s), and exceptions or additional permissions here}." + + Simply including a copy of this Agreement, including this Exhibit A + is not sufficient to license the Source Code under Secondary Licenses. + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to + look for such a notice. + + You may add additional accurate notices of copyright ownership. + +--- + +## The GNU General Public License (GPL) Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1335 + USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your freedom to + share and change it. By contrast, the GNU General Public License is + intended to guarantee your freedom to share and change free software--to + make sure the software is free for all its users. This General Public + License applies to most of the Free Software Foundation's software and + to any other program whose authors commit to using it. (Some other Free + Software Foundation software is covered by the GNU Library General + Public License instead.) You can apply it to your programs, too. + + When we speak of free software, we are referring to freedom, not price. + Our General Public Licenses are designed to make sure that you have the + freedom to distribute copies of free software (and charge for this + service if you wish), that you receive source code or can get it if you + want it, that you can change the software or use pieces of it in new + free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid anyone + to deny you these rights or to ask you to surrender the rights. These + restrictions translate to certain responsibilities for you if you + distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether gratis + or for a fee, you must give the recipients all the rights that you have. + You must make sure that they, too, receive or can get the source code. + And you must show them these terms so they know their rights. + + We protect your rights with two steps: (1) copyright the software, and + (2) offer you this license which gives you legal permission to copy, + distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain + that everyone understands that there is no warranty for this free + software. If the software is modified by someone else and passed on, we + want its recipients to know that what they have is not the original, so + that any problems introduced by others will not reflect on the original + authors' reputations. + + Finally, any free program is threatened constantly by software patents. + We wish to avoid the danger that redistributors of a free program will + individually obtain patent licenses, in effect making the program + proprietary. To prevent this, we have made it clear that any patent must + be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and + modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains a + notice placed by the copyright holder saying it may be distributed under + the terms of this General Public License. The "Program", below, refers + to any such program or work, and a "work based on the Program" means + either the Program or any derivative work under copyright law: that is + to say, a work containing the Program or a portion of it, either + verbatim or with modifications and/or translated into another language. + (Hereinafter, translation is included without limitation in the term + "modification".) Each licensee is addressed as "you". + + Activities other than copying, distribution and modification are not + covered by this License; they are outside its scope. The act of running + the Program is not restricted, and the output from the Program is + covered only if its contents constitute a work based on the Program + (independent of having been made by running the Program). Whether that + is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's source + code as you receive it, in any medium, provided that you conspicuously + and appropriately publish on each copy an appropriate copyright notice + and disclaimer of warranty; keep intact all the notices that refer to + this License and to the absence of any warranty; and give any other + recipients of the Program a copy of this License along with the Program. + + You may charge a fee for the physical act of transferring a copy, and + you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion of + it, thus forming a work based on the Program, and copy and distribute + such modifications or work under the terms of Section 1 above, provided + that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any part + thereof, to be licensed as a whole at no charge to all third parties + under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this License. + (Exception: if the Program itself is interactive but does not + normally print such an announcement, your work based on the Program + is not required to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, and + can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based on + the Program, the distribution of the whole must be on the terms of this + License, whose permissions for other licensees extend to the entire + whole, and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you; rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Program. + + In addition, mere aggregation of another work not based on the Program + with the Program (or with a work based on the Program) on a volume of a + storage or distribution medium does not bring the other work under the + scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms of + Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections 1 + and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your cost + of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to + distribute corresponding source code. (This alternative is allowed + only for noncommercial distribution and only if you received the + program in object code or executable form with such an offer, in + accord with Subsection b above.) + + The source code for a work means the preferred form of the work for + making modifications to it. For an executable work, complete source code + means all the source code for all modules it contains, plus any + associated interface definition files, plus the scripts used to control + compilation and installation of the executable. However, as a special + exception, the source code distributed need not include anything that is + normally distributed (in either source or binary form) with the major + components (compiler, kernel, and so on) of the operating system on + which the executable runs, unless that component itself accompanies the + executable. + + If distribution of executable or object code is made by offering access + to copy from a designated place, then offering equivalent access to copy + the source code from the same place counts as distribution of the source + code, even though third parties are not compelled to copy the source + along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt otherwise + to copy, modify, sublicense or distribute the Program is void, and will + automatically terminate your rights under this License. However, parties + who have received copies, or rights, from you under this License will + not have their licenses terminated so long as such parties remain in + full compliance. + + 5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Program or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Program (or any work based on the + Program), you indicate your acceptance of this License to do so, and all + its terms and conditions for copying, distributing or modifying the + Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program subject to + these terms and conditions. You may not impose any further restrictions + on the recipients' exercise of the rights granted herein. You are not + responsible for enforcing compliance by third parties to this License. + + 7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot distribute + so as to satisfy simultaneously your obligations under this License and + any other pertinent obligations, then as a consequence you may not + distribute the Program at all. For example, if a patent license would + not permit royalty-free redistribution of the Program by all those who + receive copies directly or indirectly through you, then the only way you + could satisfy both it and this License would be to refrain entirely from + distribution of the Program. + + If any portion of this section is held invalid or unenforceable under + any particular circumstance, the balance of the section is intended to + apply and the section as a whole is intended to apply in other + circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims; this section has the sole purpose of protecting the + integrity of the free software distribution system, which is implemented + by public license practices. Many people have made generous + contributions to the wide range of software distributed through that + system in reliance on consistent application of that system; it is up to + the author/donor to decide if he or she is willing to distribute + software through any other system and a licensee cannot impose that choice. + + This section is intended to make thoroughly clear what is believed to be + a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License may + add an explicit geographical distribution limitation excluding those + countries, so that distribution is permitted only in or among countries + not thus excluded. In such case, this License incorporates the + limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new + versions of the General Public License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the Program + specifies a version number of this License which applies to it and "any + later version", you have the option of following the terms and + conditions either of that version or of any later version published by + the Free Software Foundation. If the Program does not specify a version + number of this License, you may choose any version ever published by the + Free Software Foundation. + + 10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the + author to ask for permission. For software which is copyrighted by the + Free Software Foundation, write to the Free Software Foundation; we + sometimes make exceptions for this. Our decision will be guided by the + two goals of preserving the free status of all derivatives of our free + software and of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. + EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR + OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, + EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE + ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH + YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL + NECESSARY SERVICING, REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY + AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR + DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL + DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM + (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED + INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF + THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR + OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest + possible use to the public, the best way to achieve this is to make it + free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest to + attach them to the start of each source file to most effectively convey + the exclusion of warranty; and each file should have at least the + "copyright" line and a pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + + Also add information on how to contact you by electronic and paper mail. + + If the program is interactive, make it output a short notice like this + when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type + `show w'. This is free software, and you are welcome to redistribute + it under certain conditions; type `show c' for details. + + The hypothetical commands `show w' and `show c' should show the + appropriate parts of the General Public License. Of course, the commands + you use may be called something other than `show w' and `show c'; they + could even be mouse-clicks or menu items--whatever suits your program. + + You should also get your employer (if you work as a programmer) or your + school, if any, to sign a "copyright disclaimer" for the program, if + necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (which makes passes at compilers) written by + James Hacker. + + signature of Ty Coon, 1 April 1989 + Ty Coon, President of Vice + + This General Public License does not permit incorporating your program + into proprietary programs. If your program is a subroutine library, you + may consider it more useful to permit linking proprietary applications + with the library. If this is what you want to do, use the GNU Library + General Public License instead of this License. + +--- + +## CLASSPATH EXCEPTION + + Linking this library statically or dynamically with other modules is + making a combined work based on this library. Thus, the terms and + conditions of the GNU General Public License version 2 cover the whole + combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent + modules, and to copy and distribute the resulting executable under + terms of your choice, provided that you also meet, for each linked + independent module, the terms and conditions of the license of that + module. An independent module is a module which is not derived from or + based on this library. If you modify this library, you may extend this + exception to your version of the library, but you are not obligated to + do so. If you do not wish to do so, delete this exception statement + from your version.
diff --git a/NOTICE.md b/NOTICE.md new file mode 100644 index 0000000..48252b0 --- /dev/null +++ b/NOTICE.md
@@ -0,0 +1,42 @@ +# Notices for Jakarta JSON Binding + +This content is produced and maintained by the Jakarta JSON Binding project. + +* Project home: https://projects.eclipse.org/projects/ee4j.jsonb + +## Trademarks + +Jakarta JSON Binding™ is a trademark of the Eclipse Foundation. + +## Copyright + +All content is the property of the respective authors or their employers. For +more information regarding authorship of content, please consult the listed +source code repository logs. + +## Declared Project Licenses + +This program and the accompanying materials are made available under the terms +of the Eclipse Public License v. 2.0 which is available at +https://www.eclipse.org/legal/epl-2.0. This Source Code may also be made +available under the following Secondary Licenses when the conditions for such +availability set forth in the Eclipse Public License v. 2.0 are satisfied: +GPL-2.0 with Classpath-exception-2.0 which is available at +https://openjdk.java.net/legal/gplv2+ce.html. + +SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0 + +## Source Code + +The project maintains the following source code repositories: + +* https://github.com/jakartaee/jsonb-api + +## Cryptography + +Content may contain encryption software. The country in which you are currently +may have restrictions on the import, possession, and use, and/or re-export to +another country, of encryption software. BEFORE using any encryption software, +please check the country's laws, regulations and policies concerning the import, +possession, or use, and re-export of encryption software, to see if this is +permitted.
diff --git a/README.md b/README.md new file mode 100644 index 0000000..d67ed86 --- /dev/null +++ b/README.md
@@ -0,0 +1,67 @@ +# Jakarta JSON Binding (JSON-B) + +[](https://mvnrepository.com/artifact/jakarta.json.bind/jakarta.json.bind-api) +[](https://javadoc.io/doc/jakarta.json.bind/jakarta.json.bind-api) +[](https://jakarta.oss.sonatype.org/content/repositories/staging/jakarta/json/bind/jakarta.json.bind-api/) +[](https://gitter.im/eclipse/jsonb) +[](https://opensource.org/licenses/EPL-2.0) + +JSON-B is a standard binding layer for converting Java objects to/from JSON messages. It defines a default mapping algorithm for converting existing Java classes to JSON, while enabling developers to customize the mapping process through the use of Java annotations. + +## Get it + +### Maven +```xml +<!-- https://mvnrepository.com/artifact/jakarta.json.bind/jakarta.json.bind-api --> +<dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-api</artifactId> + <version>3.0.0</version> +</dependency> +``` + +## Mapping a simple class + +Suppose we have the following Java object, which we want to represent with JSON data: +```java +public class User { + public long id; + public String name; + public int age; +} +``` + +Using the default mapping, this class can be serialized (as-is) to a JSON string: +```java +Jsonb jsonb = JsonbBuilder.create(); + +User bob = new User(); +bob.id = 1234; +bob.name = "Bob"; +bob.age = 42; + +String bobJson = jsonb.toJson(bob); +System.out.println(bobJson); // {"id":1234,"name":"Bob","age":42} +``` + +Likewise, JSON data can be deserialized back into Java objects: +```java +Jsonb jsonb = JsonbBuilder.create(); + +String aliceJson = "{\"id\":5678,\"name\":\"Alice\",\"age\":42}"; +User alice = jsonb.fromJson(aliceJson, User.class); +``` + +## How to run the TCK tests + +The JSON-B TCK tests are produced as a Maven artifact where the tests use Arquillian + JUnit. To run the TCK tests using your implementation, +include the TCK module and apply the appropriate Arquillian container. See the [Eclipse Yasson](https://github.com/eclipse-ee4j/yasson) repository for an example of this. + +## Links + +- [Official web site](https://jakartaee.github.io/jsonb-api) +- [Eclipse project](https://projects.eclipse.org/projects/ee4j.jsonb) +- [User's Guide](https://jakartaee.github.io/jsonb-api/docs/user-guide.html) +- [Jenkins Builds](https://ci.eclipse.org/jsonb/view/all/) +- [Mailing list](https://www.eclipse.org/lists/jsonb-dev/) +- [Yasson (Compatible Implementation)](https://github.com/eclipse-ee4j/yasson)
diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..fcdbb76 --- /dev/null +++ b/SECURITY.md
@@ -0,0 +1,21 @@ +# Security Policy + +This project implements the Eclipse Foundation Security Policy + +* https://www.eclipse.org/security + +## Supported Versions + +These versions of Jakarta JSON Binding are currently being supported with +security updates. + +| Version | Released | Supported | +| ------- | ---------- | --------- | +| 3.0.0 | 2022-03-31 | Yes | +| 2.0.0 | 2020-10-07 | Yes | +| < 1.0.2 | 2019-09-10 | No | + +## Reporting a Vulnerability + +Please report vulnerabilities to the Eclipse Foundation Security Team at +security@eclipse.org
diff --git a/api/pom.xml b/api/pom.xml new file mode 100644 index 0000000..16d689b --- /dev/null +++ b/api/pom.xml
@@ -0,0 +1,491 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2016, 2024 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.ee4j</groupId> + <artifactId>project</artifactId> + <version>1.0.9</version> + </parent> + + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-api</artifactId> + <version>3.0.1</version> + <packaging>jar</packaging> + + <name>JSON-B API</name> + <description>Jakarta JSON Binding is a standard binding layer for converting Java objects to/from JSON documents.</description> + <inceptionYear>2016</inceptionYear> + <url>https://jakartaee.github.io/jsonb-api</url> + + <issueManagement> + <system>github</system> + <url>https://github.com/jakartaee/jsonb-api/issues</url> + </issueManagement> + + <mailingLists> + <mailingList> + <name>Mailing list</name> + <archive>jsonb-dev@eclipse.org</archive> + </mailingList> + </mailingLists> + + <licenses> + <license> + <name>Eclipse Public License 2.0</name> + <url>https://projects.eclipse.org/license/epl-2.0</url> + <distribution>repo</distribution> + </license> + <license> + <name>GNU General Public License, version 2 with the GNU Classpath Exception</name> + <url>https://projects.eclipse.org/license/secondary-gpl-2.0-cp</url> + <distribution>repo</distribution> + </license> + </licenses> + + <scm> + <connection>scm:git:git://github.com/jakartaee/jsonb-api.git</connection> + <developerConnection>scm:git:git@github.com:jakartaee/jsonb-api.git</developerConnection> + <url>https://github.com/jakartaee/jsonb-api</url> + <tag>HEAD</tag> + </scm> + + <developers> + <developer> + <id>m0mus</id> + <name>Dmitry Kornilov</name> + <email>dmitry.kornilov@oracle.com</email> + <url>https://dmitrykornilov.net</url> + <organization>Oracle</organization> + <roles> + <role>Project Lead</role> + </roles> + <timezone>CET</timezone> + </developer> + </developers> + + <properties> + <release.spec.feedback>jsonb-dev@eclipse.org</release.spec.feedback> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <milestone.number>01</milestone.number> + <new.spec.version>3.0.0</new.spec.version> + <non.final>false</non.final> + <skip.release.tests>false</skip.release.tests> + <spec.version>3.0</spec.version> + <jakarta.json.version>2.1.3</jakarta.json.version> + <!-- The version of JSON-B API to compare against to verify we follow semantic versioning rules --> + <baseline.compare.version>2.0.0</baseline.compare.version> + <api_package>jakarta.json.bind</api_package> + <legal.doc.source>${project.basedir}/..</legal.doc.source> + <vendor.name>Oracle Corporation</vendor.name> + + <copyright.exclude>${project.basedir}/../etc/config/copyright-exclude</copyright.exclude> + <copyright.templatefile>${project.basedir}/../etc/config/epl-copyright.txt</copyright.templatefile> + <copyright.bsdTemplateFile>${project.basedir}/../etc/config/edl-copyright.txt</copyright.bsdTemplateFile> + <copyright.ignoreyear>true</copyright.ignoreyear> + <copyright.scmonly>true</copyright.scmonly> + <copyright.update>false</copyright.update> + + <spotbugs.exclude>${project.basedir}/../etc/config/spotbugs-exclude.xml</spotbugs.exclude> + <spotbugs.skip>false</spotbugs.skip> + <spotbugs.threshold>Low</spotbugs.threshold> + <spotbugs.version>4.8.3.1</spotbugs.version> + + <maven.compiler.release>11</maven.compiler.release> + <maven.compiler.testRelease>${maven.compiler.release}</maven.compiler.testRelease> + </properties> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>jakarta.json</groupId> + <artifactId>jakarta.json-api</artifactId> + <version>${jakarta.json.version}</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.13.2</version> + <scope>test</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <dependencies> + <dependency> + <groupId>jakarta.json</groupId> + <artifactId>jakarta.json-api</artifactId> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>final</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <properties> + <!-- Final API bundle version properties --> + <non.final>false</non.final> + </properties> + </profile> + <profile> + <!-- Use it with release-perform goal to skip another test run. --> + <id>skip-tests</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <properties> + <skip.release.tests>true</skip.release.tests> + </properties> + </profile> + <profile> + <id>release</id> + <activation> + <activeByDefault>false</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + </plugin> + </plugins> + </build> + </profile> + </profiles> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.5.0</version> + </plugin> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <version>${spotbugs.version}</version> + <configuration> + <skip>${spotbugs.skip}</skip> + <threshold>${spotbugs.threshold}</threshold> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.12.1</version> + <configuration> + <compilerArgs> + <arg>-Xlint:all</arg> + </compilerArgs> + </configuration> + </plugin> + <plugin> + <!-- This plugin generates the buildNumber property used in maven-bundle-plugin --> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + <version>3.2.0</version> + <configuration> + <format>{0,date,MM/dd/yyyy hh:mm aa}</format> + <items> + <item>timestamp</item> + </items> + </configuration> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>create</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <!-- This plugin generates the spec.* properties used in maven-bundle-plugin --> + <groupId>org.glassfish.build</groupId> + <artifactId>spec-version-maven-plugin</artifactId> + <version>2.2</version> + <configuration> + <spec> + <nonFinal>${non.final}</nonFinal> + <jarType>api</jarType> + <specVersion>${spec.version}</specVersion> + <newSpecVersion>${new.spec.version}</newSpecVersion> + <specBuild>${milestone.number}</specBuild> + <specImplVersion>${project.version}</specImplVersion> + <apiPackage>${api_package}</apiPackage> + </spec> + </configuration> + <executions> + <execution> + <goals> + <goal>set-spec-properties</goal> + <!-- TODO: Enable when spec version plugin is fixed. --> + <!--goal>check-module</goal--> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <version>5.1.9</version> + <extensions>true</extensions> + <configuration> + <archive> + <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> + </archive> + <instructions> + <Build-Id>${buildNumber}</Build-Id> + <Bundle-Description>Java API for JSON Binding (JSON-Binding)</Bundle-Description> + <Bundle-Version>${spec.bundle.version}</Bundle-Version> + <Bundle-SymbolicName>${spec.bundle.symbolic-name}</Bundle-SymbolicName> + <DynamicImport-Package>*</DynamicImport-Package> + <Extension-Name>${spec.extension.name}</Extension-Name> + <Implementation-Version>${spec.implementation.version}</Implementation-Version> + <Specification-Version>${spec.specification.version}</Specification-Version> + <Specification-Vendor>${vendor.name}</Specification-Vendor> + <_nodefaultversion>false</_nodefaultversion> + <Export-Package>jakarta.json.bind.*; version=${spec.version}</Export-Package> + <_noee>true</_noee> + </instructions> + </configuration> + <executions> + <execution> + <id>osgi-bundle</id> + <phase>process-classes</phase> + <goals> + <goal>manifest</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.3.0</version> + <configuration> + <archive> + <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile> + </archive> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-javadoc-plugin</artifactId> + <version>3.6.3</version> + <configuration> + <doctitle>Jakarta JSON Binding ${project.version} API Specification</doctitle> + <sourceFileExcludes> + <sourceFileExclude>**/module-info.java</sourceFileExclude> + <sourceFileExclude>target/**/*.java</sourceFileExclude> + </sourceFileExcludes> + <docfilessubdirs>true</docfilessubdirs> + <links> + <link>http://docs.oracle.com/en/java/javase/11/docs/api/</link> + </links> + <detectJavaApiLink>false</detectJavaApiLink> + <detectOfflineLinks>false</detectOfflineLinks> + <header><![CDATA[<br>Jakarta JSON Binding API v${project.version}]]> + </header> + <bottom><![CDATA[ + Comments to: <a href="mailto:${release.spec.feedback}">${release.spec.feedback}</a>.<br> + Copyright © 2019, 2024 Eclipse Foundation. All Rights Reserved.<br> + Use is subject to <a href="{@docRoot}/doc-files/EFSL.html" target="_top">license terms</a>.]]> + </bottom> + </configuration> + <executions> + <execution> + <id>attach-javadocs</id> + <goals> + <goal>jar</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <version>3.2.1</version> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + <version>3.3.2</version> + <executions> + <execution> + <goals> + <goal>jxr</goal> + </goals> + <phase>validate</phase> + </execution> + </executions> + </plugin> + <plugin> + <!-- e.g. mvn validate glassfish-copyright:repair --> + <groupId>org.glassfish.copyright</groupId> + <artifactId>glassfish-copyright-maven-plugin</artifactId> + <version>2.4</version> + <configuration> + <excludeFile>${copyright.exclude}</excludeFile> + <scmOnly>${copyright.scmonly}</scmOnly> + <update>${copyright.update}</update> + <ignoreYear>${copyright.ignoreyear}</ignoreYear> + <quiet>false</quiet> + <templateFile>${copyright.templatefile}</templateFile> + <bsdTemplateFile>${copyright.bsdTemplateFile}</bsdTemplateFile> + </configuration> + <executions> + <execution> + <phase>verify</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>3.3.1</version> + <dependencies> + <dependency> + <groupId>com.puppycrawl.tools</groupId> + <artifactId>checkstyle</artifactId> + <version>8.29</version> + </dependency> + </dependencies> + <configuration> + <outputFile>${project.build.directory}/checkstyle/checkstyle-result.xml</outputFile> + <configLocation>${basedir}/../etc/config/checkstyle.xml</configLocation> + <failOnViolation>true</failOnViolation> + <failsOnError>true</failsOnError> + <excludes>**/module-info.java</excludes> + </configuration> + <executions> + <execution> + <goals> + <goal>check</goal> + </goals> + <phase>compile</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-gpg-plugin</artifactId> + <version>3.1.0</version> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-legal-resource</id> + <phase>generate-resources</phase> + <goals> + <goal>add-resource</goal> + </goals> + <configuration> + <resources> + <resource> + <directory>${legal.doc.source}</directory> + <includes> + <include>NOTICE.md</include> + <include>LICENSE.md</include> + </includes> + <targetPath>META-INF</targetPath> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>buildnumber-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.glassfish.copyright</groupId> + <artifactId>glassfish-copyright-maven-plugin</artifactId> + </plugin> + <!-- Ensures that we follow semantic versioning rules --> + <plugin> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-baseline-maven-plugin</artifactId> + <version>6.0.0</version> + <configuration> + <base> + <version>${baseline.compare.version}</version> + </base> + </configuration> + <executions> + <execution> + <id>baseline</id> + <goals> + <goal>baseline</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>com.github.spotbugs</groupId> + <artifactId>spotbugs-maven-plugin</artifactId> + <configuration> + <fork>true</fork> + <excludeFilterFile>${spotbugs.exclude}</excludeFilterFile> + <failThreshold>High</failThreshold> + </configuration> + </plugin> + </plugins> + </build> +</project>
diff --git a/api/src/main/java/jakarta/json/bind/Jsonb.java b/api/src/main/java/jakarta/json/bind/Jsonb.java new file mode 100644 index 0000000..093d480 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/Jsonb.java
@@ -0,0 +1,360 @@ +/* + * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind; + +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.lang.reflect.Type; + +/** + * <p>{@code Jsonb} provides an abstraction over the JSON Binding framework operations:</p> + * + * <ul> + * <li>{@code fromJson}: read JSON input, deserialize to Java objects content tree + * <li>{@code toJson}: serialize Java objects content tree to JSON input + * </ul> + * + * <p>Instance of this class is created using {@link jakarta.json.bind.JsonbBuilder JsonbBuilder} + * builder methods:</p> + * <pre>{@code + * // Example 1 - Creating Jsonb using default JsonbBuilder instance provided by default JsonbProvider + * Jsonb jsonb = JsonbBuilder.create(); + * + * // Example 2 - Creating Jsonb instance for a specific provider specified by a class name + * Jsonb jsonb = JsonbBuilder.newBuilder("foo.bar.ProviderImpl).build(); + * + * // Example 3 - Creating Jsonb instance from a custom provider implementation + * Jsonb jsonb = new CustomJsonbBuilder().build(); + * }</pre> + * + * <b>Deserializing (reading) JSON</b><br> + * <blockquote> + * Can de-serialize JSON data that represents either an entire JSON + * document or a subtree of a JSON document. + * </blockquote> + * <blockquote> + * Reading (deserializing) object content tree from a File:<br><br> + * <pre> + * Jsonb jsonb = JsonbBuilder.create(); + * Book book = jsonb.fromJson(new FileReader("jsonfile.json"), Book.class);</pre> + * If the deserialization process is unable to deserialize the JSON content to an object + * content tree, fatal error is reported that terminates processing by + * throwing JsonbException. + * </blockquote> + * + * <p><b>Serializing (writing) to JSON</b></p> + * <blockquote> + * Serialization writes the representation of a Java object content tree into + * JSON data. + * </blockquote> + * <blockquote> + * Writing (serializing) object content tree to a File:<br><br> + * <pre> + * jsonb.toJson(object, new FileWriter("foo.json"));</pre> + * Writing (serializing) to a Writer:<br><br> + * <pre> + * jsonb.toJson(object, new PrintWriter(System.out)); + * </pre> + * </blockquote> + * + * <p><b>Encoding</b></p> + * <blockquote> + * In deserialization operations ({@code fromJson}), encoding of JSON data is detected automatically. + * Use the {@link jakarta.json.bind.JsonbConfig JsonbConfig} API to configure expected + * input encoding used within deserialization operations. Client applications are + * expected to supply a valid character encoding as defined in the + * <a href="http://tools.ietf.org/html/rfc7159">RFC 7159</a> and supported by Java Platform. + * + * In serialization operations ({@code toJson}), UTF-8 encoding is used by default + * for writing JSON data. + * Use the {@link jakarta.json.bind.JsonbConfig JsonbConfig} API to configure the + * output encoding used within serialization operations. Client applications are + * expected to supply a valid character encoding as defined in the + * <a href="http://tools.ietf.org/html/rfc7159">RFC 7159</a> and supported by Java Platform. + * </blockquote> + * + * <p>For optimal use, {@code JsonbBuilder} and {@code Jsonb} instances should be + * reused - for a typical use-case, only one {@code Jsonb} instance is + * required by an application.</p> + * + * <p>All the methods in this class are safe for use by multiple concurrent threads.</p> + * + * <p>Calling {@code Closable.close()} method will cleanup all CDI managed components + * (such as adapters with CDI dependencies) created during interaction with Jsonb. + * Calling {@code close()} must be done after all threads has finished interaction with Jsonb. + * If there are remaining threads working with Jsonb and {@code close()} is called, behaviour is undefined. + * </p> + * + * @see Jsonb + * @see JsonbBuilder + * @see java.util.ServiceLoader + * @since JSON Binding 1.0 + */ +public interface Jsonb extends AutoCloseable { + + /** + * Reads in a JSON data from the specified string and return the resulting + * content tree. + * + * @param str + * The string to deserialize JSON data from. + * @param type + * Type of the content tree's root object. + * @param <T> + * Type of the content tree's root object. + * + * @return the newly created root object of the java content tree + * + * @throws JsonbException + * If any unexpected error(s) occur(s) during deserialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + */ + <T> T fromJson(String str, Class<T> type) throws JsonbException; + + /** + * Reads in a JSON data from the specified string and return the resulting + * content tree. + * + * @param str + * The string to deserialize JSON data from. + * @param runtimeType + * Runtime type of the content tree's root object. + * @param <T> + * Type of the content tree's root object. + * + * @return the newly created root object of the java content tree + * + * @throws JsonbException + * If any unexpected error(s) occur(s) during deserialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + */ + <T> T fromJson(String str, Type runtimeType) throws JsonbException; + + /** + * Reads in a JSON data from the specified Reader and return the + * resulting content tree. + * + * @param reader + * The character stream is read as a JSON data. + * @param type + * Type of the content tree's root object. + * @param <T> + * Type of the content tree's root object. + * + * @return the newly created root object of the java content tree + * + * @throws JsonbException + * If any unexpected error(s) occur(s) during deserialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + */ + <T> T fromJson(Reader reader, Class<T> type) throws JsonbException; + + /** + * Reads in a JSON data from the specified Reader and return the + * resulting content tree. + * + * @param reader + * The character stream is read as a JSON data. + * + * @param runtimeType + * Runtime type of the content tree's root object. + * + * @param <T> + * Type of the content tree's root object. + * + * @return the newly created root object of the java content tree + * + * @throws JsonbException + * If any unexpected error(s) occur(s) during deserialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + */ + <T> T fromJson(Reader reader, Type runtimeType) throws JsonbException; + + /** + * Reads in a JSON data from the specified InputStream and return the + * resulting content tree. + * + * @param stream + * The stream is read as a JSON data. Upon a + * successful completion, the stream will be closed by this method. + * @param type + * Type of the content tree's root object. + * @param <T> + * Type of the content tree's root object. + * + * @return the newly created root object of the java content tree + * + * @throws JsonbException + * If any unexpected error(s) occur(s) during deserialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + */ + <T> T fromJson(InputStream stream, Class<T> type) throws JsonbException; + + /** + * Reads in a JSON data from the specified InputStream and return the + * resulting content tree. + * + * @param stream + * The stream is read as a JSON data. Upon a + * successful completion, the stream will be closed by this method. + * + * @param runtimeType + * Runtime type of the content tree's root object. + * + * @param <T> + * Type of the content tree's root object. + * + * @return the newly created root object of the java content tree + * + * @throws JsonbException + * If any unexpected error(s) occur(s) during deserialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + */ + <T> T fromJson(InputStream stream, Type runtimeType) throws JsonbException; + + /** + * Writes the Java object tree with root object {@code object} to a String + * instance as JSON. + * + * @param object + * The root object of the object content tree to be serialized. Must not be null. + * + * @return String instance with serialized JSON data. + * + * @throws JsonbException If any unexpected problem occurs during the + * serialization, such as I/O error. + * @throws NullPointerException + * If any of the parameters is {@code null}. + * + * @since JSON Binding 1.0 + */ + String toJson(Object object) throws JsonbException; + + /** + * Writes the Java object tree with root object {@code object} to a String + * instance as JSON. + * + * @param object + * The root object of the object content tree to be serialized. Must not be null. + * + * @param runtimeType + * Runtime type of the content tree's root object. Provided type needs to be + * related to the type of the instance. + * + * @return String instance with serialized JSON data. + * + * @throws JsonbException If any unexpected problem occurs during the + * serialization, such as I/O error. + * @throws NullPointerException + * If any of the parameters is {@code null}. + * + * @since JSON Binding 1.0 + */ + String toJson(Object object, Type runtimeType) throws JsonbException; + + /** + * Writes the object content tree into a Writer character stream. + * + * @param object + * The object content tree to be serialized. + * @param writer + * The JSON will be sent as a character stream to the given + * {@link Writer}. + * + * @throws JsonbException If any unexpected problem occurs during the + * serialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + * + * @since JSON Binding 1.0 + */ + void toJson(Object object, Writer writer) throws JsonbException; + + /** + * Writes the object content tree into a Writer character stream. + * + * @param object + * The object content tree to be serialized. + * + * @param runtimeType + * Runtime type of the content tree's root object. Provided type needs to be + * related to the type of the instance. + * + * @param writer + * The JSON will be sent as a character stream to the given + * {@link Writer}. + * + * @throws JsonbException If any unexpected problem occurs during the + * serialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + * + * @since JSON Binding 1.0 + */ + void toJson(Object object, Type runtimeType, Writer writer) throws JsonbException; + + /** + * Writes the object content tree into output stream. + * + * @param object + * The object content tree to be serialized. + * @param stream + * The JSON will be sent as a byte stream to the given + * {@link OutputStream}. Upon a successful completion, the stream will be closed + * by this method. + * + * @throws JsonbException If any unexpected problem occurs during the + * serialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + * + * @since JSON Binding 1.0 + */ + void toJson(Object object, OutputStream stream) throws JsonbException; + + /** + * Writes the object content tree into output stream. + * + * @param object + * The object content tree to be serialized. + * + * @param runtimeType + * Runtime type of the content tree's root object. Provided type needs to be + * related to the type of the instance. + * + * @param stream + * The JSON will be sent as a byte stream to the given + * {@link OutputStream}. Upon a successful completion, the stream will be closed + * by this method. + * + * @throws JsonbException If any unexpected problem occurs during the + * serialization. + * @throws NullPointerException + * If any of the parameters is {@code null}. + * + * @since JSON Binding 1.0 + */ + void toJson(Object object, Type runtimeType, OutputStream stream) throws JsonbException; +}
diff --git a/api/src/main/java/jakarta/json/bind/JsonbBuilder.java b/api/src/main/java/jakarta/json/bind/JsonbBuilder.java new file mode 100644 index 0000000..db85422 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/JsonbBuilder.java
@@ -0,0 +1,142 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind; + +import jakarta.json.bind.spi.JsonbProvider; + +import jakarta.json.spi.JsonProvider; + +/** + * JsonbBuilder class provides the client's entry point to the JSON Binding + * API. It builds {@link jakarta.json.bind.Jsonb Jsonb} instances based on all + * parameters and configuration provided before calling {@code build()} method. + * + * For most use-cases, only one instance of JsonbBuilder is required within the + * application. + * + * @see Jsonb + * @see java.util.ServiceLoader + * @since JSON Binding 1.0 + */ +public interface JsonbBuilder { + + /** + * Set configuration which will be set to the newly created + * {@link jakarta.json.bind.Jsonb Jsonb} instance. + * + * @param config + * Configuration for {@link jakarta.json.bind.Jsonb Jsonb} instance. + * + * @return This {@code JsonbBuilder} instance. + */ + JsonbBuilder withConfig(JsonbConfig config); + + /** + * Provides a <a href="https://projects.eclipse.org/projects/ee4j.jsonp/">JSON-P</a> provider + * to be used for all <a href="https://projects.eclipse.org/projects/ee4j.jsonp/">JSON-P</a> related operations. + * + * @param jsonpProvider + * {@link jakarta.json.spi.JsonProvider JsonProvider} instance + * to be used by Jsonb to lookup JSON-P implementation. + * + * @return This {@code JsonbBuilder} instance. + */ + JsonbBuilder withProvider(JsonProvider jsonpProvider); + + /** + * Returns a new instance of {@link jakarta.json.bind.Jsonb Jsonb} based on the + * parameters and configuration specified previously in this builder. + * + * @return Jsonb A new instance of {@link jakarta.json.bind.Jsonb Jsonb} class. + * Always a non-null valid object. + * + * @throws jakarta.json.bind.JsonbException If an error was encountered while + * creating the Jsonb instance, such as (but not limited to) no JSON + * Binding provider found, or classes provide conflicting annotations. + * + * @throws IllegalArgumentException If there's an error processing the set + * parameters, such as the non-null parameter is assigned null value, or + * unrecognized property is set in + * {@link jakarta.json.bind.JsonbConfig JsonbConfig}. + */ + Jsonb build(); + + /** + * Create a new {@link jakarta.json.bind.Jsonb} instance using the default + * {@code JsonbBuilder} implementation provided as returned from + * {@link jakarta.json.bind.spi.JsonbProvider#provider()} method. + * + * @return new {@link jakarta.json.bind.Jsonb Jsonb} instance. + */ + static Jsonb create() { + return JsonbProvider.provider().create().build(); + } + + /** + * Create a new {@link jakarta.json.bind.Jsonb} instance using the default + * {@code JsonbBuilder} implementation provided as returned from + * {@link jakarta.json.bind.spi.JsonbProvider#provider()} method, configured + * with provided configuration. + * + * @param config + * Provided configuration for {@link jakarta.json.bind.Jsonb} instance. + * + * @return new {@link jakarta.json.bind.Jsonb Jsonb} instance. + */ + static Jsonb create(JsonbConfig config) { + return JsonbProvider.provider().create().withConfig(config).build(); + } + + /** + * Create a new {@code JsonbBuilder} instance as returned by the default + * {@link jakarta.json.bind.spi.JsonbProvider#provider()} method. + * + * @return new {@code JsonbBuilder} instance. + */ + static JsonbBuilder newBuilder() { + return JsonbProvider.provider().create(); + } + + /** + * Create a new {@code JsonbBuilder} instance as returned by + * {@link jakarta.json.bind.spi.JsonbProvider#provider(String)} + * method. + * + * @param providerName + * Provider class name to be looked up by {@link java.util.ServiceLoader ServiceLoader}. + * + * @return new {@code JsonbBuilder} instance. + */ + static JsonbBuilder newBuilder(final String providerName) { + return JsonbProvider.provider(providerName).create(); + } + + /** + * Create a new {@code JsonbBuilder} instance as returned by + * {@code provider#create} call. + * + * @param provider + * {@link jakarta.json.spi.JsonProvider JsonProvider} instance + * used for creating {@code JsonBuilder instances}. + * + * @return new {@code JsonbBuilder} instance. + */ + static JsonbBuilder newBuilder(final JsonbProvider provider) { + return provider.create(); + } + +}
diff --git a/api/src/main/java/jakarta/json/bind/JsonbConfig.java b/api/src/main/java/jakarta/json/bind/JsonbConfig.java new file mode 100644 index 0000000..1ba5f27 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/JsonbConfig.java
@@ -0,0 +1,437 @@ +/* + * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind; + +import jakarta.json.bind.adapter.JsonbAdapter; + +import jakarta.json.bind.config.PropertyNamingStrategy; +import jakarta.json.bind.config.PropertyVisibilityStrategy; + +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.bind.serializer.JsonbSerializer; + +import java.lang.reflect.Array; +import java.util.Collections; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; + +/** + * <p> + * <a id="supportedProps"></a> + * <b>Supported Properties</b><br> + * <blockquote> + * <p> + * All JSON Binding providers are required to support the following set of properties. + * Some providers may support additional properties. + * <dl> + * <dt><code>jsonb.to.json.formatted</code> - java.lang.Boolean + * <dd>Controls whether or not the {@link jakarta.json.bind.Jsonb Jsonb} {@code toJson()} + * methods will format the resulting JSON data with line breaks and indentation. A + * true value for this property indicates human readable indented + * data, while a false value indicates unformatted data. + * Default value is false (unformatted) if this property is not specified. + * </dl> + * <dl> + * <dt><code>jsonb.to.json.encoding</code> - java.lang.String + * <dd>The {@link jakarta.json.bind.Jsonb Jsonb} serialization {@code toJson()} methods + * will default to this property for encoding of output JSON data. Default + * value is 'UTF-8' if this property is not specified. + * </dl> + * <dl> + * <dt><code>jsonb.from.json.encoding</code> - java.lang.String + * <dd>The {@link jakarta.json.bind.Jsonb Jsonb} deserialization {@code fromJson()} + * methods will default to this property encoding of input JSON data if the + * encoding cannot be detected. + * </dl> + * </blockquote> + * + * This object is not thread safe. Implementations are expected to make a defensive copy + * of the object before applying the configuration. + * + * @since JSON Binding 1.0 + */ +public class JsonbConfig { + + private final Map<String, Object> configuration = new HashMap<>(); + + /** + * Property used to specify whether or not the serialized + * JSON data is formatted with line feeds and indentation. + */ + public static final String FORMATTING = "jsonb.formatting"; + + /** + * The Jsonb serialization {@code toJson()} methods will default to this property + * for encoding of output JSON data. Default value is 'UTF-8'. + * + * The Jsonb deserialization {@code fromJson()} methods will default to this + * property encoding of input JSON data if the encoding cannot be detected + * automatically. + */ + public static final String ENCODING = "jsonb.encoding"; + + /** + * Property used to specify custom naming strategy. + */ + public static final String PROPERTY_NAMING_STRATEGY = "jsonb.property-naming-strategy"; + + /** + * Property used to specify custom order strategy. + */ + public static final String PROPERTY_ORDER_STRATEGY = "jsonb.property-order-strategy"; + + /** + * Property used to specify null values serialization behavior. + */ + public static final String NULL_VALUES = "jsonb.null-values"; + + /** + * Property used to specify strict I-JSON serialization compliance. + */ + public static final String STRICT_IJSON = "jsonb.strict-ijson"; + + /** + * Property used to specify custom visibility strategy. + */ + public static final String PROPERTY_VISIBILITY_STRATEGY = "jsonb.property-visibility-strategy"; + + /** + * Property used to specify custom mapping adapters for generic types. + */ + public static final String ADAPTERS = "jsonb.adapters"; + + /** + * Property used to specify custom serializers. + */ + public static final String SERIALIZERS = "jsonb.serializers"; + + /** + * Property used to specify custom deserializers. + */ + public static final String DESERIALIZERS = "jsonb.derializers"; + + /** + * Property used to specify custom binary data strategy. + */ + public static final String BINARY_DATA_STRATEGY = "jsonb.binary-data-strategy"; + + /** + * Property used to specify custom date format globally. + */ + public static final String DATE_FORMAT = "jsonb.date-format"; + + /** + * Property used to specify locale globally. + */ + public static final String LOCALE = "jsonb.locale"; + + /** + * Property used to specify required creator parameters. + */ + public static final String CREATOR_PARAMETERS_REQUIRED = "jsonb.creator-parameters-required"; + + /** + * Set the particular configuration property to a new value. The method can + * only be used to set one of the standard JSON Binding properties defined in + * this class or a provider specific property. + * + * @param name + * The name of the property to be set. This value can either + * be specified using one of the constant fields or a user supplied + * string. + * @param value + * The value of the property to be set + * + * @return This JsonbConfig instance. + * + * @throws NullPointerException if the name parameter is null. + */ + public final JsonbConfig setProperty(final String name, final Object value) { + configuration.put(name, value); + return this; + } + + /** + * Return value of particular configuration property. The method can + * only be used to retrieve one of the standard JSON Binding properties defined + * in this class or a provider specific property. Attempting to get an undefined + * property will result in an empty Optional value. + * See <a href="#supportedProps"> Supported Properties</a>. + * + * @param name + * The name of the property to retrieve + * + * @return The value of the requested property + * + * @throws NullPointerException if the name parameter is null. + */ + public final Optional<Object> getProperty(final String name) { + return Optional.ofNullable(configuration.get(name)); + } + + /** + * Return all configuration properties as an unmodifiable map. + * + * @return All configuration properties as an unmodifiable map + */ + public final Map<String, Object> getAsMap() { + return Collections.unmodifiableMap(configuration); + } + + /** + * Property used to specify whether or not the serialized JSON data is formatted + * with linefeeds and indentation. + * + * Configures value of {@link #FORMATTING} property. + * + * @param formatted + * True means serialized data is formatted, false (default) + * means no formatting. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withFormatting(final Boolean formatted) { + return setProperty(FORMATTING, formatted); + } + + /** + * Property used to specify whether null values should be serialized to JSON document or skipped. + * + * Configures value of {@link #NULL_VALUES} property. + * + * @param serializeNullValues + * True means that null values will be serialized into JSON document, + * otherwise they will be effectively skipped. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withNullValues(final Boolean serializeNullValues) { + return setProperty(NULL_VALUES, serializeNullValues); + } + + /** + * The binding operations will default to this property + * for encoding of JSON data. For input data (fromJson), selected encoding is used if + * the encoding cannot be detected automatically. Default value is 'UTF-8'. + * + * Configures value of {@link #ENCODING} property. + * + * @param encoding + * Valid character encoding as defined in the + * <a href="http://tools.ietf.org/html/rfc7159">RFC 7159</a> and supported by + * Java Platform. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withEncoding(final String encoding) { + return setProperty(ENCODING, encoding); + } + + /** + * Property used to specify whether strict I-JSON serialization compliance should be enforced. + * + * Configures value of {@link #STRICT_IJSON} property. + * + * @param enabled + * True means data is serialized in strict compliance according to RFC 7493. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withStrictIJSON(final Boolean enabled) { + return setProperty(STRICT_IJSON, enabled); + } + + /** + * Property used to specify custom naming strategy. + * + * Configures value of {@link #PROPERTY_NAMING_STRATEGY} property. + * + * @param propertyNamingStrategy + * Custom naming strategy which affects serialization and deserialization. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withPropertyNamingStrategy(final PropertyNamingStrategy propertyNamingStrategy) { + return setProperty(PROPERTY_NAMING_STRATEGY, propertyNamingStrategy); + } + + /** + * Property used to specify custom naming strategy. + * + * Configures value of {@link #PROPERTY_NAMING_STRATEGY} property. + * + * @param propertyNamingStrategy + * Predefined naming strategy which affects serialization and deserialization. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withPropertyNamingStrategy(final String propertyNamingStrategy) { + return setProperty(PROPERTY_NAMING_STRATEGY, propertyNamingStrategy); + } + + /** + * Property used to specify property order strategy. + * + * Configures values of {@link #PROPERTY_ORDER_STRATEGY} property. + * + * @param propertyOrderStrategy + * Predefined property order strategy which affects serialization. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withPropertyOrderStrategy(final String propertyOrderStrategy) { + return setProperty(PROPERTY_ORDER_STRATEGY, propertyOrderStrategy); + } + + /** + * Property used to specify custom property visibility strategy. + * + * Configures value of {@link #PROPERTY_VISIBILITY_STRATEGY} property. + * + * @param propertyVisibilityStrategy + * Custom property visibility strategy which affects serialization and deserialization. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withPropertyVisibilityStrategy(final PropertyVisibilityStrategy + propertyVisibilityStrategy) { + return setProperty(PROPERTY_VISIBILITY_STRATEGY, propertyVisibilityStrategy); + } + + /** + * Property used to specify custom mapping adapters. + * + * Configures value of {@link #ADAPTERS} property. + * + * Calling withAdapters more than once will merge the adapters with previous value. + * + * @param adapters + * Custom mapping adapters which affects serialization and deserialization. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withAdapters(final JsonbAdapter... adapters) { + mergeProperties(ADAPTERS, adapters, JsonbAdapter.class); + return this; + } + + /** + * Property used to specify custom serializers. + * + * Configures value of {@link #SERIALIZERS} property. + * + * Calling withSerializers more than once will merge the serializers with previous value. + * + * @param serializers + * Custom serializers which affects serialization. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withSerializers(final JsonbSerializer... serializers) { + mergeProperties(SERIALIZERS, serializers, JsonbSerializer.class); + return this; + } + + /** + * Property used to specify custom deserializers. + * + * Configures value of {@link #DESERIALIZERS} property. + * + * Calling withDeserializers more than once will merge the deserializers with previous value. + * + * @param deserializers + * Custom deserializers which affects deserialization. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withDeserializers(final JsonbDeserializer... deserializers) { + mergeProperties(DESERIALIZERS, deserializers, JsonbDeserializer.class); + return this; + } + + /** + * Property used to specify custom binary data strategy. + * + * Configures value of {@link #BINARY_DATA_STRATEGY} property. + * + * @param binaryDataStrategy + * Custom binary data strategy which affects serialization and deserialization. + * + * @return This JsonbConfig instance. + */ + public final JsonbConfig withBinaryDataStrategy(final String binaryDataStrategy) { + return setProperty(BINARY_DATA_STRATEGY, binaryDataStrategy); + } + + /** + * Property used to specify custom date format. This format will be used by default for all date classes + * serialization and deserialization. + * + * Configures values of {@link #DATE_FORMAT} and {@link #LOCALE} properties. + * + * @param dateFormat + * Custom date format as specified in {@link java.time.format.DateTimeFormatter}. + * @param locale + * Locale, if null is specified {@link Locale#getDefault} will be used. + * @return This JsonbConfig instance. + */ + public final JsonbConfig withDateFormat(final String dateFormat, final Locale locale) { + return setProperty(DATE_FORMAT, dateFormat) + .setProperty(LOCALE, locale != null ? locale : Locale.getDefault()); + } + + /** + * Property used to specify custom locale. + * + * Configures value of {@link #LOCALE} property. + * + * @param locale + * Locale, must not be null. + * @return This JsonbConfig instance. + */ + public final JsonbConfig withLocale(final Locale locale) { + return setProperty(LOCALE, locale); + } + + /** + * Property used to specify whether all creator parameters should be treated as required. + * <br> + * Default value is {@code false}. + * + * @param requiredParameters Whether creator parameters are required + * @return This JsonbConfig instance. + */ + public final JsonbConfig withCreatorParametersRequired(final boolean requiredParameters) { + return setProperty(CREATOR_PARAMETERS_REQUIRED, requiredParameters); + } + + @SuppressWarnings("unchecked") + private <T> void mergeProperties(final String propertyKey, final T[] values, final Class<T> tClass) { + final Optional<Object> property = getProperty(propertyKey); + if (!property.isPresent()) { + setProperty(propertyKey, values); + return; + } + T[] storedValues = (T[]) property.get(); + T[] newValues = (T[]) Array.newInstance(tClass, storedValues.length + values.length); + System.arraycopy(storedValues, 0, newValues, 0, storedValues.length); + System.arraycopy(values, 0, newValues, storedValues.length, values.length); + setProperty(propertyKey, newValues); + } +}
diff --git a/api/src/main/java/jakarta/json/bind/JsonbException.java b/api/src/main/java/jakarta/json/bind/JsonbException.java new file mode 100644 index 0000000..046a38d --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/JsonbException.java
@@ -0,0 +1,61 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind; + +/** + * Root class for all JSON Binding exceptions. + * + * @since JSON Binding 1.0 + */ +public class JsonbException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + /** + * Constructs a new runtime exception with the specified detail message. + * The cause is not initialized, and may subsequently be initialized by a + * call to {@link #initCause}. + * + * @param message + * The detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ + public JsonbException(final String message) { + super(message); + } + + /** + * Constructs a new runtime exception with the specified detail message and + * cause. <p>Note that the detail message associated with + * {@code cause} is <i>not</i> automatically incorporated in + * this runtime exception's detail message. + * + * @param message + * The detail message (which is saved for later retrieval + * by the {@link #getMessage()} method). + * @param cause + * The cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A {@code null} value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + */ + public JsonbException(final String message, final Throwable cause) { + super(message, cause); + } + +} +
diff --git a/api/src/main/java/jakarta/json/bind/adapter/JsonbAdapter.java b/api/src/main/java/jakarta/json/bind/adapter/JsonbAdapter.java new file mode 100644 index 0000000..90f6fa5 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/adapter/JsonbAdapter.java
@@ -0,0 +1,89 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.adapter; + +/** + * <p>Allows to define custom mapping for given java type. The target type could be string or some + * mappable java type.</p> + * + * <p>On serialization "Original" type is converted into "Adapted" type. After that "Adapted" type is serialized to + * JSON the standard way.</p> + * + * <p>On deserialization it works the reverse way: JSON data are deserialized into "Adapted" type which is converted + * to "Original" type after that.</p> + * + * <p>Adapters are registered using {@link jakarta.json.bind.JsonbConfig#withAdapters(JsonbAdapter[])} method + * or using {@link jakarta.json.bind.annotation.JsonbTypeAdapter} annotation on class field.</p> + * + * @param <Original> The type that JSONB doesn't know how to handle + * @param <Adapted> The type that JSONB knows how to handle out of the box + * + * <p>Adapter runtime "Original" and "Adapted" generic types are inferred from subclassing information, + * which is mandatory for adapter to work.</p> + * + * <p>Sample 1:</p> + * <pre> + * {@code + * // Generic information is provided by subclassing. + * class BoxToCrateAdapter implements JsonbAdapter<Box<Integer>, Crate<String>> {...}; + * jsonbConfig.withAdapters(new BoxToCrateAdapter()); + * + * // Generic information is provided by subclassing with anonymous class + * jsonbConfig.withAdapters(new JsonbAdapter<Box<Integer>, Crate<String>> {...}); + * } + * </pre> + * + * <p>Sample 2:</p> + * <pre> + * {@code + * BoxToCrateAdapter<T> implements JsonbAdapter<Box<T>, Integer> {...}; + * + * // Bad way: Generic type information is lost due to type erasure + * jsonbConfig.withAdapters(new BoxToCrateAdapter<Integer>()); + * + * // Proper way: Anonymous class holds generic type information + * jsonbConfig.withAdapters(new BoxToCrateAdapter<Integer>(){}); + * } + * </pre> + * + * @see jakarta.json.bind.JsonbConfig + * @see jakarta.json.bind.annotation.JsonbTypeAdapter + * @since JSON Binding 1.0 + */ +public interface JsonbAdapter<Original, Adapted> { + + /** + * This method is used on serialization only. It contains a conversion logic from type Original to type Adapted. + * After conversion Adapted type will be mapped to JSON the standard way. + * + * @param obj + * Object to convert or {@code null}. + * @return Converted object which will be serialized to JSON or {@code null}. + * @throws Exception if there is an error during the conversion. + */ + Adapted adaptToJson(Original obj) throws Exception; + + /** + * This method is used on deserialization only. It contains a conversion logic from type Adapted to type Original. + * + * @param obj + * Object to convert or {@code null}. + * @return Converted object representing pojo to be set into object graph or {@code null}. + * @throws Exception if there is an error during the conversion. + */ + Original adaptFromJson(Adapted obj) throws Exception; +}
diff --git a/api/src/main/java/jakarta/json/bind/adapter/package-info.java b/api/src/main/java/jakarta/json/bind/adapter/package-info.java new file mode 100644 index 0000000..afbde86 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/adapter/package-info.java
@@ -0,0 +1,24 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * <p> + * Defines adapter related classes. + * </p> + * + * @since JSON Binding 1.0 + */ +package jakarta.json.bind.adapter;
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbAnnotation.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbAnnotation.java new file mode 100644 index 0000000..647e99d --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbAnnotation.java
@@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.Documented; +import java.lang.annotation.Retention; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +/** + * Marks any relevant JSON Binding annotations. Includes + * {@code @Documented} and {@code @Retention(RUNTIME)} definitions. + * + * @since JSON Binding 1.0 + */ + +@Documented +@Retention(RUNTIME) +public @interface JsonbAnnotation { }
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbCreator.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbCreator.java new file mode 100644 index 0000000..5eb8607 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbCreator.java
@@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p>This annotation identifies the custom constructor or factory method to use when creating an instance + * of the associated class.</p> + * + * <p>Only one constructor or static factory method can be annotated with {@code JsonbCreator} in a given class.</p> + * + * <p>The {@code @JsonbCreator} annotation is intended to be used with constructors/methods with parameters. + * Such parameters could be annotated for instance with {@code @JsonbProperty}.</p> + * + * <p><b>Usage</b></p> + * <p>The {@code @JsonbCreator} annotation can be used with the following program elements:</p> + * <ul> + * <li> method </li> + * <li> constructor </li> + * </ul> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR}) +public @interface JsonbCreator { +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbDateFormat.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbDateFormat.java new file mode 100644 index 0000000..2f2e22e --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbDateFormat.java
@@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p>Annotation provides way how to set custom date format to field or JavaBean property.</p> + * + * <p>The pattern format is specified in {@link java.time.format.DateTimeFormatter}</p> + * + * <p><b>Usage</b></p> + * <p>The {@code @JsonbDateFormat} annotation can be used with the following program elements:</p> + * <ul> + * <li> field </li> + * <li> getter/setter </li> + * <li> type </li> + * <li> parameter </li> + * <li> package </li> + * </ul> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, + ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER, ElementType.PACKAGE}) +public @interface JsonbDateFormat { + + /** + * Value that indicates that default {@link java.util.Locale}. + */ + String DEFAULT_LOCALE = "##default"; + + /** + * Value that indicates the default format. + */ + String DEFAULT_FORMAT = "##default"; + + /** + * Special date format which serializes given date as milliseconds. + * Such date is serialized as a number. + */ + String TIME_IN_MILLIS = "##time-in-millis"; + + /** + * Specifies the date pattern to use. + * + * @return Date pattern to use. + */ + String value() default DEFAULT_FORMAT; + + /** + * Custom {@link java.util.Locale} to use. + * + * @return Locale to use. + */ + String locale() default DEFAULT_LOCALE; + +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbNillable.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbNillable.java new file mode 100644 index 0000000..2d7e891 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbNillable.java
@@ -0,0 +1,53 @@ +/* + * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PACKAGE; +import static java.lang.annotation.ElementType.TYPE; + +/** + * <p>Specifies how fields having null values are serialized into JSON.</p> + * + * <p>There are two possible values which can be specified. In case of true, fields are serialized as + * key/value pair with value null. In case of false, fields will not be serialized (default behaviour).</p> + * + * <p>Annotation can be specified on field, method, type or on package and affects all underlying properties and classes.</p> + * + * <p>For similar functionality on a property level see {@link JsonbProperty}. However this {@link JsonbProperty} functionality + * has been deprecated and should not be used</p> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ANNOTATION_TYPE, FIELD, METHOD, TYPE, PACKAGE}) +public @interface JsonbNillable { + + /** + * Switches on/off serialization of properties with null value. + * + * @return True if field with null value should be serialized as key/value pair into JSON with null value. + */ + boolean value() default true; +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbNumberFormat.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbNumberFormat.java new file mode 100644 index 0000000..476fbe1 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbNumberFormat.java
@@ -0,0 +1,65 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p>Annotation provides way how to set custom number format to field or JavaBean property.</p> + * + * <p>The pattern format is specified in {@link java.text.DecimalFormat}</p> + * + * <p><b>Usage</b></p> + * <p>The {@code @JsonbNumberFormat} annotation can be used with the following program elements:</p> + * <ul> + * <li> field </li> + * <li> getter/setter </li> + * <li> type </li> + * <li> parameter </li> + * <li> package </li> + * </ul> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.FIELD, + ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER, ElementType.PACKAGE}) +public @interface JsonbNumberFormat { + + /** + * Value that indicates that default {@link java.util.Locale}. + */ + String DEFAULT_LOCALE = "##default"; + + /** + * Specifies the number pattern to use. + * + * @return Number pattern to use. + */ + String value() default ""; + + /** + * Custom {@link java.util.Locale} to use. + * + * @return Custom locale to use. + */ + String locale() default DEFAULT_LOCALE; +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbProperty.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbProperty.java new file mode 100644 index 0000000..0f80e2d --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbProperty.java
@@ -0,0 +1,58 @@ +/* + * Copyright (c) 2015, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p>Allows customization of field (or JavaBean property) name.This name is used either in serialization or + * in deserialization.</p> + * + * <p><b>Usage</b></p> + * <p>The {@code @JsonbProperty} annotation can be used with the following program elements:</p> + * <ul> + * <li> a JavaBean property </li> + * <li> field </li> + * <li> parameter </li> + * </ul> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER}) +public @interface JsonbProperty { + + /** + * Customized name of the field (or JavaBean property). + * + * @return Customized property name. + */ + String value() default ""; + + /** + * Switches on/off serialization of null values. + * + * @return True if field with null value should be serialized as key/value pair into JSON with null value. + * @deprecated Please use {@link JsonbNillable} as another annotation instead. This option will be removed in the future. + */ + @Deprecated(since = "2.1") + boolean nillable() default false; +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbPropertyOrder.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbPropertyOrder.java new file mode 100644 index 0000000..738fa97 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbPropertyOrder.java
@@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p>Specifies order in which properties are serialized.</p> + * + * <p>Partial mapping can also be specified. In that case, properties included + * in annotation declaration will be serialized first (in defined order), followed + * by any properties not included in the definition. The order of properties not + * included in the definition is not guaranteed.</p> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) +public @interface JsonbPropertyOrder { + + /** + * Order in which properties are serialized. Names must correspond to original + * names defined in Java class before any customization applied. + * + * @return Array of property names which defines an order. + */ + String[] value(); +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbSubtype.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbSubtype.java new file mode 100644 index 0000000..d56c0f6 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbSubtype.java
@@ -0,0 +1,74 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Subtype is tightly bound to the {@link JsonbTypeInfo}. + * <br> + * Type defines class which instance will be created when processing specific alias, or when processing + * instance of the specified type, to determine which alias should be used. + * <br> + * Alias is used instead of a class name. It has to be unique value among all the defined subtypes + * bound to the specific {@link JsonbTypeInfo}. An exception should be thrown when processing and + * validating aliases and duplicate alias is found. + * <pre><code> + * // Example + * {@literal @}JsonbTypeInfo({ + * {@literal @}JsonbSubtype(alias = "dog", type = Dog.class) + * {@literal @}JsonbSubtype(alias = "cat", type = Cat.class) + * }) + * interface Animal {} + * + * class Dog implements Animal { + * public String isDog = true; + * } + * class Cat implements Animal { + * public String isCat = true; + * } + * class Rat implements Animal { + * public String isRat = true; + * } + * + * jsonb.toJson(new Dog());// {"@type":"dog","isDog":true} + * jsonb.toJson(new Cat());// {"@type":"cat","isCat":true} + * jsonb.toJson(new Rat());// {"isRat":true} + * </code></pre> + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({}) +public @interface JsonbSubtype { + + /** + * Type alias which is used instead of a class name. + * + * @return alias value + */ + String alias(); + + /** + * An actual type bound to the alias. + * + * @return alias bound type + */ + Class<?> type(); + +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbTransient.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbTransient.java new file mode 100644 index 0000000..0e9b9fe --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbTransient.java
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.FIELD; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; + +/** + * <p>Prevents mapping of a Java Bean property, field or type to JSON representation.</p> + * + * <p><b>Usage</b></p> + * <p>The {@code @JsonbTransient} annotation can be used with the following program elements:</p> + * <ul> + * <li> getter/setter </li> + * <li> field </li> + * </ul> + * + * <p>{@code @JsonbTransient} is mutually exclusive with all other JSON Binding defined annotations. </p> + * + * <p>If a class field is annotated with {@code @JsonbTransient}, exception is thrown when this field, + * getter or setter is annotated with other JSON Binding annotations.</p> + * + * <p>If a getter is annotated with {@code @JsonbTransient}, exception is thrown if when the field + * or this getter are annotated with other JSON Binding annotations. Exception is not thrown + * if JSON Binding annotations are presented on the setter.</p> + * + * <p>If a setter is annotated with {@code @JsonbTransient}, exception is thrown if when the field + * or this setter are annotated with other JSON Binding annotations. Exception is not thrown + * if JSON Binding annotations are presented on the getter.</p> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ANNOTATION_TYPE, FIELD, METHOD}) +public @interface JsonbTransient { } +
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeAdapter.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeAdapter.java new file mode 100644 index 0000000..3d59f23 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeAdapter.java
@@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import jakarta.json.bind.adapter.JsonbAdapter; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p>Annotation provides way how to set custom JsonbAdapter to field or JavaBean property.</p> + * + * <p><b>Usage</b></p> + * <p>The {@code @JsonbTypeAdapter} annotation can be used with the following program elements:</p> + * <ul> + * <li> type </li> + * <li> field </li> + * <li> method </li> + * <li> parameter </li> + * </ul> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +public @interface JsonbTypeAdapter { + + /** + * Custom JsonbAdapter which provides custom mapping for given field or JavaBean property. + * + * @return Adapter to use. + */ + Class<? extends JsonbAdapter> value(); +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeDeserializer.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeDeserializer.java new file mode 100644 index 0000000..77c412f --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeDeserializer.java
@@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + + +import jakarta.json.bind.serializer.JsonbDeserializer; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p> + * Annotation provides way how to set custom JsonbDeserializer to field or JavaBean property. + * </p> + * + * <p><b>Usage</b></p> + * <p> The {@code @JsonbDeserializer} annotation can be used with the following + * program elements: + * <ul> + * <li> type </li> + * <li> field </li> + * <li> method </li> + * <li> creator parameter </li> + * </ul> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +public @interface JsonbTypeDeserializer { + + /** + * Custom {@link JsonbDeserializer} which provides custom mapping for given field or JavaBean property. + * + * @return Deserializer to use. + */ + Class<? extends JsonbDeserializer> value(); +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeInfo.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeInfo.java new file mode 100644 index 0000000..e14d97a --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeInfo.java
@@ -0,0 +1,64 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Configuration annotation of the type information handling. + * <br> + * This annotation is required on the most common parent of all classes when type information will be applied. + * <pre><code> + * // Example + * {@literal @}JsonbTypeInfo(key = "@key") + * interface Animal {} + * + * class Dog implements Animal {} + * class Cat implements Animal {} + * </code></pre> + * This annotation is tightly bound to {@link JsonbSubtype}. It is required to use + * {@link JsonbSubtype} annotations to specify all the possible classes and their aliases. + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE}) +public @interface JsonbTypeInfo { + + /** + * Default type information key name. + */ + String DEFAULT_KEY_NAME = "@type"; + + /** + * Key used for keeping the type information (alias). + * Default value is {@code @type}. + * + * @return key name + */ + String key() default DEFAULT_KEY_NAME; + + /** + * Allowed aliases of the handled type. + * + * @return list of allowed aliases + */ + JsonbSubtype[] value() default {}; + +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeSerializer.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeSerializer.java new file mode 100644 index 0000000..16bb28a --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbTypeSerializer.java
@@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + + +import jakarta.json.bind.serializer.JsonbSerializer; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p>Annotation provides way how to set custom JsonbSerializer to field or JavaBean property.</p> + * + * <p><b>Usage</b></p> + * <p>The {@code @JsonbSerializer} annotation can be used with the following program elements:</p> + * <ul> + * <li> type </li> + * <li> field </li> + * <li> method </li> + * </ul> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.FIELD, ElementType.METHOD}) +public @interface JsonbTypeSerializer { + + /** + * Custom {@link JsonbSerializer} which provides custom mapping for given field or JavaBean property. + * + * @return Serializaer to use. + */ + Class<? extends JsonbSerializer> value(); +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/JsonbVisibility.java b/api/src/main/java/jakarta/json/bind/annotation/JsonbVisibility.java new file mode 100644 index 0000000..85ab9c2 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/JsonbVisibility.java
@@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.annotation; + +import jakarta.json.bind.config.PropertyVisibilityStrategy; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * <p>Annotation provides way how to customize visibility strategy of the JSON Binding.</p> + * + * <p>It allows for example to specify, that only public getters and setter should be visible.</p> + * + * <p><b>Usage</b></p> + * <p>The {@code @JsonbVisibility} annotation can be used with the following program elements:</p> + * <ul> + * <li> type </li> + * <li> package </li> + * </ul> + * + * @since JSON Binding 1.0 + */ +@JsonbAnnotation +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.ANNOTATION_TYPE, ElementType.TYPE, ElementType.PACKAGE}) +public @interface JsonbVisibility { + + /** + * Custom property visibility strategy used to resolve visibility of the members. + * + * @return Visibility strategy to use. + */ + Class<? extends PropertyVisibilityStrategy> value(); +}
diff --git a/api/src/main/java/jakarta/json/bind/annotation/package-info.java b/api/src/main/java/jakarta/json/bind/annotation/package-info.java new file mode 100644 index 0000000..09ff95f --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/annotation/package-info.java
@@ -0,0 +1,25 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * <p> + * Defines annotations for customizing the mapping between Java program elements + * and JSON documents. + * </p> + * + * @since JSON Binding 1.0 + */ +package jakarta.json.bind.annotation;
diff --git a/api/src/main/java/jakarta/json/bind/config/BinaryDataStrategy.java b/api/src/main/java/jakarta/json/bind/config/BinaryDataStrategy.java new file mode 100644 index 0000000..af64529 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/config/BinaryDataStrategy.java
@@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.config; + +/** + * Specifies predefined binary data handling strategies. + * This strategy can be set via {@link jakarta.json.bind.JsonbConfig#withBinaryDataStrategy(String)}. + * + * @see jakarta.json.bind.JsonbConfig + * @since JSON Binding 1.0 + */ +public final class BinaryDataStrategy { + + /** + * Private constructor to disallow instantiation. + */ + private BinaryDataStrategy() { }; + + /** + * Using this strategy, binary data is encoded as a byte array. + * Default encoding strategy. + */ + public static final String BYTE = "BYTE"; + + /** + * Using this strategy, binary data is encoded using + * the Base64 encoding scheme as specified in RFC 4648 and RFC 2045. + */ + public static final String BASE_64 = "BASE_64"; + + /** + * Using this strategy, binary data is encoded using + * the "URL and Filename safe Base64 Alphabet" as specified in Table 2 of RFC 4648. + */ + public static final String BASE_64_URL = "BASE_64_URL"; +}
diff --git a/api/src/main/java/jakarta/json/bind/config/PropertyNamingStrategy.java b/api/src/main/java/jakarta/json/bind/config/PropertyNamingStrategy.java new file mode 100644 index 0000000..f7e4a86 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/config/PropertyNamingStrategy.java
@@ -0,0 +1,72 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.config; + +/** + * <p>Allows to define custom property naming strategy. + * Specifies predefined property naming strategies. + * Does not override JsonbProperty value.</p> + * + * <p>This strategy can be set via {@link jakarta.json.bind.JsonbConfig}.</p> + * + * @see jakarta.json.bind.JsonbConfig + * @since JSON Binding 1.0 + */ +public interface PropertyNamingStrategy { + /** + * Using this strategy, the property name is unchanged. + */ + String IDENTITY = "IDENTITY"; + + /** + * Using this strategy, the property name is transformed to lower case with dashes. + * The dashes are on the positions of different case boundaries in the original field name (camel case). + */ + String LOWER_CASE_WITH_DASHES = "LOWER_CASE_WITH_DASHES"; + + /** + * Using this strategy, the property name is transformed to lower case with underscores. + * The underscores are on the positions of different case boundaries in the original field name (camel case). + */ + String LOWER_CASE_WITH_UNDERSCORES = "LOWER_CASE_WITH_UNDERSCORES"; + + /** + * Using this strategy, the first character will be capitalized. + */ + String UPPER_CAMEL_CASE = "UPPER_CAMEL_CASE"; + + /** + * Using this strategy, the first character will be capitalized and the words + * will be separated by spaces. + */ + String UPPER_CAMEL_CASE_WITH_SPACES = "UPPER_CAMEL_CASE_WITH_SPACES"; + + /** + * Using this strategy, the serialization will be same as identity. + * Deserialization will be case insensitive. E.g. property in JSON with name + * PropertyNAME, will be mapped to field propertyName. + */ + String CASE_INSENSITIVE = "CASE_INSENSITIVE"; + + /** + * Translates the property name into its JSON field name representation. + * + * @param propertyName Name of the property to translate. + * @return Translated JSON field name. + */ + String translateName(String propertyName); +}
diff --git a/api/src/main/java/jakarta/json/bind/config/PropertyOrderStrategy.java b/api/src/main/java/jakarta/json/bind/config/PropertyOrderStrategy.java new file mode 100644 index 0000000..ae96ee5 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/config/PropertyOrderStrategy.java
@@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.config; + +/** + * Specifies predefined property order strategies. + * This strategy can be set via {@link jakarta.json.bind.JsonbConfig#withPropertyOrderStrategy(String)} + * + * @see jakarta.json.bind.JsonbConfig + * @since JSON Binding 1.0 + */ +public final class PropertyOrderStrategy { + + /** + * Private constructor to disallow instantiation. + */ + private PropertyOrderStrategy() { }; + + /** + * Using this strategy, the order of properties is lexicographical. + */ + public static final String LEXICOGRAPHICAL = "LEXICOGRAPHICAL"; + + /** + * Using this strategy, the order of properties + * is not guaranteed to retain any order. + */ + public static final String ANY = "ANY"; + + /** + * Using this strategy, the order of properties is in reverse order + * to lexicographical order. + */ + public static final String REVERSE = "REVERSE"; +}
diff --git a/api/src/main/java/jakarta/json/bind/config/PropertyVisibilityStrategy.java b/api/src/main/java/jakarta/json/bind/config/PropertyVisibilityStrategy.java new file mode 100644 index 0000000..52fc1d0 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/config/PropertyVisibilityStrategy.java
@@ -0,0 +1,49 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.config; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/** + * <p>Provides mechanism how to define customized property visibility strategy.</p> + * + * <p>This strategy can be set via {@link jakarta.json.bind.JsonbConfig}.</p> + * + * @see jakarta.json.bind.JsonbConfig + * @since JSON Binding 1.0 + */ +public interface PropertyVisibilityStrategy { + + /** + * Responds whether the given field should be considered + * as the JsonbProperty. + * + * @param field member of the class + * @return true if member should be visible + */ + boolean isVisible(Field field); + + /** + * Responds whether the given method should be considered + * as the JsonbProperty. + * + * @param method member of the class + * @return true if member should be visible + */ + boolean isVisible(Method method); +}
diff --git a/api/src/main/java/jakarta/json/bind/config/package-info.java b/api/src/main/java/jakarta/json/bind/config/package-info.java new file mode 100644 index 0000000..6f72b0d --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/config/package-info.java
@@ -0,0 +1,25 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * <p> + * Defines strategies and policies for customizing the mapping between Java program elements + * and JSON documents. + * </p> + * + * @since JSON Binding 1.0 + */ +package jakarta.json.bind.config;
diff --git a/api/src/main/java/jakarta/json/bind/package-info.java b/api/src/main/java/jakarta/json/bind/package-info.java new file mode 100644 index 0000000..38dd021 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/package-info.java
@@ -0,0 +1,26 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * Provides JSON Binding API, which enables binding Java objects from and to + * JSON documents. + * + * Main user entry points to the API is {@link jakarta.json.bind.JsonbBuilder JsonbBuilder} + * which builds {@link jakarta.json.bind.Jsonb Jsonb} instances. + * + * @since JSON Binding 1.0 + */ +package jakarta.json.bind;
diff --git a/api/src/main/java/jakarta/json/bind/serializer/DeserializationContext.java b/api/src/main/java/jakarta/json/bind/serializer/DeserializationContext.java new file mode 100644 index 0000000..17b207f --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/serializer/DeserializationContext.java
@@ -0,0 +1,80 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.serializer; + + +import jakarta.json.stream.JsonParser; +import java.lang.reflect.Type; + +/** + * Provides JSONB Mapper functionality on top of JSONP parser. + * + * @see JsonbDeserializer + * @since JSON Binding 1.0 + */ +public interface DeserializationContext { + + /** + * <p> + * Deserialize JSON stream into instance of provided class using {@link jakarta.json.stream.JsonParser}. + * JsonParser cursor have to be at KEY_NAME before START_OBJECT / START_ARRAY, or at START_OBJECT / START_ARRAY + * to call this method. After deserialization is complete JsonParser will be at END_OBJECT / END_ARRAY + * for deserialized JSON structure. + * </p> + * + * <p> + * If method is called for the same type, which is deserializer bound to, deserializer recursion is suppressed. + * Otherwise deserializers are reentrant during deserialization process started by this method. + * </p> + * + * {@link JsonParser} instance of JSONB runtime is shared with custom deserializer. + * + * @param clazz + * Type to deserialize into. No arg constructor required. + * @param parser + * JSONP parser to drive. + * @param <T> + * Type of class. + * @return Deserialized instance. + */ + <T> T deserialize(Class<T> clazz, JsonParser parser); + + /** + * <p> + * Deserialize JSON stream into instance of provided class using {@link jakarta.json.stream.JsonParser}. + * JsonParser cursor have to be at KEY_NAME before START_OBJECT / START_ARRAY, or at START_OBJECT / START_ARRAY + * to call this method. After deserialization is complete JsonParser will be at END_OBJECT / END_ARRAY + * for deserialized JSON structure. + * </p> + * + * <p> + * If method is called for the same type, which is deserializer bound to, deserializer recursion is suppressed. + * Otherwise deserializers are reentrant during deserialization process started by this method. + * </p> + * + * {@link JsonParser} instance of JSONB runtime is shared with custom deserializer. + * + * @param type + * Type to deserialize into. No arg constructor required. + * @param parser + * JSONP parser to drive. + * @param <T> + * Type to deserialize into. + * @return Deserialized instance. + */ + <T> T deserialize(Type type, JsonParser parser); +}
diff --git a/api/src/main/java/jakarta/json/bind/serializer/JsonbDeserializer.java b/api/src/main/java/jakarta/json/bind/serializer/JsonbDeserializer.java new file mode 100644 index 0000000..836b5a6 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/serializer/JsonbDeserializer.java
@@ -0,0 +1,84 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.serializer; + +import jakarta.json.stream.JsonParser; +import java.lang.reflect.Type; + +/** + * <p>Interface representing a custom deserializer for a given type. It provides a low-level API for java object + * deserialization from JSON stream using {@link JsonParser}. Unlike {@link jakarta.json.bind.adapter.JsonbAdapter}, + * which acts more as converter from one java type to another, deserializer provides more fine grained control over + * deserialization process.</p> + * + * <p>{@link DeserializationContext} acts as JSONB runtime, able to deserialize any java object provided.</p> + * + * <p>Sample of custom Deserializer:</p> + * <pre> + * class Box { + * public BoxInner boxInnerObject; + * public String name; + * } + * + * BoxDeserializer implements JsonbDeserializer<Box> { + * public Box deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + * Box = new Box(); + * + * while (parser.hasNext()) { + * Event event = parser.next(); + * + * if (event == JsonParser.Event.KEY_NAME && parser.getString().equals("boxInnerObject") { + * // Deserialize inner object + * box.boxInnerObject = ctx.deserialize(BoxInner.class, jsonParser); + * + * } else if (event == JsonParser.Event.KEY_NAME && parser.getString().equals("name") { + * // Deserialize name property + * parser.next(); // move to VALUE + * box.name = parser.getString(); + * } + * } + * + * return box; + * } + * } + * </pre> + * + * <p>Deserializers are registered using {@link jakarta.json.bind.JsonbConfig#withDeserializers(JsonbDeserializer[])} + * method or using {@link jakarta.json.bind.annotation.JsonbTypeDeserializer} annotation on type.</p> + * + * @param <T> Type to bind deserializer for. + * @see jakarta.json.bind.JsonbConfig + * @see jakarta.json.bind.annotation.JsonbTypeDeserializer + * @see JsonbSerializer + * @see jakarta.json.bind.adapter.JsonbAdapter + * @since JSON Binding 1.0 + */ +public interface JsonbDeserializer<T> { + + /** + * Deserialize JSON stream into object. + * + * @param parser + * Json parser. + * @param ctx + * Deserialization context. + * @param rtType + * Type of returned object. + * @return Deserialized instance. + */ + T deserialize(JsonParser parser, DeserializationContext ctx, Type rtType); +}
diff --git a/api/src/main/java/jakarta/json/bind/serializer/JsonbSerializer.java b/api/src/main/java/jakarta/json/bind/serializer/JsonbSerializer.java new file mode 100644 index 0000000..b072b44 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/serializer/JsonbSerializer.java
@@ -0,0 +1,65 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.serializer; + +import jakarta.json.stream.JsonGenerator; + +/** + * <p>Interface representing a custom serializer for given type. Unlike {@link jakarta.json.bind.adapter.JsonbAdapter} + * serializer provides more fine grained control over serialization process by writing java object directly into + * JSON stream using {@link JsonGenerator}. {@link SerializationContext} acts as JSONB runtime, able to serialize + * any java object provided.</p> + * + * <p>Serializers are registered using {@link jakarta.json.bind.JsonbConfig#withSerializers(JsonbSerializer[])} + * method or using {@link jakarta.json.bind.annotation.JsonbTypeSerializer} annotation on type</p> + * + * <p>Sample of custom Serializer:</p> + * <pre> + * class Box { + * public BoxInner boxInnerObject; + * public String name; + * } + * + * class BoxSerializer implements JsonbSerializer<Box> { + * public void serialize(Box box, JsonGenerator generator, SerializationContext ctx) { + * generator.write("name", box.name); + * ctx.serialize("boxInnerObject", generator); + * } + * } + * </pre> + * + * @param <T> Type to bind serializer for. + * @see jakarta.json.bind.JsonbConfig + * @see jakarta.json.bind.annotation.JsonbTypeSerializer + * @see JsonbDeserializer + * @see jakarta.json.bind.adapter.JsonbAdapter + * @since JSON Binding 1.0 + */ +public interface JsonbSerializer<T> { + + /** + * Serializes object into JSON stream. + * + * @param obj + * Object to serialize. + * @param generator + * JSON generator used to write java object to JSON stream. + * @param ctx + * JSONB mapper context. Use it to serialize sub-objects. + */ + void serialize(T obj, JsonGenerator generator, SerializationContext ctx); +}
diff --git a/api/src/main/java/jakarta/json/bind/serializer/SerializationContext.java b/api/src/main/java/jakarta/json/bind/serializer/SerializationContext.java new file mode 100644 index 0000000..9ac2f49 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/serializer/SerializationContext.java
@@ -0,0 +1,60 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.serializer; + +import jakarta.json.stream.JsonGenerator; + +/** + * Provides JSONB internals for custom serializers. + * + * @see JsonbSerializer + * @since JSON Binding 1.0 + */ +public interface SerializationContext { + + /** + * Serializes arbitrary object to JSON, using current {@link jakarta.json.stream.JsonGenerator} instance. + * Serialization is ran as serialization of a root type from user {@link JsonbSerializer}. {@link JsonGenerator} + * instance is shared with JSONB and user serializer. + * + * @param key + * JSON key name. + * @param object + * Object to serialize. + * @param generator + * JSONP generator to serialize with. + * @param <T> + * Type of serialized object. + */ + <T> void serialize(String key, T object, JsonGenerator generator); + + /** + * Serializes arbitrary object to JSON, using current {@link jakarta.json.stream.JsonGenerator} instance. + * Serialization is ran as serialization of a root type from user {@link JsonbSerializer}. {@link JsonGenerator} + * instance is shared with JSONB and user serializer. + * + * Method without key parameter is intended to serialize inside JSON_ARRAYs. + * + * @param object + * Object to serialize. + * @param generator + * JSONP generator to serialize with. + * @param <T> + * Type of serialized object. + */ + <T> void serialize(T object, JsonGenerator generator); +}
diff --git a/api/src/main/java/jakarta/json/bind/serializer/package-info.java b/api/src/main/java/jakarta/json/bind/serializer/package-info.java new file mode 100644 index 0000000..18ffb36 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/serializer/package-info.java
@@ -0,0 +1,23 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * <p> + * Defines serializer depending classes. + * </p> + * @since JSON Binding 1.0 + */ +package jakarta.json.bind.serializer;
diff --git a/api/src/main/java/jakarta/json/bind/spi/JsonbProvider.java b/api/src/main/java/jakarta/json/bind/spi/JsonbProvider.java new file mode 100644 index 0000000..250a478 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/spi/JsonbProvider.java
@@ -0,0 +1,160 @@ +/* + * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package jakarta.json.bind.spi; + +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; + +import java.util.Iterator; +import java.util.ServiceLoader; + +/** + * Service provider for JSON Binding implementations. + * + * Provider implementors must implement all abstract methods. + * + * API clients can obtain instance of default provider by calling: + * <pre> + * {@code + * JsonbProvider provider = JsonbProvider.provider(); + * }}</pre> + * + * Specific provider instance lookup: + * <pre> + * {@code + * JsonbProvider provider; + * try { + * JsonbProvider.provider("foo.bar.ProviderImpl"); + * } catch (JsonbException e) { + * // provider not found or could not be instantiated + * }}</pre> + * where '{@code foo.bar.ProviderImpl}' is a vendor implementation class extending + * {@link jakarta.json.bind.spi.JsonbProvider} and identified to service loader as + * specified in {@link java.util.ServiceLoader} documentation. + * <br> + * All the methods in this class are allowed to be called by multiple concurrent + * threads. + * + * @see jakarta.json.bind.Jsonb + * @see java.util.ServiceLoader + * @since JSON Binding 1.0 + */ +public abstract class JsonbProvider { + + /** + * A constant representing the name of the default + * {@link jakarta.json.bind.spi.JsonbProvider JsonbProvider} implementation class. + */ + private static final String DEFAULT_PROVIDER = "org.eclipse.yasson.JsonBindingProvider"; + + /** + * Protected constructor. + */ + protected JsonbProvider() { + } + + /** + * Creates a JSON Binding provider object by using the + * {@link java.util.ServiceLoader#load(Class)} method. The first provider of + * {@code JsonbProvider} class from list of providers returned by + * {@code ServiceLoader.load} call is returned. If there are no available + * service providers, this method tries to load the default service provider using + * {@link Class#forName(String)} method. + * + * @see java.util.ServiceLoader + * + * @throws JsonbException if there is no provider found, or there is a problem + * instantiating the provider instance. + * + * @return {@code JsonbProvider} instance + */ + @SuppressWarnings("UseSpecificCatch") + public static JsonbProvider provider() { + ServiceLoader<JsonbProvider> loader = ServiceLoader.load(JsonbProvider.class); + Iterator<JsonbProvider> it = loader.iterator(); + if (it.hasNext()) { + return it.next(); + } + + try { + Class<?> clazz = Class.forName(DEFAULT_PROVIDER); + return (JsonbProvider) clazz.newInstance(); + } catch (ClassNotFoundException x) { + throw new JsonbException("JSON Binding provider " + DEFAULT_PROVIDER + " not found", x); + } catch (Exception x) { + throw new JsonbException("JSON Binding provider " + DEFAULT_PROVIDER + + " could not be instantiated: " + x, x); + } + } + + /** + * Creates a JSON Binding provider object by using the + * {@link java.util.ServiceLoader#load(Class)} method, matching {@code providerName}. + * The first provider of {@code JsonbProvider} class from list of providers returned by + * {@code ServiceLoader.load} call, matching providerName is returned. + * If no such provider is found, JsonbException is thrown. + * + * @param providerName + * Class name ({@code class.getName()}) to be chosen from the list of providers + * returned by {@code ServiceLoader.load(JsonbProvider.class)} call. + * + * @throws JsonbException if there is no provider found, or there is a problem + * instantiating the provider instance. + * + * @throws NullPointerException if providerName is {@code null}. + * + * @see java.util.ServiceLoader + * + * @return {@code JsonbProvider} instance + */ + @SuppressWarnings("UseSpecificCatch") + public static JsonbProvider provider(final String providerName) { + if (providerName == null) { + throw new IllegalArgumentException(); + } + ServiceLoader<JsonbProvider> loader = ServiceLoader.load(JsonbProvider.class); + Iterator<JsonbProvider> it = loader.iterator(); + while (it.hasNext()) { + JsonbProvider provider = it.next(); + if (providerName.equals(provider.getClass().getName())) { + return provider; + } + } + + throw new JsonbException("JSON Binding provider " + providerName + " not found", + new ClassNotFoundException(providerName)); + } + + /** + * Returns a new instance of {@link jakarta.json.bind.JsonbBuilder JsonbBuilder} class. + * + * {@link jakarta.json.bind.JsonbBuilder JsonbBuilder} provides necessary getter + * methods to access required parameters. + * + * @return JsonbBuilder + * A new instance of class implementing {@link jakarta.json.bind.JsonbBuilder}. + * Always a non-null valid object. + * + * @see jakarta.json.bind.Jsonb + * @see jakarta.json.bind.JsonbBuilder + * + * @throws JsonbException + * If an error was encountered while creating the {@link JsonbBuilder} instance. + */ + public abstract JsonbBuilder create(); + +}
diff --git a/api/src/main/java/jakarta/json/bind/spi/package-info.java b/api/src/main/java/jakarta/json/bind/spi/package-info.java new file mode 100644 index 0000000..9f76bc8 --- /dev/null +++ b/api/src/main/java/jakarta/json/bind/spi/package-info.java
@@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015, 2020 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * Service Provider Interface (SPI) to plug in implementations of JSON + * Binding API {@link jakarta.json.bind.JsonbBuilder JsonbBuilder} objects. + * + * <p> {@link jakarta.json.bind.spi.JsonbProvider JsonbProvider} is an abstract class + * that provides a service for creating JSON Binding builder implementation instances. + * A <i>service provider</i> for {@link jakarta.json.bind.spi.JsonbProvider JsonbProvider} provides an + * specific implementation by subclassing and implementing the + * {@link jakarta.json.bind.JsonbBuilder JsonbBuilder} creation + * method(s) in {@link jakarta.json.bind.spi.JsonbProvider JsonbProvider}. + * + * <p>The API locates and loads providers using {@link java.util.ServiceLoader ServiceLoader}. + * + * @since JSON Binding 1.0 + */ +package jakarta.json.bind.spi;
diff --git a/api/src/main/java/module-info.java b/api/src/main/java/module-info.java new file mode 100644 index 0000000..08536f8 --- /dev/null +++ b/api/src/main/java/module-info.java
@@ -0,0 +1,32 @@ +/* + * Copyright (c) 2017, 2021 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/** + * Jakarta JSON Binding API. + */ +module jakarta.json.bind { + exports jakarta.json.bind; + exports jakarta.json.bind.adapter; + exports jakarta.json.bind.annotation; + exports jakarta.json.bind.config; + exports jakarta.json.bind.serializer; + exports jakarta.json.bind.spi; + + requires jakarta.json; + requires java.logging; + + uses jakarta.json.bind.spi.JsonbProvider; +}
diff --git a/api/src/main/javadoc/doc-files/EFSL.html b/api/src/main/javadoc/doc-files/EFSL.html new file mode 100644 index 0000000..cbfbb28 --- /dev/null +++ b/api/src/main/javadoc/doc-files/EFSL.html
@@ -0,0 +1,74 @@ +<html> +<head> +<title>Eclipse Foundation Specification License - v1.0</title> +</head> +<body> +<h1>Eclipse Foundation Specification License - v1.0</h1> +<p>By using and/or copying this document, or the Eclipse Foundation + document from which this statement is linked, you (the licensee) agree + that you have read, understood, and will comply with the following + terms and conditions:</p> + +<p>Permission to copy, and distribute the contents of this document, or + the Eclipse Foundation document from which this statement is linked, in + any medium for any purpose and without fee or royalty is hereby + granted, provided that you include the following on ALL copies of the + document, or portions thereof, that you use:</p> + +<ul> + <li> link or URL to the original Eclipse Foundation document.</li> + <li>All existing copyright notices, or if one does not exist, a notice + (hypertext is preferred, but a textual representation is permitted) + of the form: "Copyright © [$date-of-document] + “Eclipse Foundation, Inc. <a href="https://www.eclipse.org/legal/efsl.php"> + https://www.eclipse.org/legal/efsl.php</a>" + </li> +</ul> + +<p>Inclusion of the full text of this NOTICE must be provided. We + request that authorship attribution be provided in any software, + documents, or other items or products that you create pursuant to the + implementation of the contents of this document, or any portion + thereof.</p> + +<p>No right to create modifications or derivatives of Eclipse Foundation + documents is granted pursuant to this license, except anyone may + prepare and distribute derivative works and portions of this document + in software that implements the specification, in supporting materials + accompanying such software, and in documentation of such software, + PROVIDED that all such works include the notice below. HOWEVER, the + publication of derivative works of this document for use as a technical + specification is expressly prohibited.</p> + +<p>The notice is:</p> + +<p>"Copyright © 2018, 2020 Eclipse Foundation. This software or + document includes material copied from or derived from + Jakarta JSON Binding + <a href="https://jakarta.ee/specifications/jsonb/2.0/"> + https://jakarta.ee/specifications/jsonb/2.0/</a>."</p> + +<h2>Disclaimers</h2> + +<p>THIS DOCUMENT IS PROVIDED "AS IS," AND THE COPYRIGHT + HOLDERS AND THE ECLIPSE FOUNDATION MAKE NO REPRESENTATIONS OR + WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, + WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, + NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE + SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS + WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR + OTHER RIGHTS.</p> + +<p>THE COPYRIGHT HOLDERS AND THE ECLIPSE FOUNDATION WILL NOT BE LIABLE + FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT + OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE + CONTENTS THEREOF.</p> + +<p>The name and trademarks of the copyright holders or the Eclipse + Foundation may NOT be used in advertising or publicity pertaining to + this document or its contents without specific, written prior + permission. Title to copyright in this document will at all times + remain with copyright holders.</p> + +</body> +</html>
diff --git a/docs/pom.xml b/docs/pom.xml new file mode 100644 index 0000000..04f9ad7 --- /dev/null +++ b/docs/pom.xml
@@ -0,0 +1,102 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2011, 2024 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Distribution License v. 1.0, which is available at + http://www.eclipse.org/org/documents/edl-v10.php. + + SPDX-License-Identifier: BSD-3-Clause + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-docs</artifactId> + <version>3.0.0</version> + <packaging>pom</packaging> + <name>JSON Binding Docs</name> + + <properties> + <asciidoctor.maven.plugin.version>3.0.0</asciidoctor.maven.plugin.version> + <asciidoctorj.version>2.5.11</asciidoctorj.version> + <asciidoctorj.pdf.version>2.3.13</asciidoctorj.pdf.version> + </properties> + + <build> + <defaultGoal>process-resources</defaultGoal> + <plugins> + <plugin> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctor-maven-plugin</artifactId> + <version>${asciidoctor.maven.plugin.version}</version> + <dependencies> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj</artifactId> + <version>${asciidoctorj.version}</version> + </dependency> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj-pdf</artifactId> + <version>${asciidoctorj.pdf.version}</version> + </dependency> + </dependencies> + <configuration> + <sourceDirectory>src/docs</sourceDirectory> + <sourceDocumentName>user-guide.adoc</sourceDocumentName> + </configuration> + <executions> + <execution> + <id>asciidoc-to-html</id> + <phase>generate-resources</phase> + <goals> + <goal>process-asciidoc</goal> + </goals> + <configuration> + <backend>html5</backend> + <attributes> + <sourcedir>${project.build.sourceDirectory}</sourcedir> + <imagesdir>./images</imagesdir> + <toc>left</toc> + <toclevels>3</toclevels> + <icons>font</icons> + <sectanchors>true</sectanchors> + <idprefix/> + <idseparator>-</idseparator> + <docinfo1>true</docinfo1> + </attributes> + </configuration> + </execution> + <execution> + <id>generate-pdf-doc</id> + <phase>generate-resources</phase> + <goals> + <goal>process-asciidoc</goal> + </goals> + <configuration> + <backend>pdf</backend> + <attributes> + <imagesdir>./images</imagesdir> + <doctype>book</doctype> + <compat-mode/> + <data-uri/> + <icons>font</icons> + <pagenums/> + <toc/> + <icons>font</icons> + <sectanchors>true</sectanchors> + <idprefix/> + <idseparator>-</idseparator> + <docinfo1>true</docinfo1> + <embedAssets>true</embedAssets> + </attributes> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
diff --git a/docs/src/docs/user-guide.adoc b/docs/src/docs/user-guide.adoc new file mode 100644 index 0000000..a929301 --- /dev/null +++ b/docs/src/docs/user-guide.adoc
@@ -0,0 +1,720 @@ +:component-name: Json Binding 3.0.1 Users Guide +:toc: left +:toclevels: 3 +:source-highlighter: coderay + += {component-name} + +JSON-B is a standard binding layer for converting Java objects to/from JSON messages. It defines a default mapping algorithm for converting existing Java classes to JSON, while enabling developers to customize the mapping process through the use of Java annotations. + +== Installation + +=== Coordinates + +[source,xml] +.Maven Dependencies +---- +<dependencies> + <!-- JSON-P API --> + <dependency> + <groupId>jakarta.json</groupId> + <artifactId>jakarta.json-api</artifactId> + <version>2.1.3</version> + </dependency> + + <!-- Eclipse Parsson (JSON-P implementation) --> + <dependency> + <groupId>org.eclipse.parsson</groupId> + <artifactId>parsson</artifactId> + <version>1.1.6</version> + <scope>runtime</scope> + </dependency> + + <!-- JSON-B API --> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-api</artifactId> + <version>3.0.1</version> + </dependency> + + <!-- Yasson (JSON-B implementation) --> + <dependency> + <groupId>org.eclipse</groupId> + <artifactId>yasson</artifactId> + <version>3.0.4</version> + <scope>runtime</scope> + </dependency> +</dependencies> +---- + +== JSON Binding API + +=== Default mapping + +Default mapping is a set of rules used by JSON-B engine be default without any customization annotations and custom configuration provided. + +The main entry point in JSON-B is the Jsonb class. It provides a set of overloaded toJson and fromJson methods to serialize Java objects to JSON documents and deserialize them back. Jsonb instances are thread safe and can be reused. The recommended way is to have a single instance per configuration type. + +Default Jsonb engine can be created like this: + +[source,java] +---- +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +// ... +Jsonb jsonb = JsonbBuilder.create(); +---- + + +==== Mapping an object + +The sample below demonstrates serialization and deserialization of a simple POJO. + +[source,java] +---- +public static class Dog { + public String name; + public int age; + public boolean bites; +} + +// Create a dog instance +Dog dog = new Dog(); +dog.name = "Falco"; +dog.age = 4; +dog.bites = false; + +// Create Jsonb and serialize +Jsonb jsonb = JsonbBuilder.create(); +String result = jsonb.toJson(dog); + +// Deserialize back +dog = jsonb.fromJson("{\"name\":\"Falco\",\"age\":4,\"bites\":false}", Dog.class); +---- + +==== Mapping a collection + +JSON-B supports raw collections serialization. + +[source,java] +---- +// List of dogs +List dogs = new ArrayList(); +dogs.add(falco); +dogs.add(cassidy); + +// Create Jsonb and serialize +Jsonb jsonb = JsonbBuilder.create(); +String result = jsonb.toJson(dogs); + +// We can also deserialize back into a raw collection, but since there is no way to infer a type here, +// the result will be a list of java.util.Map instances with string keys. +dogs = jsonb.fromJson(result, ArrayList.class); +---- + +==== Mapping a generic collection + +JSON-B supports collections and generic collections handling. For proper deserialization the runtime type of resulting object needs to be passed to JSON-B during deserialization. It can be done a way shown below. + +[source,java] +---- +// List of dogs +List<Dog> dogs = new ArrayList<>(); +dogs.add(falco); +dogs.add(cassidy); + +// Create Jsonb and serialize +Jsonb jsonb = JsonbBuilder.create(); +String result = jsonb.toJson(dogs); + +// Deserialize back +dogs = jsonb.fromJson(result, new ArrayList<Dog>(){}.getClass().getGenericSuperclass()); +---- + +=== Customized mapping + +Your mappings can be customized in many different ways. You can use JSON-B annotations for compile time customizations and JsonbConfig class for runtime customizations. + +The sample below shows how to create JSON-B engine with custom configuration: + +[source,java] +---- +// Create custom configuration +JsonbConfig config = new JsonbConfig(); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(config); +---- + +==== Formatted output + +[source,java] +---- +// Create custom configuration with formatted output +JsonbConfig config = new JsonbConfig() + .withFormatting(true); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(config); + +// Use it! +String result = jsonb.toJson(pojo); +---- + +==== Changing property names + +By default, JSON property name is the same as Java property name. A common use case is serializing properties using different names. This can be achieved using @JsonbProperty annotation on fields or globally using JsonbNamingStrategy. + +===== @JsonbProperty annotation + +@JsonbProperty is used to change name of one particular property. It can be placed + + - on field, in this case it will affect serialization and deserialization + - on getter, in this case it will affect serialization only + - on setter, in this case it will affect deserialization only + +In the sample below property property name will be serialized as 'person-name'. + +[source,java] +---- +public class Person { + @JsonbProperty("person-name") + public String name; + + public String profession; +} +---- + +The resulting JSON document will look like this: + +[source,json] +---- +{ + "person-name": "Jason Bourne", + "profession": "Super Agent" +} +---- + +The same JSON document will be produced if @JsonbProperty annotation is placed on getter like this: + +[source,java] +---- +public class Person { + private String name; + private String profession; + + @JsonbProperty("person-name") + public String getName() { + return name; + } + + public String getProfession() { + return profession; + } + + // public setters ... +} +---- + +This sample demonstrating an ability to write property to one JSON-property and read from another. Property 'name' is serialized to 'name-to-write' property and read from 'name-to-read' property during deserialization. + +[source,java] +---- +public class Person { + private String name; + private String profession; + + @JsonbProperty("name-to-write") + public String getName() { + return name; + } + + @JsonbProperty("name-to-read") + public void setName(String name) { + this.name = name; + } + + // other public getters/setters ... +} +---- + +===== Naming Strategies + +Naming strategy is used to change a default way of constructing property names. + +Supported naming strategies are: + +- IDENTITY (myMixedCaseProperty) +- LOWER_CASE_WITH_DASHES (my-mixed-case-property) +- LOWER_CASE_WITH_UNDERSCORES (my_mixed_case_property) +- UPPER_CAMEL_CASE (MyMixedCaseProperty) +- UPPER_CAMEL_CASE_WITH_SPACES (My Mixed Case Property) +- CASE_INSENSITIVE (mYmIxEdCaSePrOpErTy) +- Or your custom implementation of JsonbNamingStrategy interface + +IDENTITY strategy is the default one. + +It can be applied using with withPropertyNamingStrategy method of JsonbConfig class: + +[source,java] +---- +// Custom configuration +JsonbConfig config = new JsonbConfig() + .withPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CASE_WITH_DASHES); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(config); + +... +---- + + +==== Properties order + +To customize the order of serialized properties, JSON Binding provides PropertyOrderStrategy class. + +The supported strategies are: + +- LEXICOGRAPHICAL (A-Z) +- ANY (order is undefined, in the most cases it will an order in which properties appear in the class) +- REVERSE (Z-A) + +Default order strategy is LEXICOGRAPHICAL. +Order strategy can be applied globally using withPropertyOrderStrategy method of JsonbConfig class: + +[source,java] +---- +// Custom configuration +JsonbConfig config = new JsonbConfig() + .withPropertyOrderStrategy(PropertyOrderStrategy.ANY); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(config); + +... +---- + +or using @JsonbPropertyOrder annotation on class: + +[source,java] +---- +@JsonbPropertyOrder(PropertyOrderStrategy.ANY) +public class Person { + private String name; + private String profession; + + // public getters/setters ... +} +---- + +==== Ignoring properties + +By default, JSONB ignores properties with a non public access. All public properties - either public fields or +non public fields with public getters are serialized into JSON text. + +Excluding properties can be done with a @JsonbTransient annotation. Class properties annotated with +@JsonbTransient annotation are ignored by JSON Binding engine. The behavior is different depending on +where @JsonbTransient annotation is placed. + +- On field: Property is ignored during serialization and deserialization. +- On getter: Property is ignored during serialization only. +- On setter: Property is ignored during deserialization only. + +Serialization of this class + +[source,java] +---- +@JsonbPropertyOrder(PropertyOrderStrategy.ANY) +public class Person { + @JsonbTransient + private String name; + + private String profession; + + // public getters/setters ... +} +---- + +will produce the following JSON document: + +[source,json] +---- +{ + "profession": "Super Agent" +} +---- + +If @JsonbTransient annotation is placed on getter like this: + +[source,java] +---- +public class Person { + private String name; + private String profession; + + @JsonbTransient + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + // other public getters/setters ... +} +---- + +'name' property won't be serialized, but will be deserialized. + +==== Null handling + +By default JSON-B doesn't serialize fields with null values. This may be a not desired behaviour. +There are three different ways to change default null handling. + +- On a class or package level using @JsonbNillable annotation + +[source,java] +---- +@JsonbNillable +public class Person { + private String name; + private String profession; + + // public getters/setters ... +} +---- + +- On individual properties using @JsonbProperty annotation with nillable=true parameter + +[source,java] +---- +public class Person { + @JsonbProperty(nillable=true) + private String name; + + private String profession; + + // public getters/setters ... +} +---- + +- Globally using withNullValues method of JsonbConfig class + +[source,java] +---- +// Create custom configuration +JsonbConfig nillableConfig = new JsonbConfig() + .withNullValues(true); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(nillableConfig); + +... +---- + +==== Custom instantiation + +By default, public default no-arguments constructor is required for deserialization. In many scenarios this requirement is too strict. JSON-B provides @JsonbCreator annotation which can be used to annotate a custom constructor with parameters or a static factory method used to create a class instance. + +The sample below shows how @JsonbCreator annotation can be used on a custom constructor. @JsonbProperty annotation on the constructor parameter is required for proper parameter substitution. In this case a value of JSON property 'name' will be passed to the constructor. + +[source,java] +---- +public class Person { + private String name; + private String profession; + + @JsonbCreator + public Person(@JsonbProperty("name") String name) { + this.name = name; + } + + // public getters/setters ... +} +---- + +==== Date/Number Formats + +By default JSON-B uses ISO formats to serialize and deserialize date and number fields. Sometimes it's required to override these settings. It can be done using @JsonbDateFormat and @JsonbNumberFormat annotations on fields: + +[source,java] +---- +public class Person { + private String name; + + @JsonbDateFormat("dd.MM.yyyy") + private LocalDate birthDate; + + @JsonbNumberFormat("#0.00") + private BigDecimal salary; + + // public getters/setters ... +} +---- + +or globally using withDateFormat method of JsonbConfig class: + +[source,java] +---- +// Create custom configuration +JsonbConfig config = new JsonbConfig() + .withDateFormat("dd.MM.yyyy", null); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(config); + +... +---- + + +==== Binary Encoding + +JSON-B supports mapping of binary data. By default it uses BYTE encoding, but it can be easily customized using BinaryDataStrategy class which provides support for the most common binary data encodings: + +- BYTE +- BASE_64 +- BASE_64_URL + +The sample below shows a creation of Jsonb engine with BASE_64_URL encoding: + +[source,java] +---- +// Create custom configuration +JsonbConfig config = new JsonbConfig() + .withBinaryDataStrategy(BinaryDataStrategy.BASE_64); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(config); + +... +---- + + +==== Adapters + +In some cases it may be difficult to serialize/deserialize a class the desired way. Sometimes it's not possible to put custom annotations on the source code because you don't have access to it or custom annotations don't solve the problem. In this case adapters is another option to try. + +Adapter is a class implementing jakarta.json.bind.adapter.JsonbAdapter interface. It has a custom code to convert the “unmappable” type (Original) into another one (Adapted) that is serialized/deserialized the desired way. It's similar to how type adapters in JAXB work. + +Let's take a look at the sample. Imagine that you have a Customer object with all customer details. In one scenario you need to serialize the whole object, in another you need to provide only its id and name. The solution could be to to serialize it as it is for the first scenario and create an adapter to JsonObject which has only data required for the second scenario. + +[source,java] +---- +public class Customer { + private int id; + private String name; + private String organization; + private String position; + + // public getters/setters ... +} + +public class CustomerAnnotated { + @JsonbProperty("customer_id") + private int id; + + @JsonbProperty("customer_name") + private String name; + + // public getters/setters ... +} + +public class CustomerAdapter implements JsonbAdapter<Customer, CustomerAnnotated> { + @Override + public CustomerAnnotated adaptToJson(Customer c) throws Exception { + if (c == null) + return null; + CustomerAnnotated customer = new CustomerAnnotated(); + customer.setId(c.getId()); + customer.setName(c.getName()); + return customer; + } + + @Override + public Customer adaptFromJson(CustomerAnnotated adapted) throws Exception { + if (adapted == null) + return null; + Customer customer = new Customer(); + customer.setId(adapted.getId()); + customer.setName(adapted.getName()); + return customer; + } +} + +---- + +First scenario: + +[source,java] +---- +// Create Jsonb with default configuration +Jsonb jsonb = JsonbBuilder.create(); + +// Create customer +Customer customer = new Customer(); + +// Initialization code is skipped + +// Serialize +jsonb.toJson(customer); +---- + +Result: + +[source,json] +---- +{ + "id": 1, + "name": "Jason Bourne", + "organization": "Super Agents", + "position": "Super Agent" +} +---- + +Second scenario: + +[source,java] +---- +// Create custom configuration +JsonbConfig config = new JsonbConfig() + .withAdapters(new CustomerAdapter()); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(config); + +// Create customer +Customer customer = new Customer(); + +// Initialization code is skipped + +// Serialize +jsonb.toJson(customer); +---- + +Result: + +[source,json] +---- +{ + "customer_id": 1, + "customer_name": "Jason Bourne", +} +---- + + +==== Serializers/Deserializers + +Sometimes adapters mechanism is not enough and low level access to JSONP parser/generator is needed. + +From the spec: + +Serializer is a class implementing jakarta.json.bind.serializers.JsonbSerializer interface. It is used to serialize the type it’s registered on (Original). On serializing of Original type JSONB calls JsonbSerializer::serialize method. This method has to contain a custom code to serialize Original type using provided JsonpGenerator. + +Deserializer is a class implementing jakarta.json.bind.serializers.JsonbDeserializer interface. It is used to deserialize the type it’s registered on (Original). On deserialization of Original type JSONB calls JsonbDeserializer::deserialize method. This method has to contain a custom code to deserialize Original type using provided JsonpParser. + +Let's take a look at the sample. Imagine that we would like to serialize and deserialize a list of pet carriers. A carried pet defined by an abstract class Animal. It can be any of its subclasses. We would like to properly serialize and deserialize it. In order to do it we need to preserve a type information in JSON document and use it on deserialization. It can be done using custom serializer/deserializer pair. + + +Model: + +[source,java] +---- +public static class Customer { + private int id; + private String name; + private String organization; + private String position; + + // public getters/setters +} +---- + +Serializer/Deserializer: + +[source,java] +---- +public static class CustomerSerializer implements JsonbSerializer<Customer> { + @Override + public void serialize(Customer customer, JsonGenerator generator, SerializationContext ctx) { + generator.writeStartObject(); + generator.write("customer_id", customer.getId()); + generator.write("customer_name", customer.getName()); + generator.writeEnd(); + } +} + +public static class CustomerDeserializer implements JsonbDeserializer<Customer> { + @Override + public Customer deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + Customer customer = new Customer(); + JsonParser.Event next; + + // Moving parser by hand looking for customer_id and customer_name properties + while ((next = parser.next()) != JsonParser.Event.END_OBJECT) { + if (next == JsonParser.Event.KEY_NAME) { + String jsonKeyName = parser.getString(); + + // Move to json value + parser.next(); + + if ("customer_id".equals(jsonKeyName)) { + customer.setId(parser.getInt()); + } else if ("customer_name".equals(jsonKeyName)) { + customer.setName(parser.getString()); + } + } + } + return customer; + } +} +---- + +Usage: + +[source,java] +---- +// Create pojo +Customer customer = new Customer(); +customer.setId(1); +customer.setName("Freddie"); + +// Also configurable with @JsonbSerializer / JsonbDeserializer on properties and class. +JsonbConfig config = new JsonbConfig() + .withSerializers(new CustomerSerializer()) + .withDeserializers(new CustomerDeserializer()); + +Jsonb jsonb = JsonbBuilder.create(config); +String json = jsonb.toJson(customer); +Customer result = jsonb.fromJson(json, Customer.class); +---- + +==== Strict I-JSON support + +https://tools.ietf.org/html/draft-ietf-json-i-json-06[I-JSON] (”Internet JSON”) is a restricted profile of JSON. JSON-B fully supports I-JSON by default with three exceptions: + +- JSON Binding does not restrict the serialization of top-level JSON texts that are neither objects nor arrays. The restriction should happen at application level. +- JSON Binding does not serialize binary data with base64url encoding. +- JSON Binding does not enforce additional restrictions on dates/times/duration. + +Full support mode can be switched on like it's shown below: + +[source,java] +---- +// Create custom configuration +JsonbConfig config = new JsonbConfig() + .withStrictIJSON(true); + +// Create Jsonb with custom configuration +Jsonb jsonb = JsonbBuilder.create(config); + +... +---- + + +== Further Information + +- JSON-B official web site: https://jakartaee.github.io/jsonb-api +- Jakarta JSON Binding: https://projects.eclipse.org/projects/ee4j.jsonb +- Mailing list: jsonb-dev@eclipse.org +- Yasson (Compatible Implementation): https://github.com/eclipse-ee4j/yasson
diff --git a/etc/config/checkstyle.xml b/etc/config/checkstyle.xml new file mode 100644 index 0000000..3892350 --- /dev/null +++ b/etc/config/checkstyle.xml
@@ -0,0 +1,229 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.2//EN" "http://www.puppycrawl.com/dtds/configuration_1_2.dtd"> +<!-- + This file is based on maven-checkstyle-plugin config/sun_checks.xml file. + + Checkstyle configuration that checks the coding conventions based on: + + - the Java Language Specification at + http://java.sun.com/docs/books/jls/second_edition/html/index.html + + - the Sun Code Conventions at http://java.sun.com/docs/codeconv/ + + - the Javadoc guidelines at + http://java.sun.com/j2se/javadoc/writingdoccomments/index.html + + - the JDK Api documentation http://java.sun.com/j2se/docs/api/index.html + + - some custom relaxations of the rules above & best practices + + Checkstyle is very configurable. Be sure to read the documentation at + http://checkstyle.sf.net (or in your downloaded distribution). + + Most Checks are configurable, be sure to consult the documentation. + To completely disable a check, just comment it out or delete it from the file. + Finally, it is worth reading the documentation. +--> + +<module name="Checker"> + <!-- + If you set the basedir property below, then all reported file + names will be relative to the specified directory. See + http://checkstyle.sourceforge.net/5.x/config.html#Checker + + <property name="basedir" value="${basedir}"/> + --> + + <!-- Checks that each Java package has a Javadoc file used for commenting. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage --> + <module name="JavadocPackage" /> + + <!-- Checks whether files end with a new line. --> + <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile --> + <module name="NewlineAtEndOfFile"/> + + <!-- Checks that property files contain the same keys. --> + <!-- See http://checkstyle.sf.net/config_misc.html#Translation --> + <module name="Translation"/> + + <module name="FileLength"/> + + <!-- Following interprets the header file as regular expressions. --> + <!-- <module name="RegexpHeader"/> --> + + <module name="FileTabCharacter"> + <property name="eachLine" value="true"/> + </module> + + <module name="RegexpSingleline"> + <property name="format" value="\S+\s+$"/> + <property name="message" value="Non-empty line has trailing spaces."/> + </module> + + <module name="TreeWalker"> + <property name="cacheFile" value="${checkstyle.cache.file}"/> + <property name="tabWidth" value="4"/> + + <!-- Checks for Javadoc comments. --> + <!-- See http://checkstyle.sf.net/config_javadoc.html --> + <module name="JavadocMethod"> + <property name="scope" value="protected"/> + <property name="allowUndeclaredRTE" value="true"/> + </module> + <module name="JavadocType"> + <property name="scope" value="protected"/> + </module> + <module name="JavadocVariable"> + <property name="scope" value="protected"/> + </module> + <module name="JavadocStyle"/> + + + <!-- Checks for Naming Conventions. --> + <!-- See http://checkstyle.sf.net/config_naming.html --> + <module name="ConstantName"/> + <module name="LocalFinalVariableName"/> + <module name="LocalVariableName"/> + <module name="MemberName"/> + <module name="MethodName"/> + <module name="PackageName"/> + <module name="ParameterName"/> + <module name="StaticVariableName"/> + <module name="TypeName"/> + + + <!-- Checks for Headers --> + <!-- See http://checkstyle.sf.net/config_header.html --> + <!-- <module name="Header"> --> + <!-- The follow property value demonstrates the ability --> + <!-- to have access to ANT properties. In this case it uses --> + <!-- the ${basedir} property to allow Checkstyle to be run --> + <!-- from any directory within a project. See property --> + <!-- expansion, --> + <!-- http://checkstyle.sf.net/config.html#properties --> + <!-- <property --> + <!-- name="headerFile" --> + <!-- value="${basedir}/java.header"/> --> + <!-- </module> --> + + + <!-- Checks for imports --> + <!-- See http://checkstyle.sf.net/config_import.html --> + <module name="AvoidStarImport"/> + <module name="IllegalImport"/> <!-- defaults to sun.* packages --> + <module name="RedundantImport"/> + <module name="UnusedImports"/> + + + <!-- Checks for Size Violations. --> + <!-- See http://checkstyle.sf.net/config_sizes.html --> + <module name="LineLength"> + <property name="max" value="120"/> + <property name="ignorePattern" value="@version|@see|@todo|TODO"/> + </module> + <module name="MethodLength"/> + <module name="ParameterNumber"/> + + + <!-- Checks for whitespace --> + <!-- See http://checkstyle.sf.net/config_whitespace.html --> + <module name="EmptyForIteratorPad"/> + <module name="MethodParamPad"/> + <module name="NoWhitespaceAfter"/> + <!--property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS" /> + </module--> + <module name="NoWhitespaceBefore"/> + <module name="OperatorWrap"/> + <module name="ParenPad"/> + <module name="TypecastParenPad"/> + <module name="WhitespaceAfter"/> + <module name="WhitespaceAround"> + <property name="tokens" value="ASSIGN, BAND, BAND_ASSIGN, BOR, + BOR_ASSIGN, BSR, BSR_ASSIGN, BXOR, BXOR_ASSIGN, COLON, DIV, + DIV_ASSIGN, EQUAL, GE, GT, LAND, LCURLY, LE, LITERAL_ASSERT, + LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, + LITERAL_FOR, LITERAL_IF, LITERAL_RETURN, LITERAL_SYNCHRONIZED, + LITERAL_TRY, LITERAL_WHILE, LOR, LT, MINUS, MINUS_ASSIGN, MOD, + MOD_ASSIGN, NOT_EQUAL, PLUS, PLUS_ASSIGN, QUESTION, SL, + SLIST, SL_ASSIGN, SR, SR_ASSIGN, STAR, STAR_ASSIGN, + TYPE_EXTENSION_AND" /> <!-- RCURLY removed --> + </module> + + + <!-- Modifier Checks --> + <!-- See http://checkstyle.sf.net/config_modifiers.html --> + <module name="ModifierOrder"/> + <!--module name="RedundantModifier"/--> + + + <!-- Checks for blocks. You know, those {}'s --> + <!-- See http://checkstyle.sf.net/config_blocks.html --> + <module name="AvoidNestedBlocks"/> + <module name="EmptyBlock"/> + <module name="LeftCurly"/> + <module name="NeedBraces"/> + <module name="RightCurly"/> + + + <!-- Checks for common coding problems --> + <!-- See http://checkstyle.sf.net/config_coding.html --> + <!-- module name="AvoidInlineConditionals"/--> + <!--module name="DoubleCheckedLocking"/--> + <module name="EmptyStatement"/> + <module name="EqualsHashCode"/> + <module name="HiddenField"> + <property name="ignoreConstructorParameter" value="true"/> + <property name="ignoreSetter" value="true"/> + </module> + <module name="IllegalInstantiation"/> + <module name="InnerAssignment"/> + <!-- + Unable to use MagicNumber until maven plugin supports Checkstyle 5.3 + or, at least, until Checkstyle 5.3 is available in a maven repository + <module name="MagicNumber"> + <property name="ignoreHashCodeMethod" value="true"/> + </module--> + <module name="MissingSwitchDefault"/> + <module name="SimplifyBooleanExpression"/> + <module name="SimplifyBooleanReturn"/> + + + <!-- Checks for class design --> + <!-- See http://checkstyle.sf.net/config_design.html --> + <!--module name="DesignForExtension"/--> + <module name="FinalClass"/> + <module name="HideUtilityClassConstructor"/> + <module name="InterfaceIsType"/> + <module name="VisibilityModifier"/> + <module name="ThrowsCount"> + <property name="max" value="3"/> + </module> + + + + <!-- Miscellaneous other checks. --> + <!-- See http://checkstyle.sf.net/config_misc.html --> + <module name="ArrayTypeStyle"/> + <module name="FinalParameters"/> + <module name="TodoComment"/> + <module name="UpperEll"/> + </module> +</module>
diff --git a/etc/config/copyright-exclude b/etc/config/copyright-exclude new file mode 100644 index 0000000..b39b750 --- /dev/null +++ b/etc/config/copyright-exclude
@@ -0,0 +1,33 @@ +.apt +.args +.bundle +.class +.exe +.gif +.gitignore +.ico +.iml +.ipr +.iws +.jar +.jks +.jpg +.js +.json +.mm +.ods +.png +.project +.sql +.svg +.war +.zip +.dat +/MANIFEST.MF +/META-INF/services/ +/README +spec-license.html +copyright-exclude +api/etc/config/copyright.txt +nb-configuration.xml +EFSL.html
diff --git a/etc/config/edl-copyright.txt b/etc/config/edl-copyright.txt new file mode 100644 index 0000000..1858057 --- /dev/null +++ b/etc/config/edl-copyright.txt
@@ -0,0 +1,9 @@ +/* + * Copyright (c) YYYY Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Distribution License v. 1.0, which is available at + * http://www.eclipse.org/org/documents/edl-v10.php. + * + * SPDX-License-Identifier: BSD-3-Clause + */
diff --git a/etc/config/epl-copyright.txt b/etc/config/epl-copyright.txt new file mode 100644 index 0000000..9c347b6 --- /dev/null +++ b/etc/config/epl-copyright.txt
@@ -0,0 +1,15 @@ +/* + * Copyright (c) YYYY Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */
diff --git a/etc/config/spotbugs-exclude.xml b/etc/config/spotbugs-exclude.xml new file mode 100644 index 0000000..6e7dd29 --- /dev/null +++ b/etc/config/spotbugs-exclude.xml
@@ -0,0 +1,20 @@ +<!-- + + Copyright (c) 2024 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<FindBugsFilter> +</FindBugsFilter> \ No newline at end of file
diff --git a/spec/LICENSE b/spec/LICENSE new file mode 100644 index 0000000..d3087e4 --- /dev/null +++ b/spec/LICENSE
@@ -0,0 +1,277 @@ +Eclipse Public License - v 2.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION + OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + + a) in the case of the initial Contributor, the initial content + Distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + where such changes and/or additions to the Program originate from + and are Distributed by that particular Contributor. A Contribution + "originates" from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include changes or additions to the Program that + are not Modified Works. + +"Contributor" means any person or entity that Distributes the Program. + +"Licensed Patents" mean patent claims licensable by a Contributor which +are necessarily infringed by the use or sale of its Contribution alone +or when combined with the Program. + +"Program" means the Contributions Distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this Agreement +or any Secondary License (as applicable), including Contributors. + +"Derivative Works" shall mean any work, whether in Source Code or other +form, that is based on (or derived from) the Program and for which the +editorial revisions, annotations, elaborations, or other modifications +represent, as a whole, an original work of authorship. + +"Modified Works" shall mean any work in Source Code or other form that +results from an addition to, deletion from, or modification of the +contents of the Program, including, for purposes of clarity any new file +in Source Code form that contains any contents of the Program. Modified +Works shall not include works that contain only declarations, +interfaces, types, classes, structures, or files of the Program solely +in each case in order to link to, bind by name, or subclass the Program +or Modified Works thereof. + +"Distribute" means the acts of a) distributing or b) making available +in any manner that enables the transfer of a copy. + +"Source Code" means the form of a Program preferred for making +modifications, including but not limited to software source code, +documentation source, and configuration files. + +"Secondary License" means either the GNU General Public License, +Version 2.0, or any later versions of that license, including any +exceptions or additional permissions as identified by the initial +Contributor. + +2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free copyright + license to reproduce, prepare Derivative Works of, publicly display, + publicly perform, Distribute and sublicense the Contribution of such + Contributor, if any, and such Derivative Works. + + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free patent + license under Licensed Patents to make, use, sell, offer to sell, + import and otherwise transfer the Contribution of such Contributor, + if any, in Source Code or other form. This patent license shall + apply to the combination of the Contribution and the Program if, at + the time the Contribution is added by the Contributor, such addition + of the Contribution causes such combination to be covered by the + Licensed Patents. The patent license shall not apply to any other + combinations which include the Contribution. No hardware per se is + licensed hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the + rights and licenses granted hereunder, each Recipient hereby + assumes sole responsibility to secure any other intellectual + property rights needed, if any. For example, if a third party + patent license is required to allow Recipient to Distribute the + Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + + d) Each Contributor represents that to its knowledge it has + sufficient copyright rights in its Contribution, if any, to grant + the copyright license set forth in this Agreement. + + e) Notwithstanding the terms of any Secondary License, no + Contributor makes additional grants to any Recipient (other than + those set forth in this Agreement) as a result of such Recipient's + receipt of the Program under the terms of a Secondary License + (if permitted under the terms of Section 3). + +3. REQUIREMENTS + +3.1 If a Contributor Distributes the Program in any form, then: + + a) the Program must also be made available as Source Code, in + accordance with section 3.2, and the Contributor must accompany + the Program with a statement that the Source Code for the Program + is available under this Agreement, and informs Recipients how to + obtain it in a reasonable manner on or through a medium customarily + used for software exchange; and + + b) the Contributor may Distribute the Program under a license + different than this Agreement, provided that such license: + i) effectively disclaims on behalf of all other Contributors all + warranties and conditions, express and implied, including + warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness + for a particular purpose; + + ii) effectively excludes on behalf of all other Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) does not attempt to limit or alter the recipients' rights + in the Source Code under section 3.2; and + + iv) requires any subsequent distribution of the Program by any + party to be under a license that satisfies the requirements + of this section 3. + +3.2 When the Program is Distributed as Source Code: + + a) it must be made available under this Agreement, or if the + Program (i) is combined with other material in a separate file or + files made available under a Secondary License, and (ii) the initial + Contributor attached to the Source Code the notice described in + Exhibit A of this Agreement, then the Program may be made available + under the terms of such Secondary Licenses, and + + b) a copy of this Agreement must be included with each copy of + the Program. + +3.3 Contributors may not remove or alter any copyright, patent, +trademark, attribution notices, disclaimers of warranty, or limitations +of liability ("notices") contained within the Program from any copy of +the Program which they Distribute, provided that Contributors may add +their own appropriate notices. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities +with respect to end users, business partners and the like. While this +license is intended to facilitate the commercial use of the Program, +the Contributor who includes the Program in a commercial product +offering should do so in a manner which does not create potential +liability for other Contributors. Therefore, if a Contributor includes +the Program in a commercial product offering, such Contributor +("Commercial Contributor") hereby agrees to defend and indemnify every +other Contributor ("Indemnified Contributor") against any losses, +damages and costs (collectively "Losses") arising from claims, lawsuits +and other legal actions brought by a third party against the Indemnified +Contributor to the extent caused by the acts or omissions of such +Commercial Contributor in connection with its distribution of the Program +in a commercial product offering. The obligations in this section do not +apply to any claims or Losses relating to any actual or alleged +intellectual property infringement. In order to qualify, an Indemnified +Contributor must: a) promptly notify the Commercial Contributor in +writing of such claim, and b) allow the Commercial Contributor to control, +and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may +participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those performance +claims and warranties, and if a court requires any other Contributor to +pay any damages as a result, the Commercial Contributor must pay +those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" +BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF +TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR +PURPOSE. Each Recipient is solely responsible for determining the +appropriateness of using and distributing the Program and assumes all +risks associated with its exercise of rights under this Agreement, +including but not limited to the risks and costs of program errors, +compliance with applicable laws, damage to or loss of data, programs +or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT +PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS +SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the +Program itself (excluding combinations of the Program with other software +or hardware) infringes such Recipient's patent(s), then such Recipient's +rights granted under Section 2(b) shall terminate as of the date such +litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign the +responsibility to serve as the Agreement Steward to a suitable separate +entity. Each new version of the Agreement will be given a distinguishing +version number. The Program (including Contributions) may always be +Distributed subject to the version of the Agreement under which it was +received. In addition, after a new version of the Agreement is published, +Contributor may elect to Distribute the Program (including its +Contributions) under the new version. + +Except as expressly stated in Sections 2(a) and 2(b) above, Recipient +receives no rights or licenses to the intellectual property of any +Contributor under this Agreement, whether expressly, by implication, +estoppel or otherwise. All rights in the Program not expressly granted +under this Agreement are reserved. Nothing in this Agreement is intended +to be enforceable by any entity that is not a Contributor or Recipient. +No third-party beneficiary rights are created under this Agreement. + +Exhibit A - Form of Secondary Licenses Notice + +"This Source Code may also be made available under the following +Secondary Licenses when the conditions for such availability set forth +in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), +version(s), and exceptions or additional permissions here}." + + Simply including a copy of this Agreement, including this Exhibit A + is not sufficient to license the Source Code under Secondary Licenses. + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to + look for such a notice. + + You may add additional accurate notices of copyright ownership.
diff --git a/spec/README.md b/spec/README.md new file mode 100644 index 0000000..35c754d --- /dev/null +++ b/spec/README.md
@@ -0,0 +1,26 @@ +Jakarta JSON Binding Specification +=================================== + +This project generates the Jakarta JSON Binding Specification. + +Building +-------- + +Prerequisites: + +* JDK8+ +* Maven 3.0.3+ + +Run the full build: + +`mvn clean install` + +Generate specification with given status: + +`mvn clean install -Dstatus="Final Release"` + +Locate the html files: +- target/generated-docs/jsonb-spec-XXX.html + +Locate the PDF files: +- target/generated-docs/jsonb-spec-XXX.pdf
diff --git a/spec/assembly.xml b/spec/assembly.xml new file mode 100644 index 0000000..99e3413 --- /dev/null +++ b/spec/assembly.xml
@@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="iso-8859-1"?> +<!-- + + Copyright (c) 2017, 2019 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<assembly> + <id>spec</id> + <formats> + <format>zip</format> + </formats> + <baseDirectory>jsonb-spec</baseDirectory> + <fileSets> + <fileSet> + <directory>target/generated-docs</directory> + <outputDirectory></outputDirectory> + </fileSet> + </fileSets> +</assembly>
diff --git a/spec/pom.xml b/spec/pom.xml new file mode 100644 index 0000000..c892ce6 --- /dev/null +++ b/spec/pom.xml
@@ -0,0 +1,210 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <parent> + <groupId>org.eclipse.ee4j</groupId> + <artifactId>project</artifactId> + <version>1.0.9</version> + <relativePath/> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>jakarta.json.bind</groupId> + <artifactId>jsonb-spec</artifactId> + <packaging>pom</packaging> + <version>3.0-SNAPSHOT</version> + <name>Jakarta JSON Binding Specification</name> + + <properties> + <site.output.dir>${project.build.directory}/staging</site.output.dir> + <maven.site.skip>true</maven.site.skip> + <asciidoctor.maven.plugin.version>1.6.0</asciidoctor.maven.plugin.version> + <asciidoctorj.version>1.6.2</asciidoctorj.version> + <asciidoctorj.pdf.version>1.5.0-rc.1</asciidoctorj.pdf.version> + <jruby.version>9.2.9.0</jruby.version> + <!-- status: DRAFT, BETA, etc., or blank for final --> + <status>DRAFT</status> + <maven.build.timestamp.format>MMMM dd, yyyy</maven.build.timestamp.format> + <revisiondate>${maven.build.timestamp}</revisiondate> + </properties> + + <scm> + <connection>scm:git:git://github.com/jakartaee/jsonb-api.git</connection> + <developerConnection>scm:git:git@github.com:jakartaee/jsonb-api.git</developerConnection> + <url>https://github.com/jakartaee/jsonb-api</url> + <tag>HEAD</tag> + </scm> + + <distributionManagement> + <site> + <url>scm:git:git@github.com:jakartaee/jsonb-api.git</url> + </site> + </distributionManagement> + + <build> + <defaultGoal>package</defaultGoal> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <version>1.4.1</version> + <executions> + <execution> + <id>enforce-versions</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <requireJavaVersion> + <version>[1.8.0,)</version> + <message>You need JDK8 or later</message> + </requireJavaVersion> + </rules> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctor-maven-plugin</artifactId> + <version>${asciidoctor.maven.plugin.version}</version> + <dependencies> + <dependency> + <groupId>org.jruby</groupId> + <artifactId>jruby-complete</artifactId> + <version>${jruby.version}</version> + </dependency> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj</artifactId> + <version>${asciidoctorj.version}</version> + </dependency> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj-pdf</artifactId> + <version>${asciidoctorj.pdf.version}</version> + </dependency> + </dependencies> + <executions> + <execution> + <id>asciidoc-to-html</id> + <phase>generate-resources</phase> + <goals> + <goal>process-asciidoc</goal> + </goals> + <configuration> + <backend>html5</backend> + <outputFile>${project.build.directory}/generated-docs/jsonb-spec-${project.version}.html</outputFile> + <attributes> + <doctype>book</doctype> + <status>${status}</status> + <data-uri /> + <icons>font</icons> + <toc>left</toc> + <icons>font</icons> + <sectanchors>true</sectanchors> + <idprefix /> + <idseparator>-</idseparator> + <docinfo1>true</docinfo1> + </attributes> + </configuration> + </execution> + <execution> + <id>asciidoc-to-pdf</id> + <phase>generate-resources</phase> + <goals> + <goal>process-asciidoc</goal> + </goals> + <configuration> + <backend>pdf</backend> + <outputFile>${project.build.directory}/generated-docs/jsonb-spec-${project.version}.pdf</outputFile> + <attributes> + <pdf-stylesdir>${project.basedir}/src/theme</pdf-stylesdir> + <pdf-style>jakartaee</pdf-style> + <doctype>book</doctype> + <status>${status}</status> + <data-uri /> + <icons>font</icons> + <pagenums /> + <toc /> + <icons>font</icons> + <sectanchors>true</sectanchors> + <idprefix /> + <idseparator>-</idseparator> + <docinfo1>true</docinfo1> + <embedAssets>true</embedAssets> + </attributes> + </configuration> + </execution> + </executions> + <configuration> + <sourceDocumentName>jsonb-spec.adoc</sourceDocumentName> + <sourceHighlighter>coderay</sourceHighlighter> + <attributes> + <revnumber>${project.version}</revnumber> + <revremark>${status}</revremark> + <revdate>${revisiondate}</revdate> + </attributes> + </configuration> + + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-release-plugin</artifactId> + <version>2.5.2</version> + <configuration> + <mavenExecutorId>forked-path</mavenExecutorId> + <useReleaseProfile>false</useReleaseProfile> + <arguments>${release.arguments}</arguments> + </configuration> + <dependencies> + <dependency> + <groupId>org.apache.maven.scm</groupId> + <artifactId>maven-scm-provider-gitexe</artifactId> + <version>1.9.4</version> + </dependency> + </dependencies> + </plugin> + + <!-- + This is the rule that builds the zip file for download. + --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>3.1.1</version> + <inherited>false</inherited> + <executions> + <execution> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + <descriptors> + <descriptor>assembly.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
diff --git a/spec/src/main/asciidoc/images/jakarta_ee_logo_schooner_color_stacked_default.png b/spec/src/main/asciidoc/images/jakarta_ee_logo_schooner_color_stacked_default.png new file mode 100644 index 0000000..97b46ce --- /dev/null +++ b/spec/src/main/asciidoc/images/jakarta_ee_logo_schooner_color_stacked_default.png Binary files differ
diff --git a/spec/src/main/asciidoc/jsonb-spec.adoc b/spec/src/main/asciidoc/jsonb-spec.adoc new file mode 100644 index 0000000..52ae7bb --- /dev/null +++ b/spec/src/main/asciidoc/jsonb-spec.adoc
@@ -0,0 +1,28 @@ +// +// Copyright (c) 2017, 2019 Contributors to the Eclipse Foundation +// + += Jakarta JSON Binding +:authors: Jakarta JSON Binding Team, https://projects.eclipse.org/projects/ee4j.jsonb +:email: https://dev.eclipse.org/mailman/listinfo/jsonb-dev +:version-label!: +:doctype: book +:license: Eclipse Foundation Specification License v1.0 +:source-highlighter: coderay +:toc: left +:toclevels: 4 +:sectnumlevels: 4 +:sectanchors: +ifdef::backend-pdf[] +:pagenums: +:numbered: +:title-logo-image: image:jakarta_ee_logo_schooner_color_stacked_default.png[pdfwidth=4.25in,align=right] +endif::[] + +// == License +:sectnums!: +include::license-efsl.adoc[] + +// == Spec +:sectnums: +include::jsonb.adoc[]
diff --git a/spec/src/main/asciidoc/jsonb.adoc b/spec/src/main/asciidoc/jsonb.adoc new file mode 100644 index 0000000..0e7d44c --- /dev/null +++ b/spec/src/main/asciidoc/jsonb.adoc
@@ -0,0 +1,836 @@ +:sectnums: += Jakarta JSON Binding Specification + +== Introduction + +This specification defines binding API between Java objects and https://tools.ietf.org/html/rfc7159[JSON] documents. Readers are assumed to be familiar with JSON; for more information about JSON, see: + +* https://www.ics.uci.edu/~fielding/pubs/dissertation/fielding_dissertation.pdf[Architectural Styles and the Design of Network-based Software Architectures] +* http://en.wikipedia.org/wiki/JSON[JSON on Wikipedia] + +=== Status + +A list of open issues can be found at: + +____ +https://github.com/jakartaee/jsonb-api/issues +____ + +The corresponding source code can be found online at: + +____ +https://github.com/jakartaee/jsonb-api +____ + +The committer group is seeking feedback from the community on any aspect of this specification. Please join our discussion groups at: + +____ +https://gitter.im/eclipse/jsonb +____ + +=== Goals + +The goals of the API are as follows: + +* *JSON* + +Support binding (serialization and deserialization) for all RFC 7159-compatible JSON documents. +* *Relationships to JSON Related specifications* + +JSON-related specifications will be surveyed to determine their relationship to JSON-Binding. +* *Consistency* + +Maintain consistency with Jakarta XML Binding and other Jakarta EE and Java SE APIs where appropriate. +* *Convention* + +Define default mapping of Java classes and instances to JSON document counterparts. +* *Customization* + +Allow customization of the default mapping definition. +* *Ease of Use* + +Default use of the APIs should not require prior knowledge of the JSON document format and specification. +* *Partial Mapping* + +In many use cases, only a subset of JSON Document is required to be mapped to a Java object instance. +* *Integration* + +Define or enable integration with Jakarta JSON Processing (JSON-P) 1.1. + +=== Non-Goals + +The following are non-goals: + +* *Preserving equivalence (Round-trip)* + +The specification recommends, but does not require equivalence of content for deserialized and serialized JSON documents. +* *JSON Schema* + +Generation of JSON Schema from Java classes, as well as validation based on JSON schema. +* *JEP 198 Lightweight JSON API* + +Support and integration with Lightweight JSON API as defined within JEP 198 is out of scope of this specification. Will be reconsidered in future specification revisions. + +=== Conventions + +The keywords ‘MUST’, ‘MUST NOT’, ‘REQUIRED’, ‘SHALL’, ‘SHALL NOT’, ‘SHOULD’, ‘SHOULD NOT’, ‘RECOMMENDED’, ‘MAY’, and ‘OPTIONAL’ in this document are to be interpreted as described in https://www.ietf.org/rfc/rfc2119.txt[RFC 2119]. + +Java code and sample data fragments are formatted as shown in Figure 1: + +[source,java] +.Example Java Code +---- +package com.example.hello; + +public class Hello { + public static void main(String args[]) { + System.out.println("Hello World"); + } +} +---- + +URIs of the general form link:http://example.org/...[http://example.org/...] and link:http://example.com/...[http://example.com/...] represent +application or context-dependent URIs. + +All parts of this specification are normative, with the exception of examples, notes and sections explicitly marked as ‘Non-Normative’. Non-normative notes are formatted as shown below: + +*Note:* _This is a note._ + +=== Terminology + +*Data binding* + +Process which defines the representation of information in a JSON document as an object instance, and vice versa. + +*Deserialization* + +Process of reading a JSON document and constructing a tree of content objects, where each object corresponds to part of JSON document, thus the content tree reflects the document’s content. + +*Serialization* + +Inverse process to deserialization. Process of traversing content object tree and writing a JSON document that reflects the tree’s content. + +=== Acknowledgements + +This specification was originally developed as part of JSR 367 under the Java Community Process. It was the result of the collaborative work of the members of the JSR 367 Expert Group. The following were the expert group members: + +* Dmitry Kornilov (Oracle) +* Roman Grigoriadi (Oracle) +* Lukas Jungmann (Oracle) +* Martin Vojtek (Datlowe) +* Hendrik Saly (Individual Member) +* Gregor Zurowski (Individual Member) +* Inderjeet Singh (Individual Member) +* Eugen Cepoi (Individual Member) +* Przemyslaw Bielicki (Individual Member) +* Kyung Koo Yoon (TmaxSoft, Inc.) +* Otavio Santana (Individual Member) +* Nathan Rauh (IBM) +* Alexander Salvanos (Individual Member) +* Romain Manni-Bucau (Tomitribe) + +During the course of JSR 367 we received many excellent suggestions. Special thanks to Heather VanCura, David Delabassee and Reza Rahman for feedback and help with evangelizing the specification, and John Clingan for feedback and language corrections. + +During the course of JSR 367 we also received many excellent suggestions. Thanks in particular to Mark Struberg, Olena Syrota, Oleg Tsal-Tsalko and whole JUG UA for their contributions. + +== Runtime API + +The JSON-B runtime API provides access to serialization and deserialization operations for manipulating JSON documents and mapped JSON-B classes and instances. The full specification of the binding framework is available in the javadoc for the `jakarta.json.bind` package accompanied with this specification. + +== Default Mapping + +This section defines the default binding (representation) of Java components and classes to JSON documents. The default binding defined here can be further customized as specified in Customizing Mapping. + +=== General + +JSON Binding implementations (_implementations_ in further text) MUST support binding of JSON documents as defined in https://tools.ietf.org/html/rfc7159[RFC 7159 JSON Grammar]]. Serialized JSON output MUST conform to the RFC 7159 JSON Grammar and be encoded in UTF-8 encoding as defined in Section 8.1 (Character Encoding) of RFC 7159. Implementations MUST support deserialization of documents conforming to RFC 7159 JSON Grammar. In addition, implementations SHOULD NOT allow deserialization of RFC 7159 non-conforming text (e.g. unsupported encoding, ...) and report error in such cases. Detection of UTF encoding of a deserialized document MUST follow the encoding process defined in the Section 3 (Encoding) of https://tools.ietf.org/html/rfc4627[RFC 4627]. Implementations SHOULD ignore the presence of an UTF byte order mark (BOM) and not treat it as an error. + +=== Errors + +Implementations SHOULD NOT allow deserialization of RFC 7159 non-conforming text (e.g. unsupported encoding, ...) and report an error in such case. Implementations SHOULD also report an error during a deserialization operation, if it is not possible to represent a JSON document value with the expected Java type. + +=== Basic Java Types + +Implementations MUST support binding of the following basic Java classes and their corresponding primitive types: + +* java.lang.String +* java.lang.Character +* java.lang.Byte +* java.lang.Short +* java.lang.Integer +* java.lang.Long +* java.lang.Float +* java.lang.Double +* java.lang.Boolean + +==== java.lang.String, Character + +Instances of type `java.lang.String` and `java.lang.Character` are serialized to JSON String values as defined within RFC 7159 Section 7 (Strings) in UTF-8 encoding without a byte order mark. [JSB-3.3.1-1] Implementations SHOULD support deserialization of JSON text in other (than UTF-8) UTF encodings into `java.lang.String` instances. + +==== java.lang.Byte, Short, Integer, Long, Float, Double + +Serialization of type `java.lang.Byte`, `Short`, `Integer`, `Long`, `Float` or `Double` (and their corresponding primitive types) to a JSON Number MUST follow the conversion process defined in the javadoc specification for the corresponding type’s `toString()` method [JSB-3.3.2-1]. Deserialization of a JSON value into `java.lang.Byte`, `Short`, `Integer`, `Long`, `Float` or `Double` instance (or their corresponding primitive types) MUST follow the conversion process defined in the javadoc specification for the corresponding `parse$Type` method, such as `java.lang.Byte.parseByte()` for `Byte`. + +==== java.lang.Boolean + +Serialization of type `java.lang.Boolean` and its corresponding `boolean` primitive type to a JSON value MUST follow the conversion process defined in the javadoc specification for `java.lang.Boolean.toString()` method. Deserialization of a JSON value into `java.lang.Boolean` instance or `boolean` primitive type MUST follow the conversion process defined in the javadoc specification for `java.lang.Boolean.parseBoolean()` method. + +==== java.lang.Number + +Serialization of `java.lang.Number` instances (if their more concrete type is not defined elsewhere in this chapter) to a JSON string MUST retrieve double value from `java.lang.Number.doubleValue()` method and convert it to a JSON Number as defined in section-3.3.2,section 3.3.2. Deserialization of a JSON value into `java.lang.Number` type MUST return an instance of `java.math.BigDecimal` by using conversion process defined in the javadoc specification for constructor of `java.math.BigDecimal` with `java.lang.String` argument. + +=== Specific Standard Java SE Types + +Implementations MUST support binding of the following standard Java SE classes: + +* java.math.BigInteger +* java.math.BigDecimal +* java.net.URL +* java.net.URI +* java.util.Optional +* java.util.OptionalInt +* java.util.OptionalLong +* java.util.OptionalDouble + +==== java.math.BigInteger, BigDecimal + +Serialization of type `java.math.BigInteger` or `BigDecimal` to a JSON Number MUST follow the conversion process defined in the javadoc specification for the corresponding type’s `toString()` method. Deserialization of a JSON value into `java.math.BigInteger` or `BigDecimal` instance MUST follow the conversion process defined in the javadoc specification for the constructor of `java.math.BigInteger` or `BigDecimal` with `java.lang.String` argument. + +==== java.net.URL, URI + +Serialization of type `java.net.URL` or `URI` to a JSON String MUST follow the conversion process defined in the javadoc specification for the corresponding type’s `toString()` method. Deserialization of a JSON value into `java.net.URL` or `URI` instance MUST follow the conversion process defined in the javadoc specification for the constructor of `java.net.URL` or `URI` with `java.lang.String` argument. + +==== java.util.Optional, OptionalInt, OptionalLong, OptionalDouble + +Non-empty instances of type java.util.Optional, OptionalInt, OptionalLong, OptionalDouble are serialized to a JSON value by retrieving their contained instance and converting it to JSON value based on its type and corresponding mapping definitions within this chapter. Class fields containing empty optional instances are treated as having a null value and serialized based on section 3.14.1. + +Empty optional instances in array items are serialized as null. + +Deserializing into `Optional`, `OptionalInt`, `OptionalLong`, `OptionalDouble` return empty optional value for properties containing a null value. Otherwise any non-empty `Optional`, `OptionalInt`, `OptionalLong`, `OptionalDouble` value is constructed of type which deserialized based on mappings defined in this chapter. + +Instances of type `java.util.Optional<T>` are serialized to a JSON value as JSON objects when T alone would be serialized as JSON object. When T would be serialized as a JSON value (e.g. `java.lang.String`, `java.lang.Integer`), an instance of `java.util.Optional<T>` is serialized as a JSON value (without curly brackets). + +Deserialization of a JSON value into `java.util.Optional<T>` MUST be supported if deserialization of a JSON value into instance of T is supported. + +=== Dates + +Implementations MUST support binding of the following standard Java date/time classes: + +* java.util.Date +* java.util.Calendar +* java.util.GregorianCalendar +* java.util.TimeZone +* java.util.SimpleTimeZone +* java.time.Instant +* java.time.Duration +* java.time.Period +* java.time.LocalDate +* java.time.LocalTime +* java.time.LocalDateTime +* java.time.ZonedDateTime +* java.time.ZoneId +* java.time.ZoneOffset +* java.time.OffsetDateTime +* java.time.OffsetTime + +If not specified otherwise in this section, GMT standard time zone and offset specified from UTC Greenwich is used. If not specified otherwise, the date time format for serialization and deserialization is ISO 8601 without offset, as specified in `java.time.format.DateTimeFormatter.ISO_DATE`. + +Implementations MUST report an error if the date/time string in a JSON document does not correspond to the expected date/time format. + +If in strict I-JSON compliance mode, default date format is changed as it’s described in 4.4.1. + +==== java.util.Date, Calendar, GregorianCalendar + +The serialization format of `java.util.Date`, `Calendar`, `GregorianCalendar` instances with no time information is `ISO_DATE`. + +If time information is present, the format is `ISO_DATE_TIME`. + +Implementations MUST support deserialization of both `ISO_DATE` and `ISO_DATE_TIME` into `java.util.Date`, `Calendar` and `GregorianCalendar` instances. + +==== java.util.TimeZone, SimpleTimeZone + +Implementations MUST support deserialization of any time zone format specified in `java.util.TimeZone` into a field or property of type `java.util.TimeZone` and `SimpleTimeZone`. + +Implementations MUST report an error for deprecated three-letter time zone IDs as specified in `java.util.Timezone`. + +The serialization format of `java.util.TimeZone` and `SimpleTimeZone` is `NormalizedCustomID` as specified in `java.util.TimeZone`. + +==== java.time.* + +The serialization output for a java.time.Instant instance MUST be in a `ISO_INSTANT` format, as specified in `java.time.format.DateTimeFormatter`. Implementations MUST support the deserialization of an `ISO_INSTANT` formatted JSON string to a `java.time.Instant` instance. + +For other `java.time.*` classes, the following mapping table maps Java types to their corresponding formats: + +[cols=",",options="header",] +.Date/time formats for java.time.* types +|=== +|Java Type |Format +|java.time.Instant |ISO_INSTANT +|java.time.LocalDate |ISO_LOCAL_DATE +|java.time.LocalTime |ISO_LOCAL_TIME +|java.time.LocalDateTime |ISO_LOCAL_DATE_TIME +|java.time.ZonedDateTime |ISO_ZONED_DATE_TIME +|java.time.OffsetDateTime |ISO_OFFSET_DATE_TIME +|java.time.OffsetTime |ISO_OFFSET_TIME +|=== + +Implementations MUST support the deserialization of any time zone ID format specified in `java.time.ZoneId` into a field or property of type `java.time.ZoneId`. The serialization format of `java.time.ZoneId` is the normalized zone ID as specified in `java.time.ZoneId`. + +Implementations MUST support the deserialization of any time zone ID format specified in `java.time.ZoneOffset` into a field or property of type `java.time.ZoneOffset`. The serialization format of `java.time.ZoneOffset` is the normalized zone ID as specified in `java.time.ZoneOffset`. + +Implementations MUST support the deserialization of any duration format specified in `java.time.Duration` into a field or property of type `java.time.Duration`. This is super-set of ISO 8601 duration format. The serialization format of `java.time.Duration` is the ISO 8601 seconds based representation, such as PT8H6M12.345S. + +Implementations MUST support the deserialization of any period format specified in `java.time.Period` into a field or property of type `java.time.Period`. This is a super-set of ISO 8601 period format. The serialization format of `java.time.Period` is ISO 8601 period representation. A zero-length period is represented as zero days 'P0D'. + +=== Untyped mapping + +For an unspecified output type of a deserialization operation, as well as where output type is specified as `Object.class`, implementations MUST deserialize a JSON document using Java runtime types specified in table below: + +[cols=",",options="header",] +.Untyped Mapping +|=== +|JSON Value |Java Type +|object |java.util.Map<String, Object> +|array |java.util.List<Object> +|string |java.lang.String +|number |java.math.BigDecimal +|true, false |java.lang.Boolean +|null |null +|=== + +JSON object values are deserialized into an implementation of `java.util.Map<String, Object>` with a predictable iteration order. + +=== Java Class + +Any instance passed to a deserialization operation must have a public or protected no-argument constructor. Implementations SHOULD throw an error if this condition is not met. This limitation does not apply to serialization operations, as well as to classes which specify explicit instantiation methods as described in section 4.5. + +==== Scope and Field access strategy + +For a deserialization operation of a Java property, if a matching public setter method exists, the method is called to set the value of the property. If a matching setter method with private, protected, or defaulted to package-only access exists, then this field is ignored. If no matching setter method exists and the field is public, then direct field assignment is used. + +For a serialization operation, if a matching public getter method exists, the method is called to obtain the value of the property. If a matching getter method with private, protected, or defaulted to package-only access exists, then this field is ignored. If no matching getter method exists and the field is public, then the value is obtained directly from the field. + +JSON Binding implementations MUST NOT deserialize into transient, final or static fields and MUST ignore name/value pairs corresponding to such fields. + +Implementations MUST support serialization of final fields. Transient and static fields MUST be ignored during serialization operation. + +If a JSON document contains a name/value pair not corresponding to field or setter method then this name/value pair is skipped (see 3.18). + +Public getter/setter methods without a corresponding field MUST be supported. When only public getter/setter methods without corresponding fields are present in the class, the getter method is called to obtain the value to serialize, and the setter method is called during deserialization operation. + +==== Nested Classes + +Implementations MUST support the binding of public and protected nested classes. For deserialization operations, both nested and encapsulating classes MUST fulfill the same instantiation requirements as specified in 3.7.1. + +==== Static Nested Classes + +Implementations MUST support the binding of public and protected static nested classes. For deserialization operations, the nested class MUST fulfill the same instantiation requirements as specified in 3.7.1. + +==== Anonymous Classes + +Deserialization into anonymous classes is not supported. Serialization of anonymous classes is supported by default object mapping. + +=== Polymorphic Types + +Polymorphic type handling is supported for deserialization and serialization. Polymorphic handling is ensured by annotation `JsonbTypeInfo` and `@JsonbSubtype`. `JsonbTypeInfo` defines key name of the property to store type information in it and defines all the supported aliases using `@JsonbSubtype` annotations. `@JsonbSubtype` ensures proper and safe mapping between class alias and type. Implementation must validate mapped types if they are assignable from the annotated type. If not, an exception must be thrown. + +Type information is obtained from `@JsonbSubtype` annotation as a type alias mapped to the type. If no matching class is found for obtained alias during deserialization, an exception must be thrown. + +New property with type information is added to the serialized object. The property key name is taken from the `key` property of the annotation `JsonbTypeInfo`. This type information property key name has to be unique in the resulting JSON document. If any naming collision with class or any other `JsonbTypeInfo` properties occurs, an exception must be thrown. It is required for all polymorphism fields to be serialized as the first properties in the JSON and any actual object properties are serialized after. + +If no `JsonbTypeInfo` is used on handled class or its predecessors, it is not possible to ensure proper polymorphic type handling and in such cases deserialization is not supported. + +If there are multiple different type polymorphic customizations that need to be merged, an exception must be thrown. Multiple inheritance of this customization is not supported. + +[source,java] +---- +@JsonbTypeInfo({...}) +interface Vehicle {} + +@JsonbTypeInfo({...}) +interface Machine {} + +class Car implements Vehicle, Machine {} +---- + +In case of the following example: +[source,java] +---- +@JsonbTypeInfo(key = "@vehicle", value = {@JsonbSubtype(alias = "car", type = Car.class)}) +class Vehicle {...} + +@JsonbTypeInfo(key = "@car", value = {@JsonbSubtype(alias = "myCar", type = MyCar.class)}) +class Car extends Vehicle {...} + +class MyCar extends Car {...} +---- +The order of the type information properties must be the same in which they appear in the polymorphic type chain. Resulting JSON when serializing MyCar class would look like this: +[source,json] +---- +{ + "@vehicle" : "car", + "@car" : "myCar", + ... Vehicle properties + ... Car properties + ... MyCar properties +} +---- + +=== Enum + +Serialization of an Enum instance to a JSON String value MUST follow the conversion process defined in javadoc specification for their `name()`. + +Deserialization of a JSON value into an enum instance MUST be done by calling the enum’s `valueOf(String)` method. + +=== Interfaces + +Implementations MUST support the deserialization of specific interfaces defined in 3.11 and 3.3.4. + +Deserialization to other interfaces is not supported and implementations SHOULD report error in such case. + +If a class property is defined with an interface and not concrete type, then the mapping for a serialized property is resolved based on its runtime type. + +=== Collections + +Implementations MUST support the binding of the following collection interfaces, classes and their implementations: + +* java.util.Collection +* java.util.Map +* java.util.Set +* java.util.HashSet +* java.util.NavigableSet +* java.util.SortedSet +* java.util.TreeSet +* java.util.LinkedHashSet +* java.util.HashMap +* java.util.NavigableMap +* java.util.SortedMap +* java.util.TreeMap +* java.util.LinkedHashMap +* java.util.List +* java.util.ArrayList +* java.util.LinkedList +* java.util.Deque +* java.util.ArrayDeque +* java.util.Queue +* java.util.PriorityQueue + +Implementations of these interfaces must provide an accessible default constructor. + +JSON Binding implementations MUST report a deserialization error if a default constructor is not present or is not in accessible scope. + +=== Arrays + +JSON Binding implementations MUST support the binding of Java arrays of all supported Java types from this chapter into/from JSON array structures as defined in Section 5 of RFC 7159. + +Arrays of primitive types and multi-dimensional arrays MUST be supported. + +=== Attribute order + +Class properties MUST be serialized in lexicographical order into the resulting JSON document. In case of inheritance, properties declared in super class MUST be serialized before properties declared in a child class. + +When deserializing a JSON document, field values MUST be set in the order of attributes present in the JSON document. + +=== Null value handling + +==== Null Java field + +The result of serializing a java field with a null value is the absence of the property in the resulting JSON document. + +The deserialization operation of a property absent in JSON document MUST not set the value of the field, the setter (if available) MUST not be called, and thus original value of the field MUST be preserved. + +The deserialization operation of a property with a null value in a JSON document MUST set the value of the field to null value (or call setter with null value if setter is present). The exception is `java.util.Optional`, `OptionalInt`, `OptionalLong`, `OptionalDouble` instances. In this case the value of the field is set to an empty optional value. + +==== Null Array Values + +The result of deserialization n-ary array represented in JSON document is n-ary Java array. + +Null value in JSON array is represented by null value in Java array. + +Serialization operation on Java array with null value at index `i` MUST output null value at index `i` of the array in resulting JSON document. + +=== Names and identifiers + +According to RFC 7159 Section 7, every Java identifier name can be transformed using identity function into a valid JSON String. Identity function MUST be used for transforming Java identifier names into Strings in JSON document. + +For deserialization operations defined in 3.6 section, identity function is used to transform JSON name strings into Java `String` instances in the resulting map `Map<String, Object>`. + +Naming strategy can be further customized in customization. + +=== Big numbers + +JSON Binding implementation MUST serialize/deserialize numbers that express greater magnitude or precision than an IEEE 754 double precision number as strings. + +=== Generics + +JSON Binding implementations MUST support binding of generic types. + +Due to type erasure, there are situations when it is not possible to obtain generic type information. There are two ways for JSON Binding implementations to obtain generic type information. + +If there is a class file available (in the following text referred as static type information), it is possible to obtain generic type information (effectively generic type declaration) from Signature attribute (if this information is present). + +The second option is to provide generic type information at runtime. To provide generic type information at runtime, an argument of `java.lang.reflect.Type` MUST be passed to `Jsonb::toJson` or to `Jsonb::fromJson` method. + +==== Type resolution algorithm + +There are several levels of information JSON Binding implementations may obtain about the type of field/class/interface: + +[arabic] +. runtime type provided via `java.lang.reflect.Type` parameter passed to +`Jsonb::toJson` or `Jsonb::fromJson` method +. static type provided in class file (effectively stored in Signature +attribute) +. raw type +. no information about the type + +If there is no information about the type, JSON Binding implementation MUST treat this type as `java.lang.Object`. + +If only raw type of given field/class/interface is known, then the type MUST be treated like raw type. For example, if the only available information is that given field/class/interface is of type `java.util.ArrayList`, then the type MUST be treated as `java.util.ArrayList<Object>`. + +JSON Binding implementations MUST use the most specific type derived from the information available. + +Let’s consider situation when there is only a static type information of a given field/class/interface known, and there is no runtime type information available. + +Let `GenericClass<T~1~…T~n~>` be part of generic type declaration, where `GenericClass` is name of the generic type and `T~1~…T~n~` are type parameters. For every , where `i` in `1…n`, there are 3 possible options: + +[arabic] +. is concrete parameter type +. is bounded parameter type +. is wildcard parameter type without bounds + +In case 1, the most specific parameter type MUST be given concrete parameter type. + +For bounded parameter type, let’s use bounds `B~1~,…,B~m~`. + +If `m = 1`, then the most specific parameter type MUST be derived from the given bound. + +If is class or interface, the most specific parameter type MUST be the class or interface. + +Otherwise, the most specific parameter type SHOULD be `java.lang.Object`. + +If multiple bounds are specified, the first step is to resolve every bound separately. Let’s define result of such resolution as `S~1~,…,S~m~` specific parameter types. + +If `S~1~,…,S~m~` are `java.lang.Object`, then the bounded parameter type MUST be `java.lang.Object`. + +If there is exactly one , where `1<=k<=m` is different than `java.lang.Object`, then the most specific parameter type for this bounded parameter type MUST be . + +If there exists `S~k1~,S~k2~`, where `1<=k1<=k2<=m`, then the most specific parameter type is . + +For wildcard parameter type without bounds, the most specific parameter type MUST be `java.lang.Object`. + +Any unresolved type parameter MUST be treated as `java.lang.Object`. + +If runtime type is provided via `java.lang.reflect.Type` parameter passed to `Jsonb::toJson` or `Jsonb::fromJson` method, then that runtime type overrides static type declaration wherever applicable. + +There are situations when it is necessary to use combination of runtime and static type information. + +[source,java] +.Example Type resolution +---- +public class MyGenericType<T,U> { + public T field1; + public U field2; +} +---- + +To resolve type of `field1`, runtime type of `MyGenericType` and static type of `field1` is required. + +=== Must-Ignore policy + +When JSON Binding implementation during deserialization encounters key in key/value pair that it does not recognize, it should treat the rest of the JSON document as if the element simply did not appear, and in particular, the implementation MUST NOT treat this as an error condition. + +=== Uniqueness of properties + +JSON Binding implementations MUST NOT produce JSON documents with members with duplicate names. In this context, "duplicate" means that the names, after processing any escaped characters, are identical sequences of Unicode characters. + +When non-unique property (after override and rename) is found, implementation MUST throw an exception. This doesn’t apply for customized user serialization behavior implemented with the usage of `JsonbAdapter` and `JsonbSerializer/JsonbDeserializer` mechanisms. + +=== JSON Processing integration + +JSON Binding implementations MUST support binding of the following JSON Processing types: + +* jakarta.json.JsonObject +* jakarta.json.JsonArray +* jakarta.json.JsonStructure +* jakarta.json.JsonValue +* jakarta.json.JsonString +* jakarta.json.JsonNumber + +Serialization of supported `jakarta.json.*` objects/interfaces/fields MUST have the same result as serialization these objects with `jakarta.json.JsonWriter`. + +Deserialization into supported `jakarta.json.*` objects/interfaces/fields MUST have the same result as deserialization into such objects with `jakarta.json.JsonReader`. + +If the null value is deserialized into the JsonValue, it is handled as `JsonValue.NULL`. `JsonValue.NULL` is not assigned as a default value if no value is set. + +== Customizing Mapping + +This section defines several ways how to customize the default behavior. The default behavior can be customized annotating a given field, JavaBean property, type or package, or by providing an implementation of particular strategy, e.g. `PropertyOrderStrategy`. JSON Binding provider MUST support these customization options. + +=== Customizing Property Names + +There are two standard ways how to customize serialization of field (or JavaBean property) to JSON document. The same applies to deserialization. The first way is to annotate field (or JavaBean property) with `jakarta.json.bind.annotation.JsonbProperty` annotation. The second option is to set `jakarta.json.bind.config.PropertyNamingStrategy`. + +==== jakarta.json.bind.annotation.JsonbTransient + +JSON Binding implementations MUST NOT process fields, JavaBean properties or types annotated with `jakarta.json.bind.annotation.JsonbTransient`. + +`JsonbTransient` annotation is mutually exclusive with all other JSON Binding defined annotations. Implementations must throw `JsonbException` in the following cases: + +* Class field is annotated with `@JsonbTransient` +** Exception must be thrown when this field, getter or setter is annotated with other JSON Binding annotations. +* Getter is annotated with `@JsonbTransient` +** Exception is thrown if when the field or this getter are annotated with other JSON Binding annotations. Exception is not thrown if JSON Binding annotations are presented on the setter. +* Setter is annotated with `@JsonbTransient` +** Exception is thrown if when the field or this setter are annotated with other JSON Binding annotations. Exception is not thrown if JSON Binding annotations are presented on the getter. + +==== jakarta.json.bind.annotation.JsonbProperty + +According to default mapping 3.15, property names are serialized unchanged to JSON document (identity transformation). To provide custom name for given field (or JavaBean property), `jakarta.json.bind.annotation.JsonbProperty` may be used. `JsonbProperty` annotation may be specified on field, getter or setter method. + +If specified on field, custom name is used both for serialization and deserialization. + +If `jakarta.json.bind.annotation.JsonbProperty` is specified on getter method, it is used only for serialization. If `jakarta.json.bind.annotation.JsonbProperty` is specified on setter method, it is used only for deserialization. + +It is possible to specify different values for getter and setter method for `jakarta.json.bind.annotation.JsonbProperty` annotation. In such case the different custom name will be used for serialization and deserialization. + +==== jakarta.json.bind.config.PropertyNamingStrategy + +To customize name translation of properties, JSON Binding provides `jakarta.json.bind.config.PropertyNamingStrategy` interface. + +Interface `jakarta.json.bind.config.PropertyNamingStrategy` provides the most common property naming strategies. + +* IDENTITY +* LOWER_CASE_WITH_DASHES +* LOWER_CASE_WITH_UNDERSCORES +* UPPER_CAMEL_CASE +* UPPER_CAMEL_CASE_WITH_SPACES +* CASE_INSENSITIVE + +The detailed description of property naming strategies can be found in javadoc. + +The way to set custom property naming strategy is to use `jakarta.json.bind.JsonbConfig::withPropertyNamingStrategy` method. + +==== Property names resolution + +Property name resolution consists of two phases: + +[arabic] +. Standard override mechanism +. Applying property name resolution, which involves the value of +`@JsonbProperty` + +If duplicate name is found exception MUST be thrown. The definition of duplicate (non-unique) property can be found in 3.19. + +=== Customizing Property Order + +To customize the order of serialized properties, JSON Binding provides `jakarta.json.bind.config.PropertyOrderStrategy` class. + +Class `jakarta.json.bind.config.PropertyOrderStrategy` provides the most common property order strategies. + +* LEXICOGRAPHICAL +* ANY +* REVERSE + +The detailed description of property order strategies can be found in javadoc. + +The way to set custom property order strategy is to use `jakarta.json.bind.JsonbConfig::withPropertyOrderStrategy` method. + +To customize the order of serialized properties only for one specific type, JSON Binding provides `jakarta.json.bind.annotation.JsonbPropertyOrder` annotation. Order specified by `JsonbPropertyOrder` annotation overrides order specified by `PropertyOrderStrategy`. + +The order is applied to already renamed properties as stated in 4.1. + +=== Customizing Null Handling + +There are two main ways how to change default null handling. The first option is to annotate type, package, field or JavaBean property with `jakarta.json.bind.annotation.JsonbNillable` annotation. The second option is to set config-wide configuration via `JsonbConfig::withNullValues` method. There is also a third option to annotate a field or JavaBean property with `jakarta.json.bind.annotation.JsonbProperty` and to set nillable parameter to true. However, this option is currently deprecated, and it is recommended to use `jakarta.json.bind.annotation.JsonbNillable` instead. + +If annotations (`JsonbNillable` or `JsonbProperty`) on different level apply to the same field (or JavaBean property) or if there is config wide configuration and some annotation (`JsonbNillable` or `JsonbProperty`) which apply to the same field (or JavaBean property), the annotation with the smallest scope applies. For example, if there is type level `JsonbNillable` annotation applied to some class with field which is annotated with `JsonbProperty` annotation with nillable = false, then `JsonbProperty` annotation overrides `JsonbNillable` annotation. + +If `JsonbNillable` and `JsonbProperty` are applied on the same level, `JsonbNillable` takes precedence. + +==== jakarta.json.bind.annotation.JsonbNillable + +To customize the result of serializing field (or JavaBean property) with null value, JSON Binding provides `jakarta.json.bind.annotation.JsonbNillable` annotation. + +When given object (type, package, field or JavaBean property) is annotated with `jakarta.json.bind.annotation.JsonbNillable` annotation, the result of null value will be presence of associated property in JSON document with explicit null value. + +The same behavior as `JsonbNillable`, but only at field, parameter and method (JavaBean property) level is provided by `jakarta.json.bind.annotation.JsonbProperty` annotation with its `nillable` parameter. This option is currently deprecated, and it is recommended to use `jakarta.json.bind.annotation.JsonbNillable` instead. + +JSON Binding implementations MUST implement override of annotations according to target of the annotation (FIELD, PARAMETER, METHOD, TYPE, PACKAGE). Type level annotation overrides behavior set at the package level. Method, parameter or field level annotation overrides behavior set at the type level. + +==== Global null handling configuration + +Null handling behavior can be customized via `jakarta.json.bind.JsonbConfig::withNullValues` method. + +The way to enforce serialization of null values, is to call method `jakarta.json.bind.JsonbConfig::withNullValues` with parameter true. + +The way to skip serialization of null values is to call method `jakarta.json.bind.JsonbConfig::withNullValues` with parameter `false`. + +=== I-JSON support + +I-JSON (short for "Internet JSON") is a restricted profile of JSON designed to maximize interoperability and increase confidence that software can process it successfully with predictable results. The profile is defined in https://tools.ietf.org/html/rfc7493[The I-JSON Message Format]. + +JSON Binding provides full support for I-JSON standard. Without any configuration, JSON Binding produces JSON documents which are compliant with I-JSON with three exceptions. + +* JSON Binding does not restrict the serialization of top-level JSON texts that are neither objects nor arrays. The restriction should happen at application level. +* JSON Binding does not serialize binary data with base64url encoding. +* JSON Binding does not enforce additional restrictions on dates/times/duration. + +These exceptions refer only to recommended areas of I-JSON. + +To enforce strict compliance of serialized JSON documents, JSON Binding implementations MUST implement configuration option "jsonb.strict-ijson". + +The way to enable strict compliance of serialized JSON documents, is to call method `JsonbConfig::withStrictIJSON` with parameter `true`. + +Strict I-JSON compliance changes only default mapping behavior (see Section 3). + +==== Strict date serialization + +Uppercase rather than lowercase letters MUST be used. + +The time zone MUST always be included and optional trailing seconds MUST be included even when their value is "00". + +JSON Binding implementations MUST serialize `java.util.Date, java.util.Calendar, java.util.GregorianCalendar, java.time.LocalDate, java.time.LocalDateTime` and `java.time.Instant` in the same format as `java.time.ZonedDateTime`. + +The result of serialization of duration must conform to the "duration" production in Appendix A of RFC 3339, with the same additional restrictions. + +=== Custom instantiation + +In many scenarios instantiation with the use of default constructor is not enough. To support these scenarios, JSON Binding provides `jakarta.json.bind.annotation.JsonbCreator` annotation. + +At most one `JsonbCreator` annotation can be used to annotate custom constructor or static factory method in a class, otherwise `JsonbException` MUST be thrown. + +Factory method annotated with `JsonbCreator` annotation should return instance of a particular class this annotation is used for, otherwise `JsonbException` MUST be thrown. + +Mapping between parameters of constructor/factory method annotated with `JsonbCreator` and JSON fields is defined using `JsonbProperty` annotation on all parameters. + +If the `JsonbProperty` annotation on parameters is not used, then parameters should be mapped from JSON fields with the same name. In this case the proper mapping is NOT guaranteed. + +All the `JsonbCreator` parameters are treated as optional by default. See <<optional-parameter-values, Optional parameter values>> chapter for default optional parameter values. + +All the `JsonbCreator` parameters can be turned to required by using configuration method `Config::withCreatorParametersRequired`. + +If a required field for a parameter mapping does not exist in the JSON document, then `JsonbException` MUST be thrown. + +[[optional-parameter-values]] +==== Optional parameter values +When a property is marked as optional, the proper default should be used. If the parameter is any type other than `Optional` or its variations, then the `null` value is used. If the parameter is `java.util.Optional`, `OptionalInt`, `OptionalLong`, `OptionalDouble`, then the corresponding empty object must be used. + +Primitive types cannot accept `null` values, so a corresponding value is required as listed in the following table: + +[cols=",",options="header",] +.Provided primitive values instead of null +|=== +|Primitive type |Provided value +|byte |0 +|short |0 +|int |0 +|long |0L +|float |0.0F +|double |0.0 +|boolean |false +|char |'\u0000' +|=== + +=== Custom visibility + +To customize scope and field access strategy as specified in section 3.7.1, it is possible to specify `jakarta.json.bind.annotation.JsonbVisibility` annotation or to override default behavior globally calling `JsonbConfig::withPropertyVisibilityStrategy` method with given custom property visibility strategy. + +=== Custom mapping + +Some Java types do not map naturally to a JSON representation and annotations cannot be used to customize mapping. An example can be some third party classes or classes without no-arg constructor. To customize mapping in this case JSON Binding has two mechanisms: Adapters and Serializers. + +==== Adapters + +Adapter is a class implementing `jakarta.json.bind.adapter.JsonbAdapter` interface. It has a custom code to convert the “unmappable” type (Original) into another one that JSONB can handle (Adapted). + +On serialization of Original type JSONB calls `JsonbAdapter::adaptToJson` method of the adapter to convert Original to Adapted and serializes Adapted the standard way. + +On deserialization JSONB deserializes Adapted from JSON and converts it to Original using `JsonbAdapter::adaptFromJson` method. + +There are two ways how to register `JsonbAdapter`: + +[arabic] +. Using `JsonbConfig::withAdapters` method; +. Annotating a class field with `JsonbTypeAdapter` annotation. + +`JsonbAdapter` registered via `JsonbConfig::withAdapters` is visible to all serialize/deserialize operations performed with given `JsonbConfig`. `JsonbAdapter` registered with annotation is visible to serialize/deserialize operation used only for annotated field. + +It is possible to annotate `JsonbCreator` parameter with `JsonbTypeAdapter` and provide adapter for a parameter this way. However, if `JsonbTypeAdapter` annotation is provided to any other parameter (such as setter method parameter) it will be ignored. + +Implementations must provide a CDI support in adapters to allow injection of CDI managed beans into it. + +==== Serializers/Deserializers + +Sometimes adapters mechanism is not enough and low level access to JSONP parser/generator is needed. + +Serializer is a class implementing `jakarta.json.bind.serializers.JsonbSerializer` interface. It is used to serialize the type it’s registered on (Original). On serializing of Original type JSONB calls `JsonbSerializer::serialize` method. This method has to contain a custom code to serialize Original type using provided `JsonpGenerator`. + +Deserializer is a class implementing `jakarta.json.bind.serializers.JsonbDeserializer` interface. It is used to deserialize the type it’s registered on (Original). On deserialization of Original type JSONB calls `JsonbDeserializer::deserialize` method. This method has to contain a custom code to deserialize Original type using provided `JsonpParser`. + +There are two ways how to register `JsonbSerializer/JsonbDeserializer`: + +[arabic] +. Using `JsonbConfig::withSerializers/ JsonbConfig::withDeserializers` method; +. Annotating a type with `JsonbSerializer/JsonbDeserializer` annotation. + +It is possible to annotate `JsonbCreator` parameter with `JsonbTypeDeserializer` and provide deserializer for a parameter this way. However, if `JsonbTypeDeserializer` annotation is provided to any other parameter (such as setter method parameter) it will be ignored. + +Implementations must provide a CDI support in serializers/deserializers to allow injection of CDI managed beans into it. + +=== Custom date format + +To specify custom date format, it is necessary to annotate given annotation. `JsonbDateFormat` annotation can be applied to the following targets: + +* field +* getter/setter +* type +* parameter +* package + +Default date format and default locale can be customized globally using `jakarta.json.bind.JsonbConfig::withDateFormat` and `jakarta.json.bind.JsonbConfig::withLocale` methods. + +If `jakarta.json.bind.annotation.JsonbDateFormat` is specified on a getter method, it is used only for serialization. If `jakarta.json.bind.annotation.JsonbDateFormat` is specified on a setter method, it is used only for deserialization. + +Annotation applied to more specific target overrides the same annotation applied to target with wider scope and global configuration. For example, annotation applied to type target will override the same annotation applied to package target. + +=== Custom number format + +To specify custom number format, it is necessary to annotate given annotation target with `jakarta.json.bind.annotation.JsonbNumberFormat` annotation. `JsonbNumberFormat` annotation can be applied to the following targets: + +* field +* getter/setter +* type +* parameter +* package + +If `jakarta.json.bind.annotation.JsonbNumberFormat` is specified on a getter method, it is used only for serialization. If `jakarta.json.bind.annotation.JsonbNumberFormat` is specified on a setter method, it is used only for deserialization. + +Annotation applied to more specific target overrides the same annotation applied to target with wider scope. For example, annotation applied to type target will override the same annotation applied to package target. + +=== Custom binary data handling + +To customize encoding of binary data, JSON Binding provides `jakarta.json.bind.config.BinaryDataStrategy` class. + +Class `jakarta.json.bind.config.BinaryDataStrategy` provides the most common binary data encodings. + +* BYTE +* BASE_64 +* BASE_64_URL + +The detailed description of binary encoding strategies can be found in javadoc. + +The way to set custom binary data handling strategy is to use `jakarta.json.bind.JsonbConfig::withBinaryDataStrategy` method. + +== Appendix + +=== Change Log + +==== Changes Since 1.0 Early Draft + +* Section 3.7: Clarified that default constructor is not needed in case of `JsonbCreator`. +* Chapters 3 and 4: Synchronized vocabulary to serialization and deserialization. +* Section 3.9: Conversion method changed from `toString()` to `name()`. +* Section 3.4.3: Changed serialization rules of object properties with `Optional` type and `null` value. +* Section 3.14.1: Added an exception for `Optional` fields. +* Section 3.6: Removed ’smallest possible type’ rule for number types. JSON number type is always mapped to `BigDecimal` in case target type is not specified. +* Removed ’Simple Value’ customization (`@JsonbValue`). Adapters shouldbe used instead. +* Adapters section (4.7.1) changed. +* Serializers/Deserializers section (4.7.2) added. + +==== Changes Since 1.0 Public Draft + +* Section 3.17.1: Sample fixed. +* Section 4.4: Method name is changed from `JsonbConfig::withStrictIJSONSerializationCompliance` to `JsonbConfig::withStrictIJSON`. Config property name is changed from `jsonb.i-json.strict-ser-compliance` to `jsonb.strict-ijson`. +* Sections 4.7.1 and 4.7.2: Added CDI support. +* Section 4.8: Added a paragraph explicitly explaining the use case when `JsonbDateFormat` annotation is placed on getter or setter. +* Section 4.9: Added a paragraph explicitly explaining the use case when `JsonbNumberFormat` annotation is placed on getter or setter. +* Section 4.5: `JsonbProperty` on parameters is required for proper mapping. If not present mapping is is done by matching names, but is not guaranteed. Clarified condition when exception is raised. +* Section 4.1.1: Clarified conditions when exceptions are throwed. +* Section 4.4: Clarified that strict I_JSON compliance affects only default mapping mechanism. +* Section 3.13: Declared fields changed to class properties.
diff --git a/spec/src/main/asciidoc/license-efsl.adoc b/spec/src/main/asciidoc/license-efsl.adoc new file mode 100644 index 0000000..5194167 --- /dev/null +++ b/spec/src/main/asciidoc/license-efsl.adoc
@@ -0,0 +1,79 @@ +[subs="normal"] +.... +Specification: {doctitle} + +Version: {revnumber} + +ifeval::["{revremark}" != ""] +Status: {revremark} +endif::[] +ifeval::["{revremark}" == ""] +Status: Final Release +endif::[] + +Release: {revdate} +.... + +Copyright (c) 2019, 2020 Eclipse Foundation. + +=== Eclipse Foundation Specification License + +By using and/or copying this document, or the Eclipse Foundation +document from which this statement is linked, you (the licensee) agree +that you have read, understood, and will comply with the following +terms and conditions: + +Permission to copy, and distribute the contents of this document, or +the Eclipse Foundation document from which this statement is linked, in +any medium for any purpose and without fee or royalty is hereby +granted, provided that you include the following on ALL copies of the +document, or portions thereof, that you use: + +* link or URL to the original Eclipse Foundation document. +* All existing copyright notices, or if one does not exist, a notice + (hypertext is preferred, but a textual representation is permitted) + of the form: "Copyright (c) [$date-of-document] + Eclipse Foundation, Inc. https://www.eclipse.org/legal/efsl.php[]" + +Inclusion of the full text of this NOTICE must be provided. We +request that authorship attribution be provided in any software, +documents, or other items or products that you create pursuant to the +implementation of the contents of this document, or any portion +thereof. + +No right to create modifications or derivatives of Eclipse Foundation +documents is granted pursuant to this license, except anyone may +prepare and distribute derivative works and portions of this document +in software that implements the specification, in supporting materials +accompanying such software, and in documentation of such software, +PROVIDED that all such works include the notice below. HOWEVER, the +publication of derivative works of this document for use as a technical +specification is expressly prohibited. + +The notice is: + +"Copyright (c) 2018, 2020 Eclipse Foundation. This software or +document includes material copied from or derived from Jakarta JSON Binding +https://jakarta.ee/specifications/jsonb/2.0/[]" + +==== Disclaimers + +THIS DOCUMENT IS PROVIDED "AS IS," AND THE COPYRIGHT +HOLDERS AND THE ECLIPSE FOUNDATION MAKE NO REPRESENTATIONS OR +WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, +NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE +SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS +WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR +OTHER RIGHTS. + +THE COPYRIGHT HOLDERS AND THE ECLIPSE FOUNDATION WILL NOT BE LIABLE +FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT +OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE +CONTENTS THEREOF. + +The name and trademarks of the copyright holders or the Eclipse +Foundation may NOT be used in advertising or publicity pertaining to +this document or its contents without specific, written prior +permission. Title to copyright in this document will at all times +remain with copyright holders.
diff --git a/spec/src/theme/jakartaee-theme.yml b/spec/src/theme/jakartaee-theme.yml new file mode 100644 index 0000000..6092a2f --- /dev/null +++ b/spec/src/theme/jakartaee-theme.yml
@@ -0,0 +1,299 @@ +# +# Following is the asciidoctor-pdf default theme [1], with small +# customizations, mostly for header and footer, marked "EE". +# +# [1] https://github.com/asciidoctor/asciidoctor-pdf/blob/master/data/themes/default-theme.yml +# +font: + catalog: + # Noto Serif supports Latin, Latin-1 Supplement, Latin Extended-A, Greek, Cyrillic, Vietnamese & an assortment of symbols + Noto Serif: + normal: notoserif-regular-subset.ttf + bold: notoserif-bold-subset.ttf + italic: notoserif-italic-subset.ttf + bold_italic: notoserif-bold_italic-subset.ttf + # M+ 1mn supports ASCII and the circled numbers used for conums + M+ 1mn: + normal: mplus1mn-regular-ascii-conums.ttf + bold: mplus1mn-bold-ascii.ttf + italic: mplus1mn-italic-ascii.ttf + bold_italic: mplus1mn-bold_italic-ascii.ttf + # M+ 1p supports Latin, Latin-1 Supplement, Latin Extended, Greek, Cyrillic, Vietnamese, Japanese & an assortment of symbols + # It also provides arrows for ->, <-, => and <= replacements in case these glyphs are missing from font + M+ 1p Fallback: + normal: mplus1p-regular-fallback.ttf + bold: mplus1p-regular-fallback.ttf + italic: mplus1p-regular-fallback.ttf + bold_italic: mplus1p-regular-fallback.ttf + fallbacks: + - M+ 1p Fallback +page: + background_color: ffffff + layout: portrait + margin: [0.5in, 0.67in, 0.67in, 0.67in] + # margin_inner and margin_outer keys are used for recto/verso print margins when media=prepress + margin_inner: 0.75in + margin_outer: 0.59in + #size: A4 # EE + size: Letter # EE +base: + align: justify + # color as hex string (leading # is optional) + font_color: 333333 + # color as RGB array + #font_color: [51, 51, 51] + # color as CMYK array (approximated) + #font_color: [0, 0, 0, 0.92] + #font_color: [0, 0, 0, 92%] + font_family: Noto Serif + # choose one of these font_size/line_height_length combinations + #font_size: 14 + #line_height_length: 20 + #font_size: 11.25 + #line_height_length: 18 + #font_size: 11.2 + #line_height_length: 16 + font_size: 10.5 + #line_height_length: 15 + # correct line height for Noto Serif metrics + line_height_length: 12 + #font_size: 11.25 + #line_height_length: 18 + line_height: $base_line_height_length / $base_font_size + font_size_large: round($base_font_size * 1.25) + font_size_small: round($base_font_size * 0.85) + font_size_min: $base_font_size * 0.75 + font_style: normal + border_color: eeeeee + border_radius: 4 + border_width: 0.5 +# FIXME vertical_rhythm is weird; we should think in terms of ems +#vertical_rhythm: $base_line_height_length * 2 / 3 +# correct line height for Noto Serif metrics (comes with built-in line height) +vertical_rhythm: $base_line_height_length +horizontal_rhythm: $base_line_height_length +# QUESTION should vertical_spacing be block_spacing instead? +vertical_spacing: $vertical_rhythm +link: + font_color: 428bca +# literal is currently used for inline monospaced in prose and table cells +literal: + font_color: b12146 + font_family: M+ 1mn +menu_caret_content: " <font size=\"1.15em\"><color rgb=\"b12146\">\u203a</color></font> " +heading: + align: left + #font_color: 181818 + font_color: $base_font_color + font_family: $base_font_family + font_style: bold + # h1 is used for part titles (book doctype) or the doctitle (article doctype) + #h1_font_size: floor($base_font_size * 2.6) # EE + h1_font_size: floor($base_font_size * 2.5) # EE, squeeze title onto one line + # h2 is used for chapter titles (book doctype only) + h2_font_size: floor($base_font_size * 2.15) + h3_font_size: round($base_font_size * 1.7) + h4_font_size: $base_font_size_large + h5_font_size: $base_font_size + h6_font_size: $base_font_size_small + #line_height: 1.4 + # correct line height for Noto Serif metrics (comes with built-in line height) + line_height: 1 + margin_top: $vertical_rhythm * 0.4 + margin_bottom: $vertical_rhythm * 0.9 +title_page: + align: right + logo: + top: 10% + title: + top: 55% + font_size: $heading_h1_font_size + font_color: 999999 + line_height: 0.9 + subtitle: + font_size: $heading_h3_font_size + font_style: bold_italic + line_height: 1 + authors: + margin_top: $base_font_size * 1.25 + font_size: $base_font_size_large + font_color: 181818 + revision: + margin_top: $base_font_size * 1.25 +block: + margin_top: 0 + margin_bottom: $vertical_rhythm +caption: + align: left + font_size: $base_font_size * 0.95 + font_style: italic + # FIXME perhaps set line_height instead of / in addition to margins? + margin_inside: $vertical_rhythm / 3 + #margin_inside: $vertical_rhythm / 4 + margin_outside: 0 +lead: + font_size: $base_font_size_large + line_height: 1.4 +abstract: + font_color: 5c6266 + font_size: $lead_font_size + line_height: $lead_line_height + font_style: italic + first_line_font_style: bold + title: + align: center + font_color: $heading_font_color + font_family: $heading_font_family + font_size: $heading_h4_font_size + font_style: $heading_font_style +admonition: + column_rule_color: $base_border_color + column_rule_width: $base_border_width + padding: [0, $horizontal_rhythm, 0, $horizontal_rhythm] + #icon: + # tip: + # name: fa-lightbulb-o + # stroke_color: 111111 + # size: 24 + label: + text_transform: uppercase + font_style: bold +blockquote: + font_color: $base_font_color + font_size: $base_font_size_large + border_color: $base_border_color + border_width: 5 + # FIXME disable negative padding bottom once margin collapsing is implemented + padding: [0, $horizontal_rhythm, $block_margin_bottom * -0.75, $horizontal_rhythm + $blockquote_border_width / 2] + cite_font_size: $base_font_size_small + cite_font_color: 999999 +# code is used for source blocks (perhaps change to source or listing?) +code: + font_color: $base_font_color + font_family: $literal_font_family + font_size: ceil($base_font_size) + padding: $code_font_size + line_height: 1.25 + # line_gap is an experimental property to control how a background color is applied to an inline block element + line_gap: 3.8 + background_color: f5f5f5 + border_color: cccccc + border_radius: $base_border_radius + border_width: 0.75 +conum: + font_family: M+ 1mn + font_color: $literal_font_color + font_size: $base_font_size + line_height: 4 / 3 +example: + border_color: $base_border_color + border_radius: $base_border_radius + border_width: 0.75 + background_color: ffffff + # FIXME reenable padding bottom once margin collapsing is implemented + padding: [$vertical_rhythm, $horizontal_rhythm, 0, $horizontal_rhythm] +image: + align: left +prose: + margin_top: $block_margin_top + margin_bottom: $block_margin_bottom +sidebar: + background_color: eeeeee + border_color: e1e1e1 + border_radius: $base_border_radius + border_width: $base_border_width + # FIXME reenable padding bottom once margin collapsing is implemented + padding: [$vertical_rhythm, $vertical_rhythm * 1.25, 0, $vertical_rhythm * 1.25] + title: + align: center + font_color: $heading_font_color + font_family: $heading_font_family + font_size: $heading_h4_font_size + font_style: $heading_font_style +thematic_break: + border_color: $base_border_color + border_style: solid + border_width: $base_border_width + margin_top: $vertical_rhythm * 0.5 + margin_bottom: $vertical_rhythm * 1.5 +description_list: + term_font_style: bold + term_spacing: $vertical_rhythm / 4 + description_indent: $horizontal_rhythm * 1.25 +outline_list: + indent: $horizontal_rhythm * 1.5 + #marker_font_color: 404040 + # NOTE outline_list_item_spacing applies to list items that do not have complex content + item_spacing: $vertical_rhythm / 2 +table: + background_color: $page_background_color + #head_background_color: <hex value> + #head_font_color: $base_font_color + head_font_style: bold + #body_background_color: <hex value> + body_stripe_background_color: f9f9f9 + foot_background_color: f0f0f0 + border_color: dddddd + border_width: $base_border_width + cell_padding: 3 +toc: + indent: $horizontal_rhythm + line_height: 1.4 + dot_leader: + #content: ". " + font_color: a9a9a9 + #levels: 2 3 +# NOTE in addition to footer, header is also supported +footer: + font_size: $base_font_size_small + # NOTE if background_color is set, background and border will span width of page + #border_color: dddddd # EE + #border_width: 0.25 # EE + height: $base_line_height_length * 2.5 + line_height: 1 + padding: [$base_line_height_length / 2, 1, 0, 1] + vertical_align: top + #image_vertical_align: <alignment> or <number> + # additional attributes for content: + # * {page-count} + # * {page-number} + # * {document-title} + # * {document-subtitle} + # * {chapter-title} + # * {section-title} + # * {section-or-chapter-title} + recto: + #columns: "<50% =0% >50%" + right: + #content: '{page-number}' # EE + #content: '{section-or-chapter-title} | {page-number}' + #content: '{document-title} | {page-number}' + content: '{document-title}{nbsp}{nbsp}{nbsp} *{page-number}*' # EE + #center: + # content: '{page-number}' + left: # EE + content: '{status}' # EE + verso: + #columns: $footer_recto_columns + left: + #content: $footer_recto_right_content # EE + #content: '{page-number} | {chapter-title}' + content: '*{page-number}* {nbsp}{nbsp}{nbsp}{document-title}' # EE + #center: + # content: '{page-number}' + right: # EE + content: '{status}' # EE +header: # EE + font_size: $base_font_size_small # EE + border_color: dddddd # EE + border_width: 0.25 # EE + height: $base_line_height_length * 2.5 # EE + line_height: 1 # EE + padding: [$base_line_height_length / 2, 1, 0, 1] # EE + vertical_align: top # EE + recto: # EE + right: # EE + content: '{section-or-chapter-title}' # EE + verso: # EE + left: # EE + content: '{section-or-chapter-title}' # EE
diff --git a/tck-dist/pom.xml b/tck-dist/pom.xml new file mode 100644 index 0000000..fcc8145 --- /dev/null +++ b/tck-dist/pom.xml
@@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.ee4j</groupId> + <artifactId>project</artifactId> + <version>1.0.7</version> + </parent> + + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck-dist</artifactId> + <packaging>pom</packaging> + <version>3.0.0-SNAPSHOT</version> + <name>JSONB TCK Distribution</name> + + <dependencies> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck-ug</artifactId> + <version>${project.version}</version> + <type>zip</type> + </dependency> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck</artifactId> + <version>${project.version}</version> + <type>pom</type> + </dependency> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck</artifactId> + <version>${project.version}</version> + <type>jar</type> + </dependency> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck</artifactId> + <version>${project.version}</version> + <classifier>sources</classifier> + <optional>true</optional> + </dependency> + </dependencies> + + <profiles> + <profile> + <id>EFTL</id> + <properties> + <license>EFTL</license> + <bundle-name>jakarta-jsonb-tck</bundle-name> + </properties> + </profile> + <profile> + <id>EPL</id> + <properties> + <license>EPL</license> + <bundle-name>jsonb-tck</bundle-name> + </properties> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + </profile> + </profiles> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>3.3.0</version> + <executions> + <execution> + <id>distribution</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/main/assembly/assembly.xml</descriptor> + </descriptors> + <escapeString>\</escapeString> + <appendAssemblyId>false</appendAssemblyId> + <finalName>${bundle-name}-${project.version}</finalName> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
diff --git a/tck-dist/src/main/assembly/assembly.xml b/tck-dist/src/main/assembly/assembly.xml new file mode 100644 index 0000000..7471767 --- /dev/null +++ b/tck-dist/src/main/assembly/assembly.xml
@@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> + <id>distribution</id> + <baseDirectory>jsonb-tck</baseDirectory> + <formats> + <format>zip</format> + </formats> + + <files> + <!-- license --> + <file> + <source>${project.basedir}/src/main/resources/LICENSE_${license}.md</source> + <destName>LICENSE.md</destName> + </file> + </files> + <fileSets> + <fileSet> + <directory>${project.build.scriptSourceDirectory}</directory> + <outputDirectory>artifacts</outputDirectory> + <fileMode>755</fileMode> + <includes> + <include>**/*.sh</include> + </includes> + </fileSet> + <fileSet> + <directory>${project.basedir}/src/main/bin</directory> + <outputDirectory>bin</outputDirectory> + <includes> + <include>**/*.xml</include> + </includes> + <filtered>true</filtered> + </fileSet> + </fileSets> + <dependencySets> + <dependencySet> + <includes> + <include>jakarta.json.bind:jakarta.json.bind-tck</include> + </includes> + <useTransitiveDependencies>true</useTransitiveDependencies> + <outputDirectory>artifacts</outputDirectory> + <useProjectArtifact>false</useProjectArtifact> + </dependencySet> + <dependencySet> + <includes> + <include>jakarta.json.bind:jakarta.json.bind-tck-ug</include> + </includes> + <unpack>true</unpack> + <outputDirectory>.</outputDirectory> + </dependencySet> + </dependencySets> + +</assembly>
diff --git a/tck-dist/src/main/bin/pom.xml b/tck-dist/src/main/bin/pom.xml new file mode 100644 index 0000000..1fdc252 --- /dev/null +++ b/tck-dist/src/main/bin/pom.xml
@@ -0,0 +1,142 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.ee4j</groupId> + <artifactId>project</artifactId> + <version>1.0.7</version> + <relativePath/> + </parent> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck-tests</artifactId> + <version>${project.version}</version> + <properties> + <!-- Vendor Implementation (VI) --> + <jsonb-api.groupId>jakarta.json.bind</jsonb-api.groupId> + <jsonb-api.artifactId>jakarta.json.bind-api</jsonb-api.artifactId> + <jsonb-api.version>3.0.0</jsonb-api.version> + <!-- Compatible Implementation (CI) --> + <jsonb-impl.groupId>org.eclipse</jsonb-impl.groupId> + <jsonb-impl.artifactId>yasson</jsonb-impl.artifactId> + <jsonb-impl.version>3.0.0-RC1</jsonb-impl.version> + <!-- TCK --> + <jsonb.tck.version>${project.version}</jsonb.tck.version> + <!-- properties --> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <jimage.dir>\${project.build.directory}/jdk-bundle</jimage.dir> + <!-- !!! DO NOT EDIT !!! --> + <jakarta.jsonb-api.version>3.0.0</jakarta.jsonb-api.version> + <jakarta.json-api.version>2.1.0</jakarta.json-api.version> + </properties> + <dependencies> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck</artifactId> + <version>\${jsonb.tck.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>\${jsonb-api.groupId}</groupId> + <artifactId>\${jsonb-api.artifactId}</artifactId> + <version>\${jsonb-api.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>\${jsonb-impl.groupId}</groupId> + <artifactId>\${jsonb-impl.artifactId}</artifactId> + <version>\${jsonb-impl.version}</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jboss.weld.se</groupId> + <artifactId>weld-se-core</artifactId> + <version>5.0.0.Beta1</version> + <scope>test</scope> + </dependency> + </dependencies> + <build> + <defaultGoal>verify</defaultGoal> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>3.2.0</version> + <executions> + <execution> + <id>copy</id> + <phase>generate-test-sources</phase> + <goals> + <goal>copy</goal> + </goals> + <configuration> + <artifactItems> + <artifactItem> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-api</artifactId> + <version>\${jakarta.jsonb-api.version}</version> + <type>jar</type> + <overWrite>true</overWrite> + <outputDirectory>\${project.build.directory}/signaturedirectory</outputDirectory> + <destFileName>jakarta.json.bind-api.jar</destFileName> + </artifactItem> + <artifactItem> + <groupId>jakarta.json</groupId> + <artifactId>jakarta.json-api</artifactId> + <version>\${jakarta.json-api.version}</version> + <type>jar</type> + <overWrite>true</overWrite> + <outputDirectory>\${project.build.directory}/signaturedirectory</outputDirectory> + <destFileName>jakarta.json-api.jar</destFileName> + </artifactItem> + </artifactItems> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>3.0.0-M5</version> + <configuration> + <useModulePath>false</useModulePath> + <trimStackTrace>false</trimStackTrace> + <failIfNoTests>true</failIfNoTests> + <dependenciesToScan>jakarta.json.bind:jakarta.json.bind-tck</dependenciesToScan> + <systemPropertyVariables> + <jimage.dir>\${jimage.dir}</jimage.dir> + <signature.sigTestClasspath>\${project.build.directory}/signaturedirectory/jakarta.json.bind-api.jar:\${jimage.dir}/java.base:\${jimage.dir}/java.rmi:\${jimage.dir}/java.sql:\${jimage.dir}/java.naming</signature.sigTestClasspath> + </systemPropertyVariables> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-report-plugin</artifactId> + <version>3.0.0-M4</version> + <executions> + <execution> + <id>post-unit-test</id> + <phase>test</phase> + <goals> + <goal>report</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> \ No newline at end of file
diff --git a/tck-dist/src/main/resources/LICENSE_EFTL.md b/tck-dist/src/main/resources/LICENSE_EFTL.md new file mode 100644 index 0000000..a210682 --- /dev/null +++ b/tck-dist/src/main/resources/LICENSE_EFTL.md
@@ -0,0 +1,83 @@ +# Eclipse Foundation Technology Compatibility Kit License - v 1.0 + +Copyright (c) 2018, Eclipse Foundation, Inc. and its licensors. + +Redistribution and use in binary form is permitted provided that the +following conditions are met: + +1. Use of the Technology Compatibility Kit accompanying this license + (the "TCK") and its documentation is permitted solely for the + purpose of testing compatibility of an implementation (the + "Product") of a specification (the "Specification") made available + by the Eclipse Foundation, Inc. ("Eclipse"). + +2. Only those modifications expressly permitted by the TCK and its + documentation are permitted. Except in these limited circumstances, + no modifications to the TCK are permitted under this license. + +3. A Product will be deemed to be "compatible" with the Specification + if it fully and completely meets and satisfies all requirements of + the TCK. + +4. Before any claim of compatibility (or any similar claim suggesting + compatibility) is made based on the TCK, the testing party must: + + a. use the TCK to demonstrate that the Product fully and + completely meets and satisfies all requirements of the TCK; + + b. make TCK test results showing full and complete satisfaction of + all requirements of the TCK publicly available on the testing + party's website and send a link to such test results to Eclipse + at [tck@eclipse.org](mailto:tck@eclipse.org); and + + c. comply with any requirements stated in the Specification with + regard to subsetting, supersetting, modifying or extending the + Specification in any Product claimed to be compatible with the + Specification. + +5. The test results must be continuously available and the link must + be live for at least as long as the Product is available in the + marketplace. + +6. The TCK may not be used as a basis for any statements of partial + compatibility. The TCK may only be used as a basis for true, + factual statements of full compatibility of Products that fully + meet and satisfy all requirements of the TCK. + +7. A determination that a Product is compatible with the TCK does not, + in itself, give rise to the right to use any name, mark, logo + associated with the TCK, Eclipse, or Eclipse's contributors or + licensors. + +8. Upon the request of Eclipse, a tester will retract any statements + of compatibility (or any similar claim suggesting compatibility) + which Eclipse reasonably determines to be false or misleading or in + violation of the terms of this license. + +9. Redistribution of the TCK must be under this Eclipse Foundation + Technology Compatibility Kit License and must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + +10. Neither the name, trademarks or logos of Eclipse, nor the names, + trademarks or logos of its contributors or licensors may be used to + endorse or promote products tested with this software without + specific prior written permission. + +11. The source code for the TCK accompanying this license is available + from Eclipse. + +TO THE EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED ON +AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER +EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR +CONDITIONS OF TITLE, NON- INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR +A PARTICULAR PURPOSE. TO THE EXTENT PERMITTED BY APPLICABLE LAW, +NEITHER THE COPYRIGHT OWNER OR ANY CONTRIBUTORS SHALL HAVE ANY +LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE +EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES.
diff --git a/tck-dist/src/main/resources/LICENSE_EPL.md b/tck-dist/src/main/resources/LICENSE_EPL.md new file mode 100644 index 0000000..1d428ed --- /dev/null +++ b/tck-dist/src/main/resources/LICENSE_EPL.md
@@ -0,0 +1,637 @@ +# Eclipse Public License - v 2.0 + + THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE + PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION + OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + + 1. DEFINITIONS + + "Contribution" means: + + a) in the case of the initial Contributor, the initial content + Distributed under this Agreement, and + + b) in the case of each subsequent Contributor: + i) changes to the Program, and + ii) additions to the Program; + where such changes and/or additions to the Program originate from + and are Distributed by that particular Contributor. A Contribution + "originates" from a Contributor if it was added to the Program by + such Contributor itself or anyone acting on such Contributor's behalf. + Contributions do not include changes or additions to the Program that + are not Modified Works. + + "Contributor" means any person or entity that Distributes the Program. + + "Licensed Patents" mean patent claims licensable by a Contributor which + are necessarily infringed by the use or sale of its Contribution alone + or when combined with the Program. + + "Program" means the Contributions Distributed in accordance with this + Agreement. + + "Recipient" means anyone who receives the Program under this Agreement + or any Secondary License (as applicable), including Contributors. + + "Derivative Works" shall mean any work, whether in Source Code or other + form, that is based on (or derived from) the Program and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. + + "Modified Works" shall mean any work in Source Code or other form that + results from an addition to, deletion from, or modification of the + contents of the Program, including, for purposes of clarity any new file + in Source Code form that contains any contents of the Program. Modified + Works shall not include works that contain only declarations, + interfaces, types, classes, structures, or files of the Program solely + in each case in order to link to, bind by name, or subclass the Program + or Modified Works thereof. + + "Distribute" means the acts of a) distributing or b) making available + in any manner that enables the transfer of a copy. + + "Source Code" means the form of a Program preferred for making + modifications, including but not limited to software source code, + documentation source, and configuration files. + + "Secondary License" means either the GNU General Public License, + Version 2.0, or any later versions of that license, including any + exceptions or additional permissions as identified by the initial + Contributor. + + 2. GRANT OF RIGHTS + + a) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free copyright + license to reproduce, prepare Derivative Works of, publicly display, + publicly perform, Distribute and sublicense the Contribution of such + Contributor, if any, and such Derivative Works. + + b) Subject to the terms of this Agreement, each Contributor hereby + grants Recipient a non-exclusive, worldwide, royalty-free patent + license under Licensed Patents to make, use, sell, offer to sell, + import and otherwise transfer the Contribution of such Contributor, + if any, in Source Code or other form. This patent license shall + apply to the combination of the Contribution and the Program if, at + the time the Contribution is added by the Contributor, such addition + of the Contribution causes such combination to be covered by the + Licensed Patents. The patent license shall not apply to any other + combinations which include the Contribution. No hardware per se is + licensed hereunder. + + c) Recipient understands that although each Contributor grants the + licenses to its Contributions set forth herein, no assurances are + provided by any Contributor that the Program does not infringe the + patent or other intellectual property rights of any other entity. + Each Contributor disclaims any liability to Recipient for claims + brought by any other entity based on infringement of intellectual + property rights or otherwise. As a condition to exercising the + rights and licenses granted hereunder, each Recipient hereby + assumes sole responsibility to secure any other intellectual + property rights needed, if any. For example, if a third party + patent license is required to allow Recipient to Distribute the + Program, it is Recipient's responsibility to acquire that license + before distributing the Program. + + d) Each Contributor represents that to its knowledge it has + sufficient copyright rights in its Contribution, if any, to grant + the copyright license set forth in this Agreement. + + e) Notwithstanding the terms of any Secondary License, no + Contributor makes additional grants to any Recipient (other than + those set forth in this Agreement) as a result of such Recipient's + receipt of the Program under the terms of a Secondary License + (if permitted under the terms of Section 3). + + 3. REQUIREMENTS + + 3.1 If a Contributor Distributes the Program in any form, then: + + a) the Program must also be made available as Source Code, in + accordance with section 3.2, and the Contributor must accompany + the Program with a statement that the Source Code for the Program + is available under this Agreement, and informs Recipients how to + obtain it in a reasonable manner on or through a medium customarily + used for software exchange; and + + b) the Contributor may Distribute the Program under a license + different than this Agreement, provided that such license: + i) effectively disclaims on behalf of all other Contributors all + warranties and conditions, express and implied, including + warranties or conditions of title and non-infringement, and + implied warranties or conditions of merchantability and fitness + for a particular purpose; + + ii) effectively excludes on behalf of all other Contributors all + liability for damages, including direct, indirect, special, + incidental and consequential damages, such as lost profits; + + iii) does not attempt to limit or alter the recipients' rights + in the Source Code under section 3.2; and + + iv) requires any subsequent distribution of the Program by any + party to be under a license that satisfies the requirements + of this section 3. + + 3.2 When the Program is Distributed as Source Code: + + a) it must be made available under this Agreement, or if the + Program (i) is combined with other material in a separate file or + files made available under a Secondary License, and (ii) the initial + Contributor attached to the Source Code the notice described in + Exhibit A of this Agreement, then the Program may be made available + under the terms of such Secondary Licenses, and + + b) a copy of this Agreement must be included with each copy of + the Program. + + 3.3 Contributors may not remove or alter any copyright, patent, + trademark, attribution notices, disclaimers of warranty, or limitations + of liability ("notices") contained within the Program from any copy of + the Program which they Distribute, provided that Contributors may add + their own appropriate notices. + + 4. COMMERCIAL DISTRIBUTION + + Commercial distributors of software may accept certain responsibilities + with respect to end users, business partners and the like. While this + license is intended to facilitate the commercial use of the Program, + the Contributor who includes the Program in a commercial product + offering should do so in a manner which does not create potential + liability for other Contributors. Therefore, if a Contributor includes + the Program in a commercial product offering, such Contributor + ("Commercial Contributor") hereby agrees to defend and indemnify every + other Contributor ("Indemnified Contributor") against any losses, + damages and costs (collectively "Losses") arising from claims, lawsuits + and other legal actions brought by a third party against the Indemnified + Contributor to the extent caused by the acts or omissions of such + Commercial Contributor in connection with its distribution of the Program + in a commercial product offering. The obligations in this section do not + apply to any claims or Losses relating to any actual or alleged + intellectual property infringement. In order to qualify, an Indemnified + Contributor must: a) promptly notify the Commercial Contributor in + writing of such claim, and b) allow the Commercial Contributor to control, + and cooperate with the Commercial Contributor in, the defense and any + related settlement negotiations. The Indemnified Contributor may + participate in any such claim at its own expense. + + For example, a Contributor might include the Program in a commercial + product offering, Product X. That Contributor is then a Commercial + Contributor. If that Commercial Contributor then makes performance + claims, or offers warranties related to Product X, those performance + claims and warranties are such Commercial Contributor's responsibility + alone. Under this section, the Commercial Contributor would have to + defend claims against the other Contributors related to those performance + claims and warranties, and if a court requires any other Contributor to + pay any damages as a result, the Commercial Contributor must pay + those damages. + + 5. NO WARRANTY + + EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT + PERMITTED BY APPLICABLE LAW, THE PROGRAM IS PROVIDED ON AN "AS IS" + BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR + IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF + TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR + PURPOSE. Each Recipient is solely responsible for determining the + appropriateness of using and distributing the Program and assumes all + risks associated with its exercise of rights under this Agreement, + including but not limited to the risks and costs of program errors, + compliance with applicable laws, damage to or loss of data, programs + or equipment, and unavailability or interruption of operations. + + 6. DISCLAIMER OF LIABILITY + + EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, AND TO THE EXTENT + PERMITTED BY APPLICABLE LAW, NEITHER RECIPIENT NOR ANY CONTRIBUTORS + SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST + PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE + EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGES. + + 7. GENERAL + + If any provision of this Agreement is invalid or unenforceable under + applicable law, it shall not affect the validity or enforceability of + the remainder of the terms of this Agreement, and without further + action by the parties hereto, such provision shall be reformed to the + minimum extent necessary to make such provision valid and enforceable. + + If Recipient institutes patent litigation against any entity + (including a cross-claim or counterclaim in a lawsuit) alleging that the + Program itself (excluding combinations of the Program with other software + or hardware) infringes such Recipient's patent(s), then such Recipient's + rights granted under Section 2(b) shall terminate as of the date such + litigation is filed. + + All Recipient's rights under this Agreement shall terminate if it + fails to comply with any of the material terms or conditions of this + Agreement and does not cure such failure in a reasonable period of + time after becoming aware of such noncompliance. If all Recipient's + rights under this Agreement terminate, Recipient agrees to cease use + and distribution of the Program as soon as reasonably practicable. + However, Recipient's obligations under this Agreement and any licenses + granted by Recipient relating to the Program shall continue and survive. + + Everyone is permitted to copy and distribute copies of this Agreement, + but in order to avoid inconsistency the Agreement is copyrighted and + may only be modified in the following manner. The Agreement Steward + reserves the right to publish new versions (including revisions) of + this Agreement from time to time. No one other than the Agreement + Steward has the right to modify this Agreement. The Eclipse Foundation + is the initial Agreement Steward. The Eclipse Foundation may assign the + responsibility to serve as the Agreement Steward to a suitable separate + entity. Each new version of the Agreement will be given a distinguishing + version number. The Program (including Contributions) may always be + Distributed subject to the version of the Agreement under which it was + received. In addition, after a new version of the Agreement is published, + Contributor may elect to Distribute the Program (including its + Contributions) under the new version. + + Except as expressly stated in Sections 2(a) and 2(b) above, Recipient + receives no rights or licenses to the intellectual property of any + Contributor under this Agreement, whether expressly, by implication, + estoppel or otherwise. All rights in the Program not expressly granted + under this Agreement are reserved. Nothing in this Agreement is intended + to be enforceable by any entity that is not a Contributor or Recipient. + No third-party beneficiary rights are created under this Agreement. + + Exhibit A - Form of Secondary Licenses Notice + + "This Source Code may also be made available under the following + Secondary Licenses when the conditions for such availability set forth + in the Eclipse Public License, v. 2.0 are satisfied: {name license(s), + version(s), and exceptions or additional permissions here}." + + Simply including a copy of this Agreement, including this Exhibit A + is not sufficient to license the Source Code under Secondary Licenses. + + If it is not possible or desirable to put the notice in a particular + file, then You may include the notice in a location (such as a LICENSE + file in a relevant directory) where a recipient would be likely to + look for such a notice. + + You may add additional accurate notices of copyright ownership. + +--- + +## The GNU General Public License (GPL) Version 2, June 1991 + + Copyright (C) 1989, 2022 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1335 + USA + + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your freedom to + share and change it. By contrast, the GNU General Public License is + intended to guarantee your freedom to share and change free software--to + make sure the software is free for all its users. This General Public + License applies to most of the Free Software Foundation's software and + to any other program whose authors commit to using it. (Some other Free + Software Foundation software is covered by the GNU Library General + Public License instead.) You can apply it to your programs, too. + + When we speak of free software, we are referring to freedom, not price. + Our General Public Licenses are designed to make sure that you have the + freedom to distribute copies of free software (and charge for this + service if you wish), that you receive source code or can get it if you + want it, that you can change the software or use pieces of it in new + free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid anyone + to deny you these rights or to ask you to surrender the rights. These + restrictions translate to certain responsibilities for you if you + distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether gratis + or for a fee, you must give the recipients all the rights that you have. + You must make sure that they, too, receive or can get the source code. + And you must show them these terms so they know their rights. + + We protect your rights with two steps: (1) copyright the software, and + (2) offer you this license which gives you legal permission to copy, + distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain + that everyone understands that there is no warranty for this free + software. If the software is modified by someone else and passed on, we + want its recipients to know that what they have is not the original, so + that any problems introduced by others will not reflect on the original + authors' reputations. + + Finally, any free program is threatened constantly by software patents. + We wish to avoid the danger that redistributors of a free program will + individually obtain patent licenses, in effect making the program + proprietary. To prevent this, we have made it clear that any patent must + be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and + modification follow. + + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains a + notice placed by the copyright holder saying it may be distributed under + the terms of this General Public License. The "Program", below, refers + to any such program or work, and a "work based on the Program" means + either the Program or any derivative work under copyright law: that is + to say, a work containing the Program or a portion of it, either + verbatim or with modifications and/or translated into another language. + (Hereinafter, translation is included without limitation in the term + "modification".) Each licensee is addressed as "you". + + Activities other than copying, distribution and modification are not + covered by this License; they are outside its scope. The act of running + the Program is not restricted, and the output from the Program is + covered only if its contents constitute a work based on the Program + (independent of having been made by running the Program). Whether that + is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's source + code as you receive it, in any medium, provided that you conspicuously + and appropriately publish on each copy an appropriate copyright notice + and disclaimer of warranty; keep intact all the notices that refer to + this License and to the absence of any warranty; and give any other + recipients of the Program a copy of this License along with the Program. + + You may charge a fee for the physical act of transferring a copy, and + you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion of + it, thus forming a work based on the Program, and copy and distribute + such modifications or work under the terms of Section 1 above, provided + that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any part + thereof, to be licensed as a whole at no charge to all third parties + under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a notice + that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under these + conditions, and telling the user how to view a copy of this License. + (Exception: if the Program itself is interactive but does not + normally print such an announcement, your work based on the Program + is not required to print an announcement.) + + These requirements apply to the modified work as a whole. If + identifiable sections of that work are not derived from the Program, and + can be reasonably considered independent and separate works in + themselves, then this License, and its terms, do not apply to those + sections when you distribute them as separate works. But when you + distribute the same sections as part of a whole which is a work based on + the Program, the distribution of the whole must be on the terms of this + License, whose permissions for other licensees extend to the entire + whole, and thus to each and every part regardless of who wrote it. + + Thus, it is not the intent of this section to claim rights or contest + your rights to work written entirely by you; rather, the intent is to + exercise the right to control the distribution of derivative or + collective works based on the Program. + + In addition, mere aggregation of another work not based on the Program + with the Program (or with a work based on the Program) on a volume of a + storage or distribution medium does not bring the other work under the + scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, + under Section 2) in object code or executable form under the terms of + Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections 1 + and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your cost + of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to + distribute corresponding source code. (This alternative is allowed + only for noncommercial distribution and only if you received the + program in object code or executable form with such an offer, in + accord with Subsection b above.) + + The source code for a work means the preferred form of the work for + making modifications to it. For an executable work, complete source code + means all the source code for all modules it contains, plus any + associated interface definition files, plus the scripts used to control + compilation and installation of the executable. However, as a special + exception, the source code distributed need not include anything that is + normally distributed (in either source or binary form) with the major + components (compiler, kernel, and so on) of the operating system on + which the executable runs, unless that component itself accompanies the + executable. + + If distribution of executable or object code is made by offering access + to copy from a designated place, then offering equivalent access to copy + the source code from the same place counts as distribution of the source + code, even though third parties are not compelled to copy the source + along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program + except as expressly provided under this License. Any attempt otherwise + to copy, modify, sublicense or distribute the Program is void, and will + automatically terminate your rights under this License. However, parties + who have received copies, or rights, from you under this License will + not have their licenses terminated so long as such parties remain in + full compliance. + + 5. You are not required to accept this License, since you have not + signed it. However, nothing else grants you permission to modify or + distribute the Program or its derivative works. These actions are + prohibited by law if you do not accept this License. Therefore, by + modifying or distributing the Program (or any work based on the + Program), you indicate your acceptance of this License to do so, and all + its terms and conditions for copying, distributing or modifying the + Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the + Program), the recipient automatically receives a license from the + original licensor to copy, distribute or modify the Program subject to + these terms and conditions. You may not impose any further restrictions + on the recipients' exercise of the rights granted herein. You are not + responsible for enforcing compliance by third parties to this License. + + 7. If, as a consequence of a court judgment or allegation of patent + infringement or for any other reason (not limited to patent issues), + conditions are imposed on you (whether by court order, agreement or + otherwise) that contradict the conditions of this License, they do not + excuse you from the conditions of this License. If you cannot distribute + so as to satisfy simultaneously your obligations under this License and + any other pertinent obligations, then as a consequence you may not + distribute the Program at all. For example, if a patent license would + not permit royalty-free redistribution of the Program by all those who + receive copies directly or indirectly through you, then the only way you + could satisfy both it and this License would be to refrain entirely from + distribution of the Program. + + If any portion of this section is held invalid or unenforceable under + any particular circumstance, the balance of the section is intended to + apply and the section as a whole is intended to apply in other + circumstances. + + It is not the purpose of this section to induce you to infringe any + patents or other property right claims or to contest validity of any + such claims; this section has the sole purpose of protecting the + integrity of the free software distribution system, which is implemented + by public license practices. Many people have made generous + contributions to the wide range of software distributed through that + system in reliance on consistent application of that system; it is up to + the author/donor to decide if he or she is willing to distribute + software through any other system and a licensee cannot impose that choice. + + This section is intended to make thoroughly clear what is believed to be + a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in + certain countries either by patents or by copyrighted interfaces, the + original copyright holder who places the Program under this License may + add an explicit geographical distribution limitation excluding those + countries, so that distribution is permitted only in or among countries + not thus excluded. In such case, this License incorporates the + limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new + versions of the General Public License from time to time. Such new + versions will be similar in spirit to the present version, but may + differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the Program + specifies a version number of this License which applies to it and "any + later version", you have the option of following the terms and + conditions either of that version or of any later version published by + the Free Software Foundation. If the Program does not specify a version + number of this License, you may choose any version ever published by the + Free Software Foundation. + + 10. If you wish to incorporate parts of the Program into other free + programs whose distribution conditions are different, write to the + author to ask for permission. For software which is copyrighted by the + Free Software Foundation, write to the Free Software Foundation; we + sometimes make exceptions for this. Our decision will be guided by the + two goals of preserving the free status of all derivatives of our free + software and of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO + WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. + EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR + OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, + EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE + ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH + YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL + NECESSARY SERVICING, REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN + WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY + AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR + DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL + DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM + (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED + INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF + THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR + OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest + possible use to the public, the best way to achieve this is to make it + free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest to + attach them to the start of each source file to most effectively convey + the exclusion of warranty; and each file should have at least the + "copyright" line and a pointer to where the full notice is found. + + One line to give the program's name and a brief idea of what it does. + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA + + Also add information on how to contact you by electronic and paper mail. + + If the program is interactive, make it output a short notice like this + when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type + `show w'. This is free software, and you are welcome to redistribute + it under certain conditions; type `show c' for details. + + The hypothetical commands `show w' and `show c' should show the + appropriate parts of the General Public License. Of course, the commands + you use may be called something other than `show w' and `show c'; they + could even be mouse-clicks or menu items--whatever suits your program. + + You should also get your employer (if you work as a programmer) or your + school, if any, to sign a "copyright disclaimer" for the program, if + necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + program `Gnomovision' (which makes passes at compilers) written by + James Hacker. + + signature of Ty Coon, 1 April 1989 + Ty Coon, President of Vice + + This General Public License does not permit incorporating your program + into proprietary programs. If your program is a subroutine library, you + may consider it more useful to permit linking proprietary applications + with the library. If this is what you want to do, use the GNU Library + General Public License instead of this License. + +--- + +## CLASSPATH EXCEPTION + + Linking this library statically or dynamically with other modules is + making a combined work based on this library. Thus, the terms and + conditions of the GNU General Public License version 2 cover the whole + combination. + + As a special exception, the copyright holders of this library give you + permission to link this library with independent modules to produce an + executable, regardless of the license terms of these independent + modules, and to copy and distribute the resulting executable under + terms of your choice, provided that you also meet, for each linked + independent module, the terms and conditions of the license of that + module. An independent module is a module which is not derived from or + based on this library. If you modify this library, you may extend this + exception to your version of the library, but you are not obligated to + do so. If you do not wish to do so, delete this exception statement + from your version.
diff --git a/tck-dist/src/main/scripts/artifact-install.sh b/tck-dist/src/main/scripts/artifact-install.sh new file mode 100644 index 0000000..b8aca1b --- /dev/null +++ b/tck-dist/src/main/scripts/artifact-install.sh
@@ -0,0 +1,34 @@ +#!/usr/bin/env bash + +# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +##script to install the artifact directory contents into a local maven repository + +if [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then + VERSION="$1" +else + VERSION="3.0.0" +fi + +#jar +mvn org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file \ +-Dfile=jakarta.json.bind-tck-"$VERSION".jar -DgroupId=jakarta.json.bind \ +-DartifactId=jakarta.json.bind-tck -Dversion="$VERSION" -Dpackaging=jar + + +#jar +mvn org.apache.maven.plugins:maven-install-plugin:3.0.0-M1:install-file \ +-Dfile=jakarta.json.bind-tck-"$VERSION".jar -DgroupId=jakarta.json.bind \ +-DartifactId=jakarta.json.bind-tck-sources -Dversion="$VERSION" -Dpackaging=jar \ No newline at end of file
diff --git a/tck-docs/JSONB3.0-ReleaseNotes.html b/tck-docs/JSONB3.0-ReleaseNotes.html new file mode 100644 index 0000000..ff75a4e --- /dev/null +++ b/tck-docs/JSONB3.0-ReleaseNotes.html
@@ -0,0 +1,95 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- + + Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<html><head><title>Jakarta JSON Binding TCK, Version 3.0 Release Notes, March 2022</title> + +<style type="text/css"> +<!-- +body { background-color: #ffffdd; color: #000000} +pre { background-color: #eeeeee; color: #000099; font-size: smaller} +code { color: #000099; font-size: smaller} +h1 { color: #000099} +h2 { color: #000099} +h3 { color: #000099; text-decoration: underline} +h4 { font-style: italic; color: #000099} +.tabletitle { font-style: italic; color: #ffffcc; font-size: small; font-variant: small-caps} +.subtitle { font-style: italic; color: #ffffcc; font-variant: small-caps} +.emphasize { font-style: italic; color: #000099} +.step { font-weight: bold} +.note { background-color: #fffff0; border-bottom-width: thin; border-top-width: thin; border-top-style: inset; border-bottom-style: inset; font-size: -10%;} +th { background-color: #eeeeee; padding-left: 2pt; padding-right: 2pt;} +--> +</style></head> + +<body> +<div align="center"> +<h1>Jakarta JSON Binding Technology Compatibility Kit, Version 3.0<br> +<em class="emphasize">Release Notes, March, 2022</em></h1> +</div> + + +<h2><a name="kit_contents">Kit Contents</a></h2> + +<p>The Jakarta JSON Binding, Version 3.0 Technology Compatibility Kit (TCK) includes the following items:</p> + +<ul> + <li><p><strong>Jakarta JSON Binding TCK tests signature, API, and end-to-end tests:</strong></p> + <ul type="square"> + <li><p>A <strong>signature test</strong> that checks that all of the public APIs are supported in the Jakarta JSON Binding Version 3.0 implementation that is being tested</p></li> + <li><p><strong>API tests</strong> for all of the public APIs under the <code>javax.xml.soap</code> package</p></li> + <li><p><strong>Specification tests</strong> for the testable assertions required by the Jakarta JSON Binding 3.0 Specification.</p></li> + </ul> + </li> +</ul> + +<hr> +<h2>Jakarta JSON Binding 3.0 TCK Facts</h2> +<p>The test suite bundle contains the following:</p> +<ul> + <li>295 total tests</li> +</ul> + +<hr> +<h2><a name="platform">Platform Notes</a></h2> + +<p>The Jakarta JSON Binding TCK tests have been built and tested running on the Java<font size="-2"><sup>TM</sup></font> +Standard Edition 11 (Java SE 11) platform.</p> + +<p>The Jakarta JSON Binding TCK tests run on the following platforms:</p> + +<ul> +<li>Oracle Linux 7.1</li> +<li>Windows 10</li> +</ul> + +<hr> + +<h2><a name="install_setup_run">Installing, Setting Up, and Running the Jakarta JSON Binding TCK</a></h2> + +<p>Refer to the <cite>Jakarta JSON Binding TCK 3.0 User's Guide</cite> for complete instructions on installing, setting up, and running the Jakarta JSON Binding TCK.</p> + +<hr> +<h2>Attributions</h2> +<p>The Jakarta JSON Binding 3.0 TCK includes software developed by the Apache + Software Foundation (<a href="http://www.apache.org/">http://www.apache.org/</a>). +</p> + +<hr> +<p><cite><small>Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.</small></cite></p> +</body></html>
diff --git a/tck-docs/TCK-Exclude-List.txt b/tck-docs/TCK-Exclude-List.txt new file mode 100644 index 0000000..b0170c7 --- /dev/null +++ b/tck-docs/TCK-Exclude-List.txt
@@ -0,0 +1,33 @@ +# +# Copyright (c) 2021, 2024 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +# +# Bug ID: https://github.com/jakartaee/jsonb-api/issues/180 +# +jakarta/jsonb/bind/tck/defaultmapping/basictypes/BasicJavaTypesMappingTest.java#testLongMapping_from_standalone +jakarta/jsonb/bind/tck/defaultmapping/bignumbers/BigNumbersMappingTest.java#testBigNumberMarshalling_from_standalone + +# +# Bug ID: https://github.com/jakartaee/platform-tck/issues/102 +# +jakarta/jsonb/bind/tck/defaultmapping/dates/DatesMappingTest.java#testGregorianCalendarWithTimeMapping_from_standalone + +# +# Bug ID: https://github.com/jakartaee/platform-tck/issues/103 +# +jakarta/jsonb/bind/tck/defaultmapping/collections/CollectionsMappingTest.java#testEnumMap_from_standalone +jakarta/jsonb/bind/tck/defaultmapping/collections/CollectionsMappingTest.java#testEnumSet_from_standalone +
diff --git a/tck-docs/assertions/JSONBJavadocAssertions.html b/tck-docs/assertions/JSONBJavadocAssertions.html new file mode 100644 index 0000000..9af6567 --- /dev/null +++ b/tck-docs/assertions/JSONBJavadocAssertions.html
@@ -0,0 +1,1181 @@ +<!-- + + Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<html xmlns:Assertions="http://download.eclipse.org/ee4j/jakartaee-tck/CTS/XMLassertions"> + <head> + <META http-equiv="Content-Type" content="text/html; charset=UTF-8"> + <title>JavaDoc Assertion Detail</title> + </head> + <body bgcolor="white"> + <br> + <CENTER> + <h2> + JSONB 3.0 + <br> + Jakarta JSON Binding 3.0 + <br> + JavaDoc Assertion Detail + + </h2> + </CENTER> + <TABLE width="900" border="1" frame="box" cellpadding="5"> + <TH bgcolor="#BFBFBF"><FONT size="1PT">Totals</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Total</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Active</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Deprecated</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Removed</FONT></TH> + <tr> + <TD align="center" valign="center"><font size="2PT"> + # of Assertions + </font></TD><TD align="center" valign="center"><font size="2PT">108</font></TD><TD align="center" valign="center"><font size="2PT">100</font></TD><TD align="center" valign="center"><font size="2PT">1</font></TD><TD align="center" valign="center"><font size="2PT">7</font></TD> + </tr> + <tr> + <TD align="center" valign="center"><font size="2PT"> + # of Required Assertions + </font></TD><TD align="center" valign="center"><font size="2PT">108</font></TD><TD align="center" valign="center"><font size="2PT">100</font></TD><TD align="center" valign="center"><font size="2PT">1</font></TD><TD align="center" valign="center"><font size="2PT">7</font></TD> + </tr> + <tr> + <TD align="center" valign="center"><font size="2PT"> + # of Optional Assertions + </font></TD><TD align="center" valign="center"><font size="2PT">0</font></TD><TD align="center" valign="center"><font size="2PT">0</font></TD><TD align="center" valign="center"><font size="2PT">0</font></TD><TD align="center" valign="center"><font size="2PT">0</font></TD> + </tr> + </TABLE> + <br> + <TABLE width="900" border="1" frame="box" cellpadding="1" summary="Javadoc Assertions"> + <TH bgcolor="#BFBFBF"><FONT size="1PT">ID</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Return</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Method/Field</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Description</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Required</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Deprecated</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Testable</FONT></TH> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:1"></a><font size="1PT">JSONB:JAVADOC:1</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + String + , + <br> + Class + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Reads in a JSON data from the specified string and return the resulting content tree.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:2"></a><font size="1PT">JSONB:JAVADOC:2</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + String + , + <br> + Class + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected error(s) occur(s) during deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:3"></a><font size="1PT">JSONB:JAVADOC:3</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + String + , + <br> + Type + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Reads in a JSON data from the specified string and return the resulting content tree.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:4"></a><font size="1PT">JSONB:JAVADOC:4</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + String + , + <br> + Type + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected error(s) occur(s) during deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:5"></a><font size="1PT">JSONB:JAVADOC:5</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + Reader + , + <br> + Class + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Reads in a JSON data from the specified Reader and return the resulting content tree.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:6"></a><font size="1PT">JSONB:JAVADOC:6</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + Reader + , + <br> + Class + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected error(s) occur(s) during deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:7"></a><font size="1PT">JSONB:JAVADOC:7</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + Reader + , + <br> + Type + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Reads in a JSON data from the specified Reader and return the resulting content tree.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:8"></a><font size="1PT">JSONB:JAVADOC:8</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + Reader + , + <br> + Type + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected error(s) occur(s) during deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:9"></a><font size="1PT">JSONB:JAVADOC:9</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + InputStream + , + <br> + Class + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Reads in a JSON data from the specified InputStream and return the resulting content tree.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:10"></a><font size="1PT">JSONB:JAVADOC:10</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + InputStream + , + <br> + Class + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected error(s) occur(s) during deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:11"></a><font size="1PT">JSONB:JAVADOC:11</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + InputStream + , + <br> + Type + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Reads in a JSON data from the specified InputStream and return the resulting content tree.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:12"></a><font size="1PT">JSONB:JAVADOC:12</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.fromJson + <br> + ( + InputStream + , + <br> + Type + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected error(s) occur(s) during deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:13"></a><font size="1PT">JSONB:JAVADOC:13</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Writes the Java object tree with root object object to a String instance as JSON.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:14"></a><font size="1PT">JSONB:JAVADOC:14</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected problem occurs during the serialization, such as I/O error.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:15"></a><font size="1PT">JSONB:JAVADOC:15</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + Type + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Writes the Java object tree with root object object to a String instance as JSON.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:16"></a><font size="1PT">JSONB:JAVADOC:16</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + Type + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected problem occurs during the serialization, such as I/O error.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:17"></a><font size="1PT">JSONB:JAVADOC:17</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + Writer + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Writes the object content tree into a Writer character stream.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:18"></a><font size="1PT">JSONB:JAVADOC:18</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + Writer + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected problem occurs during the serialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:19"></a><font size="1PT">JSONB:JAVADOC:19</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + Type + , + <br> + Writer + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Writes the object content tree into a Writer character stream.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:20"></a><font size="1PT">JSONB:JAVADOC:20</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + Type + , + <br> + Writer + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected problem occurs during the serialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:21"></a><font size="1PT">JSONB:JAVADOC:21</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + OutputStream + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Writes the object content tree into output stream.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:22"></a><font size="1PT">JSONB:JAVADOC:22</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + OutputStream + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected problem occurs during the serialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:23"></a><font size="1PT">JSONB:JAVADOC:23</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + Type + , + <br> + OutputStream + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Writes the object content tree into output stream.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:24"></a><font size="1PT">JSONB:JAVADOC:24</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.Jsonb.toJson + <br> + ( + Object + , + <br> + Type + , + <br> + OutputStream + ) + + <br> + throws + JsonbException + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">If any unexpected problem occurs during the serialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:25"></a><font size="1PT">JSONB:JAVADOC:25</font></TD><TD align="center" valign="center"><font size="1PT">Jsonb</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbBuilder.build + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Returns a new instance of jakarta.json.bind.Jsonb Jsonb based on the parameters and configuration specified previously in this builder.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:26"></a><font size="1PT">JSONB:JAVADOC:26</font></TD><TD align="center" valign="center"><font size="1PT">Jsonb</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbBuilder.create + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Create a new jakarta.json.bind.Jsonb instance using the default JsonbBuilder implementation provided as returned from jakarta.json.bind.spi.JsonbProvider#provider() method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:27"></a><font size="1PT">JSONB:JAVADOC:27</font></TD><TD align="center" valign="center"><font size="1PT">Jsonb</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbBuilder.create + <br> + ( + JsonbConfig + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Create a new jakarta.json.bind.Jsonb instance using the default JsonbBuilder implementation provided as returned from jakarta.json.bind.spi.JsonbProvider#provider() method, configured with provided configuration.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:28"></a><font size="1PT">JSONB:JAVADOC:28</font></TD><TD align="center" valign="center"><font size="1PT">JsonbBuilder</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbBuilder.newBuilder + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Create a new JsonbBuilder instance as returned by the default jakarta.json.bind.spi.JsonbProvider#provider() method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:29"></a><font size="1PT">JSONB:JAVADOC:29</font></TD><TD align="center" valign="center"><font size="1PT">JsonbBuilder</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbBuilder.newBuilder + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Create a new JsonbBuilder instance as returned by jakarta.json.bind.spi.JsonbProvider#provider(String) method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:30"></a><font size="1PT">JSONB:JAVADOC:30</font></TD><TD align="center" valign="center"><font size="1PT">JsonbBuilder</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbBuilder.newBuilder + <br> + ( + JsonbProvider + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Create a new JsonbBuilder instance as returned by provider#create call.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:31"></a><font size="1PT">JSONB:JAVADOC:31</font></TD><TD align="center" valign="center"><font size="1PT">JsonbBuilder</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbBuilder.withConfig + <br> + ( + JsonbConfig + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Set configuration which will be set to the newly created jakarta.json.bind.Jsonb Jsonb instance.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:33"></a><font size="1PT">JSONB:JAVADOC:33</font></TD><TD align="center" valign="center"><font size="1PT">Map</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.getAsMap + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Return all configuration properties as an unmodifiable map.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:34"></a><font size="1PT">JSONB:JAVADOC:34</font></TD><TD align="center" valign="center"><font size="1PT">Optional</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.getProperty + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Return value of particular configuration property. The method can only be used to retrieve one of the standard JSON Binding properties defined in this class or a provider specific property. Attempting to get an undefined property will result in an empty Optional value. See Supported Properties.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:35"></a><font size="1PT">JSONB:JAVADOC:35</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.JsonbConfig + <br> + </font></TD><TD align="left" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:36"></a><font size="1PT">JSONB:JAVADOC:36</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.setProperty + <br> + ( + String + , + <br> + Object + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Set the particular configuration property to a new value. The method can only be used to set one of the standard JSON Binding properties defined in this class or a provider specific property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:51"></a><font size="1PT">JSONB:JAVADOC:51</font></TD><TD align="center" valign="center"><font size="1PT">JsonbException</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbException.JsonbException + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Constructs a new runtime exception with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to #initCause.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:52"></a><font size="1PT">JSONB:JAVADOC:52</font></TD><TD align="center" valign="center"><font size="1PT">JsonbException</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbException.JsonbException + <br> + ( + String + , + <br> + Throwable + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Constructs a new runtime exception with the specified detail message and cause. Note that the detail message associated with cause is not automatically incorporated in this runtime exception's detail message.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:53"></a><font size="1PT">JSONB:JAVADOC:53</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.adapter.JsonbAdapter.adaptFromJson + <br> + ( + Object + ) + </font></TD><TD align="left" valign="center"><font size="1PT">This method is used on deserialization only. It contains a conversion logic from type Adapted to type Original.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:54"></a><font size="1PT">JSONB:JAVADOC:54</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.adapter.JsonbAdapter.adaptFromJson + <br> + ( + Object + ) + + <br> + throws + Exception + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">if there is an error during the conversion.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:55"></a><font size="1PT">JSONB:JAVADOC:55</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.adapter.JsonbAdapter.adaptToJson + <br> + ( + Object + ) + </font></TD><TD align="left" valign="center"><font size="1PT">This method is used on serialization only. It contains a conversion logic from type Original to type Adapted. After conversion Adapted type will be mapped to JSON the standard way.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:56"></a><font size="1PT">JSONB:JAVADOC:56</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.adapter.JsonbAdapter.adaptToJson + <br> + ( + Object + ) + + <br> + throws + Exception + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">if there is an error during the conversion.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:57"></a><font size="1PT">JSONB:JAVADOC:57</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbDateFormat.locale + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Custom java.util.Locale to use.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:58"></a><font size="1PT">JSONB:JAVADOC:58</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbDateFormat.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Specifies the date pattern to use.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:60"></a><font size="1PT">JSONB:JAVADOC:60</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbNumberFormat.locale + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Custom java.util.Locale to use.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:61"></a><font size="1PT">JSONB:JAVADOC:61</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbNumberFormat.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Specifies the number pattern to use.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:63"></a><font size="1PT">JSONB:JAVADOC:63</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbProperty.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Customized name of the field (or JavaBean property).</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:64"></a><font size="1PT">JSONB:JAVADOC:64</font></TD><TD align="center" valign="center"><font size="1PT">String[]</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbPropertyOrder.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Order in which properties are serialized. Names must correspond to original names defined in Java class before any customization applied.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:65"></a><font size="1PT">JSONB:JAVADOC:65</font></TD><TD align="center" valign="center"><font size="1PT">Class</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbTypeAdapter.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Custom JsonbAdapter which provides custom mapping for given field or JavaBean property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:66"></a><font size="1PT">JSONB:JAVADOC:66</font></TD><TD align="center" valign="center"><font size="1PT">Class</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbTypeDeserializer.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Custom JsonbDeserializer which provides custom mapping for given field or JavaBean property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:67"></a><font size="1PT">JSONB:JAVADOC:67</font></TD><TD align="center" valign="center"><font size="1PT">Class</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbTypeSerializer.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Custom JsonbSerializer which provides custom mapping for given field or JavaBean property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:68"></a><font size="1PT">JSONB:JAVADOC:68</font></TD><TD align="center" valign="center"><font size="1PT">Class</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbVisibility.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Custom property visibility strategy used to resolve visibility of the members.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:69"></a><font size="1PT">JSONB:JAVADOC:69</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.config.PropertyNamingStrategy.translateName + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Translates the property name into its JSON field name representation.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:70"></a><font size="1PT">JSONB:JAVADOC:70</font></TD><TD align="center" valign="center"><font size="1PT">boolean</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.config.PropertyVisibilityStrategy.isVisible + <br> + ( + Field + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Responds whether the given field should be considered as the JsonbProperty.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:71"></a><font size="1PT">JSONB:JAVADOC:71</font></TD><TD align="center" valign="center"><font size="1PT">boolean</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.config.PropertyVisibilityStrategy.isVisible + <br> + ( + Method + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Responds whether the given method should be considered as the JsonbProperty.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:78"></a><font size="1PT">JSONB:JAVADOC:78</font></TD><TD align="center" valign="center"><font size="1PT">JsonbBuilder</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.spi.JsonbProvider.create + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Returns a new instance of jakarta.json.bind.JsonbBuilder JsonbBuilder class. jakarta.json.bind.JsonbBuilder JsonbBuilder provides necessary getter methods to access required parameters.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:80"></a><font size="1PT">JSONB:JAVADOC:80</font></TD><TD align="center" valign="center"><font size="1PT">JsonbProvider</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.spi.JsonbProvider.provider + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Creates a JSON Binding provider object by using the java.util.ServiceLoader#load(Class) method. The first provider of JsonbProvider class from list of providers returned by ServiceLoader.load call is returned. If there are no available service providers, this method tries to load the default service provider using Class#forName(String) method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:81"></a><font size="1PT">JSONB:JAVADOC:81</font></TD><TD align="center" valign="center"><font size="1PT">JsonbProvider</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.spi.JsonbProvider.provider + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Creates a JSON Binding provider object by using the java.util.ServiceLoader#load(Class) method, matching providerName. The first provider of JsonbProvider class from list of providers returned by ServiceLoader.load call, matching providerName is returned. If no such provider is found, JsonbException is thrown.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:37__OLD"></a><font size="1PT">JSONB:JAVADOC:37__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withAdapters + <br> + ( + JsonbAdapter[] + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom mapping adapters. Configures value of ADAPTERS property. Calling withAdapters more than once will merge the adapters with previous value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:37"></a><font size="1PT">JSONB:JAVADOC:37</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withAdapters + <br> + ( + JsonbAdapter[] + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom mapping adapters. Configures value of #ADAPTERS property. Calling withAdapters more than once will merge the adapters with previous value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:38__OLD"></a><font size="1PT">JSONB:JAVADOC:38__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withBinaryDataStrategy + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom binary data strategy. Configures value of BINARY_DATA_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:38"></a><font size="1PT">JSONB:JAVADOC:38</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withBinaryDataStrategy + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom binary data strategy. Configures value of #BINARY_DATA_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:39__OLD"></a><font size="1PT">JSONB:JAVADOC:39__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withDateFormat + <br> + ( + String + , + <br> + Locale + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom date format. This format will be used by default for all date classes serialization and deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:39"></a><font size="1PT">JSONB:JAVADOC:39</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withDateFormat + <br> + ( + String + , + <br> + Locale + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom date format. This format will be used by default for all date classes serialization and deserialization. Configures values of #DATE_FORMAT and #LOCALE properties.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:40__OLD"></a><font size="1PT">JSONB:JAVADOC:40__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withDeserializers + <br> + ( + JsonbDeserializer[] + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom deserializers. Configures value of DESERIALIZERS property. Calling withDeserializers more than once will merge the deserializers with previous value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:40"></a><font size="1PT">JSONB:JAVADOC:40</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withDeserializers + <br> + ( + JsonbDeserializer[] + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom deserializers. Configures value of #DESERIALIZERS property. Calling withDeserializers more than once will merge the deserializers with previous value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:41__OLD"></a><font size="1PT">JSONB:JAVADOC:41__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withEncoding + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">The binding operations will default to this property for encoding of JSON data. For input data (fromJson), selected encoding is used if the encoding cannot be detected automatically. Default value is 'UTF-8'. Configures value of ENCODING property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:41"></a><font size="1PT">JSONB:JAVADOC:41</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withEncoding + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">The binding operations will default to this property for encoding of JSON data. For input data (fromJson), selected encoding is used if the encoding cannot be detected automatically. Default value is 'UTF-8'. Configures value of #ENCODING property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:42__OLD"></a><font size="1PT">JSONB:JAVADOC:42__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withFormatting + <br> + ( + Boolean + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify whether or not the serialized JSON data is formatted with linefeeds and indentation. Configures value of FORMATTING property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:42"></a><font size="1PT">JSONB:JAVADOC:42</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withFormatting + <br> + ( + Boolean + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify whether or not the serialized JSON data is formatted with linefeeds and indentation. Configures value of #FORMATTING property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:43__OLD"></a><font size="1PT">JSONB:JAVADOC:43__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withLocale + <br> + ( + Locale + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom locale.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:43"></a><font size="1PT">JSONB:JAVADOC:43</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withLocale + <br> + ( + Locale + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom locale. Configures value of #LOCALE property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:44__OLD"></a><font size="1PT">JSONB:JAVADOC:44__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withNullValues + <br> + ( + Boolean + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify whether null values should be serialized to JSON document or skipped. Configures value of NULL_VALUES property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:44"></a><font size="1PT">JSONB:JAVADOC:44</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withNullValues + <br> + ( + Boolean + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify whether null values should be serialized to JSON document or skipped. Configures value of #NULL_VALUES property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:45__OLD"></a><font size="1PT">JSONB:JAVADOC:45__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withPropertyNamingStrategy + <br> + ( + PropertyNamingStrategy + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom naming strategy. Configures value of JSONB_PROPERTY_NAMING_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:45"></a><font size="1PT">JSONB:JAVADOC:45</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withPropertyNamingStrategy + <br> + ( + PropertyNamingStrategy + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom naming strategy. Configures value of #PROPERTY_NAMING_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:46__OLD"></a><font size="1PT">JSONB:JAVADOC:46__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withPropertyNamingStrategy + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom naming strategy. Configures value of JSONB_PROPERTY_NAMING_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:46"></a><font size="1PT">JSONB:JAVADOC:46</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withPropertyNamingStrategy + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom naming strategy. Configures value of #PROPERTY_NAMING_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:47__OLD"></a><font size="1PT">JSONB:JAVADOC:47__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withPropertyOrderStrategy + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify property order strategy. Configures values of JSONB_PROPERTY_ORDER_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:47"></a><font size="1PT">JSONB:JAVADOC:47</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withPropertyOrderStrategy + <br> + ( + String + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify property order strategy. Configures values of #PROPERTY_ORDER_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:48__OLD"></a><font size="1PT">JSONB:JAVADOC:48__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withPropertyVisibilityStrategy + <br> + ( + PropertyVisibilityStrategy + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom property visibility strategy. Configures value of PROPERTY_VISIBILITY_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:48"></a><font size="1PT">JSONB:JAVADOC:48</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withPropertyVisibilityStrategy + <br> + ( + PropertyVisibilityStrategy + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom property visibility strategy. Configures value of #PROPERTY_VISIBILITY_STRATEGY property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:49__OLD"></a><font size="1PT">JSONB:JAVADOC:49__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withSerializers + <br> + ( + JsonbSerializer[] + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom serializers. Configures value of SERIALIZERS property. Calling withSerializers more than once will merge the serializers with previous value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:49"></a><font size="1PT">JSONB:JAVADOC:49</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withSerializers + <br> + ( + JsonbSerializer[] + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify custom serializers. Configures value of #SERIALIZERS property. Calling withSerializers more than once will merge the serializers with previous value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:50__OLD"></a><font size="1PT">JSONB:JAVADOC:50__OLD</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withStrictIJSON + <br> + ( + Boolean + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify whether strict I-JSON serialization compliance should be enforced. Configures value of STRICT_IJSON property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:50"></a><font size="1PT">JSONB:JAVADOC:50</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withStrictIJSON + <br> + ( + Boolean + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify whether strict I-JSON serialization compliance should be enforced. Configures value of #STRICT_IJSON property.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:59__OLD"></a><font size="1PT">JSONB:JAVADOC:59__OLD</font></TD><TD align="center" valign="center"><font size="1PT">boolean</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbNillable.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">True if field with null value should be serialized as key/value pair into JSON with null value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:59"></a><font size="1PT">JSONB:JAVADOC:59</font></TD><TD align="center" valign="center"><font size="1PT">boolean</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbNillable.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Switches on/off serialization of properties with null value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:62__OLD"></a><font size="1PT">JSONB:JAVADOC:62__OLD</font></TD><TD align="center" valign="center"><font size="1PT">boolean</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbProperty.nillable + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">True if field with null value should be serialized as key/value pair into JSON with null value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:62"></a><font size="1PT">JSONB:JAVADOC:62</font></TD><TD align="center" valign="center"><font size="1PT">boolean</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbProperty.nillable + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Switches on/off serialization of null values.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:82"></a><font size="1PT">JSONB:JAVADOC:82</font></TD><TD align="center" valign="center"><font size="1PT">JsonbBuilder</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbBuilder.withProvider + <br> + ( + JsonProvider + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Provides a JSON-P provider to be used for all JSON-P related operations.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:83"></a><font size="1PT">JSONB:JAVADOC:83</font></TD><TD align="center" valign="center"><font size="1PT">JsonbConfig</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.JsonbConfig.withCreatorParametersRequired + <br> + ( + boolean + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Property used to specify whether all creator parameters should be treated as required. Default value is false.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:84"></a><font size="1PT">JSONB:JAVADOC:84</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbSubtype.alias + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Type alias which is used instead of a class name.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:85"></a><font size="1PT">JSONB:JAVADOC:85</font></TD><TD align="center" valign="center"><font size="1PT">Class</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbSubtype.type + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">An actual type bound to the alias.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:86"></a><font size="1PT">JSONB:JAVADOC:86</font></TD><TD align="center" valign="center"><font size="1PT">String</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbTypeInfo.key + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Key used for keeping the type information (alias). Default value is @type.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:87"></a><font size="1PT">JSONB:JAVADOC:87</font></TD><TD align="center" valign="center"><font size="1PT">JsonbSubtype[]</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.annotation.JsonbTypeInfo.value + <br> + </font></TD><TD align="left" valign="center"><font size="1PT">Allowed aliases of the handled type.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:88"></a><font size="1PT">JSONB:JAVADOC:88</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.serializer.DeserializationContext.deserialize + <br> + ( + Class + , + <br> + JsonParser + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Deserialize JSON stream into instance of provided class using jakarta.json.stream.JsonParser. JsonParser cursor have to be at KEY_NAME before START_OBJECT / START_ARRAY, or at START_OBJECT / START_ARRAY to call this method. After deserialization is complete JsonParser will be at END_OBJECT / END_ARRAY for deserialized JSON structure. If method is called for the same type, which is deserializer bound to, deserializer recursion is suppressed. Otherwise deserializers are reentrant during deserialization process started by this method. JsonParser instance of JSONB runtime is shared with custom deserializer.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:89"></a><font size="1PT">JSONB:JAVADOC:89</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.serializer.DeserializationContext.deserialize + <br> + ( + Type + , + <br> + JsonParser + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Deserialize JSON stream into instance of provided class using jakarta.json.stream.JsonParser. JsonParser cursor have to be at KEY_NAME before START_OBJECT / START_ARRAY, or at START_OBJECT / START_ARRAY to call this method. After deserialization is complete JsonParser will be at END_OBJECT / END_ARRAY for deserialized JSON structure. If method is called for the same type, which is deserializer bound to, deserializer recursion is suppressed. Otherwise deserializers are reentrant during deserialization process started by this method. JsonParser instance of JSONB runtime is shared with custom deserializer.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:90"></a><font size="1PT">JSONB:JAVADOC:90</font></TD><TD align="center" valign="center"><font size="1PT">Object</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.serializer.JsonbDeserializer.deserialize + <br> + ( + JsonParser + , + <br> + DeserializationContext + , + <br> + Type + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Deserialize JSON stream into object.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:91"></a><font size="1PT">JSONB:JAVADOC:91</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.serializer.JsonbSerializer.serialize + <br> + ( + Object + , + <br> + JsonGenerator + , + <br> + SerializationContext + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Serializes object into JSON stream.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:92"></a><font size="1PT">JSONB:JAVADOC:92</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.serializer.SerializationContext.serialize + <br> + ( + String + , + <br> + Object + , + <br> + JsonGenerator + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Serializes arbitrary object to JSON, using current jakarta.json.stream.JsonGenerator instance. Serialization is ran as serialization of a root type from user JsonbSerializer. JsonGenerator instance is shared with JSONB and user serializer.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + <TR> + <TD align="center" valign="center"><a name="JSONB:JAVADOC:93"></a><font size="1PT">JSONB:JAVADOC:93</font></TD><TD align="center" valign="center"><font size="1PT">void</font></TD><TD align="left" valign="center"><font size="1PT">jakarta.json.bind.serializer.SerializationContext.serialize + <br> + ( + Object + , + <br> + JsonGenerator + ) + </font></TD><TD align="left" valign="center"><font size="1PT">Serializes arbitrary object to JSON, using current jakarta.json.stream.JsonGenerator instance. Serialization is ran as serialization of a root type from user JsonbSerializer. JsonGenerator instance is shared with JSONB and user serializer. Method without key parameter is intended to serialize inside JSON_ARRAYs.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"> + <br> + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> + </TR> + </TABLE> + </body> +</html>
diff --git a/tck-docs/assertions/JSONBJavadocAssertions.xml b/tck-docs/assertions/JSONBJavadocAssertions.xml new file mode 100644 index 0000000..78e689f --- /dev/null +++ b/tck-docs/assertions/JSONBJavadocAssertions.xml
@@ -0,0 +1,1267 @@ +<?xml version="1.0" encoding="US-ASCII"?> +<!DOCTYPE javadoc SYSTEM "http://download.eclipse.org/ee4j/jakartaee-tck/CTS/XMLassertions/dtd/javadoc_assertions.dtd"> +<!-- + + Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<javadoc> + <next-available-id>94</next-available-id> + <previous-id>82</previous-id> + <technology>JSONB</technology> + <id>JSONB 3.0</id> + <name>Jakarta JSON Binding 3.0</name> + <version>3.0</version> + <assertions> + <!-- ********************************************************************************** --> + <!-- ********************************************************************************** --> + <!-- UNMODIFIED ASSERTIONS LISTED BELOW --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>1</id> + <description>Reads in a JSON data from the specified string and return the resulting content tree.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.lang.Class</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>2</id> + <description>If any unexpected error(s) occur(s) during deserialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.lang.Class</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>3</id> + <description>Reads in a JSON data from the specified string and return the resulting content tree.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>4</id> + <description>If any unexpected error(s) occur(s) during deserialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>5</id> + <description>Reads in a JSON data from the specified Reader and return the resulting content tree.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.io.Reader</parameter> + <parameter>java.lang.Class</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>6</id> + <description>If any unexpected error(s) occur(s) during deserialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.io.Reader</parameter> + <parameter>java.lang.Class</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>7</id> + <description>Reads in a JSON data from the specified Reader and return the resulting content tree.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.io.Reader</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>8</id> + <description>If any unexpected error(s) occur(s) during deserialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.io.Reader</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>9</id> + <description>Reads in a JSON data from the specified InputStream and return the resulting content tree.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.io.InputStream</parameter> + <parameter>java.lang.Class</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>10</id> + <description>If any unexpected error(s) occur(s) during deserialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.io.InputStream</parameter> + <parameter>java.lang.Class</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>11</id> + <description>Reads in a JSON data from the specified InputStream and return the resulting content tree.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.io.InputStream</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>12</id> + <description>If any unexpected error(s) occur(s) during deserialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="fromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.io.InputStream</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>13</id> + <description>Writes the Java object tree with root object object to a String instance as JSON.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="java.lang.String"> + <parameters> + <parameter>java.lang.Object</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>14</id> + <description>If any unexpected problem occurs during the serialization, such as I/O error.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="java.lang.String"> + <parameters> + <parameter>java.lang.Object</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>15</id> + <description>Writes the Java object tree with root object object to a String instance as JSON.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="java.lang.String"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>16</id> + <description>If any unexpected problem occurs during the serialization, such as I/O error.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="java.lang.String"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>17</id> + <description>Writes the object content tree into a Writer character stream.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.io.Writer</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>18</id> + <description>If any unexpected problem occurs during the serialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.io.Writer</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>19</id> + <description>Writes the object content tree into a Writer character stream.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.lang.reflect.Type</parameter> + <parameter>java.io.Writer</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>20</id> + <description>If any unexpected problem occurs during the serialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.lang.reflect.Type</parameter> + <parameter>java.io.Writer</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>21</id> + <description>Writes the object content tree into output stream.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.io.OutputStream</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>22</id> + <description>If any unexpected problem occurs during the serialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.io.OutputStream</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>23</id> + <description>Writes the object content tree into output stream.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.lang.reflect.Type</parameter> + <parameter>java.io.OutputStream</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>24</id> + <description>If any unexpected problem occurs during the serialization.</description> + <package>jakarta.json.bind</package> + <class-interface>Jsonb</class-interface> + <method name="toJson" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>java.lang.reflect.Type</parameter> + <parameter>java.io.OutputStream</parameter> + </parameters> + <throw>jakarta.json.bind.JsonbException</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>25</id> + <description>Returns a new instance of jakarta.json.bind.Jsonb Jsonb based on the parameters and configuration specified previously in this builder.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="build" return-type="jakarta.json.bind.Jsonb" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>26</id> + <description>Create a new jakarta.json.bind.Jsonb instance using the default JsonbBuilder implementation provided as returned from jakarta.json.bind.spi.JsonbProvider#provider() method.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="create" return-type="jakarta.json.bind.Jsonb" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>27</id> + <description>Create a new jakarta.json.bind.Jsonb instance using the default JsonbBuilder implementation provided as returned from jakarta.json.bind.spi.JsonbProvider#provider() method, configured with provided configuration.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="create" return-type="jakarta.json.bind.Jsonb"> + <parameters> + <parameter>jakarta.json.bind.JsonbConfig</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>28</id> + <description>Create a new JsonbBuilder instance as returned by the default jakarta.json.bind.spi.JsonbProvider#provider() method.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="newBuilder" return-type="jakarta.json.bind.JsonbBuilder" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>29</id> + <description>Create a new JsonbBuilder instance as returned by jakarta.json.bind.spi.JsonbProvider#provider(String) method.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="newBuilder" return-type="jakarta.json.bind.JsonbBuilder"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>30</id> + <description>Create a new JsonbBuilder instance as returned by provider#create call.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="newBuilder" return-type="jakarta.json.bind.JsonbBuilder"> + <parameters> + <parameter>jakarta.json.bind.spi.JsonbProvider</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>31</id> + <description>Set configuration which will be set to the newly created jakarta.json.bind.Jsonb Jsonb instance.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="withConfig" return-type="jakarta.json.bind.JsonbBuilder"> + <parameters> + <parameter>jakarta.json.bind.JsonbConfig</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>33</id> + <description>Return all configuration properties as an unmodifiable map.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="getAsMap" return-type="java.util.Map" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>34</id> + <description>Return value of particular configuration property. The method can only be used to retrieve one of the standard JSON Binding properties defined in this class or a provider specific property. Attempting to get an undefined property will result in an empty Optional value. See Supported Properties.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="getProperty" return-type="java.util.Optional"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>35</id> + <description /> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="JsonbConfig" return-type="JsonbConfig" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>36</id> + <description>Set the particular configuration property to a new value. The method can only be used to set one of the standard JSON Binding properties defined in this class or a provider specific property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="setProperty" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.lang.Object</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>51</id> + <description>Constructs a new runtime exception with the specified detail message. The cause is not initialized, and may subsequently be initialized by a call to #initCause.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbException</class-interface> + <method name="JsonbException" return-type="JsonbException"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>52</id> + <description>Constructs a new runtime exception with the specified detail message and cause. Note that the detail message associated with cause is not automatically incorporated in this runtime exception's detail message.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbException</class-interface> + <method name="JsonbException" return-type="JsonbException"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.lang.Throwable</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>53</id> + <description>This method is used on deserialization only. It contains a conversion logic from type Adapted to type Original.</description> + <package>jakarta.json.bind.adapter</package> + <class-interface>JsonbAdapter</class-interface> + <method name="adaptFromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.Object</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>54</id> + <description>if there is an error during the conversion.</description> + <package>jakarta.json.bind.adapter</package> + <class-interface>JsonbAdapter</class-interface> + <method name="adaptFromJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.Object</parameter> + </parameters> + <throw>java.lang.Exception</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>55</id> + <description>This method is used on serialization only. It contains a conversion logic from type Original to type Adapted. After conversion Adapted type will be mapped to JSON the standard way.</description> + <package>jakarta.json.bind.adapter</package> + <class-interface>JsonbAdapter</class-interface> + <method name="adaptToJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.Object</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="false"> + <id>56</id> + <description>if there is an error during the conversion.</description> + <package>jakarta.json.bind.adapter</package> + <class-interface>JsonbAdapter</class-interface> + <method name="adaptToJson" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.Object</parameter> + </parameters> + <throw>java.lang.Exception</throw> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>57</id> + <description>Custom java.util.Locale to use.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbDateFormat</class-interface> + <method name="locale" return-type="java.lang.String" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>58</id> + <description>Specifies the date pattern to use.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbDateFormat</class-interface> + <method name="value" return-type="java.lang.String" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>60</id> + <description>Custom java.util.Locale to use.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbNumberFormat</class-interface> + <method name="locale" return-type="java.lang.String" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>61</id> + <description>Specifies the number pattern to use.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbNumberFormat</class-interface> + <method name="value" return-type="java.lang.String" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>63</id> + <description>Customized name of the field (or JavaBean property).</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbProperty</class-interface> + <method name="value" return-type="java.lang.String" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>64</id> + <description>Order in which properties are serialized. Names must correspond to original names defined in Java class before any customization applied.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbPropertyOrder</class-interface> + <method name="value" return-type="java.lang.String[]" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>65</id> + <description>Custom JsonbAdapter which provides custom mapping for given field or JavaBean property.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbTypeAdapter</class-interface> + <method name="value" return-type="java.lang.Class" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>66</id> + <description>Custom JsonbDeserializer which provides custom mapping for given field or JavaBean property.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbTypeDeserializer</class-interface> + <method name="value" return-type="java.lang.Class" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>67</id> + <description>Custom JsonbSerializer which provides custom mapping for given field or JavaBean property.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbTypeSerializer</class-interface> + <method name="value" return-type="java.lang.Class" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>68</id> + <description>Custom property visibility strategy used to resolve visibility of the members.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbVisibility</class-interface> + <method name="value" return-type="java.lang.Class" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>69</id> + <description>Translates the property name into its JSON field name representation.</description> + <package>jakarta.json.bind.config</package> + <class-interface>PropertyNamingStrategy</class-interface> + <method name="translateName" return-type="java.lang.String"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>70</id> + <description>Responds whether the given field should be considered as the JsonbProperty.</description> + <package>jakarta.json.bind.config</package> + <class-interface>PropertyVisibilityStrategy</class-interface> + <method name="isVisible" return-type="boolean"> + <parameters> + <parameter>java.lang.reflect.Field</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>71</id> + <description>Responds whether the given method should be considered as the JsonbProperty.</description> + <package>jakarta.json.bind.config</package> + <class-interface>PropertyVisibilityStrategy</class-interface> + <method name="isVisible" return-type="boolean"> + <parameters> + <parameter>java.lang.reflect.Method</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>78</id> + <description>Returns a new instance of jakarta.json.bind.JsonbBuilder JsonbBuilder class. jakarta.json.bind.JsonbBuilder JsonbBuilder provides necessary getter methods to access required parameters.</description> + <package>jakarta.json.bind.spi</package> + <class-interface>JsonbProvider</class-interface> + <method name="create" return-type="jakarta.json.bind.JsonbBuilder" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>80</id> + <description>Creates a JSON Binding provider object by using the java.util.ServiceLoader#load(Class) method. The first provider of JsonbProvider class from list of providers returned by ServiceLoader.load call is returned. If there are no available service providers, this method tries to load the default service provider using Class#forName(String) method.</description> + <package>jakarta.json.bind.spi</package> + <class-interface>JsonbProvider</class-interface> + <method name="provider" return-type="jakarta.json.bind.spi.JsonbProvider" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>81</id> + <description>Creates a JSON Binding provider object by using the java.util.ServiceLoader#load(Class) method, matching providerName. The first provider of JsonbProvider class from list of providers returned by ServiceLoader.load call, matching providerName is returned. If no such provider is found, JsonbException is thrown.</description> + <package>jakarta.json.bind.spi</package> + <class-interface>JsonbProvider</class-interface> + <method name="provider" return-type="jakarta.json.bind.spi.JsonbProvider"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ********************************************************************************** --> + <!-- ********************************************************************************** --> + <!-- MODIFIED ASSERTIONS LISTED BELOW --> + <!-- The original assertion is followed by the modified version --> + <!-- of the assertion. Users must edit the file to verify --> + <!-- that the modified assertion is correct. User should then --> + <!-- delete the original assertion or use the style sheet --> + <!-- that removes them automatically. The original and modified --> + <!-- assertions differ by their IDs, notice the original assertion --> + <!-- now ends with "__OLD" --> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>37__OLD</id> + <description>Property used to specify custom mapping adapters. Configures value of ADAPTERS property. Calling withAdapters more than once will merge the adapters with previous value.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withAdapters" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.adapter.JsonbAdapter[]</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>37</id> + <description>Property used to specify custom mapping adapters. Configures value of #ADAPTERS property. Calling withAdapters more than once will merge the adapters with previous value.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withAdapters" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.adapter.JsonbAdapter[]</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>38__OLD</id> + <description>Property used to specify custom binary data strategy. Configures value of BINARY_DATA_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withBinaryDataStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>38</id> + <description>Property used to specify custom binary data strategy. Configures value of #BINARY_DATA_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withBinaryDataStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>39__OLD</id> + <description>Property used to specify custom date format. This format will be used by default for all date classes serialization and deserialization.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withDateFormat" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.util.Locale</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>39</id> + <description>Property used to specify custom date format. This format will be used by default for all date classes serialization and deserialization. Configures values of #DATE_FORMAT and #LOCALE properties.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withDateFormat" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.util.Locale</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>40__OLD</id> + <description>Property used to specify custom deserializers. Configures value of DESERIALIZERS property. Calling withDeserializers more than once will merge the deserializers with previous value.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withDeserializers" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.serializer.JsonbDeserializer[]</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>40</id> + <description>Property used to specify custom deserializers. Configures value of #DESERIALIZERS property. Calling withDeserializers more than once will merge the deserializers with previous value.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withDeserializers" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.serializer.JsonbDeserializer[]</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>41__OLD</id> + <description>The binding operations will default to this property for encoding of JSON data. For input data (fromJson), selected encoding is used if the encoding cannot be detected automatically. Default value is 'UTF-8'. Configures value of ENCODING property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withEncoding" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>41</id> + <description>The binding operations will default to this property for encoding of JSON data. For input data (fromJson), selected encoding is used if the encoding cannot be detected automatically. Default value is 'UTF-8'. Configures value of #ENCODING property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withEncoding" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>42__OLD</id> + <description>Property used to specify whether or not the serialized JSON data is formatted with linefeeds and indentation. Configures value of FORMATTING property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withFormatting" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.Boolean</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>42</id> + <description>Property used to specify whether or not the serialized JSON data is formatted with linefeeds and indentation. Configures value of #FORMATTING property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withFormatting" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.Boolean</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>43__OLD</id> + <description>Property used to specify custom locale.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withLocale" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.util.Locale</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>43</id> + <description>Property used to specify custom locale. Configures value of #LOCALE property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withLocale" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.util.Locale</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>44__OLD</id> + <description>Property used to specify whether null values should be serialized to JSON document or skipped. Configures value of NULL_VALUES property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withNullValues" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.Boolean</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>44</id> + <description>Property used to specify whether null values should be serialized to JSON document or skipped. Configures value of #NULL_VALUES property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withNullValues" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.Boolean</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>45__OLD</id> + <description>Property used to specify custom naming strategy. Configures value of JSONB_PROPERTY_NAMING_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withPropertyNamingStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.config.PropertyNamingStrategy</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>45</id> + <description>Property used to specify custom naming strategy. Configures value of #PROPERTY_NAMING_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withPropertyNamingStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.config.PropertyNamingStrategy</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>46__OLD</id> + <description>Property used to specify custom naming strategy. Configures value of JSONB_PROPERTY_NAMING_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withPropertyNamingStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>46</id> + <description>Property used to specify custom naming strategy. Configures value of #PROPERTY_NAMING_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withPropertyNamingStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>47__OLD</id> + <description>Property used to specify property order strategy. Configures values of JSONB_PROPERTY_ORDER_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withPropertyOrderStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>47</id> + <description>Property used to specify property order strategy. Configures values of #PROPERTY_ORDER_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withPropertyOrderStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.String</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>48__OLD</id> + <description>Property used to specify custom property visibility strategy. Configures value of PROPERTY_VISIBILITY_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withPropertyVisibilityStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.config.PropertyVisibilityStrategy</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>48</id> + <description>Property used to specify custom property visibility strategy. Configures value of #PROPERTY_VISIBILITY_STRATEGY property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withPropertyVisibilityStrategy" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.config.PropertyVisibilityStrategy</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>49__OLD</id> + <description>Property used to specify custom serializers. Configures value of SERIALIZERS property. Calling withSerializers more than once will merge the serializers with previous value.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withSerializers" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.serializer.JsonbSerializer[]</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>49</id> + <description>Property used to specify custom serializers. Configures value of #SERIALIZERS property. Calling withSerializers more than once will merge the serializers with previous value.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withSerializers" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>jakarta.json.bind.serializer.JsonbSerializer[]</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>50__OLD</id> + <description>Property used to specify whether strict I-JSON serialization compliance should be enforced. Configures value of STRICT_IJSON property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withStrictIJSON" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.Boolean</parameter> + </parameters> + </method> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>50</id> + <description>Property used to specify whether strict I-JSON serialization compliance should be enforced. Configures value of #STRICT_IJSON property.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withStrictIJSON" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>java.lang.Boolean</parameter> + </parameters> + </method> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>59__OLD</id> + <description>True if field with null value should be serialized as key/value pair into JSON with null value.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbNillable</class-interface> + <method name="value" return-type="boolean" /> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <id>59</id> + <description>Switches on/off serialization of properties with null value.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbNillable</class-interface> + <method name="value" return-type="boolean" /> + </assertion> + <!-- ****** ORIGINAL ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>62__OLD</id> + <description>True if field with null value should be serialized as key/value pair into JSON with null value.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbProperty</class-interface> + <method name="nillable" return-type="boolean" /> + </assertion> + <!-- ****** MODIFIED ASSERTION ****** --> + <assertion required="true" impl-spec="false" status="deprecated" testable="true"> + <id>62</id> + <description>Switches on/off serialization of null values.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbProperty</class-interface> + <method name="nillable" return-type="boolean" /> + </assertion> + <!-- ********************************************************************************** --> + <!-- ********************************************************************************** --> + <!-- REMOVED ASSERTIONS LISTED BELOW --> + <assertion required="true" impl-spec="false" status="removed" testable="true"> + <modified /> + <id>32</id> + <description>Provides a JSON-P provider to be used for all JSON-P related operations.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="withProvider" return-type="jakarta.json.bind.JsonbBuilder"> + <parameters> + <parameter>JsonProvider</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="removed" testable="true"> + <modified /> + <id>72</id> + <description>Deserialize JSON stream into instance of provided class using jakarta.json.stream.JsonParser. JsonParser cursor have to be at KEY_NAME before START_OBJECT / START_ARRAY, or at START_OBJECT / START_ARRAY to call this method. After deserialization is complete JsonParser will be at END_OBJECT / END_ARRAY for deserialized JSON structure. If method is called for the same type, which is deserializer bound to, deserializer recursion is suppressed. Otherwise deserializers are reentrant during deserialization process started by this method. JsonParser instance of JSONB runtime is shared with custom deserializer.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>DeserializationContext</class-interface> + <method name="deserialize" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.Class</parameter> + <parameter>JsonParser</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="removed" testable="true"> + <modified /> + <id>73</id> + <description>Deserialize JSON stream into instance of provided class using jakarta.json.stream.JsonParser. JsonParser cursor have to be at KEY_NAME before START_OBJECT / START_ARRAY, or at START_OBJECT / START_ARRAY to call this method. After deserialization is complete JsonParser will be at END_OBJECT / END_ARRAY for deserialized JSON structure. If method is called for the same type, which is deserializer bound to, deserializer recursion is suppressed. Otherwise deserializers are reentrant during deserialization process started by this method. JsonParser instance of JSONB runtime is shared with custom deserializer.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>DeserializationContext</class-interface> + <method name="deserialize" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.reflect.Type</parameter> + <parameter>JsonParser</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="removed" testable="true"> + <modified /> + <id>74</id> + <description>Deserialize JSON stream into object.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>JsonbDeserializer</class-interface> + <method name="deserialize" return-type="java.lang.Object"> + <parameters> + <parameter>JsonParser</parameter> + <parameter>jakarta.json.bind.serializer.DeserializationContext</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="removed" testable="true"> + <modified /> + <id>75</id> + <description>Serializes object into JSON stream.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>JsonbSerializer</class-interface> + <method name="serialize" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>JsonGenerator</parameter> + <parameter>jakarta.json.bind.serializer.SerializationContext</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="removed" testable="true"> + <modified /> + <id>76</id> + <description>Serializes arbitrary object to JSON, using current jakarta.json.stream.JsonGenerator instance. Serialization is ran as serialization of a root type from user JsonbSerializer. JsonGenerator instance is shared with JSONB and user serializer.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>SerializationContext</class-interface> + <method name="serialize" return-type="void"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.lang.Object</parameter> + <parameter>JsonGenerator</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="removed" testable="true"> + <modified /> + <id>77</id> + <description>Serializes arbitrary object to JSON, using current jakarta.json.stream.JsonGenerator instance. Serialization is ran as serialization of a root type from user JsonbSerializer. JsonGenerator instance is shared with JSONB and user serializer. Method without key parameter is intended to serialize inside JSON_ARRAYs.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>SerializationContext</class-interface> + <method name="serialize" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>JsonGenerator</parameter> + </parameters> + </method> + </assertion> + <!-- ********************************************************************************** --> + <!-- ********************************************************************************** --> + <!-- NEW ASSERTIONS LISTED BELOW --> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:82</id> + <description>Provides a JSON-P provider to be used for all JSON-P related operations.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbBuilder</class-interface> + <method name="withProvider" return-type="jakarta.json.bind.JsonbBuilder"> + <parameters> + <parameter>jakarta.json.spi.JsonProvider</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:83</id> + <description>Property used to specify whether all creator parameters should be treated as required. Default value is false.</description> + <package>jakarta.json.bind</package> + <class-interface>JsonbConfig</class-interface> + <method name="withCreatorParametersRequired" return-type="jakarta.json.bind.JsonbConfig"> + <parameters> + <parameter>boolean</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:84</id> + <description>Type alias which is used instead of a class name.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbSubtype</class-interface> + <method name="alias" return-type="java.lang.String" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:85</id> + <description>An actual type bound to the alias.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbSubtype</class-interface> + <method name="type" return-type="java.lang.Class" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:86</id> + <description>Key used for keeping the type information (alias). Default value is @type.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbTypeInfo</class-interface> + <method name="key" return-type="java.lang.String" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:87</id> + <description>Allowed aliases of the handled type.</description> + <package>jakarta.json.bind.annotation</package> + <class-interface>JsonbTypeInfo</class-interface> + <method name="value" return-type="jakarta.json.bind.annotation.JsonbSubtype[]" /> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:88</id> + <description>Deserialize JSON stream into instance of provided class using jakarta.json.stream.JsonParser. JsonParser cursor have to be at KEY_NAME before START_OBJECT / START_ARRAY, or at START_OBJECT / START_ARRAY to call this method. After deserialization is complete JsonParser will be at END_OBJECT / END_ARRAY for deserialized JSON structure. If method is called for the same type, which is deserializer bound to, deserializer recursion is suppressed. Otherwise deserializers are reentrant during deserialization process started by this method. JsonParser instance of JSONB runtime is shared with custom deserializer.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>DeserializationContext</class-interface> + <method name="deserialize" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.Class</parameter> + <parameter>jakarta.json.stream.JsonParser</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:89</id> + <description>Deserialize JSON stream into instance of provided class using jakarta.json.stream.JsonParser. JsonParser cursor have to be at KEY_NAME before START_OBJECT / START_ARRAY, or at START_OBJECT / START_ARRAY to call this method. After deserialization is complete JsonParser will be at END_OBJECT / END_ARRAY for deserialized JSON structure. If method is called for the same type, which is deserializer bound to, deserializer recursion is suppressed. Otherwise deserializers are reentrant during deserialization process started by this method. JsonParser instance of JSONB runtime is shared with custom deserializer.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>DeserializationContext</class-interface> + <method name="deserialize" return-type="java.lang.Object"> + <parameters> + <parameter>java.lang.reflect.Type</parameter> + <parameter>jakarta.json.stream.JsonParser</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:90</id> + <description>Deserialize JSON stream into object.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>JsonbDeserializer</class-interface> + <method name="deserialize" return-type="java.lang.Object"> + <parameters> + <parameter>jakarta.json.stream.JsonParser</parameter> + <parameter>jakarta.json.bind.serializer.DeserializationContext</parameter> + <parameter>java.lang.reflect.Type</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:91</id> + <description>Serializes object into JSON stream.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>JsonbSerializer</class-interface> + <method name="serialize" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>jakarta.json.stream.JsonGenerator</parameter> + <parameter>jakarta.json.bind.serializer.SerializationContext</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:92</id> + <description>Serializes arbitrary object to JSON, using current jakarta.json.stream.JsonGenerator instance. Serialization is ran as serialization of a root type from user JsonbSerializer. JsonGenerator instance is shared with JSONB and user serializer.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>SerializationContext</class-interface> + <method name="serialize" return-type="void"> + <parameters> + <parameter>java.lang.String</parameter> + <parameter>java.lang.Object</parameter> + <parameter>jakarta.json.stream.JsonGenerator</parameter> + </parameters> + </method> + </assertion> + <assertion required="true" impl-spec="false" status="active" testable="true"> + <modified /> + <id>JSONB:JAVADOC:93</id> + <description>Serializes arbitrary object to JSON, using current jakarta.json.stream.JsonGenerator instance. Serialization is ran as serialization of a root type from user JsonbSerializer. JsonGenerator instance is shared with JSONB and user serializer. Method without key parameter is intended to serialize inside JSON_ARRAYs.</description> + <package>jakarta.json.bind.serializer</package> + <class-interface>SerializationContext</class-interface> + <method name="serialize" return-type="void"> + <parameters> + <parameter>java.lang.Object</parameter> + <parameter>jakarta.json.stream.JsonGenerator</parameter> + </parameters> + </method> + </assertion> + </assertions> +</javadoc> +
diff --git a/tck-docs/assertions/JSONBSpecAssertions.html b/tck-docs/assertions/JSONBSpecAssertions.html new file mode 100644 index 0000000..eb87d73 --- /dev/null +++ b/tck-docs/assertions/JSONBSpecAssertions.html
@@ -0,0 +1,1020 @@ +<!-- + + Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<html> +<head> +<META http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Specification Assertion Detail</title> +</head> +<body bgcolor="white"> +<br> +<CENTER> + <h2> Jakarta JSON Binding - 3.0<br> +Specification Assertion Detail +</h2> +</CENTER> +<TABLE width="900" border="1" frame="box" cellpadding="5"> +<TH bgcolor="#BFBFBF"><FONT size="1PT">Totals</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Total</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Active</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Deprecated</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Removed</FONT></TH> +<tr> +<TD align="center" valign="center"><font size="2PT"> +# of Assertions +</font></TD><TD align="center" valign="center"><font size="2PT">169</font></TD><TD align="center" valign="center"><font size="2PT">168</font></TD><TD align="center" valign="center"><font size="2PT">0</font></TD><TD align="center" valign="center"><font size="2PT">1</font></TD> +</tr> +<tr> +<TD align="center" valign="center"><font size="2PT"> +# of Required Assertions +</font></TD><TD align="center" valign="center"><font size="2PT">162</font></TD><TD align="center" valign="center"><font size="2PT">161</font></TD><TD align="center" valign="center"><font size="2PT">0</font></TD><TD align="center" valign="center"><font size="2PT">1</font></TD> +</tr> +<tr> +<TD align="center" valign="center"><font size="2PT"> +# of Optional Assertions +</font></TD><TD align="center" valign="center"><font size="2PT">7</font></TD><TD align="center" valign="center"><font size="2PT">7</font></TD><TD align="center" valign="center"><font size="2PT">0</font></TD><TD align="center" valign="center"><font size="2PT">0</font></TD> +</tr> +</TABLE> +<br> Assertions<TABLE width="900" border="1" frame="box" cellpadding="5"> +<TH bgcolor="#BFBFBF"><FONT size="1PT">ID</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Chapter</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Section</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Description</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Required</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Dependency</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Implementation Specific</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Defined by</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Status</FONT></TH><TH bgcolor="#BFBFBF"><FONT size="1PT">Testable</FONT></TH> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.1-1"></a><font size="1PT">JSONB:SPEC:JSB-3.1-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.1</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST support binding of JSON documents as defined in RFC 7159 JSON Grammar. Serialized JSON output MUST conform to the RFC 7159 JSON Grammar and be encoded in UTF-8 encoding as defined in Section 8.1 (Character Encoding) of RFC 7159 + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.1-2"></a><font size="1PT">JSONB:SPEC:JSB-3.1-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.1</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support deserialization of documents conforming to RFC 7159 JSON Grammar</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.1-3"></a><font size="1PT">JSONB:SPEC:JSB-3.1-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.1</font></TD><TD align="left" valign="center"><font size="1PT">In addition, implementations SHOULD NOT allow deserialization of RFC 7159 non-conforming text (e.g. unsupported encoding, ...) and report error in such case</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.1-4"></a><font size="1PT">JSONB:SPEC:JSB-3.1-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.1</font></TD><TD align="left" valign="center"><font size="1PT">Detection of UTF encoding of deserialized document is done as defined in the Section 3 (Encoding) of RFC 4627</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.1-5"></a><font size="1PT">JSONB:SPEC:JSB-3.1-5</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.1</font></TD><TD align="left" valign="center"><font size="1PT">Implementations SHOULD ignore presence of UTF byte order mark (BOM) and not treat it as an error.</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.2-1"></a><font size="1PT">JSONB:SPEC:JSB-3.2-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.2</font></TD><TD align="left" valign="center"><font size="1PT">Implementations SHOULD NOT allow unmarshalling of RFC 7159 non-conforming text (e.g. unsupported encoding) and report error in such case.</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.2-2"></a><font size="1PT">JSONB:SPEC:JSB-3.2-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.2</font></TD><TD align="left" valign="center"><font size="1PT">Implementation SHOULD also report error also during unmarshalling operation, if it is not possible to represent JSON document value in the expected Java type</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3-1"></a><font size="1PT">JSONB:SPEC:JSB-3.3-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3</font></TD><TD align="left" valign="center"><font size="1PT">Implementation MUST report binding of the following basic java classes and their corresponding primitive types +java.lang.String +java.lang.Character +java.lang.Byte +java.lang.Short +java.lang.Integer +java.lang.Long +java.lang.Float +java.lang.Double +java.lang.Boolean</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3.1-1"></a><font size="1PT">JSONB:SPEC:JSB-3.3.1-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3.1</font></TD><TD align="left" valign="center"><font size="1PT">Instances of type java.lang.String and java.lang.Character are marshalled to JSON String values as defined within RFC 7159 Section 7 (Strings) in UTF-8 encoding without byte order mark. </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3.1-2"></a><font size="1PT">JSONB:SPEC:JSB-3.3.1-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3.1</font></TD><TD align="left" valign="center"><font size="1PT">Implementations SHOULD support deserialization of JSON text in other (than UTF-8) UTF encodings into java.lang.String instances</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3.2-1"></a><font size="1PT">JSONB:SPEC:JSB-3.3.2-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3.2</font></TD><TD align="left" valign="center"><font size="1PT">Serialization of type java.lang.Byte, Short, Integer, Long, Float, Double and their corresponding primitive types to JSON Number MUST follow the conversion process defined in javadoc specification for the corresponding toString method</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3.2-2"></a><font size="1PT">JSONB:SPEC:JSB-3.3.2-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3.2</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization of a JSON value into java.lang.Byte, Short, Integer, Long, Float, Double instance or corresponding primitive type MUST follow the conversion process as defined in the specification for their corresponding parse$Type method, such as java.lang.Byte.parseByte for Byte.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3.3-1"></a><font size="1PT">JSONB:SPEC:JSB-3.3.3-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3.3</font></TD><TD align="left" valign="center"><font size="1PT">Serialization of type java.lang.Boolean and its corresponding boolean primitive type to JSON value MUST follow conversion process defined in specification for java.lang.Boolean.toString method</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3.3-2"></a><font size="1PT">JSONB:SPEC:JSB-3.3.3-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3.3</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization of a JSON value into java.lang.Boolean instance or boolean primitive type MUST follow the conversion process as defined in specification for java.lang.Boolean.parseBoolean method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3.4-1"></a><font size="1PT">JSONB:SPEC:JSB-3.3.4-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3.4</font></TD><TD align="left" valign="center"><font size="1PT">Serialization of type java.lang.Number (if their more concrete type is not defined elsewhere in this chapter) to JSON string MUST retrieve double value returned from java.lang.Number.doubleValue() method and converting the value to JSON Number as defined in subsection 3.3.2</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.3.4-2"></a><font size="1PT">JSONB:SPEC:JSB-3.3.4-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.3.4</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization of a JSON value into Java type java.lang.Number should return instance of java.math.BigDecimal by using conversion as defined in the specification for constructor of java.math.BigDecimal with java.lang.String.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4-1"></a><font size="1PT">JSONB:SPEC:JSB-3.4-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support binding of the following standard Java SE classes: +java.math.BigInteger +java.math.BigDecimal +java.net.URL +java.net.URI +java.util.Optional +java.util.OptionalInt +java.util.OptionalLong +java.util.OptionalDouble </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.1-1"></a><font size="1PT">JSONB:SPEC:JSB-3.4.1-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.1</font></TD><TD align="left" valign="center"><font size="1PT">Serialization of type java.math.BigInteger, BigDecimal to s JSON Number MUST follow the conversion process defined in specification for their toString method</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.1-2"></a><font size="1PT">JSONB:SPEC:JSB-3.4.1-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.1</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization of JSON value into java.math.BigInteger, BigDecimal instance MUST follow the conversion process as defined in the specification for constructor of java.math.BigInteger, BigDecimal with java.lang.String.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.2-1"></a><font size="1PT">JSONB:SPEC:JSB-3.4.2-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.2</font></TD><TD align="left" valign="center"><font size="1PT">Serialization of type java.net.URL, URI to a JSON String value MUST follow the conversion process defined in specification for their toString method</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.2-2"></a><font size="1PT">JSONB:SPEC:JSB-3.4.2-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.2</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization of a JSON value into java.net.URL, URI instance MUST follow the conversion process as defined in the specification for constructor of java.net.URL, URI with java.lang.String input.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.3-1"></a><font size="1PT">JSONB:SPEC:JSB-3.4.3-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.3</font></TD><TD align="left" valign="center"><font size="1PT">Non-empty instances of type java.util.Optional, OptionalInt, OptionalLong, OptionalDouble are serialized to a JSON value by retrieving their contained instance and converting it to JSON value based on its type and corresponding mapping definitions within this chapter.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.3-2"></a><font size="1PT">JSONB:SPEC:JSB-3.4.3-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.3</font></TD><TD align="left" valign="center"><font size="1PT">Class fields containing empty optional instances are treated as having a null value and serialized based on 3.14.1.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.3-3"></a><font size="1PT">JSONB:SPEC:JSB-3.4.3-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.3</font></TD><TD align="left" valign="center"><font size="1PT">Empty optional instances in array items are serialized as null.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.3-4"></a><font size="1PT">JSONB:SPEC:JSB-3.4.3-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.3</font></TD><TD align="left" valign="center"><font size="1PT">Deserializing into Optional, OptionalInt, OptionalLong, OptionalDouble return empty optional value for properties containing a null value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.3-5"></a><font size="1PT">JSONB:SPEC:JSB-3.4.3-5</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.3</font></TD><TD align="left" valign="center"><font size="1PT">Otherwise any non-empty Optional, OptionalInt, OptionalLong, OptionalDouble value is constructed of type unmarshalled based on mappings defined in this chapter.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.3-6"></a><font size="1PT">JSONB:SPEC:JSB-3.4.3-6</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.3</font></TD><TD align="left" valign="center"><font size="1PT">Instances of type java.util.Optional T are serialized to a JSON value as JSON objects when T alone would be serialized as JSON object. When T would be serialized as a JSON value (e.g. java.lang.String, java.lang.Integer), an instance of java.util.Optional T is serialized as a JSON value (without curly brackets).</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.4.3-7"></a><font size="1PT">JSONB:SPEC:JSB-3.4.3-7</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.4.3</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization of a JSON value into java.util.Optional(T) MUST be supported if deserialization of a JSON value into instance of T is supported.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5-1"></a><font size="1PT">JSONB:SPEC:JSB-3.5-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support binding of the following standard Java date/time classes: java.util.Date +java.util.Calendar +java.util.GregorianCalendar +java.util.TimeZone +java.util.SimpleTimeZone +java.time.Instant +java.time.Duration +java.time.Period +java.time.LocalDate +java.time.LocalTime +java.time.LocalDateTime +java.time.ZonedDateTime +java.time.ZoneId +java.time.ZoneOffset +java.time.OffsetDateTime +java.time.OffsetTime</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5-2"></a><font size="1PT">JSONB:SPEC:JSB-3.5-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5</font></TD><TD align="left" valign="center"><font size="1PT">If not specified otherwise in this section, GMT standard time zone and offset specified from UTC Greenwich is used.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5-3"></a><font size="1PT">JSONB:SPEC:JSB-3.5-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5</font></TD><TD align="left" valign="center"><font size="1PT">If not specified otherwise, date time format for marshalling and unmarshalling is ISO 8601 without offset, as specified in java.time.format.DateTimeFormatter.ISO_DATE.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5-4"></a><font size="1PT">JSONB:SPEC:JSB-3.5-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST report error if the date/time string in JSON document does not correspond to the expected datetime format. </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5-5"></a><font size="1PT">JSONB:SPEC:JSB-3.5-5</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5</font></TD><TD align="left" valign="center"><font size="1PT">If in strict I-JSON compliance mode, default date format is changed as it’s described in 4.4.1.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.1-1"></a><font size="1PT">JSONB:SPEC:JSB-3.5.1-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.1</font></TD><TD align="left" valign="center"><font size="1PT">The serialization format of java.util.Date, Calendar, GregorianCalendar instances with no time information is ISO_DATE.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.1-2"></a><font size="1PT">JSONB:SPEC:JSB-3.5.1-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.1</font></TD><TD align="left" valign="center"><font size="1PT">If time information is present, the format is ISO_DATE_TIME</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.1-3"></a><font size="1PT">JSONB:SPEC:JSB-3.5.1-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.1</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support deserialization of both ISO_DATE and ISO_DATE_TIME into java.util.Date, Calendar and GregorianCalendar instances.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.2-1"></a><font size="1PT">JSONB:SPEC:JSB-3.5.2-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.2</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support deserialization of any time zone format specified in java.util.TimeZone into a field or property of type java.util.TimeZone and SimpleTimeZone.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.2-2"></a><font size="1PT">JSONB:SPEC:JSB-3.5.2-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.2</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST report an error for deprecated three-letter time zone IDs as specified in java.util.Timezone.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.2-3"></a><font size="1PT">JSONB:SPEC:JSB-3.5.2-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.2</font></TD><TD align="left" valign="center"><font size="1PT">The serialization format of java.util.TimeZone and SimpleTimeZone is NormalizedCustomID as specified in java.util.TimeZone.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-1"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">The serialization output for a java.time.Instant instance MUST be in a ISO_INSTANT format, as specified in java.time.format.DateTimeFormatter.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-2"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support the deserialization of an ISO_INSTANT formatted JSON string to a java.time.Instant instance.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-3"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">Analogically, for other java.time.* classes, following mapping table matches Java types and corresponding formats: +java.time.Instant ISO_INSTANT +java.time.LocalDate ISO_LOCAL_DATE +java.time.LocalTime ISO_LOCAL_TIME +java.time.LocalDateTime ISO_LOCAL_DATE_TIME +java.time.ZonedDateTime ISO_ZONED_DATE_TIME +java.time.OffsetDateTime ISO_OFFSET_DATE_TIME +java.time.OffsetTime ISO_OFFSET_TIME</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-4"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support the deserialization of any time zone ID format specified in java.time.ZoneId into a field or property of type java.time.ZoneId.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-5"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-5</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">The serialization format of java.time.ZoneId is the normalized zone ID as specified in java.time.ZoneId.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-6"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-6</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support the deserialization of any time zone ID format specified in java.time.ZoneOffset into a field or property of type java.time.ZoneOffset.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-7"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-7</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">The serialization format of java.time.ZoneOffset is the normalized zone ID as specified in java.time.ZoneOffset.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-8"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-8</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support the deserialization of any duration format specified in java.time.Duration into a field or property of type java.time.Duration.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-9"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-9</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">This is super-set of ISO 8601 duration format. The serialization format of java.time.Duration is the ISO 8601 seconds based representation, such as PT8H6M12.345S.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-10"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-10</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support the deserialization of any period format specified in java.time.Period into a field or property of type java.time.Period.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-11"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-11</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">This is a super-set of ISO 8601 period format. The serialization format of java.time.Period is ISO 8601 period representation.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.5.3-12"></a><font size="1PT">JSONB:SPEC:JSB-3.5.3-12</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.5.3</font></TD><TD align="left" valign="center"><font size="1PT">A zero-length period is represented as zero days 'P0D'.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.6-1"></a><font size="1PT">JSONB:SPEC:JSB-3.6-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.6</font></TD><TD align="left" valign="center"><font size="1PT">For an unspecified output type of a deserialization operation, as well as where output type is specified as Object.class, implementations MUST deserialize a JSON document using Java runtime types specified in table below: +object java.util.Map String,Object +array java.util.List Object +string java.lang.String +number java.math.BigDecimal +true, false java.lang.Boolean +null null +</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.6-2"></a><font size="1PT">JSONB:SPEC:JSB-3.6-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.6</font></TD><TD align="left" valign="center"><font size="1PT">JSON object values are deserialized into an implementation of java.util.Map(String, Object) with a predictable iteration order.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7-1"></a><font size="1PT">JSONB:SPEC:JSB-3.7-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7</font></TD><TD align="left" valign="center"><font size="1PT">Any instance passed to a deserialization operation must have a public or protected no-argument constructor. Implementations SHOULD throw an error if this condition is not met.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7-2"></a><font size="1PT">JSONB:SPEC:JSB-3.7-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7</font></TD><TD align="left" valign="center"><font size="1PT">This limitation does not apply to serialization operations, as well as to classes which specify explicit instantiation methods as described in section 4.5.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.1-1"></a><font size="1PT">JSONB:SPEC:JSB-3.7.1-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.1</font></TD><TD align="left" valign="center"><font size="1PT">For a deserialization operation of a Java property, if a matching public setter method exists, the method is called to set the value of the property. If a matching setter method with private, protected, or defaulted to package-only access exists, then this field is ignored. If no matching setter method exists and the field is public, then direct field assignment is used.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.1-2"></a><font size="1PT">JSONB:SPEC:JSB-3.7.1-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.1</font></TD><TD align="left" valign="center"><font size="1PT">For a serialization operation, if a matching public getter method exists, the method is called to obtain the value of the property. If a matching getter method with private, protected, or defaulted to package-only access exists, then this field is ignored. If no matching getter method exists and the field is public, then the value is obtained directly from the field.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.1-3"></a><font size="1PT">JSONB:SPEC:JSB-3.7.1-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.1</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST NOT deserialize into transient, final or static fields and MUST ignore name/value pairs corresponding to such fields.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.1-4"></a><font size="1PT">JSONB:SPEC:JSB-3.7.1-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.1</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support serialization of final fields.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.1-5"></a><font size="1PT">JSONB:SPEC:JSB-3.7.1-5</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.1</font></TD><TD align="left" valign="center"><font size="1PT">Transient and static fields MUST be ignored during serialization operation.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.1-6"></a><font size="1PT">JSONB:SPEC:JSB-3.7.1-6</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.1</font></TD><TD align="left" valign="center"><font size="1PT">If a JSON document contains a name/value pair not corresponding to field or setter method, then this name/value pair MUST be ignored.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.1-7"></a><font size="1PT">JSONB:SPEC:JSB-3.7.1-7</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.1</font></TD><TD align="left" valign="center"><font size="1PT">Public getter/setter methods without a corresponding field MUST be supported. When only public getter/setter method without corresponding field is present in the class, the getter method is called to obtain the value to serialize, and the setter method is called during deserialization operation.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.2-1"></a><font size="1PT">JSONB:SPEC:JSB-3.7.2-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.2</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support the binding of public and protected nested classes.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.2-2"></a><font size="1PT">JSONB:SPEC:JSB-3.7.2-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.2</font></TD><TD align="left" valign="center"><font size="1PT">For deserialization operations, both nested and encapsulating classes MUST fulfill the same instantiation requirements as specified in 3.7.1.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.3-1"></a><font size="1PT">JSONB:SPEC:JSB-3.7.3-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.3</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support the binding of public and protected static nested classes.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.3-2"></a><font size="1PT">JSONB:SPEC:JSB-3.7.3-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.3</font></TD><TD align="left" valign="center"><font size="1PT">For deserialization operations, the nested class MUST fulfill the same instantiation requirements as specified in 3.7.1.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.7.4-1"></a><font size="1PT">JSONB:SPEC:JSB-3.7.4-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.7.4</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization into anonymous classes is not supported. Serialization of anonymous classes is supported by default object mapping.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-1"></a><font size="1PT">JSONB:SPEC:JSB-3.8-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">Polymorphic type handling is supported for deserialization and serialization. Polymorphic handling is ensured by annotation JsonbTypeInfo and @JsonbSubtype.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-2"></a><font size="1PT">JSONB:SPEC:JSB-3.8-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">JsonbTypeInfo defines key name of the property to store type information in it and defines all the supported aliases using @JsonbSubtype annotations.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-3"></a><font size="1PT">JSONB:SPEC:JSB-3.8-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">@JsonbSubtype ensures proper and safe mapping between class alias and type.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-4"></a><font size="1PT">JSONB:SPEC:JSB-3.8-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">Implementation must validate mapped types if they are assignable from the annotated type. If not, an exception must be thrown.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-5"></a><font size="1PT">JSONB:SPEC:JSB-3.8-5</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">Type information is obtained from @JsonbSubtype annotation as a type alias mapped to the type. If no matching class is found for obtained alias during deserialization, an exception must be thrown.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-6"></a><font size="1PT">JSONB:SPEC:JSB-3.8-6</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">New property with type information is added to the serialized object.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-7"></a><font size="1PT">JSONB:SPEC:JSB-3.8-7</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">The property key name is taken from the key property of the annotation JsonbTypeInfo.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-8"></a><font size="1PT">JSONB:SPEC:JSB-3.8-8</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">This type information property key name has to be unique in the resulting JSON document. If any naming collision with class or any other JsonbTypeInfo properties occurs, an exception must be thrown.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-9"></a><font size="1PT">JSONB:SPEC:JSB-3.8-9</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">It is required for all polymorphism fields to be serialized as the first properties in the JSON and any actual object properties are serialized after.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-10"></a><font size="1PT">JSONB:SPEC:JSB-3.8-10</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">If no JsonbTypeInfo is used on handled class or its predecessors, it is not possible to ensure proper polymorphic type handling and in such cases deserialization is not supported.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-11"></a><font size="1PT">JSONB:SPEC:JSB-3.8-11</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">If there are multiple different type polymorphic customizations that need to be merged, an exception must be thrown.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.8-12"></a><font size="1PT">JSONB:SPEC:JSB-3.8-12</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.8</font></TD><TD align="left" valign="center"><font size="1PT">The order of the type information properties must be the same in which they appear in the +polymorphic type chain.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.9-1"></a><font size="1PT">JSONB:SPEC:JSB-3.9-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.9</font></TD><TD align="left" valign="center"><font size="1PT">Serialization of an Enum instance to a JSON String value MUST follow the conversion process defined in javadoc specification for their name().</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.9-2"></a><font size="1PT">JSONB:SPEC:JSB-3.9-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.9</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization of a JSON value into an enum instance MUST be done by calling the enum’s valueOf(String) method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.10-1"></a><font size="1PT">JSONB:SPEC:JSB-3.10-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.10</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support the deserialization of specific interfaces defined in 3.11 and 3.3.4.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.10-2"></a><font size="1PT">JSONB:SPEC:JSB-3.10-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.10</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization to other interfaces is not supported and implementations SHOULD report error in such case.</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.10-3"></a><font size="1PT">JSONB:SPEC:JSB-3.10-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.10</font></TD><TD align="left" valign="center"><font size="1PT">If a class property is defined with an interface and not concrete type, then the mapping for a serialized property is resolved based on its runtime type.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.11-1"></a><font size="1PT">JSONB:SPEC:JSB-3.11-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.11</font></TD><TD align="left" valign="center"><font size="1PT">Implementations MUST support binding of the following collection interfaces, classes and their implementations. +java.util.Collection +java.util.Map +java.util.Set +java.util.HashSet +java.util.NavigableSet +java.util.SortedSet +java.util.TreeSet +java.util.LinkedHashSet +java.util.TreeHashSet +java.util.HashMap +java.util.NavigableMap +java.util.SortedMap +java.util.TreeMap +java.util.LinkedHashMap +java.util.TreeHashMap +java.util.List +java.util.ArrayList +java.util.LinkedList +java.util.Deque +java.util.ArrayDeque +java.util.Queue +java.util.PriorityQueue +java.util.EnumSet +java.util.EnumMap + +</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.11-2"></a><font size="1PT">JSONB:SPEC:JSB-3.11-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.11</font></TD><TD align="left" valign="center"><font size="1PT">Implementations of interfaces below must provide accessible default constructor. JSON Binding implementations MUST report unmarshalling error if default constructor is not present or is not in accessible scope.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.12-1"></a><font size="1PT">JSONB:SPEC:JSB-3.12-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.12</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST support binding of Java arrays of all supported Java types from this chapter into/from JSON array structures as defined in Section 5 of RFC 7159</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.12-2"></a><font size="1PT">JSONB:SPEC:JSB-3.12-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.12</font></TD><TD align="left" valign="center"><font size="1PT">Arrays of primitive types and multi-dimensional arrays MUST be supported.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.13-1"></a><font size="1PT">JSONB:SPEC:JSB-3.13-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.13</font></TD><TD align="left" valign="center"><font size="1PT">Declared fields MUST be serialized in lexicographical order into the resulting JSON document. In case of inheritance, declared fields of super class MUST be serialized before declared fields of child class.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.13-2"></a><font size="1PT">JSONB:SPEC:JSB-3.13-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.13</font></TD><TD align="left" valign="center"><font size="1PT">When deserializing a JSON document, declared fields MUST be set in the order of attributes present in the JSON document.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.14.1-1"></a><font size="1PT">JSONB:SPEC:JSB-3.14.1-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.14.1</font></TD><TD align="left" valign="center"><font size="1PT">The result of serializing a java field with a null value is the absence of the property in the resulting JSON document.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.14.1-2"></a><font size="1PT">JSONB:SPEC:JSB-3.14.1-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.14.1</font></TD><TD align="left" valign="center"><font size="1PT">The deserialization operation of a property absent in JSON document MUST not set the value of the field, the setter (if available) MUST not be called, and thus original value of the field MUST be preserved.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.14.1-3"></a><font size="1PT">JSONB:SPEC:JSB-3.14.1-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.14.1</font></TD><TD align="left" valign="center"><font size="1PT">The deserialization operation of a property with a null value in a JSON document MUST set the value of the field to null value (or call setter with null value if setter is present). The exception is java.util.Optional, OptionalInt, OptionalLong, OptionalDouble instances. In this case the value of the field is set to an empty optional value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.14.2-1"></a><font size="1PT">JSONB:SPEC:JSB-3.14.2-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.14.2</font></TD><TD align="left" valign="center"><font size="1PT">The result of deserialization n-ary array represented in JSON document is n-ary Java array.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.14.2-2"></a><font size="1PT">JSONB:SPEC:JSB-3.14.2-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.14.2</font></TD><TD align="left" valign="center"><font size="1PT">Null value in JSON array is represented by null value in Java array.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.14.2-3"></a><font size="1PT">JSONB:SPEC:JSB-3.14.2-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.14.2</font></TD><TD align="left" valign="center"><font size="1PT">Serialization operation on Java array with null value at index i MUST output null value at index i of the array in resulting JSON document.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.15-1"></a><font size="1PT">JSONB:SPEC:JSB-3.15-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.15</font></TD><TD align="left" valign="center"><font size="1PT">According to RFC 7159 Section 7 , every Java identifier name can be transformed using identity function into a valid JSON String. Identity function MUST be used for transforming Java identifier names into name Strings in JSON document.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.15-2"></a><font size="1PT">JSONB:SPEC:JSB-3.15-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.15</font></TD><TD align="left" valign="center"><font size="1PT">For deserialization operations defined in 3.6 section, identity function is used to transform JSON name strings into Java String instances in the resulting map Map(String, Object).</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.15-3"></a><font size="1PT">JSONB:SPEC:JSB-3.15-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.15</font></TD><TD align="left" valign="center"><font size="1PT">Identity function is used also for other deseralization operations.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">removed</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.15-4"></a><font size="1PT">JSONB:SPEC:JSB-3.15-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.15</font></TD><TD align="left" valign="center"><font size="1PT">If a Java identifier with corresponding name does not exist or is not accessible, the implementations MUST report error.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.16-1"></a><font size="1PT">JSONB:SPEC:JSB-3.16-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.16</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementation MUST serialize numbers that express greater magnitude or precision than an IEEE 754 double precision number as strings.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17-1"></a><font size="1PT">JSONB:SPEC:JSB-3.17-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST support binding of generic types.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17-2"></a><font size="1PT">JSONB:SPEC:JSB-3.17-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17</font></TD><TD align="left" valign="center"><font size="1PT">Due to type erasure, there are situations when it is not possible to obtain generic type information. There are two ways for JSON Binding implementations to obtain generic type information. If there is a class file available (in the following text referred as static type information), it is possible to obtain generic type information (effectively generic type declaration) from Signature attribute (if this information is present).</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17-3"></a><font size="1PT">JSONB:SPEC:JSB-3.17-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17</font></TD><TD align="left" valign="center"><font size="1PT">The second option is to provide generic type information at runtime. To provide generic type information at runtime, an argument of java.lang.reflect.Type MUST be passed to Jsonb::toJson or to Jsonb::fromJson method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-1"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">There are several levels of information JSON Binding implementations may obtain about the type of field/class/interface: + 1. runtime type provided via java.lang.reflect.Type parameter passed to Jsonb::toJson or Jsonb::fromJson method + 2. static type provided in class file (effectively stored in Signature attribute) + 3. raw type + 4. no information about the type</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-2"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">If there is no information about the type, JSON Binding implementation MUST treat this type as java.lang.Object.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-3"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">If only raw type of given field/class/interface is known, then the type MUST be treated like raw type.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-4"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">For example, if the only available information is that given field/class/interface is of type java.util.ArrayList, than the type MUST be treated as java.util.ArrayList Object. JSON Binding implementations MUST use the most specific type derived from the information available.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-5"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-5</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">Let's consider situation where there is only static type information of a given field/class/interface known, +and there is no runtime type information available. Let GenericClass T1; : : : ; Tn be part of generic type +declaration, where GenericClass is name of the generic type and T1; : : : ; Tn are type parameters. For every +Ti, where i in 1; : : : ; n, there are 3 possible options:</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-6"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-6</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">1. Ti is concrete parameter type +2. Ti is bounded parameter type +3. Ti is wildcard parameter type without bounds +In case 1, the most specific parameter type MUST be given concrete parameter type Ti.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-7"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-7</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">For bounded parameter type, using bounds B1; : : : ;Bm. If m = 1, then the most specific parameter type MUST be derived from the given bound B1.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-8"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-8</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">If B1 is class or interface, the most specific parameter type MUST be the class or interface.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-9"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-9</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">Otherwise, the most specific parameter type SHOULD be java.lang.Object.</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-10"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-10</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">If multiple bounds are specified, the first step is to resolve every bound separately. Let’s define result of such resolution as S1; : : : ; Sm specific parameter types. If S1; : : : ; Sm are java.lang.Object, then the bounded parameter type Ti MUST be java.lang.Object.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-11"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-11</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">If there is exactly one Sk, where 1 <= k <= m is different than java.lang.Object, then the most specific parameter type for this bounded parameter type Ti MUST be Sk.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-12"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-12</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">If there exists Sk1; Sk2, where 1 <= k1 <= k2 <= m, then the most specific parameter type is Sk1.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-13"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-13</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">For wildcard parameter type without bounds, the most specific parameter type MUST be java.lang.Object.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-14"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-14</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">Any unresolved type parameter MUST be treated as java.lang.Object. </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.17.1-15"></a><font size="1PT">JSONB:SPEC:JSB-3.17.1-15</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.17.1</font></TD><TD align="left" valign="center"><font size="1PT">If runtime type is provided via java.lang.reflect.Type parameter passed to Jsonb::toJson or Jsonb::fromJson method, than that runtime type overrides static type declaration wherever applicable</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.18-1"></a><font size="1PT">JSONB:SPEC:JSB-3.18-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.18</font></TD><TD align="left" valign="center"><font size="1PT">When JSON Binding implementation encounters key in key/value pair that it does not recognize, it should treat the rest of the JSON document as if the element simply did not appear, and in particular, the implementation MUST NOT treat this as an error condition.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.19-1"></a><font size="1PT">JSONB:SPEC:JSB-3.19-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.19</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST NOT produce JSON documents with members with duplicate names. In this context, "duplicate" means that the names, after processing any escaped characters, are identical sequences of Unicode characters.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.19-2"></a><font size="1PT">JSONB:SPEC:JSB-3.19-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.19</font></TD><TD align="left" valign="center"><font size="1PT">When non-unique property (after override and rename) is found, implementation MUST throw an exception. This doesn't apply for customized user serialization behavior implemented with the usage of JsonbAdapter mechanism.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.20-1"></a><font size="1PT">JSONB:SPEC:JSB-3.20-1</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.20</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST support binding of the following JSON Processing types. + +jakarta.json.JsonObject +jakarta.json.JsonArray +jakarta.json.JsonStructure +jakarta.json.JsonValue +jakarta.json.JsonPointer +jakarta.json.JsonString +jakarta.json.JsonNumber + </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.20-2"></a><font size="1PT">JSONB:SPEC:JSB-3.20-2</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.20</font></TD><TD align="left" valign="center"><font size="1PT">Serialization of supported jakarta.json.* objects/interfaces/fields MUST have the same result as serialization these objects with jakarta.json.JsonWriter.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.20-3"></a><font size="1PT">JSONB:SPEC:JSB-3.20-3</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.20</font></TD><TD align="left" valign="center"><font size="1PT">Deserialization into supported jakarta.json.* objects/interfaces/fields MUST have the same result as deserialization into such objects with jakarta.json.JsonReader.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-3.20-4"></a><font size="1PT">JSONB:SPEC:JSB-3.20-4</font></TD><TD align="center" valign="center"><font size="1PT">3</font></TD><TD align="center" valign="center"><font size="1PT">3.20</font></TD><TD align="left" valign="center"><font size="1PT">If the null value is deserialized into the JsonValue, it is handled as JsonValue.NULL. JsonValue.NULL is not assigned as a default value if no value is set.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.1-1"></a><font size="1PT">JSONB:SPEC:JSB-4.1.1-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.1</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST NOT serialize fields, JavaBean properties or types annotated with jakarta.json.bind.annotation.JsonbTransient.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.1-2"></a><font size="1PT">JSONB:SPEC:JSB-4.1.1-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.1</font></TD><TD align="left" valign="center"><font size="1PT">JsonbTransient annotation is mutually exclusive with all other JSON Binding defined annotations. Implementations must throw JsonbException in the following cases: Class field is annotated with @JsonbTransient. Exception must be thrown when this field, getter or setter is annotated with other JSON Binding annotations.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.1-3"></a><font size="1PT">JSONB:SPEC:JSB-4.1.1-3</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.1</font></TD><TD align="left" valign="center"><font size="1PT">Getter is annotated with @JsonbTransient. Exception is thrown if when the field or this getter are annotated with other JSON Binding annotations. Exception is not thrown if JSON Binding annotations are presented on the setter.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.1-4"></a><font size="1PT">JSONB:SPEC:JSB-4.1.1-4</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.1</font></TD><TD align="left" valign="center"><font size="1PT">Setter is annotated with @JsonbTransient. Exception is thrown if when the field or this setter are annotated with other JSON Binding annotations. Exception is not thrown if JSON Binding annotations are presented on the getter.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.2-1"></a><font size="1PT">JSONB:SPEC:JSB-4.1.2-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.2</font></TD><TD align="left" valign="center"><font size="1PT">To provide custom name for given field (or JavaBean property), +jakarta.json.bind.annotation.JsonbProperty may be used. JsonbProperty annotation may be specified on +field, getter or setter method. If specified on field, custom name is used both for serialization and +deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.2-2"></a><font size="1PT">JSONB:SPEC:JSB-4.1.2-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.2</font></TD><TD align="left" valign="center"><font size="1PT">If jakarta.json.bind.annotation.JsonbProperty is specified on getter method, it is used +only for serialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.2-3"></a><font size="1PT">JSONB:SPEC:JSB-4.1.2-3</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.2</font></TD><TD align="left" valign="center"><font size="1PT">If jakarta.json.bind.annotation.JsonbProperty is specified on setter method, it is used only for deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.2-4"></a><font size="1PT">JSONB:SPEC:JSB-4.1.2-4</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.2</font></TD><TD align="left" valign="center"><font size="1PT">It is possible to specify different values for getter and setter method for jakarta.json.bind.annotation.JsonbProperty annotation. In such case the different custom name will be used for serialization and deserialization.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.3-1"></a><font size="1PT">JSONB:SPEC:JSB-4.1.3-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.3</font></TD><TD align="left" valign="center"><font size="1PT">The way to set custom property naming strategy is to use jakarta.json.bin.JsonbConfig::withPropertyNamingStrategy method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.1.4-1"></a><font size="1PT">JSONB:SPEC:JSB-4.1.4-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.1.4</font></TD><TD align="left" valign="center"><font size="1PT">If duplicate name is found exception MUST be thrown. The definition of duplicate (non-unique) property +can be found in 3.19.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.2"></a><font size="1PT">JSONB:SPEC:JSB-4.2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.2</font></TD><TD align="left" valign="center"><font size="1PT">The way to set custom property order strategy is to use jakarta.json.bin.JsonbConfig::withPropertyOrderStrategy method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.2-2"></a><font size="1PT">JSONB:SPEC:JSB-4.2-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.2</font></TD><TD align="left" valign="center"><font size="1PT">To customize the order of serialized properties only for one specific type, JSON Binding provides jakarta.json.bind.annotation.JsonbPropertyOrder annotation. Order specified by JsonbPropertyOrder annotation overrides order specified by PropertyOrderStrategy.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.3-1"></a><font size="1PT">JSONB:SPEC:JSB-4.3-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.3</font></TD><TD align="left" valign="center"><font size="1PT">If annotations (JsonbNillable or JsonbProperty) on different level apply to the same field (or JavaBean property) or if there is config wide configuration and some annotation (JsonbNillable or JsonbProperty) which apply to the same field (or JavaBean property), the annotation with the smallest scope applies.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.3-2"></a><font size="1PT">JSONB:SPEC:JSB-4.3-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.3/font></TD><TD align="left" valign="center"><font size="1PT"> JsonbNillable and JsonbProperty are applied on the same level, JsonbNillable takes precedence.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.3.1-1"></a><font size="1PT">JSONB:SPEC:JSB-4.3.1-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.3.1</font></TD><TD align="left" valign="center"><font size="1PT">When given object (type or package) is annotated with jakarta.json.bind.annotation.JsonbNillable annotation, the result of null value will be presence of associated property in JSON document with explicit null value.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.3.1-2"></a><font size="1PT">JSONB:SPEC:JSB-4.3.1-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.3.1</font></TD><TD align="left" valign="center"><font size="1PT">The same behavior as JsonbNillable, but only at field, parameter and method (JavaBean property) level is provided by jakarta.json.bind.annotation.JsonbProperty annotation with its nillable parameter. This option is currently deprecated, and it is recommended to use +jakarta.json.bind.annotation.JsonbNillable instead.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.3.1-3"></a><font size="1PT">JSONB:SPEC:JSB-4.3.1-3</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.3.1</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST implement override of annotations according to target of the annotation (FIELD, PARAMETER, METHOD, TYPE, PACKAGE). Type level annotation overrides behavior set at the package level. Method, parameter or field level annotation overrides behavior set at the type level.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.3.2-1"></a><font size="1PT">JSONB:SPEC:JSB-4.3.2-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.3.2</font></TD><TD align="left" valign="center"><font size="1PT">The way to enforce serialization of null values, is to call method jakarta.json.bind.JsonbConfig::withNullValues with parameter true. The way to skip serialization of null values is to call method jakarta.json.bind.JsonbConfig::withNullValues with parameter false.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.4-1"></a><font size="1PT">JSONB:SPEC:JSB-4.4-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.4</font></TD><TD align="left" valign="center"><font size="1PT">To enforce strict compliance of serialized JSON documents, JSON Binding implementations MUST implement configuration option jsonb.i-json.strict-ser-compliance.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.4.1-1"></a><font size="1PT">JSONB:SPEC:JSB-4.4.1-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.4.1</font></TD><TD align="left" valign="center"><font size="1PT">Uppercase rather than lowercase letters MUST be used.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.4.1-2"></a><font size="1PT">JSONB:SPEC:JSB-4.4.1-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.4.1</font></TD><TD align="left" valign="center"><font size="1PT">The timezone MUST always be included and optional trailing seconds MUST be included even when their value is 00.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.4.1-3"></a><font size="1PT">JSONB:SPEC:JSB-4.4.1-3</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.4.1</font></TD><TD align="left" valign="center"><font size="1PT">JSON Binding implementations MUST serialize java.util.Date, java.util.Calendar, java.util.GregorianCalendar, java.time.LocalDate, java.time.LocalDateTime and java.time.Instant in the same format as java.time.ZonedDateTime.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.4.1-4"></a><font size="1PT">JSONB:SPEC:JSB-4.4.1-4</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.4.1</font></TD><TD align="left" valign="center"><font size="1PT">The result of serialization of duration must conform to the duration production in Appendix A of RFC 3339, with the same additional restrictions</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.5-1"></a><font size="1PT">JSONB:SPEC:JSB-4.5-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.5</font></TD><TD align="left" valign="center"><font size="1PT">At most one JsonbCreator annotation can be used to annotate custom constructor or static void factory method in a class, otherwise JsonbException MUST be thrown.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.5-2"></a><font size="1PT">JSONB:SPEC:JSB-4.5-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.5</font></TD><TD align="left" valign="center"><font size="1PT">Factory method annotated with JsonbCreator annotation should return instance of particular class this annotation is used for, otherwise JsonbException MUST be thrown.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.5-3"></a><font size="1PT">JSONB:SPEC:JSB-4.5-3</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.5</font></TD><TD align="left" valign="center"><font size="1PT">Mapping between parameters of constructor/factory method annotated with JsonbCreator and JSON fields is defined using JsonbProperty annotation on all parameters. +If the JsonbProperty annotation on parameters is not used, then parameters should be mapped from JSON fields with the same name. In this case the proper mapping is NOT guaranteed. +All the JsonbCreator parameters are treated as optional by default. See Optional parameter values chapter for default optional parameter values. +All the JsonbCreator parameters can be turned to required by using configuration method Config::withCreatorParametersRequired. +If a required field for a parameter mapping does not exist in the JSON document, then JsonbException MUST be thrown.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.5.1-1"></a><font size="1PT">JSONB:SPEC:JSB-4.5.1-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.5</font></TD><TD align="left" valign="center"><font size="1PT">When a property is marked as optional, the proper default should be used. If the parameter is any type other than Optional or its variations, then the null value is used. If the parameter is java.util.Optional, OptionalInt, OptionalLong, OptionalDouble, then the corresponding empty object must be used. +Primitive types cannot accept null values, so a corresponding value is required as listed in the following table:.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.6-1"></a><font size="1PT">JSONB:SPEC:JSB-4.6-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.5</font></TD><TD align="left" valign="center"><font size="1PT">To customize scope and field access strategy as specified in section 3.7.1, it is possible to specify jakarta.json.bind.annotation.JsonbVisibility annotation or to override default behavior globally calling JsonbConfig::withPropertyVisibilityStrategy method with given custom property visibility strategy.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.1-1"></a><font size="1PT">JSONB:SPEC:JSB-4.7.1-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.1</font></TD><TD align="left" valign="center"><font size="1PT">On serialization of Original type JSONB calls JsonbAdapter::adaptToJson method of the adapter to convert Original to Adapted and serializes Adapted the standard way. On deserialization JSONB deserializes Adapted from JSON and converts it to Original using JsonbAdapter::adaptFromJson method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.1-2"></a><font size="1PT">JSONB:SPEC:JSB-4.7.1-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.1</font></TD><TD align="left" valign="center"><font size="1PT">There are two ways how to register JsonbAdapter: Using JsonbConfig::withAdapters method & Annotating a class field with JsonbTypeAdapter annotation.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.1-3"></a><font size="1PT">JSONB:SPEC:JSB-4.7.1-3</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.1</font></TD><TD align="left" valign="center"><font size="1PT">Implementations must provide a CDI support in adapters to allow injection of CDI managed beans into it.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.1-4"></a><font size="1PT">JSONB:SPEC:JSB-4.7.1-4</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.1</font></TD><TD align="left" valign="center"><font size="1PT">JsonbAdapter registered via JsonbConfig::withAdapters is visible to all serialize/deserialize operations +performed with given JsonbConfig. JsonbAdapter registered with annotation is visible to serialize/deserialize operation used only for annotated field.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.1-5"></a><font size="1PT">JSONB:SPEC:JSB-4.7.1-5</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.1</font></TD><TD align="left" valign="center"><font size="1PT">It is possible to annotate JsonbCreator parameter with JsonbTypeAdapter and provide adapter for a parameter this way. However, if JsonbTypeAdapter annotation is provided to any other parameter (such as setter method parameter) it will be ignored.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.2-1"></a><font size="1PT">JSONB:SPEC:JSB-4.7.2-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.2</font></TD><TD align="left" valign="center"><font size="1PT">Serializer is a class implementing jakarta.json.bind.serializers.JsonbSerializer interface. It is used to serialize the type it's registered on (Original). On marshalling of Original type JSONB calls JsonbSerializer::serialize method. This method has to contain a custom code to serialize Original type using provided JsonpGenerator.Deserializer is a class implementing jakarta.json.bind.serializers.JsonbDeserializer interface. It is used to deserialize the type it’s registered on (Original). On deserialization of Original type JSONB calls JsonbDeserializer::deserialize method. This method has to contain a custom code to deserialize Original type using provided JsonpParser. There are two ways how to register JsonbSerializer/JsonbDeserializer:Using JsonbConfig::withSerializers/ JsonbConfig::withDeserializers method;</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.2-2"></a><font size="1PT">JSONB:SPEC:JSB-4.7.2-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.2</font></TD><TD align="left" valign="center"><font size="1PT">Annotating a type with JsonbSerializer/JsonbDeserializer annotation.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.2-3"></a><font size="1PT">JSONB:SPEC:JSB-4.7.2-3</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.2</font></TD><TD align="left" valign="center"><font size="1PT">Implementations must provide a CDI support in serializers/deserializers to allow injection of CDI managed beans into it.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.7.2-4"></a><font size="1PT">JSONB:SPEC:JSB-4.7.2-4</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.7.2</font></TD><TD align="left" valign="center"><font size="1PT">It is possible to annotate JsonbCreator parameter with JsonbTypeDeserializer and provide deserializer for a parameter this way. However, if JsonbTypeDeserializer annotation is provided to any other parameter (such as setter method parameter) it will be ignored.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> + +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.8-1"></a><font size="1PT">JSONB:SPEC:JSB-4.8-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.8</font></TD><TD align="left" valign="center"><font size="1PT">JsonbDateFormat annotation can be applied to the following targets: field, method, type, parameter, package</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.8-2"></a><font size="1PT">JSONB:SPEC:JSB-4.8-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.8</font></TD><TD align="left" valign="center"><font size="1PT">Annotation applied to more specific target overrides the same annotation applied to target with wider scope and global configuration. For example, annotation applied to type target will override the same annotation applied to package target.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.8-3"></a><font size="1PT">JSONB:SPEC:JSB-4.8-3</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.8</font></TD><TD align="left" valign="center"><font size="1PT">Default date format and default locale can be customized globally using jakarta.json.bind.JsonbConfig::withDateFormat and jakarta.json.bind.JsonbConfig::withLocale methods.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.9-1"></a><font size="1PT">JSONB:SPEC:JSB-4.9-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.9</font></TD><TD align="left" valign="center"><font size="1PT">JsonbNumberFormat annotation can be applied to the following targets: field, getter/setter, method, type, parameter, package</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.9-2"></a><font size="1PT">JSONB:SPEC:JSB-4.9-2</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.9</font></TD><TD align="left" valign="center"><font size="1PT">Annotation applied to more specific target overrides the same annotation applied to target with wider scope. For example, annotation applied to type target will override the same annotation applied to package target. </font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +<TR> +<TD align="center" valign="center"><a name="JSONB:SPEC:JSB-4.10-1"></a><font size="1PT">JSONB:SPEC:JSB-4.10-1</font></TD><TD align="center" valign="center"><font size="1PT">4</font></TD><TD align="center" valign="center"><font size="1PT">4.10</font></TD><TD align="left" valign="center"><font size="1PT">The way to set custom binary data handling strategy is to use jakarta.json.bin.JsonbConfig::withBinaryDataStrategy method.</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD><TD align="center" valign="center"><font size="1PT"><a></a> +<br> +</font></TD><TD align="center" valign="center"><font size="1PT">false</font></TD><TD align="center" valign="center"><font size="1PT">technology</font></TD><TD align="center" valign="center"><font size="1PT">active</font></TD><TD align="center" valign="center"><font size="1PT">true</font></TD> +</TR> +</TABLE> +</body> +</html>
diff --git a/tck-docs/index.html b/tck-docs/index.html new file mode 100644 index 0000000..263b362 --- /dev/null +++ b/tck-docs/index.html
@@ -0,0 +1,57 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> +<!-- + + Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<html> +<head> + +<title>Welcome to the JSON-B TCK, Version 3.0</title> +<style type="text/css"> +<!-- +pre { background-color: #eeeeee; color: #000099} +code { color: #000099} +h1 { color: #000099} +h2 { color: #000099} +h3 { color: #000099; text-decoration: underline} +h4 { font-style: italic; color: #000099} +.tabletitle { font-style: italic; color: #ffffcc; font-size: small; font-variant: small-caps} +.subtitle { font-style: italic; color: #ffffcc; font-variant: small-caps} +.emphasize { font-style: italic; color: #000099} +--> +</style> +</head> +<body bgcolor="#ffffdd" text="#000000" link="#0000FF" vlink="#840084" alink="#0000FF"> +<div align="center"> +<h1>Welcome to the JSON-B TCK, Version 3.0<br> +<span class="emphasize">Your Starting Point</span></h1> +</div> +<hr> +<h2>Guide to JSON-B TCK 3.0 Documentation</h2> + +<p>The JSON-B TCK 3.0 documentation includes the following:</p> + + <ul> + <li><p>The <cite><a href="JSONB3.0-ReleaseNotes.html">JSON-B Release Notes</a></cite> provide the information that you need to install, set up, and run the JSON-B TCK, Version 3.0. The Release Notes are located in the TCK product bundle.</p></li> + <li><p>The <cite>JSON-B 3.0 Technology Compatibility Kit User's Guide</cite> provides the information that you need to install, set up, and run the JSON-B TCK as well as the rules you must comply with for certification.</p></li> + <li><p>The <a href="assertions/JSONBJavadocAssertions.html">Javadoc Assertion List</a> lists all the javadoc assertions that are tested by the JSON-B TCK.</p></li> + <li><p>The <a href="assertions/JSONBSpecAssertions.html">Specification Assertion List</a> lists all the specification assertions that are tested by the JSON-B TCK.</p></li> + </ul> +<hr> +<p><cite><small><address>Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.</address></small><cite></p> +</body> +</html>
diff --git a/tck-docs/userguide/README.md b/tck-docs/userguide/README.md new file mode 100644 index 0000000..a3ec2b6 --- /dev/null +++ b/tck-docs/userguide/README.md
@@ -0,0 +1,77 @@ +# A JBake project template + +## About JBake + +JBake is a static site generator, it's inspired from jekyll and written +in java. The basic idea is to have templates for the structure of the +page, and the body generated from asciidoc content. + +## Pre requisites + +- Maven +- JDK8+ + +Deploying to Github will require password less authentication. + +This is done by exporting your SSH public key into your Github account. + +## Build the site locally + +The site is generated under target/staging. + +Open file:///PATH_TO_PROJECT_DIR/target/staging in a browser to view the site. + +``` +mvn generate-resources +``` + +Or you can invoke the JBake plugin directly. + +``` +mvn jbake:build +``` + +### Rebuild the site on changes + +``` +mvn jbake:watch +``` + +If you keep this command running, changes to the sources will be +detected and the site will be rendered incrementally. + +This is convenient when writing content. + +### Serve the site locally + +``` +mvn jbake:serve +``` + +If a webserver is required (e.g. absolute path are used), this command +will start a webserver (jetty) at http://localhost:8820. It will also +watch for changes and rebuild incrementally. + +## Deploy the site to Github Pages + +``` +mvn deploy +``` + +## Produce a zip file for download + +To produce a zip file containing the generated html files, use: + +``` +mvn package +``` + +When making a release on GitHub, this zip file should be added to the release. + +## Links + +- [JBake maven plugin documentation](https://github.com/Blazebit/jbake-maven-plugin) +- [JBake documentation](http://jbake.org/docs/2.5.1) +- [Freemarker documentation](http://freemarker.org/docs) +- [AsciiDoc User Guide](http://asciidoc.org/userguide.html) +- [Asciidoctor quick reference](http://asciidoctor.org/docs/asciidoc-syntax-quick-reference)
diff --git a/tck-docs/userguide/pom.xml b/tck-docs/userguide/pom.xml new file mode 100644 index 0000000..e32bd13 --- /dev/null +++ b/tck-docs/userguide/pom.xml
@@ -0,0 +1,276 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.eclipse.ee4j</groupId> + <artifactId>project</artifactId> + <version>1.0.9</version> + </parent> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck-ug</artifactId> + <packaging>pom</packaging> + <version>3.0.0-SNAPSHOT</version> + <name>Eclipse Foundation Technology Compatibility Kit User's Guide for Jakarta JSON Binding for Jakarta EE, Release 3.0</name> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <site.output.dir>${project.build.directory}/staging</site.output.dir> + <maven.site.skip>true</maven.site.skip> + <asciidoctorj.version>2.4.2</asciidoctorj.version> + <asciidoctorj.diagram.version>2.1.0</asciidoctorj.diagram.version> + <asciidoctorj.maven.plugin.version>2.1.0</asciidoctorj.maven.plugin.version> + <asciidoctorj.pdf.version>1.5.3</asciidoctorj.pdf.version> + <jbake.maven.plugin.version>0.3.3</jbake.maven.plugin.version> + <freemarker.version>2.3.30</freemarker.version> + <!-- status: DRAFT, BETA, etc., or blank for final --> + <status></status> + <doc.pdf>Jakarta-JSON-Binding-TCK-Users-Guide.pdf</doc.pdf> + <maven.deploy.skip>true</maven.deploy.skip> + </properties> + + <distributionManagement> + <site> + <url>scm:git:git@github.com:jakartaee/jsonb-api.git</url> + </site> + </distributionManagement> + + <build> + <defaultGoal>package</defaultGoal> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + <configuration> + <filesets> + <fileset> + <directory>src/main/jbake/content</directory> + <includes> + <include>toc.adoc</include> + </includes> + </fileset> + </filesets> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <executions> + <execution> + <id>enforce-versions</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <requireJavaVersion> + <version>[11,)</version> + <message>You need JDK11 or newer</message> + </requireJavaVersion> + </rules> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.glassfish.doc</groupId> + <artifactId>glassfish-doc-maven-plugin</artifactId> + <executions> + <execution> + <id>generate-toc</id> + <phase>generate-resources</phase> + <goals> + <goal>toc</goal> + </goals> + <configuration> + <chapterPatterns> + [A-C0-9]+\s.*,Preface.*,Part\s.* + </chapterPatterns> + </configuration> + </execution> + <execution> + <id>generate-book</id> + <phase>generate-resources</phase> + <goals> + <goal>book</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jbake</groupId> + <artifactId>jbake-maven-plugin</artifactId> + <configuration> + <outputDirectory>${site.output.dir}</outputDirectory> + <properties> + <status>${status}</status> + </properties> + </configuration> + <executions> + <execution> + <id>build-site</id> + <phase>generate-resources</phase> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctor-maven-plugin</artifactId> + <configuration> + <sourceDirectory>${project.build.directory}/book</sourceDirectory> + <sourceDocumentName>book.adoc</sourceDocumentName> + <!-- XXX - below depends on running jbake first --> + <imagesDir>${project.build.directory}/staging/</imagesDir> + <backend>pdf</backend> + <outputFile>${doc.pdf}</outputFile> + <attributes> + <pdf-stylesdir>${project.basedir}/src/theme</pdf-stylesdir> + <pdf-style>jakartaee</pdf-style> + <doctype>book</doctype> + <status>${status}</status> + <compat-mode /> + <data-uri /> + <icons>font</icons> + <pagenums /> + <toc /> + <icons>font</icons> + <sectanchors>true</sectanchors> + <idprefix /> + <idseparator>-</idseparator> + <docinfo1>true</docinfo1> + <embedAssets>true</embedAssets> + </attributes> + </configuration> + <executions> + <execution> + <id>generate-pdf-doc</id> + <phase>generate-resources</phase> + <goals> + <goal>process-asciidoc</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <executions> + <execution> + <id>distribution</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <descriptors> + <descriptor>src/main/assembly/assembly.xml</descriptor> + </descriptors> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-scm-publish-plugin</artifactId> + <executions> + <execution> + <id>deploy-site</id> + <phase>deploy</phase> + <goals> + <goal>publish-scm</goal> + </goals> + <configuration> + <scmBranch>gh-pages</scmBranch> + <skipDeletedFiles>false</skipDeletedFiles> + <checkinComment>Update site</checkinComment> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-clean-plugin</artifactId> + <version>3.1.0</version> + </plugin> + <plugin> + <groupId>org.glassfish.doc</groupId> + <artifactId>glassfish-doc-maven-plugin</artifactId> + <version>1.3</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <version>3.0.0-M3</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>3.3.0</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-scm-publish-plugin</artifactId> + <version>3.1.0</version> + </plugin> + <plugin> + <groupId>org.jbake</groupId> + <artifactId>jbake-maven-plugin</artifactId> + <version>${jbake.maven.plugin.version}</version> + <dependencies> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj</artifactId> + <version>${asciidoctorj.version}</version> + </dependency> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj-diagram</artifactId> + <version>${asciidoctorj.diagram.version}</version> + </dependency> + <dependency> + <groupId>org.freemarker</groupId> + <artifactId>freemarker</artifactId> + <version>${freemarker.version}</version> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctor-maven-plugin</artifactId> + <version>${asciidoctorj.maven.plugin.version}</version> + <dependencies> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj-pdf</artifactId> + <version>${asciidoctorj.pdf.version}</version> + </dependency> + </dependencies> + </plugin> + </plugins> + </pluginManagement> + </build> +</project>
diff --git a/tck-docs/userguide/src/main/assembly/assembly.xml b/tck-docs/userguide/src/main/assembly/assembly.xml new file mode 100644 index 0000000..c057b81 --- /dev/null +++ b/tck-docs/userguide/src/main/assembly/assembly.xml
@@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd"> + <id>userguides</id> + <includeBaseDirectory>false</includeBaseDirectory> + <formats> + <format>zip</format> + </formats> + + <fileSets> + <fileSet> + <directory>${project.build.directory}/generated-docs</directory> + <outputDirectory>docs/pdf-usersguide</outputDirectory> + <includes> + <include>**/*.pdf</include> + </includes> + </fileSet> + <fileSet> + <directory>${project.build.directory}/staging</directory> + <outputDirectory>docs/html-usersguide</outputDirectory> + <excludes> + <exclude>*.inc</exclude> + <exclude>*.conf</exclude> + <exclude>*.yml</exclude> + <exclude>*.md</exclude> + <exclude>README</exclude> + </excludes> + </fileSet> + <fileSet> + <directory>../assertions</directory> + <outputDirectory>docs/assertions</outputDirectory> + <includes> + <include>*Assertions.html</include> + </includes> + </fileSet> + <fileSet> + <directory>../</directory> + <outputDirectory>docs/</outputDirectory> + <includes> + <include>*.*</include> + </includes> + </fileSet> + </fileSets> +</assembly>
diff --git a/tck-docs/userguide/src/main/jbake/assets/README.md b/tck-docs/userguide/src/main/jbake/assets/README.md new file mode 100644 index 0000000..f8f962c --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/assets/README.md
@@ -0,0 +1,4 @@ +# About + +The {{site.title}} project contains the [AsciiDoc](http://asciidoc.org/) +source code for the ...
diff --git a/tck-docs/userguide/src/main/jbake/assets/_config.yml b/tck-docs/userguide/src/main/jbake/assets/_config.yml new file mode 100644 index 0000000..0d96e16 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/assets/_config.yml
@@ -0,0 +1,14 @@ +remote_theme: jakartaee/jekyll-theme-jakarta-ee + +title: [tck_jsonb_v1_0] +description: [Oracle Technology Compatibility Kit User's Guide for Java API for JSON Binding 3.0 for Technology Licensees, Release 3.0] + +# sidebar links url +links: + source: https://github.com/javaee/tck_jsonb_v1_0 + download: https://github.com/javaee/tck_jsonb_v1_0/releases + #mailinglist: https://javaee.groups.io/g/tck_jsonb_v1_0 + #javadocs: + docs: https://javaee.github.io/tck_jsonb_v1_0 + #faq: +
diff --git a/tck-docs/userguide/src/main/jbake/assets/css/style.css b/tck-docs/userguide/src/main/jbake/assets/css/style.css new file mode 100644 index 0000000..182f755 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/assets/css/style.css
@@ -0,0 +1,313 @@ +/* CSS */ +/*! normalize.css v3.0.2 | MIT License | git.io/normalize */ +/** 1. Set default font family to sans-serif. 2. Prevent iOS text size adjust after orientation change, without disabling user zoom. */ +html { font-family: sans-serif; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ } + +/* HTML5 display definitions ========================================================================== */ +/** Correct `block` display not defined for any HTML5 element in IE 8/9. Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox. Correct `block` display not defined for `main` in IE 11. */ +article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary { display: block; } + +/** 1. Correct `inline-block` display not defined in IE 8/9. 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. */ +audio, canvas, progress, video { display: inline-block; /* 1 */ vertical-align: baseline; /* 2 */ } + +/** Prevent modern browsers from displaying `audio` without controls. Remove excess height in iOS 5 devices. */ +audio:not([controls]) { display: none; height: 0; } + +/** Address `[hidden]` styling not present in IE 8/9/10. Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. */ +[hidden], template { display: none; } + +/* Links ========================================================================== */ +/** Remove the gray background color from active links in IE 10. */ +a { background-color: transparent; } + +/** Improve readability when focused and also mouse hovered in all browsers. */ +a:active, a:hover { outline: 0; } + +/* Text-level semantics ========================================================================== */ +/** Address styling not present in IE 8/9/10/11, Safari, and Chrome. */ +abbr[title] { border-bottom: 1px dotted; } + +/** Address style set to `bolder` in Firefox 4+, Safari, and Chrome. */ +b, strong { font-weight: bold; } + +/** Address styling not present in Safari and Chrome. */ +dfn { font-style: italic; } + +/** Address variable `h1` font-size and margin within `section` and `article` contexts in Firefox 4+, Safari, and Chrome. */ +h1 { font-size: 2em; margin: 0.67em 0; } + +/** Address styling not present in IE 8/9. */ +mark { background: #ff0; color: #000; } + +/** Address inconsistent and variable font size in all browsers. */ +small { font-size: 80%; } + +/** Prevent `sub` and `sup` affecting `line-height` in all browsers. */ +sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } + +sup { top: -0.5em; } + +sub { bottom: -0.25em; } + +/* Embedded content ========================================================================== */ +/** Remove border when inside `a` element in IE 8/9/10. */ +img { border: 0; } + +/** Correct overflow not hidden in IE 9/10/11. */ +svg:not(:root) { overflow: hidden; } + +/* Grouping content ========================================================================== */ +/** Address margin not present in IE 8/9 and Safari. */ +figure { margin: 1em 40px; } + +/** Address differences between Firefox and other browsers. */ +hr { box-sizing: content-box; height: 0; } + +/** Contain overflow in all browsers. */ +pre { overflow: auto; } + +/** Address odd `em`-unit font size rendering in all browsers. */ +code, kbd, pre, samp { font-family: monospace, monospace; font-size: 1em; } + +/* Forms ========================================================================== */ +/** Known limitation: by default, Chrome and Safari on OS X allow very limited styling of `select`, unless a `border` property is set. */ +/** 1. Correct color not being inherited. Known issue: affects color of disabled elements. 2. Correct font properties not being inherited. 3. Address margins set differently in Firefox 4+, Safari, and Chrome. */ +button, input, optgroup, select, textarea { color: inherit; /* 1 */ font: inherit; /* 2 */ margin: 0; /* 3 */ } + +/** Address `overflow` set to `hidden` in IE 8/9/10/11. */ +button { overflow: visible; } + +/** Address inconsistent `text-transform` inheritance for `button` and `select`. All other form control elements do not inherit `text-transform` values. Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. Correct `select` style inheritance in Firefox. */ +button, select { text-transform: none; } + +/** 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` and `video` controls. 2. Correct inability to style clickable `input` types in iOS. 3. Improve usability and consistency of cursor style between image-type `input` and others. */ +button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; /* 2 */ cursor: pointer; /* 3 */ } + +/** Re-set default cursor for disabled elements. */ +button[disabled], html input[disabled] { cursor: default; } + +/** Remove inner padding and border in Firefox 4+. */ +button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } + +/** Address Firefox 4+ setting `line-height` on `input` using `!important` in the UA stylesheet. */ +input { line-height: normal; } + +/** It's recommended that you don't attempt to style these elements. Firefox's implementation doesn't respect box-sizing, padding, or width. 1. Address box sizing set to `content-box` in IE 8/9/10. 2. Remove excess padding in IE 8/9/10. */ +input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ } + +/** Fix the cursor style for Chrome's increment/decrement buttons. For certain `font-size` values of the `input`, it causes the cursor style of the decrement button to change from `default` to `text`. */ +input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; } + +/** 1. Address `appearance` set to `searchfield` in Safari and Chrome. 2. Address `box-sizing` set to `border-box` in Safari and Chrome (include `-moz` to future-proof). */ +input[type="search"] { -webkit-appearance: textfield; /* 1 */ /* 2 */ box-sizing: content-box; } + +/** Remove inner padding and search cancel button in Safari and Chrome on OS X. Safari (but not Chrome) clips the cancel button when the search input has padding (and `textfield` appearance). */ +input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; } + +/** Define consistent border, margin, and padding. */ +fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; } + +/** 1. Correct `color` not being inherited in IE 8/9/10/11. 2. Remove padding so people aren't caught out if they zero out fieldsets. */ +legend { border: 0; /* 1 */ padding: 0; /* 2 */ } + +/** Remove default vertical scrollbar in IE 8/9/10/11. */ +textarea { overflow: auto; } + +/** Don't inherit the `font-weight` (applied by a rule above). NOTE: the default cannot safely be changed in Chrome and Safari on OS X. */ +optgroup { font-weight: bold; } + +/* Tables ========================================================================== */ +/** Remove most spacing between table cells. */ +table { border-collapse: collapse; border-spacing: 0; } + +td, th { padding: 0; } + +/* LAYOUT STYLES */ + +p { margin-top: 0; } + +code, pre { margin-bottom: 30px; font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; font-size: 13px; color: #222; } + +code { padding: 0 3px; background-color: #f2f8fc; border: solid 1px #dbe7f3; } + +pre { padding: 20px; overflow: auto; text-shadow: none; background: #fff; border: solid 1px #f2f2f2; } + +pre code { padding: 0; color: #2879d0; background-color: #fff; border: none; } + +ul, ol, dl { margin-bottom: 20px; } + +/* COMMON STYLES */ + +td.halign-right { text-align: right; } + +td.halign-center { text-align: center; } + +form { padding: 20px; background: #f2f2f2; } + +h2 { + font-size: 2em; + line-height: 1.2em; + font-weight: 200; + letter-spacing: 0; +} + +h3 { + font-size: 1.4em; + line-height: 1.2em; + font-weight: normal; + letter-spacing: 0; +} + +.sect1 { + margin-left: 4%; + margin-right: 4%; + font: 13px/20px Arial, Helvetica, sans-serif +} + +a:link { + text-decoration: none; + color: #09569d; +} + +#preamble hr{ + margin-left: 0%; + margin-right: 0%; +} + +#preamble .sectionbody table { + font-weight: 200; + margin-left: 4%; + margin-right: 4%; +} + +hr { + margin-bottom: 12px; +} + +table.tableblock.frame-all.grid-all.spread { + font-size: 12px; +} + +code { + font-size:.9em; + border: 1px solid #eaeaea; + background-color: #f6f6f6; + border-radius: 3px; + padding: 1px; + padding-left:2px; + padding-right:2px; +} + +pre.prettyprint.highlight { + border: 1px solid #eaeaea; + background-color: #f6f6f6; + border-radius: 4px; + padding: 8px; + padding-top:4px; + padding-bottom:4px; +} + +.language-oac_no_warn { + font-size:.9em; + color:#222; + background-color: transparent; +} + +#doc-title { + margin-left: 4%; +} + +#top-nav { + margin-left: 4%; + font-size: 12px; +} + +#bottom-nav { + margin-left: 4%; + font-size: 12px; +} + +.vector-font { + color:grey; + font-size: 20px; +} + +#copyright { + padding-top: 10px; + padding-bottom: 4px; + display: table; + margin:0 auto; + color: grey; + font-size: 12px; + vertical-align: middle; +} + +.beta {color: #FF0000} + +/* GENERAL ELEMENT TYPE STYLES */ + +/* #Media Queries +================================================== */ +/* Smaller than standard 960 (devices and browsers) */ +/* Tablet Portrait size to standard 960 (devices and browsers) */ +@media only screen and (min-width: 768px) and (max-width: 959px) { .inner { width: 740px; } + header h1, header h2 { width: 340px; } + header h1 { font-size: 60px; } + header h2 { font-size: 30px; } +} +/* All Mobile Sizes (devices and browser) */ +@media only screen and (max-width: 767px) { .inner { width: 93%; } + header { padding: 20px 0; } + header .inner { position: relative; } + header h1, header h2 { width: 100%; } + header h1 { font-size: 48px; } + header h2 { font-size: 24px; } + header a.button { position: relative; display: inline-block; width: auto; height: auto; padding: 5px 10px; margin-top: 15px; font-size: 13px; line-height: 1; color: #2879d0; text-align: center; background-color: #9ddcff; background-image: none; border-radius: 5px; -moz-border-radius: 5px; -webkit-border-radius: 5px; } + header a.button small { display: inline; font-size: 13px; } +} +/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */ +/* Mobile Portrait Size to Mobile Landscape Size (devices and browsers) */ + +header h1 { padding-top: 14px; font-size: 2em; font-weight: 200; line-height: 1.4; color: #FFFFFF; letter-spacing: 0px; border-bottom: 0px; } + +header h2 { font-size: 1.2em; margin-top: 0; margin-bottom: 0; font-weight: 200; line-height: .8; color: #ec7D11; letter-spacing: 0; } + +//header a.button { background: transparent url(../images/logo.png) 0 0 no-repeat; padding-left: 32px; } + +header a:hover { text-decoration: none; } + +/* Admonition (Note) block */ +.admonitionblock > table { + border: 0; + background: none; + width: 100%; + table-layout: auto; + margin-bottom: 10.5px; +} +.admonitionblock > table td.icon { + text-align: center; + width: 60px; +} +.admonitionblock > table td.icon img { + max-width: none; +} +.admonitionblock > table td.icon .title { + text-transform: uppercase; +} +.admonitionblock > table td.content { + padding-left: 1em; + padding-right: 1em; + border-left: 3px solid #ddd; +} +.admonitionblock > table td.content > :last-child > :last-child { + margin-bottom: 0; +} +.admonitionblock td.icon [class^="fa icon-"]:before { + font-size: 2.5em; + text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5); + cursor: default; +} +.admonitionblock td.icon .icon-note:before { + content: "\f05a"; + color: #5bc0de; +}
diff --git a/tck-docs/userguide/src/main/jbake/assets/img/eclipse_foundation_logo_tiny.png b/tck-docs/userguide/src/main/jbake/assets/img/eclipse_foundation_logo_tiny.png new file mode 100644 index 0000000..ee830ae --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/assets/img/eclipse_foundation_logo_tiny.png Binary files differ
diff --git a/tck-docs/userguide/src/main/jbake/content/README b/tck-docs/userguide/src/main/jbake/content/README new file mode 100644 index 0000000..05fa2c2 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/README
@@ -0,0 +1,77 @@ +The file attributes.conf defines several attributes (variables) that +need to be customized for each technology. + +The *.adoc files should not be modified. + +The following "include" files should be customized as necessary +for the specific technology: + +- rules.inc + + Additional compatibility rules needed by some technologies. + The rules in rules.adoc should NOT be changed. + +- defns.inc + + Additional definitions needed by additional compatibility + rules in rules.inc. + +- config.inc + + Detailed instructions for configuring the TCK, included in + Chapter 4. Unfortunately, these are sections 4.1 - 4.3, + so even if the TCK doesn't require 3 sections you need to + make up something, or else change the sections to "N/A". + +- packages.inc + + A simple list of Jakarta EE package names for the technology. + +- tck-packages.inc + + A list of additional software packages included in the TCK. + +- req-software.inc + + A list of software required in addition to the TCK and CI. + +- install-server.inc + + Steps to install the Jakarta EE CI, if needed. + For standalone technologies, no server may be required, + and this file can be empty. + This is used in install.adoc in section 3.2. + +- install-server-vi.inc + + Steps to install a Vendor's web server, if needed. + For standalone technologies, no web server may be required, + and this file can be empty. + This is used in install.adoc in section 3.2. + +- using-examples.inc + + Command line examples showing how to run the TCK. + +- using.inc + + Optional additional instructions for running the TCK. + +- debug-tips.inc + + Technology-specific troubleshooting tips for Chapter 6. + If this isn't needed, it can be an empty file, but toc.adoc + will need to be fixed. + +- rebuild.inc + + Special instructions for rebuilding the WAR files used by some TCKs. + If needed, customize it appropriately and define the "rebuild" + attribute in attributes.conf. + +- title.inc + Add acronym references as required do distinguish between legacy and + current APIs. + +Note that this template is NOT sufficient for the Jakarta EE platform +or Jakarta EE Web Profile.
diff --git a/tck-docs/userguide/src/main/jbake/content/attributes.conf b/tck-docs/userguide/src/main/jbake/content/attributes.conf new file mode 100644 index 0000000..9463c2c --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/attributes.conf
@@ -0,0 +1,38 @@ +:TechnologyFullName: Jakarta JSON Binding +:TechnologyShortName: JSON Binding +:LegacyAcronym: JSONB +:ReleaseDate: March 2022 +:CopyrightDates: 2017, 2022 +:TechnologyVersion: 3.0 +:TechnologyRI: Eclipse Yasson 3.0 +:TechnologyRIURL: https://projects.eclipse.org/projects/ee4j.yasson +:SpecificationURL: https://jakarta.ee/specifications/jsonb/3.0/ +:TCKInquiryList: mailto:jsonb-dev@eclipse.org[jsonb-dev@eclipse.org] +:SpecificationInquiryList: mailto:jsonb-dev@eclipse.org[jsonb-dev@eclipse.org] +:techID: JSONB +// Define this attribute (uncomment it) if the TCK includes no API tests. (Rare.) +// :no-api-tests: +// Define this attribute (uncomment it) if the TCK includes end-to-end tests. +// :end-to-end-tests: +// Define this attribute (uncomment it) if subsets of the API are allowed. +// (Common Annotations only) +// :subset-allowed: +// +// The environment variable used to specify the home directory +// for the technology. Used in config.inc. +:TechnologyHomeEnv: JSONB_HOME +// Java SE version required. +:SEversion: 11+ +:MavenVersion: 3.6.3+ +:JunitVersion: 5.7.2+ +:JakartaEEVersion: 10 +:excludeListFileName: TCK-Exclude-List.txt +:TCKPackageName: jakarta-jsonb-tck-3.0.0.zip +// Directory names used in examples in using.adoc. +:sigTestDirectoryExample: ee.jakarta.tck.json.bind.signaturetest.jsonb +:singleTestDirectoryExample: ee.jakarta.tck.json.bind.api.annotation +:subsetTestDirectoryExample: ee.jakarta.tck.json.bind.api +:singleTestExample: ee.jakarta.tck.json.bind.api.jsonb.JsonbTest +:sigTestExample: ee.jakarta.tck.json.bind.signaturetest.jsonb.JSONBSigTest +// Define this attribute (uncomment it) if the TCK needs the rebuild appendix. +// :rebuild:
diff --git a/tck-docs/userguide/src/main/jbake/content/config.adoc b/tck-docs/userguide/src/main/jbake/content/config.adoc new file mode 100644 index 0000000..c0d9b89 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/config.adoc
@@ -0,0 +1,48 @@ +type=page +status=published +title=Setup and Configuration +next=using.html +prev=install.html +~~~~~~ +include::attributes.conf[] +Setup and Configuration +======================= + +[[GBFVV]] + + + +[[setup-and-configuration]] +4 Setup and Configuration +------------------------- + + +[NOTE] +==== +The Jakarta EE Specification process provides for any number of compatible implementations. +As additional implementations become available, refer to project or product documentation from +those vendors for specific TCK setup and operational guidance. + +==== + +This chapter describes how to set up the {TechnologyShortName} TCK. +Before proceeding with the instructions in +this chapter, be sure to install all required software, as described in +link:install.html#GBFTP[Chapter 3, "Installation."] + +After completing the instructions in this chapter, proceed to +link:using.html#GBFWO[Chapter 5, "Executing Tests,"] for instructions on +running the {TechnologyShortName} TCK. + +[NOTE] +==== +The {TechnologyShortName} TCK is not depended on any particular build +tool to run the tests. It will be convenient and advisable to create a +Apache Maven project to setup and run the TCK. +This chapter will henceforth use instructions and steps to provide setup +with Apache Maven as a build tool. +==== + +include::config.inc[] + +
diff --git a/tck-docs/userguide/src/main/jbake/content/config.inc b/tck-docs/userguide/src/main/jbake/content/config.inc new file mode 100644 index 0000000..7bc6c9a --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/config.inc
@@ -0,0 +1,195 @@ +/////////////////////////////////////////////////////////////////////// +NOTE TO WRITERS: +The following sections should be customized for the technology. +This text was originally from the JAX-RS TCK. Most references +to JAX-RS have been parameterized to serve as a simple starting +point for customization. There are still many details that will +need to be changed or removed. The major sections 4.1, 4.2, and +4.3 should be preserved. If their titles are changed, the links +at the top of config.adoc will need to be changed as well as well +as toc.adoc. +/////////////////////////////////////////////////////////////////////// + +[[GBFVU]][[configuring-your-environment-to-run-the-tck-against-the-reference-implementation]] + +4.1 Configuring Your Environment to Run the TCK Against the Reference Implementation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After configuring your environment as described in this section, +continue with the instructions in link:using.html#GBFWO[Chapter 5, "Executing Tests."] + + +[NOTE] +======================================================================= + +In these instructions, variables in angle brackets need to be expanded +for each platform. For example, `<JAVA_HOME>` becomes `$JAVA_HOME` on +Solaris/Linux and `%JAVA_HOME%` on Windows. In addition, the forward +slashes (`/`) used in all of the examples need to be replaced with +backslashes (`\`) for Windows. Finally, be sure to use the appropriate +separator for your operating system when specifying multiple path +entries (`;` on Windows, `:` on UNIX/Linux). + +On Windows, you must escape any backslashes with an extra backslash in +path separators used in any of the following properties, or use forward +slashes as a path separator instead. + +======================================================================= + +1. Set the following environment variables in your shell environment: + a. `JAVA_HOME` to the directory in which Java SE {SEversion} is installed + b. `M2_HOME` to the directory in which the Apache Maven build tool is installed. + c. +{TechnologyHomeEnv}+ to the directory in which the {TechnologyShortName} + {TechnologyVersion} CI has been installed + d. `PATH` to include the following directories: `JAVA_HOME/bin`, + and `M2_HOME/bin` + +2. Set below Maven/System properties + a. `jimage.dir` This property specifies the directory where Java 11+ modules will be expanded by the + jimage tool for use in sigTestClasspath + b. `sigTestClasspath` This property must be set when running signature tests. + This property should be set to a list of jar files and/or directories which contain your + Jakarta EE and Java SE classes. Paths must be separated by the appropriate path separator (';' windows, ':' Unixes). + c. `jsonb-impl.groupId` property is set to the Maven Group Id of the CI to test. + d. `jsonb-impl.artifactId` property is set to the Maven Artifact Id of the CI to test. + e. `jsonb-impl.version` property is set to the Maven Version of the CI to test. + +3. Set the below jars to the classpath + a. JAR file for the {TechnologyShortName} {TechnologyVersion} CI. + + `jakarta.json.bind-api.jar`. + b. JUnit 5 jars ({JunitVersion}) + c. {TechnologyShortName} TCK tests (`jakarta.json.bind:jakarta.json.bind-tck`) + ++ +.Example: Maven configuration +[source,oac_no_warn,xml] +---- + <dependencies> + <dependency> + <groupId>CI.group.id</groupId> + <artifactId>CI.artifact.id</artifactId> + <version>CI.version</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-api</artifactId> + <version>3.0.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>jakarta.json</groupId> + <artifactId>jakarta.json-api</artifactId> + <version>2.1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.weld.se</groupId> + <artifactId>weld-se-core</artifactId> + <version>5.0.0.Beta1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck</artifactId> + <scope>test</scope> + </dependency> + </dependencies> +---- ++ + +[[GCLHU]][[configuring-your-environment-run-the-tck-against-the-vendor-implementation]] + +4.2 Configuring Your Environment to Run the TCK Against the Vendor Implementation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After configuring your environment as described in this section, +continue with the instructions in link:using.html#GBFWO[Chapter 5, "Executing Tests."] + + +[NOTE] +======================================================================= + +In these instructions, variables in angle brackets need to be expanded +for each platform. For example, `<JAVA_HOME>` becomes `$JAVA_HOME` on +Solaris/Linux and `%JAVA_HOME%` on Windows. In addition, the forward +slashes (`/`) used in all of the examples need to be replaced with +backslashes (`\`) for Windows. Finally, be sure to use the appropriate +separator for your operating system when specifying multiple path +entries (`;` on Windows, `:` on UNIX/Linux). + +On Windows, you must escape any backslashes with an extra backslash in +path separators used in any of the following properties, or use forward +slashes as a path separator instead. + +======================================================================= + + +1. Set the following environment variables in your shell environment: + a. `JAVA_HOME` to the directory in which Java SE {SEversion} is installed + b. `M2_HOME` to the directory in which the Apache Maven build tool is installed. + c. +{TechnologyHomeEnv}+ to the directory in which the {TechnologyShortName} + {TechnologyVersion} CI has been installed + d. `PATH` to include the following directories: `JAVA_HOME/bin`, + and `M2_HOME/bin` + +2. Set below Maven/System properties + a. `jimage.dir` This property specifies the directory where Java 11+ modules will be expanded by the + jimage tool for use in sigTestClasspath + b. `sigTestClasspath` This property must be set when running signature tests. + This property should be set to a list of jar files and/or directories which contain your + Java EE and Java SE classes. Paths must be separated by the appropriate path separator (';' windows, ':' Unixes). + c. `jsonb-api.groupId` property is set to the Maven Group Id of the VI to test. + d. `jsonb-api.artifactId` property is set to the Maven Artifact Id of the VI to test. + e. `jsonb-api.version` property is set to the Maven Version of the VI to test. + +3. Set the below jars to the classpath + a. JAR file for the {TechnologyShortName} {TechnologyVersion} VI. + + `yasson.jar`. + b. JUnit 5 jars ({JunitVersion}) + c. {TechnologyShortName} TCK tests (`jakarta.json.bind:jakarta.json.bind-tck`) + ++ +.Example: Maven configuration +[source,oac_no_warn,xml] +---- + <dependencies> + <dependency> + <groupId>VI.grou.id</groupId> + <artifactId>VI.artefact.id</artifactId> + <version>VI.version</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.eclipse</groupId> + <artifactId>yasson</artifactId> + <version>3.0.0-R1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>jakarta.json</groupId> + <artifactId>jakarta.json-api</artifactId> + <version>2.1.0</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.jboss.weld.se</groupId> + <artifactId>weld-se-core</artifactId> + <version>5.0.0.Beta1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck</artifactId> + <scope>test</scope> + </dependency> + </dependencies> +---- ++ + +[[GHGDG]][[publishing-the-test-applications]] + +4.3 Publishing the Test Applications +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Not needed for the {TechnologyShortName} TCK.
diff --git a/tck-docs/userguide/src/main/jbake/content/debug-tips.inc b/tck-docs/userguide/src/main/jbake/content/debug-tips.inc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/debug-tips.inc
diff --git a/tck-docs/userguide/src/main/jbake/content/debug.adoc b/tck-docs/userguide/src/main/jbake/content/debug.adoc new file mode 100644 index 0000000..cc6043f --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/debug.adoc
@@ -0,0 +1,66 @@ +type=page +status=published +title=Debugging Test Problems +next=faq.html +prev=using.html +~~~~~~ +include::attributes.conf[] +Debugging Test Problems +======================= + +[[GBFUV]] + + +[[debugging-test-problems]] +6 Debugging Test Problems +------------------------- + +There are a number of reasons that tests can fail to execute properly. +This chapter provides some approaches for dealing with these failures. +Please note that most of these suggestions are only relevant when +running the test harness in GUI mode. + +This chapter includes the following topics: + +* link:#GBFYP[Overview] +* link:#GBFYF[Configuration Failures] + +[[GBFYP]][[overview]] + +6.1 Overview +~~~~~~~~~~~~ + +The goal of a test run is for all tests in the test suite that are not +filtered out to have passing results. If the root test suite folder +contains tests with errors or failing results, you must troubleshoot and +correct the cause to satisfactorily complete the test run. + +* Errors: Tests with errors could not be executed by the Junit +framework. These errors usually occur because the test environment is not +properly configured. +* Failures: Tests that fail were executed but had failing results. + + +For every test run, the Junit framework creates a set of report files +in the target directory. + + +If a large number of tests failed, you should read +link:#GBFYF[Configuration Failures] to see if a +configuration issue is the cause of the failures. + + +If a large number of tests failed, you should read +link:#GBFYF[Configuration Failures] to see if a +configuration issue is the cause of the failures. + +[[GBFYF]][[configuration-failures]] + +6.2 Configuration Failures +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Configuration failures are easily recognized because many tests fail the +same way. When all your tests begin to fail, you may want to stop the +run immediately and start viewing individual test output. + +include::debug-tips.inc[]
diff --git a/tck-docs/userguide/src/main/jbake/content/defns.inc b/tck-docs/userguide/src/main/jbake/content/defns.inc new file mode 100644 index 0000000..038db2d --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/defns.inc
@@ -0,0 +1,46 @@ +// NOTE TO WRITERS: +// Most technologies will only need the compatibility rules in rules.adoc. +// Some technologies will need additional definitions to go with additional +// rules. If they're needed, remove the comment characters below +// and update the definitions as appropriate. +// +// The first block below is additional definitions needed by +// Jakarta XML Web Services. +// +// The second block below is additional defintions needed by +// Jakarta Server Pages. +// +// NOTE: This set of examples is NOT complete, but should be. +// +// +// Jakarta XML Web Services +// +// |Development Kit |A software product that implements or incorporates a +// Compiler, a Schema Compiler, a Schema Generator, a Java-to-WSDL Tool, a +// WSDL-to-Java Tool, and/or an RMI Compiler. +// +// |Java-to-WSDL Output |Output of a Java-to-WSDL Tool that is required for +// Web service deployment and invocation. +// +// |Java-to-WSDL Tool |A software development tool that implements or +// incorporates a function that generates web service endpoint descriptions +// in WSDL and XML schema format from Source Code as specified by the +// Jakarta XML Web Services Specification. +// +// |WSDL-to-Java Output |Output of a WSDL-to-Java tool that is required for +// Web service deployment and invocation. +// +// |WSDL-to-Java Tool |A software development tool that implements or +// incorporates a function that generates web service interfaces for +// clients and endpoints from a WSDL description as specified by the +// Jakarta XML Web Services Specification. +// +// +// Jakarta Server Pages +// +// |Jakarta Server Page |A text-based document that uses Jakarta Server +// Pages technology. +// +// |Jakarta Server Page Implementation Class |A program constructed by +// transforming the Jakarta Server Page text into a Java language program +// using the transformation rules described in the Specifications.
diff --git a/tck-docs/userguide/src/main/jbake/content/faq.adoc b/tck-docs/userguide/src/main/jbake/content/faq.adoc new file mode 100644 index 0000000..621f90c --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/faq.adoc
@@ -0,0 +1,53 @@ +type=page +status=published +title=Appendix A: Frequently Asked Questions +next=rebuild.html +prev=debug.html +~~~~~~ +include::attributes.conf[] +Appendix A: Frequently Asked Questions +====================================== + +[[GBFYD]] + + +[[a-frequently-asked-questions]] +A Frequently Asked Questions +---------------------------- + +This appendix contains the following questions. + +* link:#GBFYQ[Where do I start to debug a test failure?] +* link:#GBFYR[How do I restart a crashed test run?] +* link:#GBFWU[What would cause tests be added to the exclude list?] + +[[GBFYQ]][[a.1-where-do-i-start-to-debug-a-test-failure]] + +A.1 Where do I start to debug a test failure? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +See link:debug.html#GBFUV[Chapter 6, "Debugging Test Problems,"] for more +information. + +[[GBFYR]][[a.2-how-do-i-restart-a-crashed-test-run]] + +A.2 How do I restart a crashed test run? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you need to restart a test run, you can figure out which test crashed +the test suite by looking at the logs. + +[[GBFWU]][[a.3-what-would-cause-tests-be-added-to-the-exclude-list]] + +A.3 What would cause tests be added to the exclude list? +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The exclude file (+{excludeListFileName}+) contains all tests that are not +required to be run. The following is a list of reasons for a test to be +included in the Exclude List: + +* An error in a Compatible Implementation that does not allow the test to +execute properly has been discovered. +* An error in the specification that was used as the basis of the test +has been discovered. +* An error in the test has been discovered.
diff --git a/tck-docs/userguide/src/main/jbake/content/install-server-vi.inc b/tck-docs/userguide/src/main/jbake/content/install-server-vi.inc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/install-server-vi.inc
diff --git a/tck-docs/userguide/src/main/jbake/content/install-server.inc b/tck-docs/userguide/src/main/jbake/content/install-server.inc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/install-server.inc
diff --git a/tck-docs/userguide/src/main/jbake/content/install.adoc b/tck-docs/userguide/src/main/jbake/content/install.adoc new file mode 100644 index 0000000..50d72e5 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/install.adoc
@@ -0,0 +1,91 @@ +type=page +status=published +title=Installation +next=config.html +prev=rules.html +~~~~~~ +include::attributes.conf[] +Installation +============ + +[[GBFTP]] + + +[[installation]] +3 Installation +-------------- + +This chapter explains how to install the {TechnologyFullName} TCK software. + +After installing the software according to the instructions in this +chapter, proceed to link:config.html#GBFVV[Chapter 4, "Setup and +Configuration,"] for instructions on configuring your test environment. + +[NOTE] +======================================================================= + +Although the {TechnologyShortName} {TechnologyVersion} TCK is not +depended on any particular build tool, it is convenient to install +Apache Maven {MavenVersion} for setup and execution of tests. +Any other build tools like Gradle and JUnit 4 Console Runner can also +be used that is Jupiter API compatible. + +======================================================================= + +[[GBFUD]][[obtaining-the-reference-implementation]] + +3.1 Obtaining a Compatible Implementation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Each compatible implementation (CI) will provide instructions for obtaining +their implementation. +{TechnologyRI} is a compatible implementation which may be obtained +from {TechnologyRIURL} + +[[GBFTS]][[installing-the-software]] + +3.2 Installing the Software +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Before you can run the {TechnologyShortName} TCK tests, you must +install and set up the following software components: + +include::req-software.inc[] +* Java SE {SEversion} +* A CI for {TechnologyShortName} {TechnologyVersion}, one example is {TechnologyRI} +* The {TechnologyShortName} {TechnologyVersion} Vendor Implementation (VI) +* Any Jupiter API compatible test runner (eg. Apache Maven {MavenVersion}) + +Follow these steps: + +. Install the Java SE {SEversion} software, if it is not already installed. + +Download and install the Java SE {SEversion} software from +http://www.oracle.com/technetwork/java/javase/downloads/index.html. +Refer to the installation instructions that accompany the software for +additional information. + +. Install the build tool that will be used to run the TCK, if it is not already installed. + +It will be convenient to use Apache Maven {MavenVersion} for running the tests. The test kit +is not depended on Maven, any build tool compatible with Jupiter API is suffitient. + +. Install the {TechnologyShortName} TCK {TechnologyVersion} software. + a. Copy or download the {TechnologyShortName} TCK software to your + local system. + + You can obtain the {TechnologyShortName} TCK software from the + Jakarta EE site {SpecificationURL}. + b. Use the `unzip` command to extract the bundle in the directory of + your choice: + + +unzip {TCKPackageName}+ + + +include::install-server.inc[] +. Install a {TechnologyShortName} {TechnologyVersion} Compatible +Implementation. + +A Compatible Implementation is used to validate your initial +configuration and setup of the {TechnologyShortName} TCK +{TechnologyVersion} tests, which are explained further in +link:config.html#GBFVV[Chapter 4, "Setup and Configuration."] + +The Compatible Implementations for {TechnologyShortName} are listed on +the Jakarta EE Specifications web site: {SpecificationURL}. +include::install-server-vi.inc[] +. Install the {TechnologyShortName} VI to be tested. + +Follow the installation instructions for the particular VI under test.
diff --git a/tck-docs/userguide/src/main/jbake/content/intro.adoc b/tck-docs/userguide/src/main/jbake/content/intro.adoc new file mode 100644 index 0000000..4ad5f11 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/intro.adoc
@@ -0,0 +1,313 @@ +type=page +status=published +title=Introduction +next=rules.html +prev=preface.html +~~~~~~ +include::attributes.conf[] +Introduction +============ + +[[GBFOW]] + + +[[introduction]] +1 Introduction +-------------- + +This chapter provides an overview of the principles that apply +generally to all Technology Compatibility Kits (TCKs) and describes the +{TechnologyFullName} TCK ({TechnologyShortName} {TechnologyVersion} TCK). +It also includes a high level listing +of what is needed to get up and running with the {TechnologyShortName} +TCK. + +This chapter includes the following topics: + +* link:#GBFTK[Compatibility Testing] +* link:#GBFQR[About the TCK] +* link:#GBFQW[Getting Started With the TCK] + +[[GBFTK]][[compatibility-testing]] + +1.1 Compatibility Testing +~~~~~~~~~~~~~~~~~~~~~~~~~ + +Compatibility testing differs from traditional product testing in a +number of ways. The focus of compatibility testing is to test those +features and areas of an implementation that are likely to differ across +other implementations, such as those features that: + +* Rely on hardware or operating system-specific behavior +* Are difficult to port +* Mask or abstract hardware or operating system behavior + +Compatibility test development for a given feature relies on a complete +specification and compatible implementation (CI) for that feature. +Compatibility testing is not primarily concerned with robustness, +performance, nor ease of use. + +[[GBFQN]][[why-compatibility-testing-is-important]] + +1.1.1 Why Compatibility Testing is Important +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Jakarta platform compatibility is important to different groups involved +with Jakarta technologies for different reasons: + +* Compatibility testing ensures that the Jakarta platform does not become +fragmented as it is ported to different operating systems and hardware +environments. +* Compatibility testing benefits developers working in the Jakarta +programming language, allowing them to write applications once and then +to deploy them across heterogeneous computing environments without +porting. +* Compatibility testing allows application users to obtain applications +from disparate sources and deploy them with confidence. +* Conformance testing benefits Jakarta platform implementors by ensuring a +level playing field for all Jakarta platform ports. + +[[GBFPR]][[tck-compatibility-rules]] + +1.1.2 TCK Compatibility Rules +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Compatibility criteria for all technology implementations are embodied +in the TCK Compatibility Rules that apply to a specified technology. +Each TCK tests for adherence to these Rules as described in +link:rules.html#GBFSN[Chapter 2, "Procedure for Certification."] + +[[GBFPW]][[tck-overview]] + +1.1.3 TCK Overview +^^^^^^^^^^^^^^^^^^ + +A TCK is a set of tools and tests used to verify that a vendor's compatible +implementation of a Jakarta EE technology conforms to the applicable +specification. All tests in the TCK are based on the written +specifications for the Jakarta EE platform. A TCK tests compatibility of a +vendor's compatible implementation of the technology to the applicable +specification of the technology. Compatibility testing is a means of +ensuring correctness, completeness, and consistency across all +implementations developed by technology licensees. + +The set of tests included with each TCK is called the test suite. Most +tests in a TCK's test suite are self-checking, but some tests may +require tester interaction. Most tests return either a Pass or Fail +status. For a given platform to be certified, all of the required tests +must pass. The definition of required tests may change from platform to +platform. + +The definition of required tests will change over time. Before your +final certification test pass, be sure to download the latest version +of this TCK. + +[[GBFPB]][[java-community-process-jcp-program-and-compatibility-testing]] + +1.1.4 Jakarta EE Specification Process (JESP) Program and Compatibility Testing +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The Jakarta EE Specification Process (JESP) program is the formalization of the +open process that has been used since 2019 to develop and revise Jakarta EE +technology specifications in cooperation with the international Jakarta EE +community. The JESP program specifies that the following three major +components must be included as deliverables in a final Jakarta EE technology +release under the direction of the responsible Expert Group: + +* Technology Specification +* Compatible Implementation (CI) +* Technology Compatibility Kit (TCK) + +For further information about the JESP program, go to Jakarta EE Specification +Process community page https://jakarta.ee/specifications. + +[[GBFQR]][[about-the-tck]] + +1.2 About the TCK +~~~~~~~~~~~~~~~~~ + +The {TechnologyShortName} TCK {TechnologyVersion} is designed as a +portable, configurable, automated test suite for verifying the +compatibility of a vendor's implementation of the +{TechnologyShortName} {TechnologyVersion} Specification. + +[[GBFQV]][[tck-specifications-and-requirements]] + +1.2.1 TCK Specifications and Requirements +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This section lists the applicable requirements and specifications. + +* Specification Requirements: Software requirements for a +{TechnologyShortName} implementation are described in detail in the +{TechnologyShortName} {TechnologyVersion} Specification. Links to the +{TechnologyShortName} specification and other product information can +be found at {SpecificationURL}. +* {TechnologyShortName} Version: The {TechnologyShortName} {TechnologyVersion} TCK +is based on the {TechnologyShortName} +Specification, Version {TechnologyVersion}. +* Compatible Implementation: One {TechnologyShortName} +{TechnologyVersion} Compatible Implementation, {TechnologyRI} is +available from the Eclipse EE4J project +(https://projects.eclipse.org/projects/ee4j). See the CI documentation page at +{TechnologyRIURL} for more information. + +See the {TechnologyShortName} TCK Release Notes for more specific +information about Java SE version requirements, supported platforms, +restrictions, and so on. + +[[GBFSQ]][[tck-components]] + +1.2.2 TCK Components +^^^^^^^^^^^^^^^^^^^^ + +The {TechnologyShortName} TCK {TechnologyVersion} includes the +following components: + +* {TechnologyShortName} TCK signature tests; check that all public APIs +are supported and/or defined as specified in the {TechnologyShortName} +Version {TechnologyVersion} implementation under test. +* If applicable, an exclude list, which provides a list of tests that your +implementation is not required to pass. +ifndef::no-api-tests[] +* API tests for all of the {TechnologyShortName} API in all related packages: +include::packages.inc[] +endif::no-api-tests[] +ifdef::end-to-end-tests[] +* End-to-end tests that demonstrate compliance with the {TechnologyFullName} +Specification. +endif::end-to-end-tests[] + +The {TechnologyShortName} TCK tests run on the following platforms: + +include::platforms.inc[] + + +[[GBFRA]][[tck-compatibility-test-suite]] + +1.2.3 TCK Compatibility Test Suite +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The test suite is the collection of tests +to test a particular technology implementation. In this case, it is the +collection of tests used by the {TechnologyShortName} TCK +{TechnologyVersion} to test a {TechnologyShortName} {TechnologyVersion} +implementation. The tests are designed to verify that a vendor's +runtime implementation of the technology complies with the appropriate +specification. The individual tests correspond to assertions of the +specification. + +The tests that make up the TCK compatibility test suite are precompiled +and indexed within the TCK test directory structure. + +[[GBFSH]][[exclude-lists]] + +1.2.4 Exclude Lists +^^^^^^^^^^^^^^^^^^^ + +Each version of a TCK includes an Exclude List contained in a `TCK-Exclude-List.txt` +file. +This is a list of test file URLs that identify tests which do not +have to be run for the specific version of the TCK being used. +Whenever tests are run, the Junit framework automatically excludes +these tests from being executed as those are disabled using '@Ignore' tag in JUnit. + +A vendor's compatible implementation is not required to pass or run any test on the Exclude List. +The Exclude List file, +{excludeListFileName}+, is documented in the +{TechnologyShortName} TCK. Please note this file is not parsed to exclude any test and is only +for documentation purpose. + + +[NOTE] +======================================================================= + +From time to time, updates to the Exclude List are made available. +The exclude list is included in the TCK ZIP archive. +Each time an update is approved and released, the version number +will be incremented. +You should always make sure you are using an up-to-date copy of the +Exclude List before running the {TechnologyShortName} TCK to verify your +implementation. + +======================================================================= + + +A test might be in the Exclude List for reasons such as: + +* An error in an underlying implementation API has been discovered which +does not allow the test to execute properly. +* An error in the specification that was used as the basis of the test +has been discovered. +* An error in the test itself has been discovered. +* The test fails due to a bug in the tools used to run the test. + +In addition, all tests are run against the compatible implementations. +Any tests that fail when run on a compatible Jakarta platform are put on the +Exclude List. Any test that is not specification-based, or for which the +specification is vague, may be excluded. Any test that is found to be +implementation dependent (based on a particular thread scheduling model, +based on a particular file system behavior, and so on) may be excluded. + + +[NOTE] +======================================================================= + +Vendors are not permitted to alter or modify Exclude Lists. Changes to +an Exclude List can only be made by using the procedure described in +link:rules.html#CJAJEAEI[Section 2.3.1, "TCK Test Appeals Steps."] + +======================================================================= + + +[[GBFRR]][[tck-configuration]] + +1.2.5 TCK Configuration +^^^^^^^^^^^^^^^^^^^^^^^ + +You need to set several variables in your test environment, +and run the {TechnologyShortName} tests, as described in +link:config.html#GBFVV[Chapter 4, "Setup and Configuration."] + +include::intro.inc[] + +[[GBFQW]][[getting-started-with-the-tck]] + +[NOTE] +==== +The Jakarta EE Specification Process support multiple compatible implementations. +These instructions explain how to get started with the {TechnologyRI} CI. +If you are using another compatible implementation, refer to material provided +by that implementation for specific instructions and procedures. + +==== + +1.3 Getting Started With the TCK +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This section provides an general overview of what needs to be done to +install, set up, test, and use the {TechnologyShortName} TCK. These +steps are explained in more detail in subsequent chapters of this +guide. + +1. Make sure that the following software has been correctly installed +on the system: ++ +-- +include::req-software.inc[] +* Java SE {SEversion} +* A CI for {TechnologyShortName} {TechnologyVersion}. One example is {TechnologyRI}. +* {TechnologyShortName} TCK version {TechnologyVersion}, which includes: +include::tck-packages.inc[] +* The {TechnologyShortName} {TechnologyVersion} Vendor Implementation (VI) + +* Any Jupiter API compatible test runner +-- +See the documentation for each of these software applications for +installation instructions. See link:install.html#GBFTP[Chapter 3, +"Installation,"] for instructions on installing the {TechnologyShortName} TCK. +2. Set up the {TechnologyShortName} TCK software. + +See link:config.html#GBFVV[Chapter 4, "Setup and Configuration,"] for +details about the following steps. + a. Set up your shell environment. +3. Test the {TechnologyShortName} {TechnologyVersion} implementation. + +Test the {TechnologyShortName} implementation installation by running +the test suite. See link:using.html#GBFWO[Chapter 5, "Executing Tests."]
diff --git a/tck-docs/userguide/src/main/jbake/content/intro.inc b/tck-docs/userguide/src/main/jbake/content/intro.inc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/intro.inc
diff --git a/tck-docs/userguide/src/main/jbake/content/packages.inc b/tck-docs/userguide/src/main/jbake/content/packages.inc new file mode 100644 index 0000000..0e15a82 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/packages.inc
@@ -0,0 +1,11 @@ +** `jakarta.json.bind` + +** `jakarta.json.bind.adapter` + +** `jakarta.json.bind.annotation` + +** `jakarta.json.bind.config` + +** `jakarta.json.bind.serializer` + +** `jakarta.json.bind.spi`
diff --git a/tck-docs/userguide/src/main/jbake/content/platforms.inc b/tck-docs/userguide/src/main/jbake/content/platforms.inc new file mode 100644 index 0000000..236beed --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/platforms.inc
@@ -0,0 +1 @@ +* CentOS Linux 7 \ No newline at end of file
diff --git a/tck-docs/userguide/src/main/jbake/content/preface.adoc b/tck-docs/userguide/src/main/jbake/content/preface.adoc new file mode 100644 index 0000000..7a5b1ec --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/preface.adoc
@@ -0,0 +1,141 @@ +type=page +status=published +title=Preface +next=intro.html +prev=title.html +~~~~~~ +include::attributes.conf[] +Preface +======= + +[[TCJRS00001]][[GBFTI]] + + +[[preface]] +Preface +------- + +This guide describes how to install, configure, and run the Technology +Compatibility Kit (TCK) that is used to test the {TechnologyFullName} +({TechnologyShortName} {TechnologyVersion}) technology. + +The {TechnologyShortName} TCK is a portable, configurable automated +test suite for verifying the compatibility of a vendor's +implementation of the {TechnologyShortName} {TechnologyVersion} +Specification (hereafter referred to as the vendor implementation or VI). +The {TechnologyShortName} TCK uses the Junit framework to run the test suite + + +[NOTE] +======================================================================= + +Note All references to specific Web URLs are given for the sake of your +convenience in locating the resources quickly. These references are +always subject to changes that are in many cases beyond the control of +the authors of this guide. + +======================================================================= + +Jakarta EE is a community sponsored and community run program. +Organizations contribute, along side individual contributors who use, evolve +and assist others. +Commercial support is not available through the Eclipse Foundation resources. +Please refer to the Eclipse EE4J project site +(https://projects.eclipse.org/projects/ee4j). +There, you will find additional details as well as a list of all the associated sub-projects +(Implementations and APIs), that make up Jakarta EE and define these specifications. +If you have questions about this Specification you may +send inquiries to {SpecificationInquiryList}. +If you have questions about this TCK, you may send inquiries to +{TCKInquiryList}. + +[[TCJRS00034]][[GBFUS]] + + +[[who-should-use-this-book]] +Who Should Use This Book +~~~~~~~~~~~~~~~~~~~~~~~~ + +This guide is for vendors that implement the {TechnologyShortName} +{TechnologyVersion} technology to assist them in running the test suite +that verifies compatibility of their implementation of the +{TechnologyShortName} {TechnologyVersion} Specification. + + +[[TCJRS00035]][[GBFPO]] + + +[[before-you-read-this-book]] +Before You Read This Book +~~~~~~~~~~~~~~~~~~~~~~~~~ + +You should be familiar with the {TechnologyShortName} +{TechnologyVersion}, version {TechnologyVersion} Specification, +which can be found at {SpecificationURL}. + +[[TCJRS00036]][[GBFWF]] + + +[[typographic-conventions]] +Typographic Conventions +~~~~~~~~~~~~~~~~~~~~~~~ + +The following table describes the typographic conventions that are used +in this book. + +[width="100%",cols="15%,40%,45%",options="header",] +|======================================================================= +|Convention |Meaning |Example +|*Boldface* |Boldface type indicates graphical user interface elements +associated with an action, terms defined in text, or what you type, +contrasted with onscreen computer output. a| +From the *File* menu, select *Open Project*. + +A *cache* is a copy that is stored locally. + +`machine_name% *su*` + +`Password:` + +|`Monospace` |Monospace type indicates the names of files and +directories, commands within a paragraph, URLs, code in examples, text +that appears on the screen, or text that you enter. a| +Edit your `.login` file. + +Use `ls` `-a` to list all files. + +`machine_name% you have mail.` + +|_Italic_ |Italic type indicates book titles, emphasis, or placeholder +variables for which you supply particular values. a| +Read Chapter 6 in the _User's Guide_. + +Do _not_ save the file. + +The command to remove a file is `rm` _filename_. + +|======================================================================= + + +[[TCJRS00037]][[FWBSD]] + + +[[shell-prompts-in-command-examples]] +Shell Prompts in Command Examples +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following table shows the default UNIX system prompt and superuser +prompt for the C shell, Bourne shell, and Korn shell. + +[width="100%",cols="50%,50%",options="header",] +|===================================================== +|Shell |Prompt +|C shell |`machine_name%` +|C shell for superuser |`machine_name#` +|Bourne shell and Korn shell |`$` + +|Bourne shell and Korn shell for superuser |`#` + +|Bash shell |`shell_name-shell_version$` +|Bash shell for superuser |`shell_name-shell_version#` +|===================================================== + + +
diff --git a/tck-docs/userguide/src/main/jbake/content/rebuild.adoc b/tck-docs/userguide/src/main/jbake/content/rebuild.adoc new file mode 100644 index 0000000..e4021cf --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/rebuild.adoc
@@ -0,0 +1,20 @@ +type=page +status=published +title=Appendix B: Rebuild Rules +prev=faq.html +~~~~~~ +include::attributes.conf[] + +Appendix B: Rebuild Rules +========================= + + +ifdef::rebuild[] +include::rebuild.inc[] +endif::rebuild[] +ifndef::rebuild[] + +<<< +Appendix B is not used for the {TechnologyShortName} TCK. + +endif::rebuild[]
diff --git a/tck-docs/userguide/src/main/jbake/content/rebuild.inc b/tck-docs/userguide/src/main/jbake/content/rebuild.inc new file mode 100644 index 0000000..f7b9651 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/rebuild.inc
@@ -0,0 +1,8 @@ +/////////////////////////////////////////////////////////////////////// +NOTE TO WRITERS: +The following sections should be customized for the technology. +See the JAXRS User Guide for an example of this file. +/////////////////////////////////////////////////////////////////////// + +[[GCLIZ]] +
diff --git a/tck-docs/userguide/src/main/jbake/content/req-software.inc b/tck-docs/userguide/src/main/jbake/content/req-software.inc new file mode 100644 index 0000000..48014f5 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/req-software.inc
@@ -0,0 +1,10 @@ +/////////////////////////////////////////////////////////////////////// +NOTE TO WRITERS: +This is a list of software required in addition to the TCK and the RI. +For many Java EE APIs, the Java EE RI will be required, as described below. +For standalone technologies, no other software may be required, and the +below line can be removed. + +This is used in intro.adoc in section 1.3 and install.adoc in section 3.2. +/////////////////////////////////////////////////////////////////////// +
diff --git a/tck-docs/userguide/src/main/jbake/content/rules.adoc b/tck-docs/userguide/src/main/jbake/content/rules.adoc new file mode 100644 index 0000000..e027394 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/rules.adoc
@@ -0,0 +1,401 @@ +type=page +status=published +title=Procedure for Certification +next=install.html +prev=intro.html +~~~~~~ +include::attributes.conf[] +Procedure for Certification +=========================== + +[[GBFSN]] + + +[[procedure-for-certification]] +2 Procedure for Certification +----------------------------- + +This chapter describes the compatibility testing procedure and +compatibility requirements for {TechnologyFullName}. +This chapter contains the following sections: + +* link:#CJAFFDGI[Certification Overview] +* link:#CJAFGIGG[Compatibility Requirements] +* link:#CJAIIBDJ[Test Appeals Process] +* link:#CJAJECIE[Specifications for {TechnologyFullName}] +* link:#CJABAHGI[Libraries for {TechnologyFullName}] + +[[CJAFFDGI]][[certification-overview]] + +2.1 Certification Overview +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The certification process for {technologyShortName} {TechnologyVersion} +consists of the following activities: + +* Install the appropriate version of the Technology Compatibility Kit +(TCK) and execute it in accordance with the instructions in this User's +Guide. +* Ensure that you meet the requirements outlined in +link:#CJAFGIGG[Compatibility Requirements] below. +* Certify to the Eclipse Foundation that you have finished +testing and that you meet all of the compatibility requirements, +as required by the Eclipse Foundation TCK License. + +[[CJAFGIGG]][[compatibility-requirements]] + +2.2 Compatibility Requirements +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The compatibility requirements for {TechnologyShortName} +{TechnologyVersion} consist of meeting the requirements set forth by +the rules and associated definitions contained in this section. + +[[sthref4]][[definitions]] + +2.2.1 Definitions +^^^^^^^^^^^^^^^^^ + +These definitions are for use only with these compatibility requirements +and are not intended for any other purpose. + +[[sthref5]][[sthref6]] + +Table 2-1 Definitions + +[width="100%",cols="25%,75%",options="header",] +|======================================================================= +|Term |Definition +|API Definition Product |A Product for which the only Java class files +contained in the product are those corresponding to the application +programming interfaces defined by the Specifications, and which is +intended only as a means for formally specifying the application +programming interfaces defined by the Specifications. + +|Computational Resource a| +A piece of hardware or software that may vary in quantity, existence, or +version, which may be required to exist in a minimum quantity and/or at +a specific or minimum revision level so as to satisfy the requirements +of the Test Suite. + +Examples of computational resources that may vary in quantity are RAM +and file descriptors. + +Examples of computational resources that may vary in existence (that is, +may or may not exist) are graphics cards and device drivers. + +Examples of computational resources that may vary in version are +operating systems and device drivers. + +|Configuration Descriptor |Any file whose format is well defined by a +specification and which contains configuration information for a set of +Java classes, archive, or other feature defined in the specification. + +|Conformance Tests |All tests in the Test Suite for an indicated +Technology Under Test, as released and distributed by the +Eclipse Foundation, excluding those tests on the +published Exclude List for the Technology Under Test. + +|Container |An implementation of the associated Libraries, as specified +in the Specifications, and a version of a Java Platform, Standard +Edition Runtime Product, as specified in the Specifications, or a later +version of a Java Platform, Standard Edition Runtime Product that also +meets these compatibility requirements. + +|Documented |Made technically accessible and made known to users, +typically by means such as marketing materials, product documentation, +usage messages, or developer support programs. + +|Exclude List |The most current list of tests, released and distributed by the +Eclipse Foundation, that are not required to be passed to certify +conformance. The Jakarta EE Specification Committee may add to the Exclude List for that +Test Suite as needed at any time, in which case the updated TCK version +supplants any previous Exclude Lists for that Test Suite. + +|Libraries a| +The class libraries, as specified through the Jakarta EE Specification Process +(JESP), for the Technology Under Test. + +The Libraries for {TechnologyFullName} are listed at the end of this chapter. + +|Location Resource a| +A location of classes or native libraries that are components of the +test tools or tests, such that these classes or libraries may be +required to exist in a certain location in order to satisfy the +requirements of the test suite. + +For example, classes may be required to exist in directories named in a +CLASSPATH variable, or native libraries may be required to exist in +directories named in a PATH variable. + +|Maintenance Lead |The corresponding Jakarta EE Specification Project +is responsible for maintaining the Specification, and the TCK for the +Technology. The Specification Project Team will propose revisions and +updates to the Jakarta EE Specification Committee which will approve +and release new versions of the specification and TCK. + +|Operating Mode a| +Any Documented option of a Product that can be changed by a user in +order to modify the behavior of the Product. + +For example, an Operating Mode can be binary (enable/disable +optimization), an enumeration (select from a list of protocols), or a +range (set the maximum number of active threads). + +Note that an Operating Mode may be selected by a command line switch, an +environment variable, a GUI user interface element, a configuration or +control file, etc. + +|Product |A vendor's product in which the Technology Under Test is +implemented or incorporated, and that is subject to compatibility +testing. + +|Product Configuration a| +A specific setting or instantiation of an Operating Mode. + +For example, a Product supporting an Operating Mode that permits user +selection of an external encryption package may have a Product +Configuration that links the Product to that encryption package. + +|Rebuildable Tests |Tests that must be built using an +implementation-specific mechanism. This mechanism must produce +specification-defined artifacts. Rebuilding and running these tests +against a known compatible implementation verifies that the mechanism generates +compatible artifacts. + +|Resource |A Computational Resource, a Location Resource, or a Security +Resource. + +|Rules |These definitions and rules in this Compatibility Requirements +section of this User's Guide. + +|Runtime |The Containers specified in the Specifications. + +|Security Resource a| +A security privilege or policy necessary for the proper execution of the +Test Suite. + +For example, the user executing the Test Suite will need the privilege +to access the files and network resources necessary for use of the +Product. + +|Specifications a| +The documents produced through the Jakarta EE Specification Process (JESP) +that define a particular Version of a Technology. + +The Specifications for the Technology Under Test are referenced later in +this chapter. + +|Technology |Specifications and one or more compatible implementations produced +through the Jakarta EE Specification Process (JESP). + +|Technology Under Test |Specifications and a compatible implementation +for {TechnologyFullName} Version {TechnologyVersion}. + +|Test Suite |The requirements, tests, and testing tools distributed by +the Maintenance Lead as applicable to a given Version of the Technology. + +|Version |A release of the Technology, as produced through the +Jakarta EE Specification Process (JESP). + +include::defns.inc[] +|======================================================================= + + +[[sthref7]][[rules-for-products]] + +2.2.2 Rules for {TechnologyFullName} Products +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The following rules apply for each version of an operating system, +software component, and hardware platform Documented as supporting the +Product: + +*{techID}1* The Product must be able to satisfy all applicable compatibility +requirements, including passing all Conformance Tests, in every Product +Configuration and in every combination of Product Configurations, except +only as specifically exempted by these Rules. + +For example, if a Product provides distinct Operating Modes to optimize +performance, then that Product must satisfy all applicable compatibility +requirements for a Product in each Product Configuration, and +combination of Product Configurations, of those Operating Modes. + +*{techID}1.1* If an Operating Mode controls a Resource necessary for the +basic execution of the Test Suite, testing may always use a Product +Configuration of that Operating Mode providing that Resource, even if +other Product Configurations do not provide that Resource. +Notwithstanding such exceptions, each Product must have at least one set +of Product Configurations of such Operating Modes that is able to pass +all the Conformance Tests. + +For example, a Product with an Operating Mode that controls a security +policy (i.e., Security Resource) which has one or more Product +Configurations that cause Conformance Tests to fail may be tested using +a Product Configuration that allows all Conformance Tests to pass. + +*{techID}1.2* A Product Configuration of an Operating Mode that causes the +Product to report only version, usage, or diagnostic information is +exempted from these compatibility rules. + +*{techID}1.3* An API Definition Product is exempt from all functional +testing requirements defined here, except the signature tests. + +*{techID}2* Some Conformance Tests may have properties that may be changed. +Properties that can be changed are identified in the configuration +interview. Apart from changing such properties and other allowed +modifications described in this User's Guide (if any), no source or +binary code for a Conformance Test may be altered in any way without +prior written permission. Any such allowed alterations to the +Conformance Tests will be provided via the Jakarta EE Specification Project +website and apply to all vendor compatible implementations. + +*{techID}3* The testing tools supplied as part of the Test Suite or as +updated by the Maintenance Lead must be used to certify compliance. + +*{techID}4* The Exclude List associated with the Test Suite cannot be +modified. + +*{techID}5* The Maintenance Lead can define exceptions to these Rules. Such +exceptions would be made available as above, and will apply to all vendor implementations. + +*{techID}6* All hardware and software component additions, deletions, and +modifications to a Documented supporting hardware/software platform, +that are not part of the Product but required for the Product to satisfy +the compatibility requirements, must be Documented and available to +users of the Product. + +For example, if a patch to a particular version of a supporting +operating system is required for the Product to pass the Conformance +Tests, that patch must be Documented and available to users of the +Product. + +*{techID}7* The Product must contain the full set of public and protected +classes and interfaces for all the Libraries. Those classes and +interfaces must contain exactly the set of public and protected methods, +constructors, and fields defined by the Specifications for those +Libraries. No subsetting, supersetting, or modifications of the public +and protected API of the Libraries are allowed except only as +specifically exempted by these Rules. + +*{techID}7.1* If a Product includes Technologies in addition to the +Technology Under Test, then it must contain the full set of combined +public and protected classes and interfaces. The API of the Product +must contain the union of the included Technologies. No further +modifications to the APIs of the included Technologies are allowed. + +ifdef::subset-allowed[] +*{techID}7.2* The Product may contain a subset of the classes and +interfaces for the Libraries. +endif::subset-allowed[] + +*{techID}8* Except for tests specifically required by this TCK to be rebuilt +(if any), the binary Conformance Tests supplied as part of the Test +Suite or as updated by the Maintenance Lead must be used to certify +compliance. + +*{techID}9* The functional programmatic behavior of any binary class or +interface must be that defined by the Specifications. + +include::rules.inc[] + +[[CJAIIBDJ]][[test-appeals-process]] + +2.3 Test Appeals Process +~~~~~~~~~~~~~~~~~~~~~~~~ + +Jakarta has a well established process for managing challenges to its +TCKs. Any implementor may submit a challenge to one or more tests in the +{TechnologyShortName} TCK as it relates to their implementation. Implementor +means the entity as a whole in charge of producing the final certified release. +*Challenges filed should represent the consensus of that entity*. + +2.3.1 Valid Challenges +^^^^^^^^^^^^^^^^^^^^^^ +Any test case (e.g., test class, @Test method), test case configuration (e.g., deployment descriptor), test beans, annotations, and other resources considered part of the TCK may be challenged. + +The following scenarios are considered in scope for test challenges: + +* Claims that a test assertion conflicts with the specification. +* Claims that a test asserts requirements over and above that of the specification. +* Claims that an assertion of the specification is not sufficiently implementable. +* Claims that a test is not portable or depends on a particular implementation. + +2.3.2 Invalid Challenges +^^^^^^^^^^^^^^^^^^^^^^^^ +The following scenarios are considered out of scope for test challenges and will be immediately closed if filed: + +* Challenging an implementation’s claim of passing a test. Certification is an honor system and these issues must be raised directly with the implementation. +* Challenging the usefulness of a specification requirement. The challenge process cannot be used to bypass the specification process and raise in question the need or relevance of a specification requirement. +* Claims the TCK is inadequate or missing assertions required by the specification. See the Improvement section, which is outside the scope of test challenges. +* Challenges that do not represent a consensus of the implementing community will be closed until such time that the community does agree or agreement cannot be made. The test challenge process is not the place for implementations to initiate their own internal discussions. +* Challenges to tests that are already excluded for any reason. +* Challenges that an excluded test should not have been excluded and should be re-added should be opened as a new enhancement request + +Test challenges must be made in writing via the {TechnologyShortName} specification project issue tracker +as described in link:#CJAJEAEI[Section 2.3.3, "TCK Test Appeals Steps."] + +All tests found to be invalid will be placed on the Exclude List +for that version of the {TechnologyShortName} TCK. + + +[[CJAJEAEI]][[tck-test-appeals-steps]] + +2.3.3 TCK Test Appeals Steps +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +1. Challenges should be filed via the {TechnologyFullName} specification project’s issue tracker using the label `challenge` and include the following information: +* The relevant specification version and section number(s) +* The coordinates of the challenged test(s) +* The exact TCK and exclude list versions +* The implementation being tested, including name and company +* The full test name +* A full description of why the test is invalid and what the correct behavior is believed to be +* Any supporting material; debug logs, test output, test logs, run scripts, etc. + + + +2. Specification project evaluates the challenge. + +Challenges can be resolved by a specification project lead, or a project challenge triage team, after a consensus of the specification project committers is reached or attempts to gain consensus fails. +Specification projects may exercise lazy consensus, voting or any practice that follows the principles of Eclipse Foundation Development Process. +The expected timeframe for a response is two weeks or less. +If consensus cannot be reached by the specification project for a prolonged period of time, the default recommendation is to exclude the tests and address the dispute in a future revision of the specification. + +3. Accepted Challenges. + +A consensus that a test produces invalid results will result in the exclusion of that test from certification requirements, and an immediate update and release of an official distribution of the TCK including the new exclude list. The associated `challenge` issue must be closed with an `accepted` label to indicate it has been resolved. + +4. Rejected Challenges and Remedy. + +When a`challenge` issue is rejected, it must be closed with a label of `invalid` to indicate it has been rejected. +There appeal process for challenges rejected on technical terms is outlined in Escalation Appeal. +If, however, an implementer feels the TCK challenge process was not followed, an appeal issue should be filed with specification project’s TCK issue tracker using the label `challenge-appeal`. +A project lead should escalate the issue with the Jakarta EE Specification Committee via email (jakarta.ee-spec@eclipse.org). +The committee will evaluate the matter purely in terms of due process. +If the appeal is accepted, the original TCK challenge issue will be reopened and a label of `appealed-challenge` added, along with a discussion of the appeal decision, and the `challenge-appeal` issue with be closed. +If the appeal is rejected, the `challenge-appeal` issue should closed with a label of `invalid`. + +5. Escalation Appeal. + +If there is a concern that a TCK process issue has not been resolved satisfactorily, the +https://www.eclipse.org/projects/dev_process/#6_5_Grievance_Handling[Eclipse Development Process Grievance Handling] procedure should be followed to escalate the resolution. Note that this is not a mechanism to attempt to handle implementation specific issues. + + +[[CJAJECIE]][[specifications-for-technology]] + +2.4 Specifications for {TechnologyFullName} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The {TechnologyFullName} specification is available from the specification +project web-site: {SpecificationURL}. + +[[CJABAHGI]][[libraries-for-technology]] + +2.5 Libraries for {TechnologyFullName} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The following is a list of the packages comprising the required class +libraries for {TechnologyShortName} {TechnologyVersion}: + +include::packages.inc[] + +For the latest list of packages, also see: + +{SpecificationURL}
diff --git a/tck-docs/userguide/src/main/jbake/content/rules.inc b/tck-docs/userguide/src/main/jbake/content/rules.inc new file mode 100644 index 0000000..b5a250f --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/rules.inc
@@ -0,0 +1,78 @@ +/////////////////////////////////////////////////////////////////////// +NOTE TO WRITERS: +Most technologies will only need the compatibility rules in rules.adoc. +Some technologies will need additional rules. If they're needed, +remove the comment block delimiters below and update the rules as +appropriate. You may need to adjust the rule numbers to avoid gaps. + +The first comment block below is additional rules needed by JPA. + +The second comment block below is additional rules needed by +JSP and Servlet. (And EJB, if it had a standalone TCK.) + +The third comment block below is additional rules that apply +to any technology that defines deployment descriptors. + +The fourth comment block is special rules that apply only to JSP. + +NOTE: This set of examples is NOT complete, but should be. +/////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////// +*{techID}10* The Runtime must report an error when processing a +Configuration Descriptor that does not conform to the Specifications. + +*{techID}11* An error must be reported when processing a configuration +descriptor that includes a Java Persistence QL expression that does not +conform to the Specifications. + +*{techID}12* The presence of an XML comment in a Configuration +Descriptor, when processed by the Runtime, must not cause the +functional programmatic behavior of the Runtime to vary from the +functional programmatic behavior of the Runtime in the absence of that +comment. +/////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////// +*{techID}10* Each Container must make technically accessible all Java SE +Runtime interfaces and functionality, as defined by the Specifications, +to programs running in the Container, except only as specifically +exempted by these Rules. + +*{techID}10.1* Containers may impose security constraints, as defined by +the Specifications. +/////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////// +*{techID}11* A Deployment Tool must report an error when processing a +Configuration Descriptor that does not conform to the Specifications. + +*{techID}12* The presence of an XML comment in a Configuration +Descriptor, when processed by a Deployment Tool, must not cause the +functional programmatic behavior of the Deployment Tool to vary from +the functional programmatic behavior of the Deployment Tool in the +absence of that comment. +/////////////////////////////////////////////////////////////////////// + +/////////////////////////////////////////////////////////////////////// +*{techID}11* A web Container must report an error, as defined by the +Specifications, when processing a JSP Page that does not conform to the +Specifications. + +*{techID}12* The presence of a Java language comment or Java language +directive in a JSP Page that specifies ”java” as the scripting +language, when processed by a web Container, must not cause the +functional programmatic behavior of that JSP Page to vary from the +functional programmatic behavior of that JSP Page in the absence of +that Java language comment or Java language directive. + +*{techID}13* The contents of any fixed template data (defined by the +Specifications) in a JSP Page, when processed by a web Container, must +not affect the functional programmatic behavior of that JSP Page, +except as defined by the Specifications. + +*{techID}14* The functional programmatic behavior of a JSP Page that +specifies ”java” as the scripting language must be equivalent to the +functional programmatic behavior of the JSP Page Implementation Class +constructed from that JSP Page. +///////////////////////////////////////////////////////////////////////
diff --git a/tck-docs/userguide/src/main/jbake/content/tck-packages.inc b/tck-docs/userguide/src/main/jbake/content/tck-packages.inc new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/tck-packages.inc
@@ -0,0 +1 @@ +
diff --git a/tck-docs/userguide/src/main/jbake/content/title.adoc b/tck-docs/userguide/src/main/jbake/content/title.adoc new file mode 100644 index 0000000..232172d --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/title.adoc
@@ -0,0 +1,42 @@ +type=page +status=published +title=TCK User's Guide for Technology Implementors +next=preface.html +prev=toc.html +~~~~~~ +include::attributes.conf[] + +TCK User's Guide for {TechnologyFullName}, Release {TechnologyVersion} for Jakarta EE +===================================================================================== + +[[eclipse-foundation]] +Eclipse Foundation +------------------ + +Technology Compatibility Kit User's Guide for {TechnologyFullName} + +Release {TechnologyVersion} for Jakarta EE + +{ReleaseDate} + +[[sthref1]] + +''''' + +Technology Compatibility Kit User's Guide for {TechnologyFullName}, +Release {TechnologyVersion} for Jakarta EE + +Copyright © {CopyrightDates} Oracle and/or its affiliates. All rights reserved. + +This program and the accompanying materials are made available under +the terms of the Eclipse Public License v. 2.0, which is available at +http://www.eclipse.org/legal/epl-2.0. + +SPDX-License-Identifier: EPL-2.0 + +Oracle and Java are registered trademarks of Oracle and/or its +affiliates. Other names may be trademarks of their respective owners. + +include::title.inc[] + +
diff --git a/tck-docs/userguide/src/main/jbake/content/title.inc b/tck-docs/userguide/src/main/jbake/content/title.inc new file mode 100644 index 0000000..25bf47e --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/title.inc
@@ -0,0 +1,11 @@ +/////////////////////////////////////////////////////////////////////// +NOTE TO WRITERS: +This is included at the tail end of the Title page. +The following section should be customized for the technology. +This is provided to allow each technology to customize legacy acronym names +that are used in this TCK. +Be sure to customize LegacyAcronym in attributes.conf +Add additional lines as needed for acronyms found in your TCK user guide. +/////////////////////////////////////////////////////////////////////// + +References in this document to {LegacyAcronym} refer to the {TechnologyFullName} unless otherwise noted.
diff --git a/tck-docs/userguide/src/main/jbake/content/toc.adoc b/tck-docs/userguide/src/main/jbake/content/toc.adoc new file mode 100644 index 0000000..c5c5867 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/toc.adoc
@@ -0,0 +1,93 @@ +type=page +status=published +title=TCK User's Guide for Technology Implementors +next=title.html +~~~~~~ +include::attributes.conf[] +TCK User's Guide for Technology Implementors +============================================ + +[[contents]] +Contents +-------- + +* link:title.html#eclipse-foundation[Eclipse Foundation] + +link:preface.html#GBFTI[Preface] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +** link:preface.html#GBFUS[Who Should Use This Book] +** link:preface.html#GBFPO[Before You Read This Book] +** link:preface.html#GBFWF[Typographic Conventions] +** link:preface.html#FWBSD[Shell Prompts in Command Examples] + +link:intro.html#GBFOW[1 Introduction] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +** link:intro.html#GBFTK[1.1 Compatibility Testing] +*** link:intro.html#GBFQN[1.1.1 Why Compatibility Testing is Important] +*** link:intro.html#GBFPR[1.1.2 TCK Compatibility Rules] +*** link:intro.html#GBFPW[1.1.3 TCK Overview] +*** link:intro.html#GBFPB[1.1.4 Jakarta EE Specification Process (JESP) Program and Compatibility Testing] +** link:intro.html#GBFQR[1.2 About the TCK] +*** link:intro.html#GBFQV[1.2.1 TCK Specifications and Requirements] +*** link:intro.html#GBFSQ[1.2.2 TCK Components] +*** link:intro.html#GBFRA[1.2.3 TCK Compatibility Test Suite] +*** link:intro.html#GBFSH[1.2.4 Exclude Lists] +*** link:intro.html#GBFRR[1.2.5 TCK Configuration] +** link:intro.html#GBFQW[1.3 Getting Started With the TCK] + +[[procedure-for-certification]] +link:rules.html#GBFSN[2 Procedure for Certification] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +** link:rules.html#CJAFFDGI[2.1 Certification Overview] +** link:rules.html#CJAFGIGG[2.2 Compatibility Requirements] +*** link:rules.html#definitions[2.2.1 Definitions] +*** link:rules.html#sthref7[2.2.2 Rules for {TechnologyFullName} Products] +** link:rules.html#CJAIIBDJ[2.3 Test Appeals Process] +*** link:rules.html#[2.3.1 Valid Challenges] +*** link:rules.html#[2.3.2 Invalid Challenges] +*** link:rules.html#CJAJEAEI[2.3.3 TCK Test Appeals Steps] +** link:rules.html#CJAJECIE[2.4 Specifications for {TechnologyFullName}] +** link:rules.html#CJABAHGI[2.5 Libraries for {TechnologyFullName}] + +link:install.html#GBFTP[3 Installation] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +** link:install.html#GBFUD[3.1 Obtaining a Compatible Implementation] +** link:install.html#GBFTS[3.2 Installing the Software] + +[[setup-and-configuration]] +link:config.html#GBFVV[4 Setup and Configuration] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + +[[executing-tests]] +link:using.html#GBFWO[5 Executing Tests] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +** link:using.html#GBFUZ[5.1 Starting the tests] +*** link:using.html#GBFVW[5.1.1 To Run All Tests] +** link:using.html#GBFWM[5.2 Running a Subset of the Tests] +*** link:using.html#GBFWK[5.2.1 To Run a Single Test] +*** link:using.html#GCMCA[5.2.2 To Run a Subset of Tests] +*** link:using.html#GCMCU[5.2.3 To Run Signature Tests] +** link:using.html#GCLRR[5.3 Running the TCK Against another CI] +** link:using.html#GCLRZ[5.4 Running the TCK Against a Vendor's Implementation] +** link:using.html#GBFVK[5.5 Test Reports] + +[[debugging-test-problems]] +link:debug.html#GBFUV[6 Debugging Test Problems] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +** link:debug.html#GBFYP[6.1 Overview] +** link:debug.html#GBFYF[6.2 Configuration Failures] + +[[a-frequently-asked-questions]] +link:faq.html#GBFYD[A Frequently Asked Questions] +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +** link:faq.html#GBFYQ[A.1 Where do I start to debug a test failure?] +** link:faq.html#GBFYR[A.2 How do I restart a crashed test run?] +** link:faq.html#GBFWU[A.3 What would cause tests be added to the exclude list?]
diff --git a/tck-docs/userguide/src/main/jbake/content/using-examples.inc b/tck-docs/userguide/src/main/jbake/content/using-examples.inc new file mode 100644 index 0000000..5fb981b --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/using-examples.inc
@@ -0,0 +1,49 @@ +/////////////////////////////////////////////////////////////////////// +NOTE TO WRITERS: +These CLI examples can be customized as necessary. +/////////////////////////////////////////////////////////////////////// + +Start test using the following command: + +-- +[source,oac_no_warn] +---- +mvn clean verify +---- +-- + +[[GCMCU]] + +Example 5-1 {TechnologyShortName} TCK Signature Tests + +To run the {TechnologyShortName} TCK signature tests, enter the +following commands: + +[source,subs="attributes"] +---- +mvn verify -Dit.test=jakarta.jsonb.tck.signaturetest.** +---- + +[[GCMBV]] + + +Example 5-2 Single Test Directory + +To run a single test directory, enter the following commands: + +[source,subs="attributes"] +---- +mvn verify -Dit.test={singleTestDirectoryExample}.** +---- + +[[GCMCA]] + + +Example 5-3 Subset of Test Directories + +To run a subset of test directories, enter the following commands: + +[source,subs="attributes"] +---- +mvn verify -Dit.test={subsetTestDirectoryExample}.** +----
diff --git a/tck-docs/userguide/src/main/jbake/content/using.adoc b/tck-docs/userguide/src/main/jbake/content/using.adoc new file mode 100644 index 0000000..26d35c7 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/using.adoc
@@ -0,0 +1,177 @@ +type=page +status=published +title=Executing Tests +next=debug.html +prev=config.html +~~~~~~ +include::attributes.conf[] +Executing Tests +=============== + +[[GBFWO]] + + +[[executing-tests]] +5 Executing Tests +----------------- + +The {TechnologyShortName} TCK uses the Junit +framework to execute the tests. + +This chapter includes the following topics: + +* link:#GBFUZ[Running All Tests] +* link:#GBFWM[Running a Subset of the Tests] +* link:#GCLRR[Running the TCK Against your selected CI] +* link:#GCLRZ[Running the TCK Against a Vendor's Implementation] +* link:#GBFVK[Test Reports] + + +[NOTE] +======================================================================= + +The instructions in this chapter assume that you have installed and +configured your test environment as described in +link:install.html#GBFTP[Chapter 3, "Installation,"] and +link:config.html#GBFVV[Chapter 4, "Setup and Configuration,"], +respectively. + +======================================================================= + +ifdef::rebuild[] +As explained in link:rebuild.html#GCLIZ[Appendix B, "Packaging the +Test Applications in Servlet-Compliant WAR +Files With VI-Specific Information,"] the {TechnologyShortName} TCK +introduces the concept of repackaging the TCK tests. +endif::rebuild[] + + +[[GBFUZ]][[starting-javatest]] + +5.1 Starting the tests +~~~~~~~~~~~~~~~~~~~~~~ + +The {TechnologyShortName} TCK can be run from the command line +in your shell environment by executing tests from the TCK jar. + +[NOTE] +======================================================================= + +The `mvn` command referenced in the following +two procedures and elsewhere in this guide is the Apache Maven +build tool, which will need to be downloaded separately. + +======================================================================= + +[[GBFVW]][[to-start-tests-in-command-line-mode]] + +5.1.1 To Run All Tests +^^^^^^^^^^^^^^^^^^^^^^ + +To run all tests, enter the following command: + +[source,subs="attributes"] +---- +cd ${TechnologyHomeEnv}/bin +mvn verify +---- + +[[GBFWM]][[running-a-subset-of-the-tests]] + +5.2 Running a Subset of the Tests +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Use the following modes to run a subset of the tests: + +* link:#GBFWK[Section 5.2.1, "To Run a Single Test"] +* link:#GCMCA[Section 5.2.2, "To Run a Subset of Tests"] +* link:#GCMCU[Section 5.2.3, "To Run Signature Tests"] + + +[[GBFWK]][[to-run-a-single-test]] + +5.2.1 To Run a Single Test +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To run a single test, enter the following command: + + +[source,subs="attributes"] +---- +cd ${TechnologyHomeEnv}/bin +mvn verify -Dtest={singleTestExample} +---- + +[[GCMCA]][[to-run-a-subset-of-tests]] + +5.2.2 To Run a Subset of Tests +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To run a subset of tests, enter the following command: + +[source,subs="attributes"] +---- +cd ${TechnologyHomeEnv}/bin +mvn verify -Dtest={subsetTestDirectoryExample} +---- + +[[GCMCU]][[to-run-signature-tests]] + +5.2.3 To Run Signature Tests +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +To run the {TechnologyShortName} TCK Signature Tests, enter the +following command: + +[source,subs="attributes"] +---- +cd ${TechnologyHomeEnv}/bin +mvn verify -Dtest={sigTestExample} +---- + + +[[GCLRR]][[running-the-tck-against-the-ri]] + +5.3 Running the TCK Against another CI +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some test scenarios are designed to ensure that the configuration and deployment of +all the prebuilt {TechnologyShortName} TCK tests against one Compatible +Implementation are successful operating with other compatible implementations, and that the TCK is ready for +compatibility testing against the Vendor and Compatible Implementations. + +1. Verify that you have followed the configuration instructions in +link:config.html#GBFVU[Section 4.1, "Configuring Your Environment to Run +the TCK Against the Compatible Implementation."] +2. Run the tests, as described in link:#GBFUZ[Section 5.1, "Starting +the tests,"] and, if desired, link:#GBFWM[Section 5.2, "Running a Subset +of the Tests."] + +[[GCLRZ]][[running-the-tck-against-a-vendors-implementation]] + +5.4 Running the TCK Against a Vendor's Implementation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This test scenario is one of the compatibility test phases that all +Vendors must pass. + +1. Verify that you have followed the configuration instructions in +link:config.html#GCLHU[Section 4.2, "Configuring Your Environment to +Run the TCK Against the Vendor Implementation."] +2. If required, verify that you have completed the steps in +link:config.html#GCLIL[Section 4.3.3, "Deploying the +Test Applications Against the Vendor Implementation."] +3. Run the tests, as described in link:#GBFUZ[Section 5.1, "Starting +the Tests,"] and, if desired, link:#GBFWM[Section 5.2, "Running a Subset +of the Tests."] + +[[GBFVK]][[test-reports]] + +5.5 Test Reports +~~~~~~~~~~~~~~~~ + +A set of report files is created for every test run. These report files +can be found in the target directory that the test is run. After a test run is +completed, the Junit framework writes reports for the test run. + +include::using.inc[] +
diff --git a/tck-docs/userguide/src/main/jbake/content/using.inc b/tck-docs/userguide/src/main/jbake/content/using.inc new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/content/using.inc
diff --git a/tck-docs/userguide/src/main/jbake/jbake.properties b/tck-docs/userguide/src/main/jbake/jbake.properties new file mode 100644 index 0000000..05c7056 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/jbake.properties
@@ -0,0 +1,24 @@ +# +# Copyright (c) 2021 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +site.host=http://jbake.org +render.tags=false +render.sitemap=false +render.archive=false +render.feed=false +render.index=false +asciidoctor.option.safe=0 +asciidoctor.attributes.export=true \ No newline at end of file
diff --git a/tck-docs/userguide/src/main/jbake/templates/footer.ftl b/tck-docs/userguide/src/main/jbake/templates/footer.ftl new file mode 100644 index 0000000..cb4fbe5 --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/templates/footer.ftl
@@ -0,0 +1,44 @@ +<#-- a footer template fragment included in the page template --> +<hr /> + +<table width="90%" id="bottom-nav" cellspacing="0" cellpadding="0"> + <colgroup> + <col width="12%"/> + <col width="12%"/> + <col width="*"/> + </colgroup> + <tr> + <#if content.prev??> + <td align="left"> + <a href="${content.prev}"> + <span class=" vector-font"><i class="fa fa-arrow-circle-left" aria-hidden="true"></i></span> + <span style="position:relative;top:-2px;">Previous</span> + </a> + </td> + </#if> + + <#if content.next??> + <td align="left"> + <a href="${content.next}"> + <span class="vector-font"><i class="fa fa-arrow-circle-right vector-font" aria-hidden="true"></i></span> + <span style="position:relative;top:-2px;">Next</span> + </a> + </td> + </#if> + + <td align="right"> + <a href="toc.html"> + <span class="vector-font"><i class="fa fa-list vector-font" aria-hidden="true"></i></span> + <span style="position:relative;top:-2px;">Contents</span> + </a> + </td> + </tr> +</table> + +<span id="copyright"> + <img src="img/eclipse_foundation_logo_tiny.png" height="20px" alt="Eclipse Foundation Logo" align="top"/> + <span >Copyright © 2017, 2022 Oracle and/or its affiliates. All rights reserved.</span> +</span> + +</body> +</html>
diff --git a/tck-docs/userguide/src/main/jbake/templates/header.ftl b/tck-docs/userguide/src/main/jbake/templates/header.ftl new file mode 100644 index 0000000..50b72ae --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/templates/header.ftl
@@ -0,0 +1,54 @@ +<!DOCTYPE html> +<#-- a header template fragment included in the page template --> +<html lang="en"> + <head> + <meta charset="utf-8"/> + <title><#if (content.title)??><#escape x as x?xml>${content.title}</#escape></#if></title> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> + <link href="<#if (content.rootpath)??>${content.rootpath}<#else></#if>css/style.css" rel="stylesheet"> + <script src="https://use.fontawesome.com/96c4d89611.js"></script> + </head> + <body> +<table id="doc-title" cellspacing="0" cellpadding="0"> + <tr> + <td align="left" valign="top"> + <b>${content.title}</b><br /> + </td> + </tr> +</table> +<hr /> + +<table width="90%" id="top-nav" cellspacing="0" cellpadding="0"> + <colgroup> + <col width="12%"/> + <col width="12%"/> + <col width="*"/> + </colgroup> + <tr> + <#if content.prev??> + <td align="left"> + <a href="${content.prev}"> + <span class="vector-font"><i class="fa fa-arrow-circle-left" aria-hidden="true"></i></span> + <span style="position:relative;top:-2px;">Previous</span> + </a> + </td> + </#if> + + <#if content.next??> + <td align="left"> + <a href="${content.next}"> + <span class=" vector-font"><i class="fa fa-arrow-circle-right vector-font" aria-hidden="true"></i></span> + <span style="position:relative;top:-2px;">Next</span> + </a> + </td> + </#if> + + <td align="right"> + <a href="toc.html"> + <span class=" vector-font"><i class="fa fa-list vector-font" aria-hidden="true"></i></span> + <span style="position:relative;top:-2px;">Contents</span> + </a> + </td> + </tr> +</table> +
diff --git a/tck-docs/userguide/src/main/jbake/templates/menu.ftl b/tck-docs/userguide/src/main/jbake/templates/menu.ftl new file mode 100644 index 0000000..888c03d --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/templates/menu.ftl
@@ -0,0 +1 @@ +<#-- a menu bar template fragment included in the page template --> \ No newline at end of file
diff --git a/tck-docs/userguide/src/main/jbake/templates/page.ftl b/tck-docs/userguide/src/main/jbake/templates/page.ftl new file mode 100644 index 0000000..eca51db --- /dev/null +++ b/tck-docs/userguide/src/main/jbake/templates/page.ftl
@@ -0,0 +1,8 @@ +<#-- a top level page layout template --> + +<#include "header.ftl"> +<#include "menu.ftl"> + +${content.body} + +<#include "footer.ftl"> \ No newline at end of file
diff --git a/tck-docs/userguide/src/theme/jakartaee-theme.yml b/tck-docs/userguide/src/theme/jakartaee-theme.yml new file mode 100644 index 0000000..6092a2f --- /dev/null +++ b/tck-docs/userguide/src/theme/jakartaee-theme.yml
@@ -0,0 +1,299 @@ +# +# Following is the asciidoctor-pdf default theme [1], with small +# customizations, mostly for header and footer, marked "EE". +# +# [1] https://github.com/asciidoctor/asciidoctor-pdf/blob/master/data/themes/default-theme.yml +# +font: + catalog: + # Noto Serif supports Latin, Latin-1 Supplement, Latin Extended-A, Greek, Cyrillic, Vietnamese & an assortment of symbols + Noto Serif: + normal: notoserif-regular-subset.ttf + bold: notoserif-bold-subset.ttf + italic: notoserif-italic-subset.ttf + bold_italic: notoserif-bold_italic-subset.ttf + # M+ 1mn supports ASCII and the circled numbers used for conums + M+ 1mn: + normal: mplus1mn-regular-ascii-conums.ttf + bold: mplus1mn-bold-ascii.ttf + italic: mplus1mn-italic-ascii.ttf + bold_italic: mplus1mn-bold_italic-ascii.ttf + # M+ 1p supports Latin, Latin-1 Supplement, Latin Extended, Greek, Cyrillic, Vietnamese, Japanese & an assortment of symbols + # It also provides arrows for ->, <-, => and <= replacements in case these glyphs are missing from font + M+ 1p Fallback: + normal: mplus1p-regular-fallback.ttf + bold: mplus1p-regular-fallback.ttf + italic: mplus1p-regular-fallback.ttf + bold_italic: mplus1p-regular-fallback.ttf + fallbacks: + - M+ 1p Fallback +page: + background_color: ffffff + layout: portrait + margin: [0.5in, 0.67in, 0.67in, 0.67in] + # margin_inner and margin_outer keys are used for recto/verso print margins when media=prepress + margin_inner: 0.75in + margin_outer: 0.59in + #size: A4 # EE + size: Letter # EE +base: + align: justify + # color as hex string (leading # is optional) + font_color: 333333 + # color as RGB array + #font_color: [51, 51, 51] + # color as CMYK array (approximated) + #font_color: [0, 0, 0, 0.92] + #font_color: [0, 0, 0, 92%] + font_family: Noto Serif + # choose one of these font_size/line_height_length combinations + #font_size: 14 + #line_height_length: 20 + #font_size: 11.25 + #line_height_length: 18 + #font_size: 11.2 + #line_height_length: 16 + font_size: 10.5 + #line_height_length: 15 + # correct line height for Noto Serif metrics + line_height_length: 12 + #font_size: 11.25 + #line_height_length: 18 + line_height: $base_line_height_length / $base_font_size + font_size_large: round($base_font_size * 1.25) + font_size_small: round($base_font_size * 0.85) + font_size_min: $base_font_size * 0.75 + font_style: normal + border_color: eeeeee + border_radius: 4 + border_width: 0.5 +# FIXME vertical_rhythm is weird; we should think in terms of ems +#vertical_rhythm: $base_line_height_length * 2 / 3 +# correct line height for Noto Serif metrics (comes with built-in line height) +vertical_rhythm: $base_line_height_length +horizontal_rhythm: $base_line_height_length +# QUESTION should vertical_spacing be block_spacing instead? +vertical_spacing: $vertical_rhythm +link: + font_color: 428bca +# literal is currently used for inline monospaced in prose and table cells +literal: + font_color: b12146 + font_family: M+ 1mn +menu_caret_content: " <font size=\"1.15em\"><color rgb=\"b12146\">\u203a</color></font> " +heading: + align: left + #font_color: 181818 + font_color: $base_font_color + font_family: $base_font_family + font_style: bold + # h1 is used for part titles (book doctype) or the doctitle (article doctype) + #h1_font_size: floor($base_font_size * 2.6) # EE + h1_font_size: floor($base_font_size * 2.5) # EE, squeeze title onto one line + # h2 is used for chapter titles (book doctype only) + h2_font_size: floor($base_font_size * 2.15) + h3_font_size: round($base_font_size * 1.7) + h4_font_size: $base_font_size_large + h5_font_size: $base_font_size + h6_font_size: $base_font_size_small + #line_height: 1.4 + # correct line height for Noto Serif metrics (comes with built-in line height) + line_height: 1 + margin_top: $vertical_rhythm * 0.4 + margin_bottom: $vertical_rhythm * 0.9 +title_page: + align: right + logo: + top: 10% + title: + top: 55% + font_size: $heading_h1_font_size + font_color: 999999 + line_height: 0.9 + subtitle: + font_size: $heading_h3_font_size + font_style: bold_italic + line_height: 1 + authors: + margin_top: $base_font_size * 1.25 + font_size: $base_font_size_large + font_color: 181818 + revision: + margin_top: $base_font_size * 1.25 +block: + margin_top: 0 + margin_bottom: $vertical_rhythm +caption: + align: left + font_size: $base_font_size * 0.95 + font_style: italic + # FIXME perhaps set line_height instead of / in addition to margins? + margin_inside: $vertical_rhythm / 3 + #margin_inside: $vertical_rhythm / 4 + margin_outside: 0 +lead: + font_size: $base_font_size_large + line_height: 1.4 +abstract: + font_color: 5c6266 + font_size: $lead_font_size + line_height: $lead_line_height + font_style: italic + first_line_font_style: bold + title: + align: center + font_color: $heading_font_color + font_family: $heading_font_family + font_size: $heading_h4_font_size + font_style: $heading_font_style +admonition: + column_rule_color: $base_border_color + column_rule_width: $base_border_width + padding: [0, $horizontal_rhythm, 0, $horizontal_rhythm] + #icon: + # tip: + # name: fa-lightbulb-o + # stroke_color: 111111 + # size: 24 + label: + text_transform: uppercase + font_style: bold +blockquote: + font_color: $base_font_color + font_size: $base_font_size_large + border_color: $base_border_color + border_width: 5 + # FIXME disable negative padding bottom once margin collapsing is implemented + padding: [0, $horizontal_rhythm, $block_margin_bottom * -0.75, $horizontal_rhythm + $blockquote_border_width / 2] + cite_font_size: $base_font_size_small + cite_font_color: 999999 +# code is used for source blocks (perhaps change to source or listing?) +code: + font_color: $base_font_color + font_family: $literal_font_family + font_size: ceil($base_font_size) + padding: $code_font_size + line_height: 1.25 + # line_gap is an experimental property to control how a background color is applied to an inline block element + line_gap: 3.8 + background_color: f5f5f5 + border_color: cccccc + border_radius: $base_border_radius + border_width: 0.75 +conum: + font_family: M+ 1mn + font_color: $literal_font_color + font_size: $base_font_size + line_height: 4 / 3 +example: + border_color: $base_border_color + border_radius: $base_border_radius + border_width: 0.75 + background_color: ffffff + # FIXME reenable padding bottom once margin collapsing is implemented + padding: [$vertical_rhythm, $horizontal_rhythm, 0, $horizontal_rhythm] +image: + align: left +prose: + margin_top: $block_margin_top + margin_bottom: $block_margin_bottom +sidebar: + background_color: eeeeee + border_color: e1e1e1 + border_radius: $base_border_radius + border_width: $base_border_width + # FIXME reenable padding bottom once margin collapsing is implemented + padding: [$vertical_rhythm, $vertical_rhythm * 1.25, 0, $vertical_rhythm * 1.25] + title: + align: center + font_color: $heading_font_color + font_family: $heading_font_family + font_size: $heading_h4_font_size + font_style: $heading_font_style +thematic_break: + border_color: $base_border_color + border_style: solid + border_width: $base_border_width + margin_top: $vertical_rhythm * 0.5 + margin_bottom: $vertical_rhythm * 1.5 +description_list: + term_font_style: bold + term_spacing: $vertical_rhythm / 4 + description_indent: $horizontal_rhythm * 1.25 +outline_list: + indent: $horizontal_rhythm * 1.5 + #marker_font_color: 404040 + # NOTE outline_list_item_spacing applies to list items that do not have complex content + item_spacing: $vertical_rhythm / 2 +table: + background_color: $page_background_color + #head_background_color: <hex value> + #head_font_color: $base_font_color + head_font_style: bold + #body_background_color: <hex value> + body_stripe_background_color: f9f9f9 + foot_background_color: f0f0f0 + border_color: dddddd + border_width: $base_border_width + cell_padding: 3 +toc: + indent: $horizontal_rhythm + line_height: 1.4 + dot_leader: + #content: ". " + font_color: a9a9a9 + #levels: 2 3 +# NOTE in addition to footer, header is also supported +footer: + font_size: $base_font_size_small + # NOTE if background_color is set, background and border will span width of page + #border_color: dddddd # EE + #border_width: 0.25 # EE + height: $base_line_height_length * 2.5 + line_height: 1 + padding: [$base_line_height_length / 2, 1, 0, 1] + vertical_align: top + #image_vertical_align: <alignment> or <number> + # additional attributes for content: + # * {page-count} + # * {page-number} + # * {document-title} + # * {document-subtitle} + # * {chapter-title} + # * {section-title} + # * {section-or-chapter-title} + recto: + #columns: "<50% =0% >50%" + right: + #content: '{page-number}' # EE + #content: '{section-or-chapter-title} | {page-number}' + #content: '{document-title} | {page-number}' + content: '{document-title}{nbsp}{nbsp}{nbsp} *{page-number}*' # EE + #center: + # content: '{page-number}' + left: # EE + content: '{status}' # EE + verso: + #columns: $footer_recto_columns + left: + #content: $footer_recto_right_content # EE + #content: '{page-number} | {chapter-title}' + content: '*{page-number}* {nbsp}{nbsp}{nbsp}{document-title}' # EE + #center: + # content: '{page-number}' + right: # EE + content: '{status}' # EE +header: # EE + font_size: $base_font_size_small # EE + border_color: dddddd # EE + border_width: 0.25 # EE + height: $base_line_height_length * 2.5 # EE + line_height: 1 # EE + padding: [$base_line_height_length / 2, 1, 0, 1] # EE + vertical_align: top # EE + recto: # EE + right: # EE + content: '{section-or-chapter-title}' # EE + verso: # EE + left: # EE + content: '{section-or-chapter-title}' # EE
diff --git a/tck/pom.xml b/tck/pom.xml new file mode 100644 index 0000000..d7990a7 --- /dev/null +++ b/tck/pom.xml
@@ -0,0 +1,180 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2020 IBM and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> + +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <parent> + <groupId>org.eclipse.ee4j</groupId> + <artifactId>project</artifactId> + <version>1.0.7</version> + </parent> + + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-tck</artifactId> + <version>3.0.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <name>JSON-B TCK</name> + <description>Jakarta JSON Binding TCK Tests</description> + + <licenses> + <license> + <name>Eclipse Public License 2.0</name> + <url>https://projects.eclipse.org/license/epl-2.0</url> + <distribution>repo</distribution> + </license> + <license> + <name>GNU General Public License, version 2 with the GNU Classpath Exception</name> + <url>https://projects.eclipse.org/license/secondary-gpl-2.0-cp</url> + <distribution>repo</distribution> + </license> + </licenses> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.target>11</maven.compiler.target> + <maven.compiler.source>11</maven.compiler.source> + </properties> + + <dependencies> + <dependency> + <groupId>jakarta.json.bind</groupId> + <artifactId>jakarta.json.bind-api</artifactId> + <version>3.0.0-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.json</groupId> + <artifactId>jakarta.json-api</artifactId> + <version>2.1.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.inject</groupId> + <artifactId>jakarta.inject-api</artifactId> + <version>2.0.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>jakarta.enterprise</groupId> + <artifactId>jakarta.enterprise.cdi-api</artifactId> + <version>3.0.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-api</artifactId> + <version>5.6.2</version> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter-engine</artifactId> + <version>5.6.2</version> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest</artifactId> + <version>2.2</version> + </dependency> + <dependency> + <groupId>org.netbeans.tools</groupId> + <artifactId>sigtest-maven-plugin</artifactId> + <version>1.4</version> + </dependency> + </dependencies> + + <!-- TODO: Temporarily enable snapshot repository --> + <repositories> + <repository> + <id>jakarta-snapshots</id> + <url>https://jakarta.oss.sonatype.org/content/repositories/staging/</url> + </repository> + </repositories> + + + <build> + <plugins> + <!-- + <plugin> + <groupId>org.netbeans.tools</groupId> + <artifactId>sigtest-maven-plugin</artifactId> + <version>1.4</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + <configuration> + <FileName>${project.build.directory}/jakarta.json.bind.sig_${version}</FileName> + <packages>"jakarta.json.bind","jakarta.json.bind.adapter","jakarta.json.bind.annotation","jakarta.json.bind.config","jakarta.json.bind.serializer","jakarta.json.bind.spi"</packages> + </configuration> + </plugin> + --> + <plugin> + <artifactId>maven-javadoc-plugin</artifactId> + <configuration> + <doclint>none</doclint> + </configuration> + </plugin> + <plugin> + <groupId>org.glassfish.copyright</groupId> + <artifactId>glassfish-copyright-maven-plugin</artifactId> + <version>2.4</version> + <configuration> + <excludeFile>${basedir}/../etc/config/copyright-exclude</excludeFile> + <scm>git</scm> + <debug>false</debug> + <scmOnly>true</scmOnly> + <warn>false</warn> + <!-- for use with repair --> + <update>false</update> + <!-- check that year is correct --> + <ignoreYear>false</ignoreYear> + <templateFile>${basedir}/../etc/config/epl-copyright.txt</templateFile> + <bsdTemplateFile>${basedir}/../etc/config/edl-copyright.txt</bsdTemplateFile> + </configuration> + <executions> + <execution> + <goals> + <goal>copyright</goal> + <goal>check</goal> + </goals> + <phase>compile</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <goals> + <goal>jar-no-fork</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project>
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/MappingTester.java b/tck/src/main/java/ee/jakarta/tck/json/bind/MappingTester.java new file mode 100644 index 0000000..f4c77ec --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/MappingTester.java
@@ -0,0 +1,348 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.lang.reflect.Type; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.nio.charset.StandardCharsets; +import java.util.function.BiPredicate; +import java.util.regex.Pattern; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +public class MappingTester<T> { + private static final String JSON_PATTERN_PREFIX = "\\{\\s*"; + + private static final String JSON_PATTERN_PROPERTY = "\"instance\"\\s*:\\s*"; + + private static final String JSON_PATTERN_SUFFIX = "\\s*\\}"; + + private static final String JSON_PREFIX = "{ "; + + private static final String JSON_PROPERTY = "\"instance\" : "; + + private static final String JSON_SUFFIX = " }"; + + // 53 means max bit value of number with sign bit included + private static final int MAX_BIT_SIZE = 53; + + // -1022 is the lowest range of the exponent + // more https://en.wikipedia.org/wiki/Exponent_bias + private static final int MIN_RANGE = -1022; + + // 1023 is the highest range of the exponent + // more https://en.wikipedia.org/wiki/Exponent_bias + private static final int MAX_RANGE = 1023; + + private final Jsonb jsonb = JsonbBuilder.create(); + + private final Class<? extends TypeContainer<T>> typeContainerClass; + + private final boolean nillable; + + private T testValue; + + private BiPredicate<T, T> testUnmarshall = Object::equals; + + private String fixedRegExp = null; + + public MappingTester(Class<? extends TypeContainer<T>> typeContainerClass) { + this(typeContainerClass, true); + } + + public MappingTester(Class<? extends TypeContainer<T>> typeContainerClass, + boolean nillable) { + this.typeContainerClass = typeContainerClass; + this.nillable = nillable; + } + + public void test(T value, String expectedRepresentation) { + try { + this.testValue = value; + testMarshalling(value, expectedRepresentation); + testMarshallingToStream(value, expectedRepresentation); + testMarshallingToWriter(value, expectedRepresentation); + testMarshallingByType(value, expectedRepresentation); + testMarshallingByTypeToStream(value, expectedRepresentation); + testMarshallingByTypeToWriter(value, expectedRepresentation); + testUnmarshallingByClass(value, expectedRepresentation); + testUnmarshallingByClassFromStream(value, expectedRepresentation); + testUnmarshallingByClassFromReader(value, expectedRepresentation); + testUnmarshallingByType(value, expectedRepresentation); + testUnmarshallingByTypeFromStream(value, expectedRepresentation); + testUnmarshallingByTypeFromReader(value, expectedRepresentation); + } catch (IllegalAccessException | InstantiationException e) { + fail(e.getMessage()); + } + } + + private String getExpectedJsonString(String expectedRepresentation) { + if (nillable || !expectedRepresentation.isEmpty()) { + return JSON_PATTERN_PREFIX + JSON_PATTERN_PROPERTY + + fixExpectedRepresentation(expectedRepresentation) + + JSON_PATTERN_SUFFIX; + } else { + return JSON_PATTERN_PREFIX + JSON_PATTERN_SUFFIX; + } + } + + private String getJsonString(String expectedRepresentation) { + if (nillable || !expectedRepresentation.isEmpty()) { + return JSON_PREFIX + JSON_PROPERTY + expectedRepresentation + JSON_SUFFIX; + } else { + return JSON_PREFIX + JSON_SUFFIX; + } + } + + private String fixExpectedRepresentation(String representation) { + // JSON cannot parse regexp, but the test is about to check for regexp + if (fixedRegExp != null) { + return fixedRegExp; + } + // value Float.MAX_VALUE can have E38 or E+38, depending on impl + representation = representation.replace("E38", "E[\\+]?\\+38"); + if (!Number.class.isInstance(testValue)) { + representation = Pattern.quote(representation); + // quote numbers that do not fit into double decimal precision + } else { + if (Long.class.isInstance(testValue)) { + Long longTestValue = Long.class.cast(testValue); + if (!isIEEE754(BigDecimal.valueOf(longTestValue))) { + representation = quote(representation); + } + } else if (BigDecimal.class.isInstance(testValue)) { + if (!isIEEE754((BigDecimal) testValue)) { + representation = quote(representation); + } + } else if (BigInteger.class.isInstance(testValue)) { + if (!isIEEE754(new BigDecimal((BigInteger) testValue))) { + representation = quote(representation); + } + } + } + return representation; + } + + private void testMarshalling(T value, String expectedRepresentation) + throws IllegalAccessException, InstantiationException { + TypeContainer<T> container = typeContainerClass.newInstance(); + container.setInstance(value); + + String jsonString = jsonb.toJson(container); + String validationMessage = "[testMarshalling] - Failed to correctly marshal " + + value.getClass().getName() + " property with value " + value; + assertThat(validationMessage, jsonString, matchesPattern(getExpectedJsonString(expectedRepresentation))); + } + + private void testMarshallingToStream(T value, String expectedRepresentation) + throws IllegalAccessException, InstantiationException { + TypeContainer<T> container = typeContainerClass.newInstance(); + container.setInstance(value); + + try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { + jsonb.toJson(container, stream); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + String validationMessage = "[testMarshallingToStream] - Failed to correctly marshal " + + value.getClass().getName() + " property with value " + value; + assertThat(validationMessage, jsonString, matchesPattern(getExpectedJsonString(expectedRepresentation))); + } catch (IOException e) { + fail(); + } + } + + private void testMarshallingToWriter(T value, String expectedRepresentation) + throws IllegalAccessException, InstantiationException { + TypeContainer<T> container = typeContainerClass.newInstance(); + container.setInstance(value); + + try (ByteArrayOutputStream stream = new ByteArrayOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(stream, StandardCharsets.UTF_8)) { + jsonb.toJson(container, writer); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + String validationMessage = "[testMarshallingToStream] - Failed to correctly marshal " + + value.getClass().getName() + " property with value " + value; + assertThat(validationMessage, jsonString, matchesPattern(getExpectedJsonString(expectedRepresentation))); + } catch (IOException e) { + fail(); + } + } + + private void testMarshallingByType(T value, String expectedRepresentation) + throws IllegalAccessException, InstantiationException { + TypeContainer<T> container = typeContainerClass.newInstance(); + container.setInstance(value); + + String jsonString = jsonb.toJson(container, TypeContainer.class); + String validationMessage = "[testMarshallingByType] - Failed to correctly marshal " + + value.getClass().getName() + " property with value " + value; + assertThat(validationMessage, jsonString, matchesPattern(getExpectedJsonString(expectedRepresentation))); + } + + private void testMarshallingByTypeToStream(T value, String expectedRepresentation) + throws IllegalAccessException, InstantiationException { + TypeContainer<T> container = typeContainerClass.newInstance(); + container.setInstance(value); + + try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { + jsonb.toJson(container, TypeContainer.class, stream); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + String validationMessage = "[testMarshallingByTypeToStream] - Failed to correctly marshal " + + value.getClass().getName() + " property with value " + value; + assertThat(validationMessage, jsonString, matchesPattern(getExpectedJsonString(expectedRepresentation))); + } catch (IOException e) { + fail(); + } + } + + private void testMarshallingByTypeToWriter(T value, String expectedRepresentation) + throws IllegalAccessException, InstantiationException { + TypeContainer<T> container = typeContainerClass.newInstance(); + container.setInstance(value); + + try (ByteArrayOutputStream stream = new ByteArrayOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(stream, StandardCharsets.UTF_8)) { + + jsonb.toJson(container, TypeContainer.class, writer); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + String validationMessage = "[testMarshallingByTypeToWriter] - Failed to correctly marshal " + + value.getClass().getName() + " property with value " + value; + assertThat(validationMessage, jsonString, matchesPattern(getExpectedJsonString(expectedRepresentation))); + } catch (IOException e) { + fail(); + } + } + + private void testUnmarshallingByClass(T value, + String expectedRepresentation) { + String jsonString = getJsonString(expectedRepresentation); + + TypeContainer<T> typeContainer = jsonb.fromJson(jsonString, typeContainerClass); + String validationMessage = "[testUnmarshallingByClass] - Failed to correctly unmarshal " + + value.getClass().getName() + " property with value " + value; + assertTrue(testUnmarshall(value, typeContainer.getInstance()), validationMessage); + } + + private void testUnmarshallingByClassFromStream(T value, String expectedRepresentation) { + String jsonString = getJsonString(expectedRepresentation); + try (ByteArrayInputStream stream = new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8))) { + TypeContainer<T> typeContainer = jsonb.fromJson(stream, typeContainerClass); + String validationMessage = "[testUnmarshallingByClassFromStream] - Failed to correctly unmarshal " + + value.getClass().getName() + " property with value " + value; + assertTrue(testUnmarshall(value, typeContainer.getInstance()), validationMessage); + } catch (IOException e) { + fail(); + } + } + + private void testUnmarshallingByClassFromReader(T value, String expectedRepresentation) { + String jsonString = getJsonString(expectedRepresentation); + try (ByteArrayInputStream stream = new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8)); + InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { + + TypeContainer<T> typeContainer = jsonb.fromJson(reader, typeContainerClass); + String validationMessage = "[testUnmarshallingByClassFromReader] - Failed to correctly unmarshal " + + value.getClass().getName() + " property with value " + value; + assertTrue(testUnmarshall(value, typeContainer.getInstance()), validationMessage); + } catch (IOException e) { + fail(); + } + } + + private void testUnmarshallingByType(T value, String expectedRepresentation) { + String jsonString = getJsonString(expectedRepresentation); + + TypeContainer<T> typeContainer = jsonb.fromJson(jsonString, (Type) typeContainerClass); + String validationMessage = "[testUnmarshallingByType] - Failed to correctly unmarshal " + + value.getClass().getName() + " property with value " + value; + assertTrue(testUnmarshall(value, typeContainer.getInstance()), validationMessage); + } + + private void testUnmarshallingByTypeFromStream(T value, String expectedRepresentation) { + String jsonString = getJsonString(expectedRepresentation); + try (ByteArrayInputStream stream = new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8))) { + TypeContainer<T> typeContainer = jsonb.fromJson(stream, (Type) typeContainerClass); + String validationMessage = "[testUnmarshallingByTypeFromStream] - Failed to correctly unmarshal " + + value.getClass().getName() + " property with value " + value; + assertTrue(testUnmarshall(value, typeContainer.getInstance()), validationMessage); + } catch (IOException e) { + fail(); + } + } + + private void testUnmarshallingByTypeFromReader(T value, String expectedRepresentation) { + String jsonString = getJsonString(expectedRepresentation); + try (ByteArrayInputStream stream = new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8)); + InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8)) { + + TypeContainer<T> typeContainer = jsonb.fromJson(reader, (Type) typeContainerClass); + String validationMessage = "[testUnmarshallingByTypeFromReader] - Failed to correctly unmarshal " + + value.getClass().getName() + " property with value " + value; + assertTrue(testUnmarshall(value, typeContainer.getInstance()), validationMessage); + } catch (IOException e) { + fail(); + } + } + + protected boolean testUnmarshall(T value, T fromJson) { + return testUnmarshall.test(value, fromJson); + } + + public MappingTester<T> setUnmarshallTestPredicate( + BiPredicate<T, T> testPredicate) { + this.testUnmarshall = testPredicate; + return this; + } + + public MappingTester<T> setMarshallExpectedRegExp(String regExp) { + this.fixedRegExp = regExp; + return this; + } + + /** + * Checks whether the value of {@link BigDecimal} matches format IEEE-754 + * + * @param value value which is going to be checked + * @return true if value matches format IEEE-754 + */ + private static boolean isIEEE754(BigDecimal value) { + // scale of the number + int scale = value.scale(); + // bit value of number without scale + int valBits = value.unscaledValue().abs().bitLength(); + // bit value of scaled number + int intBitsScaled = value.toBigInteger().bitLength(); + // Number whose bit length is than 53 or is not in range is considered as non + // IEEE 754-2008 binary64 compliant + return valBits <= MAX_BIT_SIZE && intBitsScaled <= MAX_BIT_SIZE && MIN_RANGE <= scale && scale <= MAX_RANGE; + } + + private String quote(String value) { + return '"' + value + '"'; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/SimpleMappingTester.java b/tck/src/main/java/ee/jakarta/tck/json/bind/SimpleMappingTester.java new file mode 100644 index 0000000..b40d3f8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/SimpleMappingTester.java
@@ -0,0 +1,182 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.util.Objects; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.jupiter.api.Assertions.fail; + +public class SimpleMappingTester<T> { + private final Jsonb jsonb = JsonbBuilder.create(); + + private final Class<T> typeClass; + private final Class<? super T> serializationType; + + public SimpleMappingTester(Class<T> typeClass, Class<? super T> serializationType) { + this.typeClass = Objects.requireNonNull(typeClass); + this.serializationType = Objects.requireNonNull(serializationType); + } + + public void test(T value, String expectedRepresentationPattern, + String expectedRepresentation, Object expectedOutput) { + testMarshalling(value, expectedRepresentationPattern); + testMarshallingToStream(value, expectedRepresentationPattern); + testMarshallingToWriter(value, expectedRepresentationPattern); + testMarshallingByType(value, expectedRepresentationPattern); + testMarshallingByTypeToStream(value, expectedRepresentationPattern); + testMarshallingByTypeToWriter(value, expectedRepresentationPattern); + testUnmarshallingByClass(expectedRepresentation, expectedOutput); + testUnmarshallingByClassFromStream(expectedRepresentation, + expectedOutput); + testUnmarshallingByClassFromReader(expectedRepresentation, + expectedOutput); + testUnmarshallingByType(expectedRepresentation, expectedOutput); + testUnmarshallingByTypeFromStream(expectedRepresentation, + expectedOutput); + testUnmarshallingByTypeFromReader(expectedRepresentation, + expectedOutput); + } + + private void testMarshalling(T value, String expectedRepresentation) { + String jsonString = jsonb.toJson(value); + assertThat("[testMarshalling] - Failed to correctly marshal " + value.getClass().getName() + " object", + jsonString, matchesPattern(expectedRepresentation)); + } + + private void testMarshallingToStream(T value, String expectedRepresentation) { + try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { + jsonb.toJson(value, stream); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + assertThat("[testMarshallingToStream] - Failed to correctly marshal " + value.getClass().getName() + " object", + jsonString, matchesPattern(expectedRepresentation)); + } catch (IOException e) { + fail(e.getMessage(), e); + } + } + + private void testMarshallingToWriter(T value, String expectedRepresentation) { + try (ByteArrayOutputStream stream = new ByteArrayOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(stream)) { + jsonb.toJson(value, writer); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + assertThat("[testMarshallingToWriter] - Failed to correctly marshal " + value.getClass().getName() + " object", + jsonString, matchesPattern(expectedRepresentation)); + } catch (IOException e) { + fail(e.getMessage(), e); + } + } + + private void testMarshallingByType(T value, String expectedRepresentation) { + String jsonString = jsonb.toJson(value, serializationType); + assertThat("[testMarshallingByType] - Failed to correctly marshal " + value.getClass().getName() + " object", + jsonString, matchesPattern(expectedRepresentation)); + } + + private void testMarshallingByTypeToStream(T value, String expectedRepresentation) { + try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { + jsonb.toJson(value, serializationType, stream); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + assertThat("[testMarshallingByTypeToStream] - Failed to correctly marshal " + value.getClass().getName() + " object", + jsonString, matchesPattern(expectedRepresentation)); + } catch (IOException e) { + fail(e.getMessage(), e); + } + } + + private void testMarshallingByTypeToWriter(T value, String expectedRepresentation) { + try (ByteArrayOutputStream stream = new ByteArrayOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(stream)) { + jsonb.toJson(value, serializationType, writer); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + assertThat("[testMarshallingByTypeToWriter] - Failed to correctly marshal " + value.getClass().getName() + " object", + jsonString, matchesPattern(expectedRepresentation)); + } catch (IOException e) { + fail(e.getMessage(), e); + } + } + + private void testUnmarshallingByClass(String expectedRepresentation, Object value) { + Object unmarshalledObject = jsonb.fromJson(expectedRepresentation, typeClass); + assertThat("[testUnmarshallingByClass] - Failed to correctly unmarshal " + value.getClass().getName() + " object", + unmarshalledObject, is(value)); + } + + private void testUnmarshallingByClassFromStream(String expectedRepresentation, Object value) { + try (ByteArrayInputStream stream = new ByteArrayInputStream(expectedRepresentation.getBytes(StandardCharsets.UTF_8))) { + Object unmarshalledObject = jsonb.fromJson(stream, typeClass); + assertThat("[testUnmarshallingByClassFromStream] - Failed to correctly unmarshal " + value.getClass() + .getName() + " object", + unmarshalledObject, is(value)); + } catch (IOException e) { + fail(e.getMessage(), e); + } + } + + private void testUnmarshallingByClassFromReader(String expectedRepresentation, Object value) { + try (ByteArrayInputStream stream = new ByteArrayInputStream(expectedRepresentation.getBytes(StandardCharsets.UTF_8)); + InputStreamReader reader = new InputStreamReader(stream)) { + Object unmarshalledObject = jsonb.fromJson(reader, typeClass); + assertThat("[testUnmarshallingByClassFromReader] - Failed to correctly unmarshal " + value.getClass() + .getName() + " object", + unmarshalledObject, is(value)); + } catch (IOException e) { + fail(e.getMessage(), e); + } + } + + private void testUnmarshallingByType(String expectedRepresentation, Object value) { + Object unmarshalledObject = jsonb.fromJson(expectedRepresentation, (Type) typeClass); + assertThat("[testUnmarshallingByType] - Failed to correctly unmarshal " + value.getClass().getName() + " object", + unmarshalledObject, is(value)); + } + + private void testUnmarshallingByTypeFromStream(String expectedRepresentation, Object value) { + try (ByteArrayInputStream stream = new ByteArrayInputStream(expectedRepresentation.getBytes(StandardCharsets.UTF_8))) { + Object unmarshalledObject = jsonb.fromJson(stream, (Type) typeClass); + assertThat("[testUnmarshallingByTypeFromStream] - Failed to correctly unmarshal " + value.getClass() + .getName() + " object", + unmarshalledObject, is(value)); + } catch (IOException e) { + fail(e.getMessage(), e); + } + } + + private void testUnmarshallingByTypeFromReader(String expectedRepresentation, Object value) { + try (ByteArrayInputStream stream = new ByteArrayInputStream(expectedRepresentation.getBytes(StandardCharsets.UTF_8)); + InputStreamReader reader = new InputStreamReader(stream)) { + Object unmarshalledObject = jsonb.fromJson(reader, (Type) typeClass); + assertThat("[testUnmarshallingByTypeFromReader] - Failed to correctly unmarshal " + value.getClass() + .getName() + " object", + unmarshalledObject, is(value)); + } catch (IOException e) { + fail(e.getMessage(), e); + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/TypeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/TypeContainer.java new file mode 100644 index 0000000..5be213a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/TypeContainer.java
@@ -0,0 +1,27 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind; + +public interface TypeContainer<T> { + T getInstance(); + + void setInstance(T instance); +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/annotation/AnnotationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/annotation/AnnotationTest.java new file mode 100644 index 0000000..0c9e22b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/annotation/AnnotationTest.java
@@ -0,0 +1,250 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.annotation; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedAdaptedContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedDateContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedDoubleContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedNillableContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedNillablePropertyContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedPropertyOrderContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedPropertyVisibilityContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedSerializedArrayContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleAnnotatedSerializedContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleContainer; +import ee.jakarta.tck.json.bind.api.model.SimplePartiallyAnnotatedPropertyOrderContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources AnnotationTest.java + * @executeClass com.sun.ts.tests.jsonb.api.AnnotationTest + **/ +public class AnnotationTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testJsonbDateFormat + * + * @assertion_ids: JSONB:JAVADOC:57; JSONB:JAVADOC:58 + * + * @test_Strategy: Assert that JsonbDateFormat annotation can be used to + * customize date format + */ + @Test + public void testJsonbDateFormat() { + String jsonString = jsonb.toJson(new SimpleAnnotatedDateContainer()); + assertThat(jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Do(\\.?), 01 Jan(\\.?) 1970\"\\s*}")); + } + + /* + * @testName: testJsonbNillable + * + * @assertion_ids: JSONB:JAVADOC:59 + * + * @test_Strategy: Assert that JsonbNillable annotation can be used to enable + * serialization of null values + */ + @Test + public void testJsonbNillable() { + String jsonString = jsonb.toJson(new SimpleAnnotatedNillableContainer()); + assertThat("Failed to enable serialization of null values using JsonbNillable annotation.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*null\\s*}")); + } + + /* + * @testName: testJsonbNumberFormat + * + * @assertion_ids: JSONB:JAVADOC:60; JSONB:JAVADOC:61 + * + * @test_Strategy: Assert that JsonbNumberFormat annotation can be used to + * customize number format + */ + @Test + public void testJsonbNumberFormat() { + String jsonString = jsonb.toJson(new SimpleAnnotatedDoubleContainer()); + assertThat("Failed to customize number format using JsonbNumberFormat annotation.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"123.456,8\"\\s*}")); + } + + /* + * @testName: testJsonbProperty + * + * @assertion_ids: JSONB:JAVADOC:62; JSONB:JAVADOC:63 + * + * @test_Strategy: Assert that JsonbProperty annotation can be used to + * customize property name and enable serialization of null values + */ + @Test + public void testJsonbProperty() { + String jsonString = jsonb.toJson(new SimpleAnnotatedNillablePropertyContainer()); + assertThat("Failed to customize property name and enable serialization of null values using JsonbProperty annotation.", + jsonString, matchesPattern("\\{\\s*\"nillableInstance\"\\s*:\\s*null\\s*}")); + } + + /* + * @testName: testJsonbPropertyOrder + * + * @assertion_ids: JSONB:JAVADOC:64 + * + * @test_Strategy: Assert that JsonbPropertyOrder annotation can be used to + * customize the order in which fields will be serialized + */ + @Test + public void testJsonbPropertyOrder() { + String jsonString = jsonb.toJson(new SimpleAnnotatedPropertyOrderContainer()); + assertThat("Failed to customize the order in which fields will be serialized using JsonbPropertyOrder annotation.", + jsonString, matchesPattern("\\{\\s*\"secondInstance\"\\s*:\\s*\"Second String\"\\s*," + + "\\s*\"firstInstance\"\\s*:\\s*\"First String\"\\s*}")); + } + + /* + * @testName: testJsonbPropertyPartialOrder + * + * @assertion_ids: JSONB:JAVADOC:64 + * + * @test_Strategy: In that case, properties included in annotation declaration + * will be serialized first (in defined order), followed by any properties not + * included in the definition. The order of properties not included in the + * definition is not guaranteed + */ + @Test + public void testJsonbPropertyPartialOrder() { + String jsonString = jsonb.toJson(new SimplePartiallyAnnotatedPropertyOrderContainer()); + assertThat("Failed to order the fields partially defined using JsonbPropertyOrder annotation.", + jsonString, matchesPattern("\\{\\s*\"thirdInstance\"\\s*:\\s*\"Third String\"\\s*," + + "\\s*\"fourthInstance\"\\s*:\\s*\"Fourth String\".*}")); + } + + /* + * @testName: testJsonbTypeAdapter + * + * @assertion_ids: JSONB:JAVADOC:65 + * + * @test_Strategy: Assert that JsonbTypeAdapter annotation can be used to + * configure a JsonbAdapter implementation to provide custom mapping + */ + @Test + public void testJsonbTypeAdapter() { + String jsonString = jsonb.toJson(new SimpleAnnotatedAdaptedContainer() { + { + setInstance(new SimpleContainer() { + { + setInstance("Test String"); + } + }); + } + }); + assertThat( + "Failed to configure a JsonbAdapter implementation to provide custom mapping using JsonbTypeAdapter annotation.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\{\\s*\"instance\"\\s*:\\s*\"Test String Adapted\"\\s*}\\s*}")); + } + + /* + * @testName: testJsonbTypeSerializer + * + * @assertion_ids: JSONB:JAVADOC:66; JSONB:JAVADOC:67; JSONB:JAVADOC:72; + * JSONB:JAVADOC:74; JSONB:JAVADOC:75; JSONB:JAVADOC:76 + * + * @test_Strategy: Assert that JsonbTypeSerializer and JsonbTypeDeserializer + * annotations can be used to configure a JsonbSerializer and + * JsonbDeserializer implementation to provide custom mapping + */ + @Test + public void testJsonbTypeSerializer() { + SimpleAnnotatedSerializedContainer container = new SimpleAnnotatedSerializedContainer(); + SimpleContainer instance = new SimpleContainer(); + instance.setInstance("Test String"); + container.setInstance(instance); + + String jsonString = jsonb.toJson(container); + assertThat("Failed to configure a JsonbSerializer implementation to " + + "provide custom mapping using JsonbTypeSerializer annotation.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\{\\s*\"instance\"\\s*:\\s*\"Test String " + + "Serialized\"\\s*}\\s*}")); + + SimpleAnnotatedSerializedContainer unmarshalledObject = jsonb.fromJson( + "{ \"instance\" : { \"instance\" : \"Test String\" } }", + SimpleAnnotatedSerializedContainer.class); + assertThat("Failed to configure a JsonbDeserializer implementation to " + + "provide custom mapping using JsonbTypeDeserializer annotation.", + unmarshalledObject.getInstance().getInstance(), is("Test String Deserialized")); + } + + /* + * @testName: testJsonbArrayTypeSerializer + * + * @assertion_ids: JSONB:JAVADOC:66; JSONB:JAVADOC:67; JSONB:JAVADOC:73; + * JSONB:JAVADOC:74; JSONB:JAVADOC:75; JSONB:JAVADOC:77 + * + * @test_Strategy: Assert that JsonbTypeSerializer and JsonbTypeDeserializer + * annotations can be used to configure a JsonbSerializer and + * JsonbDeserializer implementation to provide custom mapping for array type + */ + @Test + public void testJsonbArrayTypeSerializer() { + SimpleAnnotatedSerializedArrayContainer container = new SimpleAnnotatedSerializedArrayContainer(); + SimpleContainer instance1 = new SimpleContainer(); + instance1.setInstance("Test String 1"); + SimpleContainer instance2 = new SimpleContainer(); + instance2.setInstance("Test String 2"); + container.setInstance(new SimpleContainer[] {instance1, instance2}); + + String jsonString = jsonb.toJson(container); + assertThat("Failed to configure a JsonbSerializer implementation to " + + "provide custom mapping using JsonbTypeSerializer annotation.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\[\\s*\\{\\s*\"instance\"\\s*:\\s*\"Test String 1\"\\s*}\\s*," + + "\\s*\\{\\s*\"instance\"\\s*:\\s*\"Test String 2\"\\s*}\\s*]\\s*}")); + + SimpleAnnotatedSerializedArrayContainer unmarshalledObject = jsonb.fromJson( + "{ \"instance\" : [ { \"instance\" : \"Test String 1\" }, { \"instance\" : \"Test String 2\" } ] }", + SimpleAnnotatedSerializedArrayContainer.class); + assertThat("Failed to configure a JsonbDeserializer implementation to " + + "provide custom mapping using JsonbTypeDeserializer annotation.", + unmarshalledObject.getInstance()[0].getInstance(), is("Test String 1")); + } + + /* + * @testName: testJsonbVisibility + * + * @assertion_ids: JSONB:JAVADOC:68; JSONB:JAVADOC:70; JSONB:JAVADOC:71 + * + * @test_Strategy: Assert that JsonbVisibility annotation can be used to + * customize field visibility + */ + @Test + public void testJsonbVisibility() { + String jsonString = jsonb.toJson(new SimpleAnnotatedPropertyVisibilityContainer()); + assertThat("Failed to customize fields visibility using JsonbVisibility annotation.", + jsonString, matchesPattern("\\{\\s*\"secondInstance\"\\s*:\\s*\"Second String\"\\s*}")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/builder/JsonbBuilderTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/builder/JsonbBuilderTest.java new file mode 100644 index 0000000..7e0e0b6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/builder/JsonbBuilderTest.java
@@ -0,0 +1,193 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.builder; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.spi.JsonbProvider; +import jakarta.json.spi.JsonProvider; + +import ee.jakarta.tck.json.bind.api.model.SimpleContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.notNullValue; + +/** + * @test + * @sources JsonbBuilderTest.java + * @executeClass com.sun.ts.tests.jsonb.api.JsonbBuilderTest + **/ +public class JsonbBuilderTest { + + /* + * @testName: testBuild + * + * @assertion_ids: JSONB:JAVADOC:25 + * + * @test_Strategy: Assert that JsonbBuilder.build returns a new instance of + * jakarta.json.bind.Jsonb + */ + @Test + public void testBuild() { + Jsonb jsonb = JsonbBuilder.newBuilder().build(); + assertThat("Failed to create a new Jsonb instance using JsonBuilder.build method.", jsonb, notNullValue()); + } + + /* + * @testName: testCreate + * + * @assertion_ids: JSONB:JAVADOC:26 + * + * @test_Strategy: Assert that JsonbBuilder.create returns a new instance of + * jakarta.json.bind.Jsonb + */ + @Test + public void testCreate() { + Jsonb jsonb = JsonbBuilder.create(); + assertThat("Failed to create a new Jsonb instance using JsonBuilder.create method.", jsonb, notNullValue()); + } + + /* + * @testName: testCreateConfig + * + * @assertion_ids: JSONB:JAVADOC:27 + * + * @test_Strategy: Assert that JsonbBuilder.create method with Config argument + * returns a new instance of jakarta.json.bind.Jsonb configured with provided + * configuration + */ + @Test + public void testCreateConfig() { + JsonbConfig jsonbConfig = new JsonbConfig().withNullValues(true); + Jsonb jsonb = JsonbBuilder.create(jsonbConfig); + + String jsonString = jsonb.toJson(new SimpleContainer() { + { + setInstance(null); + } + }); + assertThat("Failed to create a new Jsonb instance using JsonBuilder.create method " + + "with Config argument configured with provided configuration.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*null\\s*}")); + } + + /* + * @testName: testNewBuilder + * + * @assertion_ids: JSONB:JAVADOC:28; JSONB:JAVADOC:80 + * + * @test_Strategy: Assert that JsonbBuilder.newBuilder returns a new + * JsonbBuilder instance as returned by + * jakarta.json.bind.spi.JsonbProvider#provider method + */ + @Test + public void testNewBuilder() { + JsonbBuilder jsonbBuilder = JsonbBuilder.newBuilder(); + String validationMessage = "Failed to create a new Jsonb instance as returned by " + + "jakarta.json.bind.spi.JsonbProvider#provider method using JsonBuilder.newBuilder method."; + assertThat(validationMessage, jsonbBuilder, notNullValue()); + assertThat(validationMessage, jsonbBuilder.getClass(), is(JsonbProvider.provider().create().getClass())); + } + + /* + * @testName: testNewBuilderString + * + * @assertion_ids: JSONB:JAVADOC:29; JSONB:JAVADOC:80; JSONB:JAVADOC:81 + * + * @test_Strategy: Assert that JsonbBuilder.newBuilder method with String + * argument returns a new JsonbBuilder instance as returned by + * jakarta.json.bind.spi.JsonbProvider#provider(String) method + */ + @Test + public void testNewBuilderString() { + JsonbBuilder jsonbBuilder = JsonbBuilder.newBuilder(JsonbProvider.provider().getClass().getName()); + String validationMessage = "Failed to create a new Jsonb instance as returned by " + + "jakarta.json.bind.spi.JsonbProvider#provider(String) method using JsonBuilder.newBuilder method with String " + + "argument."; + assertThat(validationMessage, jsonbBuilder, notNullValue()); + + Class<?> clazz = JsonbProvider.provider(JsonbProvider.provider().getClass().getName()).create().getClass(); + assertThat(validationMessage, jsonbBuilder.getClass(), is(clazz)); + } + + /* + * @testName: testNewBuilderProvider + * + * @assertion_ids: JSONB:JAVADOC:30; JSONB:JAVADOC:78; JSONB:JAVADOC:80 + * + * @test_Strategy: Assert that JsonbBuilder.newBuilder method with + * JsonbProvider argument returns a new JsonbBuilder instance as returned by + * provider#create method + */ + @Test + public void testNewBuilderProvider() { + JsonbBuilder jsonbBuilder = JsonbBuilder.newBuilder(JsonbProvider.provider()); + + String validationMessage = "Failed to create a new Jsonb instance as returned by provider#create " + + "method using JsonBuilder.newBuilder method with JsonbProvider argument."; + assertThat(validationMessage, jsonbBuilder, notNullValue()); + assertThat(validationMessage, jsonbBuilder.getClass(), is(JsonbProvider.provider().create().getClass())); + } + + /* + * @testName: testWithConfig + * + * @assertion_ids: JSONB:JAVADOC:31 + * + * @test_Strategy: Assert that JsonbBuilder.withConfig method with JsonbConfig + * argument returns a new JsonbBuilder instance configured with configuration + * passed as an argument + */ + @Test + public void testWithConfig() { + JsonbConfig jsonbConfig = new JsonbConfig().withNullValues(true); + Jsonb jsonb = JsonbBuilder.newBuilder().withConfig(jsonbConfig).build(); + + String jsonString = jsonb.toJson(new SimpleContainer() { + { + setInstance(null); + } + }); + assertThat("Failed to apply configuration passed as an argument to JsonbBuilder.withConfig method.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*null\\s*}")); + } + + /* + * @testName: testWithProvider + * + * @assertion_ids: JSONB:JAVADOC:32; JSONB:JAVADOC:80 + * + * @test_Strategy: Assert that JsonbBuilder.withProvider method with + * JsonProvider argument returns a new JsonbBuilder instance using the + * JsonProvider passed as an argument + */ + @Test + public void testWithProvider() { + JsonbBuilder jsonbBuilder = JsonbBuilder.newBuilder().withProvider(JsonProvider.provider()); + assertThat("Failed to create a new JsonbBuilder instance using a specific " + + "JsonProvider using JsonbBuilder.withProvider method.", + jsonbBuilder, notNullValue()); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/config/JsonbConfigTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/config/JsonbConfigTest.java new file mode 100644 index 0000000..88bdf33 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/config/JsonbConfigTest.java
@@ -0,0 +1,479 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.config; + +import java.util.Locale; +import java.util.Map; +import java.util.Optional; + +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.adapter.JsonbAdapter; +import jakarta.json.bind.config.BinaryDataStrategy; +import jakarta.json.bind.config.PropertyNamingStrategy; +import jakarta.json.bind.config.PropertyOrderStrategy; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.bind.serializer.JsonbSerializer; + +import ee.jakarta.tck.json.bind.api.model.SimpleContainerDeserializer; +import ee.jakarta.tck.json.bind.api.model.SimpleContainerSerializer; +import ee.jakarta.tck.json.bind.api.model.SimpleIntegerAdapter; +import ee.jakarta.tck.json.bind.api.model.SimpleIntegerDeserializer; +import ee.jakarta.tck.json.bind.api.model.SimpleIntegerSerializer; +import ee.jakarta.tck.json.bind.api.model.SimplePropertyNamingStrategy; +import ee.jakarta.tck.json.bind.api.model.SimplePropertyVisibilityStrategy; +import ee.jakarta.tck.json.bind.api.model.SimpleStringAdapter; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasKey; +import static org.hamcrest.Matchers.instanceOf; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * @test + * @sources JsonbConfigTest.java + * @executeClass com.sun.ts.tests.jsonb.api.JsonbConfigTest + **/ +public class JsonbConfigTest { + + /* + * @testName: testGetAsMap + * + * @assertion_ids: JSONB:JAVADOC:33; JSONB:JAVADOC:35 + * + * @test_Strategy: Assert that JsonbConfig.getAsMap returns all configuration + * properties as an unmodifiable map + */ + @Test + public void testGetAsMap() { + JsonbConfig jsonbConfig = new JsonbConfig().withFormatting(true) + .withNullValues(true); + Map<String, Object> configMap = jsonbConfig.getAsMap(); + String validationMessage = "Failed to get configuration properties as a map using JsonbConfig.getAsMap method."; + assertThat(validationMessage, configMap.size(), is(2)); + assertThat(validationMessage, configMap, hasKey(JsonbConfig.FORMATTING)); + assertThat(validationMessage, configMap, hasKey(JsonbConfig.NULL_VALUES)); + + assertThrows(UnsupportedOperationException.class, + () -> configMap.put(JsonbConfig.BINARY_DATA_STRATEGY, BinaryDataStrategy.BASE_64), + "Failed to get configuration properties as an unmodifiable map using JsonbConfig.getAsMap method."); + + } + + /* + * @testName: testGetProperty + * + * @assertion_ids: JSONB:JAVADOC:34; JSONB:JAVADOC:35 + * + * @test_Strategy: Assert that JsonbConfig.getProperty returns the value of a + * specific configuration property + */ + @Test + public void testGetProperty() { + JsonbConfig jsonbConfig = new JsonbConfig().withFormatting(true) + .withNullValues(true); + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.FORMATTING); + + String validationMessage = "Failed to get a configuration property using JsonbConfig.getProperty method."; + assertTrue(property.isPresent(), validationMessage); + assertTrue((Boolean) property.get(), validationMessage); + } + + /* + * @testName: testGetUnsetProperty + * + * @assertion_ids: JSONB:JAVADOC:34; JSONB:JAVADOC:35 + * + * @test_Strategy: Assert that JsonbConfig.getProperty returns the value of a + * specific configuration property + */ + @Test + public void testGetUnsetProperty() { + JsonbConfig jsonbConfig = new JsonbConfig().withFormatting(true) + .withNullValues(true); + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.ADAPTERS); + + assertFalse(property.isPresent(), + "Failed to get Optional.empty for an unset configuration property using JsonbConfig.getProperty method."); + } + + /* + * @testName: testSetProperty + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:36 + * + * @test_Strategy: Assert that JsonbConfig.setProperty sets the value of a + * specific configuration property + */ + @Test + public void testSetProperty() { + JsonbConfig jsonbConfig = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY, + PropertyNamingStrategy.UPPER_CAMEL_CASE_WITH_SPACES); + assertThat("Failed to set a property value using JsonbConfig.setProperty method.", + jsonbConfig.getProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY).get(), + is(PropertyNamingStrategy.UPPER_CAMEL_CASE_WITH_SPACES)); + } + + /* + * @testName: testWithAdapters + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:37 + * + * @test_Strategy: Assert that JsonbConfig.withAdapters configures custom + * mapping adapters + */ + @Test + public void testWithAdapters() { + SimpleStringAdapter simpleStringAdapter = new SimpleStringAdapter(); + JsonbConfig jsonbConfig = new JsonbConfig() + .withAdapters(simpleStringAdapter); + String validationMessage = "Failed to configure a custom adapter using JsonbConfig.withAdapters method."; + Object adapters = jsonbConfig.getProperty(JsonbConfig.ADAPTERS).get(); + assertThat(validationMessage, adapters, instanceOf(JsonbAdapter[].class)); + assertThat(validationMessage, ((JsonbAdapter<?, ?>[]) adapters)[0], is(simpleStringAdapter)); + } + + /* + * @testName: testWithAdaptersMultipleCalls + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:37 + * + * @test_Strategy: Assert that multiple JsonbConfig.withAdapters calls result + * in a merge of adapter values configured + */ + @Test + public void testWithAdaptersMultipleCalls() { + JsonbConfig jsonbConfig = new JsonbConfig() + .withAdapters(new SimpleIntegerAdapter()) + .withAdapters(new SimpleStringAdapter()); + + Object adapters = jsonbConfig.getProperty(JsonbConfig.ADAPTERS).get(); + assertThat("Not expected JsonbAdapter array but " + adapters.getClass(), adapters, instanceOf(JsonbAdapter[].class)); + assertThat("Failed to configure multiple custom adapters using multiple JsonbConfig.withAdapters method calls.", + ((JsonbAdapter<?, ?>[]) adapters).length, is(2)); + } + + /* + * @testName: testWithMultipleAdapters + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:37 + * + * @test_Strategy: Assert that multiple JsonbConfig.withAdapters calls result + * in a merge of adapter values configured + */ + @Test + public void testWithMultipleAdapters() { + JsonbConfig jsonbConfig = new JsonbConfig().withAdapters(new SimpleIntegerAdapter(), new SimpleStringAdapter()); + + Object adapters = jsonbConfig.getProperty(JsonbConfig.ADAPTERS).get(); + assertThat("Not expected JsonbAdapter array but " + adapters.getClass(), adapters, instanceOf(JsonbAdapter[].class)); + assertThat("Failed to configure multiple custom adapters using multiple JsonbConfig.withAdapters method calls.", + ((JsonbAdapter<?, ?>[]) adapters).length, is(2)); + } + + /* + * @testName: testWithBinaryDataStrategy + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:38 + * + * @test_Strategy: Assert that JsonbConfig.withBinaryDataStrategy configures + * custom binary data strategy + */ + @Test + public void testWithBinaryDataStrategy() { + JsonbConfig jsonbConfig = new JsonbConfig().withBinaryDataStrategy(BinaryDataStrategy.BASE_64_URL); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.BINARY_DATA_STRATEGY); + String validationMessage = "Failed to configure a custom binary data strategy using JsonbConfig.withBinaryDataStrategy " + + "method."; + assertTrue(property.isPresent(), validationMessage); + assertThat(validationMessage, property.get(), is(BinaryDataStrategy.BASE_64_URL)); + } + + /* + * @testName: testWithDateFormat + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:39 + * + * @test_Strategy: Assert that JsonbConfig.withDateFormat configures custom + * date format + */ + @Test + public void testWithDateFormat() { + JsonbConfig jsonbConfig = new JsonbConfig().withDateFormat("YYYYMMDD", Locale.GERMAN); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.DATE_FORMAT); + String validationMessage = "Failed to configure a custom date format using JsonbConfig.withDateFormat method."; + assertTrue(property.isPresent(), validationMessage); + assertThat(validationMessage, property.get(), is("YYYYMMDD")); + } + + /* + * @testName: testWithDeserializers + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:40 + * + * @test_Strategy: Assert that JsonbConfig.withDeserializers configures custom + * deserializers + */ + @Test + public void testWithDeserializers() { + SimpleContainerDeserializer deserializer = new SimpleContainerDeserializer(); + JsonbConfig jsonbConfig = new JsonbConfig().withDeserializers(deserializer); + + Object deserializers = jsonbConfig.getProperty(JsonbConfig.DESERIALIZERS).get(); + String validationMessage = "Failed to configure a custom deserializer using JsonbConfig.withDeserializers method."; + assertThat(validationMessage, deserializers, instanceOf(JsonbDeserializer[].class)); + assertThat(validationMessage, ((JsonbDeserializer<?>[]) deserializers)[0], is(deserializer)); + } + + /* + * @testName: testWithDeserializersMultipleCalls + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:40 + * + * @test_Strategy: Assert that multiple JsonbConfig.withDeserializers calls + * result in a merge of deserializer values configured + */ + @Test + public void testWithDeserializersMultipleCalls() { + JsonbConfig jsonbConfig = new JsonbConfig() + .withDeserializers(new SimpleIntegerDeserializer()) + .withDeserializers(new SimpleContainerDeserializer()); + + Object deserializers = jsonbConfig.getProperty(JsonbConfig.DESERIALIZERS).get(); + assertThat("Not expected JsonbDeserializer array but " + deserializers.getClass(), + deserializers, instanceOf(JsonbDeserializer[].class)); + assertThat("Failed to configure multiple custom deserializers using multiple JsonbConfig.withDeserializers method calls.", + ((JsonbDeserializer<?>[]) deserializers).length, is(2)); + } + + /* + * @testName: testWithEncoding + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:41 + * + * @test_Strategy: Assert that JsonbConfig.withEncoding configures custom + * character encoding + */ + @Test + public void testWithEncoding() { + JsonbConfig jsonbConfig = new JsonbConfig().withEncoding("UCS2"); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.ENCODING); + String validationMessage = "Failed to configure a custom character encoding using JsonbConfig.withEncoding method."; + assertTrue(property.isPresent(), validationMessage); + assertThat(validationMessage, property.get(), is("UCS2")); + } + + /* + * @testName: testWithFormatting + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:42 + * + * @test_Strategy: Assert that JsonbConfig.withFormatting configures whether + * JSON string formatting is enabled + */ + @Test + public void testWithFormatting() { + JsonbConfig jsonbConfig = new JsonbConfig().withFormatting(true); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.FORMATTING); + String validationMessage = "Failed to configure JSON string formatting using JsonbConfig.withFormatting method."; + assertTrue(property.isPresent(), validationMessage); + assertTrue((boolean) property.get(), validationMessage); + } + + /* + * @testName: testWithLocale + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:43 + * + * @test_Strategy: Assert that JsonbConfig.withLocale configures custom locale + */ + @Test + public void testWithLocale() { + JsonbConfig jsonbConfig = new JsonbConfig().withLocale(Locale.GERMAN); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.LOCALE); + String validationMessage = "Failed to configure a custom locale using JsonbConfig.withLocale method."; + assertTrue(property.isPresent(), validationMessage); + assertThat(validationMessage, property.get(), is(Locale.GERMAN)); + } + + /* + * @testName: testWithNullValues + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:44 + * + * @test_Strategy: Assert that JsonbConfig.withNullValues configures + * serialization of null values + */ + @Test + public void testWithNullValues() { + JsonbConfig jsonbConfig = new JsonbConfig().withNullValues(true); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.NULL_VALUES); + String validationMessage = "Failed to configure serialization of null values using JsonbConfig.withNullValues method."; + assertTrue(property.isPresent(), validationMessage); + assertTrue((boolean) property.get(), validationMessage); + } + + /* + * @testName: testWithPropertyNamingStrategy + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:45; JSONB:JAVADOC:69 + * + * @test_Strategy: Assert that JsonbConfig.withPropertyNamingStrategy + * configures custom property naming strategy + */ + @Test + public void testWithPropertyNamingStrategy() { + SimplePropertyNamingStrategy propertyNamingStrategy = new SimplePropertyNamingStrategy(); + JsonbConfig jsonbConfig = new JsonbConfig().withPropertyNamingStrategy(propertyNamingStrategy); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY); + String validationMessage = "Failed to configure a custom property naming strategy using " + + "JsonbConfig.withPropertyNamingStrategy method."; + assertTrue(property.isPresent(), validationMessage); + assertThat(validationMessage, property.get(), is(propertyNamingStrategy)); + } + + /* + * @testName: testWithPropertyNamingStrategyString + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:46 + * + * @test_Strategy: Assert that JsonbConfig.withPropertyNamingStrategy with + * String argument configures custom property naming strategy + */ + @Test + public void testWithPropertyNamingStrategyString() { + JsonbConfig jsonbConfig = new JsonbConfig().withPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY); + String validationMessage = "Failed to configure a custom property naming strategy using " + + "JsonbConfig.withPropertyNamingStrategy method with String argument."; + assertTrue(property.isPresent(), validationMessage); + assertThat(validationMessage, property.get(), is(PropertyNamingStrategy.UPPER_CAMEL_CASE)); + } + + /* + * @testName: testWithPropertyOrderStrategy + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:47 + * + * @test_Strategy: Assert that JsonbConfig.withPropertyOrderStrategy + * configures custom property order strategy + */ + @Test + public void testWithPropertyOrderStrategy() { + JsonbConfig jsonbConfig = new JsonbConfig().withPropertyOrderStrategy(PropertyOrderStrategy.LEXICOGRAPHICAL); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.PROPERTY_ORDER_STRATEGY); + String validationMessage = "Failed to configure a custom property order strategy using " + + "JsonbConfig.withPropertyOrderStrategy method."; + assertTrue(property.isPresent(), validationMessage); + assertThat(validationMessage, property.get(), is(PropertyOrderStrategy.LEXICOGRAPHICAL)); + } + + /* + * @testName: testWithPropertyVisibilityStrategy + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:48 + * + * @test_Strategy: Assert that JsonbConfig.withPropertyVisibilityStrategy + * configures custom property visibility + */ + @Test + public void testWithPropertyVisibilityStrategy() { + SimplePropertyVisibilityStrategy propertyVisibilityStrategy = new SimplePropertyVisibilityStrategy(); + JsonbConfig jsonbConfig = new JsonbConfig().withPropertyVisibilityStrategy(propertyVisibilityStrategy); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.PROPERTY_VISIBILITY_STRATEGY); + String validationMessage = "Failed to configure a custom property visibility strategy using " + + "JsonbConfig.withPropertyVisibilityStrategy method."; + assertTrue(property.isPresent(), validationMessage); + assertThat(validationMessage, property.get(), is(propertyVisibilityStrategy)); + } + + /* + * @testName: testWithSerializers + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:49 + * + * @test_Strategy: Assert that JsonbConfig.withSerializers configures custom + * serializers + */ + @Test + public void testWithSerializers() { + SimpleContainerSerializer serializer = new SimpleContainerSerializer(); + JsonbConfig jsonbConfig = new JsonbConfig().withSerializers(serializer); + + Object serializers = jsonbConfig.getProperty(JsonbConfig.SERIALIZERS).get(); + String validationMessage = "Failed to configure a custom serializer using JsonbConfig.withSerializers method."; + assertThat(validationMessage, serializers, instanceOf(JsonbSerializer[].class)); + assertThat(validationMessage, ((JsonbSerializer<?>[]) serializers)[0], is(serializer)); + } + + /* + * @testName: testWithSerializersMultipleCalls + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:49 + * + * @test_Strategy: Assert that multiple JsonbConfig.withSerializers calls + * result in a merge of serializer values configured + */ + @Test + public void testWithSerializersMultipleCalls() { + JsonbConfig jsonbConfig = new JsonbConfig() + .withSerializers(new SimpleIntegerSerializer()) + .withSerializers(new SimpleContainerSerializer()); + + Object serializers = jsonbConfig.getProperty(JsonbConfig.SERIALIZERS).get(); + assertThat("Not expected JsonbSerializer array but " + serializers.getClass(), + serializers, instanceOf(JsonbSerializer[].class)); + assertThat("Failed to configure multiple custom serializers using multiple JsonbConfig.withSerializers method calls.", + ((JsonbSerializer<?>[]) serializers).length, is(2)); + } + + /* + * @testName: testWithStrictIJson + * + * @assertion_ids: JSONB:JAVADOC:35; JSONB:JAVADOC:50 + * + * @test_Strategy: Assert that JsonbConfig.withStrictIJSON configures strict + * I-JSON support + */ + @Test + public void testWithStrictIJson() { + JsonbConfig jsonbConfig = new JsonbConfig().withStrictIJSON(true); + + Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.STRICT_IJSON); + String validationMessage = "Failed to configure strict I-JSON support using JsonbConfig.withStrictIJSON method."; + assertTrue(property.isPresent(), validationMessage); + assertTrue((boolean) property.get(), validationMessage); + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/exception/JsonbExceptionTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/exception/JsonbExceptionTest.java new file mode 100644 index 0000000..6a22227 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/exception/JsonbExceptionTest.java
@@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.exception; + +import jakarta.json.bind.JsonbException; + +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +/** + * @test + * @sources JsonbExceptionTest.java + * @executeClass com.sun.ts.tests.jsonb.api.JsonbExceptionTest + **/ +public class JsonbExceptionTest { + + private static final String EXCEPTION_MESSAGE = "Exception message"; + + /* + * @testName: testJsonbExceptionString + * + * @assertion_ids: JSONB:JAVADOC:51 + * + * @test_Strategy: Assert that JsonbException with String argument is creating + * a new RuntimeException with cause uninitialized and that subsequent call to + * #initCause may initialize the cause + */ + @Test + public void testJsonbExceptionString() { + RuntimeException jsonbException = new JsonbException(EXCEPTION_MESSAGE); + String validationMessage = "Failed to create JsonbException with an exception message and empty cause."; + assertThat(validationMessage, jsonbException.getMessage(), is(EXCEPTION_MESSAGE)); + assertThat(validationMessage, jsonbException.getCause(), nullValue()); + + RuntimeException exception = new RuntimeException(); + jsonbException.initCause(exception); + validationMessage = "Failed to initialize the JsonbException cause with a call to initCause method."; + assertThat(validationMessage, jsonbException.getMessage(), is(EXCEPTION_MESSAGE)); + assertThat(validationMessage, jsonbException.getCause(), is(exception)); + } + + /* + * @testName: testJsonbExceptionStringThrowable + * + * @assertion_ids: JSONB:JAVADOC:52 + * + * @test_Strategy: Assert that JsonbException with String and throwable + * arguments is creating a new RuntimeException with exception message and + * cause initialized + */ + @Test + public void testJsonbExceptionStringThrowable() { + RuntimeException cause = new RuntimeException(); + RuntimeException jsonbException = new JsonbException(EXCEPTION_MESSAGE, cause); + String validationMessage = "Failed to create JsonbException with an exception message and cause."; + assertThat(validationMessage, jsonbException.getMessage(), is(EXCEPTION_MESSAGE)); + assertThat(validationMessage, jsonbException.getCause(), is(cause)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/jsonb/JsonbTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/jsonb/JsonbTest.java new file mode 100644 index 0000000..48daeae --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/jsonb/JsonbTest.java
@@ -0,0 +1,261 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.jsonb; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.api.model.SimpleContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources JsonbTest.java + * @executeClass com.sun.ts.tests.jsonb.api.JsonbTest + **/ +public class JsonbTest { + + private static final String TEST_STRING = "Test String"; + private static final String TEST_JSON = "{ \"instance\" : \"" + TEST_STRING + "\" }"; + private static final byte[] TEST_JSON_BYTE = TEST_JSON.getBytes(StandardCharsets.UTF_8); + + private static final String MATCHING_PATTERN = "\\{\\s*\"instance\"\\s*:\\s*\"Test\"\\s*}"; + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testFromJsonStringClass + * + * @assertion_ids: JSONB:JAVADOC:1 + * + * @test_Strategy: Assert that Jsonb.fromJson method with String and Class + * arguments is working as expected + */ + @Test + public void testFromJsonStringClass() { + SimpleContainer unmarshalledObject = jsonb.fromJson(TEST_JSON, SimpleContainer.class); + assertThat("Failed to unmarshal using Jsonb.fromJson method with String and Class arguments.", + unmarshalledObject.getInstance(), is(TEST_STRING)); + } + + /* + * @testName: testFromJsonStringType + * + * @assertion_ids: JSONB:JAVADOC:3 + * + * @test_Strategy: Assert that Jsonb.fromJson method with String and Type + * arguments is working as expected + */ + @Test + public void testFromJsonStringType() { + SimpleContainer unmarshalledObject = jsonb + .fromJson(TEST_JSON, new SimpleContainer() { }.getClass().getGenericSuperclass()); + assertThat("Failed to unmarshal using Jsonb.fromJson method with String and Type arguments.", + unmarshalledObject.getInstance(), is(TEST_STRING)); + } + + /* + * @testName: testFromJsonReaderClass + * + * @assertion_ids: JSONB:JAVADOC:5 + * + * @test_Strategy: Assert that Jsonb.fromJson method with Reader and Class + * arguments is working as expected + */ + @Test + public void testFromJsonReaderClass() throws IOException { + try (ByteArrayInputStream stream = new ByteArrayInputStream(TEST_JSON_BYTE); + InputStreamReader reader = new InputStreamReader(stream)) { + SimpleContainer unmarshalledObject = jsonb.fromJson(reader, SimpleContainer.class); + assertThat("Failed to unmarshal using Jsonb.fromJson method with Reader and Class arguments.", + unmarshalledObject.getInstance(), is(TEST_STRING)); + } + } + + /* + * @testName: testFromJsonReaderType + * + * @assertion_ids: JSONB:JAVADOC:7 + * + * @test_Strategy: Assert that Jsonb.fromJson method with Reader and Type + * arguments is working as expected + */ + @Test + public void testFromJsonReaderType() throws IOException { + try (ByteArrayInputStream stream = new ByteArrayInputStream(TEST_JSON_BYTE); + InputStreamReader reader = new InputStreamReader(stream)) { + SimpleContainer unmarshalledObject = jsonb + .fromJson(reader, new SimpleContainer() { }.getClass().getGenericSuperclass()); + assertThat("Failed to unmarshal using Jsonb.fromJson method with Reader and Type arguments.", + unmarshalledObject.getInstance(), is(TEST_STRING)); + } + } + + /* + * @testName: testFromJsonStreamClass + * + * @assertion_ids: JSONB:JAVADOC:9 + * + * @test_Strategy: Assert that Jsonb.fromJson method with InputStream and + * Class arguments is working as expected + */ + @Test + public void testFromJsonStreamClass() throws IOException { + try (ByteArrayInputStream stream = new ByteArrayInputStream(TEST_JSON_BYTE)) { + SimpleContainer unmarshalledObject = jsonb.fromJson(stream, SimpleContainer.class); + assertThat("Failed to unmarshal using Jsonb.fromJson method with InputStream and Class arguments.", + unmarshalledObject.getInstance(), is(TEST_STRING)); + } + } + + /* + * @testName: testFromJsonStreamType + * + * @assertion_ids: JSONB:JAVADOC:11 + * + * @test_Strategy: Assert that Jsonb.fromJson method with InputStream and + * Class arguments is working as expected + */ + @Test + public void testFromJsonStreamType() throws IOException { + try (ByteArrayInputStream stream = new ByteArrayInputStream(TEST_JSON_BYTE)) { + SimpleContainer unmarshalledObject = jsonb + .fromJson(stream, new SimpleContainer() { }.getClass().getGenericSuperclass()); + assertThat("Failed to unmarshal using Jsonb.fromJson method with InputStream and Type arguments.", + unmarshalledObject.getInstance(), is(TEST_STRING)); + } + } + + /* + * @testName: testToJsonObject + * + * @assertion_ids: JSONB:JAVADOC:13 + * + * @test_Strategy: Assert that Jsonb.toJson method with Object argument is + * working as expected + */ + @Test + public void testToJsonObject() { + String jsonString = jsonb.toJson(new SimpleContainer()); + assertThat("Failed to marshal using Jsonb.toJson method with Object argument.", + jsonString, matchesPattern(MATCHING_PATTERN)); + } + + /* + * @testName: testToJsonObjectType + * + * @assertion_ids: JSONB:JAVADOC:15 + * + * @test_Strategy: Assert that Jsonb.toJson method with Object and Type + * arguments is working as expected + */ + @Test + public void testToJsonObjectType() { + String jsonString = jsonb.toJson(new SimpleContainer(), new SimpleContainer() { }.getClass().getGenericSuperclass()); + assertThat("Failed to marshal using Jsonb.toJson method with Object and Type arguments.", + jsonString, matchesPattern(MATCHING_PATTERN)); + } + + /* + * @testName: testToJsonObjectWriter + * + * @assertion_ids: JSONB:JAVADOC:17 + * + * @test_Strategy: Assert that Jsonb.toJson method with Object and Writer + * arguments is working as expected + */ + @Test + public void testToJsonObjectWriter() throws IOException { + try (ByteArrayOutputStream stream = new ByteArrayOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(stream)) { + jsonb.toJson(new SimpleContainer(), writer); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + assertThat("Failed to marshal using Jsonb.toJson method with Object and Writer arguments.", + jsonString, matchesPattern(MATCHING_PATTERN)); + } + } + + /* + * @testName: testToJsonObjectTypeWriter + * + * @assertion_ids: JSONB:JAVADOC:19 + * + * @test_Strategy: Assert that Jsonb.toJson method with Object, Type and + * Writer arguments is working as expected + */ + @Test + public void testToJsonObjectTypeWriter() throws IOException { + try (ByteArrayOutputStream stream = new ByteArrayOutputStream(); + OutputStreamWriter writer = new OutputStreamWriter(stream)) { + jsonb.toJson(new SimpleContainer(), new SimpleContainer() { }.getClass().getGenericSuperclass(), writer); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + assertThat("Failed to marshal using Jsonb.toJson method with Object, Type and Writer arguments.", + jsonString, matchesPattern(MATCHING_PATTERN)); + } + } + + /* + * @testName: testToJsonObjectStream + * + * @assertion_ids: JSONB:JAVADOC:21 + * + * @test_Strategy: Assert that Jsonb.toJson method with Object and + * OutputStream arguments is working as expected + */ + @Test + public void testToJsonObjectStream() throws IOException { + try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { + jsonb.toJson(new SimpleContainer(), stream); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + assertThat("Failed to marshal using Jsonb.toJson method with Object and OutputStream arguments.", + jsonString, matchesPattern(MATCHING_PATTERN)); + } + } + + /* + * @testName: testToJsonObjectTypeStream + * + * @assertion_ids: JSONB:JAVADOC:23 + * + * @test_Strategy: Assert that Jsonb.toJson method with Object, Type and + * OutputStream arguments is working as expected + */ + @Test + public void testToJsonObjectTypeStream() throws IOException { + try (ByteArrayOutputStream stream = new ByteArrayOutputStream()) { + jsonb.toJson(new SimpleContainer(), new SimpleContainer() { }.getClass().getGenericSuperclass(), stream); + String jsonString = new String(stream.toByteArray(), StandardCharsets.UTF_8); + assertThat("Failed to marshal using Jsonb.toJson method with Object, Type and OutputStream arguments.", + jsonString, matchesPattern(MATCHING_PATTERN)); + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/jsonbadapter/JsonbAdapterTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/jsonbadapter/JsonbAdapterTest.java new file mode 100644 index 0000000..3efb5a5 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/jsonbadapter/JsonbAdapterTest.java
@@ -0,0 +1,89 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.jsonbadapter; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; + +import ee.jakarta.tck.json.bind.api.model.SimpleContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleContainerContainer; +import ee.jakarta.tck.json.bind.api.model.SimpleStringAdapter; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources JsonbAdapterTest.java + * @executeClass com.sun.ts.tests.jsonb.api.JsonbAdapterTest + **/ +public class JsonbAdapterTest { + + /* + * @testName: testAdaptFromJson + * + * @assertion_ids: JSONB:JAVADOC:53 + * + * @test_Strategy: Assert that JsonbAdapter.adaptFromJson method can be + * configured during object deserialization to provide conversion logic from + * adapted object to original + */ + @Test + public void testAdaptFromJson() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withAdapters(new SimpleStringAdapter())); + SimpleContainerContainer unmarshalledObject = jsonb + .fromJson("{ \"instance\" : { \"instance\" : \"Test String Adapted\" } }", + SimpleContainerContainer.class); + assertThat("Failed to use JsonbAdapter.adaptFromJson method to provide conversion logic from " + + "adapted object to original during object deserialization.", + unmarshalledObject.getInstance().getInstance(), is("Test String")); + } + + /* + * @testName: testAdaptToJson + * + * @assertion_ids: JSONB:JAVADOC:55 + * + * @test_Strategy: Assert that JsonbAdapter.adaptToJson method can be + * configured during object serialization to provide conversion logic from + * original object to adapted + */ + @Test + public void testAdaptToJson() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withAdapters(new SimpleStringAdapter())); + String jsonString = jsonb.toJson(new SimpleContainerContainer() { + { + setInstance(new SimpleContainer() { + { + setInstance("Test String"); + } + }); + } + }); + assertThat("Failed to use JsonbAdapter.adaptToJson method to provide conversion " + + "logic from original object to adapted during object serialization.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\{\\s*\"instance\"\\s*:\\s*\"Test String Adapted\"\\s*}\\s*}")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedAdaptedContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedAdaptedContainer.java new file mode 100644 index 0000000..9fed3d8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedAdaptedContainer.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbTypeAdapter; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleAnnotatedAdaptedContainer + implements TypeContainer<SimpleContainer> { + @JsonbTypeAdapter(SimpleStringAdapter.class) + private SimpleContainer instance; + + @Override + public SimpleContainer getInstance() { + return instance; + } + + @Override + public void setInstance(SimpleContainer instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedDateContainer.java new file mode 100644 index 0000000..235b0c7 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedDateContainer.java
@@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import java.util.Date; + +import jakarta.json.bind.annotation.JsonbDateFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleAnnotatedDateContainer implements TypeContainer<Date> { + @JsonbDateFormat(value = "EEE, dd MMM yyyy", locale = "de") + private Date instance = new Date(0); + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedDoubleContainer.java new file mode 100644 index 0000000..0cc1335 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedDoubleContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbNumberFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleAnnotatedDoubleContainer implements TypeContainer<Double> { + @JsonbNumberFormat(value = "###,###.#", locale = "de") + private Double instance = 123456.789; + + @Override + public Double getInstance() { + return instance; + } + + @Override + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedNillableContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedNillableContainer.java new file mode 100644 index 0000000..45c7bbd --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedNillableContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbNillable; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbNillable +public class SimpleAnnotatedNillableContainer implements TypeContainer<Object> { + private Object instance; + + @Override + public Object getInstance() { + return instance; + } + + @Override + public void setInstance(Object instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedNillablePropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedNillablePropertyContainer.java new file mode 100644 index 0000000..a71d6f3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedNillablePropertyContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbNillable; +import jakarta.json.bind.annotation.JsonbProperty; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleAnnotatedNillablePropertyContainer + implements TypeContainer<Object> { + @JsonbProperty(value = "nillableInstance") + @JsonbNillable + private Object instance; + + @Override + public Object getInstance() { + return instance; + } + + @Override + public void setInstance(Object instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedPropertyOrderContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedPropertyOrderContainer.java new file mode 100644 index 0000000..9ea6fcb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedPropertyOrderContainer.java
@@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbPropertyOrder; + +@JsonbPropertyOrder({"secondInstance", "firstInstance"}) +public class SimpleAnnotatedPropertyOrderContainer { + private String firstInstance = "First String"; + + private String secondInstance = "Second String"; + + public String getFirstInstance() { + return firstInstance; + } + + public void setFirstInstance(String firstInstance) { + this.firstInstance = firstInstance; + } + + public String getSecondInstance() { + return secondInstance; + } + + public void setSecondInstance(String secondInstance) { + this.secondInstance = secondInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedPropertyVisibilityContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedPropertyVisibilityContainer.java new file mode 100644 index 0000000..7234f91 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedPropertyVisibilityContainer.java
@@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbVisibility; + +@JsonbVisibility(SimpleVisibilityStrategy.class) +public class SimpleAnnotatedPropertyVisibilityContainer { + private String firstInstance = "First String"; + + private String secondInstance = "Second String"; + + public String getFirstInstance() { + return firstInstance; + } + + public void setFirstInstance(String firstInstance) { + this.firstInstance = firstInstance; + } + + public String getSecondInstance() { + return secondInstance; + } + + public void setSecondInstance(String secondInstance) { + this.secondInstance = secondInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedSerializedArrayContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedSerializedArrayContainer.java new file mode 100644 index 0000000..b2bcc3a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedSerializedArrayContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbTypeDeserializer; +import jakarta.json.bind.annotation.JsonbTypeSerializer; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleAnnotatedSerializedArrayContainer + implements TypeContainer<SimpleContainer[]> { + @JsonbTypeSerializer(SimpleContainerArraySerializer.class) + @JsonbTypeDeserializer(SimpleContainerArrayDeserializer.class) + private SimpleContainer[] instance; + + @Override + public SimpleContainer[] getInstance() { + return instance; + } + + @Override + public void setInstance(SimpleContainer[] instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedSerializedContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedSerializedContainer.java new file mode 100644 index 0000000..06a9fc6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleAnnotatedSerializedContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbTypeDeserializer; +import jakarta.json.bind.annotation.JsonbTypeSerializer; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleAnnotatedSerializedContainer + implements TypeContainer<SimpleContainer> { + @JsonbTypeSerializer(SimpleContainerSerializer.class) + @JsonbTypeDeserializer(SimpleContainerDeserializer.class) + private SimpleContainer instance; + + @Override + public SimpleContainer getInstance() { + return instance; + } + + @Override + public void setInstance(SimpleContainer instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainer.java new file mode 100644 index 0000000..a891ee6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainer.java
@@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleContainer implements TypeContainer<String> { + private String instance = "Test"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerAdapted.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerAdapted.java new file mode 100644 index 0000000..32f3e0b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerAdapted.java
@@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleContainerAdapted implements TypeContainer<String> { + private String instance = "Test"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerArrayDeserializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerArrayDeserializer.java new file mode 100644 index 0000000..0cd0bf3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerArrayDeserializer.java
@@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.stream.JsonParser; + +public class SimpleContainerArrayDeserializer + implements JsonbDeserializer<SimpleContainer[]> { + public SimpleContainer[] deserialize(JsonParser jsonParser, + DeserializationContext deserializationContext, Type type) { + List<SimpleContainer> containers = new ArrayList<>(); + + while (jsonParser.hasNext()) { + JsonParser.Event event = jsonParser.next(); + if (event == JsonParser.Event.START_OBJECT) { + containers + .add(deserializationContext.deserialize(new SimpleContainer() { + }.getClass().getGenericSuperclass(), jsonParser)); + } + if (event == JsonParser.Event.END_OBJECT) { + break; + } + } + + return containers.toArray(new SimpleContainer[0]); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerArraySerializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerArraySerializer.java new file mode 100644 index 0000000..ad05de1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerArraySerializer.java
@@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.serializer.JsonbSerializer; +import jakarta.json.bind.serializer.SerializationContext; +import jakarta.json.stream.JsonGenerator; + +public class SimpleContainerArraySerializer + implements JsonbSerializer<SimpleContainer[]> { + @Override + public void serialize(SimpleContainer[] containers, + JsonGenerator jsonGenerator, SerializationContext serializationContext) { + jsonGenerator.writeStartArray(); + for (SimpleContainer container : containers) { + serializationContext.serialize(container, jsonGenerator); + } + jsonGenerator.writeEnd(); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerContainer.java new file mode 100644 index 0000000..e54d869 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerContainer.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleContainerContainer + implements TypeContainer<SimpleContainer> { + private SimpleContainer instance; + + public SimpleContainer getInstance() { + return instance; + } + + public void setInstance(SimpleContainer instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerDeserializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerDeserializer.java new file mode 100644 index 0000000..f035ca8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerDeserializer.java
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import java.lang.reflect.Type; + +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.stream.JsonParser; + +public class SimpleContainerDeserializer + implements JsonbDeserializer<SimpleContainer> { + public SimpleContainer deserialize(JsonParser jsonParser, + DeserializationContext deserializationContext, Type type) { + SimpleContainer container = new SimpleContainer(); + + while (jsonParser.hasNext()) { + JsonParser.Event event = jsonParser.next(); + if (event == JsonParser.Event.START_OBJECT) { + continue; + } + if (event == JsonParser.Event.END_OBJECT) { + break; + } + if (event == JsonParser.Event.KEY_NAME) { + switch (jsonParser.getString()) { + case "instance": + container.setInstance( + deserializationContext.deserialize(String.class, jsonParser) + + " Deserialized"); + break; + } + } + } + + return container; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerSerializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerSerializer.java new file mode 100644 index 0000000..151de89 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleContainerSerializer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.serializer.JsonbSerializer; +import jakarta.json.bind.serializer.SerializationContext; +import jakarta.json.stream.JsonGenerator; + +public class SimpleContainerSerializer + implements JsonbSerializer<SimpleContainer> { + @Override + public void serialize(SimpleContainer container, JsonGenerator jsonGenerator, + SerializationContext serializationContext) { + jsonGenerator.writeStartObject(); + serializationContext.serialize("instance", + container.getInstance() + " Serialized", jsonGenerator); + jsonGenerator.writeEnd(); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerAdapter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerAdapter.java new file mode 100644 index 0000000..bedcdfb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerAdapter.java
@@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.adapter.JsonbAdapter; + +public class SimpleIntegerAdapter implements JsonbAdapter<Integer, Integer> { + @Override + public Integer adaptToJson(Integer integer) throws Exception { + return integer; + } + + @Override + public Integer adaptFromJson(Integer adapted) throws Exception { + return adapted; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerDeserializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerDeserializer.java new file mode 100644 index 0000000..fec1a17 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerDeserializer.java
@@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import java.lang.reflect.Type; + +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.stream.JsonParser; + +public class SimpleIntegerDeserializer implements JsonbDeserializer<Integer> { + public Integer deserialize(JsonParser jsonParser, + DeserializationContext deserializationContext, Type type) { + return deserializationContext.deserialize(type, jsonParser); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerSerializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerSerializer.java new file mode 100644 index 0000000..69b1ceb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleIntegerSerializer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.serializer.JsonbSerializer; +import jakarta.json.bind.serializer.SerializationContext; +import jakarta.json.stream.JsonGenerator; + +public class SimpleIntegerSerializer implements JsonbSerializer<Integer> { + @Override + public void serialize(Integer i, JsonGenerator jsonGenerator, + SerializationContext serializationContext) { + serializationContext.serialize(i, jsonGenerator); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePartiallyAnnotatedPropertyOrderContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePartiallyAnnotatedPropertyOrderContainer.java new file mode 100644 index 0000000..5f752da --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePartiallyAnnotatedPropertyOrderContainer.java
@@ -0,0 +1,72 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.annotation.JsonbPropertyOrder; + +@JsonbPropertyOrder({"thirdInstance", "fourthInstance"}) +public class SimplePartiallyAnnotatedPropertyOrderContainer { + private String firstInstance = "First String"; + + private String secondInstance = "Second String"; + + private String thirdInstance = "Third String"; + + private String fourthInstance = "Fourth String"; + + private String anyOtherInstance = "Fifth String property starting with A"; + + public String getThirdInstance() { + return thirdInstance; + } + + public void setThirdInstance(String thirdInstance) { + this.thirdInstance = thirdInstance; + } + + public String getFourthInstance() { + return fourthInstance; + } + + public void setFourthInstance(String fourthInstance) { + this.fourthInstance = fourthInstance; + } + + public String getAnyOtherInstance() { + return anyOtherInstance; + } + + public void setAnyOtherInstance(String anyOtherInstance) { + this.anyOtherInstance = anyOtherInstance; + } + + public String getFirstInstance() { + return firstInstance; + } + + public void setFirstInstance(String firstInstance) { + this.firstInstance = firstInstance; + } + + public String getSecondInstance() { + return secondInstance; + } + + public void setSecondInstance(String secondInstance) { + this.secondInstance = secondInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePropertyNamingStrategy.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePropertyNamingStrategy.java new file mode 100644 index 0000000..3c5e00d --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePropertyNamingStrategy.java
@@ -0,0 +1,30 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.config.PropertyNamingStrategy; + +public class SimplePropertyNamingStrategy implements PropertyNamingStrategy { + @Override + public String translateName(String s) { + return s; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePropertyVisibilityStrategy.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePropertyVisibilityStrategy.java new file mode 100644 index 0000000..34889f5 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimplePropertyVisibilityStrategy.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import jakarta.json.bind.config.PropertyVisibilityStrategy; + +public class SimplePropertyVisibilityStrategy + implements PropertyVisibilityStrategy { + @Override + public boolean isVisible(Field field) { + return true; + } + + @Override + public boolean isVisible(Method method) { + return true; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleStringAdapter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleStringAdapter.java new file mode 100644 index 0000000..b57b262 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleStringAdapter.java
@@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import jakarta.json.bind.adapter.JsonbAdapter; + +public class SimpleStringAdapter + implements JsonbAdapter<SimpleContainer, SimpleContainerAdapted> { + @Override + public SimpleContainerAdapted adaptToJson(SimpleContainer simpleContainer) + throws Exception { + SimpleContainerAdapted simpleContainerAdapted = new SimpleContainerAdapted(); + simpleContainerAdapted + .setInstance(simpleContainer.getInstance() + " Adapted"); + return simpleContainerAdapted; + } + + @Override + public SimpleContainer adaptFromJson(SimpleContainerAdapted adapted) + throws Exception { + SimpleContainer simpleContainer = new SimpleContainer(); + simpleContainer.setInstance(adapted.getInstance().substring(0, + adapted.getInstance().indexOf(" Adapted"))); + return simpleContainer; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleVisibilityStrategy.java b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleVisibilityStrategy.java new file mode 100644 index 0000000..95b8cec --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/api/model/SimpleVisibilityStrategy.java
@@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.api.model; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import jakarta.json.bind.config.PropertyVisibilityStrategy; + +public class SimpleVisibilityStrategy implements PropertyVisibilityStrategy { + @Override + public boolean isVisible(Field field) { + return field.getName().equals("secondInstance"); + } + + @Override + public boolean isVisible(Method method) { + return method.getName().equals("getSecondInstance"); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/AdaptersCustomizationCDITest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/AdaptersCustomizationCDITest.java new file mode 100644 index 0000000..d7da0c1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/AdaptersCustomizationCDITest.java
@@ -0,0 +1,111 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.cdi.customizedmapping.adapters; + +import jakarta.enterprise.inject.se.SeContainer; +import jakarta.enterprise.inject.se.SeContainerInitializer; +import jakarta.enterprise.inject.spi.CDI; +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.cdi.customizedmapping.adapters.model.AnimalShelterInjectedAdapter; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Dog; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources AdaptersCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.adapters.AdaptersCustomizationTest + **/ +/* + * @class.setup_props: webServerHost; webServerPort; ts_home; + */ +public class AdaptersCustomizationCDITest { + + private static SeContainer container; + + @BeforeAll + private static void startContainer() { + try { + //Verify that CDI container is already running + CDI.current(); + } catch (IllegalStateException exception) { + container = SeContainerInitializer.newInstance().initialize(); + } + } + + @AfterAll + private static void stopContainer() { + if (container != null) { + container.close(); + } + } + + /* + * @testName: testCDISupport + * + * @assertion_ids: JSONB:SPEC:JSB-4.7.1-3 + * + * @test_Strategy: Assert that CDI injection is supported in adapters + */ + @Test + public void testCDISupport() { + Jsonb jsonb = JsonbBuilder.create(); + String validationPattern = "\\{\\s*\"animals\"\\s*:\\s*\\[\\s*" + + "\\{\\s*\"age\"\\s*:\\s*5\\s*,\\s*\"cuddly\"\\s*:\\s*true\\s*,\\s*\"furry\"\\s*:\\s*true\\s*," + + "\\s*\"name\"\\s*:\\s*\"Garfield\"\\s*,\\s*\"type\"\\s*:\\s*\"CAT\"\\s*,\\s*\"weight\"\\s*:\\s*10.5\\s*}\\s*," + + "\\s*" + + "\\{\\s*\"age\"\\s*:\\s*3\\s*,\\s*\"barking\"\\s*:\\s*true\\s*,\\s*\"furry\"\\s*:\\s*false\\s*," + + "\\s*\"name\"\\s*:\\s*\"Milo\"\\s*,\\s*\"type\"\\s*:\\s*\"DOG\"\\s*,\\s*\"weight\"\\s*:\\s*5.5\\s*}\\s*,\\s*" + + "\\{\\s*\"age\"\\s*:\\s*6\\s*,\\s*\"furry\"\\s*:\\s*false\\s*,\\s*\"name\"\\s*:\\s*\"Tweety\"\\s*," + + "\\s*\"type\"\\s*:\\s*\"GENERIC\"\\s*,\\s*\"weight\"\\s*:\\s*0.5\\s*}\\s*" + + "]\\s*}"; + AnimalShelterInjectedAdapter animalShelter = new AnimalShelterInjectedAdapter(); + animalShelter.addAnimal(new Cat(5, "Garfield", 10.5f, true, true)); + animalShelter.addAnimal(new Dog(3, "Milo", 5.5f, false, true)); + animalShelter.addAnimal(new Animal(6, "Tweety", 0.5f, false)); + + String jsonString = jsonb.toJson(animalShelter); + assertThat("Failed to correctly marshall complex type hierarchy using an adapter with a CDI managed field " + + "configured using JsonbTypeAdapter annotation to a simpler class.", + jsonString, matchesPattern(validationPattern)); + + String toSerialize = "{ \"animals\" : [ " + + "{ \"age\" : 5, \"cuddly\" : true, \"furry\" : true, \"name\" : \"Garfield\" , \"type\" : \"CAT\", \"weight\"" + + " : 10.5}, " + + "{ \"age\" : 3, \"barking\" : true, \"furry\" : false, \"name\" : \"Milo\", \"type\" : \"DOG\", \"weight\" : " + + "5.5}, " + + "{ \"age\" : 6, \"furry\" : false, \"name\" : \"Tweety\", \"type\" : \"GENERIC\", \"weight\" : 0.5}" + + " ] }"; + AnimalShelterInjectedAdapter unmarshalledObject = jsonb.fromJson(toSerialize, AnimalShelterInjectedAdapter.class); + assertThat("Failed to correctly unmarshall complex type hierarchy using an adapter with a CDI managed " + + "field configured using JsonbTypeAdapter annotation to a simpler class.", + unmarshalledObject, is(animalShelter)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/AnimalShelterInjectedAdapter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/AnimalShelterInjectedAdapter.java new file mode 100644 index 0000000..40dff00 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/AnimalShelterInjectedAdapter.java
@@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.cdi.customizedmapping.adapters.model; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.json.bind.annotation.JsonbTypeAdapter; + +import ee.jakarta.tck.json.bind.cdi.customizedmapping.adapters.model.adapter.InjectedListAdapter; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Animal; + +public class AnimalShelterInjectedAdapter { + @JsonbTypeAdapter(InjectedListAdapter.class) + private List<Animal> animals = new ArrayList<>(); + + public List<Animal> getAnimals() { + return animals; + } + + public void setAnimals(List<Animal> animals) { + this.animals = animals; + } + + public boolean addAnimal(Animal animal) { + return animals.add(animal); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof AnimalShelterInjectedAdapter)) { + return false; + } + + AnimalShelterInjectedAdapter that = (AnimalShelterInjectedAdapter) o; + + return animals != null ? animals.equals(that.animals) + : that.animals == null; + } + + @Override + public int hashCode() { + return animals != null ? animals.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/adapter/InjectedAdapter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/adapter/InjectedAdapter.java new file mode 100644 index 0000000..ce627a7 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/adapter/InjectedAdapter.java
@@ -0,0 +1,83 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.cdi.customizedmapping.adapters.model.adapter; + +import jakarta.inject.Inject; +import jakarta.json.bind.adapter.JsonbAdapter; + +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Dog; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalIdentifier; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson; + +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.CAT; +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.DOG; +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.GENERIC; + +public class InjectedAdapter implements JsonbAdapter<Animal, AnimalJson> { + @Inject + private AnimalIdentifier animalIdentifier; + + @Override + public AnimalJson adaptToJson(Animal animal) throws Exception { + AnimalJson adapted = new AnimalJson(); + switch (animalIdentifier.getType(animal)) { + case CAT: + adapted.setType(CAT); + adapted.setCuddly(((Cat) animal).isCuddly()); + break; + case DOG: + adapted.setType(DOG); + adapted.setBarking(((Dog) animal).isBarking()); + break; + default: + adapted.setType(GENERIC); + } + adapted.setName(animal.getName()); + adapted.setAge(animal.getAge()); + adapted.setFurry(animal.isFurry()); + adapted.setWeight(animal.getWeight()); + return adapted; + } + + @Override + public Animal adaptFromJson(AnimalJson adapted) throws Exception { + Animal animal; + switch (adapted.getType()) { + case CAT: + animal = new Cat(); + ((Cat) animal).setCuddly(adapted.isCuddly()); + break; + case DOG: + animal = new Dog(); + ((Dog) animal).setBarking(adapted.isBarking()); + break; + default: + animal = new Animal(); + } + animal.setName(adapted.getName()); + animal.setAge(adapted.getAge()); + animal.setFurry(adapted.isFurry()); + animal.setWeight(adapted.getWeight()); + return animal; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/adapter/InjectedListAdapter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/adapter/InjectedListAdapter.java new file mode 100644 index 0000000..3beb0fc --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/adapters/model/adapter/InjectedListAdapter.java
@@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.cdi.customizedmapping.adapters.model.adapter; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.json.bind.adapter.JsonbAdapter; + +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson; + +public class InjectedListAdapter + implements JsonbAdapter<List<Animal>, List<AnimalJson>> { + @Inject + private InjectedAdapter animalAdapter; + + @Override + public List<AnimalJson> adaptToJson(List<Animal> animals) throws Exception { + List<AnimalJson> adapted = new ArrayList<>(); + for (Animal animal : animals) { + adapted.add(animalAdapter.adaptToJson(animal)); + } + return adapted; + } + + @Override + public List<Animal> adaptFromJson(List<AnimalJson> adapted) throws Exception { + List<Animal> animals = new ArrayList<>(); + for (AnimalJson animal : adapted) { + animals.add(animalAdapter.adaptFromJson(animal)); + } + return animals; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/SerializersCustomizationCDITest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/SerializersCustomizationCDITest.java new file mode 100644 index 0000000..67c5aa6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/SerializersCustomizationCDITest.java
@@ -0,0 +1,112 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.cdi.customizedmapping.serializers; + +import jakarta.enterprise.inject.se.SeContainer; +import jakarta.enterprise.inject.se.SeContainerInitializer; +import jakarta.enterprise.inject.spi.CDI; +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.cdi.customizedmapping.serializers.model.AnimalShelterWithInjectedSerializer; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Dog; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources SerializersCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.serializers.SerializersCustomizationTest + **/ +public class SerializersCustomizationCDITest { + + private static SeContainer container; + + @BeforeAll + private static void startContainer() { + try { + //Verify that CDI container is already running + CDI.current(); + } catch (IllegalStateException exception) { + container = SeContainerInitializer.newInstance().initialize(); + } + } + + @AfterAll + private static void stopContainer() { + if (container != null) { + container.close(); + } + } + + /* + * @testName: testCDISupport + * + * @assertion_ids: JSONB:SPEC:JSB-4.7.2-3 + * + * @test_Strategy: Assert that CDI injection is supported in serializers and + * deserializers + */ + @Test + public void testCDISupport() { + Jsonb jsonb = JsonbBuilder.create(); + String validationPattern = "\\{\\s*\"animals\"\\s*:\\s*\\[\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"cat\"\\s*,\\s*\"cuddly\"\\s*:\\s*true\\s*,\\s*\"age\"\\s*:\\s*5\\s*," + + "\\s*\"furry\"\\s*:\\s*true\\s*,\\s*\"name\"\\s*:\\s*\"Garfield\"\\s*,\\s*\"weight\"\\s*:\\s*10.5\\s*}\\s*,\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"dog\"\\s*,\\s*\"barking\"\\s*:\\s*true\\s*,\\s*\"age\"\\s*:\\s*3\\s*," + + "\\s*\"furry\"\\s*:\\s*false\\s*,\\s*\"name\"\\s*:\\s*\"Milo\"\\s*,\\s*\"weight\"\\s*:\\s*5.5\\s*}\\s*,\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"animal\"\\s*,\\s*\"age\"\\s*:\\s*6\\s*,\\s*\"furry\"\\s*:\\s*false\\s*," + + "\\s*\"name\"\\s*:\\s*\"Tweety\"\\s*,\\s*\"weight\"\\s*:\\s*0.5\\s*}\\s*" + + "]\\s*}"; + AnimalShelterWithInjectedSerializer animalShelter = new AnimalShelterWithInjectedSerializer(); + animalShelter.addAnimal(new Cat(5, "Garfield", 10.5f, true, true)); + animalShelter.addAnimal(new Dog(3, "Milo", 5.5f, false, true)); + animalShelter.addAnimal(new Animal(6, "Tweety", 0.5f, false)); + + String validationMessage = "Failed to correctly marshall complex type hierarchy using a serializer configured using " + + "JsonbTypeSerializer annotation and a deserializer with a CDI managed field configured using " + + "JsonbTypeDeserializer annotation."; + + String jsonString = jsonb.toJson(animalShelter); + assertThat(validationMessage, jsonString, matchesPattern(validationPattern)); + + String toSerialize = "{ \"animals\" : [ " + + "{ \"type\" : \"cat\", \"cuddly\" : true, \"age\" : 5, \"furry\" : true, \"name\" : \"Garfield\" , \"weight\"" + + " : 10.5}, " + + "{ \"type\" : \"dog\", \"barking\" : true, \"age\" : 3, \"furry\" : false, \"name\" : \"Milo\", \"weight\" : " + + "5.5}, " + + "{ \"type\" : \"animal\", \"age\" : 6, \"furry\" : false, \"name\" : \"Tweety\", \"weight\" : 0.5}" + + " ] }"; + validationMessage = "Failed to correctly unmarshall complex type hierarchy using a serializer configured using " + + "JsonbTypeSerializer annotation and a deserializer with a CDI managed field configured using " + + "JsonbTypeDeserializer annotation."; + AnimalShelterWithInjectedSerializer unmarshalledObject = jsonb + .fromJson(toSerialize, AnimalShelterWithInjectedSerializer.class); + assertThat(validationMessage, unmarshalledObject, is((animalShelter))); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/AnimalShelterWithInjectedSerializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/AnimalShelterWithInjectedSerializer.java new file mode 100644 index 0000000..72befd5 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/AnimalShelterWithInjectedSerializer.java
@@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.cdi.customizedmapping.serializers.model; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.json.bind.annotation.JsonbTypeDeserializer; +import jakarta.json.bind.annotation.JsonbTypeSerializer; + +import ee.jakarta.tck.json.bind.cdi.customizedmapping.serializers.model.serializer.AnimalListDeserializerInjected; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer.AnimalListSerializer; + +public class AnimalShelterWithInjectedSerializer { + @JsonbTypeSerializer(AnimalListSerializer.class) + @JsonbTypeDeserializer(AnimalListDeserializerInjected.class) + private List<Animal> animals = new ArrayList<>(); + + public List<Animal> getAnimals() { + return animals; + } + + public void setAnimals(List<Animal> animals) { + this.animals = animals; + } + + public boolean addAnimal(Animal animal) { + return animals.add(animal); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof AnimalShelterWithInjectedSerializer)) { + return false; + } + + AnimalShelterWithInjectedSerializer that = (AnimalShelterWithInjectedSerializer) o; + + return animals != null ? animals.equals(that.animals) + : that.animals == null; + } + + @Override + public int hashCode() { + return animals != null ? animals.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/serializer/AnimalDeserializerInjected.java b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/serializer/AnimalDeserializerInjected.java new file mode 100644 index 0000000..1d9c12b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/serializer/AnimalDeserializerInjected.java
@@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.cdi.customizedmapping.serializers.model.serializer; + +import java.lang.reflect.Type; + +import jakarta.inject.Inject; +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.stream.JsonParser; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer.AnimalBuilder; + +public class AnimalDeserializerInjected implements JsonbDeserializer<Animal> { + @Inject + private AnimalBuilder animalBuilder; + + public Animal deserialize(JsonParser jsonParser, + DeserializationContext deserializationContext, Type type) { + while (jsonParser.hasNext()) { + JsonParser.Event event = jsonParser.next(); + if (event == JsonParser.Event.START_OBJECT) { + continue; + } + if (event == JsonParser.Event.END_OBJECT) { + break; + } + if (event == JsonParser.Event.KEY_NAME) { + switch (jsonParser.getString()) { + case "type": + jsonParser.next(); + switch (jsonParser.getString()) { + case "cat": + animalBuilder.setType(AnimalBuilder.TYPE.CAT); + break; + case "dog": + animalBuilder.setType(AnimalBuilder.TYPE.DOG); + break; + default: + animalBuilder.setType(AnimalBuilder.TYPE.GENERIC); + } + break; + case "name": + jsonParser.next(); + animalBuilder.setName(jsonParser.getString()); + break; + case "age": + jsonParser.next(); + animalBuilder.setAge(jsonParser.getInt()); + break; + case "furry": + event = jsonParser.next(); + animalBuilder.setFurry(event == JsonParser.Event.VALUE_TRUE); + break; + case "weight": + jsonParser.next(); + animalBuilder.setWeight(jsonParser.getBigDecimal().floatValue()); + break; + case "cuddly": + event = jsonParser.next(); + animalBuilder.setCuddly(event == JsonParser.Event.VALUE_TRUE); + break; + case "barking": + event = jsonParser.next(); + animalBuilder.setBarking(event == JsonParser.Event.VALUE_TRUE); + } + } + } + return animalBuilder.build(); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/serializer/AnimalListDeserializerInjected.java b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/serializer/AnimalListDeserializerInjected.java new file mode 100644 index 0000000..137f91e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/cdi/customizedmapping/serializers/model/serializer/AnimalListDeserializerInjected.java
@@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.cdi.customizedmapping.serializers.model.serializer; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +import jakarta.inject.Inject; +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.stream.JsonParser; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer.AnimalDeserializer; + +public class AnimalListDeserializerInjected + implements JsonbDeserializer<List<Animal>> { + @Inject + private AnimalDeserializer animalDeserializer; + + public List<Animal> deserialize(JsonParser jsonParser, + DeserializationContext deserializationContext, Type type) { + // start array + List<Animal> animals = new ArrayList<>(); + while (jsonParser.next() == JsonParser.Event.START_OBJECT) { + animals.add(animalDeserializer.deserialize(jsonParser, + deserializationContext, type)); + } + + return animals; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/AdaptersCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/AdaptersCustomizationTest.java new file mode 100644 index 0000000..0ce7e4c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/AdaptersCustomizationTest.java
@@ -0,0 +1,125 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; + +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.AnimalShelter; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.AnimalShelterAdapted; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Dog; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalAdapter; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources AdaptersCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.adapters.AdaptersCustomizationTest + **/ +public class AdaptersCustomizationTest { + + private static final String PATTERN = "\\{\\s*\"animals\"\\s*:\\s*\\[\\s*" + + "\\{\\s*\"age\"\\s*:\\s*5\\s*,\\s*\"cuddly\"\\s*:\\s*true\\s*,\\s*\"furry\"\\s*:\\s*true\\s*," + + "\\s*\"name\"\\s*:\\s*\"Garfield\"\\s*,\\s*\"type\"\\s*:\\s*\"CAT\"\\s*,\\s*\"weight\"\\s*:\\s*10.5\\s*}\\s*,\\s*" + + "\\{\\s*\"age\"\\s*:\\s*3\\s*,\\s*\"barking\"\\s*:\\s*true\\s*,\\s*\"furry\"\\s*:\\s*false\\s*," + + "\\s*\"name\"\\s*:\\s*\"Milo\"\\s*,\\s*\"type\"\\s*:\\s*\"DOG\"\\s*,\\s*\"weight\"\\s*:\\s*5.5\\s*}\\s*,\\s*" + + "\\{\\s*\"age\"\\s*:\\s*6\\s*,\\s*\"furry\"\\s*:\\s*false\\s*,\\s*\"name\"\\s*:\\s*\"Tweety\"\\s*," + + "\\s*\"type\"\\s*:\\s*\"GENERIC\"\\s*,\\s*\"weight\"\\s*:\\s*0.5\\s*}\\s*" + + "]\\s*}"; + + /* + * @testName: testAdapterConfiguration + * + * @assertion_ids: JSONB:SPEC:JSB-4.7.1-1 + * + * @test_Strategy: Assert that JSONB adapters can be configured using + * JsonbConfig.withAdapters and are working as expected + */ + @Test + public void testAdapterConfiguration() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withAdapters(new AnimalAdapter())); + + AnimalShelter animalShelter = new AnimalShelter(); + animalShelter.addAnimal(new Cat(5, "Garfield", 10.5f, true, true)); + animalShelter.addAnimal(new Dog(3, "Milo", 5.5f, false, true)); + animalShelter.addAnimal(new Animal(6, "Tweety", 0.5f, false)); + + String jsonString = jsonb.toJson(animalShelter); + + assertThat("Failed to correctly marshall complex type hierarchy using an adapter configured using " + + "JsonbConfig.withAdapters to a simpler class.", + jsonString, matchesPattern(PATTERN)); + + String toSerializer = "{ \"animals\" : [ " + + "{ \"age\" : 5, \"cuddly\" : true, \"furry\" : true, \"name\" : \"Garfield\" , \"type\" : \"CAT\", \"weight\"" + + " : 10.5}, " + + "{ \"age\" : 3, \"barking\" : true, \"furry\" : false, \"name\" : \"Milo\", \"type\" : \"DOG\", \"weight\" : " + + "5.5}, " + + "{ \"age\" : 6, \"furry\" : false, \"name\" : \"Tweety\", \"type\" : \"GENERIC\", \"weight\" : 0.5}" + + " ] }"; + AnimalShelter unmarshalledObject = jsonb.fromJson(toSerializer, AnimalShelter.class); + assertThat("Failed to correctly unmarshall complex type hierarchy using an adapter configured using " + + "JsonbConfig.withAdapters to a simpler class.", + unmarshalledObject, is(animalShelter)); + } + + /* + * @testName: testAdapterAnnotation + * + * @assertion_ids: JSONB:SPEC:JSB-4.7.1-2 + * + * @test_Strategy: Assert that JSONB adapters can be configured using + * JsonbTypeAdapter annotation and are working as expected + */ + @Test + public void testAdapterAnnotation() { + Jsonb jsonb = JsonbBuilder.create(); + AnimalShelterAdapted animalShelter = new AnimalShelterAdapted(); + animalShelter.addAnimal(new Cat(5, "Garfield", 10.5f, true, true)); + animalShelter.addAnimal(new Dog(3, "Milo", 5.5f, false, true)); + animalShelter.addAnimal(new Animal(6, "Tweety", 0.5f, false)); + + String jsonString = jsonb.toJson(animalShelter); + + assertThat("Failed to correctly marshall complex type hierarchy using an adapter configured using " + + "JsonbTypeAdapter annotation to a simpler class.", + jsonString, matchesPattern(PATTERN)); + + String toSerialize = "{ \"animals\" : [ " + + "{ \"age\" : 5, \"cuddly\" : true, \"furry\" : true, \"name\" : \"Garfield\" , \"type\" : \"CAT\", \"weight\"" + + " : 10.5}, " + + "{ \"age\" : 3, \"barking\" : true, \"furry\" : false, \"name\" : \"Milo\", \"type\" : \"DOG\", \"weight\" : " + + "5.5}, " + + "{ \"age\" : 6, \"furry\" : false, \"name\" : \"Tweety\", \"type\" : \"GENERIC\", \"weight\" : 0.5}" + + " ] }"; + AnimalShelterAdapted unmarshalledObject = jsonb.fromJson(toSerialize, AnimalShelterAdapted.class); + assertThat("Failed to correctly unmarshall complex type hierarchy using an adapter configured using " + + "JsonbTypeAdapter annotation to a simpler class.", + unmarshalledObject, is(animalShelter)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Animal.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Animal.java new file mode 100644 index 0000000..99e76bc --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Animal.java
@@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model; + +public class Animal { + private int age; + + private String name; + + private float weight; + + private boolean furry; + + public Animal() { + } + + public Animal(int age, String name, float weight, boolean furry) { + this.age = age; + this.name = name; + this.weight = weight; + this.furry = furry; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public float getWeight() { + return weight; + } + + public void setWeight(float weight) { + this.weight = weight; + } + + public boolean isFurry() { + return furry; + } + + public void setFurry(boolean furry) { + this.furry = furry; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Animal)) { + return false; + } + + Animal animal = (Animal) o; + + if (age != animal.age) { + return false; + } + if (Float.compare(animal.weight, weight) != 0) { + return false; + } + if (furry != animal.furry) { + return false; + } + return name != null ? name.equals(animal.name) : animal.name == null; + } + + @Override + public int hashCode() { + int result = age; + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (weight != +0.0f ? Float.floatToIntBits(weight) : 0); + result = 31 * result + (furry ? 1 : 0); + return result; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/AnimalShelter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/AnimalShelter.java new file mode 100644 index 0000000..463f127 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/AnimalShelter.java
@@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model; + +import java.util.ArrayList; +import java.util.List; + +public class AnimalShelter { + private List<Animal> animals = new ArrayList<>(); + + public List<Animal> getAnimals() { + return animals; + } + + public void setAnimals(List<Animal> animals) { + this.animals = animals; + } + + public boolean addAnimal(Animal animal) { + return animals.add(animal); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof AnimalShelter)) { + return false; + } + + AnimalShelter that = (AnimalShelter) o; + + return animals != null ? animals.equals(that.animals) + : that.animals == null; + } + + @Override + public int hashCode() { + return animals != null ? animals.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/AnimalShelterAdapted.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/AnimalShelterAdapted.java new file mode 100644 index 0000000..108281a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/AnimalShelterAdapted.java
@@ -0,0 +1,65 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.json.bind.annotation.JsonbTypeAdapter; + +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalListAdapter; + +public class AnimalShelterAdapted { + @JsonbTypeAdapter(AnimalListAdapter.class) + private List<Animal> animals = new ArrayList<>(); + + public List<Animal> getAnimals() { + return animals; + } + + public void setAnimals(List<Animal> animals) { + this.animals = animals; + } + + public boolean addAnimal(Animal animal) { + return animals.add(animal); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof AnimalShelterAdapted)) { + return false; + } + + AnimalShelterAdapted that = (AnimalShelterAdapted) o; + + return animals != null ? animals.equals(that.animals) + : that.animals == null; + } + + @Override + public int hashCode() { + return animals != null ? animals.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Cat.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Cat.java new file mode 100644 index 0000000..282c62d --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Cat.java
@@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model; + +public class Cat extends Animal { + public Cat() { + } + + public Cat(int age, String name, float weight, boolean furry, + boolean cuddly) { + super(age, name, weight, furry); + this.cuddly = cuddly; + } + + private boolean cuddly; + + public boolean isCuddly() { + return cuddly; + } + + public void setCuddly(boolean cuddly) { + this.cuddly = cuddly; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Cat)) { + return false; + } + if (!super.equals(o)) { + return false; + } + + Cat cat = (Cat) o; + + return cuddly == cat.cuddly; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (cuddly ? 1 : 0); + return result; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Dog.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Dog.java new file mode 100644 index 0000000..4f6a0e1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/Dog.java
@@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model; + +public class Dog extends Animal { + private boolean barking; + + public Dog() { + } + + public Dog(int age, String name, float weight, boolean furry, + boolean barking) { + super(age, name, weight, furry); + this.barking = barking; + } + + public boolean isBarking() { + return barking; + } + + public void setBarking(boolean barking) { + this.barking = barking; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Dog)) { + return false; + } + if (!super.equals(o)) { + return false; + } + + Dog dog = (Dog) o; + + return barking == dog.barking; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (barking ? 1 : 0); + return result; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalAdapter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalAdapter.java new file mode 100644 index 0000000..6665404 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalAdapter.java
@@ -0,0 +1,74 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter; + +import jakarta.json.bind.adapter.JsonbAdapter; + +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Dog; + +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.CAT; +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.DOG; +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.GENERIC; + +public class AnimalAdapter implements JsonbAdapter<Animal, AnimalJson> { + @Override + public AnimalJson adaptToJson(Animal animal) throws Exception { + AnimalJson adapted = new AnimalJson(); + if (Cat.class.isAssignableFrom(animal.getClass())) { + adapted.setType(CAT); + adapted.setCuddly(((Cat) animal).isCuddly()); + } else if (Dog.class.isAssignableFrom(animal.getClass())) { + adapted.setType(DOG); + adapted.setBarking(((Dog) animal).isBarking()); + } else { + adapted.setType(GENERIC); + } + adapted.setName(animal.getName()); + adapted.setAge(animal.getAge()); + adapted.setFurry(animal.isFurry()); + adapted.setWeight(animal.getWeight()); + return adapted; + } + + @Override + public Animal adaptFromJson(AnimalJson adapted) throws Exception { + Animal animal; + switch (adapted.getType()) { + case CAT: + animal = new Cat(); + ((Cat) animal).setCuddly(adapted.isCuddly()); + break; + case DOG: + animal = new Dog(); + ((Dog) animal).setBarking(adapted.isBarking()); + break; + default: + animal = new Animal(); + } + animal.setName(adapted.getName()); + animal.setAge(adapted.getAge()); + animal.setFurry(adapted.isFurry()); + animal.setWeight(adapted.getWeight()); + return animal; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalIdentifier.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalIdentifier.java new file mode 100644 index 0000000..1b9fd5f --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalIdentifier.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter; + +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Dog; + +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.CAT; +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.DOG; +import static ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter.AnimalJson.TYPE.GENERIC; + +public class AnimalIdentifier { + public AnimalJson.TYPE getType(Animal animal) { + if (Cat.class.isAssignableFrom(animal.getClass())) { + return CAT; + } else if (Dog.class.isAssignableFrom(animal.getClass())) { + return DOG; + } else { + return GENERIC; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalJson.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalJson.java new file mode 100644 index 0000000..d54ba1b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalJson.java
@@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter; + +public class AnimalJson { + public enum TYPE { + CAT, DOG, GENERIC + } + + private TYPE type; + + private int age; + + private String name; + + private float weight; + + private Boolean furry; + + private Boolean cuddly; + + private Boolean barking; + + public TYPE getType() { + return type; + } + + public void setType(TYPE type) { + this.type = type; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public float getWeight() { + return weight; + } + + public void setWeight(float weight) { + this.weight = weight; + } + + public Boolean isFurry() { + return furry; + } + + public void setFurry(Boolean furry) { + this.furry = furry; + } + + public Boolean isCuddly() { + return cuddly; + } + + public void setCuddly(Boolean cuddly) { + this.cuddly = cuddly; + } + + public Boolean isBarking() { + return barking; + } + + public void setBarking(Boolean barking) { + this.barking = barking; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalListAdapter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalListAdapter.java new file mode 100644 index 0000000..817901b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/adapters/model/adapter/AnimalListAdapter.java
@@ -0,0 +1,51 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.adapters.model.adapter; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.json.bind.adapter.JsonbAdapter; + +import ee.jakarta.tck.json.bind.customizedmapping.adapters.model.Animal; + +public class AnimalListAdapter + implements JsonbAdapter<List<Animal>, List<AnimalJson>> { + private AnimalAdapter animalAdapter = new AnimalAdapter(); + + @Override + public List<AnimalJson> adaptToJson(List<Animal> animals) throws Exception { + List<AnimalJson> adapted = new ArrayList<>(); + for (Animal animal : animals) { + adapted.add(animalAdapter.adaptToJson(animal)); + } + return adapted; + } + + @Override + public List<Animal> adaptFromJson(List<AnimalJson> adapted) throws Exception { + List<Animal> animals = new ArrayList<>(); + for (AnimalJson animal : adapted) { + animals.add(animalAdapter.adaptFromJson(animal)); + } + return animals; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/binarydata/BinaryDataCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/binarydata/BinaryDataCustomizationTest.java new file mode 100644 index 0000000..ae5edb0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/binarydata/BinaryDataCustomizationTest.java
@@ -0,0 +1,107 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.binarydata; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.config.BinaryDataStrategy; + +import ee.jakarta.tck.json.bind.customizedmapping.binarydata.model.BinaryDataContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources BinaryDataCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.binarydata.BinaryDataCustomizationTest + **/ +public class BinaryDataCustomizationTest { + + /* + * @testName: testByteBinaryDataEncoding + * + * @assertion_ids: JSONB:SPEC:JSB-4.10-1 + * + * @test_Strategy: Assert that binary data is correctly encoded using BYTE + * binary data encoding + */ + @Test + public void testByteBinaryDataEncoding() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withBinaryDataStrategy(BinaryDataStrategy.BYTE)); + String validationPattern = "\\{\\s*\"data\"\\s*:\\s*\\[\\s*84\\s*,\\s*101\\s*,\\s*115\\s*,\\s*116\\s*,\\s*32\\s*," + + "\\s*83\\s*,\\s*116\\s*,\\s*114\\s*,\\s*105\\s*,\\s*110\\s*,\\s*103\\s*]\\s*}"; + + String jsonString = jsonb.toJson(new BinaryDataContainer()); + assertThat("Failed to correctly marshal binary data using BYTE binary data encoding.", + jsonString, matchesPattern(validationPattern)); + + BinaryDataContainer container = jsonb.fromJson("{ \"data\" : [ 84, 101, 115, 116, 32, 83, 116, 114, 105, 110, 103 ] }", + BinaryDataContainer.class); + assertThat("Failed to correctly unmarshal binary data using BYTE binary data encoding.", + new String(container.getData()), is("Test String")); + } + + /* + * @testName: testBase64BinaryDataEncoding + * + * @assertion_ids: JSONB:SPEC:JSB-4.10-1 + * + * @test_Strategy: Assert that binary data is correctly encoded using BASE_64 + * binary data encoding + */ + @Test + public void testBase64BinaryDataEncoding() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withBinaryDataStrategy(BinaryDataStrategy.BASE_64)); + + String jsonString = jsonb.toJson(new BinaryDataContainer()); + assertThat("Failed to correctly marshal binary data using BASE_64 binary data encoding.", + jsonString, matchesPattern("\\{\\s*\"data\"\\s*:\\s*\"VGVzdCBTdHJpbmc=\"\\s*}")); + + BinaryDataContainer unmarshalledObject = jsonb.fromJson("{ \"data\" : \"VGVzdCBTdHJpbmc\" }", BinaryDataContainer.class); + assertThat("Failed to correctly unmarshal binary data using BASE_64 binary data encoding.", + new String(unmarshalledObject.getData()), is("Test String")); + } + + /* + * @testName: testBase64UrlBinaryDataEncoding + * + * @assertion_ids: JSONB:SPEC:JSB-4.10-1 + * + * @test_Strategy: Assert that binary data is correctly encoded using + * BASE_64_URL binary data encoding + */ + @Test + public void testBase64UrlBinaryDataEncoding() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withBinaryDataStrategy(BinaryDataStrategy.BASE_64_URL)); + + String jsonString = jsonb.toJson(new BinaryDataContainer()); + assertThat("Failed to correctly marshal binary data using BASE_64_URL binary data encoding.", + jsonString, matchesPattern("\\{\\s*\"data\"\\s*:\\s*\"VGVzdCBTdHJpbmc=\"\\s*}")); + + BinaryDataContainer unmarshalledObject = jsonb.fromJson("{ \"data\" : \"VGVzdCBTdHJpbmc=\" }", BinaryDataContainer.class); + assertThat("Failed to correctly unmarshal binary data using BASE_64_URL binary data encoding.", + new String(unmarshalledObject.getData()), is("Test String")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/binarydata/model/BinaryDataContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/binarydata/model/BinaryDataContainer.java new file mode 100644 index 0000000..4a84224 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/binarydata/model/BinaryDataContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.binarydata.model; + +public class BinaryDataContainer { + private byte[] data = "Test String".getBytes(); + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data = data; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/DateFormatCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/DateFormatCustomizationTest.java new file mode 100644 index 0000000..a71e3ea --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/DateFormatCustomizationTest.java
@@ -0,0 +1,458 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat; + +import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.text.SimpleDateFormat; +import java.time.ZoneId; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeFormatterBuilder; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.annotation.JsonbDateFormat; + +import ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.AnnotatedAccessorsDateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.AnnotatedFieldDateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.AnnotatedTypeDateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.AnnotatedTypeFieldOverrideDateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.DateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.customized.CustomizedPackageDateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.customized.CustomizedPackageTypeOverrideDateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.customized.CustomizedPackageTypeOverrideFieldOverrideDateContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.jupiter.api.Assertions.fail; + +/** + * @test + * @sources DateFormatCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.dateformat.DateFormatCustomizationTest + **/ +public class DateFormatCustomizationTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testDateFormatConfig + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-3 + * + * @test_Strategy: Assert that JsonbConfig.withDateFormat customization is + * correctly applied + */ + @Test + public void testDateFormatConfig() { + String format = "E DD MMM yyyy HH:mm:ss z"; + Locale locale = Locale.GERMAN; + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withDateFormat(format, locale)); + Date instance = new Date(0); + String jsonString = jsonb.toJson(new DateContainer() {{ + setInstance(instance); + }}); + + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format, locale, instance); + assertThat("Failed to correctly customize date format during marshalling using JsonbConfig.withDateFormat.", + jsonString, matchesPattern(toMatch)); + + String json = String.format("{ \"instance\" : \"%s 1970 01:00:00 MEZ\" }", getDay("19700001", Locale.GERMAN)); + DateContainer unmarshalledObject = jsonb.fromJson(json, DateContainer.class); + assertThat("Failed to correctly customize date format during unmarshalling using JsonbConfig.withDateFormat.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatPackage + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1 + * + * @test_Strategy: Assert that date customization using JsonbDateFormat + * annotation on package is correctly applied + */ + @Test + public void testDateFormatPackage() { + Date instance = new Date(0); + String jsonString = jsonb.toJson(new CustomizedPackageDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotationOnPackage(CustomizedPackageDateContainer.class, JsonbDateFormat.class); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly customize date format during marshalling using JsonbDateFormat annotation on package.", + jsonString, matchesPattern(toMatch)); + + String json = String.format("{ \"instance\" : \"%s 1970 01:00:00 CET\" }", getDay("19700001", Locale.ITALY)); + CustomizedPackageDateContainer unmarshalledObject = jsonb.fromJson(json, CustomizedPackageDateContainer.class); + assertThat("Failed to correctly customize date format during unmarshalling using JsonbDateFormat annotation on package.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatType + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1 + * + * @test_Strategy: Assert that date customization using JsonbDateFormat + * annotation on type is correctly applied + */ + @Test + public void testDateFormatType() { + Date instance = new Date(0); + String jsonString = jsonb.toJson(new AnnotatedTypeDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotation(AnnotatedTypeDateContainer.class, JsonbDateFormat.class); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly customize date format during marshalling using JsonbDateFormat annotation on type.", + jsonString, matchesPattern(toMatch)); + + String json = String.format("{ \"instance\" : \"%s 1970 01:00:00 MEZ\" }", getDay("19700001", Locale.GERMAN)); + AnnotatedTypeDateContainer unmarshalledObject = jsonb.fromJson(json, AnnotatedTypeDateContainer.class); + assertThat("Failed to correctly customize date format during unmarshalling using JsonbDateFormat annotation on type.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatField + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1 + * + * @test_Strategy: Assert that date customization using JsonbDateFormat + * annotation on field is correctly applied + */ + @Test + public void testDateFormatField() { + Date instance = new Date(0); + String jsonString = jsonb.toJson(new AnnotatedFieldDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotationOnField(AnnotatedFieldDateContainer.class, JsonbDateFormat.class, "instance"); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly customize date format during marshalling using JsonbDateFormat annotation on type.", + jsonString, matchesPattern(toMatch)); + + String json = String.format("{ \"instance\" : \"%s 1970 01:00:00 MEZ\" }", getDay("19700001", Locale.GERMAN)); + AnnotatedFieldDateContainer unmarshalledObject = jsonb.fromJson(json, AnnotatedFieldDateContainer.class); + assertThat("Failed to correctly customize date format during unmarshalling using JsonbDateFormat annotation on field.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatAccessors + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1 + * + * @test_Strategy: Assert that date customization using JsonbDateFormat + * annotation on accessors is individually applied on marshalling and + * unmarshalling + */ + @Test + public void testDateFormatAccessors() { + Date instance = new Date(0); + String jsonString = jsonb.toJson(new AnnotatedAccessorsDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotationOnMethod(AnnotatedAccessorsDateContainer.class, + JsonbDateFormat.class, + "getInstance"); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly customize date format during marshalling using JsonbDateFormat annotation on getter.", + jsonString, matchesPattern(toMatch)); + + String json = String.format("{ \"instance\" : \"%s 1970 01:00:00 MEZ\" }", getDay("19700001", Locale.GERMAN)); + AnnotatedAccessorsDateContainer unmarshalledObject = jsonb.fromJson(json, AnnotatedAccessorsDateContainer.class); + assertThat("Failed to correctly customize date format during unmarshalling using JsonbDateFormat annotation on setter.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatConfigPackageOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1; JSONB:SPEC:JSB-4.8-2; + * JSONB:SPEC:JSB-4.8-3 + * + * @test_Strategy: Assert that JsonbConfig.withDateFormat customization is + * correctly overridden by annotating package with JsonbDateFormat + */ + @Test + public void testDateFormatConfigPackageOverride() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withDateFormat("E DD MMM yyyy HH:mm:ss z", Locale.GERMAN)); + + Date instance = new Date(0); + String jsonString = jsonb.toJson(new CustomizedPackageDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotationOnPackage(CustomizedPackageDateContainer.class, JsonbDateFormat.class); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly override date format customization using JsonbConfig.withDateFormat during " + + "marshalling by annotating package with JsonbDateFormat.", + jsonString, matchesPattern(toMatch)); + + String json = String.format("{ \"instance\" : \"%s 1970 01:00:00 CET\" }", getDay("19700001", Locale.ITALY)); + CustomizedPackageDateContainer unmarshalledObject = jsonb.fromJson(json, CustomizedPackageDateContainer.class); + assertThat("Failed to correctly override date format customization using JsonbConfig.withDateFormat during " + + "unmarshalling by annotating package with JsonbDateFormat.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatPackageTypeOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1; JSONB:SPEC:JSB-4.8-2 + * + * @test_Strategy: Assert that date customization using JsonbDateFormat + * annotation on package is correctly overridden by annotating type using + * JsonbDateFormat + */ + @Test + public void testDateFormatPackageTypeOverride() { + Date instance = new Date(0); + String jsonString = jsonb.toJson(new CustomizedPackageTypeOverrideDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotation(CustomizedPackageTypeOverrideDateContainer.class, JsonbDateFormat.class); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly override date format customization using JsonbDateFormat annotation " + + "on package during marshalling using JsonbDateFormat annotation on type.", + jsonString, matchesPattern(toMatch)); + + toMatch = completeByFormat("{ \"instance\" : ", " }", format.value(), locale, instance); + CustomizedPackageTypeOverrideDateContainer unmarshalledObject = jsonb.fromJson(toMatch, + CustomizedPackageTypeOverrideDateContainer.class); + assertThat("Failed to correctly override date format customization using JsonbDateFormat annotation " + + "on package during unmarshalling using JsonbDateFormat annotation on type.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatTypeFieldOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1; JSONB:SPEC:JSB-4.8-2 + * + * @test_Strategy: Assert that date customization using JsonbDateFormat + * annotation on type is correctly overridden by annotating field using + * JsonbDateFormat + */ + @Test + public void testDateFormatTypeFieldOverride() { + Date instance = new Date(0); + String jsonString = jsonb.toJson(new AnnotatedTypeFieldOverrideDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotationOnField(AnnotatedTypeFieldOverrideDateContainer.class, + JsonbDateFormat.class, + "instance"); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly customize date format during marshalling using JsonbDateFormat annotation on type.", + jsonString, matchesPattern(toMatch)); + + String json = String.format("{ \"instance\" : \"%s 1970 01:00:00 CET\" }", getDay("19700001", Locale.ITALY)); + AnnotatedTypeFieldOverrideDateContainer unmarshalledObject = jsonb.fromJson(json, + AnnotatedTypeFieldOverrideDateContainer.class); + assertThat("Failed to correctly customize date format during unmarshalling using JsonbDateFormat annotation on type.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatConfigPackageOverrideTypeOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1; JSONB:SPEC:JSB-4.8-2; + * JSONB:SPEC:JSB-4.8-3 + * + * @test_Strategy: Assert that JsonbConfig.withDateFormat customization and + * package annotating with JsonbDateFormat is correctly overridden by + * annotating type with JsonbDateFormat + */ + @Test + public void testDateFormatConfigPackageOverrideTypeOverride() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withDateFormat("E DD MMM yyyy HH:mm:ss z", Locale.CANADA)); + Date instance = new Date(0); + String jsonString = jsonb.toJson(new CustomizedPackageTypeOverrideDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotation(CustomizedPackageTypeOverrideDateContainer.class, JsonbDateFormat.class); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly override date format customization using JsonbConfig.withDateFormat and " + + "package annotating with JsonbDateFormat during marshalling by annotating type with " + + "JsonbDateFormat.", + jsonString, matchesPattern(toMatch)); + + toMatch = completeByFormat("{ \"instance\" : ", " }", format.value(), locale, instance); + CustomizedPackageTypeOverrideDateContainer unmarshalledObject = jsonb.fromJson(toMatch, + CustomizedPackageTypeOverrideDateContainer.class); + assertThat("Failed to correctly override date format customization using JsonbConfig.withDateFormat and " + + "package annotating with JsonbDateFormat during unmarshalling by annotating type with " + + "JsonbDateFormat.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatPackageTypeOverrideFieldOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1; JSONB:SPEC:JSB-4.8-2 + * + * @test_Strategy: Assert that date customization using JsonbDateFormat + * annotation on package and type is correctly overridden by annotating field + * using JsonbDateFormat + */ + @Test + public void testDateFormatPackageTypeOverrideFieldOverride() { + Date instance = new Date(0); + String jsonString = jsonb.toJson(new CustomizedPackageTypeOverrideFieldOverrideDateContainer() {{ + setInstance(instance); + }}); + JsonbDateFormat format = getAnnotationOnField(CustomizedPackageTypeOverrideFieldOverrideDateContainer.class, + JsonbDateFormat.class, + "instance"); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + assertThat("Failed to correctly override date format customization using JsonbDateFormat annotation on " + + "package and type during marshalling using JsonbDateFormat annotation on field.", + jsonString, matchesPattern(toMatch)); + + toMatch = completeByFormat("{ \"instance\" : ", " }", format.value(), locale, instance); + CustomizedPackageTypeOverrideFieldOverrideDateContainer unmarshalledObject = + jsonb.fromJson(toMatch, CustomizedPackageTypeOverrideFieldOverrideDateContainer.class); + assertThat("Failed to correctly override date format customization using JsonbDateFormat annotation on " + + "package and type during unmarshalling using JsonbDateFormat annotation on field.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDateFormatConfigPackageOverrideTypeOverrideFieldOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.8-1; JSONB:SPEC:JSB-4.8-2; + * JSONB:SPEC:JSB-4.8-3 + * + * @test_Strategy: Assert that JsonbConfig.withDateFormat customization and + * package and type annotating with JsonbDateFormat is correctly overridden by + * annotating field with JsonbDateFormat + */ + @Test + public void testDateFormatConfigPackageOverrideTypeOverrideFieldOverride() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withDateFormat("E DD MMM yyyy HH:mm:ss z", Locale.GERMAN)); + Date instance = new Date(0); + JsonbDateFormat format = getAnnotationOnField(CustomizedPackageTypeOverrideFieldOverrideDateContainer.class, + JsonbDateFormat.class, + "instance"); + Locale locale = new Locale.Builder().setLanguage(format.locale()).build(); + String toMatch = completeByFormat("\\{\\s*\"instance\"\\s*:\\s*", "\\s*\\}", format.value(), locale, instance); + String jsonString = jsonb.toJson(new CustomizedPackageTypeOverrideFieldOverrideDateContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to correctly override date format customization using JsonbConfig.withDateFormat and package " + + "and type annotating with JsonbDateFormat during marshalling by annotating field with " + + "JsonbDateFormat.", + jsonString, matchesPattern(toMatch)); + + toMatch = completeByFormat("{ \"instance\" : ", " }", format.value(), locale, instance); + CustomizedPackageTypeOverrideFieldOverrideDateContainer unmarshalledObject = jsonb + .fromJson(toMatch, CustomizedPackageTypeOverrideFieldOverrideDateContainer.class); + assertThat("Failed to correctly override date format customization using JsonbConfig.withDateFormat and package " + + "and type annotating with JsonbDateFormat during unmarshalling by annotating field with " + + "JsonbDateFormat.", + unmarshalledObject.getInstance(), is(instance)); + } + + private String completeByFormat(String prefix, String suffix, String mask, + Locale locale, Date value) { + return prefix + '"' + format(mask, locale, value) + '"' + suffix; + } + + private String format(String mask, Locale locale, Date value) { + DateTimeFormatter dtf = new DateTimeFormatterBuilder().appendPattern(mask).toFormatter(locale); + return dtf.format(ZonedDateTime.ofInstant(value.toInstant(), ZoneId.of("UTC"))); + } + + private static <T extends Annotation> T getAnnotation(Class<?> clz, Class<T> annotation) { + return getAnnotationOnElement(clz, annotation); + } + + private static <T extends Annotation> T getAnnotationOnMethod(Class<?> clz, + Class<T> annotation, + String methodName, + Class<?>... params) { + try { + Method m = clz.getDeclaredMethod(methodName, params); + return getAnnotationOnElement(m, annotation); + } catch (NoSuchMethodException | SecurityException e) { + fail(e.getMessage()); + return null; + } + } + + private static <T extends Annotation> T getAnnotationOnField(Class<?> clz, Class<T> annotation, String fieldName) { + try { + Field f = clz.getDeclaredField(fieldName); + return getAnnotationOnElement(f, annotation); + } catch (NoSuchFieldException | SecurityException e) { + fail(e.getMessage()); + return null; + } + + } + + private static <T extends Annotation> T getAnnotationOnPackage(Class<?> clz, + Class<T> annotation) { + Package p = clz.getPackage(); + return getAnnotationOnElement(p, annotation); + } + + private static <T extends Annotation> T getAnnotationOnElement( + AnnotatedElement e, Class<T> annotation) { + T[] a = e.getAnnotationsByType(annotation); + if (a == null || a.length == 0) { + fail("No " + annotation.getName() + " annotation on " + e); + } + if (a.length != 1) { + fail("Too many " + annotation.getName() + " annotation on " + e); + } + return a[0]; + } + + private static String getDay(String yyyymmdd, Locale locale) { + Calendar c = Calendar.getInstance(locale); + c.set(Calendar.YEAR, Integer.parseInt(yyyymmdd.substring(0, 4))); + c.set(Calendar.MONTH, Integer.parseInt(yyyymmdd.substring(4, 6))); + c.set(Calendar.DATE, Integer.parseInt(yyyymmdd.substring(6, 8))); + SimpleDateFormat sdf = new SimpleDateFormat("EEE' 'dd' 'MMM", locale); + return sdf.format(c.getTime()); + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedAccessorsDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedAccessorsDateContainer.java new file mode 100644 index 0000000..0b83ca0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedAccessorsDateContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model; + +import java.util.Date; + +import jakarta.json.bind.annotation.JsonbDateFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class AnnotatedAccessorsDateContainer implements TypeContainer<Date> { + private Date instance; + + @Override + @JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss z", locale = "it") + public Date getInstance() { + return instance; + } + + @Override + @JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss z", locale = "de") + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedFieldDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedFieldDateContainer.java new file mode 100644 index 0000000..e01ed07 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedFieldDateContainer.java
@@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model; + +import java.util.Date; + +import jakarta.json.bind.annotation.JsonbDateFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class AnnotatedFieldDateContainer implements TypeContainer<Date> { + @JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss z", locale = "de") + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedTypeDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedTypeDateContainer.java new file mode 100644 index 0000000..75b05b0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedTypeDateContainer.java
@@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model; + +import java.util.Date; + +import jakarta.json.bind.annotation.JsonbDateFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss z", locale = "de") +public class AnnotatedTypeDateContainer implements TypeContainer<Date> { + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedTypeFieldOverrideDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedTypeFieldOverrideDateContainer.java new file mode 100644 index 0000000..a2fe925 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/AnnotatedTypeFieldOverrideDateContainer.java
@@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model; + +import java.util.Date; + +import jakarta.json.bind.annotation.JsonbDateFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss z", locale = "de") +public class AnnotatedTypeFieldOverrideDateContainer + implements TypeContainer<Date> { + @JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss z", locale = "it") + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/DateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/DateContainer.java new file mode 100644 index 0000000..d68f5e7 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/DateContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model; + +import java.util.Date; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class DateContainer implements TypeContainer<Date> { + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageDateContainer.java new file mode 100644 index 0000000..347f0c9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageDateContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.customized; + +import java.util.Date; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class CustomizedPackageDateContainer implements TypeContainer<Date> { + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageTypeOverrideDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageTypeOverrideDateContainer.java new file mode 100644 index 0000000..d9f32bd --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageTypeOverrideDateContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.customized; + +import java.util.Date; + +import jakarta.json.bind.annotation.JsonbDateFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss", locale = "de") +public class CustomizedPackageTypeOverrideDateContainer + implements TypeContainer<Date> { + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageTypeOverrideFieldOverrideDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageTypeOverrideFieldOverrideDateContainer.java new file mode 100644 index 0000000..d57aa07 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/CustomizedPackageTypeOverrideFieldOverrideDateContainer.java
@@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.customized; + +import java.util.Date; + +import jakarta.json.bind.annotation.JsonbDateFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss", locale = "de") +public class CustomizedPackageTypeOverrideFieldOverrideDateContainer + implements TypeContainer<Date> { + @JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss", locale = "it") + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/package-info.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/package-info.java new file mode 100644 index 0000000..61c79a2 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/dateformat/model/customized/package-info.java
@@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +@JsonbDateFormat(value = "E DD MMM yyyy HH:mm:ss z", locale = "it") +package ee.jakarta.tck.json.bind.customizedmapping.dateformat.model.customized; + +import jakarta.json.bind.annotation.JsonbDateFormat;
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/IJsonSupportTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/IJsonSupportTest.java new file mode 100644 index 0000000..a709216 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/IJsonSupportTest.java
@@ -0,0 +1,252 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson; + +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.TimeZone; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.customizedmapping.ijson.model.BinaryDataContainer; +import ee.jakarta.tck.json.bind.customizedmapping.ijson.model.CalendarContainer; +import ee.jakarta.tck.json.bind.customizedmapping.ijson.model.DateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.ijson.model.DurationContainer; +import ee.jakarta.tck.json.bind.customizedmapping.ijson.model.GregorianCalendarContainer; +import ee.jakarta.tck.json.bind.customizedmapping.ijson.model.InstantContainer; +import ee.jakarta.tck.json.bind.customizedmapping.ijson.model.LocalDateContainer; +import ee.jakarta.tck.json.bind.customizedmapping.ijson.model.LocalDateTimeContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @test + * @sources IJsonSupportTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.ijson.IJsonSupportTest + **/ +public class IJsonSupportTest { + + private final Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withStrictIJSON(true)); + + /* + * @testName: testStrictNonObjectOrArrayTopLevel + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1 + * + * @test_Strategy: Assert that top level JSON texts that are neither objects + * or arrays are restricted during marshalling if JsonbConfig.withStrictIJSON + * is used + */ + @Test + public void testStrictNonObjectOrArrayTopLevel() { + assertThrows(JsonbException.class, + () -> jsonb.toJson("Test String"), + "Failed to restrict serialization of top-level JSON texts that are neither objects " + + "nor arrays when JsonbConfig.withStrictIJSON is used."); + } + + /* + * @testName: testStrictBinaryDataEncoding + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1 + * + * @test_Strategy: Assert that binary data is correctly encoded using + * BASE_64_URL binary data encoding if JsonbConfig.withStrictIJSON is used + */ + @Test + public void testStrictBinaryDataEncoding() { + String jsonString = jsonb.toJson(new BinaryDataContainer()); + assertThat("Failed to correctly marshal binary data using BASE_64_URL binary data encoding when " + + "JsonbConfig.withStrictIJSON is used.", + jsonString, matchesPattern("\\{\\s*\"data\"\\s*:\\s*\"VGVzdCBTdHJpbmc=\"\\s*}")); + } + + /* + * @testName: testStrictDate + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1; JSONB:SPEC:JSB-4.4.1-1; + * JSONB:SPEC:JSB-4.4.1-2; JSONB:SPEC:JSB-4.4.1-3 + * + * @test_Strategy: Assert that java.util.Date is serialized in the same format + * as java.time.ZonedDateTime if JsonbConfig.withStrictIJSON is used + */ + @Test + public void testStrictDate() { + final Calendar instance = Calendar.getInstance(); + instance.clear(); + instance.set(1970, Calendar.JANUARY, 1); + instance.setTimeZone(TimeZone.getTimeZone("UTC")); + String jsonString = jsonb.toJson(new DateContainer() { + { + setInstance(instance.getTime()); + } + }); + assertThat("Failed to serialize java.util.Date in the same format as java.time.ZonedDateTime when " + + "JsonbConfig.withStrictIJSON is used.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"1970-01-01T00:00:00Z\\+00:00\"\\s*}")); + } + + /* + * @testName: testStrictCalendar + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1; JSONB:SPEC:JSB-4.4.1-1; + * JSONB:SPEC:JSB-4.4.1-2; JSONB:SPEC:JSB-4.4.1-3 + * + * @test_Strategy: Assert that java.util.Calendar is serialized in the same + * format as java.time.ZonedDateTime if JsonbConfig.withStrictIJSON is used + */ + @Test + public void testStrictCalendar() { + Calendar calendarProperty = Calendar.getInstance(); + calendarProperty.clear(); + calendarProperty.set(1970, Calendar.JANUARY, 1); + calendarProperty.setTimeZone(TimeZone.getTimeZone("Europe/Paris")); + + String jsonString = jsonb.toJson(new CalendarContainer() { + { + setInstance(calendarProperty); + } + }); + assertThat("Failed to serialize java.util.Calendar in the same format as java.time.ZonedDateTime when " + + "JsonbConfig.withStrictIJSON is used.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"1970-01-01T00:00:00Z\\+01:00\"\\s*}")); + } + + /* + * @testName: testStrictGregorianCalendar + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1; JSONB:SPEC:JSB-4.4.1-1; + * JSONB:SPEC:JSB-4.4.1-2; JSONB:SPEC:JSB-4.4.1-3 + * + * @test_Strategy: Assert that java.util.GregorianCalendar is serialized in + * the same format as java.time.ZonedDateTime if JsonbConfig.withStrictIJSON + * is used + */ + @Test + public void testStrictGregorianCalendar() { + GregorianCalendar gregorianCalendar = new GregorianCalendar(); + gregorianCalendar.set(1970, Calendar.JANUARY, 1, 0, 0, 0); + gregorianCalendar.setTimeZone(TimeZone.getTimeZone("Europe/Paris")); + + String jsonString = jsonb.toJson(new GregorianCalendarContainer() { + { + setInstance(gregorianCalendar); + } + }); + assertThat("Failed to serialize java.util.GregorianCalendar in the same format as java.time.ZonedDateTime when " + + "JsonbConfig.withStrictIJSON is used.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"1970-01-01T00:00:00Z\\+01:00\"\\s*}")); + } + + /* + * @testName: testStrictLocalDate + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1; JSONB:SPEC:JSB-4.4.1-1; + * JSONB:SPEC:JSB-4.4.1-2; JSONB:SPEC:JSB-4.4.1-3 + * + * @test_Strategy: Assert that java.time.LocalDate is serialized in the same + * format as java.time.ZonedDateTime if JsonbConfig.withStrictIJSON is used + */ + @Test + public void testStrictLocalDate() { + String jsonString = jsonb.toJson(new LocalDateContainer() { + { + setInstance(LocalDate.of(1970, 1, 1)); + } + }); + assertThat("Failed to serialize java.time.LocalDate in the same format as java.time.ZonedDateTime when " + + "JsonbConfig.withStrictIJSON is used.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"1970-01-01T00:00:00Z\\+00:00\"\\s*}")); + } + + /* + * @testName: testStrictLocalDateTime + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1; JSONB:SPEC:JSB-4.4.1-1; + * JSONB:SPEC:JSB-4.4.1-2; JSONB:SPEC:JSB-4.4.1-3 + * + * @test_Strategy: Assert that java.time.LocalDate is serialized in the same + * format as java.time.ZonedDateTime if JsonbConfig.withStrictIJSON is used + */ + @Test + public void testStrictLocalDateTime() { + String jsonString = jsonb.toJson(new LocalDateTimeContainer() { + { + setInstance(LocalDateTime.of(1970, 1, 1, 1, 1, 1)); + } + }); + assertThat("Failed to serialize java.time.LocalDate in the same format as java.time.ZonedDateTime when " + + "JsonbConfig.withStrictIJSON is used.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"1970-01-01T01:01:01Z\\+00:00\"\\s*}")); + } + + /* + * @testName: testStrictInstant + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1; JSONB:SPEC:JSB-4.4.1-1; + * JSONB:SPEC:JSB-4.4.1-2; JSONB:SPEC:JSB-4.4.1-3 + * + * @test_Strategy: Assert that java.time.Instant is serialized in the same + * format as java.time.ZonedDateTime if JsonbConfig.withStrictIJSON is used + */ + @Test + public void testStrictInstant() { + String jsonString = jsonb.toJson(new InstantContainer() { + { + setInstance(Instant.ofEpochMilli(0)); + } + }); + assertThat("Failed to serialize java.time.Instant in the same format as java.time.ZonedDateTime when " + + "JsonbConfig.withStrictIJSON is used.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"1970-01-01T00:00:00Z\\+00:00\"\\s*}")); + } + + /* + * @testName: testStrictDuration + * + * @assertion_ids: JSONB:SPEC:JSB-4.4-1; JSONB:SPEC:JSB-4.4.1-1; + * JSONB:SPEC:JSB-4.4.1-4 + * + * @test_Strategy: Assert that java.time.Duration is serialized in the same + * format as in Appendix A of RFC 3339 + */ + @Test + public void testStrictDuration() { + String jsonString = jsonb.toJson(new DurationContainer() { + { + setInstance(Duration.ofDays(1).plus(Duration.ofHours(1)) + .plus(Duration.ofSeconds(1))); + } + }); + assertThat("Failed to serialize java.time.Duration in the same format as in Appendix A of RFC 3339.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"PT25H1S\"\\s*}")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/BinaryDataContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/BinaryDataContainer.java new file mode 100644 index 0000000..a0dc0a3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/BinaryDataContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson.model; + +public class BinaryDataContainer { + private byte[] data = "Test String".getBytes(); + + public byte[] getData() { + return data; + } + + public void setData(byte[] data) { + this.data = data; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/CalendarContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/CalendarContainer.java new file mode 100644 index 0000000..9a346bf --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/CalendarContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson.model; + +import java.util.Calendar; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class CalendarContainer implements TypeContainer<Calendar> { + private Calendar instance; + + @Override + public Calendar getInstance() { + return instance; + } + + @Override + public void setInstance(Calendar instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/DateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/DateContainer.java new file mode 100644 index 0000000..3989fdc --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/DateContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson.model; + +import java.util.Date; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class DateContainer implements TypeContainer<Date> { + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/DurationContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/DurationContainer.java new file mode 100644 index 0000000..0d30b0c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/DurationContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson.model; + +import java.time.Duration; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class DurationContainer implements TypeContainer<Duration> { + private Duration instance; + + @Override + public Duration getInstance() { + return instance; + } + + @Override + public void setInstance(Duration instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/GregorianCalendarContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/GregorianCalendarContainer.java new file mode 100644 index 0000000..208086c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/GregorianCalendarContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson.model; + +import java.util.GregorianCalendar; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class GregorianCalendarContainer + implements TypeContainer<GregorianCalendar> { + private GregorianCalendar instance; + + @Override + public GregorianCalendar getInstance() { + return instance; + } + + @Override + public void setInstance(GregorianCalendar instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/InstantContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/InstantContainer.java new file mode 100644 index 0000000..bda7a77 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/InstantContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson.model; + +import java.time.Instant; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class InstantContainer implements TypeContainer<Instant> { + private Instant instance; + + @Override + public Instant getInstance() { + return instance; + } + + @Override + public void setInstance(Instant instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/LocalDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/LocalDateContainer.java new file mode 100644 index 0000000..9596718 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/LocalDateContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson.model; + +import java.time.LocalDate; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LocalDateContainer implements TypeContainer<LocalDate> { + private LocalDate instance; + + @Override + public LocalDate getInstance() { + return instance; + } + + @Override + public void setInstance(LocalDate instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/LocalDateTimeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/LocalDateTimeContainer.java new file mode 100644 index 0000000..75a6f6a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/ijson/model/LocalDateTimeContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.ijson.model; + +import java.time.LocalDateTime; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LocalDateTimeContainer implements TypeContainer<LocalDateTime> { + private LocalDateTime instance; + + @Override + public LocalDateTime getInstance() { + return instance; + } + + @Override + public void setInstance(LocalDateTime instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/InstantiationCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/InstantiationCustomizationTest.java new file mode 100644 index 0000000..3d87679 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/InstantiationCustomizationTest.java
@@ -0,0 +1,234 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.CreatorWithAdapterContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.CreatorWithDeserializerContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.CreatorPlusFactoryContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.IllegalInstanceFactoryCreatorContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.MultipleCreatorsContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.MultipleFactoryCreatorsContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.SimpleCreatorContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.SimpleCreatorPlusFieldsContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.SimpleCreatorRenameContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.SimpleFactoryCreatorContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.notNullValue; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @test + * @sources InstantiationCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.instantiation.InstantiationCustomizationTest + **/ +public class InstantiationCustomizationTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testCustomConstructor + * + * @assertion_ids: JSONB:SPEC:JSB-4.5-1 + * + * @test_Strategy: Assert that a constructor annotated with JsonbCreator + * annotation can be used to customize class instantiation during + * unmarshalling + */ + @Test + public void testCustomConstructor() { + String toDeserialize = "{ \"stringInstance\" : \"Test String\", \"integerInstance\" : 1, \"floatInstance\" : 1.0 }"; + SimpleCreatorContainer unmarshalledObject = jsonb.fromJson(toDeserialize, SimpleCreatorContainer.class); + + String validationMessage = "Failed to instantiate type using JsonbCreator annotated constructor during unmarshalling."; + assertThat(validationMessage, unmarshalledObject.getStringInstance(), is("Constructor String")); + assertThat(validationMessage, unmarshalledObject.getIntegerInstance(), is(2)); + assertThat(validationMessage, unmarshalledObject.getFloatInstance(), is(2f)); + } + + /* + * @testName: testCustomConstructorPlusFields + * + * @assertion_ids: JSONB:SPEC:JSB-4.5-1 + * + * @test_Strategy: Assert that a constructor annotated with JsonbCreator + * annotation can be used to customize class instantiation during + * unmarshalling and the rest of the fields can be initialized normally + */ + @Test + public void testCustomConstructorPlusFields() { + String toDeserialize = "{ \"stringInstance\" : \"Test String\", \"integerInstance\" : 1, \"floatInstance\" : 1.0 }"; + SimpleCreatorPlusFieldsContainer unmarshalledObject = jsonb + .fromJson(toDeserialize, SimpleCreatorPlusFieldsContainer.class); + + String validationMessage = "Failed to instantiate type using JsonbCreator annotated constructor and set remaining " + + "fields as normally during unmarshalling."; + assertThat(validationMessage, unmarshalledObject.getStringInstance(), is("Constructor String")); + assertThat(validationMessage, unmarshalledObject.getIntegerInstance(), is(2)); + assertThat(validationMessage, unmarshalledObject.getFloatInstance(), is(1f)); + } + + /* + * @testName: testFactoryMethod + * + * @assertion_ids: JSONB:SPEC:JSB-4.5-1 + * + * @test_Strategy: Assert that a method annotated with JsonbCreator annotation + * can be used to customize class instantiation during unmarshalling + */ + @Test + public void testFactoryMethod() { + String toDeserialize = "{ \"constructorString\" : \"Test String\" }"; + SimpleFactoryCreatorContainer unmarshalledObject = jsonb.fromJson(toDeserialize, SimpleFactoryCreatorContainer.class); + + String validationMessage = "Failed to instantiate type using JsonbCreator annotated method during unmarshalling."; + assertThat(validationMessage, unmarshalledObject.getStringInstance(), is("Factory String")); + assertThat(validationMessage, unmarshalledObject.getIntegerInstance(), is(2)); + assertThat(validationMessage, unmarshalledObject.getFloatInstance(), is(3f)); + } + + /* + * @testName: testMultipleConstructors + * + * @assertion_ids: JSONB:SPEC:JSB-4.5-1 + * + * @test_Strategy: Assert that a JsonbException is thrown if multiple + * constructors are annotated with JsonbCreator annotation + */ + @Test + public void testMultipleConstructors() { + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"stringInstance\" : \"Test String\", " + + "\"integerInstance\" : 1, \"floatInstance\" : 1.0 }", + MultipleCreatorsContainer.class), + "A JsonbException is expected when unmarshalling to a class with multiple constructors annotated " + + "with JsonbCreator."); + } + + /* + * @testName: testMultipleFactories + * + * @assertion_ids: JSONB:SPEC:JSB-4.5-1 + * + * @test_Strategy: Assert that a JsonbException is thrown if multiple methods + * are annotated with JsonbCreator annotation + */ + @Test + public void testMultipleFactories() { + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"stringInstance\" : \"Test String\", " + + "\"integerInstance\" : 1, \"floatInstance\" : 1.0 }", + MultipleFactoryCreatorsContainer.class), + "A JsonbException is expected when unmarshalling to a class with multiple methods annotated " + + "with JsonbCreator."); + } + + /* + * @testName: testConstructorPlusFactory + * + * @assertion_ids: JSONB:SPEC:JSB-4.5-1 + * + * @test_Strategy: Assert that a JsonbException is thrown if JsonbCreator + * annotation instances are used to instantiate a type + */ + @Test + public void testConstructorPlusFactory() { + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"stringInstance\" : \"Test String\", " + + "\"integerInstance\" : 1, \"floatInstance\" : 1.0 }", + CreatorPlusFactoryContainer.class), + "A JsonbException is expected when unmarshalling to a class with multiple JsonbCreator " + + "annotation instances."); + } + + /* + * @testName: testIllegalFactoryType + * + * @assertion_ids: JSONB:SPEC:JSB-4.5-2 + * + * @test_Strategy: Assert that a JsonbException is thrown if the type returned + * by the factory method annotated with JsonbCreator is not the type that the + * annotation is used for + */ + @Test + public void testIllegalFactoryType() { + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"stringInstance\" : \"Test String\", " + + "\"integerInstance\" : 1, \"floatInstance\" : 1.0 }", + IllegalInstanceFactoryCreatorContainer.class), + "A JsonbException is expected when unmarshalling to a class with a method annotated with JsonbCreator " + + "returning a type different than the class type."); + } + + /* + * @testName: testRenamedProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.5-3 + * + * @test_Strategy: Assert that JsonbProperty annotation can be used to rename + * an argument of a constructor annotated as JsonbCreator + */ + @Test + public void testRenamedProperty() { + String toDeserialize = "{ \"stringInstance\" : \"Test String\", \"intInstance\" : 1, \"floatInstance\" : 1.0 }"; + SimpleCreatorRenameContainer unmarshalledObject = jsonb.fromJson(toDeserialize, SimpleCreatorRenameContainer.class); + + String validationMessage = "Failed to instantiate type using JsonbCreator annotated constructor having a JsonbProperty " + + "annotated argument during unmarshalling."; + assertThat(validationMessage, unmarshalledObject.getStringInstance(), is("Constructor String")); + assertThat(validationMessage, unmarshalledObject.getIntegerInstance(), is(1)); + assertThat(validationMessage, unmarshalledObject.getFloatInstance(), is(2f)); + } + + /* + * @testName: testJsonbTypeDeserializerOnCreatorParameter + * + * @assertion_ids: JSONB:SPEC:JSB-4.7.2-5 + * + * @test_Strategy: Assert that object instance has been created with JsonbCreator + * and parameter annotated with @JsonbTypeDeserializer annotation has been properly + * deserialized. + */ + @Test + public void testJsonbDeserializerOnCreatorParameter() { + CreatorWithDeserializerContainer c = jsonb.fromJson("{ \"instance\" : \"Test String\" }", + CreatorWithDeserializerContainer.class); + String expected = "Test String Deserialized"; + assertThat("JsonbDeserializer on the JsonbCreator parameter was not executed.", + c.getStringInstance(), is(expected)); + } + + @Test + public void testJsonbAdapterOnCreatorParameter() { + CreatorWithAdapterContainer c = jsonb.fromJson("{ \"instance\" : \"string value\" }", + CreatorWithAdapterContainer.class); + String expected = "string value"; + assertThat("JsonbAdapter on the JsonbCreator parameter was not executed.", c.getStringWrapper(), notNullValue()); + assertThat("JsonbAdapter on the JsonbCreator parameter was not executed.", + expected, is(c.getStringWrapper().getWrapped())); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/OptionalCreatorParametersTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/OptionalCreatorParametersTest.java new file mode 100644 index 0000000..83934a1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/OptionalCreatorParametersTest.java
@@ -0,0 +1,124 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.OptionalTypeContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.SimpleCreatorParamContainer; +import ee.jakarta.tck.json.bind.customizedmapping.instantiation.model.PrimitiveTypeContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class OptionalCreatorParametersTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + private final Jsonb jsonbRequired = JsonbBuilder.create(new JsonbConfig().withCreatorParametersRequired(true)); + + @Test + public void testCreatorMethodWithOptionalParameter() { + SimpleCreatorParamContainer unmarshalledObject = jsonb.fromJson("{ \"paramTwo\" : 1 }", + SimpleCreatorParamContainer.class); + assertThat("Failed to instantiate type using JsonbCreator annotated factory method with optional parameter", + unmarshalledObject.getParamOne(), nullValue()); + assertThat("Failed to instantiate type using JsonbCreator annotated factory method with optional parameter", + unmarshalledObject.getParamTwo(), is(1)); + + unmarshalledObject = jsonb.fromJson("{ \"paramOne\" : \"some value\", \"paramTwo\" : 2 }", + SimpleCreatorParamContainer.class); + assertThat("Failed to instantiate type using JsonbCreator annotated factory method with optional parameter", + unmarshalledObject.getParamOne(), is("some value")); + assertThat("Failed to instantiate type using JsonbCreator annotated factory method with optional parameter", + unmarshalledObject.getParamTwo(), is(2)); + + unmarshalledObject = jsonb.fromJson("{ }", SimpleCreatorParamContainer.class); + assertThat("Failed to instantiate type using JsonbCreator annotated factory method with optional parameter", + unmarshalledObject.getParamOne(), nullValue()); + assertThat("Failed to instantiate type using JsonbCreator annotated factory method with optional parameter", + unmarshalledObject.getParamTwo(), nullValue()); + } + + @Test + public void testAllParametersRequiredSetByMethodAnnotation() { + assertThrows(JsonbException.class, () -> jsonbRequired.fromJson("{ }", SimpleCreatorParamContainer.class), + "Instantiation of the type should have failed, because required creator parameters were missing"); + assertThrows(JsonbException.class, + () -> jsonbRequired.fromJson("{ \"paramOne\" : \"some value\" }", SimpleCreatorParamContainer.class), + "Instantiation of the type should have failed, because required creator parameter was missing"); + } + + @Test + public void testPrimitiveTypesDefaultValues() { + PrimitiveTypeContainer unmarshalledObject = jsonb.fromJson("{ }", PrimitiveTypeContainer.class); + assertThat("Failed to set proper default byte value to the optional creator parameter", + unmarshalledObject.getByteType(), is((byte) 0)); + assertThat("Failed to set proper default short value to the optional creator parameter", + unmarshalledObject.getShortType(), is((short) 0)); + assertThat("Failed to set proper default int value to the optional creator parameter.", + unmarshalledObject.getIntType(), is(0)); + assertThat("Failed to set proper default long value to the optional creator parameter.", + unmarshalledObject.getLongType(), is(0L)); + assertThat("Failed to set proper default float value to the optional creator parameter.", + unmarshalledObject.getFloatType(), is(0.0F)); + assertThat("Failed to set proper default double value to the optional creator parameter.", + unmarshalledObject.getDoubleType(), is(0.0)); + assertThat("Failed to set proper default boolean value to the optional creator parameter.", + unmarshalledObject.getBooleanType(), is(false)); + assertThat("Failed to set proper default char value to the optional creator parameter.", + unmarshalledObject.getCharType(), is('\u0000')); + } + + @Test + public void testOptionalTypesDefaultValues() { + OptionalTypeContainer unmarshalledObject = jsonb.fromJson("{ }", OptionalTypeContainer.class); + assertThat("Failed to set empty OptionalInt instance the the optional creator parameter", + unmarshalledObject.getIntOptional(), is(-1)); + assertThat("Failed to set empty OptionalLong instance the the optional creator parameter", + unmarshalledObject.getLongOptional(), is(-1L)); + assertThat("Failed to set empty OptionalDouble instance the the optional creator parameter", + unmarshalledObject.getDoubleOptional(), is(-1.0)); + assertThat("Failed to set empty Optional instance the the optional creator parameter", + unmarshalledObject.getStringOptional(), nullValue()); + } + + @Test + public void testOptionalTypesInCreator() { + String json = "{ \"stringOptional\":\"stringValue\"," + "\"intOptional\":1," + "\"longOptional\":2," + + "\"doubleOptional\":3.0 }"; + OptionalTypeContainer unmarshalledObject = jsonb.fromJson(json, OptionalTypeContainer.class); + assertThat("Failed to set OptionalInt instance with provided value from the JSON document", + unmarshalledObject.getIntOptional(), is(1)); + assertThat("Failed to set OptionalLong instance with provided value from the JSON document", + unmarshalledObject.getLongOptional(), is(2L)); + assertThat("Failed to set OptionalDouble instance with provided value from the JSON document", + unmarshalledObject.getDoubleOptional(), is(3.0)); + assertThat("Failed to set Optional instance with provided value from the JSON document", + unmarshalledObject.getStringOptional(), is("stringValue")); + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorPlusFactoryContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorPlusFactoryContainer.java new file mode 100644 index 0000000..354d47e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorPlusFactoryContainer.java
@@ -0,0 +1,57 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; + +public class CreatorPlusFactoryContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + @JsonbCreator + public CreatorPlusFactoryContainer(String stringInstance, + Integer integerInstance, float floatInstance) { + this.stringInstance = "Constructor String"; + this.integerInstance = 2; + this.floatInstance = 2; + } + + @JsonbCreator + public static CreatorPlusFactoryContainer createInstance( + String stringInstance) { + return new CreatorPlusFactoryContainer(stringInstance, 3, 3); + } + + public String getStringInstance() { + return stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorWithAdapterContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorWithAdapterContainer.java new file mode 100644 index 0000000..a8c69f5 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorWithAdapterContainer.java
@@ -0,0 +1,65 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.adapter.JsonbAdapter; +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTypeAdapter; + +public class CreatorWithAdapterContainer { + + private final StringWrapper stringWrapper; + + @JsonbCreator + public CreatorWithAdapterContainer(@JsonbProperty("instance") + @JsonbTypeAdapter(SimpleStringAdapter.class) StringWrapper stringWrapper) { + this.stringWrapper = stringWrapper; + } + + public StringWrapper getStringWrapper() { + return stringWrapper; + } + + public static class StringWrapper { + + private final String wrapped; + + private StringWrapper(String wrapped) { + this.wrapped = wrapped; + } + + public String getWrapped() { + return wrapped; + } + + } + + public static class SimpleStringAdapter implements JsonbAdapter<StringWrapper, String> { + + @Override + public String adaptToJson(StringWrapper obj) { + return obj.getWrapped(); + } + + @Override + public StringWrapper adaptFromJson(String obj) { + return new StringWrapper(obj); + } + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorWithDeserializerContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorWithDeserializerContainer.java new file mode 100644 index 0000000..0b33729 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/CreatorWithDeserializerContainer.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import java.lang.reflect.Type; + +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTypeDeserializer; +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.stream.JsonParser; + +public class CreatorWithDeserializerContainer { + private final String stringInstance; + + @JsonbCreator + public CreatorWithDeserializerContainer( + @JsonbProperty("instance") @JsonbTypeDeserializer(SimpleStringDeserializer.class) String stringInstance) { + this.stringInstance = stringInstance; + } + + public String getStringInstance() { + return stringInstance; + } + + public static class SimpleStringDeserializer implements JsonbDeserializer<String> { + + public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext, Type type) { + if (jsonParser.hasNext()) { + JsonParser.Event event = jsonParser.next(); + if (event != JsonParser.Event.VALUE_STRING) { + throw new IllegalStateException("Unexpected event: " + event); + } + } + return jsonParser.getString() + " Deserialized"; + } + + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/IllegalInstanceFactoryCreatorContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/IllegalInstanceFactoryCreatorContainer.java new file mode 100644 index 0000000..7873adb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/IllegalInstanceFactoryCreatorContainer.java
@@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; + +public class IllegalInstanceFactoryCreatorContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + private IllegalInstanceFactoryCreatorContainer() { + } + + @JsonbCreator + public static SimpleFactoryCreatorContainer createInstance( + String stringInstance) { + SimpleFactoryCreatorContainer simpleFactoryCreatorContainer = new SimpleFactoryCreatorContainer(); + simpleFactoryCreatorContainer.setStringInstance("Factory String"); + simpleFactoryCreatorContainer.setIntegerInstance(2); + simpleFactoryCreatorContainer.setFloatInstance(3); + return simpleFactoryCreatorContainer; + } + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public void setIntegerInstance(Integer integerInstance) { + this.integerInstance = integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } + + public void setFloatInstance(float floatInstance) { + this.floatInstance = floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/MultipleCreatorsContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/MultipleCreatorsContainer.java new file mode 100644 index 0000000..a74e8b6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/MultipleCreatorsContainer.java
@@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; + +public class MultipleCreatorsContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + @JsonbCreator + public MultipleCreatorsContainer(String stringInstance, + Integer integerInstance) { + this.stringInstance = stringInstance; + this.integerInstance = integerInstance; + } + + @JsonbCreator + public MultipleCreatorsContainer(Integer integerInstance, + float floatInstance) { + this.integerInstance = integerInstance; + this.floatInstance = floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/MultipleFactoryCreatorsContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/MultipleFactoryCreatorsContainer.java new file mode 100644 index 0000000..96ff394 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/MultipleFactoryCreatorsContainer.java
@@ -0,0 +1,76 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; + +public class MultipleFactoryCreatorsContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + private MultipleFactoryCreatorsContainer() { + } + + @JsonbCreator + public MultipleFactoryCreatorsContainer createInstance(String stringInstance, + Integer integerInstance) { + MultipleFactoryCreatorsContainer simpleFactoryCreatorContainer = new MultipleFactoryCreatorsContainer(); + simpleFactoryCreatorContainer.setStringInstance(stringInstance); + simpleFactoryCreatorContainer.setIntegerInstance(integerInstance); + return simpleFactoryCreatorContainer; + } + + @JsonbCreator + public MultipleFactoryCreatorsContainer createInstance( + Integer integerInstance, float floatInstance) { + MultipleFactoryCreatorsContainer simpleFactoryCreatorContainer = new MultipleFactoryCreatorsContainer(); + simpleFactoryCreatorContainer.setIntegerInstance(integerInstance); + simpleFactoryCreatorContainer.setFloatInstance(floatInstance); + return simpleFactoryCreatorContainer; + } + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public void setIntegerInstance(Integer integerInstance) { + this.integerInstance = integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } + + public void setFloatInstance(float floatInstance) { + this.floatInstance = floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/OptionalTypeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/OptionalTypeContainer.java new file mode 100644 index 0000000..1f449ee --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/OptionalTypeContainer.java
@@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import java.util.Optional; +import java.util.OptionalDouble; +import java.util.OptionalInt; +import java.util.OptionalLong; + +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; + +public class OptionalTypeContainer { + + private final String stringOptional; + private final int intOptional; + private final long longOptional; + private final double doubleOptional; + + public OptionalTypeContainer(String stringOptional, int intOptional, long longOptional, double doubleOptional) { + this.stringOptional = stringOptional; + this.intOptional = intOptional; + this.longOptional = longOptional; + this.doubleOptional = doubleOptional; + } + + @JsonbCreator + public static OptionalTypeContainer create(@JsonbProperty("stringOptional") Optional<String> stringOptional, + @JsonbProperty("intOptional") OptionalInt intOptional, + @JsonbProperty("longOptional") OptionalLong longOptional, + @JsonbProperty("doubleOptional") OptionalDouble doubleOptional) { + return new OptionalTypeContainer(stringOptional.orElse(null), + intOptional.orElse(-1), + longOptional.orElse(-1), + doubleOptional.orElse(-1)); + } + + public String getStringOptional() { + return stringOptional; + } + + public int getIntOptional() { + return intOptional; + } + + public long getLongOptional() { + return longOptional; + } + + public double getDoubleOptional() { + return doubleOptional; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/PrimitiveTypeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/PrimitiveTypeContainer.java new file mode 100644 index 0000000..23c874d --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/PrimitiveTypeContainer.java
@@ -0,0 +1,98 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; + +public class PrimitiveTypeContainer { + + private final byte byteType; + private final short shortType; + private final int intType; + private final long longType; + private final float floatType; + private final double doubleType; + private final char charType; + private final boolean booleanType; + + public PrimitiveTypeContainer(byte byteType, + short shortType, + int intType, + long longType, + float floatType, + double doubleType, + char charType, + boolean booleanType) { + this.byteType = byteType; + this.shortType = shortType; + this.intType = intType; + this.longType = longType; + this.floatType = floatType; + this.doubleType = doubleType; + this.charType = charType; + this.booleanType = booleanType; + } + + @JsonbCreator + public static PrimitiveTypeContainer create(@JsonbProperty("byteType") byte byteType, + @JsonbProperty("shortType") short shortType, + @JsonbProperty("intType") int intType, + @JsonbProperty("longType") long longType, + @JsonbProperty("floatType") float floatType, + @JsonbProperty("doubleType") double doubleType, + @JsonbProperty("charType") char charType, + @JsonbProperty("booleanType") boolean booleanType) { + return new PrimitiveTypeContainer(byteType, shortType, intType, longType, floatType, doubleType, charType, booleanType); + } + + public byte getByteType() { + return byteType; + } + + public short getShortType() { + return shortType; + } + + public int getIntType() { + return intType; + } + + public long getLongType() { + return longType; + } + + public float getFloatType() { + return floatType; + } + + public double getDoubleType() { + return doubleType; + } + + public char getCharType() { + return charType; + } + + public boolean getBooleanType() { + return booleanType; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorContainer.java new file mode 100644 index 0000000..40d3303 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorContainer.java
@@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; + +public class SimpleCreatorContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + @JsonbCreator + public SimpleCreatorContainer( + @JsonbProperty("stringInstance") String stringInstance, + @JsonbProperty("integerInstance") Integer integerInstance, + @JsonbProperty("floatInstance") float floatInstance) { + this.stringInstance = "Constructor String"; + this.integerInstance = 2; + this.floatInstance = 2; + } + + public String getStringInstance() { + return stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorParamContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorParamContainer.java new file mode 100644 index 0000000..29a228e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorParamContainer.java
@@ -0,0 +1,49 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; + +public class SimpleCreatorParamContainer { + + private final String paramOne; + private final Integer paramTwo; + + private SimpleCreatorParamContainer(String paramOne, Integer paramTwo) { + this.paramOne = paramOne; + this.paramTwo = paramTwo; + } + + @JsonbCreator + public static SimpleCreatorParamContainer create(@JsonbProperty("paramOne") String paramOne, + @JsonbProperty("paramTwo") Integer paramTwo) { + return new SimpleCreatorParamContainer(paramOne, paramTwo); + } + + public String getParamOne() { + return paramOne; + } + + public Integer getParamTwo() { + return paramTwo; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorPlusFieldsContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorPlusFieldsContainer.java new file mode 100644 index 0000000..5b6f2fe --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorPlusFieldsContainer.java
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; + +public class SimpleCreatorPlusFieldsContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + @JsonbCreator + public SimpleCreatorPlusFieldsContainer( + @JsonbProperty("stringInstance") String stringInstance, + @JsonbProperty("integerInstance") Integer integerInstance) { + this.stringInstance = "Constructor String"; + this.integerInstance = 2; + } + + public String getStringInstance() { + return stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } + + public void setFloatInstance(float floatInstance) { + this.floatInstance = floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorRenameContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorRenameContainer.java new file mode 100644 index 0000000..3c08fc4 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleCreatorRenameContainer.java
@@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; + +public class SimpleCreatorRenameContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + @JsonbCreator + public SimpleCreatorRenameContainer( + @JsonbProperty("stringInstance") String stringInstance, + @JsonbProperty("intInstance") Integer integerInstance, + @JsonbProperty("floatInstance") float floatInstance) { + this.stringInstance = "Constructor String"; + this.integerInstance = integerInstance; + this.floatInstance = 2; + } + + public String getStringInstance() { + return stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleFactoryCreatorContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleFactoryCreatorContainer.java new file mode 100644 index 0000000..8d2e29a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/instantiation/model/SimpleFactoryCreatorContainer.java
@@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.instantiation.model; + +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbProperty; + +public class SimpleFactoryCreatorContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + SimpleFactoryCreatorContainer() { + } + + @JsonbCreator + public static SimpleFactoryCreatorContainer createInstance( + @JsonbProperty("constructorString") String stringInstance) { + SimpleFactoryCreatorContainer simpleFactoryCreatorContainer = new SimpleFactoryCreatorContainer(); + simpleFactoryCreatorContainer.setStringInstance("Factory String"); + simpleFactoryCreatorContainer.setIntegerInstance(2); + simpleFactoryCreatorContainer.setFloatInstance(3); + return simpleFactoryCreatorContainer; + } + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public void setIntegerInstance(Integer integerInstance) { + this.integerInstance = integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } + + public void setFloatInstance(float floatInstance) { + this.floatInstance = floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/NullHandlingCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/NullHandlingCustomizationTest.java new file mode 100644 index 0000000..1d51b5a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/NullHandlingCustomizationTest.java
@@ -0,0 +1,312 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling; + +import java.util.regex.Pattern; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; + +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.NillableContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.NillablePropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.NillablePropertyNonNillableContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.NonNillableAndNillablePropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.NonNillableContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.NonNillablePropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.NonNillablePropertyNillableContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.SimpleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nillable.NillablePackageNillablePropertyNonNillableContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nillable.NillablePackageNonNillablePropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nillable.NillablePackageSimpleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nonnillable.NonNillablePackageNillableContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nonnillable.NonNillablePackageNonNillablePropertyNillableContainer; +import ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nonnillable.NonNillablePackageSimpleContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources NullHandlingCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.nullhandling.NullHandlingCustomizationTest + **/ +public class NullHandlingCustomizationTest { + + private final static Pattern PATTERN_NULL = Pattern.compile("\\{\\s*\"stringInstance\"\\s*\\:\\s*null\\s*\\}"); + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testNillableType + * + * @assertion_ids: JSONB:SPEC:JSB-4.3.1-1 + * + * @test_Strategy: Assert that type annotated as JsonbNillable includes null + * properties in marshalling + */ + @Test + public void testNillableType() { + String jsonString = jsonb.toJson(new NillableContainer()); + assertThat("Failed to correctly marshal null property of type annotated as JsonbNillable.", + jsonString, matchesPattern(PATTERN_NULL)); + } + + /* + * @testName: testNillablePackage + * + * @assertion_ids: JSONB:SPEC:JSB-4.3.1-1 + * + * @test_Strategy: Assert that type under package annotated as JsonbNillable + * includes null properties in marshalling + */ + @Test + public void testNillablePackage() { + String jsonString = jsonb.toJson(new NillablePackageSimpleContainer()); + assertThat("Failed to correctly marshal null property of type under package annotated as JsonbNillable.", + jsonString, matchesPattern(PATTERN_NULL)); + } + + /* + * @testName: testNillableProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.3.1-2 + * + * @test_Strategy: Assert that property annotated as JsonbProperty with + * nillable = true having null value is included in marshalling + */ + @Test + public void testNillableProperty() { + String jsonString = jsonb.toJson(new NillablePropertyContainer()); + assertThat("Failed to correctly marshal null property annotated as JsonbProperty with nillable = true.", + jsonString, matchesPattern("\\{\\s*\"nillableStringInstance\"\\s*\\:\\s*null\\s*\\}")); + } + + /* + * @testName: testNullValuesConfig + * + * @assertion_ids: JSONB:SPEC:JSB-4.3.2-1 + * + * @test_Strategy: Assert that null properties are included in marshalling + * when using JsonbConfig().withNullValues(true) + */ + @Test + public void testNullValuesConfig() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withNullValues(true)); + String jsonString = jsonb.toJson(new SimpleContainer()); + assertThat("Failed to correctly marshal null properties when using JsonbConfig().withNullValues(true).", + jsonString, matchesPattern(PATTERN_NULL)); + } + + /* + * @testName: testNillableTypeNonNillableProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-1; + * JSONB:SPEC:JSB-4.3.1-2; JSONB:SPEC:JSB-4.3.1-3 + * + * @test_Strategy: Assert that null property annotated as JsonbProperty with + * nillable = false of type annotated as JsonbNillable is ignored in + * marshalling + */ + @Test + public void testNillableTypeNonNillableProperty() { + String jsonString = jsonb.toJson(new NonNillablePropertyNillableContainer()); + assertThat("Failed to correctly ignore null property annotated as JsonbProperty with nillable = false of type " + + "annotated as JsonbNillable.", + jsonString, matchesPattern("\\{\\s*\\}")); + } + + /* + * @testName: testNillablePackageNonNillableProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-1; + * JSONB:SPEC:JSB-4.3.1-2; JSONB:SPEC:JSB-4.3.1-3 + * + * @test_Strategy: Assert that property annotated as JsonbProperty with + * nillable = false of type under package annotated as JsonbNillable is + * ignored in marshalling + */ + @Test + public void testNillablePackageNonNillableProperty() { + String jsonString = jsonb.toJson(new NillablePackageNonNillablePropertyContainer()); + assertThat("Failed to correctly ignore null property annotated as JsonbProperty(nillable = false) of type under " + + "package annotated as JsonbNillable.", + jsonString, matchesPattern("\\{\\s*\\}")); + } + + /* + * @testName: testNillablePackageNonNillableTypeNillableProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-1; + * JSONB:SPEC:JSB-4.3.1-2; JSONB:SPEC:JSB-4.3.1-3 + * + * @test_Strategy: Assert that property annotated as JsonbProperty with + * nillable = + * true of type annotated as JsonbNillable(false) under package + * annotated as JsonbNillable is included in marshalling + */ + @Test + public void testNillablePackageNonNillableTypeNillableProperty() { + String jsonString = jsonb.toJson(new NillablePackageNillablePropertyNonNillableContainer()); + assertThat("Failed to correctly marshal null property annotated as JsonbProperty(nillable = true) of type " + + "annotated as JsonbNillable(false) under package annotated as JsonbNillable.", + jsonString, matchesPattern("\\{\\s*\"nillableStringInstance\"\\s*\\:\\s*null\\s*\\}")); + } + + /* + * @testName: testNullValuesConfigNonNillablePackage + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-1; + * JSONB:SPEC:JSB-4.3.1-3; JSONB:SPEC:JSB-4.3.2-1 + * + * @test_Strategy: Assert that null properties are ignored in marshalling when + * using JsonbConfig().withNullValues(true) and type under package annotated + * as JsonbNillable(false) + */ + @Test + public void testNullValuesConfigNonNillablePackage() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withNullValues(true)); + String jsonString = jsonb.toJson(new NonNillablePackageSimpleContainer()); + assertThat("Failed to correctly ignore null properties when using JsonbConfig().withNullValues(true) and type under " + + "package annotated as JsonbNillable(false).", + jsonString, matchesPattern("\\{\\s*\\}")); + } + + /* + * @testName: testNullValuesConfigNonNillablePackageNillableType + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-1; + * JSONB:SPEC:JSB-4.3.1-3; JSONB:SPEC:JSB-4.3.2-1 + * + * @test_Strategy: Assert that null properties are included in marshalling + * when using JsonbConfig().withNullValues(true) and type annotated as + * JsonbNillable under package annotated as JsonbNillable(false) + */ + @Test + public void testNullValuesConfigNonNillablePackageNillableType() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withNullValues(true)); + String jsonString = jsonb.toJson(new NonNillablePackageNillableContainer()); + assertThat("Failed to correctly marshal null properties when using JsonbConfig().withNullValues(true) and type " + + "annotated as JsonbNillable under package annotated as JsonbNillable(false).", + jsonString, matchesPattern("\\{\\s*\"stringInstance\"\\s*\\:\\s*null\\s*\\}")); + } + + /* + * @testName: + * testNullValuesConfigNonNillablePackageNillableTypeNonNillableProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-1; + * JSONB:SPEC:JSB-4.3.1-2; JSONB:SPEC:JSB-4.3.1-3; JSONB:SPEC:JSB-4.3.2-1 + * + * @test_Strategy: Assert that null properties annotated as JsonbProperty with + * nillable = false are ignored in marshalling when using + * JsonbConfig().withNullValues(true) and type annotated as JsonbNillable + * under package annotated as JsonbNillable(false) + */ + @Test + public void testNullValuesConfigNonNillablePackageNillableTypeNonNillableProperty() { + String validationMessage = "Failed to correctly ignore null property annotated as JsonbProperty with nillable = false " + + "when using JsonbConfig().withNullValues(true) and type annotated as JsonbNillable under package annotated " + + "as JsonbNillable(false)."; + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withNullValues(true)); + String jsonString = jsonb.toJson(new NonNillablePackageNonNillablePropertyNillableContainer()); + assertThat(validationMessage, jsonString, matchesPattern("\\{\\s*\\}")); + } + + /* + * @testName: testNullValuesConfigNonNillableType + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-1; + * JSONB:SPEC:JSB-4.3.1-3; JSONB:SPEC:JSB-4.3.2-1 + * + * @test_Strategy: Assert that null properties are ignored in marshalling when + * using JsonbConfig().withNullValues(true) and type annotated as + * JsonbNillable(false) + */ + @Test + public void testNullValuesConfigNonNillableType() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withNullValues(true)); + String jsonString = jsonb.toJson(new NonNillableContainer()); + assertThat("Failed to correctly ignore null property when using JsonbConfig().withNullValues(true) and type " + + "annotated as JsonbNillable(false).", + jsonString, matchesPattern("\\{\\s*\\}")); + } + + /* + * @testName: testNullValuesConfigNonNillableTypeNillableProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-1; + * JSONB:SPEC:JSB-4.3.1-2; JSONB:SPEC:JSB-4.3.1-3; JSONB:SPEC:JSB-4.3.2-1 + * + * @test_Strategy: Assert that null properties annotated as JsonbProperty with + * nillable = true are included in marshalling when using + * JsonbConfig().withNullValues(true) and type annotated as + * JsonbNillable(false) + */ + @Test + public void testNullValuesConfigNonNillableTypeNillableProperty() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withNullValues(true)); + String jsonString = jsonb.toJson(new NillablePropertyNonNillableContainer()); + assertThat("Failed to correctly include null property annotated as JsonbProperty with nillable = true when " + + "using JsonbConfig().withNullValues(true) and type annotated as JsonbNillable(false).", + jsonString, matchesPattern("\\{\\s*\"nillableStringInstance\"\\s*\\:\\s*null\\s*\\}")); + } + + /* + * @testName: testNullValuesConfigNonNillableProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3.1-2; + * JSONB:SPEC:JSB-4.3.1-3; JSONB:SPEC:JSB-4.3.2-1 + * + * @test_Strategy: Assert that null properties annotated as JsonbProperty with + * nillable = false are ignored in marshalling when using + * JsonbConfig().withNullValues(true) + */ + @Test + public void testNullValuesConfigNonNillableProperty() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withNullValues(true)); + String jsonString = jsonb.toJson(new NonNillablePropertyContainer()); + assertThat("Failed to correctly ignore null property annotated as JsonbProperty with nillable = false when " + + "using JsonbConfig().withNullValues(true).", + jsonString, matchesPattern("\\{\\s*\\}")); + } + + /* + * @testName: testNullValuesConfigNonAndNillableProperty + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1; JSONB:SPEC:JSB-4.3-3; + * JSONB:SPEC:JSB-4.3.1-2; JSONB:SPEC:JSB-4.3.2-1 + * + * @test_Strategy: Assert that null properties annotated as JsonbProperty with + * nillable = false are ignored in marshalling when using + * JsonbConfig().withNullValues(true) + */ + @Test + public void testNullValuesConfigNonAndNillableProperty() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withNullValues(true)); + String jsonString = jsonb.toJson(new NonNillableAndNillablePropertyContainer()); + assertThat("Failed to correctly ignore null property annotated both JsonbProperty with nillable = true and " + + "JsonbNillable(false) when using JsonbConfig().withNullValues(true)." + + "JsonbNillable annotation should take precedence over the JsonbProperty", + jsonString, matchesPattern("\\{\\s*\\}")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillableContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillableContainer.java new file mode 100644 index 0000000..c09288b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillableContainer.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model; + +import jakarta.json.bind.annotation.JsonbNillable; + +@JsonbNillable +public class NillableContainer { + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillablePropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillablePropertyContainer.java new file mode 100644 index 0000000..ab27699 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillablePropertyContainer.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model; + +import jakarta.json.bind.annotation.JsonbNillable; + +public class NillablePropertyContainer { + @JsonbNillable + private String nillableStringInstance; + + public String getNillableStringInstance() { + return nillableStringInstance; + } + + public void setNillableStringInstance(String nillableStringInstance) { + this.nillableStringInstance = nillableStringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillablePropertyNonNillableContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillablePropertyNonNillableContainer.java new file mode 100644 index 0000000..24016d1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NillablePropertyNonNillableContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model; + +import jakarta.json.bind.annotation.JsonbNillable; + +@JsonbNillable(false) +public class NillablePropertyNonNillableContainer { + @JsonbNillable + private String nillableStringInstance; + + public String getNillableStringInstance() { + return nillableStringInstance; + } + + public void setNillableStringInstance(String nillableStringInstance) { + this.nillableStringInstance = nillableStringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillableAndNillablePropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillableAndNillablePropertyContainer.java new file mode 100644 index 0000000..0a5314d --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillableAndNillablePropertyContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model; + +import jakarta.json.bind.annotation.JsonbNillable; +import jakarta.json.bind.annotation.JsonbProperty; + +public class NonNillableAndNillablePropertyContainer { + + @JsonbProperty(nillable = true) + @JsonbNillable(value = false) + private String nillableStringInstance; + + public String getNillableStringInstance() { + return nillableStringInstance; + } + + public void setNillableStringInstance(String nillableStringInstance) { + this.nillableStringInstance = nillableStringInstance; + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillableContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillableContainer.java new file mode 100644 index 0000000..652000e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillableContainer.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model; + +import jakarta.json.bind.annotation.JsonbNillable; + +@JsonbNillable(false) +public class NonNillableContainer { + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillablePropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillablePropertyContainer.java new file mode 100644 index 0000000..5c87a79 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillablePropertyContainer.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model; + +import jakarta.json.bind.annotation.JsonbNillable; + +public class NonNillablePropertyContainer { + @JsonbNillable(false) + private String nillableStringInstance; + + public String getNillableStringInstance() { + return nillableStringInstance; + } + + public void setNillableStringInstance(String nillableStringInstance) { + this.nillableStringInstance = nillableStringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillablePropertyNillableContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillablePropertyNillableContainer.java new file mode 100644 index 0000000..33cb7f3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/NonNillablePropertyNillableContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model; + +import jakarta.json.bind.annotation.JsonbNillable; + +@JsonbNillable +public class NonNillablePropertyNillableContainer { + @JsonbNillable(false) + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/SimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/SimpleContainer.java new file mode 100644 index 0000000..8b7ffb2 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/SimpleContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model; + +public class SimpleContainer { + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageNillablePropertyNonNillableContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageNillablePropertyNonNillableContainer.java new file mode 100644 index 0000000..76b6d51 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageNillablePropertyNonNillableContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nillable; + +import jakarta.json.bind.annotation.JsonbNillable; + +@JsonbNillable(false) +public class NillablePackageNillablePropertyNonNillableContainer { + @JsonbNillable + private String nillableStringInstance; + + public String getNillableStringInstance() { + return nillableStringInstance; + } + + public void setNillableStringInstance(String nillableStringInstance) { + this.nillableStringInstance = nillableStringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageNonNillablePropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageNonNillablePropertyContainer.java new file mode 100644 index 0000000..e386c5b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageNonNillablePropertyContainer.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nillable; + +import jakarta.json.bind.annotation.JsonbNillable; + +public class NillablePackageNonNillablePropertyContainer { + @JsonbNillable(false) + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageSimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageSimpleContainer.java new file mode 100644 index 0000000..00d6585 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/NillablePackageSimpleContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nillable; + +public class NillablePackageSimpleContainer { + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/package-info.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/package-info.java new file mode 100644 index 0000000..cae5d3e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nillable/package-info.java
@@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +@JsonbNillable +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nillable; + +import jakarta.json.bind.annotation.JsonbNillable;
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageNillableContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageNillableContainer.java new file mode 100644 index 0000000..d7fa3a5 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageNillableContainer.java
@@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nonnillable; + +import jakarta.json.bind.annotation.JsonbNillable; + +@JsonbNillable +public class NonNillablePackageNillableContainer { + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageNonNillablePropertyNillableContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageNonNillablePropertyNillableContainer.java new file mode 100644 index 0000000..5aa03b1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageNonNillablePropertyNillableContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nonnillable; + +import jakarta.json.bind.annotation.JsonbNillable; + +@JsonbNillable +public class NonNillablePackageNonNillablePropertyNillableContainer { + @JsonbNillable(false) + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageSimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageSimpleContainer.java new file mode 100644 index 0000000..5ad9131 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/NonNillablePackageSimpleContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nonnillable; + +public class NonNillablePackageSimpleContainer { + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/package-info.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/package-info.java new file mode 100644 index 0000000..b5199d6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/nullhandling/model/nonnillable/package-info.java
@@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +@JsonbNillable(false) +package ee.jakarta.tck.json.bind.customizedmapping.nullhandling.model.nonnillable; + +import jakarta.json.bind.annotation.JsonbNillable;
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/NumberFormatCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/NumberFormatCustomizationTest.java new file mode 100644 index 0000000..1e5f265 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/NumberFormatCustomizationTest.java
@@ -0,0 +1,218 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.numberformat; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.AccessorCustomizedDoubleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.FieldCustomizedDoubleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.TypeCustomizedDoubleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.TypeCustomizedFieldOverriddenDoubleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.customized.PackageCustomizedDoubleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.customized.PackageCustomizedTypeOverriddenDoubleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.customized.PackageCustomizedTypeOverriddenFieldOverriddenDoubleContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources NumberFormatCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.numberformat.NumberFormatCustomizationTest + **/ +public class NumberFormatCustomizationTest { + + private static final String FRENCH_NUMBER = "\"123\\u00a0456,789\""; + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testNumberFormatPackage + * + * @assertion_ids: JSONB:SPEC:JSB-4.9-1 + * + * @test_Strategy: Assert that package annotation with JsonbNumberFormat is + * correctly applied + */ + @Test + public void testNumberFormatPackage() { + String jsonString = jsonb.toJson(new PackageCustomizedDoubleContainer() {{ + setInstance(123456.789); + }}); + assertThat("Failed to correctly customize number format during marshalling using JsonbNumberFormat annotation on " + + "package.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"123.456,8\"\\s*\\}")); + + PackageCustomizedDoubleContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"123.456,789\" }", + PackageCustomizedDoubleContainer.class); + + assertThat( + "Failed to correctly customize number format during unmarshalling using JsonbNumberFormat annotation on package.", + unmarshalledObject.getInstance(), + is(123456.789)); + } + + /* + * @testName: testNumberFormatType + * + * @assertion_ids: JSONB:SPEC:JSB-4.9-1 + * + * @test_Strategy: Assert that type annotation with JsonbNumberFormat is + * correctly applied + */ + @Test + public void testNumberFormatType() { + String jsonString = jsonb.toJson(new TypeCustomizedDoubleContainer() {{ + setInstance(123456.789); + }}); + assertThat("Failed to correctly customize number format during marshalling using JsonbNumberFormat annotation on type.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"123,456.79\"\\s*\\}")); + + TypeCustomizedDoubleContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"123,456.789\" }", + TypeCustomizedDoubleContainer.class); + assertThat("Failed to correctly customize number format during unmarshalling using JsonbNumberFormat annotation on type.", + unmarshalledObject.getInstance(), is(123456.789)); + + } + + /* + * @testName: testNumberFormatField + * + * @assertion_ids: JSONB:SPEC:JSB-4.9-1 + * + * @test_Strategy: Assert that field annotation with JsonbNumberFormat is + * correctly applied + */ + @Test + public void testNumberFormatField() { + String jsonString = jsonb.toJson(new FieldCustomizedDoubleContainer() {{ + setInstance(123456.789); + }}); + assertThat("Failed to correctly customize number format during marshalling using JsonbNumberFormat annotation on field.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"123\\u00a0456,789\"\\s*\\}")); + + FieldCustomizedDoubleContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : " + FRENCH_NUMBER + " }", + FieldCustomizedDoubleContainer.class); + assertThat("Failed to correctly customize number format during unmarshalling using JsonbNumberFormat annotation on " + + "field.", + unmarshalledObject.getInstance(), is(123456.789)); + } + + /* + * @testName: testNumberFormatAccessors + * + * @assertion_ids: JSONB:SPEC:JSB-4.9-1 + * + * @test_Strategy: Assert that accessor annotation with JsonbNumberFormat is + * correctly individually applied for marshalling and unmarshalling + */ + @Test + public void testNumberFormatAccessors() { + String jsonString = jsonb.toJson(new AccessorCustomizedDoubleContainer() {{ + setInstance(123456.789); + }}); + assertThat("Failed to correctly customize number format during marshalling using JsonbNumberFormat annotation on getter.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"123,456.79\"\\s*\\}")); + + AccessorCustomizedDoubleContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : " + FRENCH_NUMBER + " }", + AccessorCustomizedDoubleContainer.class); + assertThat( + "Failed to correctly customize number format during unmarshalling using JsonbNumberFormat annotation on setter.", + unmarshalledObject.getInstance(), + is(123456.789)); + } + + /* + * @testName: testNumberFormatPackageTypeOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.9-1; JSONB:SPEC:JSB-4.9-2 + * + * @test_Strategy: Assert that package annotation with JsonbNumberFormat is + * correctly overridden by type annotation with JsonbNumberFormat + */ + @Test + public void testNumberFormatPackageTypeOverride() { + String jsonString = jsonb.toJson(new PackageCustomizedTypeOverriddenDoubleContainer() {{ + setInstance(123456.789); + }}); + assertThat("Failed to correctly override number format customization using JsonbNumberFormat annotation on " + + "package during marshalling using JsonbNumberFormat annotation on type.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"123,456.79\"\\s*\\}")); + + PackageCustomizedTypeOverriddenDoubleContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"123,456.789\" }", + PackageCustomizedTypeOverriddenDoubleContainer.class); + assertThat("Failed to correctly override number format customization using JsonbNumberFormat annotation on " + + "package during unmarshalling using JsonbNumberFormat annotation on type.", + unmarshalledObject.getInstance(), is(123456.789)); + } + + /* + * @testName: testNumberFormatTypeFieldOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.9-1; JSONB:SPEC:JSB-4.9-2 + * + * @test_Strategy: Assert that type annotation with JsonbNumberFormat is + * correctly overridden by field annotation with JsonbNumberFormat + */ + @Test + public void testNumberFormatTypeFieldOverride() { + String jsonString = jsonb.toJson(new TypeCustomizedFieldOverriddenDoubleContainer() {{ + setInstance(123456.789); + }}); + assertThat("Failed to correctly customize number format during marshalling using JsonbNumberFormat annotation on type.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"123,456.8\"\\s*\\}")); + + TypeCustomizedFieldOverriddenDoubleContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"123,456.789\" }", + TypeCustomizedFieldOverriddenDoubleContainer.class); + assertThat("Failed to correctly customize number format during unmarshalling using JsonbNumberFormat annotation on type.", + unmarshalledObject.getInstance(), is(123456.789)); + } + + /* + * @testName: testNumberFormatPackageTypeOverrideFieldOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.9-1; JSONB:SPEC:JSB-4.9-2 + * + * @test_Strategy: Assert that package and type annotation with + * JsonbNumberFormat is correctly overridden by field annotation with + * JsonbNumberFormat + */ + @Test + public void testNumberFormatPackageTypeOverrideFieldOverride() { + String jsonString = jsonb.toJson(new PackageCustomizedTypeOverriddenFieldOverriddenDoubleContainer() {{ + setInstance(123456.789); + }}); + assertThat("Failed to correctly override number format customization using JsonbNumberFormat annotation on " + + "package during marshalling using JsonbNumberFormat annotation on type.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"123.456,789\"\\s*\\}")); + + PackageCustomizedTypeOverriddenFieldOverriddenDoubleContainer unmarshalledObject = + jsonb.fromJson("{ \"instance\" : \"123.456,789\" }", + PackageCustomizedTypeOverriddenFieldOverriddenDoubleContainer.class); + assertThat("Failed to correctly override number format customization using JsonbNumberFormat annotation on " + + "package during unmarshalling using JsonbNumberFormat annotation on type.", + unmarshalledObject.getInstance(), is(123456.789)); + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/AccessorCustomizedDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/AccessorCustomizedDoubleContainer.java new file mode 100644 index 0000000..5b13baa --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/AccessorCustomizedDoubleContainer.java
@@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.numberformat.model; + +import jakarta.json.bind.annotation.JsonbNumberFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class AccessorCustomizedDoubleContainer + implements TypeContainer<Double> { + private Double instance; + + @Override + @JsonbNumberFormat(value = "###,###.##") + public Double getInstance() { + return instance; + } + + @Override + @JsonbNumberFormat(locale = "fr") + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/FieldCustomizedDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/FieldCustomizedDoubleContainer.java new file mode 100644 index 0000000..f6fe71a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/FieldCustomizedDoubleContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.numberformat.model; + +import jakarta.json.bind.annotation.JsonbNumberFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class FieldCustomizedDoubleContainer implements TypeContainer<Double> { + @JsonbNumberFormat(locale = "fr") + private Double instance; + + @Override + public Double getInstance() { + return instance; + } + + @Override + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/TypeCustomizedDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/TypeCustomizedDoubleContainer.java new file mode 100644 index 0000000..1f9f8af --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/TypeCustomizedDoubleContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.numberformat.model; + +import jakarta.json.bind.annotation.JsonbNumberFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbNumberFormat(value = "###,###.##") +public class TypeCustomizedDoubleContainer implements TypeContainer<Double> { + private Double instance; + + @Override + public Double getInstance() { + return instance; + } + + @Override + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/TypeCustomizedFieldOverriddenDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/TypeCustomizedFieldOverriddenDoubleContainer.java new file mode 100644 index 0000000..ccb9bd4 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/TypeCustomizedFieldOverriddenDoubleContainer.java
@@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.numberformat.model; + +import jakarta.json.bind.annotation.JsonbNumberFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbNumberFormat(value = "###,###.##") +public class TypeCustomizedFieldOverriddenDoubleContainer + implements TypeContainer<Double> { + @JsonbNumberFormat(value = "###,###.#") + private Double instance; + + @Override + public Double getInstance() { + return instance; + } + + @Override + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedDoubleContainer.java new file mode 100644 index 0000000..742d49f --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedDoubleContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.customized; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class PackageCustomizedDoubleContainer implements TypeContainer<Double> { + private Double instance; + + @Override + public Double getInstance() { + return instance; + } + + @Override + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedTypeOverriddenDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedTypeOverriddenDoubleContainer.java new file mode 100644 index 0000000..b0b613c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedTypeOverriddenDoubleContainer.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.customized; + +import jakarta.json.bind.annotation.JsonbNumberFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbNumberFormat(value = "###,###.##") +public class PackageCustomizedTypeOverriddenDoubleContainer + implements TypeContainer<Double> { + private Double instance; + + @Override + public Double getInstance() { + return instance; + } + + @Override + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedTypeOverriddenFieldOverriddenDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedTypeOverriddenFieldOverriddenDoubleContainer.java new file mode 100644 index 0000000..9baffd3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/PackageCustomizedTypeOverriddenFieldOverriddenDoubleContainer.java
@@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.customized; + +import jakarta.json.bind.annotation.JsonbNumberFormat; + +import ee.jakarta.tck.json.bind.TypeContainer; + +@JsonbNumberFormat(value = "###,###.##") +public class PackageCustomizedTypeOverriddenFieldOverriddenDoubleContainer + implements TypeContainer<Double> { + @JsonbNumberFormat(locale = "de") + private Double instance; + + @Override + public Double getInstance() { + return instance; + } + + @Override + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/package-info.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/package-info.java new file mode 100644 index 0000000..0a20576 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/numberformat/model/customized/package-info.java
@@ -0,0 +1,24 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +@JsonbNumberFormat(value = "###,###.#", locale = "de") +package ee.jakarta.tck.json.bind.customizedmapping.numberformat.model.customized; + +import jakarta.json.bind.annotation.JsonbNumberFormat;
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/PropertyNameCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/PropertyNameCustomizationTest.java new file mode 100644 index 0000000..bbcccfc --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/PropertyNameCustomizationTest.java
@@ -0,0 +1,499 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.JsonbException; +import jakarta.json.bind.config.PropertyNamingStrategy; + +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.DuplicateNameContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.PropertyNameCustomizationAccessorsContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.PropertyNameCustomizationContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.StringContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientAnnotatedPropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientGetterAnnotatedPropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientGetterPlusCustomizationAnnotatedFieldContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientGetterPlusCustomizationAnnotatedGetterContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientPlusCustomizationAnnotatedGetterContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientPlusCustomizationAnnotatedPropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientPlusCustomizationAnnotatedSetterContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientPropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientSetterAnnotatedPropertyContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientSetterPlusCustomizationAnnotatedFieldContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertynames.model.TransientSetterPlusCustomizationAnnotatedSetterContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @test + * @sources PropertyNameCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.propertynames.PropertyNameCustomizationTest + **/ +public class PropertyNameCustomizationTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testTransientField + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-1 + * + * @test_Strategy: Assert that transient fields are ignored during + * marshalling/unmarshalling + */ + @Test + public void testTransientField() { + String jsonString = jsonb.toJson(new TransientPropertyContainer() {{ + setInstance("String Value"); + }}); + assertThat("Failed to ignore transient property during marshalling.", jsonString, matchesPattern("\\{\\s*\\}")); + + TransientPropertyContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientPropertyContainer.class); + assertThat("Failed to ignore transient property during unmarshalling.", unmarshalledObject.getInstance(), nullValue()); + } + + /* + * @testName: testTransientAnnotatedField + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-1 + * + * @test_Strategy: Assert that fields annotated as JsonbTransient are ignored + * during marshalling/unmarshalling + */ + @Test + public void testTransientAnnotatedField() { + String jsonString = jsonb.toJson(new TransientAnnotatedPropertyContainer() {{ + setInstance("String Value"); + }}); + assertThat("Failed to ignore JsonbTransient property during marshalling.", jsonString, matchesPattern("\\{\\s*\\}")); + + TransientAnnotatedPropertyContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientAnnotatedPropertyContainer.class); + assertThat("Failed to ignore JsonbTransient property during unmarshalling.", + unmarshalledObject.getInstance(), + nullValue()); + } + + /* + * @testName: testTransientAnnotatedGetter + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-1 + * + * @test_Strategy: Assert that fields with getters annotated as JsonbTransient + * are ignored during marshalling + */ + @Test + public void testTransientAnnotatedGetter() { + String jsonString = jsonb.toJson(new TransientGetterAnnotatedPropertyContainer() {{ + setInstance("String Value"); + }}); + assertThat("Failed to ignore @JsonbTransient on getter during marshalling.", jsonString, matchesPattern("\\{\\s*\\}")); + } + + /* + * @testName: testTransientAnnotatedSetter + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-1 + * + * @test_Strategy: Assert that fields with setters annotated as JsonbTransient + * are ignored during unmarshalling + */ + @Test + public void testTransientAnnotatedSetter() { + TransientSetterAnnotatedPropertyContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientSetterAnnotatedPropertyContainer.class); + assertThat("Failed to ignore @JsonbTransient on setter during unmarshalling.", + unmarshalledObject.getInstance(), + nullValue()); + } + + /* + * @testName: testTransientPlusCustomizationAnnotatedField + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-2 + * + * @test_Strategy: Assert that JsonbException is thrown for fields annotated + * as both JsonbTransient and other Jsonb customization annotations + */ + @Test + public void testTransientPlusCustomizationAnnotatedField() { + String message = "JsonbException not thrown for property annotated with both " + + "JsonbTransient and other Jsonb customization annotation."; + assertThrows(JsonbException.class, + () -> jsonb.toJson(new TransientPlusCustomizationAnnotatedPropertyContainer()), + message); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientPlusCustomizationAnnotatedPropertyContainer.class), + message); + } + + /* + * @testName: testTransientPlusCustomizationAnnotatedGetter + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-2 + * + * @test_Strategy: Assert that JsonbException is thrown for fields annotated + * as both JsonbTransient and other Jsonb customization annotations + */ + @Test + public void testTransientPlusCustomizationAnnotatedGetter() { + String message = "JsonbException not thrown for property annotated with JsonbTransient and getter with other " + + "Jsonb customization annotation."; + assertThrows(JsonbException.class, () -> jsonb.toJson(new TransientPlusCustomizationAnnotatedGetterContainer()), message); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientPlusCustomizationAnnotatedGetterContainer.class), + message); + } + + /* + * @testName: testTransientPlusCustomizationAnnotatedSetter + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-2 + * + * @test_Strategy: Assert that JsonbException is thrown for fields annotated + * as both JsonbTransient and other Jsonb customization annotations + */ + @Test + public void testTransientPlusCustomizationAnnotatedSetter() { + String message = "JsonbException not thrown for property annotated with JsonbTransient and setter with other " + + "Jsonb customization annotation."; + assertThrows(JsonbException.class, () -> jsonb.toJson(new TransientPlusCustomizationAnnotatedSetterContainer()), message); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientPlusCustomizationAnnotatedSetterContainer.class), + message); + } + + /* + * @testName: testTransientGetterPlusCustomizationAnnotatedField + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-3 + * + * @test_Strategy: Assert that JsonbException is thrown for fields annotated + * as both JsonbTransient and other Jsonb customization annotations + */ + @Test + public void testTransientGetterPlusCustomizationAnnotatedField() { + String message = "JsonbException not thrown for getter annotated with JsonbTransient and property with other " + + "Jsonb customization annotation."; + assertThrows(JsonbException.class, + () -> jsonb.toJson(new TransientGetterPlusCustomizationAnnotatedFieldContainer()), + message); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientGetterPlusCustomizationAnnotatedFieldContainer.class), + message); + } + + /* + * @testName: testTransientGetterPlusCustomizationAnnotatedGetter + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-3 + * + * @test_Strategy: Assert that JsonbException is thrown for fields annotated + * as both JsonbTransient and other Jsonb customization annotations + */ + @Test + public void testTransientGetterPlusCustomizationAnnotatedGetter() { + String message = "JsonbException not thrown for property annotated with JsonbTransient and getter with other " + + "Jsonb customization annotation."; + assertThrows(JsonbException.class, + () -> jsonb.toJson(new TransientGetterPlusCustomizationAnnotatedGetterContainer()), + message); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientGetterPlusCustomizationAnnotatedGetterContainer.class), + message); + } + + /* + * @testName: testTransientSetterPlusCustomizationAnnotatedSetter + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-4 + * + * @test_Strategy: Assert that JsonbException is thrown for fields annotated + * as both JsonbTransient and other Jsonb customization annotations + */ + @Test + public void testTransientSetterPlusCustomizationAnnotatedSetter() { + String message = "JsonbException not thrown for property annotated with JsonbTransient and setter with other " + + "Jsonb customization annotation."; + assertThrows(JsonbException.class, + () -> jsonb.toJson(new TransientSetterPlusCustomizationAnnotatedSetterContainer()), + message); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientSetterPlusCustomizationAnnotatedSetterContainer.class), + message); + } + + /* + * @testName: testTransientSetterPlusCustomizationAnnotatedField + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.1-4 + * + * @test_Strategy: Assert that JsonbException is thrown for fields annotated + * as both JsonbTransient and other Jsonb customization annotations + */ + @Test + public void testTransientSetterPlusCustomizationAnnotatedField() { + String message = "JsonbException not thrown for setter annotated with JsonbTransient and property with other " + + "Jsonb customization annotation."; + assertThrows(JsonbException.class, + () -> jsonb.toJson(new TransientSetterPlusCustomizationAnnotatedFieldContainer()), + message); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", + TransientSetterPlusCustomizationAnnotatedFieldContainer.class), + message); + } + + /* + * @testName: testPropertyNameCustomization + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.2-1 + * + * @test_Strategy: Assert that property name can be customized using + * JsonbProperty annotation + */ + @Test + public void testPropertyNameCustomization() { + String jsonString = jsonb.toJson(new PropertyNameCustomizationContainer() {{ + setInstance("Test String"); + }}); + assertThat("Failed to customize property name during marshalling using JsonbProperty annotation.", + jsonString, matchesPattern("\\{\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + PropertyNameCustomizationContainer unmarshalledObject = jsonb.fromJson("{ \"stringInstance\" : \"Test String\" }", + PropertyNameCustomizationContainer.class); + assertThat("Failed to customize property name during unmarshalling using JsonbProperty annotation.", + unmarshalledObject.getInstance(), is("Test String")); + } + + /* + * @testName: testPropertyNameCustomizationAccessors + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.2-1; JSONB:SPEC:JSB-4.1.2-2; + * JSONB:SPEC:JSB-4.1.2-3; JSONB:SPEC:JSB-4.1.2-4 + * + * @test_Strategy: Assert that property name can be individually customized + * for marshalling and unmarshalling using JsonbProperty annotation on + * accessors + */ + @Test + public void testPropertyNameCustomizationAccessors() { + String jsonString = jsonb.toJson(new PropertyNameCustomizationAccessorsContainer() { + { + setInstance("Test String"); + } + }); + assertThat("Failed to customize property name during marshalling using JsonbProperty annotation on getter.", + jsonString, matchesPattern("\\{\\s*\"getterInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + PropertyNameCustomizationAccessorsContainer unmarshalledObject = jsonb + .fromJson("{ \"setterInstance\" : \"Test String\" }", + PropertyNameCustomizationAccessorsContainer.class); + assertThat("Failed to customize property name during unmarshalling using JsonbProperty annotation on setter.", + unmarshalledObject.getInstance(), is("Test String")); + } + + /* + * @testName: testIdentityPropertyNamingStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.3-1 + * + * @test_Strategy: Assert that property name is the same as the field name + * when using PropertyNamingStrategy.IDENTITY + */ + @Test + public void testIdentityPropertyNamingStrategy() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY, PropertyNamingStrategy.IDENTITY); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new StringContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal property using PropertyNamingStrategy.IDENTITY.", + jsonString, matchesPattern("\\{\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + StringContainer unmarshalledObject = jsonb.fromJson("{ \"stringInstance\" : \"Test String\" }", StringContainer.class); + assertThat("Failed to correctly unmarshal property using PropertyNamingStrategy.IDENTITY.", + unmarshalledObject.getStringInstance(), is("Test String")); + } + + /* + * @testName: testLowerCaseWithDashesPropertyNamingStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.3-1 + * + * @test_Strategy: Assert that property name is the same as the field name + * when using PropertyNamingStrategy.LOWER_CASE_WITH_DASHES + */ + @Test + public void testLowerCaseWithDashesPropertyNamingStrategy() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY, + PropertyNamingStrategy.LOWER_CASE_WITH_DASHES); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new StringContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal property using PropertyNamingStrategy.LOWER_CASE_WITH_DASHES.", + jsonString, matchesPattern("\\{\\s*\"string-instance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + StringContainer unmarshalledObject = jsonb.fromJson("{ \"string-instance\" : \"Test String\" }", StringContainer.class); + assertThat("Failed to correctly unmarshal property using PropertyNamingStrategy.LOWER_CASE_WITH_DASHES.", + unmarshalledObject.getStringInstance(), is("Test String")); + } + + /* + * @testName: testLowerCaseWithUnderscoresPropertyNamingStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.3-1 + * + * @test_Strategy: Assert that property name is the same as the field name + * when using PropertyNamingStrategy.LOWER_CASE_WITH_UNDERSCORES + */ + @Test + public void testLowerCaseWithUnderscoresPropertyNamingStrategy() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY, + PropertyNamingStrategy.LOWER_CASE_WITH_UNDERSCORES); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new StringContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal property using PropertyNamingStrategy.LOWER_CASE_WITH_UNDERSCORES.", + jsonString, matchesPattern("\\{\\s*\"string_instance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + StringContainer unmarshalledObject = jsonb.fromJson("{ \"string_instance\" : \"Test String\" }", StringContainer.class); + assertThat("Failed to correctly unmarshal property using PropertyNamingStrategy.LOWER_CASE_WITH_UNDERSCORES.", + unmarshalledObject.getStringInstance(), is("Test String")); + } + + /* + * @testName: testUpperCamelCasePropertyNamingStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.3-1 + * + * @test_Strategy: Assert that property name is the same as the field name + * when using PropertyNamingStrategy.UPPER_CAMEL_CASE + */ + @Test + public void testUpperCamelCasePropertyNamingStrategy() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY, + PropertyNamingStrategy.UPPER_CAMEL_CASE); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new StringContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal property using PropertyNamingStrategy.UPPER_CAMEL_CASE.", + jsonString, matchesPattern("\\{\\s*\"StringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + StringContainer unmarshalledObject = jsonb.fromJson("{ \"StringInstance\" : \"Test String\" }", StringContainer.class); + assertThat("Failed to correctly unmarshal property using PropertyNamingStrategy.UPPER_CAMEL_CASE.", + unmarshalledObject.getStringInstance(), is("Test String")); + } + + /* + * @testName: testUpperCamelCaseWithSpacesPropertyNamingStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.3-1 + * + * @test_Strategy: Assert that property name is the same as the field name + * when using PropertyNamingStrategy.UPPER_CAMEL_CASE_WITH_SPACES + */ + @Test + public void testUpperCamelCaseWithSpacesPropertyNamingStrategy() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY, + PropertyNamingStrategy.UPPER_CAMEL_CASE_WITH_SPACES); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new StringContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal property using PropertyNamingStrategy.UPPER_CAMEL_CASE_WITH_SPACES.", + jsonString, matchesPattern("\\{\\s*\"String Instance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + StringContainer unmarshalledObject = jsonb.fromJson("{ \"String Instance\" : \"Test String\" }", StringContainer.class); + assertThat("Failed to correctly unmarshal property using PropertyNamingStrategy.UPPER_CAMEL_CASE_WITH_SPACES.", + unmarshalledObject.getStringInstance(), is("Test String")); + } + + /* + * @testName: testCaseInsensitivePropertyNamingStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.3-1 + * + * @test_Strategy: Assert that property name is the same as the field name + * when using PropertyNamingStrategy.CASE_INSENSITIVE + */ + @Test + public void testCaseInsensitivePropertyNamingStrategy() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY, + PropertyNamingStrategy.CASE_INSENSITIVE); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new StringContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal property using PropertyNamingStrategy.CASE_INSENSITIVE.", + jsonString, matchesPattern("\\{\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + StringContainer unmarshalledObject = jsonb.fromJson("{ \"stringInstance\" : \"Test String\" }", StringContainer.class); + assertThat("Failed to correctly unmarshal property using PropertyNamingStrategy.CASE_INSENSITIVE.", + unmarshalledObject.getStringInstance(), is("Test String")); + } + + /* + * @testName: testDuplicateName + * + * @assertion_ids: JSONB:SPEC:JSB-4.1.4-1 + * + * @test_Strategy: Assert that JsonbException is thrown for property name + * duplication as a result of property name customization + */ + @Test + public void testDuplicateName() { + String message = "JsonbException not thrown for property name duplication as a result of property name customization."; + assertThrows(JsonbException.class, () -> jsonb.toJson(new DuplicateNameContainer()), message); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", DuplicateNameContainer.class), + message); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/DuplicateNameContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/DuplicateNameContainer.java new file mode 100644 index 0000000..38e1b54 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/DuplicateNameContainer.java
@@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; + +public class DuplicateNameContainer { + private String firstInstance; + + @JsonbProperty("firstInstance") + private String secondInstance; + + public String getFirstInstance() { + return firstInstance; + } + + public void setFirstInstance(String firstInstance) { + this.firstInstance = firstInstance; + } + + public String getSecondInstance() { + return secondInstance; + } + + public void setSecondInstance(String secondInstance) { + this.secondInstance = secondInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/PropertyNameCustomizationAccessorsContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/PropertyNameCustomizationAccessorsContainer.java new file mode 100644 index 0000000..d92942c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/PropertyNameCustomizationAccessorsContainer.java
@@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class PropertyNameCustomizationAccessorsContainer + implements TypeContainer<String> { + private String instance; + + @Override + @JsonbProperty("getterInstance") + public String getInstance() { + return instance; + } + + @Override + @JsonbProperty("setterInstance") + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/PropertyNameCustomizationContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/PropertyNameCustomizationContainer.java new file mode 100644 index 0000000..b946626 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/PropertyNameCustomizationContainer.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class PropertyNameCustomizationContainer + implements TypeContainer<String> { + @JsonbProperty("stringInstance") + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/StringContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/StringContainer.java new file mode 100644 index 0000000..1b3fea2 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/StringContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +public class StringContainer { + private String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientAnnotatedPropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientAnnotatedPropertyContainer.java new file mode 100644 index 0000000..e0b3394 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientAnnotatedPropertyContainer.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientAnnotatedPropertyContainer + implements TypeContainer<String> { + @JsonbTransient + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterAnnotatedPropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterAnnotatedPropertyContainer.java new file mode 100644 index 0000000..fb78649 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterAnnotatedPropertyContainer.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientGetterAnnotatedPropertyContainer + implements TypeContainer<String> { + private String instance; + + @Override + @JsonbTransient + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterPlusCustomizationAnnotatedFieldContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterPlusCustomizationAnnotatedFieldContainer.java new file mode 100644 index 0000000..fac19d6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterPlusCustomizationAnnotatedFieldContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientGetterPlusCustomizationAnnotatedFieldContainer + implements TypeContainer<String> { + @JsonbProperty("instance") + private String instance; + + @Override + @JsonbTransient + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterPlusCustomizationAnnotatedGetterContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterPlusCustomizationAnnotatedGetterContainer.java new file mode 100644 index 0000000..ae27cfb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientGetterPlusCustomizationAnnotatedGetterContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientGetterPlusCustomizationAnnotatedGetterContainer + implements TypeContainer<String> { + private String instance; + + @Override + @JsonbTransient + @JsonbProperty("instance") + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedGetterContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedGetterContainer.java new file mode 100644 index 0000000..0d6cffb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedGetterContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientPlusCustomizationAnnotatedGetterContainer + implements TypeContainer<String> { + @JsonbTransient + private String instance; + + @Override + @JsonbProperty("instance") + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedPropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedPropertyContainer.java new file mode 100644 index 0000000..e199b29 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedPropertyContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientPlusCustomizationAnnotatedPropertyContainer + implements TypeContainer<String> { + @JsonbTransient + @JsonbProperty("propertyName") + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedSetterContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedSetterContainer.java new file mode 100644 index 0000000..81ad21c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPlusCustomizationAnnotatedSetterContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientPlusCustomizationAnnotatedSetterContainer + implements TypeContainer<String> { + @JsonbTransient + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + @JsonbProperty("instance") + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPropertyContainer.java new file mode 100644 index 0000000..f9856a2 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientPropertyContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientPropertyContainer implements TypeContainer<String> { + private transient String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterAnnotatedPropertyContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterAnnotatedPropertyContainer.java new file mode 100644 index 0000000..f4116c3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterAnnotatedPropertyContainer.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientSetterAnnotatedPropertyContainer + implements TypeContainer<String> { + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + @JsonbTransient + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterPlusCustomizationAnnotatedFieldContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterPlusCustomizationAnnotatedFieldContainer.java new file mode 100644 index 0000000..4b9e5b8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterPlusCustomizationAnnotatedFieldContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientSetterPlusCustomizationAnnotatedFieldContainer + implements TypeContainer<String> { + @JsonbProperty("instance") + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + @JsonbTransient + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterPlusCustomizationAnnotatedSetterContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterPlusCustomizationAnnotatedSetterContainer.java new file mode 100644 index 0000000..cd5cabf --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertynames/model/TransientSetterPlusCustomizationAnnotatedSetterContainer.java
@@ -0,0 +1,43 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertynames.model; + +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbTransient; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TransientSetterPlusCustomizationAnnotatedSetterContainer + implements TypeContainer<String> { + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + @JsonbTransient + @JsonbProperty("instance") + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/PropertyOrderCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/PropertyOrderCustomizationTest.java new file mode 100644 index 0000000..ca362b4 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/PropertyOrderCustomizationTest.java
@@ -0,0 +1,299 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertyorder; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.config.PropertyOrderStrategy; + +import ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model.CustomOrderContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model.PartialOrderContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model.RenamedPropertiesContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model.SimpleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model.SimpleOrderContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources PropertyOrderCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.propertyorder.PropertyOrderCustomizationTest + **/ +public class PropertyOrderCustomizationTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testAnyPropertyOrderStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.2 + * + * @test_Strategy: Assert that no error occurs when using + * PropertyOrderStrategy.ANY + */ + @Test + public void testAnyPropertyOrderStrategy() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_ORDER_STRATEGY, PropertyOrderStrategy.ANY); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new SimpleContainer() { + { + setStringInstance("Test String"); + } + }); + SimpleContainer unmarshalledObject = jsonb.fromJson(jsonString, SimpleContainer.class); + String validationMessage = "Failed to correctly marshal and unmarshal object using PropertyOrderStrategy.ANY."; + assertThat(validationMessage, unmarshalledObject.getStringInstance(), is("Test String")); + assertThat(validationMessage, unmarshalledObject.getIntInstance(), is(0)); + assertThat(validationMessage, unmarshalledObject.getLongInstance(), is(0L)); + } + + /* + * @testName: testLexicographicalPropertyOrderStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.2 + * + * @test_Strategy: Assert that marshalling property order is lexicographical + * when using PropertyOrderStrategy.LEXICOGRAPHICAL and unmarshalling property + * order is the order of appearance in the JSON document + */ + @Test + public void testLexicographicalPropertyOrderStrategy() { + JsonbConfig config = new JsonbConfig() + .setProperty(JsonbConfig.PROPERTY_ORDER_STRATEGY, PropertyOrderStrategy.LEXICOGRAPHICAL); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new SimpleOrderContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal properties in lexicographical order using PropertyOrderStrategy.LEXICOGRAPHICAL.", + jsonString, matchesPattern("\\{\\s*\"intInstance\"\\s*\\:\\s*0\\s*,\\s*\"longInstance\"\\s*\\:\\s*0\\s*," + + "\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + SimpleOrderContainer unmarshalledObject = jsonb.fromJson("{ \"intInstance\" : 1, \"stringInstance\" : \"Test String\", " + + "\"longInstance\" : 1 }", + SimpleOrderContainer.class); + assertThat("Failed to correctly unmarshal properties in order of appearance using PropertyOrderStrategy.LEXICOGRAPHICAL.", + unmarshalledObject.getIntInstance(), is(3)); + } + + /* + * @testName: testReversePropertyOrderStrategy + * + * @assertion_ids: JSONB:SPEC:JSB-4.2 + * + * @test_Strategy: Assert that marshalling property order is reverse + * lexicographical when using PropertyOrderStrategy.REVERSE and unmarshalling + * property order is the order of appearance in the JSON document + */ + @Test + public void testReversePropertyOrderStrategy() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_ORDER_STRATEGY, PropertyOrderStrategy.REVERSE); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new SimpleOrderContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal properties in reverse lexicographical order using PropertyOrderStrategy.REVERSE.", + jsonString, matchesPattern("\\{\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*," + + "\\s*\"longInstance\"\\s*\\:\\s*0\\s*," + + "\\s*\"intInstance\"\\s*\\:\\s*0\\s*\\}")); + + SimpleOrderContainer unmarshalledObject = jsonb.fromJson("{ \"intInstance\" : 1, \"stringInstance\" : \"Test String\", " + + "\"longInstance\" : 1 }", + SimpleOrderContainer.class); + assertThat("Failed to correctly unmarshal properties in order of appearance using PropertyOrderStrategy.REVERSE.", + unmarshalledObject.getIntInstance(), is(3)); + } + + /* + * @testName: testCustomPropertyOrder + * + * @assertion_ids: JSONB:SPEC:JSB-4.2-2 + * + * @test_Strategy: Assert that marshalling property order is as specified by + * JsonbPropertyOrder annotation and unmarshalling property order is the order + * of appearance in the JSON document + */ + @Test + public void testCustomPropertyOrder() { + String jsonString = jsonb.toJson(new CustomOrderContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal properties in custom order using JsonbPropertyOrder annotation.", + jsonString, matchesPattern("\\{\\s*\"longInstance\"\\s*\\:\\s*0\\s*,\\s*\"intInstance\"\\s*\\:\\s*0\\s*," + + "\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + CustomOrderContainer unmarshalledObject = jsonb.fromJson("{ \"intInstance\" : 1, \"stringInstance\" : \"Test String\", " + + "\"longInstance\" : 0 }", + CustomOrderContainer.class); + assertThat("Failed to correctly unmarshal properties in order of appearance using JsonbPropertyOrder annotation.", + unmarshalledObject.getIntInstance(), is(3)); + } + + /* + * @testName: testCustomPropertyOrderStrategyOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1 + * + * @test_Strategy: Assert that marshalling property order is as specified by + * JsonbPropertyOrder annotation regardless of PropertyOrderStrategy specified + * and unmarshalling property order is the order of appearance in the JSON + * document + */ + @Test + public void testCustomPropertyOrderStrategyOverride() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_ORDER_STRATEGY, PropertyOrderStrategy.REVERSE); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new CustomOrderContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal properties in custom order using JsonbPropertyOrder annotation.", + jsonString, matchesPattern("\\{\\s*\"longInstance\"\\s*\\:\\s*0\\s*,\\s*\"intInstance\"\\s*\\:\\s*0\\s*," + + "\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + CustomOrderContainer unmarshalledObject = jsonb.fromJson("{ \"intInstance\" : 1, \"stringInstance\" : \"Test String\", " + + "\"longInstance\" : 0 }", + CustomOrderContainer.class); + assertThat("Failed to correctly unmarshal properties in order of appearance using JsonbPropertyOrder annotation and " + + "PropertyOrderStrategy.REVERSE.", + unmarshalledObject.getIntInstance(), is(3)); + } + + /* + * @testName: testCustomPartialPropertyOrder + * + * @assertion_ids: JSONB:SPEC:JSB-4.2-2 + * + * @test_Strategy: In that case, properties included in annotation declaration + * will be serialized first (in defined order), followed by any properties not + * included in the definition. The order of properties not included in the + * definition is not guaranteed + */ + @Test + public void testCustomPartialPropertyOrder() { + String jsonString = jsonb.toJson(new PartialOrderContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal properties in custom order using JsonbPropertyOrder annotation.", + jsonString, matchesPattern("\\{\\s*\"longInstance\"\\s*\\:\\s*0\\s*,\\s*\"intInstance\"\\s*\\:\\s*0\\s*," + + "\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\".*\\}")); + + String validationMessage = "Did not marshall all expected properties"; + assertThat(validationMessage, jsonString, containsString("anotherIntInstance")); + assertThat(validationMessage, jsonString, containsString("anIntInstance")); + assertThat(validationMessage, jsonString, containsString("yetAnotherIntInstance")); + + String toDeserialize = "{ \"anIntInstance\" : 100, \"yetAnotherIntInstance\":100, \"anotherIntInstance\": 100, " + + "\"intInstance\" : 1, \"stringInstance\" : \"Test String\", \"longInstance\" : 0 }"; + PartialOrderContainer unmarshalledObject = jsonb.fromJson(toDeserialize, PartialOrderContainer.class); + validationMessage = "Failed to correctly unmarshal properties in order of appearance using JsonbPropertyOrder " + + "annotation."; + assertThat(validationMessage, unmarshalledObject.getIntInstance(), is(3)); + assertThat(validationMessage, unmarshalledObject.getAnotherIntInstance(), is(100)); + assertThat(validationMessage, unmarshalledObject.getYetAnotherIntInstance(), is(100)); + assertThat(validationMessage, unmarshalledObject.getAnIntInstance(), is(100)); + } + + /* + * @testName: testCustomPartialPropertyOrderStrategyOverride + * + * @assertion_ids: JSONB:SPEC:JSB-4.3-1 + * + * @test_Strategy: In that case, properties included in annotation declaration + * will be serialized first (in defined order), followed by any properties not + * included in the definition. The order of properties not included in the + * definition is not guaranteed + */ + @Test + public void testCustomPartialPropertyOrderStrategyOverride() { + JsonbConfig config = new JsonbConfig().setProperty(JsonbConfig.PROPERTY_ORDER_STRATEGY, PropertyOrderStrategy.REVERSE); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new PartialOrderContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to correctly marshal properties in custom order using JsonbPropertyOrder annotation.", + jsonString, matchesPattern("\\{\\s*\"longInstance\"\\s*\\:\\s*0\\s*,\\s*\"intInstance\"\\s*\\:\\s*0\\s*," + + "\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\".*\\}")); + + String validationMessage = "Did not marshall all expected properties"; + assertThat(validationMessage, jsonString, containsString("anotherIntInstance")); + assertThat(validationMessage, jsonString, containsString("anIntInstance")); + assertThat(validationMessage, jsonString, containsString("yetAnotherIntInstance")); + + String toDeserialize = "{ \"anIntInstance\" : 100, \"yetAnotherIntInstance\":100, \"anotherIntInstance\": 100, " + + "\"intInstance\" : 1, \"stringInstance\" : \"Test String\", \"longInstance\" : 0 }"; + PartialOrderContainer unmarshalledObject = jsonb.fromJson(toDeserialize, PartialOrderContainer.class); + validationMessage = "Failed to correctly unmarshal properties in order of appearance using JsonbPropertyOrder " + + "annotation."; + assertThat(validationMessage, unmarshalledObject.getIntInstance(), is(3)); + assertThat(validationMessage, unmarshalledObject.getAnotherIntInstance(), is(100)); + assertThat(validationMessage, unmarshalledObject.getYetAnotherIntInstance(), is(100)); + assertThat(validationMessage, unmarshalledObject.getAnIntInstance(), is(100)); + } + + /* + * @testName: testLexicographicalPropertyOrderRenamedProperties + * + * @assertion_ids: JSONB:SPEC:JSB-4.2 + * + * @test_Strategy: Assert that marshalling property order is lexicographical + * after property renaming has been applied and unmarshalling property order + * is the order of appearance in the JSON document + */ + @Test + public void testLexicographicalPropertyOrderRenamedProperties() { + JsonbConfig config = new JsonbConfig() + .setProperty(JsonbConfig.PROPERTY_ORDER_STRATEGY, PropertyOrderStrategy.LEXICOGRAPHICAL); + Jsonb jsonb = JsonbBuilder.create(config); + String jsonString = jsonb.toJson(new RenamedPropertiesContainer() { + { + setStringInstance("Test String"); + setLongInstance(1); + } + }); + assertThat("Failed to correctly marshal renamed properties in lexicographical order " + + "using PropertyOrderStrategy.LEXICOGRAPHICAL.", + jsonString, matchesPattern("\\{\\s*\"first\"\\s*\\:\\s*0\\s*,\\s*\"second\"\\s*\\:\\s*\"Test String\"\\s*," + + "\\s*\"third\"\\s*\\:\\s*1\\s*\\}")); + + RenamedPropertiesContainer unmarshalledObject = jsonb.fromJson("{ \"first\" : 1, \"second\" : \"Test String\", " + + "\"third\" : 1 }", + RenamedPropertiesContainer.class); + assertThat("Failed to correctly unmarshal renamed properties in order of appearance " + + "using PropertyOrderStrategy.LEXICOGRAPHICAL.", + unmarshalledObject.getIntInstance(), is(3)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/CustomOrderContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/CustomOrderContainer.java new file mode 100644 index 0000000..246c744 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/CustomOrderContainer.java
@@ -0,0 +1,62 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model; + +import jakarta.json.bind.annotation.JsonbPropertyOrder; + +@JsonbPropertyOrder({"longInstance", "intInstance", "stringInstance"}) +public class CustomOrderContainer { + private int intInstance; + + private String stringInstance; + + private long longInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + if (intInstance == 1) { + intInstance = 2; + } + } + + public int getIntInstance() { + return intInstance; + } + + public void setIntInstance(int intInstance) { + this.intInstance = intInstance; + } + + public long getLongInstance() { + return longInstance; + } + + public void setLongInstance(long longInstance) { + this.longInstance = longInstance; + if (intInstance == 2) { + intInstance = 3; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/PartialOrderContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/PartialOrderContainer.java new file mode 100644 index 0000000..3a42d2e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/PartialOrderContainer.java
@@ -0,0 +1,98 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model; + +import jakarta.json.bind.annotation.JsonbPropertyOrder; + +@JsonbPropertyOrder({"longInstance", "intInstance", "stringInstance"}) +public class PartialOrderContainer { + private int intInstance; + + private String stringInstance; + + private long longInstance; + + private int anIntInstance; + + private int anotherIntInstance; + + private int yetAnotherIntInstance; + + public int getAnIntInstance() { + intInstance -= 10; + return anIntInstance; + } + + public void setAnIntInstance(int anIntInstance) { + intInstance -= 30; + this.anIntInstance = anIntInstance; + } + + public int getAnotherIntInstance() { + intInstance -= 100; + return anotherIntInstance; + } + + public void setAnotherIntInstance(int anotherIntInstance) { + intInstance -= 300; + this.anotherIntInstance = anotherIntInstance; + } + + public int getYetAnotherIntInstance() { + intInstance -= 1000; + return yetAnotherIntInstance; + } + + public void setYetAnotherIntInstance(int yetAnotherIntInstance) { + intInstance -= 3000; + this.yetAnotherIntInstance = yetAnotherIntInstance; + } + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + if (intInstance == 1) { + intInstance = 2; + } + } + + public int getIntInstance() { + return intInstance; + } + + public void setIntInstance(int intInstance) { + this.intInstance = intInstance; + } + + public long getLongInstance() { + return longInstance; + } + + public void setLongInstance(long longInstance) { + this.longInstance = longInstance; + if (intInstance == 2) { + intInstance = 3; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/RenamedPropertiesContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/RenamedPropertiesContainer.java new file mode 100644 index 0000000..32347bf --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/RenamedPropertiesContainer.java
@@ -0,0 +1,64 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model; + +import jakarta.json.bind.annotation.JsonbProperty; + +public class RenamedPropertiesContainer { + @JsonbProperty("first") + private int intInstance; + + @JsonbProperty("second") + private String stringInstance; + + @JsonbProperty("third") + private long longInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + if (intInstance == 1) { + intInstance = 2; + } + } + + public int getIntInstance() { + return intInstance; + } + + public void setIntInstance(int intInstance) { + this.intInstance = intInstance; + } + + public long getLongInstance() { + return longInstance; + } + + public void setLongInstance(long longInstance) { + this.longInstance = longInstance; + if (intInstance == 2) { + intInstance = 3; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/SimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/SimpleContainer.java new file mode 100644 index 0000000..0e5b8b4 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/SimpleContainer.java
@@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model; + +public class SimpleContainer { + private int intInstance; + + private String stringInstance; + + private long longInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } + + public int getIntInstance() { + return intInstance; + } + + public void setIntInstance(int intInstance) { + this.intInstance = intInstance; + } + + public long getLongInstance() { + return longInstance; + } + + public void setLongInstance(long longInstance) { + this.longInstance = longInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/SimpleOrderContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/SimpleOrderContainer.java new file mode 100644 index 0000000..4900029 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/propertyorder/model/SimpleOrderContainer.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.propertyorder.model; + +public class SimpleOrderContainer { + private int intInstance; + + private String stringInstance; + + private long longInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + if (intInstance == 1) { + intInstance = 2; + } + } + + public int getIntInstance() { + return intInstance; + } + + public void setIntInstance(int intInstance) { + this.intInstance = intInstance; + } + + public long getLongInstance() { + return longInstance; + } + + public void setLongInstance(long longInstance) { + this.longInstance = longInstance; + if (intInstance == 2) { + intInstance = 3; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/SerializersCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/SerializersCustomizationTest.java new file mode 100644 index 0000000..ba8022a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/SerializersCustomizationTest.java
@@ -0,0 +1,136 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.AnimalShelter; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.AnimalShelterWithSerializer; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Dog; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer.AnimalDeserializer; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer.AnimalSerializer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources SerializersCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.serializers.SerializersCustomizationTest + **/ +public class SerializersCustomizationTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testSerializerConfiguration + * + * @assertion_ids: JSONB:SPEC:JSB-4.7.2-1 + * + * @test_Strategy: Assert that JSONB serializers and deserializers can be + * configured using JsonbConfig.withSerializers and + * JsonbConfig.withDeserializers and are working as expected + */ + @Test + public void testSerializerConfiguration() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withSerializers(new AnimalSerializer()) + .withDeserializers(new AnimalDeserializer())); + AnimalShelter animalShelter = new AnimalShelter(); + animalShelter.addAnimal(new Cat(5, "Garfield", 10.5f, true, true)); + animalShelter.addAnimal(new Dog(3, "Milo", 5.5f, false, true)); + animalShelter.addAnimal(new Animal(6, "Tweety", 0.5f, false)); + + String jsonString = jsonb.toJson(animalShelter); + String validationRegexp = "\\{\\s*\"animals\"\\s*:\\s*\\[\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"cat\"\\s*,\\s*\"cuddly\"\\s*:\\s*true\\s*,\\s*\"age\"\\s*:\\s*5\\s*," + + "\\s*\"furry\"\\s*:\\s*true\\s*,\\s*\"name\"\\s*:\\s*\"Garfield\"\\s*,\\s*\"weight\"\\s*:\\s*10.5\\s*}\\s*,\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"dog\"\\s*,\\s*\"barking\"\\s*:\\s*true\\s*,\\s*\"age\"\\s*:\\s*3\\s*," + + "\\s*\"furry\"\\s*:\\s*false\\s*,\\s*\"name\"\\s*:\\s*\"Milo\"\\s*,\\s*\"weight\"\\s*:\\s*5.5\\s*}\\s*,\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"animal\"\\s*,\\s*\"age\"\\s*:\\s*6\\s*,\\s*\"furry\"\\s*:\\s*false\\s*," + + "\\s*\"name\"\\s*:\\s*\"Tweety\"\\s*,\\s*\"weight\"\\s*:\\s*0.5\\s*}\\s*" + + "]\\s*}"; + assertThat("Failed to correctly marshall complex type hierarchy using a serializer configured using " + + "JsonbConfig.withSerializers and a deserializer configured using JsonbConfig.withDeserializers.", + jsonString, matchesPattern(validationRegexp)); + + String toDeserialize = "{ \"animals\" : [ " + + "{ \"type\" : \"cat\", \"cuddly\" : true, \"age\" : 5, \"furry\" : true, \"name\" : \"Garfield\" , \"weight\"" + + " : 10.5}, " + + "{ \"type\" : \"dog\", \"barking\" : true, \"age\" : 3, \"furry\" : false, \"name\" : \"Milo\", \"weight\" : " + + "5.5}, " + + "{ \"type\" : \"animal\", \"age\" : 6, \"furry\" : false, \"name\" : \"Tweety\", \"weight\" : 0.5}" + + " ] }"; + AnimalShelter unmarshalledObject = jsonb.fromJson(toDeserialize, AnimalShelter.class); + assertThat("Failed to correctly unmarshall complex type hierarchy using a serializer configured using " + + "JsonbConfig.withSerializers and a deserializer configured using JsonbConfig.withDeserializers.", + unmarshalledObject, is(animalShelter)); + } + + /* + * @testName: testSerializerAnnotation + * + * @assertion_ids: JSONB:SPEC:JSB-4.7.2-2 + * + * @test_Strategy: Assert that JSONB serializers and deserializers can be + * configured using JsonbTypeSerializer and JsonbTypeDeserializer annotation + * and are working as expected + */ + @Test + public void testSerializerAnnotation() { + AnimalShelterWithSerializer animalShelter = new AnimalShelterWithSerializer(); + animalShelter.addAnimal(new Cat(5, "Garfield", 10.5f, true, true)); + animalShelter.addAnimal(new Dog(3, "Milo", 5.5f, false, true)); + animalShelter.addAnimal(new Animal(6, "Tweety", 0.5f, false)); + + String jsonString = jsonb.toJson(animalShelter); + String validationRegexp = "\\{\\s*\"animals\"\\s*:\\s*\\[\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"cat\"\\s*,\\s*\"cuddly\"\\s*:\\s*true\\s*,\\s*\"age\"\\s*:\\s*5\\s*," + + "\\s*\"furry\"\\s*:\\s*true\\s*,\\s*\"name\"\\s*:\\s*\"Garfield\"\\s*,\\s*\"weight\"\\s*:\\s*10.5\\s*}\\s*,\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"dog\"\\s*,\\s*\"barking\"\\s*:\\s*true\\s*,\\s*\"age\"\\s*:\\s*3\\s*," + + "\\s*\"furry\"\\s*:\\s*false\\s*,\\s*\"name\"\\s*:\\s*\"Milo\"\\s*,\\s*\"weight\"\\s*:\\s*5.5\\s*}\\s*,\\s*" + + "\\{\\s*\"type\"\\s*:\\s*\"animal\"\\s*,\\s*\"age\"\\s*:\\s*6\\s*,\\s*\"furry\"\\s*:\\s*false\\s*," + + "\\s*\"name\"\\s*:\\s*\"Tweety\"\\s*,\\s*\"weight\"\\s*:\\s*0.5\\s*}\\s*" + + "]\\s*}"; + assertThat("Failed to correctly marshall complex type hierarchy using a serializer configured using " + + "JsonbTypeSerializer annotation and a deserializer configured using JsonbTypeDeserializer " + + "annotation.", + jsonString, matchesPattern(validationRegexp)); + + String toDeserialize = "{ \"animals\" : [ " + + "{ \"type\" : \"cat\", \"cuddly\" : true, \"age\" : 5, \"furry\" : true, \"name\" : \"Garfield\" , \"weight\"" + + " : 10.5}, " + + "{ \"type\" : \"dog\", \"barking\" : true, \"age\" : 3, \"furry\" : false, \"name\" : \"Milo\", \"weight\" : " + + "5.5}, " + + "{ \"type\" : \"animal\", \"age\" : 6, \"furry\" : false, \"name\" : \"Tweety\", \"weight\" : 0.5}" + + " ] }"; + AnimalShelterWithSerializer unmarshalledObject = jsonb.fromJson(toDeserialize, AnimalShelterWithSerializer.class); + assertThat("Failed to correctly unmarshall complex type hierarchy using a serializer configured using " + + "JsonbTypeSerializer annotation and a deserializer configured using JsonbTypeDeserializer " + + "annotation.", + unmarshalledObject, is(animalShelter)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Animal.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Animal.java new file mode 100644 index 0000000..c14fbb0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Animal.java
@@ -0,0 +1,105 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model; + +public class Animal { + private int age; + + private String name; + + private float weight; + + private boolean furry; + + public Animal() { + } + + public Animal(int age, String name, float weight, boolean furry) { + this.age = age; + this.name = name; + this.weight = weight; + this.furry = furry; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public float getWeight() { + return weight; + } + + public void setWeight(float weight) { + this.weight = weight; + } + + public boolean isFurry() { + return furry; + } + + public void setFurry(boolean furry) { + this.furry = furry; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Animal)) { + return false; + } + + Animal animal = (Animal) o; + + if (age != animal.age) { + return false; + } + if (Float.compare(animal.weight, weight) != 0) { + return false; + } + if (furry != animal.furry) { + return false; + } + return name != null ? name.equals(animal.name) : animal.name == null; + } + + @Override + public int hashCode() { + int result = age; + result = 31 * result + (name != null ? name.hashCode() : 0); + result = 31 * result + (weight != +0.0f ? Float.floatToIntBits(weight) : 0); + result = 31 * result + (furry ? 1 : 0); + return result; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/AnimalShelter.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/AnimalShelter.java new file mode 100644 index 0000000..6ad0687 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/AnimalShelter.java
@@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model; + +import java.util.ArrayList; +import java.util.List; + +public class AnimalShelter { + private List<Animal> animals = new ArrayList<>(); + + public List<Animal> getAnimals() { + return animals; + } + + public void setAnimals(List<Animal> animals) { + this.animals = animals; + } + + public boolean addAnimal(Animal animal) { + return animals.add(animal); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof AnimalShelter)) { + return false; + } + + AnimalShelter that = (AnimalShelter) o; + + return animals != null ? animals.equals(that.animals) + : that.animals == null; + } + + @Override + public int hashCode() { + return animals != null ? animals.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/AnimalShelterWithSerializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/AnimalShelterWithSerializer.java new file mode 100644 index 0000000..9bbdd1d --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/AnimalShelterWithSerializer.java
@@ -0,0 +1,68 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.json.bind.annotation.JsonbTypeDeserializer; +import jakarta.json.bind.annotation.JsonbTypeSerializer; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer.AnimalListDeserializer; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer.AnimalListSerializer; + +public class AnimalShelterWithSerializer { + @JsonbTypeSerializer(AnimalListSerializer.class) + @JsonbTypeDeserializer(AnimalListDeserializer.class) + private List<Animal> animals = new ArrayList<>(); + + public List<Animal> getAnimals() { + return animals; + } + + public void setAnimals(List<Animal> animals) { + this.animals = animals; + } + + public boolean addAnimal(Animal animal) { + return animals.add(animal); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof AnimalShelterWithSerializer)) { + return false; + } + + AnimalShelterWithSerializer that = (AnimalShelterWithSerializer) o; + + return animals != null ? animals.equals(that.animals) + : that.animals == null; + } + + @Override + public int hashCode() { + return animals != null ? animals.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Cat.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Cat.java new file mode 100644 index 0000000..f1f2eb1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Cat.java
@@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model; + +public class Cat extends Animal { + public Cat() { + } + + public Cat(int age, String name, float weight, boolean furry, + boolean cuddly) { + super(age, name, weight, furry); + this.cuddly = cuddly; + } + + private boolean cuddly; + + public boolean isCuddly() { + return cuddly; + } + + public void setCuddly(boolean cuddly) { + this.cuddly = cuddly; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Cat)) { + return false; + } + if (!super.equals(o)) { + return false; + } + + Cat cat = (Cat) o; + + return cuddly == cat.cuddly; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (cuddly ? 1 : 0); + return result; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Dog.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Dog.java new file mode 100644 index 0000000..d8dbc12 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/Dog.java
@@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model; + +public class Dog extends Animal { + private boolean barking; + + public Dog() { + } + + public Dog(int age, String name, float weight, boolean furry, + boolean barking) { + super(age, name, weight, furry); + this.barking = barking; + } + + public boolean isBarking() { + return barking; + } + + public void setBarking(boolean barking) { + this.barking = barking; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Dog)) { + return false; + } + if (!super.equals(o)) { + return false; + } + + Dog dog = (Dog) o; + + return barking == dog.barking; + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + (barking ? 1 : 0); + return result; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalBuilder.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalBuilder.java new file mode 100644 index 0000000..1df01aa --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalBuilder.java
@@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Dog; + +public class AnimalBuilder { + public enum TYPE { + CAT, DOG, GENERIC + } + + private TYPE type; + + private int age; + + private String name; + + private float weight; + + private boolean furry; + + private boolean cuddly; + + private boolean barking; + + public void setType(TYPE type) { + this.type = type; + } + + public void setAge(int age) { + this.age = age; + } + + public void setName(String name) { + this.name = name; + } + + public void setWeight(float weight) { + this.weight = weight; + } + + public void setFurry(boolean furry) { + this.furry = furry; + } + + public void setCuddly(boolean cuddly) { + this.cuddly = cuddly; + } + + public void setBarking(boolean barking) { + this.barking = barking; + } + + public Animal build() { + Animal animal; + + switch (type) { + case CAT: + animal = new Cat(age, name, weight, furry, cuddly); + break; + case DOG: + animal = new Dog(age, name, weight, furry, barking); + break; + default: + animal = new Animal(age, name, weight, furry); + } + + return animal; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalDeserializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalDeserializer.java new file mode 100644 index 0000000..f19ebe1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalDeserializer.java
@@ -0,0 +1,88 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer; + +import java.lang.reflect.Type; + +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.stream.JsonParser; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Dog; + +public class AnimalDeserializer implements JsonbDeserializer<Animal> { + public Animal deserialize(JsonParser jsonParser, + DeserializationContext deserializationContext, Type type) { + Animal animal = null; + while (jsonParser.hasNext()) { + JsonParser.Event event = jsonParser.next(); + if (event == JsonParser.Event.START_OBJECT) { + continue; + } + if (event == JsonParser.Event.END_OBJECT) { + break; + } + if (event == JsonParser.Event.KEY_NAME) { + switch (jsonParser.getString()) { + case "type": + jsonParser.next(); + switch (jsonParser.getString()) { + case "cat": + animal = new Cat(); + break; + case "dog": + animal = new Dog(); + break; + default: + animal = new Animal(); + } + break; + case "name": + jsonParser.next(); + animal.setName(jsonParser.getString()); + break; + case "age": + jsonParser.next(); + animal.setAge(jsonParser.getInt()); + break; + case "furry": + event = jsonParser.next(); + animal.setFurry(event == JsonParser.Event.VALUE_TRUE); + break; + case "weight": + jsonParser.next(); + animal.setWeight(jsonParser.getBigDecimal().floatValue()); + break; + case "cuddly": + event = jsonParser.next(); + ((Cat) animal).setCuddly(event == JsonParser.Event.VALUE_TRUE); + break; + case "barking": + event = jsonParser.next(); + ((Dog) animal).setBarking(event == JsonParser.Event.VALUE_TRUE); + } + } + } + return animal; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalListDeserializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalListDeserializer.java new file mode 100644 index 0000000..2d05711 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalListDeserializer.java
@@ -0,0 +1,49 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.List; + +import jakarta.json.bind.serializer.DeserializationContext; +import jakarta.json.bind.serializer.JsonbDeserializer; +import jakarta.json.stream.JsonParser; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; + +public class AnimalListDeserializer implements JsonbDeserializer<List<Animal>> { + private AnimalDeserializer animalDeserializer = new AnimalDeserializer(); + + public List<Animal> deserialize(JsonParser jsonParser, + DeserializationContext deserializationContext, Type type) { + List<Animal> animals = new ArrayList<>(); + while (jsonParser.hasNext()) { + JsonParser.Event event = jsonParser.next(); + while (event == JsonParser.Event.START_OBJECT) { + animals.add(animalDeserializer.deserialize(jsonParser, + deserializationContext, type)); + event = jsonParser.next(); + } + } + return animals; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalListSerializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalListSerializer.java new file mode 100644 index 0000000..d41c0eb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalListSerializer.java
@@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer; + +import java.util.List; + +import jakarta.json.bind.serializer.JsonbSerializer; +import jakarta.json.bind.serializer.SerializationContext; +import jakarta.json.stream.JsonGenerator; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; + +public class AnimalListSerializer implements JsonbSerializer<List<Animal>> { + private AnimalSerializer animalSerializer = new AnimalSerializer(); + + public void serialize(List<Animal> animals, JsonGenerator jsonGenerator, + SerializationContext serializationContext) { + jsonGenerator.writeStartArray(); + for (Animal animal : animals) { + animalSerializer.serialize(animal, jsonGenerator, serializationContext); + } + jsonGenerator.writeEnd(); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalSerializer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalSerializer.java new file mode 100644 index 0000000..49664ce --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/serializers/model/serializer/AnimalSerializer.java
@@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.serializers.model.serializer; + +import jakarta.json.bind.serializer.JsonbSerializer; +import jakarta.json.bind.serializer.SerializationContext; +import jakarta.json.stream.JsonGenerator; + +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Animal; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Cat; +import ee.jakarta.tck.json.bind.customizedmapping.serializers.model.Dog; + +public class AnimalSerializer implements JsonbSerializer<Animal> { + public void serialize(Animal animal, JsonGenerator jsonGenerator, + SerializationContext serializationContext) { + if (animal != null) { + jsonGenerator.writeStartObject(); + if (Cat.class.isAssignableFrom(animal.getClass())) { + jsonGenerator.write("type", "cat"); + jsonGenerator.write("cuddly", ((Cat) animal).isCuddly()); + } else if (Dog.class.isAssignableFrom(animal.getClass())) { + jsonGenerator.write("type", "dog"); + jsonGenerator.write("barking", ((Dog) animal).isBarking()); + } else { + jsonGenerator.write("type", "animal"); + } + jsonGenerator.write("age", animal.getAge()); + jsonGenerator.write("furry", animal.isFurry()); + jsonGenerator.write("name", animal.getName()); + jsonGenerator.write("weight", animal.getWeight()); + jsonGenerator.writeEnd(); + } else { + serializationContext.serialize(null, jsonGenerator); + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/VisibilityCustomizationTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/VisibilityCustomizationTest.java new file mode 100644 index 0000000..a70afe2 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/VisibilityCustomizationTest.java
@@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.visibility; + +import java.util.regex.Pattern; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; + +import ee.jakarta.tck.json.bind.customizedmapping.visibility.model.CustomFieldVisibilityStrategy; +import ee.jakarta.tck.json.bind.customizedmapping.visibility.model.CustomVisibilityAnnotatedContainer; +import ee.jakarta.tck.json.bind.customizedmapping.visibility.model.SimpleContainer; +import ee.jakarta.tck.json.bind.customizedmapping.visibility.model.customized.PackageCustomizedContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.nullValue; + +/** + * @test + * @sources VisibilityCustomizationTest.java + * @executeClass com.sun.ts.tests.jsonb.customizedmapping.visibility.VisibilityCustomizationTest + **/ +public class VisibilityCustomizationTest { + + private static final Pattern PATTERN = Pattern.compile("\\{\\s*\"floatInstance\"\\s*:\\s*0.0\\s*}"); + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testCustomVisibilityConfig + * + * @assertion_ids: JSONB:SPEC:JSB-4.6-1 + * + * @test_Strategy: Assert that only fields allowed by custom + * PropertyVisibilityStrategy are available for marshalling and unmarshalling + * if JsonbConfig.withPropertyVisibilityStrategy is used + */ + @Test + public void testCustomVisibilityConfig() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyVisibilityStrategy(new CustomFieldVisibilityStrategy())); + String jsonString = jsonb.toJson(new SimpleContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to hide fields during marshalling by applying custom visibility strategy using configuration.", + jsonString, matchesPattern(PATTERN)); + + SimpleContainer unmarshalledObject = jsonb.fromJson("{ \"stringInstance\" : \"Test String\", \"floatInstance\" : 1.0, " + + "\"integerInstance\" : 1 }", + SimpleContainer.class); + String validationMessage = "Failed to ignore fields during unmarshalling by applying custom visibility strategy " + + "using configuration."; + assertThat(validationMessage, unmarshalledObject.getStringInstance(), nullValue()); + assertThat(validationMessage, unmarshalledObject.getIntegerInstance(), is(1)); + assertThat(validationMessage, unmarshalledObject.getFloatInstance(), is(1f)); + } + + /* + * @testName: testCustomVisibilityAnnotation + * + * @assertion_ids: JSONB:SPEC:JSB-4.6-1 + * + * @test_Strategy: Assert that only fields allowed by custom + * PropertyVisibilityStrategy are available for marshalling and unmarshalling + * if JsonbVisibility annotation is used on a type + */ + @Test + public void testCustomVisibilityAnnotation() { + String jsonString = jsonb.toJson(new CustomVisibilityAnnotatedContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to hide fields during marshalling by applying custom visibility strategy using " + + "JsonbVisibility annotation.", + jsonString, matchesPattern(PATTERN)); + + CustomVisibilityAnnotatedContainer unmarshalledObject = jsonb.fromJson("{ \"stringInstance\" : \"Test String\", " + + "\"floatInstance\" : 1.0, " + + "\"integerInstance\" : 1 }", + CustomVisibilityAnnotatedContainer.class); + + String validationMessage = "Failed to ignore fields during unmarshalling by applying custom visibility strategy using " + + "JsonbVisibility annotation."; + assertThat(validationMessage, unmarshalledObject.getStringInstance(), nullValue()); + assertThat(validationMessage, unmarshalledObject.getIntegerInstance(), nullValue()); + assertThat(validationMessage, unmarshalledObject.getFloatInstance(), is(0.0f)); + } + + /* + * @testName: testCustomVisibilityPackage + * + * @assertion_ids: JSONB:SPEC:JSB-4.6-1 + * + * @test_Strategy: Assert that only fields allowed by custom + * PropertyVisibilityStrategy are available for marshalling and unmarshalling + * if JsonbVisibility annotation is used on a package + */ + @Test + public void testCustomVisibilityPackage() { + String jsonString = jsonb.toJson(new PackageCustomizedContainer() { + { + setStringInstance("Test String"); + } + }); + assertThat("Failed to hide fields during marshalling by applying custom visibility strategy using JsonbVisibility " + + "annotation on package.", + jsonString, matchesPattern(PATTERN)); + + PackageCustomizedContainer unmarshalledObject = jsonb.fromJson("{ \"stringInstance\" : \"Test String\", " + + "\"floatInstance\" : 1.0, " + + "\"integerInstance\" : 1 }", + PackageCustomizedContainer.class); + + String validationMessage = "Failed to ignore fields during unmarshalling by applying custom visibility strategy using " + + "JsonbVisibility annotation on package."; + assertThat(validationMessage, unmarshalledObject.getStringInstance(), nullValue()); + assertThat(validationMessage, unmarshalledObject.getIntegerInstance(), nullValue()); + assertThat(validationMessage, unmarshalledObject.getFloatInstance(), is(0.0f)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomFieldVisibilityStrategy.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomFieldVisibilityStrategy.java new file mode 100644 index 0000000..9c43052 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomFieldVisibilityStrategy.java
@@ -0,0 +1,34 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.customizedmapping.visibility.model; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import jakarta.json.bind.config.PropertyVisibilityStrategy; + +public class CustomFieldVisibilityStrategy implements PropertyVisibilityStrategy { + @Override + public boolean isVisible(Field field) { + return field.getGenericType() == float.class || field.getGenericType() == Integer.class; + } + + @Override + public boolean isVisible(Method method) { + return false; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomVisibilityAnnotatedContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomVisibilityAnnotatedContainer.java new file mode 100644 index 0000000..57764bb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomVisibilityAnnotatedContainer.java
@@ -0,0 +1,56 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.visibility.model; + +import jakarta.json.bind.annotation.JsonbVisibility; + +@JsonbVisibility(CustomVisibilityStrategy.class) +public class CustomVisibilityAnnotatedContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public void setIntegerInstance(Integer integerInstance) { + this.integerInstance = integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } + + public void setFloatInstance(float floatInstance) { + this.floatInstance = floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomVisibilityStrategy.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomVisibilityStrategy.java new file mode 100644 index 0000000..a7104a8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/CustomVisibilityStrategy.java
@@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.visibility.model; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import jakarta.json.bind.config.PropertyVisibilityStrategy; + +public class CustomVisibilityStrategy implements PropertyVisibilityStrategy { + @Override + public boolean isVisible(Field field) { + return false; + } + + @Override + public boolean isVisible(Method method) { + return method.getName().equals("getFloatInstance"); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/SimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/SimpleContainer.java new file mode 100644 index 0000000..d16897b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/SimpleContainer.java
@@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.visibility.model; + +public class SimpleContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public void setIntegerInstance(Integer integerInstance) { + this.integerInstance = integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } + + public void setFloatInstance(float floatInstance) { + this.floatInstance = floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/customized/PackageCustomizedContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/customized/PackageCustomizedContainer.java new file mode 100644 index 0000000..3e9e8b1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/customized/PackageCustomizedContainer.java
@@ -0,0 +1,53 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.customizedmapping.visibility.model.customized; + +public class PackageCustomizedContainer { + private String stringInstance; + + private Integer integerInstance; + + private float floatInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } + + public Integer getIntegerInstance() { + return integerInstance; + } + + public void setIntegerInstance(Integer integerInstance) { + this.integerInstance = integerInstance; + } + + public float getFloatInstance() { + return floatInstance; + } + + public void setFloatInstance(float floatInstance) { + this.floatInstance = floatInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/customized/package-info.java b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/customized/package-info.java new file mode 100644 index 0000000..ee9e534 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/customizedmapping/visibility/model/customized/package-info.java
@@ -0,0 +1,26 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +@JsonbVisibility(CustomVisibilityStrategy.class) +package ee.jakarta.tck.json.bind.customizedmapping.visibility.model.customized; + +import jakarta.json.bind.annotation.JsonbVisibility; + +import ee.jakarta.tck.json.bind.customizedmapping.visibility.model.CustomVisibilityStrategy;
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/ArraysMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/ArraysMappingTest.java new file mode 100644 index 0000000..0a809ee --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/ArraysMappingTest.java
@@ -0,0 +1,98 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.arrays; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.defaultmapping.arrays.model.MultiDimensionalArrayContainer; +import ee.jakarta.tck.json.bind.defaultmapping.arrays.model.PrimitiveArrayContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources ArraysMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.arrays.ArraysMappingTest + **/ +public class ArraysMappingTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testPrimitiveArray + * + * @assertion_ids: JSONB:SPEC:JSB-3.12-1; JSONB:SPEC:JSB-3.12-2 + * + * @test_Strategy: Assert that a simple array of primitives is handled + * correctly + */ + @Test + public void testPrimitiveArray() { + int[] instance = {Integer.MIN_VALUE, Integer.MAX_VALUE}; + String jsonString = jsonb.toJson(new PrimitiveArrayContainer() { + { + setInstance(instance); + } + }); + assertThat("Failed to marshal object with int[] attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*\\[\\s*" + Integer.MIN_VALUE + + "\\s*,\\s*" + Integer.MAX_VALUE + "\\s*\\]\\s*\\}")); + + PrimitiveArrayContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : [ " + Integer.MIN_VALUE + ", " + + Integer.MAX_VALUE + " ] }", + PrimitiveArrayContainer.class); + assertThat("Failed to unmarshal object with int[] attribute value.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testMultiDimensionalArray + * + * @assertion_ids: JSONB:SPEC:JSB-3.12-1; JSONB:SPEC:JSB-3.12-2; + * JSONB:SPEC:JSB-3.14.2-1; JSONB:SPEC:JSB-3.14.2-2; JSONB:SPEC:JSB-3.14.2-3 + * + * @test_Strategy: Assert that a multi-dimensional array is serialized and + * deserialized as a multi-dimensional array and null array values are + * correctly serialized and deserialized + */ + @Test + public void testMultiDimensionalArray() { + Integer[][] instance = {{1, null, 3}, + {Integer.MIN_VALUE, Integer.MAX_VALUE}}; + String jsonString = jsonb.toJson(new MultiDimensionalArrayContainer() { + { + setInstance(instance); + } + }); + String validationPattern = "\\{\\s*\"instance\"\\s*\\:\\s*\\[\\s*\\[\\s*1\\s*,\\s*null\\s*,\\s*3\\s*\\]\\s*,\\s*\\[\\s*" + + Integer.MIN_VALUE + "\\s*,\\s*" + Integer.MAX_VALUE + + "\\s*\\]\\s*\\]\\s*\\}"; + assertThat("Failed to marshal object with int[][] attribute value.", jsonString, matchesPattern(validationPattern)); + + String toDeserialize = "{ \"instance\" : [ [ 1, null, 3 ], [ " + Integer.MIN_VALUE + ", " + Integer.MAX_VALUE + " ] ] }"; + MultiDimensionalArrayContainer unmarshalledObject = jsonb.fromJson(toDeserialize, MultiDimensionalArrayContainer.class); + assertThat("Failed to unmarshal object with int[][] attribute value.", unmarshalledObject.getInstance(), is(instance)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/model/MultiDimensionalArrayContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/model/MultiDimensionalArrayContainer.java new file mode 100644 index 0000000..dea1516 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/model/MultiDimensionalArrayContainer.java
@@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.arrays.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class MultiDimensionalArrayContainer + implements TypeContainer<Integer[][]> { + private Integer[][] instance; + + @Override + public Integer[][] getInstance() { + return instance; + } + + @Override + public void setInstance(Integer[][] instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/model/PrimitiveArrayContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/model/PrimitiveArrayContainer.java new file mode 100644 index 0000000..31f2529 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/arrays/model/PrimitiveArrayContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.arrays.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class PrimitiveArrayContainer implements TypeContainer<int[]> { + private int[] instance; + + @Override + public int[] getInstance() { + return instance; + } + + @Override + public void setInstance(int[] instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/AttributeOrderMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/AttributeOrderMappingTest.java new file mode 100644 index 0000000..5032bf9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/AttributeOrderMappingTest.java
@@ -0,0 +1,101 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.attributeorder; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.defaultmapping.attributeorder.model.ExtendedContainer; +import ee.jakarta.tck.json.bind.defaultmapping.attributeorder.model.SimpleContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources AttributeOrderMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.attributeorder.AttributeOrderMappingTest + **/ +public class AttributeOrderMappingTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testClassAttributeOrder + * + * @assertion_ids: JSONB:SPEC:JSB-3.13-1; JSONB:SPEC:JSB-3.13-2 + * + * @test_Strategy: Assert that declared fields are marshalled in + * lexicographical order and unmarshalled in the order of appearance in the + * JSON document + */ + @Test + public void testClassAttributeOrder() { + String jsonString = jsonb.toJson(new SimpleContainer() { + { + setIntInstance(0); + setStringInstance("Test String"); + setLongInstance(0L); + } + }); + String validationPattern = "\\{\\s*\"intInstance\"\\s*\\:\\s*0\\s*,\\s*\"longInstance\"\\s*\\:\\s*0\\s*," + + "\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\}"; + assertThat("Failed to lexicographically order class attributes.", jsonString, matchesPattern(validationPattern)); + + String toDeserialize = "{ \"intInstance\" : 1, \"stringInstance\" : \"Test String\", \"longInstance\" : 0 }"; + SimpleContainer unmarshalledObject = jsonb.fromJson(toDeserialize, SimpleContainer.class); + assertThat("Failed to set class attributes in order of appearance.", unmarshalledObject.getIntInstance(), is(3)); + } + + /* + * @testName: testExtendedClassAttributeOrder + * + * @assertion_ids: JSONB:SPEC:JSB-3.13-1; JSONB:SPEC:JSB-3.13-2 + * + * @test_Strategy: Assert that declared fields of super class are marshalled + * before declared fields of child class and all are unmarshalled in the order + * of appearance in the JSON document + */ + @Test + public void testExtendedClassAttributeOrder() { + String jsonString = jsonb.toJson(new ExtendedContainer() { + { + setIntInstance(0); + setStringInstance("Test String"); + setLongInstance(0L); + setFloatInstance(0f); + setShortInstance((short) 0); + } + }); + String validationPattern = "\\{\\s*\"intInstance\"\\s*\\:\\s*0\\s*,\\s*\"longInstance\"\\s*\\:\\s*0\\s*," + + "\\s*\"stringInstance\"\\s*\\:\\s*\"Test String\"\\s*\\,\\s*\"floatInstance\"\\s*\\:\\s*0.0\\s*," + + "\\s*\"shortInstance\"\\s*\\:\\s*0\\s*}"; + assertThat("Failed to correctly order extended class attributes.", jsonString, matchesPattern(validationPattern)); + + String toDeserialize = "{ \"intInstance\" : 1, \"shortInstance\" : 0, \"stringInstance\" : \"Test String\", " + + "\"floatInstance\" : 0.0, \"longInstance\" : 0 }"; + ExtendedContainer unmarshalledObject = jsonb.fromJson(toDeserialize, ExtendedContainer.class); + assertThat("Failed to set extended class attributes in order of appearance.", + unmarshalledObject.getIntInstance(), is(5)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/model/ExtendedContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/model/ExtendedContainer.java new file mode 100644 index 0000000..b308bcf --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/model/ExtendedContainer.java
@@ -0,0 +1,70 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.attributeorder.model; + +public class ExtendedContainer extends SimpleContainer { + private short shortInstance; + + private float floatInstance; + + public short getShortInstance() { + return shortInstance; + } + + public void setShortInstance(short shortInstance) { + this.shortInstance = shortInstance; + if (intInstance == 1) { + intInstance = 2; + } + } + + public float getFloatInstance() { + return floatInstance; + } + + public void setFloatInstance(float floatInstance) { + this.floatInstance = floatInstance; + if (intInstance == 3) { + intInstance = 4; + } + } + + @Override + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + if (intInstance == 2) { + intInstance = 3; + } + } + + @Override + public void setIntInstance(int intInstance) { + this.intInstance = intInstance; + } + + @Override + public void setLongInstance(long longInstance) { + this.longInstance = longInstance; + if (intInstance == 4) { + intInstance = 5; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/model/SimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/model/SimpleContainer.java new file mode 100644 index 0000000..81ae75c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/attributeorder/model/SimpleContainer.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.attributeorder.model; + +public class SimpleContainer { + protected int intInstance; + + protected String stringInstance; + + protected long longInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + if (intInstance == 1) { + intInstance = 2; + } + } + + public int getIntInstance() { + return intInstance; + } + + public void setIntInstance(int intInstance) { + this.intInstance = intInstance; + } + + public long getLongInstance() { + return longInstance; + } + + public void setLongInstance(long longInstance) { + this.longInstance = longInstance; + if (intInstance == 2) { + intInstance = 3; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/BasicJavaTypesMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/BasicJavaTypesMappingTest.java new file mode 100644 index 0000000..b1f7b4e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/BasicJavaTypesMappingTest.java
@@ -0,0 +1,228 @@ +/* + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes; + +import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; + +import ee.jakarta.tck.json.bind.MappingTester; +import ee.jakarta.tck.json.bind.SimpleMappingTester; +import ee.jakarta.tck.json.bind.TypeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.BooleanContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.ByteContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.CharacterContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.DoubleContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.FloatContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.IntegerContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.LongContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.NumberContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.ShortContainer; +import ee.jakarta.tck.json.bind.defaultmapping.basictypes.model.StringContainer; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +/** + * @test + * @sources BasicJavaTypesMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.basictypes.BasicJavaTypesMappingTest + **/ +public class BasicJavaTypesMappingTest { + + /* + * @testName: testStringMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.1-5; JSONB:SPEC:JSB-3.3-1; + * JSONB:SPEC:JSB-3.3.1-1; JSONB:SPEC:JSB-3.3.1-2 + * + * @test_Strategy: Assert that String type is correctly handled, encodings + * other than UTF-8 are supported and that UTF-8 BOM does not produce an error + */ + @Test + public void testStringMapping() throws Exception { + MappingTester<String> stringMappingTester = new MappingTester<>(StringContainer.class); + stringMappingTester.test("Test String", "\"Test String\""); + stringMappingTester.test(new String(new byte[] {(byte) 0xef, (byte) 0xbb, (byte) 0xbf}, StandardCharsets.UTF_8), + "\"" + new String(new byte[] {(byte) 0xef, (byte) 0xbb, (byte) 0xbf}, + StandardCharsets.UTF_8) + "\""); + stringMappingTester.test(new String("Test String".getBytes(), StandardCharsets.UTF_8), + "\"" + new String("Test String".getBytes(), StandardCharsets.UTF_8) + "\""); + } + + /* + * @testName: testCharacterMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3-1; JSONB:SPEC:JSB-3.3.1-1 + * + * @test_Strategy: Assert that Character type is correctly handled + */ + @Test + public void testCharacterMapping() { + MappingTester<Character> characterMappingTester = new MappingTester<>(CharacterContainer.class); + characterMappingTester.test('c', "\"c\""); + // RFC 4627, paragraph 2.5: the control characters U+0000 must be + // escaped + characterMappingTester.test(Character.MIN_VALUE, "\"\\u0000\""); + characterMappingTester.test(Character.MAX_VALUE, "\"" + Character.MAX_VALUE + "\""); + } + + /* + * @testName: testByteMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3-1; JSONB:SPEC:JSB-3.3.2-1; + * JSONB:SPEC:JSB-3.3.2-2 + * + * @test_Strategy: Assert that Byte type is correctly handled in accordance + * with toString and parseByte methods + */ + @Test + public void testByteMapping() { + MappingTester<Byte> byteMappingTester = new MappingTester<>(ByteContainer.class); + byteMappingTester.test((byte) 0, "0"); + byteMappingTester.test(Byte.MIN_VALUE, String.valueOf(Byte.MIN_VALUE)); + byteMappingTester.test(Byte.MAX_VALUE, String.valueOf(Byte.MAX_VALUE)); + } + + /* + * @testName: testShortMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3-1; JSONB:SPEC:JSB-3.3.2-1; + * JSONB:SPEC:JSB-3.3.2-2 + * + * @test_Strategy: Assert that Short type is correctly handled in accordance + * with toString and parseShort methods + */ + @Test + public void testShortMapping() { + MappingTester<Short> shortMappingTester = new MappingTester<>(ShortContainer.class); + shortMappingTester.test((short) 0, "0"); + shortMappingTester.test(Short.MIN_VALUE, String.valueOf(Short.MIN_VALUE)); + shortMappingTester.test(Short.MAX_VALUE, String.valueOf(Short.MAX_VALUE)); + } + + /* + * @testName: testIntegerMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3-1; JSONB:SPEC:JSB-3.3.2-1; + * JSONB:SPEC:JSB-3.3.2-2 + * + * @test_Strategy: Assert that Integer type is correctly handled in accordance + * with toString and parseInteger methods + */ + @Test + public void testIntegerMapping() { + MappingTester<Integer> integerMappingTester = new MappingTester<>(IntegerContainer.class); + integerMappingTester.test(0, "0"); + integerMappingTester.test(Integer.MIN_VALUE, String.valueOf(Integer.MIN_VALUE)); + integerMappingTester.test(Integer.MAX_VALUE, String.valueOf(Integer.MAX_VALUE)); + } + + /* + * @testName: testLongMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3-1; JSONB:SPEC:JSB-3.3.2-1; + * JSONB:SPEC:JSB-3.3.2-2 + * + * @test_Strategy: Assert that Long type is correctly handled in accordance + * with toString and parseLong methods + */ + @Test + @Disabled("See https://github.com/jakartaee/jsonb-api/issues/180") + public void testLongMapping() { + MappingTester<Long> longMappingTester = new MappingTester<>(LongContainer.class); + longMappingTester.test(0L, "0"); + longMappingTester.test(Long.MIN_VALUE, String.valueOf(Long.MIN_VALUE)); + longMappingTester.test(Long.MAX_VALUE, String.valueOf(Long.MAX_VALUE)); + } + + /* + * @testName: testFloatMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3-1; JSONB:SPEC:JSB-3.3.2-1; + * JSONB:SPEC:JSB-3.3.2-2 + * + * @test_Strategy: Assert that Float type is correctly handled in accordance + * with toString and parseFloat methods + */ + @Test + public void testFloatMapping() { + MappingTester<Float> floatMappingTester = new MappingTester<>(FloatContainer.class); + floatMappingTester.test(0f, "0.0"); + floatMappingTester.test(0.5f, "0.5"); + floatMappingTester.test(Float.MIN_VALUE, String.valueOf(Float.MIN_VALUE)); + floatMappingTester.test(Float.MAX_VALUE, String.valueOf(Float.MAX_VALUE)); + } + + /* + * @testName: testDoubleMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3-1; JSONB:SPEC:JSB-3.3.2-1; + * JSONB:SPEC:JSB-3.3.2-2 + * + * @test_Strategy: Assert that Double type is correctly handled in accordance + * with toString and parseDouble methods + */ + @Test + public void testDoubleMapping() { + MappingTester<Double> doubleMappingTester = new MappingTester<>(DoubleContainer.class); + doubleMappingTester.test(0.0, "0.0"); + doubleMappingTester.test(Double.MIN_VALUE, String.valueOf(Double.MIN_VALUE)); + doubleMappingTester.test(Double.MAX_VALUE, String.valueOf(Double.MAX_VALUE)); + } + + /* + * @testName: testBooleanMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3-1; JSONB:SPEC:JSB-3.3.3-1; + * JSONB:SPEC:JSB-3.3.3-1; JSONB:SPEC:JSB-3.3.3-2 + * + * @test_Strategy: Assert that Boolean type is correctly handled in accordance + * with toString and parseBoolean methods + */ + @Test + public void testBooleanMapping() { + MappingTester<Boolean> booleanMappingTester = new MappingTester<>(BooleanContainer.class); + booleanMappingTester.test(true, "true"); + booleanMappingTester.test(false, "false"); + booleanMappingTester.test(Boolean.TRUE, Boolean.TRUE.toString()); + booleanMappingTester.test(Boolean.FALSE, Boolean.FALSE.toString()); + } + + /* + * @testName: testNumberMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.3.4-1; JSONB:SPEC:JSB-3.3.4-2; + * JSONB:SPEC:JSB-3.10-1 + * + * @test_Strategy: Assert that Number type is correctly marshalled using + * java.lang.Number.doubleValue() and toString methods and unmarshalled to + * java.math.BigDecimal using String constructor + */ + @Test + public void testNumberMapping() { + new SimpleMappingTester<>(NumberContainer.class, TypeContainer.class).test( + new NumberContainer(), "\\{\\s*\"instance\"\\s*:\\s*0[\\.0]?+\\s*}", + "{ \"instance\" : 0 }", new NumberContainer() { + { + setInstance(new BigDecimal("0")); + } + }); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/BooleanContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/BooleanContainer.java new file mode 100644 index 0000000..86525fd --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/BooleanContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class BooleanContainer implements TypeContainer<Boolean> { + private Boolean instance; + + @Override + public Boolean getInstance() { + return instance; + } + + @Override + public void setInstance(Boolean instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/ByteContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/ByteContainer.java new file mode 100644 index 0000000..c75497a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/ByteContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class ByteContainer implements TypeContainer<Byte> { + private Byte instance; + + @Override + public Byte getInstance() { + return instance; + } + + @Override + public void setInstance(Byte instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/CharacterContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/CharacterContainer.java new file mode 100644 index 0000000..803d5c5 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/CharacterContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class CharacterContainer implements TypeContainer<Character> { + private Character instance; + + @Override + public Character getInstance() { + return instance; + } + + @Override + public void setInstance(Character instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/DoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/DoubleContainer.java new file mode 100644 index 0000000..8d7779a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/DoubleContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class DoubleContainer implements TypeContainer<Double> { + private Double instance; + + @Override + public Double getInstance() { + return instance; + } + + @Override + public void setInstance(Double instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/FloatContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/FloatContainer.java new file mode 100644 index 0000000..d1ebff3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/FloatContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class FloatContainer implements TypeContainer<Float> { + private Float instance; + + @Override + public Float getInstance() { + return instance; + } + + @Override + public void setInstance(Float instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/IntegerContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/IntegerContainer.java new file mode 100644 index 0000000..42cafd3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/IntegerContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class IntegerContainer implements TypeContainer<Integer> { + private Integer instance; + + @Override + public Integer getInstance() { + return instance; + } + + @Override + public void setInstance(Integer instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/LongContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/LongContainer.java new file mode 100644 index 0000000..3d55dda --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/LongContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LongContainer implements TypeContainer<Long> { + private Long instance; + + @Override + public Long getInstance() { + return instance; + } + + @Override + public void setInstance(Long instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/NumberContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/NumberContainer.java new file mode 100644 index 0000000..e06879e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/NumberContainer.java
@@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class NumberContainer implements TypeContainer<Number> { + private Number instance = 0; + + @Override + public Number getInstance() { + return instance; + } + + @Override + public void setInstance(Number instance) { + this.instance = instance; + } + + @Override + public boolean equals(Object obj) { + if (NumberContainer.class.isInstance(obj)) { + return instance.equals(((NumberContainer) obj).instance); + } + return false; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/ShortContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/ShortContainer.java new file mode 100644 index 0000000..279e3ba --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/ShortContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class ShortContainer implements TypeContainer<Short> { + private Short instance; + + @Override + public Short getInstance() { + return instance; + } + + @Override + public void setInstance(Short instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/StringContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/StringContainer.java new file mode 100644 index 0000000..733115d --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/basictypes/model/StringContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.basictypes.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class StringContainer implements TypeContainer<String> { + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/bignumbers/BigNumbersMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/bignumbers/BigNumbersMappingTest.java new file mode 100644 index 0000000..cc4cd53 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/bignumbers/BigNumbersMappingTest.java
@@ -0,0 +1,62 @@ +/* + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.bignumbers; + +import java.math.BigDecimal; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources BigNumbersMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.bignumbers.BigNumbersMappingTest + **/ +public class BigNumbersMappingTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testBigNumberMarshalling + * + * @assertion_ids: JSONB:SPEC:JSB-3.16-1 + * + * @test_Strategy: Assert that numbers of greater magnitude or precision than + * IEEE 754 are serialized as strings as specified by IJSON RFC 7493 (default + * to JSON-B) + */ + @Test + @Disabled("See https://github.com/jakartaee/jsonb-api/issues/180") + public void testBigNumberMarshalling() { + String jsonString = jsonb.toJson(new Object() { + @SuppressWarnings("unused") + public Number number = new BigDecimal("0.10000000000000001"); + }); + assertThat("Failed to correctly marshal number of greater precision than IEEE 754 as string.", + jsonString, matchesPattern("\\{\\s*\"number\"\\s*:\\s*\"0.10000000000000001\"\\s*\\}")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/ClassesMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/ClassesMappingTest.java new file mode 100644 index 0000000..23f464b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/ClassesMappingTest.java
@@ -0,0 +1,676 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes; + +import java.lang.reflect.Field; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerAccessorsWithoutMatchingField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerFinalField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerFinalPublicField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerNoAccessorsPackagePrivateField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerNoAccessorsPrivateField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerNoAccessorsProtectedField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerNoAccessorsPublicField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPackagePrivateAccessors; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPackagePrivateConstructor; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPrivateAccessors; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPrivateAccessorsPublicField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPrivateConstructor; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerProtectedAccessors; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerProtectedConstructor; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerProtectedStaticNestedClass; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPublicAccessors; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPublicAccessorsPublicField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPublicConstructor; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerPublicStaticNestedClass; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerStaticField; +import ee.jakarta.tck.json.bind.defaultmapping.classes.model.StringContainerTransientField; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; + +/** + * @test + * @sources ClassesMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.classes.ClassesMappingTest + **/ +public class ClassesMappingTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testPublicConstructorAccess + * + * @assertion_ids: JSONB:SPEC:JSB-3.7-1; JSONB:SPEC:JSB-3.7-2 + * + * @test_Strategy: Assert that a class with a public constructor can be + * marshalled and unmarshalled + */ + @Test + public void testPublicConstructorAccess() { + String jsonString = assertDoesNotThrow(() -> jsonb.toJson(new StringContainerPublicConstructor()), + "An exception is not expected when marshalling a class with a public constructor" + + "."); + assertThat("Failed to get attribute value when marshalling a class with a public constructor.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + assertDoesNotThrow(() -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", StringContainerPublicConstructor.class), + "An exception is not expected when unmarshalling a class with a public constructor."); + } + + /* + * @testName: testProtectedConstructorAccess + * + * @assertion_ids: JSONB:SPEC:JSB-3.7-1; JSONB:SPEC:JSB-3.7-2 + * + * @test_Strategy: Assert that a class with a protected constructor can be + * marshalled and unmarshalled + */ + @Test + public void testProtectedConstructorAccess() { + String jsonString = assertDoesNotThrow(() -> jsonb.toJson(StringContainerProtectedConstructor.getClassInstance()), + "An exception is not expected when marshalling a class with a protected " + + "constructor."); + assertThat("Failed to get attribute value when marshalling a class with a protected constructor.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + assertDoesNotThrow(() -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", StringContainerProtectedConstructor.class), + "An exception is not expected when unmarshalling a class with a protected constructor."); + } + + /* + * @testName: testPrivateConstructorAccess + * + * @assertion_ids: JSONB:SPEC:JSB-3.7-1; JSONB:SPEC:JSB-3.7-2 + * + * @test_Strategy: Assert that a class with a private constructor can be + * marshalled but not unmarshalled + */ + @Test + public void testPrivateConstructorAccess() { + String jsonString = assertDoesNotThrow(() -> jsonb.toJson(StringContainerPrivateConstructor.getClassInstance()), + "An exception is not expected when marshalling a class with a private " + + "constructor."); + assertThat("Failed to get attribute value when marshalling a class with a private constructor.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", StringContainerPrivateConstructor.class), + "An exception is expected when unmarshalling a class with a private constructor."); + } + + /* + * @testName: testPackagePrivateConstructorAccess + * + * @assertion_ids: JSONB:SPEC:JSB-3.7-1; JSONB:SPEC:JSB-3.7-2 + * + * @test_Strategy: Assert that a class with a package private constructor can + * be marshalled but not unmarshalled + */ + @Test + public void testPackagePrivateConstructorAccess() { + String jsonString = assertDoesNotThrow(() -> jsonb.toJson(StringContainerPackagePrivateConstructor.getClassInstance()), + "An exception is not expected when marshalling a class with a package private " + + "constructor."); + assertThat("Failed to get attribute value when marshalling a class with a package private constructor.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", StringContainerPackagePrivateConstructor.class), + "An exception is expected when unmarshalling a class with a package private constructor."); + } + + /* + * @testName: testPublicAccessors + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that private field with public accessors can be + * managed and unmanaged + */ + @Test + public void testPublicAccessors() { + String jsonString = jsonb.toJson(new StringContainerPublicAccessors()); + assertThat("Failed to get attribute value using public getter.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + try { + StringContainerPublicAccessors unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerPublicAccessors.class); + Field instanceField = StringContainerPublicAccessors.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to set attribute value using public setter.", + instanceField.get(unmarshalledObject), is("New Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testProtectedAccessors + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that private field with protected accessors is + * ignored + */ + @Test + public void testProtectedAccessors() { + String jsonString = jsonb.toJson(new StringContainerProtectedAccessors()); + assertThat("Failed to ignore attribute value using protected getter.", jsonString, matchesPattern("\\{\\s*\\}")); + try { + StringContainerProtectedAccessors unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerProtectedAccessors.class); + Field instanceField = StringContainerProtectedAccessors.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting attribute value using protected setter.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testPrivateAccessors + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that private field with private accessors is ignored + */ + @Test + public void testPrivateAccessors() { + String jsonString = jsonb.toJson(new StringContainerPrivateAccessors()); + assertThat("Failed to ignore private value using private getter.", jsonString, matchesPattern("\\{\\s*\\}")); + try { + StringContainerPrivateAccessors unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerPrivateAccessors.class); + Field instanceField = StringContainerPrivateAccessors.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting attribute value using private setter.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testPackagePrivateAccessors + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that private field with package private accessors is + * ignored + */ + @Test + public void testPackagePrivateAccessors() { + String jsonString = jsonb.toJson(new StringContainerPackagePrivateAccessors()); + assertThat("Failed to ignore private value using package private getter.", jsonString, matchesPattern("\\{\\s*\\}")); + + try { + StringContainerPackagePrivateAccessors unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerPackagePrivateAccessors.class); + Field instanceField = StringContainerPackagePrivateAccessors.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting attribute value using package private setter.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testPublicAccessorsPublicField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that public field with public accessors is + * marshalled and unmarshalled using the accessor + */ + @Test + public void testPublicAccessorsPublicField() { + String jsonString = jsonb.toJson(new StringContainerPublicAccessorsPublicField()); + assertThat("Failed to get attribute value using public getter.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Getter String\"\\s*\\}")); + + StringContainerPublicAccessorsPublicField unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerPublicAccessorsPublicField.class); + assertThat("Failed to set attribute value using public setter.", unmarshalledObject.instance, is("Setter String")); + } + + /* + * @testName: testPrivateAccessorsPublicField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that public field with private accessors is + * marshalled and unmarshalled using direct field access + */ + @Test + public void testPrivateAccessorsPublicField() { + String jsonString = jsonb.toJson(new StringContainerPrivateAccessorsPublicField()); + assertThat("Failed to ignore public value using private getter.", jsonString, matchesPattern("\\{\\s*\\}")); + + try { + StringContainerPrivateAccessorsPublicField unmarshalledObject = jsonb + .fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerPrivateAccessorsPublicField.class); + Field instanceField = StringContainerPrivateAccessorsPublicField.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting public value using private setter.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testNoAccessorsPublicField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that public field with no accessors is marshalled + * and unmarshalled using direct field access + */ + @Test + public void testNoAccessorsPublicField() { + String jsonString = jsonb.toJson(new StringContainerNoAccessorsPublicField()); + assertThat("Failed to get public field value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + StringContainerNoAccessorsPublicField unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerNoAccessorsPublicField.class); + assertThat("Failed to set public field value.", unmarshalledObject.instance, is("New Test String")); + } + + /* + * @testName: testNoAccessorsProtectedField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that protected field with no accessors is ignored + */ + @Test + public void testNoAccessorsProtectedField() { + String jsonString = jsonb.toJson(new StringContainerNoAccessorsProtectedField()); + assertThat("Failed to ignore getting protected field value.", jsonString, matchesPattern("\\{\\s*\\}")); + + try { + StringContainerNoAccessorsProtectedField unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerNoAccessorsProtectedField.class); + Field instanceField = StringContainerNoAccessorsProtectedField.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting public value using private setter.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testNoAccessorsPrivateField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that private field with no accessors is ignored + */ + @Test + public void testNoAccessorsPrivateField() { + String jsonString = jsonb.toJson(new StringContainerNoAccessorsPrivateField()); + assertThat("Failed to ignore getting private field value.", jsonString, matchesPattern("\\{\\s*\\}")); + + try { + StringContainerNoAccessorsPrivateField unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerNoAccessorsPrivateField.class); + Field instanceField = StringContainerNoAccessorsPrivateField.class + .getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting private field value.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testNoAccessorsPackagePrivateField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-1; JSONB:SPEC:JSB-3.7.1-2 + * + * @test_Strategy: Assert that package private field with no accessors is + * ignored + */ + @Test + public void testNoAccessorsPackagePrivateField() { + String jsonString = jsonb.toJson(new StringContainerNoAccessorsPackagePrivateField()); + assertThat("Failed to ignore getting package private field value.", jsonString, matchesPattern("\\{\\s*\\}")); + + try { + StringContainerNoAccessorsPackagePrivateField unmarshalledObject = jsonb + .fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerNoAccessorsPackagePrivateField.class); + Field instanceField = StringContainerNoAccessorsPackagePrivateField.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting package private field value.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testTransientField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-3 + * + * @test_Strategy: Assert that transient fields are ignored during marshalling + * and unmarshalling + */ + @Test + public void testTransientField() { + String jsonString = jsonb.toJson(new StringContainerTransientField()); + assertThat("Failed to ignore getting transient field value.", jsonString, matchesPattern("\\{\\s*\\}")); + + try { + StringContainerTransientField unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerTransientField.class); + Field instanceField = StringContainerTransientField.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting transient field value.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testStaticField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-5 + * + * @test_Strategy: Assert that static fields are ignored during marshalling + * and unmarshalling + */ + @Test + public void testStaticField() { + String jsonString = jsonb.toJson(new StringContainerStaticField()); + assertThat("Failed to ignore getting static field value.", jsonString, matchesPattern("\\{\\s*\\}")); + + try { + StringContainerStaticField unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerStaticField.class); + Field instanceField = StringContainerStaticField.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting static field value.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testFinalField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-4 + * + * @test_Strategy: Assert that final fields are correctly marshalled but not + * unmarshalled + */ + @Test + public void testFinalField() { + String jsonString = jsonb.toJson(new StringContainerFinalField()); + assertThat("Failed to get final field value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + try { + StringContainerFinalField unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerFinalField.class); + Field instanceField = StringContainerFinalField.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting final field value.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testFinalPublicField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-4 + * + * @test_Strategy: Assert that final public fields are correctly marshalled + * but not unmarshalled + */ + @Test + public void testFinalPublicField() { + String jsonString = jsonb.toJson(new StringContainerFinalPublicField()); + assertThat("Failed to get final public field value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + try { + StringContainerFinalPublicField unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerFinalPublicField.class); + Field instanceField = StringContainerFinalPublicField.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting final public field value.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testAccessorsWithoutCorrespondingField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-7 + * + * @test_Strategy: Assert that public accessor methods without a corresponding + * field are supported + */ + @Test + public void testAccessorsWithoutCorrespondingField() { + String jsonString = jsonb.toJson(new StringContainerAccessorsWithoutMatchingField()); + assertThat("Failed to get value from getter without corresponding field.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + try { + StringContainerAccessorsWithoutMatchingField unmarshalledObject = jsonb + .fromJson("{ \"instance\" : \"New Test String\" }", + StringContainerAccessorsWithoutMatchingField.class); + Field instanceField = StringContainerAccessorsWithoutMatchingField.class.getDeclaredField("field"); + instanceField.setAccessible(true); + try { + assertThat("Failed to set value using setter without corresponding field.", + instanceField.get(unmarshalledObject), is("New Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testDeserialisationOfNonExistentField + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.1-6 + * + * @test_Strategy: Assert that an attribute without a corresponding field or + * accessor is ignored during unmarshalling + */ + @Test + public void testDeserialisationOfNonExistentField() { + try { + StringContainerPublicAccessors unmarshalledObject = jsonb.fromJson("{ \"field\" : \"New Test String\" }", + StringContainerPublicAccessors.class); + Field instanceField = StringContainerPublicAccessors.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to ignore setting value to non existent field.", + instanceField.get(unmarshalledObject), is("Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testPublicStaticNestedClass + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.3-1; JSONB:SPEC:JSB-3.7.3-2 + * + * @test_Strategy: Assert that public static nested class is correctly handled + */ + @Test + public void testPublicStaticNestedClass() { + String jsonString = jsonb.toJson(new StringContainerPublicStaticNestedClass()); + assertThat("Failed to get attribute value from public nested class.", + jsonString, + matchesPattern("\\{\\s*\"nestedClass\"\\s*:\\s*\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}\\s*\\}")); + + try { + String toDeserialize = "{ \"nestedClass\" : { \"instance\" : \"New Test String\" } }"; + StringContainerPublicStaticNestedClass unmarshalledObject = jsonb.fromJson(toDeserialize, + StringContainerPublicStaticNestedClass.class); + Field instanceField = StringContainerPublicStaticNestedClass.NestedClass.class.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to set attribute value to public nested class.", + instanceField.get(unmarshalledObject.nestedClass), is("New Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testProtectedStaticNestedClass + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.3-1; JSONB:SPEC:JSB-3.7.3-2 + * + * @test_Strategy: Assert that protected static nested class is correctly + * handled + */ + @Test + public void testProtectedStaticNestedClass() { + String jsonString = jsonb.toJson(new StringContainerProtectedStaticNestedClass()); + assertThat("Failed to get attribute value from protected nested class.", + jsonString, + matchesPattern("\\{\\s*\"nestedClass\"\\s*:\\s*\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}\\s*\\}")); + + try { + String toDeserialize = "{ \"nestedClass\" : { \"instance\" : \"New Test String\" } }"; + StringContainerProtectedStaticNestedClass unmarshalledObject = jsonb.fromJson(toDeserialize, + StringContainerProtectedStaticNestedClass.class); + Class<?> nestedClass = StringContainerProtectedStaticNestedClass.class.getDeclaredClasses()[0]; + Field instanceField = nestedClass.getDeclaredField("instance"); + instanceField.setAccessible(true); + try { + assertThat("Failed to set attribute value to protected nested class.", + instanceField.get(unmarshalledObject.nestedClass), is("New Test String")); + } finally { + instanceField.setAccessible(false); + } + } catch (Exception x) { + fail(x.getMessage(), x); + } + } + + /* + * @testName: testAnonymousClass + * + * @assertion_ids: JSONB:SPEC:JSB-3.7.4-1 + * + * @test_Strategy: Assert that marshalling of an anonymous class is supported + * using default object mapping. Unmarshalling is not supported by the spec so + * not tested. + */ + @Test + public void testAnonymousClass() { + Object anonymousInstance = new Object() { + @SuppressWarnings("unused") + public String newInstance = "Anonymous"; + }; + String jsonString = jsonb.toJson(anonymousInstance); + assertThat("Failed to get attribute value from anonymous class.", + jsonString, matchesPattern("\\{\\s*\"newInstance\"\\s*:\\s*\"Anonymous\"\\s*\\}")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerAccessorsWithoutMatchingField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerAccessorsWithoutMatchingField.java new file mode 100644 index 0000000..315742b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerAccessorsWithoutMatchingField.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerAccessorsWithoutMatchingField { + private String field = "Test String"; + + public String getInstance() { + return field; + } + + public void setInstance(String instance) { + this.field = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerFinalField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerFinalField.java new file mode 100644 index 0000000..b8ffe10 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerFinalField.java
@@ -0,0 +1,29 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerFinalField { + private final String instance = "Test String"; + + public String getInstance() { + return instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerFinalPublicField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerFinalPublicField.java new file mode 100644 index 0000000..6c62e82 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerFinalPublicField.java
@@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerFinalPublicField { + public final String instance = "Test String"; +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPackagePrivateField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPackagePrivateField.java new file mode 100644 index 0000000..e2128b4 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPackagePrivateField.java
@@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerNoAccessorsPackagePrivateField { + String instance = "Test String"; +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPrivateField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPrivateField.java new file mode 100644 index 0000000..6704124 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPrivateField.java
@@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerNoAccessorsPrivateField { + private String instance = "Test String"; +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsProtectedField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsProtectedField.java new file mode 100644 index 0000000..cf36143 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsProtectedField.java
@@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerNoAccessorsProtectedField { + protected String instance = "Test String"; +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPublicField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPublicField.java new file mode 100644 index 0000000..5e2adb0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerNoAccessorsPublicField.java
@@ -0,0 +1,25 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerNoAccessorsPublicField { + public String instance = "Test String"; +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPackagePrivateAccessors.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPackagePrivateAccessors.java new file mode 100644 index 0000000..63e8abd --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPackagePrivateAccessors.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPackagePrivateAccessors { + private String instance = "Test String"; + + String getInstance() { + return instance; + } + + void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPackagePrivateConstructor.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPackagePrivateConstructor.java new file mode 100644 index 0000000..08ce695 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPackagePrivateConstructor.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPackagePrivateConstructor { + private String instance = "Test String"; + + StringContainerPackagePrivateConstructor() { + } + + public static StringContainerPackagePrivateConstructor getClassInstance() { + return new StringContainerPackagePrivateConstructor(); + } + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateAccessors.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateAccessors.java new file mode 100644 index 0000000..f6bdbae --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateAccessors.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPrivateAccessors { + private String instance = "Test String"; + + private String getInstance() { + return instance; + } + + private void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateAccessorsPublicField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateAccessorsPublicField.java new file mode 100644 index 0000000..a37dd10 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateAccessorsPublicField.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPrivateAccessorsPublicField { + public String instance = "Test String"; + + private String getInstance() { + return instance; + } + + private void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateConstructor.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateConstructor.java new file mode 100644 index 0000000..42ddfda --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPrivateConstructor.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPrivateConstructor { + private String instance = "Test String"; + + private StringContainerPrivateConstructor() { + } + + public static StringContainerPrivateConstructor getClassInstance() { + return new StringContainerPrivateConstructor(); + } + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedAccessors.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedAccessors.java new file mode 100644 index 0000000..8f97bf0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedAccessors.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerProtectedAccessors { + private String instance = "Test String"; + + protected String getInstance() { + return instance; + } + + protected void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedConstructor.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedConstructor.java new file mode 100644 index 0000000..8378deb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedConstructor.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerProtectedConstructor { + private String instance = "Test String"; + + protected StringContainerProtectedConstructor() { + } + + public static StringContainerProtectedConstructor getClassInstance() { + return new StringContainerProtectedConstructor(); + } + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedStaticNestedClass.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedStaticNestedClass.java new file mode 100644 index 0000000..2b46d58 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerProtectedStaticNestedClass.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerProtectedStaticNestedClass { + public NestedClass nestedClass = new NestedClass(); + + protected static class NestedClass { + + public NestedClass() { + } + + private String instance = "Test String"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicAccessors.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicAccessors.java new file mode 100644 index 0000000..a4ecde6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicAccessors.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPublicAccessors { + private String instance = "Test String"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicAccessorsPublicField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicAccessorsPublicField.java new file mode 100644 index 0000000..db3ee2a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicAccessorsPublicField.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPublicAccessorsPublicField { + public String instance = "Test String"; + + public String getInstance() { + return "Getter String"; + } + + public void setInstance(String instance) { + this.instance = "Setter String"; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicConstructor.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicConstructor.java new file mode 100644 index 0000000..77f3c5b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicConstructor.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPublicConstructor { + private String instance = "Test String"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicStaticNestedClass.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicStaticNestedClass.java new file mode 100644 index 0000000..5b8e870 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerPublicStaticNestedClass.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerPublicStaticNestedClass { + public NestedClass nestedClass = new NestedClass(); + + public static class NestedClass { + private String instance = "Test String"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerStaticField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerStaticField.java new file mode 100644 index 0000000..4f6d753 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerStaticField.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerStaticField { + private static String instance = "Test String"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + StringContainerStaticField.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerTransientField.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerTransientField.java new file mode 100644 index 0000000..f2f6a8a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/classes/model/StringContainerTransientField.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.classes.model; + +public class StringContainerTransientField { + private transient String instance = "Test String"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/CollectionsMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/CollectionsMappingTest.java new file mode 100644 index 0000000..f8c4cc0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/CollectionsMappingTest.java
@@ -0,0 +1,649 @@ +/* + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections; + +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Deque; +import java.util.EnumMap; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.NavigableMap; +import java.util.NavigableSet; +import java.util.PriorityQueue; +import java.util.Queue; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; +import java.util.regex.Pattern; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.ArrayDequeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.ArrayListContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.CollectionContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.DequeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.EnumMapContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.EnumSetContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.HashSetContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.LinkedHashMapContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.LinkedHashSetContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.LinkedListContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.ListContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.MapContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.NavigableMapContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.NavigableSetContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.PriorityQueueContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.QueueContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.SetContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.SortedMapContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.SortedSetContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.TreeMapContainer; +import ee.jakarta.tck.json.bind.defaultmapping.collections.model.TreeSetContainer; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @test + * @sources CollectionsMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.collections.CollectionsMappingTest + **/ +public class CollectionsMappingTest { + + private static final String COLLECTION_JSON = "{ \"instance\" : [ \"Test 1\", \"Test 2\" ] }"; + private static final String MAP_JSON = "{ \"instance\" : { \"string1\" : \"Test 1\", \"string2\" : \"Test 2\" } }"; + + private static final Pattern COLLECTION_PATTERN = + Pattern.compile("\\{\\s*\"instance\"\\s*:\\s*\\[\\s*\"Test \\d\"\\s*,\\s*\"Test \\d\"\\s*\\]\\s*\\}"); + private static final Pattern MAP_PATTERN = + Pattern.compile("\\{\\s*\"instance\"\\s*:\\s*\\{\\s*\"string1\"\\s*:\\s*\"Test 1\"\\s*," + + "\\s*\"string2\"\\s*:\\s*\"Test 2\"\\s*\\}\\s*\\}"); + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testCollection + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.10-3; + * JSONB:SPEC:JSB-3.11-1; JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that Collection interface is correctly marshalled + * using the runtime type and reports an error when unmarshalling + */ + @Test + public void testCollection() { + String jsonString = assertDoesNotThrow(() -> jsonb.toJson(new CollectionContainer() {{ + setInstance(Arrays.asList("Test 1", "Test 2")); + }}), + "An exception is not expected when marshalling a class with a Collection " + + "attribute."); + + assertThat("Failed to get Collection attribute value.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*\\[\\s*\"Test 1\"\\s*,\\s*\"Test 2\"\\s*\\]\\s*\\}")); + + CollectionContainer unmarshall = assertDoesNotThrow(() -> jsonb.fromJson(COLLECTION_JSON, CollectionContainer.class), + "An exception is not expected when unmarshalling a class with a " + + "Collection attribute."); + + assertThat("Failed to marshal object with Collection attribute.", + unmarshall.getInstance(), contains("Test 1", "Test 2")); + } + + /* + * @testName: testMap + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that Map interface is successfully marshalled and + * unmarshalled + */ + @Test + public void testMap() { + Map<String, String> instance = new HashMap<String, String>() {{ + put("string1", "Test 1"); + put("string2", "Test 2"); + }}; + String jsonString = jsonb.toJson(new MapContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get Map attribute value.", jsonString, matchesPattern(MAP_PATTERN)); + + MapContainer unmarshalledObject = jsonb.fromJson(MAP_JSON, MapContainer.class); + assertThat("Failed to marshal object with Map attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testSet + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that Set interface is successfully marshalled and + * unmarshalled + */ + @Test + public void testSet() { + HashSet<String> instance = new HashSet<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new SetContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get Set attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + SetContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, SetContainer.class); + assertThat("Failed to marshal object with Set attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testHashSet + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that HashSet is successfully marshalled and + * unmarshalled + */ + @Test + public void testHashSet() { + HashSet<String> instance = new HashSet<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new HashSetContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get HashSet attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + HashSetContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, HashSetContainer.class); + assertThat("Failed to marshal object with HashSet attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testNavigableSet + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that NavigableSet is successfully marshalled and + * unmarshalled + */ + @Test + public void testNavigableSet() { + NavigableSet<String> instance = new TreeSet<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new NavigableSetContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get NavigableSet attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + NavigableSetContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, NavigableSetContainer.class); + assertThat("Failed to marshal object with NavigableSet attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testSortedSet + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that SortedSet interface is successfully marshalled + * and unmarshalled + */ + @Test + public void testSortedSet() { + SortedSet<String> instance = new TreeSet<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new SortedSetContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get SortedSet attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + SortedSetContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, SortedSetContainer.class); + assertThat("Failed to marshal object with SortedSet attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testTreeSet + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that TreeSet is successfully marshalled and + * unmarshalled + */ + @Test + public void testTreeSet() { + TreeSet<String> instance = new TreeSet<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new TreeSetContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get TreeSet attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + TreeSetContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, TreeSetContainer.class); + assertThat("Failed to marshal object with TreeSet attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testLinkedHashSet + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that LinkedHashSet is successfully marshalled and + * unmarshalled + */ + @Test + public void testLinkedHashSet() { + LinkedHashSet<String> instance = new LinkedHashSet<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new LinkedHashSetContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get LinkedHashSet attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + LinkedHashSetContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, LinkedHashSetContainer.class); + assertThat("Failed to marshal object with LinkedHashSet attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testHashMap + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that HashMap is successfully marshalled and + * unmarshalled + */ + @Test + public void testHashMap() { + HashMap<String, String> instance = new HashMap<String, String>() {{ + put("string1", "Test 1"); + put("string2", "Test 2"); + }}; + String jsonString = jsonb.toJson(new MapContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get HashMap attribute value.", jsonString, matchesPattern(MAP_PATTERN)); + + MapContainer unmarshalledObject = jsonb.fromJson(MAP_JSON, MapContainer.class); + assertThat("Failed to marshal object with HashMap attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testNavigableMap + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that NavigableMap interface is successfully + * marshalled and unmarshalled + */ + @Test + public void testNavigableMap() { + NavigableMap<String, String> instance = new TreeMap<String, String>() {{ + put("string1", "Test 1"); + put("string2", "Test 2"); + }}; + String jsonString = jsonb.toJson(new NavigableMapContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get NavigableMap attribute value.", jsonString, matchesPattern(MAP_PATTERN)); + + NavigableMapContainer unmarshalledObject = jsonb.fromJson(MAP_JSON, NavigableMapContainer.class); + assertThat("Failed to marshal object with NavigableMap attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testSortedMap + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that SortedMap interface is successfully marshalled + * and unmarshalled + */ + @Test + public void testSortedMap() { + SortedMap<String, String> instance = new TreeMap<String, String>() {{ + put("string1", "Test 1"); + put("string2", "Test 2"); + }}; + String jsonString = jsonb.toJson(new SortedMapContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get SortedMap attribute value.", jsonString, matchesPattern(MAP_PATTERN)); + + SortedMapContainer unmarshalledObject = jsonb.fromJson(MAP_JSON, SortedMapContainer.class); + assertThat("Failed to marshal object with SortedMap attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testTreeMap + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that TreeMap is successfully marshalled and + * unmarshalled + */ + @Test + public void testTreeMap() { + TreeMap<String, String> instance = new TreeMap<String, String>() {{ + put("string1", "Test 1"); + put("string2", "Test 2"); + }}; + String jsonString = jsonb.toJson(new TreeMapContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get TreeMap attribute value.", jsonString, matchesPattern(MAP_PATTERN)); + + TreeMapContainer unmarshalledObject = jsonb.fromJson(MAP_JSON, TreeMapContainer.class); + assertThat("Failed to marshal object with TreeMap attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testLinkedHashMap + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that LinkedHashMap is successfully marshalled and + * unmarshalled + */ + @Test + public void testLinkedHashMap() { + LinkedHashMap<String, String> instance = new LinkedHashMap<String, String>() {{ + put("string1", "Test 1"); + put("string2", "Test 2"); + }}; + String jsonString = jsonb.toJson(new LinkedHashMapContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get LinkedHashMap attribute value.", jsonString, matchesPattern(MAP_PATTERN)); + + LinkedHashMapContainer unmarshalledObject = jsonb.fromJson(MAP_JSON, LinkedHashMapContainer.class); + assertThat("Failed to marshal object with LinkedHashMap attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testList + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that List interface is successfully marshalled and + * unmarshalled + */ + @Test + public void testList() { + List<String> instance = new ArrayList<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new ListContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get List attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + ListContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, ListContainer.class); + assertThat("Failed to marshal object with List attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testArrayList + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that ArrayList is successfully marshalled and + * unmarshalled + */ + @Test + public void testArrayList() { + ArrayList<String> instance = new ArrayList<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new ArrayListContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get ArrayList attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + ArrayListContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, ArrayListContainer.class); + assertThat("Failed to marshal object with ArrayList attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testLinkedList + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that LinkedList is successfully marshalled and + * unmarshalled + */ + @Test + public void testLinkedList() { + LinkedList<String> instance = new LinkedList<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new LinkedListContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get LinkedList attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + LinkedListContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, LinkedListContainer.class); + assertThat("Failed to marshal object with LinkedList attribute.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testDeque + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that Deque interface is successfully marshalled and + * unmarshalled + */ + @Test + public void testDeque() { + Deque<String> instance = new ArrayDeque<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new DequeContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get Deque attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + DequeContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, DequeContainer.class); + assertThat("Failed to marshal object with Deque attribute.", + unmarshalledObject.getInstance(), contains(instance.toArray())); + } + + /* + * @testName: testArrayDeque + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that ArrayDeque is successfully marshalled and + * unmarshalled + */ + @Test + public void testArrayDeque() { + ArrayDeque<String> instance = new ArrayDeque<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new ArrayDequeContainer() {{ + setInstance(instance); + }}); + + assertThat("Failed to get ArrayDeque attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + ArrayDequeContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, ArrayDequeContainer.class); + assertThat("Failed to marshal object with ArrayDeque attribute.", + unmarshalledObject.getInstance(), contains(instance.toArray())); + } + + /* + * @testName: testQueue + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that Queue interface is successfully marshalled and + * unmarshalled + */ + @Test + public void testQueue() { + Queue<String> instance = new LinkedList<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new QueueContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get Queue attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + QueueContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, QueueContainer.class); + assertThat("Failed to marshal object with Queue attribute.", + unmarshalledObject.getInstance(), contains(instance.toArray())); + } + + /* + * @testName: testPriorityQueue + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that PriorityQueue is successfully marshalled and + * unmarshalled + */ + @Test + public void testPriorityQueue() { + PriorityQueue<String> instance = new PriorityQueue<String>() {{ + add("Test 1"); + add("Test 2"); + }}; + String jsonString = jsonb.toJson(new PriorityQueueContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get PriorityQueue attribute value.", jsonString, matchesPattern(COLLECTION_PATTERN)); + + PriorityQueueContainer unmarshalledObject = jsonb.fromJson(COLLECTION_JSON, PriorityQueueContainer.class); + assertThat("Failed to marshal object with PriorityQueue attribute.", + unmarshalledObject.getInstance(), contains(instance.toArray())); + } + + /* + * @testName: testEnumSet + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that EnumSet is successfully marshalled and reports + * an error when unmarshalling + */ + @Test + @Disabled("See: https://github.com/jakartaee/platform-tck/issues/103") + public void testEnumSet() { + EnumSet<EnumSetContainer.Enum> instance = EnumSet.allOf(EnumSetContainer.Enum.class); + String jsonString = jsonb.toJson(new EnumSetContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get EnumSet attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\[\\s*\"ONE\"\\s*,\\s*\"TWO\"\\s*\\]\\s*\\}")); + + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : [ \"ONE\", \"TWO\" ] }", EnumSetContainer.class), + "An exception is expected when unmarshalling a class with an EnumSet attribute."); + } + + /* + * @testName: testEnumMap + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-1; JSONB:SPEC:JSB-3.11-1; + * JSONB:SPEC:JSB-3.11-2 + * + * @test_Strategy: Assert that EnumMap is successfully marshalled and reports + * an error when unmarshalling + */ + @Test + @Disabled("See: https://github.com/jakartaee/platform-tck/issues/103") + public void testEnumMap() { + EnumMap<EnumSetContainer.Enum, String> instance = + new EnumMap<EnumSetContainer.Enum, String>(EnumSetContainer.Enum.class) {{ + put(EnumSetContainer.Enum.ONE, "Test 1"); + put(EnumSetContainer.Enum.TWO, "Test 2"); + }}; + String jsonString = jsonb.toJson(new EnumMapContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to get EnumMap attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\{\\s*\"ONE\"\\s*:\\s*\"Test 1\"\\s*," + + "\\s*\"TWO\"\\s*:\\s*\"Test 2\"\\s*\\}\\s*\\}")); + + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : { \"ONE\" : \"Test 1\", \"TWO\" : \"Test 2\" } }", + EnumSetContainer.class), + "An exception is expected when unmarshalling a class with an EnumMap attribute."); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ArrayDequeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ArrayDequeContainer.java new file mode 100644 index 0000000..6308295 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ArrayDequeContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.ArrayDeque; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class ArrayDequeContainer implements TypeContainer<ArrayDeque<String>> { + private ArrayDeque<String> instance; + + @Override + public ArrayDeque<String> getInstance() { + return instance; + } + + @Override + public void setInstance(ArrayDeque<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ArrayListContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ArrayListContainer.java new file mode 100644 index 0000000..a401e7d --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ArrayListContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.ArrayList; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class ArrayListContainer implements TypeContainer<ArrayList<String>> { + private ArrayList<String> instance; + + @Override + public ArrayList<String> getInstance() { + return instance; + } + + @Override + public void setInstance(ArrayList<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/CollectionContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/CollectionContainer.java new file mode 100644 index 0000000..1b30a49 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/CollectionContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.Collection; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class CollectionContainer implements TypeContainer<Collection<String>> { + private Collection<String> instance; + + @Override + public Collection<String> getInstance() { + return instance; + } + + @Override + public void setInstance(Collection<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/DequeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/DequeContainer.java new file mode 100644 index 0000000..6c43fab --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/DequeContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.Deque; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class DequeContainer implements TypeContainer<Deque<String>> { + private Deque<String> instance; + + @Override + public Deque<String> getInstance() { + return instance; + } + + @Override + public void setInstance(Deque<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/EnumMapContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/EnumMapContainer.java new file mode 100644 index 0000000..1bf8b33 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/EnumMapContainer.java
@@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.EnumMap; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class EnumMapContainer + implements TypeContainer<EnumMap<EnumSetContainer.Enum, String>> { + public enum Enum { + ONE, TWO + } + + private EnumMap<EnumSetContainer.Enum, String> instance; + + @Override + public EnumMap<EnumSetContainer.Enum, String> getInstance() { + return instance; + } + + @Override + public void setInstance(EnumMap<EnumSetContainer.Enum, String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/EnumSetContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/EnumSetContainer.java new file mode 100644 index 0000000..0effe68 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/EnumSetContainer.java
@@ -0,0 +1,44 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.EnumSet; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class EnumSetContainer + implements TypeContainer<EnumSet<EnumSetContainer.Enum>> { + public enum Enum { + ONE, TWO + } + + private EnumSet<Enum> instance; + + @Override + public EnumSet<Enum> getInstance() { + return instance; + } + + @Override + public void setInstance(EnumSet<Enum> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/HashMapContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/HashMapContainer.java new file mode 100644 index 0000000..d1bf0b6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/HashMapContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.HashMap; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class HashMapContainer + implements TypeContainer<HashMap<String, String>> { + private HashMap<String, String> instance; + + @Override + public HashMap<String, String> getInstance() { + return instance; + } + + @Override + public void setInstance(HashMap<String, String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/HashSetContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/HashSetContainer.java new file mode 100644 index 0000000..a645b43 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/HashSetContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.HashSet; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class HashSetContainer implements TypeContainer<HashSet<String>> { + private HashSet<String> instance; + + @Override + public HashSet<String> getInstance() { + return instance; + } + + @Override + public void setInstance(HashSet<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedHashMapContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedHashMapContainer.java new file mode 100644 index 0000000..3a027bf --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedHashMapContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.LinkedHashMap; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LinkedHashMapContainer + implements TypeContainer<LinkedHashMap<String, String>> { + private LinkedHashMap<String, String> instance; + + @Override + public LinkedHashMap<String, String> getInstance() { + return instance; + } + + @Override + public void setInstance(LinkedHashMap<String, String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedHashSetContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedHashSetContainer.java new file mode 100644 index 0000000..1d8939f --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedHashSetContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.LinkedHashSet; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LinkedHashSetContainer + implements TypeContainer<LinkedHashSet<String>> { + private LinkedHashSet<String> instance; + + @Override + public LinkedHashSet<String> getInstance() { + return instance; + } + + @Override + public void setInstance(LinkedHashSet<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedListContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedListContainer.java new file mode 100644 index 0000000..5534ad8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/LinkedListContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.LinkedList; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LinkedListContainer implements TypeContainer<LinkedList<String>> { + private LinkedList<String> instance; + + @Override + public LinkedList<String> getInstance() { + return instance; + } + + @Override + public void setInstance(LinkedList<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ListContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ListContainer.java new file mode 100644 index 0000000..8ea8f19 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/ListContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.List; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class ListContainer implements TypeContainer<List<String>> { + private List<String> instance; + + @Override + public List<String> getInstance() { + return instance; + } + + @Override + public void setInstance(List<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/MapContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/MapContainer.java new file mode 100644 index 0000000..0280f11 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/MapContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.Map; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class MapContainer implements TypeContainer<Map<String, String>> { + private Map<String, String> instance; + + @Override + public Map<String, String> getInstance() { + return instance; + } + + @Override + public void setInstance(Map<String, String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/NavigableMapContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/NavigableMapContainer.java new file mode 100644 index 0000000..d6a48b5 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/NavigableMapContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.NavigableMap; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class NavigableMapContainer + implements TypeContainer<NavigableMap<String, String>> { + private NavigableMap<String, String> instance; + + @Override + public NavigableMap<String, String> getInstance() { + return instance; + } + + @Override + public void setInstance(NavigableMap<String, String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/NavigableSetContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/NavigableSetContainer.java new file mode 100644 index 0000000..f9b6e6d --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/NavigableSetContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.NavigableSet; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class NavigableSetContainer + implements TypeContainer<NavigableSet<String>> { + private NavigableSet<String> instance; + + @Override + public NavigableSet<String> getInstance() { + return instance; + } + + @Override + public void setInstance(NavigableSet<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/PriorityQueueContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/PriorityQueueContainer.java new file mode 100644 index 0000000..83fd0e2 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/PriorityQueueContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.PriorityQueue; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class PriorityQueueContainer + implements TypeContainer<PriorityQueue<String>> { + private PriorityQueue<String> instance; + + @Override + public PriorityQueue<String> getInstance() { + return instance; + } + + @Override + public void setInstance(PriorityQueue<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/QueueContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/QueueContainer.java new file mode 100644 index 0000000..955f856 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/QueueContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.Queue; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class QueueContainer implements TypeContainer<Queue<String>> { + private Queue<String> instance; + + @Override + public Queue<String> getInstance() { + return instance; + } + + @Override + public void setInstance(Queue<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SetContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SetContainer.java new file mode 100644 index 0000000..5a2dc3a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SetContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.Set; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SetContainer implements TypeContainer<Set<String>> { + private Set<String> instance; + + @Override + public Set<String> getInstance() { + return instance; + } + + @Override + public void setInstance(Set<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SortedMapContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SortedMapContainer.java new file mode 100644 index 0000000..d20e9c8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SortedMapContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.SortedMap; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SortedMapContainer + implements TypeContainer<SortedMap<String, String>> { + private SortedMap<String, String> instance; + + @Override + public SortedMap<String, String> getInstance() { + return instance; + } + + @Override + public void setInstance(SortedMap<String, String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SortedSetContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SortedSetContainer.java new file mode 100644 index 0000000..f3f53e6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/SortedSetContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.SortedSet; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SortedSetContainer implements TypeContainer<SortedSet<String>> { + private SortedSet<String> instance; + + @Override + public SortedSet<String> getInstance() { + return instance; + } + + @Override + public void setInstance(SortedSet<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/TreeMapContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/TreeMapContainer.java new file mode 100644 index 0000000..39ce86b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/TreeMapContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.TreeMap; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TreeMapContainer + implements TypeContainer<TreeMap<String, String>> { + private TreeMap<String, String> instance; + + @Override + public TreeMap<String, String> getInstance() { + return instance; + } + + @Override + public void setInstance(TreeMap<String, String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/TreeSetContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/TreeSetContainer.java new file mode 100644 index 0000000..f215ff1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/collections/model/TreeSetContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.collections.model; + +import java.util.TreeSet; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TreeSetContainer implements TypeContainer<TreeSet<String>> { + private TreeSet<String> instance; + + @Override + public TreeSet<String> getInstance() { + return instance; + } + + @Override + public void setInstance(TreeSet<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/DatesMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/DatesMappingTest.java new file mode 100644 index 0000000..d161baa --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/DatesMappingTest.java
@@ -0,0 +1,562 @@ +/* + * Copyright (c) 2017, 2024 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates; + +import java.time.Duration; +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.Month; +import java.time.OffsetDateTime; +import java.time.OffsetTime; +import java.time.Period; +import java.time.ZoneId; +import java.time.ZoneOffset; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.SimpleTimeZone; +import java.util.TimeZone; +import java.util.function.BiPredicate; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.MappingTester; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.CalendarContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.DateContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.DurationContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.GregorianCalendarContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.InstantContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.LocalDateContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.LocalDateTimeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.LocalTimeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.OffsetDateTimeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.OffsetTimeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.PeriodContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.SimpleTimeZoneContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.TimeZoneContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.ZoneIdContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.ZoneOffsetContainer; +import ee.jakarta.tck.json.bind.defaultmapping.dates.model.ZonedDateTimeContainer; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @test + * @sources DatesMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.dates.DatesMappingTest + **/ +public class DatesMappingTest { + + private static final String OFFSET_HOURS = getHoursFromUTCRegExp(new GregorianCalendar(1970, 0, 1)); + + private <T extends TimeZone> BiPredicate<T, T> timezoneTest(final boolean canBeSaving) { + return (a, b) -> { + // Depending on when the timezone is created, it can differ by one hour + // when serialized/deserialized + long diff = Math.abs(a.getRawOffset() - b.getRawOffset()); + return a.useDaylightTime() && canBeSaving + ? diff == 0 || diff == a.getDSTSavings() + : diff == 0; + }; + } + + /* + * @testName: testDate + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; + * + * @test_Strategy: Assert that serializing and deserializing Date result in + * the same value; + */ + @SuppressWarnings("deprecation") + @Test + public void testDate() { + Date date = new Date(70, Calendar.JANUARY, 1); + Jsonb jsonb = JsonbBuilder.create(); + String json = jsonb.toJson(jsonb.fromJson(jsonb.toJson(date), Date.class)); + Date mixin = jsonb.fromJson(json, Date.class); + assertThat("Serializing and deserializing Date results in different value", mixin, is(date)); + } + + /* + * @testName: testDateNoTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5-3; + * JSONB:SPEC:JSB-3.5.1-1; JSONB:SPEC:JSB-3.5.1-3 + * + * @test_Strategy: Assert that Date with no time is still marshalled as and + * unmarshalled from ISO_DATE_TIME + */ + @SuppressWarnings("deprecation") + @Test + public void testDateNoTimeMapping() { + // Date takes time zone from the default timezone which is set by user + // environment + Date date = new Date(70, Calendar.JANUARY, 1); + + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(date); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE_TIME; + String toMatch = dtf.format(calendar.toZonedDateTime()) + .replace("]", "\\]") + .replace("[", "\\[") + .replace("+", "\\+"); + new MappingTester<>(DateContainer.class) // + .setMarshallExpectedRegExp("\"" + toMatch + "\"") + .setUnmarshallTestPredicate((a, b) -> { + Calendar orig = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + orig.clear(); + orig.set(1970, Calendar.JANUARY, 1); + return b.equals(orig.getTime()); + }).test(date, "\"1970-01-01T00:00:00\""); + } + + /* + * @testName: testCalendarNoTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.1-1; + * JSONB:SPEC:JSB-3.5.1-3 + * + * @test_Strategy: Assert that Calendar with no time is marshalled as and + * unmarshalled from ISO_DATE + */ + @Test + public void testCalendarNoTimeMapping() { + Calendar calendarProperty = Calendar.getInstance(); + calendarProperty.clear(); + new MappingTester<>(CalendarContainer.class)// + .setMarshallExpectedRegExp("\"1970-01-01" + OFFSET_HOURS + "\"") // + .setUnmarshallTestPredicate((a, b) -> { + Calendar orig = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + orig.clear(); + orig.set(1970, Calendar.JANUARY, 1); + return b.getTime().equals(orig.getTime()) + && getHoursFromUTC(orig).equals(getHoursFromUTC(b)); + }).test(calendarProperty, "\"1970-01-01\""); + } + + /* + * @testName: testGregorianCalendarNoTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5-2; + * JSONB:SPEC:JSB-3.5.1-1; JSONB:SPEC:JSB-3.5.1-3 + * + * @test_Strategy: Assert that GregorianCalendar with no time is marshalled as + * and unmarshalled from ISO_DATE + */ + @Test + public void testGregorianCalendarNoTimeMapping() { + GregorianCalendar calendar = new GregorianCalendar(1970, Calendar.JANUARY, 1); + for (int i = Calendar.DATE + 1; i != Calendar.MILLISECOND + 1; i++) { + calendar.clear(i); + } + DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE; + String toMatch = "\"" + dtf.format(calendar.toZonedDateTime()).replace("+", "\\+") + "\""; + new MappingTester<>(GregorianCalendarContainer.class) // + .setMarshallExpectedRegExp(toMatch) // + .setUnmarshallTestPredicate((a, b) -> { + Calendar orig = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + orig.clear(); + orig.set(1970, Calendar.JANUARY, 1); + return b.getTime().equals(orig.getTime()) + && getHoursFromUTC(orig).equals(getHoursFromUTC(b)); + }).test(calendar, "\"1970-01-01\""); + } + + /* + * @testName: testDateWithTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5-3; + * JSONB:SPEC:JSB-3.5.1-2; JSONB:SPEC:JSB-3.5.1-3 + * + * @test_Strategy: Assert that Date with time information is marshalled as and + * unmarshalled from ISO_DATE_TIME + */ + @SuppressWarnings("deprecation") + @Test + public void testDateWithTimeMapping() { + Date date = new Date(70, Calendar.JANUARY, 1, 0, 0, 0); + GregorianCalendar calendar = new GregorianCalendar(); + calendar.setTime(date); + calendar.setTimeZone(TimeZone.getTimeZone("UTC")); + DateTimeFormatter dtf = DateTimeFormatter.ISO_DATE_TIME; + String toMatch = dtf.format(calendar.toZonedDateTime()) + .replace("]", "\\]") + .replace("[", "\\["); + new MappingTester<>(DateContainer.class) // + .setMarshallExpectedRegExp("\"" + toMatch + "\"") + .setUnmarshallTestPredicate((a, b) -> { + Calendar orig = new GregorianCalendar(TimeZone.getTimeZone("UTC")); + orig.clear(); + orig.set(1970, Calendar.JANUARY, 1); + return b.equals(orig.getTime()); + }).test(date, "\"1970-01-01T00:00:00\""); + } + + /* + * @testName: testCalendarWithTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.1-2; + * JSONB:SPEC:JSB-3.5.1-3 + * + * @test_Strategy: Assert that Calendar with time information is marshalled as + * and unmarshalled from ISO_DATE_TIME + */ + @Test + public void testCalendarWithTimeMapping() { + Calendar calendarProperty = Calendar.getInstance(); + calendarProperty.set(1970, Calendar.JANUARY, 1, 1, 0, 0); + calendarProperty.set(Calendar.MILLISECOND, 0); + calendarProperty.setTimeZone(TimeZone.getTimeZone("Europe/Paris")); + new MappingTester<>(CalendarContainer.class) + .setMarshallExpectedRegExp( + "\"1970-01-01T01:00:00(\\.\\d{1,3})?\\+01:00\\[Europe/Paris\\]\"") + .setUnmarshallTestPredicate((a, b) -> { + return a.getTime().equals(b.getTime()) + && getHoursFromUTC(calendarProperty).equals(getHoursFromUTC(b)); + }).test(calendarProperty, + "\"1970-01-01T01:00:00.00+01:00[Europe/Paris]\""); + } + + /* + * @testName: testGregorianCalendarWithTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5-2; + * JSONB:SPEC:JSB-3.5.1-2; JSONB:SPEC:JSB-3.5.1-3 + * + * @test_Strategy: Assert that GregorianCalendar with time information is + * marshalled as and unmarshalled from ISO_DATE_TIME + */ + @Test + @Disabled("See: https://github.com/jakartaee/platform-tck/issues/102") + public void testGregorianCalendarWithTimeMapping() { + GregorianCalendar calendar = GregorianCalendar.from( + ZonedDateTime.of(LocalDateTime.of(1970, Month.FEBRUARY, 1, 1, 0, 0), + ZoneId.of("GMT"))); + new MappingTester<>(GregorianCalendarContainer.class).test(calendar, + "\"1970-01-01T01:00:00Z[GMT]\""); + } + + /* + * @testName: testShortTimeZoneMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.2-1; + * JSONB:SPEC:JSB-3.5.2-3 + * + * @test_Strategy: Assert that java.util.TimeZone is correctly handled + */ + @Test + public void testShortTimeZoneMapping() { + new MappingTester<>(TimeZoneContainer.class) // + .setUnmarshallTestPredicate(timezoneTest(false)) // + .test(TimeZone.getTimeZone("GMT+10"), "\"GMT+10:00\""); + } + + /* + * @testName: testLongTimeZoneMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.2-1; + * JSONB:SPEC:JSB-3.5.2-3 + * + * @test_Strategy: Assert that java.util.TimeZone is correctly handled + */ + @Test + public void testLongTimeZoneMapping() { + new MappingTester<>(TimeZoneContainer.class) // + .setUnmarshallTestPredicate(timezoneTest(true)) // + .test(TimeZone.getTimeZone("America/Los_Angeles"), + "\"America/Los_Angeles\""); + } + + /* + * @testName: testSimpleTimeZoneMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.2-1; + * JSONB:SPEC:JSB-3.5.2-3 + * + * @test_Strategy: Assert that java.util.SimpleTimeZone is correctly handled + */ + @Test + public void testSimpleTimeZoneMapping() { + new MappingTester<>(SimpleTimeZoneContainer.class) // + .setUnmarshallTestPredicate(timezoneTest(false)) // + .test(new SimpleTimeZone(75 * 60 * 1000, "GMT+01:15"), "\"GMT+01:15\""); + } + + /* + * @testName: testInstantMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-1; + * JSONB:SPEC:JSB-3.5.3-2; JSONB:SPEC:JSB-3.5.3-3 + * + * @test_Strategy: Assert that java.time.Instant is correctly marshalled as + * and unmarshalled from ISO_INSTANT + */ + @Test + public void testInstantMapping() { + new MappingTester<>(InstantContainer.class) + .test(Instant.ofEpochMilli(0), "\"1970-01-01T00:00:00Z\""); + } + + /* + * @testName: testDurationMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-8 + * + * @test_Strategy: Assert that Duration is correctly marshalled as and + * umarshalled from ISO 8601 seconds based representation + */ + @Test + public void testDurationMapping() { + new MappingTester<>(DurationContainer.class) + .test(Duration.ofHours(1), "\"PT1H\""); + } + + /* + * @testName: testDurationWithSecondsMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-8; + * JSONB:SPEC:JSB-3.5.3-9 + * + * @test_Strategy: Assert that Duration is correctly marshalled as and + * umarshalled from ISO 8601 seconds based representation + */ + @Test + public void testDurationWithSecondsMapping() { + new MappingTester<>(DurationContainer.class) + .test(Duration.ofHours(1).plus(Duration.ofSeconds(1)), "\"PT1H1S\""); + } + + /* + * @testName: testPeriodMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-10; + * JSONB:SPEC:JSB-3.5.3-11 + * + * @test_Strategy: Assert that Period is correctly marshalled as and + * umarshalled from ISO 8601 period representation + */ + @Test + public void testPeriodMapping() { + new MappingTester<>(PeriodContainer.class).test(Period.of(1, Calendar.FEBRUARY, 1), + "\"P1Y1M1D\""); + } + + /* + * @testName: testZeroDaysPeriodMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-10; + * JSONB:SPEC:JSB-3.5.3-11; JSONB:SPEC:JSB-3.5.3-12 + * + * @test_Strategy: Assert that a zero length Period is correctly marshalled as + * and umarshalled from "P0D" + */ + @Test + public void testZeroDaysPeriodMapping() { + new MappingTester<>(PeriodContainer.class).test(Period.of(0, 0, 0), + "\"P0D\""); + } + + /* + * @testName: testLocalDateMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-3 + * + * @test_Strategy: Assert that java.time.LocalDate is correctly marshalled as + * and umarshalled from ISO_LOCAL_DATE + */ + @Test + public void testLocalDateMapping() { + new MappingTester<>(LocalDateContainer.class) + .test(LocalDate.of(2000, Calendar.FEBRUARY, 1), "\"2000-01-01\""); + } + + /* + * @testName: testLocalTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-3 + * + * @test_Strategy: Assert that java.time.LocalTime is correctly marshalled as + * and umarshalled from ISO_LOCAL_TIME + */ + @Test + public void testLocalTimeMapping() { + new MappingTester<>(LocalTimeContainer.class) + .test(LocalTime.of(1, 1, 1), "\"01:01:01\""); + } + + /* + * @testName: testLocalDateTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-3 + * + * @test_Strategy: Assert that java.time.LocalDateTime is correctly marshalled + * as and umarshalled from ISO_LOCAL_DATE_TIME + */ + @Test + public void testLocalDateTimeMapping() { + new MappingTester<>(LocalDateTimeContainer.class) + .test(LocalDateTime.of(2000, Calendar.FEBRUARY, 1, 1, 1, 1), "\"2000-01-01T01:01:01\""); + } + + /* + * @testName: testZonedDateTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-3 + * + * @test_Strategy: Assert that java.time.ZonedDateTime is correctly marshalled + * as and umarshalled from ISO_ZONED_DATE_TIME + */ + @Test + public void testZonedDateTimeMapping() { + new MappingTester<>(ZonedDateTimeContainer.class).test( + ZonedDateTime.of(2000, Calendar.FEBRUARY, 1, 1, 1, 1, 0, + ZoneId.of("Europe/Paris")), + "\"2000-01-01T01:01:01+01:00[Europe/Paris]\""); + } + + /* + * @testName: testZoneIdMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-4; + * JSONB:SPEC:JSB-3.5.3-5 + * + * @test_Strategy: Assert that java.time.ZoneId is correctly handled + */ + @Test + public void testZoneIdMapping() { + new MappingTester<>(ZoneIdContainer.class).test(ZoneId.of("UTC"), + "\"UTC\""); + } + + /* + * @testName: testZoneOffsetMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-6; + * JSONB:SPEC:JSB-3.5.3-7 + * + * @test_Strategy: Assert that java.time.ZoneOffset is correctly handled + */ + @Test + public void testZoneOffsetMapping() { + new MappingTester<>(ZoneOffsetContainer.class) + .test(ZoneOffset.of("+01:00"), "\"+01:00\""); + } + + /* + * @testName: testOffsetDateTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-3 + * + * @test_Strategy: Assert that java.time.OffsetDateTime is correctly + * marshalled as and umarshalled from ISO_OFFSET_DATE_TIME + */ + @Test + public void testOffsetDateTimeMapping() { + new MappingTester<>(OffsetDateTimeContainer.class) + .test(OffsetDateTime.of(LocalDateTime.of(2000, Calendar.FEBRUARY, 1, 1, 1, 1), + ZoneOffset.of("+01:00")), "\"2000-01-01T01:01:01+01:00\""); + } + + /* + * @testName: testOffsetTimeMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-1; JSONB:SPEC:JSB-3.5.3-3 + * + * @test_Strategy: Assert that java.time.OffsetTime is correctly marshalled as + * and umarshalled from ISO_OFFSET_TIME + */ + @Test + public void testOffsetTimeMapping() { + new MappingTester<>(OffsetTimeContainer.class).test( + OffsetTime.of(LocalTime.of(1, 1, 1), ZoneOffset.of("+01:00")), + "\"01:01:01+01:00\""); + } + + /* + * @testName: testUnmarshallingUnknownFormat + * + * @assertion_ids: JSONB:SPEC:JSB-3.5-4 + * + * @test_Strategy: Assert that an error is reported if the date/time string + * does not correspond to the expected datetime format + */ + @Test + public void testUnmarshallingUnknownFormat() { + assertThrows(JsonbException.class, + () -> JsonbBuilder.create().fromJson("{ \"instance\" : \"01/01/1970 00:00:00\" }", DateContainer.class), + "An exception is expected if the date/time string does not correspond to the expected datetime format."); + } + + /* + * @testName: testUnmarshallingDeprecatedTimezoneIds + * + * @assertion_ids: JSONB:SPEC:JSB-3.5.2-2 + * + * @test_Strategy: Assert that error is reported for deprecated three-letter + * time zone IDs as specified in java.util.Timezone + */ + @Test + public void testUnmarshallingDeprecatedTimezoneIds() { + Jsonb jsonb = JsonbBuilder.create(); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"CST\" }", TimeZoneContainer.class), + "An exception is expected for deprecated three-letter time zone IDs."); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"CST\" }", SimpleTimeZoneContainer.class), + "An exception is expected for deprecated three-letter time zone IDs."); + } + + private static String getHoursFromUTCRegExp(Calendar calendar) { + String hours = getHoursFromUTC(calendar); + if ("+00:00".equals(hours)) { + return "(Z|\\+00:00)"; + } else { + return "\\" + hours; + } + } + + private static String getHoursFromUTC(Calendar calendar) { + int offsetInTenMins = getMinutesFromUTC(calendar); + String offset = String.format("%s%02d:%02d", + offsetInTenMins >= 0 ? "+" : "-", Math.abs(offsetInTenMins / 60), + Math.abs((offsetInTenMins) % 60)); + return offset; + } + + private static int getMinutesFromUTC(Calendar calendar) { + TimeZone tz = TimeZone.getDefault(); + Calendar def = (Calendar) calendar.clone(); + def.get(Calendar.HOUR); // setFields + return tz.getOffset(def.getTimeInMillis()) / 60000; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/CalendarContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/CalendarContainer.java new file mode 100644 index 0000000..3be86a6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/CalendarContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.util.Calendar; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class CalendarContainer implements TypeContainer<Calendar> { + private Calendar instance; + + @Override + public Calendar getInstance() { + return instance; + } + + @Override + public void setInstance(Calendar instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/DateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/DateContainer.java new file mode 100644 index 0000000..1ba7853 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/DateContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.util.Date; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class DateContainer implements TypeContainer<Date> { + private Date instance; + + @Override + public Date getInstance() { + return instance; + } + + @Override + public void setInstance(Date instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/DurationContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/DurationContainer.java new file mode 100644 index 0000000..14d38e9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/DurationContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.Duration; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class DurationContainer implements TypeContainer<Duration> { + private Duration instance; + + @Override + public Duration getInstance() { + return instance; + } + + @Override + public void setInstance(Duration instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/GregorianCalendarContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/GregorianCalendarContainer.java new file mode 100644 index 0000000..d6ab5a4 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/GregorianCalendarContainer.java
@@ -0,0 +1,40 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.util.GregorianCalendar; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class GregorianCalendarContainer + implements TypeContainer<GregorianCalendar> { + private GregorianCalendar instance; + + @Override + public GregorianCalendar getInstance() { + return instance; + } + + @Override + public void setInstance(GregorianCalendar instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/InstantContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/InstantContainer.java new file mode 100644 index 0000000..0f29061 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/InstantContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.Instant; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class InstantContainer implements TypeContainer<Instant> { + private Instant instance; + + @Override + public Instant getInstance() { + return instance; + } + + @Override + public void setInstance(Instant instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalDateContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalDateContainer.java new file mode 100644 index 0000000..6228cbb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalDateContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.LocalDate; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LocalDateContainer implements TypeContainer<LocalDate> { + private LocalDate instance; + + @Override + public LocalDate getInstance() { + return instance; + } + + @Override + public void setInstance(LocalDate instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalDateTimeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalDateTimeContainer.java new file mode 100644 index 0000000..eb76439 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalDateTimeContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.LocalDateTime; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LocalDateTimeContainer implements TypeContainer<LocalDateTime> { + private LocalDateTime instance; + + @Override + public LocalDateTime getInstance() { + return instance; + } + + @Override + public void setInstance(LocalDateTime instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalTimeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalTimeContainer.java new file mode 100644 index 0000000..f76ef7b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/LocalTimeContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.LocalTime; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class LocalTimeContainer implements TypeContainer<LocalTime> { + private LocalTime instance; + + @Override + public LocalTime getInstance() { + return instance; + } + + @Override + public void setInstance(LocalTime instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/OffsetDateTimeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/OffsetDateTimeContainer.java new file mode 100644 index 0000000..0cf2f0a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/OffsetDateTimeContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.OffsetDateTime; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class OffsetDateTimeContainer implements TypeContainer<OffsetDateTime> { + private OffsetDateTime instance; + + @Override + public OffsetDateTime getInstance() { + return instance; + } + + @Override + public void setInstance(OffsetDateTime instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/OffsetTimeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/OffsetTimeContainer.java new file mode 100644 index 0000000..f838759 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/OffsetTimeContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.OffsetTime; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class OffsetTimeContainer implements TypeContainer<OffsetTime> { + private OffsetTime instance; + + @Override + public OffsetTime getInstance() { + return instance; + } + + @Override + public void setInstance(OffsetTime instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/PeriodContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/PeriodContainer.java new file mode 100644 index 0000000..49c35b1 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/PeriodContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.Period; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class PeriodContainer implements TypeContainer<Period> { + private Period instance; + + @Override + public Period getInstance() { + return instance; + } + + @Override + public void setInstance(Period instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/SimpleTimeZoneContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/SimpleTimeZoneContainer.java new file mode 100644 index 0000000..77aa850 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/SimpleTimeZoneContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.util.SimpleTimeZone; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class SimpleTimeZoneContainer implements TypeContainer<SimpleTimeZone> { + private SimpleTimeZone instance; + + @Override + public SimpleTimeZone getInstance() { + return instance; + } + + @Override + public void setInstance(SimpleTimeZone instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/TimeZoneContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/TimeZoneContainer.java new file mode 100644 index 0000000..ee6fa0b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/TimeZoneContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.util.TimeZone; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class TimeZoneContainer implements TypeContainer<TimeZone> { + private TimeZone instance; + + @Override + public TimeZone getInstance() { + return instance; + } + + @Override + public void setInstance(TimeZone instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZoneIdContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZoneIdContainer.java new file mode 100644 index 0000000..90c3414 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZoneIdContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.ZoneId; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class ZoneIdContainer implements TypeContainer<ZoneId> { + private ZoneId instance; + + @Override + public ZoneId getInstance() { + return instance; + } + + @Override + public void setInstance(ZoneId instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZoneOffsetContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZoneOffsetContainer.java new file mode 100644 index 0000000..908dba9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZoneOffsetContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.ZoneOffset; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class ZoneOffsetContainer implements TypeContainer<ZoneOffset> { + private ZoneOffset instance; + + @Override + public ZoneOffset getInstance() { + return instance; + } + + @Override + public void setInstance(ZoneOffset instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZonedDateTimeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZonedDateTimeContainer.java new file mode 100644 index 0000000..5bf38c0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/dates/model/ZonedDateTimeContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.dates.model; + +import java.time.ZonedDateTime; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class ZonedDateTimeContainer implements TypeContainer<ZonedDateTime> { + private ZonedDateTime instance; + + @Override + public ZonedDateTime getInstance() { + return instance; + } + + @Override + public void setInstance(ZonedDateTime instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/enums/EnumMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/enums/EnumMappingTest.java new file mode 100644 index 0000000..b0790bf --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/enums/EnumMappingTest.java
@@ -0,0 +1,48 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.enums; + +import ee.jakarta.tck.json.bind.defaultmapping.enums.model.EnumContainer; +import ee.jakarta.tck.json.bind.MappingTester; +import org.junit.jupiter.api.Test; + +/** + * @test + * @sources EnumMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.enums.EnumMappingTest + **/ +public class EnumMappingTest { + + /* + * @testName: testEnum + * + * @assertion_ids: JSONB:SPEC:JSB-3.9-1; JSONB:SPEC:JSB-3.9-2 + * + * @test_Strategy: Assert that enum is correctly handled + */ + @Test + public void testEnum() { + MappingTester<EnumContainer.Enumeration> enumMappingTester = new MappingTester<>( + EnumContainer.class); + enumMappingTester.test(EnumContainer.Enumeration.ONE, "\"ONE\""); + enumMappingTester.test(EnumContainer.Enumeration.TWO, "\"TWO\""); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/enums/model/EnumContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/enums/model/EnumContainer.java new file mode 100644 index 0000000..3e40780 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/enums/model/EnumContainer.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.enums.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class EnumContainer implements TypeContainer<EnumContainer.Enumeration> { + public enum Enumeration { + ONE, TWO + } + + private Enumeration instance = Enumeration.ONE; + + @Override + public Enumeration getInstance() { + return instance; + } + + @Override + public void setInstance(Enumeration instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/GenericsMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/GenericsMappingTest.java new file mode 100644 index 0000000..89857dd --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/GenericsMappingTest.java
@@ -0,0 +1,225 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.generics; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.defaultmapping.generics.model.CollectionContainer; +import ee.jakarta.tck.json.bind.defaultmapping.generics.model.GenericContainer; +import ee.jakarta.tck.json.bind.defaultmapping.generics.model.MultipleBoundsContainer; +import ee.jakarta.tck.json.bind.defaultmapping.generics.model.NumberContainer; +import ee.jakarta.tck.json.bind.defaultmapping.generics.model.StringContainer; +import ee.jakarta.tck.json.bind.defaultmapping.generics.model.WildcardContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.hasEntry; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources GenericsMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.generics.GenericsMappingTest + **/ +public class GenericsMappingTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testClassInformationOnRuntime + * + * @assertion_ids: JSONB:SPEC:JSB-3.17-1; JSONB:SPEC:JSB-3.17-3; + * JSONB:SPEC:JSB-3.17.1-1; JSONB:SPEC:JSB-3.17.1-15 + * + * @test_Strategy: Assert that passing Type information on runtime is handled + * as expected + */ + @Test + public void testClassInformationOnRuntime() { + String jsonString = jsonb.toJson(new GenericContainer<String>() {{ + setInstance("Test String"); + }}); + assertThat("Failed to marshal generic object with String attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + Type runtimeType = new GenericContainer<String>() { }.getClass().getGenericSuperclass(); + GenericContainer<String> unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"Test String\" }", runtimeType); + assertThat("Failed to unmarshal generic object with String attribute value.", + unmarshalledObject.getInstance(), is("Test String")); + } + + /* + * @testName: testClassFileAvailable + * + * @assertion_ids: JSONB:SPEC:JSB-3.17-1; JSONB:SPEC:JSB-3.17-2; + * JSONB:SPEC:JSB-3.17.1-1; JSONB:SPEC:JSB-3.17.1-5; JSONB:SPEC:JSB-3.17.1-6 + * + * @test_Strategy: Assert that static type information is handled as expected + */ + @Test + public void testClassFileAvailable() { + String jsonString = jsonb.toJson(new GenericContainer<String>() {{ + setInstance("Test String"); + }}); + assertThat("Failed to marshal generic object with String attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + GenericContainer<String> unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"Test String\" }", StringContainer.class); + assertThat("Failed to unmarshal generic object with String attribute value.", + unmarshalledObject.getInstance(), is("Test String")); + } + + /* + * @testName: testRawTypeInformation + * + * @assertion_ids: JSONB:SPEC:JSB-3.17-1; JSONB:SPEC:JSB-3.17.1-1; + * JSONB:SPEC:JSB-3.17.1-3; JSONB:SPEC:JSB-3.17.1-4; JSONB:SPEC:JSB-3.17.1-8 + * + * @test_Strategy: Assert that raw type information is handled as expected + */ + @Test + public void testRawTypeInformation() { + final List<String> list = Arrays.asList("Test 1", "Test 2"); + String jsonString = jsonb.toJson(new CollectionContainer() {{ + setInstance(list); + }}); + assertThat("Failed to marshal object with raw List attribute.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*\\[\\s*\"Test 1\"\\s*,\\s*\"Test 2\"\\s*\\]\\s*\\}")); + + CollectionContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : [ \"Test 1\", \"Test 2\" ] }", + CollectionContainer.class); + assertThat("Failed to unmarshal object with raw List type attribute.", + unmarshalledObject.getInstance(), is(list)); + } + + /* + * @testName: testNoTypeInformation + * + * @assertion_ids: JSONB:SPEC:JSB-3.17-1; JSONB:SPEC:JSB-3.17.1-1; + * JSONB:SPEC:JSB-3.17.1-2; JSONB:SPEC:JSB-3.17.1-9; JSONB:SPEC:JSB-3.17.1-14 + * + * @test_Strategy: Assert that if no type information is provided, type is + * treated as java.lang.Object + */ + @SuppressWarnings("unchecked") + @Test + public void testNoTypeInformation() { + String jsonString = jsonb.toJson(new GenericContainer<String>() {{ + setInstance("Test String"); + }}); + assertThat("Failed to marshal generic object with String attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*\"Test String\"\\s*\\}")); + + GenericContainer<?> unmarshalledObject = jsonb.fromJson("{ \"instance\" : {\"value\":\"Test String\" } }", + GenericContainer.class); + String validationMessage = "Failed to unmarshal generic object without type information with String attribute value."; + Object evaluatedInstance = unmarshalledObject.getInstance(); + assertThat(validationMessage, evaluatedInstance, instanceOf(Map.class)); + Map<String, Object> map = (Map<String, Object>) evaluatedInstance; + assertThat(validationMessage, map.size(), is(1)); + assertThat(validationMessage, map, hasEntry("value", "Test String")); + } + + /* + * @testName: testBoundedTypeInformation + * + * @assertion_ids: JSONB:SPEC:JSB-3.17-1; JSONB:SPEC:JSB-3.17.1-5; + * JSONB:SPEC:JSB-3.17.1-7 + * + * @test_Strategy: Assert that bounded type information is treated as expected + */ + @Test + public void testBoundedTypeInformation() { + String jsonString = jsonb.toJson(new NumberContainer<Integer>() {{ + setInstance(Integer.MAX_VALUE); + }}); + assertThat("Failed to marshal object with bounded Number attribute.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*" + Integer.MAX_VALUE + "\\s*\\}")); + Type runtimeType = new NumberContainer<Integer>() { }.getClass().getGenericSuperclass(); + NumberContainer<Integer> unmarshalledObject = jsonb.fromJson("{ \"instance\" : " + Integer.MAX_VALUE + " }", runtimeType); + assertThat("Failed to unmarshal object with bounded Number attribute.", + unmarshalledObject.getInstance(), is(Integer.MAX_VALUE)); + } + + /* + * @testName: testMultipleBoundsTypeInformation + * + * @assertion_ids: JSONB:SPEC:JSB-3.17-1; JSONB:SPEC:JSB-3.17.1-5; + * JSONB:SPEC:JSB-3.17.1-7; JSONB:SPEC:JSB-3.17.1-10; + * JSONB:SPEC:JSB-3.17.1-11; JSONB:SPEC:JSB-3.17.1-12 + * + * @test_Strategy: Assert that when multiple bounds exist, the most specific + * type is used + */ + @Test + public void testMultipleBoundsTypeInformation() { + final LinkedList<String> list = new LinkedList<>(Arrays.asList("Test 1", "Test 2")); + MultipleBoundsContainer<LinkedList<String>> container = new MultipleBoundsContainer<>(); + container.setInstance(new ArrayList<>()); + container.getInstance().add(list); + + final Type type = new MultipleBoundsContainer<LinkedList<String>>() { }.getClass().getGenericSuperclass(); + String jsonString = jsonb.toJson(container, type); + assertThat("Failed to marshal object with multiple bounded attribute.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*\\[\\[\\s*\"Test 1\"\\s*,\\s*\"Test 2\"\\s*\\]\\]\\s*\\}")); + + String toDeserialize = "{ \"instance\" : [[ \"Test 1\", \"Test 2\" ]] }"; + MultipleBoundsContainer<LinkedList<String>> unmarshalledObject = jsonb.fromJson(toDeserialize, type); + assertThat("Failed to unmarshal object with multiple bounded attribute.", + unmarshalledObject.getInstance(), is(container.getInstance())); + } + + /* + * @testName: testWildcardTypeInformation + * + * @assertion_ids: JSONB:SPEC:JSB-3.17-1; JSONB:SPEC:JSB-3.17.1-5; + * JSONB:SPEC:JSB-3.17.1-13 + * + * @test_Strategy: Assert that wildcard type is handled as java.lang.Object + */ + @Test + public void testWildcardTypeInformation() { + final List<String> list = Arrays.asList("Test 1", "Test 2"); + String jsonString = jsonb.toJson(new WildcardContainer() {{ + setInstance(list); + }}); + assertThat("Failed to marshal object with unbound collection attribute.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*\\:\\s*\\[\\s*\"Test 1\"\\s*,\\s*\"Test 2\"\\s*\\]\\s*\\}")); + + WildcardContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : [ \"Test 1\", \"Test 2\" ] }", + WildcardContainer.class); + assertThat("Failed to unmarshal object with unbound collection attribute.", + unmarshalledObject.getInstance(), is(list)); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/CollectionContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/CollectionContainer.java new file mode 100644 index 0000000..0edd772 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/CollectionContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.generics.model; + +import java.util.List; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class CollectionContainer implements TypeContainer<List> { + protected List instance; + + @Override + public List getInstance() { + return instance; + } + + @Override + public void setInstance(List instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/GenericContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/GenericContainer.java new file mode 100644 index 0000000..10c61dd --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/GenericContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.generics.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class GenericContainer<T> implements TypeContainer<T> { + protected T instance; + + @Override + public T getInstance() { + return instance; + } + + @Override + public void setInstance(T instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/MultipleBoundsContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/MultipleBoundsContainer.java new file mode 100644 index 0000000..aedf677 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/MultipleBoundsContainer.java
@@ -0,0 +1,41 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.generics.model; + +import java.util.List; +import java.util.Queue; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class MultipleBoundsContainer<T extends List & Queue> + implements TypeContainer<List<T>> { + protected List<T> instance; + + @Override + public List<T> getInstance() { + return instance; + } + + @Override + public void setInstance(List<T> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/NumberContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/NumberContainer.java new file mode 100644 index 0000000..9540052 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/NumberContainer.java
@@ -0,0 +1,35 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.generics.model; + +public class NumberContainer<T extends Number> extends GenericContainer<T> { + protected T instance; + + @Override + public T getInstance() { + return instance; + } + + @Override + public void setInstance(T instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/StringContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/StringContainer.java new file mode 100644 index 0000000..7bc29c9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/StringContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.generics.model; + +public class StringContainer extends GenericContainer<String> { + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/WildcardContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/WildcardContainer.java new file mode 100644 index 0000000..94ea2e9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/generics/model/WildcardContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.generics.model; + +import java.util.List; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class WildcardContainer implements TypeContainer<List<?>> { + protected List<?> instance; + + @Override + public List<?> getInstance() { + return instance; + } + + @Override + public void setInstance(List<?> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/identifiers/NamesAndIdentifiersMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/identifiers/NamesAndIdentifiersMappingTest.java new file mode 100644 index 0000000..c6d2404 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/identifiers/NamesAndIdentifiersMappingTest.java
@@ -0,0 +1,72 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.identifiers; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbConfig; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.MappingTester; +import ee.jakarta.tck.json.bind.defaultmapping.identifiers.model.StringContainer; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @test + * @sources NamesAndIdentifiersMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.identifiers.NamesAndIdentifiersMappingTest + **/ +public class NamesAndIdentifiersMappingTest { + + /* + * @testName: testSimpleMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.15-1; JSONB:SPEC:JSB-3.15-2; + * JSONB:SPEC:JSB-3.15-3 + * + * @test_Strategy: Assert that java field name can be correctly mapped to json + * identifier and vice versa + */ + @Test + public void testSimpleMapping() { + new MappingTester<>(StringContainer.class).test("Test String", "\"Test String\""); + } + + /* + * @testName: + * testSimpleMappingNoCorrespondingIdentifierWithFailOnUnknownProperties + * + * @assertion_ids: JSONB:SPEC:JSB-3.15-4 + * + * @test_Strategy: Assert that error is reported if a Java identifier with + * corresponding name as in json document cannot be found or is not accessible + */ + @Test + public void testSimpleMappingNoCorrespondingIdentifierWithFailOnUnknownProperties() { + Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().setProperty("jsonb.fail-on-unknown-properties", true)); + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"data\" : \"Test String\" }", StringContainer.class), + "A JsonbException is expected if a Java identifier with corresponding name as in json " + + "document cannot be found."); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/identifiers/model/StringContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/identifiers/model/StringContainer.java new file mode 100644 index 0000000..8351247 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/identifiers/model/StringContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.identifiers.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class StringContainer implements TypeContainer<String> { + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/ignore/MustIgnoreMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/ignore/MustIgnoreMappingTest.java new file mode 100644 index 0000000..35d1607 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/ignore/MustIgnoreMappingTest.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.ignore; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.defaultmapping.ignore.model.StringContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; + +/** + * @test + * @sources MustIgnoreMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.ignore.MustIgnoreMappingTest + **/ +public class MustIgnoreMappingTest { + + /* + * @testName: testIgnoreUnknownAttribute + * + * @assertion_ids: JSONB:SPEC:JSB-3.18-1 + * + * @test_Strategy: Assert that unknown attributes are ignored during + * unmarshalling + */ + @Test + public void testIgnoreUnknownAttribute() { + Jsonb jsonb = JsonbBuilder.create(); + String toDeserialize = "{ \"instance\" : \"Test String\", \"newInstance\" : 0 }"; + StringContainer container = assertDoesNotThrow(() -> jsonb.fromJson(toDeserialize, StringContainer.class), + "An exception is not expected when coming across " + + "a non existent attribute during deserialization."); + + assertThat("Failed to deserialize into a class with less attributes than exist in the JSON string.", + container.getInstance(), is("Test String")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/ignore/model/StringContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/ignore/model/StringContainer.java new file mode 100644 index 0000000..d01c6ad --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/ignore/model/StringContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.ignore.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class StringContainer implements TypeContainer<String> { + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/InterfaceMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/InterfaceMappingTest.java new file mode 100644 index 0000000..97c0fc6 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/InterfaceMappingTest.java
@@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.interfaces; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.TypeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.interfaces.model.InterfaceContainer; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @test + * @sources InterfaceMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.interfaces.InterfaceMappingTest + **/ +public class InterfaceMappingTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testDeserializationToInterface + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-2 + * + * @test_Strategy: Assert that an error is reported when unmarshalling to an + * arbitrary interface + */ + @Test + public void testDeserializationToInterface() { + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : \"Test String\" }", TypeContainer.class), + "An exception is expected when unmarshalling a class to an interface."); + } + + /* + * @testName: testInterfaceField + * + * @assertion_ids: JSONB:SPEC:JSB-3.10-2 + * + * @test_Strategy: Assert that an error is reported when unmarshalling to an + * arbitrary interface + */ + @Test + public void testInterfaceField() { + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{ \"instance\" : { \"instance\" : \"Test String\" } }", InterfaceContainer.class), + "An exception is expected when unmarshalling a class with an interface property."); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/model/InterfaceContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/model/InterfaceContainer.java new file mode 100644 index 0000000..89c4c5e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/model/InterfaceContainer.java
@@ -0,0 +1,38 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.interfaces.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class InterfaceContainer + implements TypeContainer<TypeContainer<String>> { + private TypeContainer<String> instance; + + @Override + public TypeContainer<String> getInstance() { + return instance; + } + + @Override + public void setInstance(TypeContainer<String> instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/model/StringContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/model/StringContainer.java new file mode 100644 index 0000000..52f0752 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/interfaces/model/StringContainer.java
@@ -0,0 +1,37 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.interfaces.model; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class StringContainer implements TypeContainer<String> { + private String instance; + + @Override + public String getInstance() { + return instance; + } + + @Override + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/JSONPTypesMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/JSONPTypesMappingTest.java new file mode 100644 index 0000000..c7eeccc --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/JSONPTypesMappingTest.java
@@ -0,0 +1,359 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.jsonptypes; + +import jakarta.json.Json; +import jakarta.json.JsonArray; +import jakarta.json.JsonNumber; +import jakarta.json.JsonObject; +import jakarta.json.JsonString; +import jakarta.json.JsonStructure; +import jakarta.json.JsonValue; +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model.JsonArrayContainer; +import ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model.JsonNumberContainer; +import ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model.JsonObjectContainer; +import ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model.JsonStringContainer; +import ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model.JsonStructureContainer; +import ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model.JsonValueContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.nullValue; + +/** + * @test + * @sources JSONPTypesMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.jsonptypes.JSONPTypesMappingTest + **/ +public class JSONPTypesMappingTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testJsonObjectMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that JsonObject type is correctly handled + */ + @Test + public void testJsonObjectMapping() { + JsonObject instance = Json.createObjectBuilder() + .add("jsonObjectInstance", Json.createObjectBuilder().add("innerInstance", "Inner Test String")) + .add("jsonArrayInstance", + Json.createArrayBuilder() + .add(Json.createObjectBuilder().add("arrayInstance1", "Array Test String 1")) + .add(Json.createObjectBuilder().add("arrayInstance2", "Array Test String 2"))) + .add("jsonStringInstance", "Test String") + .add("jsonNumberInstance", Integer.MAX_VALUE) + .add("jsonTrueInstance", JsonValue.TRUE) + .add("jsonFalseInstance", JsonValue.FALSE) + .add("jsonNullInstance", JsonValue.NULL).build(); + + String jsonString = jsonb.toJson(new JsonObjectContainer() {{ + setInstance(instance); + }}); + String validationRegexp = "\\{\\s*\"instance\"\\s*:\\s*\\{" + + "\\s*\"jsonObjectInstance\"\\s*:\\s*\\{\\s*\"innerInstance\"\\s*:\\s*\"Inner Test String\"\\s*\\}\\s*," + + "\\s*\"jsonArrayInstance\"\\s*:\\s*\\[" + + "\\s*\\{\\s*\"arrayInstance1\"\\s*:\\s*\"Array Test String 1\"\\s*\\}\\s*," + + "\\s*\\{\\s*\"arrayInstance2\"\\s*:\\s*\"Array Test String 2\"\\s*\\}\\s*\\]\\s*," + + "\\s*\"jsonStringInstance\"\\s*:\\s*\"Test String\"\\s*," + + "\\s*\"jsonNumberInstance\"\\s*:\\s*2147483647\\s*," + + "\\s*\"jsonTrueInstance\"\\s*:\\s*true\\s*," + + "\\s*\"jsonFalseInstance\"\\s*:\\s*false\\s*," + + "\\s*\"jsonNullInstance\"\\s*:\\s*null\\s*" + + "\\}\\s*\\}"; + + assertThat("Failed to marshal object with JsonObject attribute value.", jsonString, matchesPattern(validationRegexp)); + + String toDeserialize = "{ \"instance\" : { " + + "\"jsonObjectInstance\" : { \"innerInstance\" : \"Inner Test String\" }, " + + "\"jsonArrayInstance\" : [ " + + "{ \"arrayInstance1\" : \"Array Test String 1\" }, " + + "{ \"arrayInstance2\" : \"Array Test String 2\" } ], " + + "\"jsonStringInstance\" : \"Test String\", " + + "\"jsonNumberInstance\" : 2147483647, " + + "\"jsonTrueInstance\" : true, " + + "\"jsonFalseInstance\" : false, " + + "\"jsonNullInstance\" : null " + + "} }"; + JsonObjectContainer unmarshalledObject = jsonb.fromJson(toDeserialize, JsonObjectContainer.class); + assertThat("Failed to unmarshal object with JsonObject attribute value.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testEmptyJsonObjectMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that empty JsonObject is correctly handled + */ + @Test + public void testEmptyJsonObjectMapping() { + JsonObject instance = Json.createObjectBuilder().build(); + String jsonString = jsonb.toJson(new JsonObjectContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to marshal object with empty JsonObject attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\{\\s*\\}\\s*\\}")); + + JsonObjectContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : { } }", JsonObjectContainer.class); + assertThat("Failed to unmarshal object with empty JsonObject attribute value.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testJsonArrayMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that JsonArray type is correctly handled + */ + @Test + public void testJsonArrayMapping() { + JsonArray instance = Json.createArrayBuilder() + .add(Json.createObjectBuilder().add("arrayInstance1", "Array Test String 1")) + .add(Json.createObjectBuilder().add("arrayInstance2", "Array Test String 2")) + .build(); + + String jsonString = jsonb.toJson(new JsonArrayContainer() {{ + setInstance(instance); + }}); + String validationPattern = "\\{\\s*\"instance\"\\s*:\\s*\\[" + + "\\s*\\{\\s*\"arrayInstance1\"\\s*:\\s*\"Array Test String 1\"\\s*\\}\\s*," + + "\\s*\\{\\s*\"arrayInstance2\"\\s*:\\s*\"Array Test String 2\"\\s*\\}\\s*" + + "\\]\\s*\\}"; + assertThat("Failed to marshal object with JsonArray attribute value.", + jsonString, matchesPattern(validationPattern)); + + String toDeserialize = "{ \"instance\" : [ " + + "{ \"arrayInstance1\" : \"Array Test String 1\" }, " + + "{ \"arrayInstance2\" : \"Array Test String 2\" } " + + "] }"; + JsonArrayContainer unmarshalledObject = jsonb.fromJson(toDeserialize, JsonArrayContainer.class); + assertThat("Failed to unmarshal object with JsonArray attribute value.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testEmptyJsonArrayMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that empty JsonArray is correctly handled + */ + @Test + public void testEmptyJsonArrayMapping() { + JsonArray instance = Json.createArrayBuilder().build(); + String jsonString = jsonb.toJson(new JsonArrayContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to marshal object with empty JsonArray attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\[\\s*\\]\\s*\\}")); + + JsonArrayContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : [ ] }", JsonArrayContainer.class); + assertThat("Failed to unmarshal object with empty JsonArray attribute value.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testJsonObjectStructureMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that JsonStructure of JsonObject is correctly + * handled + */ + @Test + public void testJsonObjectStructureMapping() { + JsonStructure instance = Json.createObjectBuilder() + .add("jsonObjectInstance", Json.createObjectBuilder().add("innerInstance", "Inner Test String")) + .add("jsonArrayInstance", + Json.createArrayBuilder() + .add(Json.createObjectBuilder().add("arrayInstance1", "Array Test String 1")) + .add(Json.createObjectBuilder().add("arrayInstance2", "Array Test String 2"))) + .add("jsonStringInstance", "Test String") + .add("jsonNumberInstance", Integer.MAX_VALUE) + .add("jsonTrueInstance", JsonValue.TRUE) + .add("jsonFalseInstance", JsonValue.FALSE) + .add("jsonNullInstance", JsonValue.NULL).build(); + + String jsonString = jsonb.toJson(new JsonStructureContainer() {{ + setInstance(instance); + }}); + String validationRegexp = "\\{\\s*\"instance\"\\s*:\\s*\\{" + + "\\s*\"jsonObjectInstance\"\\s*:\\s*\\{\\s*\"innerInstance\"\\s*:\\s*\"Inner Test String\"\\s*\\}\\s*," + + "\\s*\"jsonArrayInstance\"\\s*:\\s*\\[" + + "\\s*\\{\\s*\"arrayInstance1\"\\s*:\\s*\"Array Test String 1\"\\s*\\}\\s*," + + "\\s*\\{\\s*\"arrayInstance2\"\\s*:\\s*\"Array Test String 2\"\\s*\\}\\s*\\]\\s*," + + "\\s*\"jsonStringInstance\"\\s*:\\s*\"Test String\"\\s*," + + "\\s*\"jsonNumberInstance\"\\s*:\\s*2147483647\\s*," + + "\\s*\"jsonTrueInstance\"\\s*:\\s*true\\s*," + + "\\s*\"jsonFalseInstance\"\\s*:\\s*false\\s*," + + "\\s*\"jsonNullInstance\"\\s*:\\s*null\\s*" + + "\\}\\s*\\}"; + + assertThat("Failed to marshal object with JsonObject JsonStructure attribute value.", + jsonString, matchesPattern(validationRegexp)); + + String toDeserialize = "{ \"instance\" : { " + + "\"jsonObjectInstance\" : { \"innerInstance\" : \"Inner Test String\" }, " + + "\"jsonArrayInstance\" : [ " + + "{ \"arrayInstance1\" : \"Array Test String 1\" }, " + + "{ \"arrayInstance2\" : \"Array Test String 2\" } ], " + + "\"jsonStringInstance\" : \"Test String\", " + + "\"jsonNumberInstance\" : 2147483647, " + + "\"jsonTrueInstance\" : true, " + + "\"jsonFalseInstance\" : false, " + + "\"jsonNullInstance\" : null " + + "} }"; + JsonStructureContainer unmarshalledObject = jsonb.fromJson(toDeserialize, JsonStructureContainer.class); + assertThat("Failed to unmarshal object with JsonObject JsonStructure attribute value.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testJsonArrayStructureMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that JsonStructure of JsonArray is correctly handled + */ + @Test + public void testJsonArrayStructureMapping() { + JsonStructure instance = Json.createArrayBuilder() + .add(Json.createObjectBuilder().add("arrayInstance1", "Array Test String 1")) + .add(Json.createObjectBuilder().add("arrayInstance2", "Array Test String 2")) + .build(); + + String jsonString = jsonb.toJson(new JsonStructureContainer() {{ + setInstance(instance); + }}); + String validationRegexp = "\\{\\s*\"instance\"\\s*:\\s*\\[" + + "\\s*\\{\\s*\"arrayInstance1\"\\s*:\\s*\"Array Test String 1\"\\s*\\}\\s*," + + "\\s*\\{\\s*\"arrayInstance2\"\\s*:\\s*\"Array Test String 2\"\\s*\\}\\s*" + + "\\]\\s*\\}"; + assertThat("Failed to marshal object with JsonArray JsonStructure attribute value.", + jsonString, matchesPattern(validationRegexp)); + + String toDeserialize = "{ \"instance\" : [ " + + "{ \"arrayInstance1\" : \"Array Test String 1\" }, " + + "{ \"arrayInstance2\" : \"Array Test String 2\" } " + + "] }"; + JsonStructureContainer unmarshalledObject = jsonb.fromJson(toDeserialize, JsonStructureContainer.class); + assertThat("Failed to unmarshal object with JsonArray JsonStructure attribute value.", + unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testJsonValueMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that JsonValue type is correctly handled + */ + @Test + public void testJsonValueMapping() { + JsonValue instance = Json.createObjectBuilder().add("stringInstance", "Test String").build(); + String jsonString = jsonb.toJson(new JsonValueContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to marshal object with JsonValue attribute value.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\{\\s*\"stringInstance\"\\s*:\\s*\"Test String\"\\s*\\}\\s*\\}")); + + JsonValueContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : { \"stringInstance\" : \"Test String\" } }", + JsonValueContainer.class); + assertThat("Failed to unmarshal object with JsonValue attribute value.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testJsonStringMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that JsonString type is correctly handled + */ + @Test + public void testJsonStringMapping() { + JsonString instance = Json.createValue("Test String"); + String jsonString = jsonb.toJson(new JsonStringContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to marshal object with JsonString attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*\\}")); + + JsonStringContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : \"Test String\" }", JsonStringContainer.class); + assertThat("Failed to unmarshal object with JsonString attribute value.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testJsonNumberMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.20-1; JSONB:SPEC:JSB-3.20-2; + * JSONB:SPEC:JSB-3.20-3 + * + * @test_Strategy: Assert that JsonNumber type is correctly handled + */ + @Test + public void testJsonNumberMapping() { + JsonNumber instance = Json.createValue(0); + String jsonString = jsonb.toJson(new JsonNumberContainer() {{ + setInstance(instance); + }}); + assertThat("Failed to marshal object with JsonNumber attribute value.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*0\\s*\\}")); + + JsonNumberContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : 0 }", JsonNumberContainer.class); + assertThat("Failed to unmarshal object with JsonNumber attribute value.", unmarshalledObject.getInstance(), is(instance)); + } + + /* + * @testName: testNullDeserializedToJsonValueNull + * + * @assertion_ids: JSONB:SPEC:JSB-3.20 + * + * @test_Strategy: Assert that null is properly deserialized to the JsonValue.NULL + */ + @Test + public void testNullDeserializedToJsonValueNull() { + JsonValueContainer unmarshalledValue = jsonb.fromJson("{ \"instance\" : null }", JsonValueContainer.class); + assertThat("Failed to unmarshal null value to the JsonValue.NULL", unmarshalledValue.getInstance(), is(JsonValue.NULL)); + unmarshalledValue = jsonb.fromJson("{}", JsonValueContainer.class); + assertThat("No value should have been deserialized.", unmarshalledValue.getInstance(), nullValue()); + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonArrayContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonArrayContainer.java new file mode 100644 index 0000000..6f47af8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonArrayContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model; + +import jakarta.json.JsonArray; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class JsonArrayContainer implements TypeContainer<JsonArray> { + private JsonArray instance; + + @Override + public JsonArray getInstance() { + return instance; + } + + @Override + public void setInstance(JsonArray instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonNumberContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonNumberContainer.java new file mode 100644 index 0000000..339e097 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonNumberContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model; + +import jakarta.json.JsonNumber; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class JsonNumberContainer implements TypeContainer<JsonNumber> { + private JsonNumber instance; + + @Override + public JsonNumber getInstance() { + return instance; + } + + @Override + public void setInstance(JsonNumber instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonObjectContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonObjectContainer.java new file mode 100644 index 0000000..5579f97 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonObjectContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model; + +import jakarta.json.JsonObject; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class JsonObjectContainer implements TypeContainer<JsonObject> { + private JsonObject instance; + + @Override + public JsonObject getInstance() { + return instance; + } + + @Override + public void setInstance(JsonObject instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonPointerContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonPointerContainer.java new file mode 100644 index 0000000..778f034 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonPointerContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model; + +import jakarta.json.JsonPointer; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class JsonPointerContainer implements TypeContainer<JsonPointer> { + private JsonPointer instance; + + @Override + public JsonPointer getInstance() { + return instance; + } + + @Override + public void setInstance(JsonPointer instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonStringContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonStringContainer.java new file mode 100644 index 0000000..7dc1012 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonStringContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model; + +import jakarta.json.JsonString; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class JsonStringContainer implements TypeContainer<JsonString> { + private JsonString instance; + + @Override + public JsonString getInstance() { + return instance; + } + + @Override + public void setInstance(JsonString instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonStructureContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonStructureContainer.java new file mode 100644 index 0000000..5ce9e77 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonStructureContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model; + +import jakarta.json.JsonStructure; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class JsonStructureContainer implements TypeContainer<JsonStructure> { + private JsonStructure instance; + + @Override + public JsonStructure getInstance() { + return instance; + } + + @Override + public void setInstance(JsonStructure instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonValueContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonValueContainer.java new file mode 100644 index 0000000..b21ce54 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/jsonptypes/model/JsonValueContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.jsonptypes.model; + +import jakarta.json.JsonValue; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class JsonValueContainer implements TypeContainer<JsonValue> { + private JsonValue instance; + + @Override + public JsonValue getInstance() { + return instance; + } + + @Override + public void setInstance(JsonValue instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/NullValueMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/NullValueMappingTest.java new file mode 100644 index 0000000..d15c8c2 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/NullValueMappingTest.java
@@ -0,0 +1,94 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.nullvalue; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.defaultmapping.nullvalue.model.NullArrayContainer; +import ee.jakarta.tck.json.bind.defaultmapping.nullvalue.model.NullValueContainer; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.arrayContaining; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.nullValue; + +/** + * @test + * @sources NullValueMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.nullvalue.NullValueMappingTest + **/ +public class NullValueMappingTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + /* + * @testName: testNullAttributeValue + * + * @assertion_ids: JSONB:SPEC:JSB-3.14.1-1; JSONB:SPEC:JSB-3.14.1-2; + * JSONB:SPEC:JSB-3.14.1-3 + * + * @test_Strategy: Assert that fields with null value are ignored during + * marshalling and that during unmarshalling missing attributes are not set, + * maintaining original value, and null attributes are correctly unmarshalled + */ + @Test + public void testNullAttributeValue() { + String jsonString = jsonb.toJson(new NullValueContainer() {{ + setInstance(null); + }}); + assertThat("Failed to ignore displaying property with null value.", jsonString, matchesPattern("\\{\\s*\\}")); + + NullValueContainer unmarshalledObject = jsonb.fromJson("{ }", NullValueContainer.class); + assertThat("Failed to ignore calling setter of absent property during unmarshalling.", + unmarshalledObject.getInstance(), is(("Test String"))); + + unmarshalledObject = jsonb.fromJson("{ \"instance\" : null }", NullValueContainer.class); + assertThat("Failed to set property to null.", unmarshalledObject.getInstance(), nullValue()); + } + + /* + * @testName: testNullArrayValue + * + * @assertion_ids: JSONB:SPEC:JSB-3.14.2-1; JSONB:SPEC:JSB-3.14.2-2; + * JSONB:SPEC:JSB-3.14.2-3 + * + * @test_Strategy: Assert that a null array value is marked as null during + * marshalling and a null value is set to the appropriate array index during + * unmrashalling of an array containing a null value + */ + @Test + public void testNullArrayValue() { + String jsonString = jsonb.toJson(new NullArrayContainer() {{ + setInstance(new String[] {"Test 1", null, "Test 2"}); + }}); + assertThat("Failed to correctly display null array value.", + jsonString, + matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\\[\\s*\"Test 1\"\\s*,\\s*null\\s*,\\s*\"Test 2\"\\s*\\]\\s*\\}")); + + NullArrayContainer unmarshalledObject = jsonb.fromJson("{ \"instance\" : [ \"Test 1\", null, \"Test 2\" ] }", + NullArrayContainer.class); + assertThat("Failed to correctly set null array value.", + unmarshalledObject.getInstance(), arrayContaining("Test 1", null, "Test 2")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/model/NullArrayContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/model/NullArrayContainer.java new file mode 100644 index 0000000..9bb1a1c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/model/NullArrayContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.nullvalue.model; + +public class NullArrayContainer { + private Object[] instance; + + public Object[] getInstance() { + return instance; + } + + public void setInstance(Object[] instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/model/NullValueContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/model/NullValueContainer.java new file mode 100644 index 0000000..f88f26e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/nullvalue/model/NullValueContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.nullvalue.model; + +public class NullValueContainer { + private Object instance = "Test String"; + + public Object getInstance() { + return instance; + } + + public void setInstance(Object instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/AnnotationTypeInfoTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/AnnotationTypeInfoTest.java new file mode 100644 index 0000000..9ef69cb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/AnnotationTypeInfoTest.java
@@ -0,0 +1,166 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes; + +import java.time.LocalDate; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; +import jakarta.json.bind.annotation.JsonbCreator; +import jakarta.json.bind.annotation.JsonbDateFormat; +import jakarta.json.bind.annotation.JsonbProperty; +import jakarta.json.bind.annotation.JsonbSubtype; +import jakarta.json.bind.annotation.JsonbTypeInfo; + +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.arrayWithSize; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * Tests for verification of proper type inheritance handling based on annotation with property format. + */ +public class AnnotationTypeInfoTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + @Test + public void testBasicSerialization() { + Dog dog = new Dog(); + String jsonString = jsonb.toJson(dog); + assertThat("Failed to serialize Dog class correctly.", + jsonString, matchesPattern("\\{\\s*\"@type\"\\s*:\\s*\"dog\"\\s*,\\s*\"isDog\"\\s*:\\s*true\\s*\\}")); + + Cat cat = new Cat(); + jsonString = jsonb.toJson(cat); + assertThat("Failed to serialize Cat class correctly", + jsonString, matchesPattern("\\{\\s*\"@type\"\\s*:\\s*\"cat\"\\s*,\\s*\"isCat\"\\s*:\\s*true\\s*\\}")); + } + + @Test + public void testBasicDeserialization() { + Animal dog = jsonb.fromJson("{\"@type\":\"dog\",\"isDog\":false}", Animal.class); + assertThat("Incorrectly deserialized to the type. Expected was Dog instance. Got instance of class " + dog.getClass(), + dog, instanceOf(Dog.class)); + assertThat("Incorrectly deserialized field of the Dog instance. Field \"isDog\" should have been false.", + ((Dog) dog).isDog, is(false)); + + Animal cat = jsonb.fromJson("{\"@type\":\"cat\",\"isCat\":false}", Animal.class); + assertThat("Incorrectly deserialized to the type. Expected was Cat instance. Got instance of class " + cat.getClass(), + cat, instanceOf(Cat.class)); + assertThat("Incorrectly deserialized field of the Cat instance. Field \"isCat\" should have been false.", + ((Cat) cat).isCat, is(false)); + } + + @Test + public void testUnknownAliasDeserialization() { + assertThrows(JsonbException.class, + () -> jsonb.fromJson("{\"@type\":\"rat\",\"isRat\":false}", Animal.class), + "Deserialization should fail. Alias \"rat\" is not valid alias of the class Animal."); + } + + @Test + public void testCreatorDeserialization() { + SomeDateType deserialized = jsonb.fromJson("{\"@dateType\":\"constructor\",\"localDate\":\"26-02-2021\"}", + SomeDateType.class); + assertThat("Incorrectly deserialized according to the type information. Expected was DateConstructor instance. " + + "Got instance of class " + deserialized.getClass(), + deserialized, instanceOf(DateConstructor.class)); + } + + @Test + public void testArraySerialization() { + String expected = "\\[" + + "\\s*\\{\\s*\"@type\"\\s*:\\s*\"dog\"\\s*,\\s*\"isDog\"\\s*:\\s*true\\s*\\}\\s*," + + "\\s*\\{\\s*\"@type\"\\s*:\\s*\"cat\"\\s*,\\s*\"isCat\"\\s*:\\s*true\\s*\\}\\s*," + + "\\s*\\{\\s*\"@type\"\\s*:\\s*\"dog\"\\s*,\\s*\"isDog\"\\s*:\\s*true\\s*\\}\\s*" + + "\\]"; + Animal[] animals = new Animal[] {new Dog(), new Cat(), new Dog()}; + String jsonString = jsonb.toJson(animals); + assertThat("Array values were not properly serialized with type information.", + jsonString, matchesPattern(expected)); + } + + @Test + public void testArrayDeserialization() { + String array = "[{\"@type\":\"dog\",\"isDog\":true},{\"@type\":\"cat\",\"isCat\":true}," + + "{\"@type\":\"dog\",\"isDog\":true}]"; + Animal[] deserialized = jsonb.fromJson(array, Animal[].class); + assertThat("Array should have exactly 3 values.", deserialized, arrayWithSize(3)); + assertThat("Array value at index 0 was incorrectly deserialized according to the type information. " + + "Expected was Dog instance. Got instance of class " + deserialized[0].getClass(), + deserialized[0], instanceOf(Dog.class)); + assertThat("Array value at index 1 was incorrectly deserialized according to the type information. " + + "Expected was Cat instance. Got instance of class " + deserialized[1].getClass(), + deserialized[1], instanceOf(Cat.class)); + assertThat("Array value at index 2 was incorrectly deserialized according to the type information. " + + "Expected was Dog instance. Got instance of class " + deserialized[2].getClass(), + deserialized[2], instanceOf(Dog.class)); + } + + @JsonbTypeInfo({ + @JsonbSubtype(alias = "dog", type = Dog.class), + @JsonbSubtype(alias = "cat", type = Cat.class), + @JsonbSubtype(alias = "elephant", type = Elephant.class) + }) + public interface Animal { + + } + + public static class Dog implements Animal { + + public boolean isDog = true; + + } + + public static class Cat implements Animal { + + public boolean isCat = true; + + } + + public static class Elephant implements Animal { + + public boolean isElephant = true; + public String testProperty = "value"; + + } + + @JsonbTypeInfo(key = "@dateType", value = { + @JsonbSubtype(alias = "constructor", type = DateConstructor.class) + }) + public interface SomeDateType { + + } + + public static final class DateConstructor implements SomeDateType { + + public LocalDate localDate; + + @JsonbCreator + public DateConstructor(@JsonbProperty("localDate") @JsonbDateFormat(value = "dd-MM-yyyy", locale = "nl-NL") LocalDate localDate) { + this.localDate = localDate; + } + + } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/DefaultPolymorphicMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/DefaultPolymorphicMappingTest.java new file mode 100644 index 0000000..f8bb832 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/DefaultPolymorphicMappingTest.java
@@ -0,0 +1,63 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes.model.StringContainer; +import ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes.model.StringContainerSubClass; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.matchesPattern; +import static org.hamcrest.Matchers.not; + +/** + * @test + * @sources PolymorphicMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.polymorphictypes.PolymorphicMappingTest + **/ +public class DefaultPolymorphicMappingTest { + + /* + * @testName: testPolymorphicTypes + * + * @assertion_ids: JSONB:SPEC:JSB-3.8-1 + * + * @test_Strategy: Assert that unmarshalling into polymorphic types is not + * supported + */ + @Test + public void testPolymorphicTypes() { + Jsonb jsonb = JsonbBuilder.create(); + String jsonString = jsonb.toJson(new StringContainerSubClass()); + assertThat("Failed to get attribute value from subclass.", + jsonString, matchesPattern("\\{\\s*\"instance\"\\s*:\\s*\"Test String\"\\s*," + + "\\s*\"newInstance\"\\s*:\\s*\"SubClass Test String\"\\s*\\}")); + + String toDeserialize = "{ \"instance\" : \"New Test String\", \"newInstance\" : \"New SubClass Test String\" }"; + StringContainer unmarshalledObject = jsonb.fromJson(toDeserialize, StringContainer.class); + assertThat("Polymorphic types support is not expected.", + unmarshalledObject, not(instanceOf(StringContainerSubClass.class))); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/MultipleTypeInfoTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/MultipleTypeInfoTest.java new file mode 100644 index 0000000..444e0a7 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/MultipleTypeInfoTest.java
@@ -0,0 +1,116 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.annotation.JsonbSubtype; +import jakarta.json.bind.annotation.JsonbTypeInfo; + +import org.junit.jupiter.api.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.matchesPattern; + +public class MultipleTypeInfoTest { + + private static final Jsonb JSONB = JsonbBuilder.create(); + + @Test + public void testMultipleTypeInfoPropertySerialization() { + String expected = "\\{\\s*\"@living\"\\s*:\\s*\"animal\"\\s*," + + "\\s*\"@animal\"\\s*:\\s*\"dog\"\\s*," + + "\\s*\"@dogRace\"\\s*:\\s*\"labrador\"\\s*," + + "\\s*\"isLabrador\"\\s*:\\s*true\\s*\\}"; + Labrador labrador = new Labrador(); + assertThat(JSONB.toJson(labrador), matchesPattern(expected)); + } + + @Test + public void testMultipleTypeInfoPropertyDeserialization() { + String json = "{\"@living\":\"animal\",\"@animal\":\"dog\",\"@dogRace\":\"labrador\",\"isLabrador\":true}"; + assertThat(JSONB.fromJson(json, Labrador.class), instanceOf(Labrador.class)); + } + + @Test + public void testSerializeMultipleTypeInfoInSingleChain() { + String expected = "\\{" + + "\\s*\"@machine\"\\s*:\\s*\"vehicle\"\\s*," + + "\\s*\"@vehicle\"\\s*:\\s*\"car\"\\s*," + + "\\s*\"machineProperty\"\\s*:\\s*\"machineProperty\"\\s*," + + "\\s*\"vehicleProperty\"\\s*:\\s*\"vehicleProperty\"\\s*," + + "\\s*\"carProperty\"\\s*:\\s*\"carProperty\"\\s*" + + "\\}"; + Car car = new Car(); + assertThat(JSONB.toJson(car), matchesPattern(expected)); + } + + @Test + public void testDeserializeMultipleTypeInfoInSingleChain() { + String json = "{" + + "\"@machine\":\"vehicle\"," + + "\"@vehicle\":\"car\"," + + "\"machineProperty\":\"machineProperty\"," + + "\"vehicleProperty\":\"vehicleProperty\"," + + "\"carProperty\":\"carProperty\"" + + "}"; + Machine machine = JSONB.fromJson(json, Machine.class); + assertThat(machine, instanceOf(Car.class)); + } + + @JsonbTypeInfo(key = "@living", value = { + @JsonbSubtype(alias = "animal", type = Animal.class) + }) + public interface LivingThing { } + + @JsonbTypeInfo(key = "@animal", value = { + @JsonbSubtype(alias = "dog", type = Dog.class) + }) + public interface Animal extends LivingThing { + } + + @JsonbTypeInfo(key = "@dogRace", value = { + @JsonbSubtype(alias = "labrador", type = Labrador.class) + }) + public interface Dog extends Animal { + } + + public static class Labrador implements Dog { + + public boolean isLabrador = true; + + } + + @JsonbTypeInfo(key = "@machine", value = { + @JsonbSubtype(alias = "vehicle", type = Vehicle.class) + }) + public static class Machine { + public String machineProperty = "machineProperty"; + } + + @JsonbTypeInfo(key = "@vehicle", value = { + @JsonbSubtype(alias = "car", type = Car.class) + }) + public static class Vehicle extends Machine { + public String vehicleProperty = "vehicleProperty"; + } + + public static class Car extends Vehicle { + public String carProperty = "carProperty"; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/TypeInfoExceptionsTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/TypeInfoExceptionsTest.java new file mode 100644 index 0000000..68e9457 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/TypeInfoExceptionsTest.java
@@ -0,0 +1,89 @@ +/* + * Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; +import jakarta.json.bind.annotation.JsonbSubtype; +import jakarta.json.bind.annotation.JsonbTypeInfo; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class TypeInfoExceptionsTest { + + private final Jsonb jsonb = JsonbBuilder.create(); + + @Test + public void testSerializeTypeInfoMultiInheritance() { + assertThrows(JsonbException.class, () -> jsonb.toJson(new Dog()), + "Serialization of @JsonbTypeInfo multi inheritance is not supported."); + } + + @Test + public void testDeserializeTypeInfoMultiInheritance() { + assertThrows(JsonbException.class, () -> jsonb.fromJson("{\"@animal\":\"dog\",\"@livingThing\":\"dog\"}", Dog.class), + "Deserialization of @JsonbTypeInfo multi inheritance is not supported."); + } + + @Test + public void testInvalidAlias() { + assertThrows(JsonbException.class, () -> jsonb.toJson(new InvalidAlias()), + "Serialization should have failed since set alias is not subtype of the class it is defined on."); + } + + @Test + public void testNameCollision() { + assertThrows(JsonbException.class, () -> jsonb.toJson(new PropertyNameCollision()), + "Serialization of the type information to the property with the name which collides " + + "with the class property, is not supported"); + } + + //-------------- + + @JsonbTypeInfo(key = "@animal", value = { + @JsonbSubtype(alias = "dog", type = Dog.class) + }) + public interface Animal { } + + @JsonbTypeInfo(key = "@livingThing", value = { + @JsonbSubtype(alias = "dog", type = Dog.class) + }) + public interface LivingEntity { } + + public static final class Dog implements Animal, LivingEntity { } + + //-------------- + + @JsonbTypeInfo(key = "keyName", value = { + @JsonbSubtype(alias = "test", type = PropertyNameCollision.class) + }) + public static class PropertyNameCollision { + public String keyName; + } + + //-------------- + + @JsonbTypeInfo({ + @JsonbSubtype(alias = "integer", type = Integer.class), + @JsonbSubtype(alias = "invalid", type = InvalidAlias.class) + }) + public static class InvalidAlias { } + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/model/StringContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/model/StringContainer.java new file mode 100644 index 0000000..797c275 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/model/StringContainer.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes.model; + +public class StringContainer { + private String instance = "Test String"; + + public String getInstance() { + return instance; + } + + public void setInstance(String instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/model/StringContainerSubClass.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/model/StringContainerSubClass.java new file mode 100644 index 0000000..a2ae0c9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/polymorphictypes/model/StringContainerSubClass.java
@@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.polymorphictypes.model; + +public class StringContainerSubClass extends StringContainer { + private String newInstance = "SubClass Test String"; + + public String getNewInstance() { + return newInstance; + } + + public void setNewInstance(String newInstance) { + this.newInstance = newInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/SpecificTypesMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/SpecificTypesMappingTest.java new file mode 100644 index 0000000..a669779 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/SpecificTypesMappingTest.java
@@ -0,0 +1,300 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.Optional; +import java.util.OptionalDouble; +import java.util.OptionalInt; +import java.util.OptionalLong; + +import ee.jakarta.tck.json.bind.MappingTester; +import ee.jakarta.tck.json.bind.SimpleMappingTester; +import ee.jakarta.tck.json.bind.TypeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.BigDecimalContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.BigIntegerContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.OptionalArrayContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.OptionalContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.OptionalDoubleContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.OptionalIntContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.OptionalLongContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.OptionalTypeContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.SimpleContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.URIContainer; +import ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model.URLContainer; +import org.junit.jupiter.api.Test; + +/** + * @test + * @sources SpecificTypesMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.specifictypes.SpecificTypesMappingTest + **/ +public class SpecificTypesMappingTest { + + /* + * @testName: testBigIntegerMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.1-1; + * JSONB:SPEC:JSB-3.4.1-2 + * + * @test_Strategy: Assert that marshalling and unmarshalling of + * java.math.BigInteger type are performed according to the toString method + * and applicable String argument constructor + */ + @Test + public void testBigIntegerMapping() { + new MappingTester<>(BigIntegerContainer.class).test(new BigInteger("0"), "0"); + } + + /* + * @testName: testBigDecimalMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.1-1; + * JSONB:SPEC:JSB-3.4.1-2 + * + * @test_Strategy: Assert that marshalling and unmarshalling of + * java.math.BigDecimal type are performed according to the toString method + * and applicable String argument constructor + */ + @Test + public void testBigDecimalMapping() { + new MappingTester<>(BigDecimalContainer.class).test(new BigDecimal("0.0"), "0.0"); + } + + /* + * @testName: testURLMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.2-1; + * JSONB:SPEC:JSB-3.4.2-2 + * + * @test_Strategy: Assert that marshalling and unmarshalling of java.net.URL + * are performed according to the toString method and applicable String + * argument constructor + */ + @Test + public void testURLMapping() throws Exception { + new MappingTester<>(URLContainer.class).test(new URL("http://www.host.com:80"), "\"http://www.host.com:80\""); + } + + /* + * @testName: testURIMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.2-1; + * JSONB:SPEC:JSB-3.4.2-2 + * + * @test_Strategy: Assert that marshalling and unmarshalling of java.net.URI + * type are performed according to the toString method and applicable String + * argument constructor + */ + @Test + public void testURIMapping() throws URISyntaxException { + new MappingTester<>(URIContainer.class).test(new URI("http://www.host.com:80"), "\"http://www.host.com:80\""); + } + + /* + * @testName: testOptionalMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-1; + * JSONB:SPEC:JSB-3.4.3-5; JSONB:SPEC:JSB-3.4.3-6; JSONB:SPEC:JSB-3.4.3-7 + * + * @test_Strategy: Assert that non-empty java.util.Optional is correctly + * handled as defined for each type + */ + @Test + public void testOptionalMapping() { + new MappingTester<>(OptionalContainer.class).test(Optional.of("String Value"), "\"String Value\""); + } + + /* + * @testName: testOptionalObjectMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-1; + * JSONB:SPEC:JSB-3.4.3-5; JSONB:SPEC:JSB-3.4.3-6; JSONB:SPEC:JSB-3.4.3-7 + * + * @test_Strategy: Assert that non-empty java.util.Optional of a complex type + * is correctly handled + */ + @Test + public void testOptionalObjectMapping() { + OptionalTypeContainer container = new OptionalTypeContainer(); + SimpleContainer simpleContainer = new SimpleContainer(); + simpleContainer.setStringInstance("String Value"); + container.setInstance(Optional.of(simpleContainer)); + + new SimpleMappingTester<>(OptionalTypeContainer.class, TypeContainer.class).test( + container, + "\\{\\s*\"instance\"\\s*:\\s*\\{\\s*\"stringInstance\"\\s*:\\s*\"String Value\"\\s*}\\s*}", + "{ \"instance\" : { \"stringInstance\" : \"String Value\" } }", + container); + } + + /* + * @testName: testEmptyOptionalMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-2; + * JSONB:SPEC:JSB-3.4.3-4; JSONB:SPEC:JSB-3.14.1-3 + * + * @test_Strategy: Assert that empty java.util.Optional is ignored during + * marshalling and null value is returned as empty Optional value during + * unmarshalling + */ + @Test + public void testEmptyOptionalMapping() { + OptionalContainer optionalContainer = new OptionalContainer(); + optionalContainer.setInstance(Optional.empty()); + new SimpleMappingTester<>(OptionalContainer.class, TypeContainer.class).test( + optionalContainer, + "\\{\\s*}", + "{ \"instance\" : null }", + optionalContainer); + } + + /* + * @testName: testEmptyOptionalArrayMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-2; + * JSONB:SPEC:JSB-3.4.3-3; JSONB:SPEC:JSB-3.4.3-4; JSONB:SPEC:JSB-3.14.1-3 + * + * @test_Strategy: Assert that empty java.util.Optional instances in array + * items are serialized as null and null value is returned as empty Optional + * value during unmarshalling + */ + @SuppressWarnings("unchecked") + @Test + public void testEmptyOptionalArrayMapping() { + OptionalArrayContainer optionalContainer = new OptionalArrayContainer(); + optionalContainer.setInstance(new Optional[] {Optional.empty()}); + new SimpleMappingTester<>(OptionalArrayContainer.class, TypeContainer.class).test( + optionalContainer, + "\\{\\s*\"instance\"\\s*:\\s*\\[\\s*null\\s*]\\s*}", + "{ \"instance\" : [ null ] }", + optionalContainer); + } + + /* + * @testName: testOptionalIntMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-1; + * JSONB:SPEC:JSB-3.4.3-5 + * + * @test_Strategy: Assert that non-empty java.util.OptionalInt is correctly + * handled as defined for Integer type + */ + @Test + public void testOptionalIntMapping() { + new MappingTester<>(OptionalIntContainer.class).test(OptionalInt.of(0), "0"); + } + + /* + * @testName: testEmptyOptionalIntMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-2; + * JSONB:SPEC:JSB-3.4.3-4; JSONB:SPEC:JSB-3.14.1-3 + * + * @test_Strategy: Assert that empty java.util.OptionalInt is ignored during + * marshalling and null value is returned as empty OptionalInt value during + * unmarshalling + */ + @Test + public void testEmptyOptionalIntMapping() { + OptionalIntContainer optionalContainer = new OptionalIntContainer(); + optionalContainer.setInstance(OptionalInt.empty()); + new SimpleMappingTester<>(OptionalIntContainer.class, TypeContainer.class).test( + optionalContainer, + "\\{\\s*}", + "{ \"instance\" : null }", + optionalContainer); + } + + /* + * @testName: testOptionalLongMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-1; + * JSONB:SPEC:JSB-3.4.3-5 + * + * @test_Strategy: Assert that non-empty java.util.OptionalLong is correctly + * handled as defined for Long type + */ + @Test + public void testOptionalLongMapping() { + new MappingTester<>(OptionalLongContainer.class).test(OptionalLong.of(0), "0"); + } + + /* + * @testName: testEmptyOptionalLongMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-2; + * JSONB:SPEC:JSB-3.4.3-4; JSONB:SPEC:JSB-3.14.1-3 + * + * @test_Strategy: Assert that empty java.util.OptionalLong is ignored during + * marshalling and null value is returned as empty OptionalLong value during + * unmarshalling + */ + @Test + public void testEmptyOptionalLongMapping() { + OptionalLongContainer optionalContainer = new OptionalLongContainer(); + optionalContainer.setInstance(OptionalLong.empty()); + new SimpleMappingTester<>(OptionalLongContainer.class, TypeContainer.class).test( + optionalContainer, + "\\{\\s*}", + "{ \"instance\" : null }", + optionalContainer); + } + + /* + * @testName: testOptionalDoubleMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-1; + * JSONB:SPEC:JSB-3.4.3-5 + * + * @test_Strategy: Assert that non-empty java.util.OptionalDouble is correctly + * handled as defined for Double type + */ + @Test + public void testOptionalDoubleMapping() { + new MappingTester<>(OptionalDoubleContainer.class).test(OptionalDouble.of(0.0), "0.0"); + } + + /* + * @testName: testEmptyOptionalDoubleMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.4-1; JSONB:SPEC:JSB-3.4.3-2; + * JSONB:SPEC:JSB-3.4.3-4; JSONB:SPEC:JSB-3.14.1-3 + * + * @test_Strategy: Assert that empty java.util.OptionalDouble is ignored + * during marshalling and null value is returned as empty OptionalDouble value + * during unmarshalling + */ + @Test + public void testEmptyOptionalDoubleMapping() { + OptionalDoubleContainer optionalContainer = new OptionalDoubleContainer(); + optionalContainer.setInstance(OptionalDouble.empty()); + new SimpleMappingTester<>(OptionalDoubleContainer.class, TypeContainer.class).test( + optionalContainer, + "\\{\\s*}", + "{ \"instance\" : null }", + optionalContainer); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/BigDecimalContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/BigDecimalContainer.java new file mode 100644 index 0000000..d843054 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/BigDecimalContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.math.BigDecimal; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class BigDecimalContainer implements TypeContainer<BigDecimal> { + private BigDecimal instance; + + @Override + public BigDecimal getInstance() { + return instance; + } + + @Override + public void setInstance(BigDecimal instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/BigIntegerContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/BigIntegerContainer.java new file mode 100644 index 0000000..6caf7a0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/BigIntegerContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.math.BigInteger; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class BigIntegerContainer implements TypeContainer<BigInteger> { + private BigInteger instance; + + @Override + public BigInteger getInstance() { + return instance; + } + + @Override + public void setInstance(BigInteger instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalArrayContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalArrayContainer.java new file mode 100644 index 0000000..96dcb94 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalArrayContainer.java
@@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.util.Arrays; +import java.util.Optional; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class OptionalArrayContainer + implements TypeContainer<Optional<String>[]> { + private Optional<String>[] instance; + + @Override + public Optional<String>[] getInstance() { + return instance; + } + + @Override + public void setInstance(Optional<String>[] instance) { + this.instance = instance; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof OptionalArrayContainer)) { + return false; + } + + OptionalArrayContainer that = (OptionalArrayContainer) o; + + return Arrays.equals(instance, that.instance); + } + + @Override + public int hashCode() { + return Arrays.hashCode(instance); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalContainer.java new file mode 100644 index 0000000..439ceee --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalContainer.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.util.Optional; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class OptionalContainer implements TypeContainer<Optional<String>> { + private Optional<String> instance; + + @Override + public Optional<String> getInstance() { + return instance; + } + + @Override + public void setInstance(Optional<String> instance) { + this.instance = instance; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof OptionalContainer)) { + return false; + } + + OptionalContainer that = (OptionalContainer) o; + + return instance != null ? instance.equals(that.instance) + : that.instance == null; + } + + @Override + public int hashCode() { + return instance != null ? instance.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalDoubleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalDoubleContainer.java new file mode 100644 index 0000000..47bd281 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalDoubleContainer.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.util.OptionalDouble; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class OptionalDoubleContainer implements TypeContainer<OptionalDouble> { + private OptionalDouble instance; + + @Override + public OptionalDouble getInstance() { + return instance; + } + + @Override + public void setInstance(OptionalDouble instance) { + this.instance = instance; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof OptionalDoubleContainer)) { + return false; + } + + OptionalDoubleContainer that = (OptionalDoubleContainer) o; + + return instance != null ? instance.equals(that.instance) + : that.instance == null; + } + + @Override + public int hashCode() { + return instance != null ? instance.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalIntContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalIntContainer.java new file mode 100644 index 0000000..74fdd2b --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalIntContainer.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.util.OptionalInt; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class OptionalIntContainer implements TypeContainer<OptionalInt> { + private OptionalInt instance; + + @Override + public OptionalInt getInstance() { + return instance; + } + + @Override + public void setInstance(OptionalInt instance) { + this.instance = instance; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof OptionalIntContainer)) { + return false; + } + + OptionalIntContainer that = (OptionalIntContainer) o; + + return instance != null ? instance.equals(that.instance) + : that.instance == null; + } + + @Override + public int hashCode() { + return instance != null ? instance.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalLongContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalLongContainer.java new file mode 100644 index 0000000..d21d7e0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalLongContainer.java
@@ -0,0 +1,59 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.util.OptionalLong; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class OptionalLongContainer implements TypeContainer<OptionalLong> { + private OptionalLong instance; + + @Override + public OptionalLong getInstance() { + return instance; + } + + @Override + public void setInstance(OptionalLong instance) { + this.instance = instance; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof OptionalLongContainer)) { + return false; + } + + OptionalLongContainer that = (OptionalLongContainer) o; + + return instance != null ? instance.equals(that.instance) + : that.instance == null; + } + + @Override + public int hashCode() { + return instance != null ? instance.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalTypeContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalTypeContainer.java new file mode 100644 index 0000000..1d4bba9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/OptionalTypeContainer.java
@@ -0,0 +1,60 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.util.Optional; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class OptionalTypeContainer + implements TypeContainer<Optional<SimpleContainer>> { + private Optional<SimpleContainer> instance; + + @Override + public Optional<SimpleContainer> getInstance() { + return instance; + } + + @Override + public void setInstance(Optional<SimpleContainer> instance) { + this.instance = instance; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof OptionalTypeContainer)) { + return false; + } + + OptionalTypeContainer that = (OptionalTypeContainer) o; + + return instance != null ? instance.equals(that.instance) + : that.instance == null; + } + + @Override + public int hashCode() { + return instance != null ? instance.hashCode() : 0; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/SimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/SimpleContainer.java new file mode 100644 index 0000000..485b60a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/SimpleContainer.java
@@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +public class SimpleContainer { + public String stringInstance; + + public String getStringInstance() { + return stringInstance; + } + + public void setStringInstance(String stringInstance) { + this.stringInstance = stringInstance; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof SimpleContainer)) { + return false; + } + SimpleContainer that = (SimpleContainer) obj; + return stringInstance != null ? stringInstance.equals(that.stringInstance) + : that.stringInstance == null; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/URIContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/URIContainer.java new file mode 100644 index 0000000..ce0ee6e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/URIContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.net.URI; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class URIContainer implements TypeContainer<URI> { + private URI instance; + + @Override + public URI getInstance() { + return instance; + } + + @Override + public void setInstance(URI instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/URLContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/URLContainer.java new file mode 100644 index 0000000..c7e06d0 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/specifictypes/model/URLContainer.java
@@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.specifictypes.model; + +import java.net.URL; + +import ee.jakarta.tck.json.bind.TypeContainer; + +public class URLContainer implements TypeContainer<URL> { + private URL instance; + + @Override + public URL getInstance() { + return instance; + } + + @Override + public void setInstance(URL instance) { + this.instance = instance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/uniqueness/PropertyUniquenessTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/uniqueness/PropertyUniquenessTest.java new file mode 100644 index 0000000..949ac28 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/uniqueness/PropertyUniquenessTest.java
@@ -0,0 +1,54 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.uniqueness; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; +import jakarta.json.bind.JsonbException; + +import ee.jakarta.tck.json.bind.defaultmapping.uniqueness.model.SimpleContainer; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; + +/** + * @test + * @sources PropertyUniquenessTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.uniqueness.PropertyUniquenessTest + **/ +public class PropertyUniquenessTest { + + /* + * @testName: testUniqueProperties + * + * @assertion_ids: JSONB:SPEC:JSB-3.19-1; JSONB:SPEC:JSB-3.19-2 + * + * @test_Strategy: Assert that an exception is thrown when duplicate property + * names exist + */ + @Test + public void testUniqueProperties() { + Jsonb jsonb = JsonbBuilder.create(); + assertThrows(JsonbException.class, + () -> jsonb.toJson(new SimpleContainer()), + "An exception is expected when marshalling a class with duplicate attribute names."); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/uniqueness/model/SimpleContainer.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/uniqueness/model/SimpleContainer.java new file mode 100644 index 0000000..755bced --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/uniqueness/model/SimpleContainer.java
@@ -0,0 +1,46 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.uniqueness.model; + +import jakarta.json.bind.annotation.JsonbProperty; + +public class SimpleContainer { + public String firstInstance = "First Instance"; + + @JsonbProperty("firstInstance") + public String secondInstance = "Second Instance"; + + public String getFirstInstance() { + return firstInstance; + } + + public void setFirstInstance(String firstInstance) { + this.firstInstance = firstInstance; + } + + public String getSecondInstance() { + return secondInstance; + } + + public void setSecondInstance(String secondInstance) { + this.secondInstance = secondInstance; + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/untyped/UntypedMappingTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/untyped/UntypedMappingTest.java new file mode 100644 index 0000000..0fd2f13 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/defaultmapping/untyped/UntypedMappingTest.java
@@ -0,0 +1,124 @@ +/* + * Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.defaultmapping.untyped; + +import java.math.BigDecimal; +import java.util.Arrays; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import jakarta.json.bind.Jsonb; +import jakarta.json.bind.JsonbBuilder; + +import ee.jakarta.tck.json.bind.SimpleMappingTester; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.instanceOf; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.matchesPattern; + +/** + * @test + * @sources UntypedMappingTest.java + * @executeClass com.sun.ts.tests.jsonb.defaultmapping.untyped.UntypedMappingTest + **/ +public class UntypedMappingTest { + + /* + * @testName: testObjectMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.6-1; JSONB:SPEC:JSB-3.6-2 + * + * @test_Strategy: Assert that object, string, number, boolean and null JSON + * values are correctly mapped to java.util.Map<String,Object> implementation + * with predictable iteration order, with java.lang.String, + * java.math.BigDecimal, java.lang.Boolean and null values + */ + @Test + public void testObjectMapping() { + Jsonb jsonb = JsonbBuilder.create(); + @SuppressWarnings("unused") + String jsonString = jsonb.toJson(new Object() { + private String stringProperty = "Test String"; + + public String getStringProperty() { + return stringProperty; + } + + private Number numericProperty = 0; + + public Number getNumericProperty() { + return numericProperty; + } + + private boolean booleanProperty = false; + + public boolean getBooleanProperty() { + return booleanProperty; + } + + private Object nullProperty = null; + + public Object getNullProperty() { + return nullProperty; + } + }); + String validationRegexp = "\\{\\s*\"booleanProperty\"\\s*:\\s*false\\s*\\,\\s*\"numericProperty\"\\s*:\\s*0[\\.0]?+\\s*," + + "\\s*\"stringProperty\"\\s*:\\s*\"Test String\"\\s*}"; + assertThat("Failed to correctly marshal object with String, Number, Boolean and null fields.", + jsonString, matchesPattern(validationRegexp)); + + String toDeserialize = "{ \"numericProperty\" : 0.0, \"booleanProperty\" : false, \"stringProperty\" : \"Test String\" }"; + Object unmarshalledObject = jsonb.fromJson(toDeserialize, Object.class); + + String validationMessage = "Failed to correctly unmarshal object with string, number, boolean and null JSON values into" + + " a " + + "predictable order Map<String,Object> with java.lang.String, java.math.BigDecimal, java.lang.Boolean and null " + + "values."; + LinkedHashMap<String, Object> instance = new LinkedHashMap<String, Object>() {{ + put("numericProperty", BigDecimal.valueOf(0.0d)); + put("booleanProperty", false); + put("stringProperty", "Test String"); + }}; + + assertThat(validationMessage, unmarshalledObject, instanceOf(Map.class)); + assertThat(validationMessage, unmarshalledObject, is(instance)); + } + + /* + * @testName: testArrayMapping + * + * @assertion_ids: JSONB:SPEC:JSB-3.6-1 + * + * @test_Strategy: Assert that JSON arrays are correctly handled as + * java.util.List<Object> + */ + @Test + public void testArrayMapping() { + new SimpleMappingTester<>(List.class, List.class).test( + Arrays.asList("Test String"), + "\\[\\s*\"Test String\"s*\\]", + "[ \"Test String\" ]", + Arrays.asList("Test String")); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/ApiCheckDriver.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/ApiCheckDriver.java new file mode 100644 index 0000000..f54b969 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/ApiCheckDriver.java
@@ -0,0 +1,162 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintWriter; +import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.LinkedList; +import java.util.List; + + +public final class ApiCheckDriver extends SignatureTestDriver + implements Serializable { + + /* flags for the Diff utility argument list */ + private static final String BASE_FLAG = "-base"; + + private static final String TEST_FLAG = "-test"; + + private static final String PACKAGE_NO_SUBS_FLAG = "-PackageWithoutSubpackages"; + + private static final String PACKAGE_FLAG = "-package"; + + private static final String EXPACKAGE_FLAG = "-expackage"; + + private static final String REFLECT_FLAG = "-reflect"; + + private static final String CONST_FLAG = "-constvalues"; + + // ---------------------------------------- Methods from SignatureTestDriver + + @Override + protected String normalizeFileName(File f) { + return f.getPath(); + } + + @Override + protected String[] createTestArguments(String packageListFile, String mapFile, + String signatureRepositoryDir, String packageOrClassUnderTest, + String classpath, boolean bStaticMode) throws Exception { + + Class pkgListClass = Class.forName("javasoft.sqe.apiCheck.PackageList"); + Constructor pkgCtor = pkgListClass + .getDeclaredConstructor(new Class[] { String.class }); + Object pkgInstance = pkgCtor.newInstance(new Object[] { packageListFile }); + + Method pkgMethod = pkgListClass.getDeclaredMethod("getSubPackagesFormatted", + new Class[] { String.class }); + + String excludePkgs = (String) pkgMethod.invoke(pkgInstance, + new Object[] { packageOrClassUnderTest }); + + List sigArgsList = new LinkedList(); + + sigArgsList.add(BASE_FLAG); + sigArgsList.add( + getSigFileInfo(packageOrClassUnderTest, mapFile, signatureRepositoryDir) + .getFile()); + + if (classpath != null && classpath.length() > 0) { + sigArgsList.add(TEST_FLAG); + sigArgsList.add(classpath); + } + + sigArgsList.add(REFLECT_FLAG); + sigArgsList.add(CONST_FLAG); + sigArgsList.add(PACKAGE_FLAG); + sigArgsList.add(packageOrClassUnderTest); + + if (excludePkgs != null && excludePkgs.length() > 0) { + sigArgsList.add(EXPACKAGE_FLAG); + sigArgsList.add(excludePkgs); + } + + return (String[]) (sigArgsList.toArray(new String[sigArgsList.size()])); + + } // END createTestArguments + + @Override + protected boolean runSignatureTest(String packageOrClassName, + String[] testArguments) throws Exception { + + Class diffClass = Class.forName("javasoft.sqe.apiCheck.Diff"); + Method mainMethod = diffClass.getDeclaredMethod("main", + new Class[] { String[].class }); + mainMethod.invoke(null, new Object[] { testArguments }); + + Method diffMethod = diffClass.getDeclaredMethod("diffsFound", + new Class[] {}); + return (!((Boolean) diffMethod.invoke(null, new Object[] {})) + .booleanValue()); + + } // END runSignatureTest + + @Override + protected boolean runPackageSearch(String packageOrClassName, + String[] testArguments) throws Exception { + Class sigTestClass = Class + .forName("com.sun.tdk.signaturetest.SignatureTest"); + Object sigTestInstance = sigTestClass.newInstance(); + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + + // we want to replace the PACKAGE_FLAG with PACKAGE_NO_SUBS_FLAG + for (int ii = 0; ii < testArguments.length; ii++) { + if (testArguments[ii].equals(PACKAGE_FLAG)) { + testArguments[ii] = PACKAGE_NO_SUBS_FLAG; + } + } + + // dump args for debugging aid + System.out.println( + "\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); + for (int ii = 0; ii < testArguments.length; ii++) { + System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + } + + @SuppressWarnings("unchecked") + Method runMethod = sigTestClass.getDeclaredMethod("run", + new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); + runMethod.invoke(sigTestInstance, + new Object[] { testArguments, new PrintWriter(output, true), null }); + + String rawMessages = output.toString(); + + // currently, there is no way to determine if there are error msgs in + // the rawmessages, so we will always dump this and call it a status. + System.out.println( + "********** Status Report '" + packageOrClassName + "' **********\n"); + System.out.println(rawMessages); + return sigTestInstance.toString().substring(7).startsWith("Passed."); + } + + @Override + protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) + throws Exception { + // Need to find out whether implementing this method is really required now. + // By default, signature test framework will use sigtest + return true; + } + +} // END ApiCheckDriver
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/ApiCheckRecorder.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/ApiCheckRecorder.java new file mode 100644 index 0000000..20fa721 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/ApiCheckRecorder.java
@@ -0,0 +1,75 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +/** + * <p> + * This implementation of {@link Recorder} will record signatures using the + * <code>ApiCheck</code> framework. + * </p> + */ +public class ApiCheckRecorder extends Recorder { + + // ------------------------------------------------------------ Constructors + + public ApiCheckRecorder(String[] args) { + + super(args); + System.setProperty("pkg.list.file.path", packageListFile); + System.setProperty("map.file.path", signatureMapFile); + System.setProperty("signature.repository.dir", signatureRepositoryDir); + + } // END ApiCheckRecorder + + // ------------------------------------------------------- Protected Methods + + protected String[] createCommandLine(String version, String classpath, + String outputFileName, String packageName) { + + List command = new ArrayList(); + + command.add("-constvalues"); + command.add("-xpriv"); + + command.add("-in"); + command.add(classpath); + + return ((String[]) command.toArray(new String[command.size()])); + + } // END getCommandLine + + protected void writePackageListFile(String basePackageName, + String signatureFile, String packageListFile) throws Exception { + + // no-op as this is done internally by our version of ApiCheck + + } // END writePackageListFile + + protected void doRecord(String[] commandLine) throws Exception { + + Class batchSetup = Class.forName("javasoft.sqe.apiCheck.BatchSetup"); + Method mainMethod = batchSetup.getDeclaredMethod("main", + new Class[] { String[].class }); + mainMethod.invoke(null, new Object[] { commandLine }); + + } // END doRecord + +} // END SigTestRecorder
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/PackageList.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/PackageList.java new file mode 100644 index 0000000..89732c2 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/PackageList.java
@@ -0,0 +1,430 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.FileWriter; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; + +/** + * This class represents a package list file. A package list file is used in + * conjunction with a set of signature files to execute API signature tests. + * Users specify which set of package APIs are verified. Each package's + * signature is verified independently. As such all valid sub-packages must be + * excluded while a package's signature is being verified. This allows API check + * to determine incompatible additional packages included in a distribution. + * <p/> + * This class builds a package list file when signatures are recorded and + * provides an API to provide valid sub-package lists when signatures are played + * back (verified). + * <p/> + * In record mode, this class reads the existing package list file, if one + * exists, and removes the package (as well as sub-packages) that are currently + * being recorded. All package names read from the existing package list file + * are held in a tree set which sorts the package names and keeps duplicate + * package names from ocurring. The user can then instruct this class to write + * out the package list file. At this point this class reads the currently + * recorded signature file and extracts each package names and adds it to the + * tree set. After this step the previous package list file is saved as a backup + * and the new package list file is written to disk. + * <p/> + * In playback mode, this class reads the contents of the package list file and + * stores each package name in a tree set. Users can then invoke the + * getSubPackages method to retrieve the valid sub-packages for any given + * package. This is done by simply examining the package names in the tree set + * and returning any package name that starts with the parent package name and a + * trailing period character. + */ +class PackageList { + + // Any line in the packageFile starting with this character is a comment + private static final char COMMENT_CHAR = '#'; + + private static final String BACKUP_EXT = ".bak"; + + // File containing the list of packages and sub-packages + private File packageFile; + + // Signature file where the package signatures were recorded + private File sigFile; + + // Name of the package being recorded + private String additionalPackageName; + + // Name of packages and sub-packages in the + private Set packageNames = new TreeSet(); + + /** + * Creates an instance of the PackageList class. The PackageList instance + * reads the specified package file and populates it's internal state with the + * package names found in this file. Users should use this c'tor when playing + * back signature files. Users can init the PackageList instance then use the + * "String[] getSubPackages(String packageName)" method to get the list of + * valid sub-packages for every package who's signature is being verified. + * + * @param packageFileName + * The name of the file that contains the package list. This file + * contains the names of all the packages that exist across all the + * signature files that makeup this deliverable. This file is used to + * generate a list of valid sub-packages that must be exclued when + * testing theor parent package's signature. + * + * @throws Exception + * when the packageFileName does not exist. + */ + public PackageList(String packageFileName) throws Exception { + packageFile = new File(packageFileName); + if (packageFile.exists() && packageFile.isFile()) { + extractExistingPackageNames(); + } else { + throw new FileNotFoundException(packageFileName); + } + } + + /** + * Creates an instance of the PackageList class. The PackageList instance + * reads the contents of the packageFileName and stores it in it's internal + * state. Next, any packages whos name starts with the specified packageName + * are removed from the internal package list. This is done because this is + * the package being recorded and we need to remove any previously recorded + * package names in case any sub-packages have been removed since the last + * time the signatures were recorded. Users should use this c'tor when they + * are recording signature files never during playback. + * + * @param packageName + * The name of the package whos signatures are being recorded (along + * with sub-packages). + * @param sigFileName + * The name of the file that contains the recored signatures. + * @param packageFileName + * The name of the file that contains the package list. This file + * contains the names of all the packages that exist across all the + * signature files that makeup this deliverable. This file is used to + * generate a list of valid sub-packages that must be exclued when + * testing their parent package's signature. + * + * @throws Exception + * when an error occurs reading the packageFileName or the + * sigFileName does not exist. + */ + public PackageList(String packageName, String sigFileName, + String packageFileName) throws Exception { + this.additionalPackageName = packageName; + sigFile = new File(sigFileName); + if (!sigFile.exists() || !sigFile.isFile()) { + throw new FileNotFoundException(sigFileName); + } + packageFile = new File(packageFileName); + if (packageFile.exists() && packageFile.isFile()) { + extractExistingPackageNames(); + removeExistingPackage(); + } + } + + /** + * Read the package names stored in the package list file. Each package name + * found in the package list file is added to the internal tree set. + * + * @throws Exception + * if there is an error opening or reading the package list file. + */ + private void extractExistingPackageNames() throws Exception { + BufferedReader in = new BufferedReader(new FileReader(packageFile)); + String line; + String trimLine; + try { + while ((line = in.readLine()) != null) { + trimLine = line.trim(); + if (isComment(trimLine) || "".equals(trimLine)) { + continue; + } + packageNames.add(trimLine); + } + } finally { + try { + in.close(); + } catch (Exception e) { + } + } + } + + /** + * Returns true if the specified string starts with a comment character as + * denoted by the COMMENT_CHAR constant. + * + * @param line + * Determins of this line is a comment line + * + * @return boolean True if the specified line is a comment line else false. + */ + private boolean isComment(String line) { + if (line == null) { + return false; + } + String theLine = line.trim(); + if (theLine.length() > 0) { + return (theLine.charAt(0) == COMMENT_CHAR); + } + + return false; + } + + /** + * Removes package names from the package list file. The packages that are + * removed are the ones currently being recorded. The packages being recorded + * is denoted by this.additionalPackageName. This includes any sub-packages of + * the additionalPackageName. This step is necessary in the cases where a + * sub-package has been removed from a parent package in between signature + * recordings. + */ + private void removeExistingPackage() { + String delPackage = this.additionalPackageName; + String packageName; + List delPkgs = new ArrayList(); + // iterate over package set and find package names to remove + for (Iterator i = packageNames.iterator(); i.hasNext();) { + packageName = (String) i.next(); + if (packageName.startsWith(delPackage)) { + delPkgs.add(packageName); + } + } + // actually remove the package names from the set + for (int i = 0; i < delPkgs.size(); i++) { + packageName = (String) (delPkgs.get(i)); + packageNames.remove(packageName); + System.out.println( + "PackageList.removeExistingPackage() \"" + packageName + "\""); + } + } + + /** + * Write the package list out to the package list file. This is done by + * reading all the package names in the specified signature file and adding + * them to the internal tree set. Then the old package list file is removed + * and the new package list file is written out. + * + * @throws Exception + * if there is a problem removing the existing package file or + * writting the new package list file. + */ + public void writePkgListFile() throws Exception { + readPkgsFromSigFile(); + removePkgFile(); + writePkgFile(); + } + + /** + * Extract the package name from the specified string. The specified string + * should have the form: "package jakarta.ejb;" + * + * @param packageLine + * The string containing the package name. + * + * @return String The extracted package name. + * + * @throws Exception + * if the specified string does not conform to the expected format. + */ + private String parsePackageName(String packageLine) throws Exception { + + // sig test framework doesn't have the concept of package entries + // as the ApiCheck signature format does. + // Instead, we need to parse an entry similar to this: + // CLSS public jakarta.some.package.SomeClass + + return packageLine.substring(packageLine.lastIndexOf(' ') + 1, + packageLine.lastIndexOf('.')); + } + + /** + * Reads the package names from the signature file. Each package name that is + * read is added to this classes internal tree set. + * + * @throws Exception + * if there is an error opening or reading the signature file. + */ + private void readPkgsFromSigFile() throws Exception { + BufferedReader in = new BufferedReader(new FileReader(sigFile)); + String line; + String trimLine; + try { + while ((line = in.readLine()) != null) { + trimLine = line.trim(); + if (trimLine.startsWith("CLSS")) { + packageNames.add(parsePackageName(trimLine)); + } + } + } finally { + try { + in.close(); + } catch (Exception e) { + } + } + } + + /** + * Removes the existing package list file. The package list file is actually + * moved to a backup file if it exists. The old backup is lost. + * + * @throws Exception + * if there is an error moving the current package list file to a + * backup file. + */ + private void removePkgFile() throws Exception { + File backupPkgFile = new File(packageFile.getPath() + BACKUP_EXT); + if (backupPkgFile.exists() && backupPkgFile.isFile()) { + backupPkgFile.delete(); + } + if (packageFile.isFile() && packageFile.exists()) { + File copyPackageFile = new File(packageFile.getPath()); + copyPackageFile.renameTo(backupPkgFile); + } + } + + /** + * Write a simple header to the package list file to explain what the file is. + * + * @param out + * The BufferedWriter to dump the header to. + * + * @throws Exception + * if there is any errors writing the header to the specified + * BufferedWriter. + */ + private void writeHeader(BufferedWriter out) throws Exception { + out.write(COMMENT_CHAR); + out.write(COMMENT_CHAR); + out.newLine(); + out.write(COMMENT_CHAR + " This file contains a list of all the packages"); + out.newLine(); + out.write(COMMENT_CHAR + " contained in the signature files for this"); + out.newLine(); + out.write( + COMMENT_CHAR + " deliverable. This file is used to exclude valid"); + out.newLine(); + out.write(COMMENT_CHAR + " sub-packages from being verified when their"); + out.newLine(); + out.write(COMMENT_CHAR + " parent package's signature is checked."); + out.newLine(); + out.write(COMMENT_CHAR); + out.write(COMMENT_CHAR); + out.newLine(); + out.newLine(); + } + + /** + * Write the list of package names out to a package list file. + * + * @throws Exception + * if there is an error creating and writting the package list file. + */ + private void writePkgFile() throws Exception { + BufferedWriter out = null; + try { + out = new BufferedWriter(new FileWriter(packageFile)); + writeHeader(out); + for (Iterator i = packageNames.iterator(); i.hasNext();) { + String packageName = (String) i.next(); + out.write(packageName); + out.newLine(); + System.out + .println("PackageList.writePkgFile() \"" + packageName + "\""); + } + } finally { + if (out != null) { + out.close(); + } + } + } + + /** + * Returns the list of sub-packages that exist in the specified package name. + * + * @param pkgName + * The name of the package we want the sub-package list for. + * + * @return String[] The sub-packages that live under the specified parent + * package. + */ + public String[] getSubPackages(String pkgName) { + List result = new ArrayList(); + String subPackageName = pkgName + "."; + for (Iterator i = packageNames.iterator(); i.hasNext();) { + String packageName = (String) i.next(); + if (packageName.startsWith(subPackageName)) { + result.add(packageName); + } + } + return (String[]) (result.toArray(new String[result.size()])); + } + + /** + * Returns the list of sub-packages that exist in the specified package name. + * The returned string matches the API check format of specifying multiple + * packages with a single string. Each package name is separated with the "+" + * character. + * + * @param pkgName + * The name of the package we want the sub-package list for. + * + * @return String The sub-packages that live under the specified parent + * package. + */ + public String getSubPackagesFormatted(String pkgName) { + StringBuffer formattedResult = new StringBuffer(); + String[] result = getSubPackages(pkgName); + for (int i = 0; i < result.length; i++) { + formattedResult.append(result[i]); + if (i < (result.length - 1)) { + formattedResult.append("+"); + } + } + return formattedResult.toString(); + } + + /* + * Test Driver + */ + public static void main(String[] args) throws Exception { + System.out.println("\n\n*** Creating package list file ***\n\n"); + PackageList list = new PackageList("jakarta.ejb", + "/home/ryano/cts-tools-master/tools/api-check/test/jakarta.ejb.sig_2.1", + "/home/ryano/cts-tools-master/tools/api-check/test/pkg-list.txt"); + list.writePkgListFile(); + + System.out + .println("\n\n*** Reading sub-packages from package list file ***\n\n"); + PackageList readList = new PackageList( + "/home/ryano/cts-tools-master/tools/api-check/test/pkg-list.txt"); + System.out.println(Arrays.asList(readList.getSubPackages("jakarta.ejb"))); + System.out.println(readList.getSubPackagesFormatted("jakarta.ejb")); + } + +} // end class PackageList
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/README b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/README new file mode 100644 index 0000000..3fe6f32 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/README
@@ -0,0 +1,50 @@ +The latest signature files are updated in the jsonb-api repoitory +(jsonb-api/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest) +generated using sigtest-maven-plugin.jar(version 1.4). + +The signature tests are run using the sigtest-maven-plugin.jar and the framework avaliable in this folder. + + + +For TCK developers :- + + 1. Generate Signature Files : The signature file will be generated by the TCK team using tck/pom.xml + where the below commented code can be used. The classpath should contain the api jar for which we are generating the signature file. + + <!--plugin> + <groupId>org.netbeans.tools</groupId> + <artifactId>sigtest-maven-plugin</artifactId> + <version>1.4</version> + <executions> + <execution> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + <configuration> + <FileName>${project.build.directory}/jakarta.json.bind.sig_${version}</FileName> + <packages>"jakarta.json.bind","jakarta.json.bind.adapter","jakarta.json.bind.annotation","jakarta.json.bind.config","jakarta.json.bind.serializer","jakarta.json.bind.spi"</packages> + </configuration> + </plugin--> + + The signature file name expected is jakarta.json.bind.sig_${version} , where version is the api version for which the signature is generated. + +For TCK users (to run the signature test as a Junit test) :- + + 1. Set the below system properties correctly : + + jimage.dir //The jdk9+(jdk11 for this release) will be extracted to this location as to use the Java modules in the path. + optional.tech.packages.to.ignore // The optional package that should be ignored while running the signature test + signature.sigTestClasspath // the sigTestClasspath that will contain the implementation jar that needs to be tested along with dependent jars. + + For eg: + + <jimage.dir>${project.build.directory}/jdk11-bundle</jimage.dir> + <signature.sigTestClasspath>${project.build.directory}/signaturedirectory/jakarta.json.bind-api.jar:${project.build.directory}/jdk11-bundle/java.base:${project.build.directory}/jdk11-bundle/java.rmi:${project.build.directory}/jdk11-bundle/java.sql:${project.build.directory}/jdk11-bundle/java.naming</signature.sigTestClasspath> + + 2. The signature test alone can be run using below command within impl-tck/ directory. + + mvn clean test -Dtest=ee.jakarta.tck.json.bind.signaturetest.jsonb.JSONBSigTest#signatureTest + + \ No newline at end of file
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/Recorder.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/Recorder.java new file mode 100644 index 0000000..cd71334 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/Recorder.java
@@ -0,0 +1,282 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Properties; + +public abstract class Recorder { + + protected Properties signatureMap; + + protected String packageListFile; + + protected String classpath; + + protected String signatureRepositoryDir; + + protected String signatureMapFile; + + // ------------------------------------------------------------ Constructors + + public Recorder(String[] args) { + + System.out.println("\nCalling: Recorder with following args:"); + for (int ii = 0; ii < args.length; ii++) { + System.out.println(" args[" + ii + "] = " + args[ii]); + } + + Arguments arguments = new Arguments(args); + packageListFile = arguments.getPackageList(); + classpath = arguments.getClasspath(); + signatureRepositoryDir = arguments.getRepository(); + signatureMapFile = arguments.getSignatureMap(); + loadSignatureMap(signatureMapFile); + } + + // ---------------------------------------------------------- Public Methods + + /** + * <p> + * Record the signatures for each package listed in the + * <code>TS_HOME/bin/sig-test.map</code> file. + * </p> + */ + public void batchRecord() { + + for (Iterator i = signatureMap.keySet().iterator(); i.hasNext();) { + String basePackageName = (String) i.next(); + String version = (String) signatureMap.get(basePackageName); + String outputFileName = getOutputFileName(basePackageName, version); + String[] commandLine = createCommandLine(version, classpath, + outputFileName, basePackageName); + + try { + + // dump command line args passed to Setup()... + System.out.println("\n\nDUMPING SIGTEST COMMAND LINE: \n"); + for (int ii = 0; ii < commandLine.length; ii++) { + System.out.println("commandLine[" + ii + "] = " + commandLine[ii]); + } + System.out.println("\nDONE DUMPING SIGTEST COMMAND LINE. \n\n"); + + doRecord(commandLine); + } catch (Exception e) { + throw new RuntimeException(e); + } + + try { + writePackageListFile(basePackageName, outputFileName, packageListFile); + } catch (Exception e) { + System.out.println("Unexpected exception: " + e); + e.printStackTrace(); + System.exit(1); + } + } + + } // END batchRecord + + // ------------------------------------------------------- Protected Methods + + /** + * Write, to a separate file, all of the packages that were recorded. How this + * is accomplised will be dependent on the framework. + * + * @param basePackageName + * the base package + * @param signatureFile + * the file in which the signatures were recorded to + * @param packageListFile + * the name of the package list file (which may or may not exist) + * @throws Exception + * if an error occurs writing the file + */ + protected abstract void writePackageListFile(String basePackageName, + String signatureFile, String packageListFile) throws Exception; + + /** + * Create a array of arguments appropriate for use with different signature + * recording frameworks. + * + * @param version + * The version of the API + * @param classpath + * the classpath containing classes that will be recorded + * @param outputFileName + * the file in which to write the recorded signatures to + * @param packageName + * the base package name of the signatures that will be recorded + */ + protected abstract String[] createCommandLine(String version, + String classpath, String outputFileName, String packageName); + + /** + * Perform whatever action in necessary to do the actual recording of the + * signatures. + * + * @param commandLine + * the options to invoke the recording facility + * @throws Exception + * if an error occurs during the record process + */ + protected abstract void doRecord(String[] commandLine) throws Exception; + + // --------------------------------------------------------- Private Methods + + private void loadSignatureMap(String signatureTestMapFile) { + + signatureMap = new Properties(); + try { + signatureMap.load( + new BufferedInputStream(new FileInputStream(signatureTestMapFile))); + } catch (FileNotFoundException fnfe) { + throw new RuntimeException( + "Unable to find or read file '" + signatureTestMapFile + '\''); + } catch (IOException ioe) { + throw new RuntimeException( + "Error processing file '" + signatureTestMapFile + '\'', ioe); + } + + } // END loadSignatureMap + + private String getOutputFileName(String name, String version) { + + StringBuffer fileName = new StringBuffer(); + fileName.append(signatureRepositoryDir).append(File.separatorChar); + fileName.append(name).append(".sig_").append(version); + return fileName.toString(); + + } // END getOutputFileName + + // --------------------------------------------------- Static Nested Classes + + private static class Arguments { + + private static final String CLASSPATH_ARG = "-classpath"; + + private static final String PKG_LIST_ARG = "-packagelist"; + + private static final String SIG_MAP_ARG = "-sigmap"; + + private static final String REPOSITORY_ARG = "-repository"; + + private String classpath; + + private String packageList; + + private String signatureMap; + + private String repository; + + // -------------------------------------------------------- Constructors + + Arguments(String[] args) { + + // all 4 arguments must be defined, thus there should be 8 elements + if (args.length != 8) { + System.out + .println("Error - incorrect number of args should be 8 but was: " + + args.length); + System.out.println("Args passed in were: "); + for (int ii = 0; ii < args.length; ii++) { + System.out.println("args[" + ii + "] = " + args[ii]); + } + + throw new IllegalArgumentException(); + } + + String[] clonedArgs = (String[]) args.clone(); + Arrays.sort(clonedArgs); + // ensure the proper arguments are specified + if (Arrays.binarySearch(clonedArgs, CLASSPATH_ARG) < 0 + || Arrays.binarySearch(clonedArgs, PKG_LIST_ARG) < 0 + || Arrays.binarySearch(clonedArgs, SIG_MAP_ARG) < 0 + || Arrays.binarySearch(clonedArgs, REPOSITORY_ARG) < 0) { + usage(); + System.exit(1); + } + + for (int i = 0; i < args.length; i += 2) { + if (CLASSPATH_ARG.equals(args[i])) { + classpath = args[i + 1]; + } else if (PKG_LIST_ARG.equals(args[i])) { + packageList = args[i + 1]; + } else if (SIG_MAP_ARG.equals(args[i])) { + signatureMap = args[i + 1]; + } else if (REPOSITORY_ARG.equals(args[i])) { + repository = args[i + 1]; + } else { + // shouldn't get here + usage(); + System.exit(1); + } + } + + } // END Arguments + + // ---------------------------------------------------------- Properties + + public String getClasspath() { + + return classpath; + + } // END getClasspath + + public String getPackageList() { + + return packageList; + + } // END getPackageList + + public String getSignatureMap() { + + return signatureMap; + + } // END getSignatureMap + + public String getRepository() { + + return repository; + + } // END getRepository + + private static void usage() { + + String usage = "Usage:" + + "\t-classpath (classpath to JARs and/or classes under test)\n" + + "\t-packageList (Reference to the sig-test-pkg-list.txt file)\n" + + "\t-sigmap (Reference to the sig-test.map file)\n" + + "\t-repository (Directory in which to write the recorded" + + "\tsignatures to)\n\n"; + + System.err.println(usage); + + } // END usage + + } // END Arguments + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/RecorderFactory.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/RecorderFactory.java new file mode 100644 index 0000000..5d55c65 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/RecorderFactory.java
@@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +/** + * <p> + * This class is a bit overloaded in that it serves as both a factory and entry + * point from Ant to handle signature recording. + * </p> + * + * <p> + * The desired <code>type</code> is provided using a system property with a key + * of <code>recorder.type</code>. Valid values for the + * <code>recorder.type</code> property are: + * <ul> + * <li>apicheck</li> + * <li>sigtest</li> + * </ul> + * </p> + * + * <p> + * If the <code>recorder.type</code> property is not set, this factory will + * return a <code>SignatureTestRecorder</code> using the SigTest framework. + * </p> + */ +public class RecorderFactory { + + public static final String API_CHECK_RECORDER = "apicheck"; + + public static final String SIG_TEST_RECORDER = "sigtest"; + + // ---------------------------------------------------------- Public Methods + + /** + * Returns a {@link Recorder} instance to handle recording signatures based on + * the value specified via the <code>type</code> argument. + * + * @param type + * the type of {@link Recorder} to use + * @param args + * the args to pass to the {@link Recorder} + * @return a {@link Recorder} instanced based on the <code>type</code> + * provided + */ + public static Recorder getRecorder(String type, String[] args) { + + if (type == null) { + throw new IllegalArgumentException("'type' cannot be null"); + } + + if (type.equals(API_CHECK_RECORDER)) { + return new ApiCheckRecorder(args); + } else if (type.equals(SIG_TEST_RECORDER)) { + return new SigTestRecorder(args); + } else { + throw new IllegalArgumentException("Unknown type: " + type); + } + + } // END getRecorder + + public static void main(String[] args) { + + String type = System.getProperty("recorder.type", SIG_TEST_RECORDER); + Recorder recorder = getRecorder(type, args); + recorder.batchRecord(); + + } // END main + +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTest.java new file mode 100644 index 0000000..62957cd --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTest.java
@@ -0,0 +1,392 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.io.PrintStream; + +import java.util.ArrayList; +import java.util.Properties; + + +/** + * This class should be extended by TCK developers that wish to create a set of + * signature tests that run outside of any Java EE container. Developers must + * implement the getPackages method to specify which packages are to be tested + * by the signature test framework. + */ +public abstract class SigTest { + + protected SignatureTestDriver driver; + + /** + * <p> + * Returns a {@link SignatureTestDriver} appropriate for the particular TCK + * (using API check or the Signature Test Framework). + * </p> + * + * <p> + * The default implementation of this method will return a + * {@link SignatureTestDriver} that will use API Check. TCK developers can + * override this to return the desired {@link SignatureTestDriver} for their + * TCK. + */ + protected SignatureTestDriver getSigTestDriver() { + + if (driver == null) { + driver = SignatureTestDriverFactory.getInstance(SignatureTestDriverFactory.SIG_TEST); + } + + return driver; + + } // END getSigTestDriver + + /** + * Returns the location of the package list file. This file denotes the valid + * sub-packages of any package being verified in the signature tests. + * + * Sub-classes are free to override this method if they use a different path + * or filename for their package list file. Most users should be able to use + * this default implementation. + * + * @return String The path and name of the package list file. + */ + protected String getPackageFile() { + return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir()); + } + + /** + * Returns the path and name of the signature map file that this TCK uses when + * conducting signature tests. The signature map file tells the signature test + * framework which API versions of tested packages to use. To keep this code + * platform independent, be sure to use the File.separator string (or the + * File.separatorChar) to denote path separators. + * + * Sub-classes are free to override this method if they use a different path + * or filename for their signature map file. Most users should be able to use + * this default implementation. + * + * @return String The path and name of the signature map file. + */ + protected String getMapFile() { + return getSigTestDriver().getMapFileImpl(testInfo.getBinDir()); + } + + /** + * Returns the directory that contains the signature files. + * + * Sub-classes are free to override this method if they use a different + * signature repository directory. Most users should be able to use this + * default implementation. + * + * @return String The signature repository directory. + */ + protected String getRepositoryDir() { + return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome()); + } + + /** + * Returns the list of Optional Packages which are not accounted for. By + * 'unlisted optional' we mean the packages which are Optional to the + * technology under test that the user did NOT specifically list for testing. + * For example, with Java EE 7 implementation, a user could additionally opt + * to test a JSR-88 technology along with the Java EE technology. But if the + * user chooses NOT to list this optional technology for testing (via ts.jte + * javaee.level prop) then this method will return the packages for JSR-88 + * technology with this method call. + * <p/> + * This is useful for checking for a scenarios when a user may have forgotten + * to identify a whole or partial technology implementation and in such cases, + * Java EE platform still requires testing it. + * <p/> + * Any partial or complete impl of an unlistedOptionalPackage sends up a red + * flag indicating that the user must also pass tests for this optional + * technology area. + * <p/> + * Sub-classes are free to override this method if they use a different + * signature repository directory. Most users should be able to use this + * default implementation - which means that there was NO optional technology + * packages that need to be tested. + * + * @return ArrayList<String> + */ + protected ArrayList<String> getUnlistedOptionalPackages() { + return null; + } + + /** + * Returns the list of packages that must be tested by the siganture test + * framework. TCK developers must implement this method in their signature + * test sub-class. + * + * @return String A list of packages that the developer wishes to test using + * the signature test framework. + */ + protected abstract String[] getPackages(); + + /** + * Returns an array of individual classes that must be tested by the signature + * test framwork. TCK developers may override this method when this + * functionality is needed. Most will only need package level granularity. + * + * @return an Array of Strings containing the individual classes the framework + * should test. The default implementation of this method returns a + * zero-length array. + */ + protected String[] getClasses() { + + return new String[] {}; + + } // END getClasses + + protected SigTestData testInfo; // holds the bin.dir property + + /** + * Called by the test framework to initialize this test. The method simply + * retrieves some state information that is necessary to run the test when + * when the test framework invokes the run method (actually the test1 method). + * + * @param args + * List of arguments passed to this test. + * @param p + * Properties specified by the test user and passed to this test via + * the test framework. + * @throws Fault + * When an error occurs reading or saving the state information + * processed by this method. + */ + public void setup() { + try { + System.out.println("$$$ SigTest.setup() called"); + this.testInfo = new SigTestData(); + System.out.println("$$$ SigTest.setup() complete"); + } catch (Exception e) { + System.out.println("Unexpected exception " + e.getMessage()); + //throw new Fault("setup failed!", e); + } + } + + + /** + * Called by the test framework to cleanup any outstanding state. This method + * simply passes the message through to the utility class so the + * implementation can be used by both framework base classes. + * + * @throws Fault + * When an error occurs cleaning up the state of this test. + */ + public void cleanup() throws Fault { + System.out.println("$$$ SigTest.cleanup() called"); + try { + getSigTestDriver().cleanupImpl(); + System.out.println("$$$ SigTest.cleanup() returning"); + } catch (Exception e) { + throw new Fault("Cleanup failed!", e); + } + } + + public static class Fault extends Exception { + private static final long serialVersionUID = -1574745208867827913L; + + public Throwable t; + + /** + * creates a Fault with a message + */ + public Fault(String msg) { + super(msg); + System.out.println(msg); + } + + /** + * creates a Fault with a message. + * + * @param msg + * the message + * @param t + * prints this exception's stacktrace + */ + public Fault(String msg, Throwable t) { + super(msg); + this.t = t; + // System.out.println(msg, t); + } + + /** + * creates a Fault with a Throwable. + * + * @param t + * the Throwable + */ + public Fault(Throwable t) { + super(t); + this.t = t; + } + + /** + * Prints this Throwable and its backtrace to the standard error stream. + * + */ + public void printStackTrace() { + if (this.t != null) { + this.t.printStackTrace(); + } else { + super.printStackTrace(); + } + } + + /** + * Prints this throwable and its backtrace to the specified print stream. + * + * @param s + * <code>PrintStream</code> to use for output + */ + public void printStackTrace(PrintStream s) { + if (this.t != null) { + this.t.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + /** + * Prints this throwable and its backtrace to the specified print writer. + * + * @param s + * <code>PrintWriter</code> to use for output + */ + public void printStackTrace(PrintWriter s) { + if (this.t != null) { + this.t.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + @Override + public Throwable getCause() { + return t; + } + + @Override + public synchronized Throwable initCause(Throwable cause) { + if (t != null) + throw new IllegalStateException("Can't overwrite cause"); + if (!Exception.class.isInstance(cause)) + throw new IllegalArgumentException("Cause not permitted"); + this.t = (Exception) cause; + return this; + } + } + + /** + * This exception is used only by EETest. Overrides 3 printStackTrace methods + * to preserver the original stack trace. Using setStackTraceElement() would + * be more elegant but it is not available prior to j2se 1.4. + * + * @author Kyle Grucci + */ + public static class SetupException extends Exception { + private static final long serialVersionUID = -7616313680616499158L; + + public Exception e; + + /** + * creates a Fault with a message + */ + public SetupException(String msg) { + super(msg); + } + + /** + * creates a SetupException with a message + * + * @param msg + * the message + * @param e + * prints this exception's stacktrace + */ + public SetupException(String msg, Exception e) { + super(msg); + this.e = e; + } + + /** + * Prints this Throwable and its backtrace to the standard error stream. + * + */ + public void printStackTrace() { + if (this.e != null) { + this.e.printStackTrace(); + } else { + super.printStackTrace(); + } + } + + /** + * Prints this throwable and its backtrace to the specified print stream. + * + * @param s + * <code>PrintStream</code> to use for output + */ + public void printStackTrace(PrintStream s) { + if (this.e != null) { + this.e.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + /** + * Prints this throwable and its backtrace to the specified print writer. + * + * @param s + * <code>PrintWriter</code> to use for output + */ + public void printStackTrace(PrintWriter s) { + if (this.e != null) { + this.e.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + @Override + public Throwable getCause() { + return e; + } + + @Override + public synchronized Throwable initCause(Throwable cause) { + if (e != null) + throw new IllegalStateException("Can't overwrite cause"); + if (!Exception.class.isInstance(cause)) + throw new IllegalArgumentException("Cause not permitted"); + this.e = (Exception) cause; + return this; + } + } + +} // end class SigTest
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestData.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestData.java new file mode 100644 index 0000000..b94503a --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestData.java
@@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +import java.util.Properties; + +/** + * This class holds the data passed to a signature test invocation during the + * setup phase. This allows us to keep the passed data separate and reuse the + * data between the signature test framework base classes. + */ +public class SigTestData { + + private Properties props; + + public SigTestData() { + this.props = System.getProperties();; + } + + public String getVehicle() { + return props.getProperty("vehicle", ""); + } + + public String getBinDir() { + return props.getProperty("bin.dir", ""); + } + + public String getTSHome() { + return props.getProperty("ts_home", ""); + } + + public String getTestClasspath() { + return props.getProperty("sigTestClasspath", ""); + } + + public String getJavaeeLevel() { + return props.getProperty("javaee.level", ""); + } + + public String getCurrentKeywords() { + return props.getProperty("current.keywords", ""); + } + + public String getProperty(String prop) { + return props.getProperty(prop); + } + + public String getOptionalTechPackagesToIgnore() { + return props.getProperty("optional.tech.packages.to.ignore", "jakarta.xml.bind"); + } + + public String getJtaJarClasspath() { + return props.getProperty("jtaJarClasspath", ""); + } + + public String getJImageDir() { + return props.getProperty("jimage.dir", ""); + } +} // end class SigTestData
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestDriver.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestDriver.java new file mode 100644 index 0000000..db70a8e --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestDriver.java
@@ -0,0 +1,281 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + + +/** + * <p> + * Wrapper for the <code>Sig Test</code> framework. + * </p> + */ +public class SigTestDriver extends SignatureTestDriver { + + private static final String CLASSPATH_FLAG = "-Classpath"; + + private static final String FILENAME_FLAG = "-FileName"; + + private static final String PACKAGE_FLAG = "-Package"; + + private static final String PACKAGE_NO_SUBS_FLAG = "-PackageWithoutSubpackages"; + + private static final String API_VERSION_FLAG = "-ApiVersion"; + + private static final String EXCLUDE_FLAG = "-Exclude"; + + private static final String STATIC_FLAG = "-Static"; + + private static final String CHECKVALUE_FLAG = "-CheckValue"; // only valid w/ + // -static + + private static final String NO_CHECKVALUE_FLAG = "-NoCheckValue"; + + private static final String SMODE_FLAG = "-mode"; // requires arg of bin or + // src + + private static final String DEBUG_FLAG = "-Debug"; + + private static final String FORMATPLAIN_FLAG = "-FormatPlain"; + + private static final String EXCLUDE_JDK_CLASS_FLAG = "-IgnoreJDKClass"; + + private static String[] excludeJdkClasses = { + "java.util.Map", + "java.lang.Object", + "java.io.ByteArrayInputStream", + "java.io.InputStream", + "java.lang.Deprecated", + "java.io.Writer", + "java.io.OutputStream", + "java.util.List", + "java.util.Collection", + "java.lang.instrument.IllegalClassFormatException", + "javax.transaction.xa.XAException", + "java.lang.annotation.Repeatable", + "java.lang.InterruptedException", + "java.lang.CloneNotSupportedException", + "java.lang.Throwable", + "java.lang.Thread", + "java.lang.Enum" + }; + + // ---------------------------------------- Methods from SignatureTestDriver + + @Override + protected String normalizeFileName(File f) { + String sURL = null; + try { + sURL = f.toURI().toURL().toExternalForm(); + } catch (Exception e) { + throw new RuntimeException(e); + } + return sURL; + } + + @Override + protected String[] createTestArguments(String packageListFile, String mapFile, + String signatureRepositoryDir, String packageOrClassUnderTest, + String classpath, boolean bStaticMode) throws Exception { + + SignatureFileInfo info = getSigFileInfo(packageOrClassUnderTest, mapFile, + signatureRepositoryDir); + + PackageList packageList = new PackageList(packageListFile); + String[] subPackages = packageList.getSubPackages(packageOrClassUnderTest); + + List command = new ArrayList(); + + if (bStaticMode) { + // static mode allows finer level of constants checking + // -CheckValue says to check the actual const values + System.out.println("Setting static mode flag to allow constant checking."); + command.add(STATIC_FLAG); + command.add(CHECKVALUE_FLAG); + + // specifying "-mode src" allows stricter 2 way verification of constant + // vals + // (note that using "-mode bin" mode is less strict) + command.add(SMODE_FLAG); + // command.add("bin"); + command.add("src"); + } else { + System.out.println("Not Setting static mode flag to allow constant checking."); + } + + command.add("-Verbose"); + + command.add(FILENAME_FLAG); + command.add(info.getFile()); + + command.add(CLASSPATH_FLAG); + command.add(classpath); + + command.add(PACKAGE_FLAG); + command.add(packageOrClassUnderTest); + + for (int i = 0; i < subPackages.length; i++) { + command.add(EXCLUDE_FLAG); + command.add(subPackages[i]); + } + + for(String jdkClassName:excludeJdkClasses) { + command.add(EXCLUDE_JDK_CLASS_FLAG); + command.add(jdkClassName); + } + + + command.add(API_VERSION_FLAG); + command.add(info.getVersion()); + + return ((String[]) command.toArray(new String[command.size()])); + + } // END createTestArguments + + @Override + protected boolean runSignatureTest(String packageOrClassName, + String[] testArguments) throws Exception { + + Class sigTestClass = Class + .forName("com.sun.tdk.signaturetest.SignatureTest"); + Object sigTestInstance = sigTestClass.newInstance(); + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + + // do some logging to help with troubleshooting + System.out.println( + "\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); + for (int ii = 0; ii < testArguments.length; ii++) { + System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + } + + @SuppressWarnings("unchecked") + Method runMethod = sigTestClass.getDeclaredMethod("run", + new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); + runMethod.invoke(sigTestInstance, + new Object[] { testArguments, new PrintWriter(output, true), null }); + + String rawMessages = output.toString(); + + // currently, there is no way to determine if there are error msgs in + // the rawmessages, so we will always dump this and call it a status. + System.out.println( + "********** Status Report '" + packageOrClassName + "' **********\n"); + System.out.println(rawMessages); + + return sigTestInstance.toString().substring(7).startsWith("Passed."); + } // END runSignatureTest + + /* + * + * @return This returns true if the packageOrClassName is found in the impl. + */ + @Override + protected boolean runPackageSearch(String packageOrClassName, + String[] testArguments) throws Exception { + + Class sigTestClass = Class + .forName("com.sun.tdk.signaturetest.SignatureTest"); + Object sigTestInstance = sigTestClass.newInstance(); + + ByteArrayOutputStream output = new ByteArrayOutputStream(); + + // we want to replace the PACKAGE_FLAG with PACKAGE_NO_SUBS_FLAG + for (int ii = 0; ii < testArguments.length; ii++) { + if (testArguments[ii].equals(PACKAGE_FLAG)) { + testArguments[ii] = PACKAGE_NO_SUBS_FLAG; + } + } + + // dump args for debugging aid + System.out.println( + "\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); + for (int ii = 0; ii < testArguments.length; ii++) { + System.out.println(" testArguments[" + ii + "] = " + testArguments[ii]); + } + + @SuppressWarnings("unchecked") + Method runMethod = sigTestClass.getDeclaredMethod("run", + new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); + runMethod.invoke(sigTestInstance, + new Object[] { testArguments, new PrintWriter(output, true), null }); + + String rawMessages = output.toString(); + + // currently, there is no way to determine if there are error msgs in + // the rawmessages, so we will always dump this and call it a status. + System.out.println( + "********** Status Report '" + packageOrClassName + "' **********\n"); + System.out.println(rawMessages); + + return sigTestInstance.toString().substring(7).startsWith("Passed."); + } + + /* + * @return This returns true if javax.transaction.xa is not found in the + * JTA API jar + */ + protected boolean verifyJTAJarForNoXA(String classpath, String repositoryDir) throws Exception { + + System.out.println("SigTestDriver#verifyJTAJarForNoXA - Starting:"); + boolean result = false; + List command = new ArrayList(); + + // Build Commandline for com.sun.tdk.signaturetest.SignatureTest + command.add(STATIC_FLAG); + command.add(FILENAME_FLAG); + command.add(repositoryDir + "empty.sig"); + command.add(PACKAGE_FLAG); + command.add("javax.transaction.xa"); + command.add(CLASSPATH_FLAG); + command.add(classpath); + + String testArguments [] = (String[]) command.toArray(new String[command.size()]); + + // do some logging to help with troubleshooting + System.out.println("\nCalling: com.sun.tdk.signaturetest.SignatureTest() with following args:"); + for (int ii=0; ii < testArguments.length; ii++) { + System.out.println(" testArguments[" +ii+ "] = " + testArguments[ii]); + } + + Class sigTestClass = Class.forName("com.sun.tdk.signaturetest.SignatureTest"); + Object sigTestInstance = sigTestClass.newInstance(); + ByteArrayOutputStream output = new ByteArrayOutputStream(); + + @SuppressWarnings("unchecked") + Method runMethod = sigTestClass.getDeclaredMethod("run", + new Class[] { String[].class, + PrintWriter.class, + PrintWriter.class }); + runMethod.invoke(sigTestInstance, + new Object[] { testArguments, + new PrintWriter(output, true), + null }); + String rawMessages = output.toString(); + + // currently, there is no way to determine if there are error msgs in + // the rawmessages, so we will always dump this and call it a status. + System.out.println("********** Status Report JTA JAR validation **********\n"); + System.out.println(rawMessages); + return sigTestInstance.toString().substring(7).startsWith("Passed."); + } +}
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestEE.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestEE.java new file mode 100644 index 0000000..e749dd8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestEE.java
@@ -0,0 +1,486 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.PrintStream; + +import java.util.ArrayList; +import java.util.Properties; + + +/** + * This class should be extended by TCK developers that wish to create a set of + * signature tests that run inside all the Java EE containers. Developers must + * implement the getPackages method to specify which packages are to be tested + * by the signature test framework within which container. + */ +public abstract class SigTestEE { + + String[] sVehicles; + + private Object theSharedObject; + + private Object theSharedObjectArray[]; + + + protected SignatureTestDriver driver; + + /** + * <p> + * Returns a {@link SignatureTestDriver} appropriate for the particular TCK + * (using API check or the Signature Test Framework). + * </p> + * + * <p> + * The default implementation of this method will return a + * {@link SignatureTestDriver} that will use API Check. TCK developers can + * override this to return the desired {@link SignatureTestDriver} for their + * TCK. + */ + protected SignatureTestDriver getSigTestDriver() { + + if (driver == null) { + driver = SignatureTestDriverFactory.getInstance(SignatureTestDriverFactory.SIG_TEST); + } + + return driver; + + } // END getSigTestDriver + + /** + * Returns the location of the package list file. This file denotes the valid + * sub-packages of any package being verified in the signature tests. + * <p/> + * Sub-classes are free to override this method if they use a different path + * or filename for their package list file. Most users should be able to use + * this default implementation. + * + * @return String The path and name of the package list file. + */ + protected String getPackageFile() { + return getSigTestDriver().getPackageFileImpl(testInfo.getBinDir()); + } + + /** + * Returns the path and name of the signature map file that this TCK uses when + * conducting signature tests. The signature map file tells the signature test + * framework which API versions of tested packages to use. To keep this code + * platform independent, be sure to use the File.separator string (or the + * File.separatorChar) to denote path separators. + * <p/> + * Sub-classes are free to override this method if they use a different path + * or filename for their signature map file. Most users should be able to use + * this default implementation. + * + * @return String The path and name of the signature map file. + */ + protected String getMapFile() { + return getSigTestDriver().getMapFileImpl(testInfo.getBinDir()); + } + + /** + * Returns the directory that contains the signature files. + * <p/> + * Sub-classes are free to override this method if they use a different + * signature repository directory. Most users should be able to use this + * default implementation. + * + * @return String The signature repository directory. + */ + protected String getRepositoryDir() { + return getSigTestDriver().getRepositoryDirImpl(testInfo.getTSHome()); + } + + /** + * Returns the list of Optional Packages which are not accounted for. By + * 'unlisted optional' we mean the packages which are Optional to the + * technology under test that the user did NOT specifically list for testing. + * For example, with Java EE 7 implementation, a user could additionally opt + * to test a JSR-88 technology along with the Java EE technology. But if the + * user chooses NOT to list this optional technology for testing (via ts.jte + * javaee.level prop) then this method will return the packages for JSR-88 + * technology with this method call. + * <p/> + * This is useful for checking for a scenarios when a user may have forgotten + * to identify a whole or partial technology implementation and in such cases, + * Java EE platform still requires testing it. + * <p/> + * Any partial or complete impl of an unlistedOptionalPackage sends up a red + * flag indicating that the user must also pass tests for this optional + * technology area. + * <p/> + * Sub-classes are free to override this method if they use a different + * signature repository directory. Most users should be able to use this + * default implementation - which means that there was NO optional technology + * packages that need to be tested. + * + * @return ArrayList<String> + */ + protected ArrayList<String> getUnlistedOptionalPackages() { + return null; + } + + /** + * Returns the list of packages that must be tested by the signature test + * framework. TCK developers must implement this method in their signature + * test sub-class. + * + * @param vehicleName + * The name of the vehicle the signature tests should be conducted + * in. Valid values for this property are ejb, servlet, ejb and + * appclient. + * + * @return String[] A list of packages that the developer wishes to test using + * the signature test framework. If the developer does not wish to + * test any package signatures in the specified vehicle this method + * should return null. + * <p> + * Note, The proper way to insure that this method is not called with + * a vehicle name that has no package signatures to verify is to + * modify the vehicle.properties in the $TS_HOME/src directory. This + * file provides a mapping that maps test directories to a list of + * vehicles where the tests in those directory should be run. As an + * extra precaution users are encouraged to return null from this + * method if the specified vehicle has no package signatures to be + * verified within it. + */ + protected abstract String[] getPackages(String vehicleName); + + /** + * <p> + * Returns an array of individual classes that must be tested by the signature + * test framwork within the specified vehicle. TCK developers may override + * this method when this functionality is needed. Most will only need package + * level granularity. + * </p> + * + * <p> + * If the developer doesn't wish to test certain classes within a particular + * vehicle, the implementation of this method must return a zero-length array. + * </p> + * + * @param vehicleName + * The name of the vehicle the signature tests should be conducted + * in. Valid values for this property are ejb, servlet, ejb and + * appclient. + * + * @return an Array of Strings containing the individual classes the framework + * should test based on the specifed vehicle. The default + * implementation of this method returns a zero-length array no matter + * the vehicle specified. + */ + protected String[] getClasses(String vehicleName) { + + return new String[] {}; + + } // END getClasses + + protected SigTestData testInfo; // holds the bin.dir and vehicle properties + + /** + * Called by the test framework to initialize this test. The method simply + * retrieves some state information that is necessary to run the test when + * when the test framework invokes the run method (actually the test1 method). + * + * @param args + * List of arguments passed to this test. + * @param p + * Properties specified by the test user and passed to this test via + * the test framework. + * + * @throws Fault + * When an error occurs reading or saving the state information + * processed by this method. + */ + public void setup() { + try { + System.out.println("$$$ SigTestEE.setup() called"); + this.testInfo = new SigTestData(); + System.out.println("$$$ SigTestEE.setup() complete"); + } catch (Exception e) { + System.out.println("Unexpected exception " + e.getMessage()); + } + } + + /** + * Called by the test framework to run this test. This method utilizes the + * state information set in the setup method to run the signature tests. All + * signature test code resides in the utility class so it can be reused by the + * signature test framework base classes. + * + * @throws Fault + * When an error occurs executing the signature tests. + */ + public void signatureTest() throws Fault { + System.out.println("$$$ SigTestEE.signatureTest() called"); + SigTestResult results = null; + String mapFile = getMapFile(); + String repositoryDir = getRepositoryDir(); + String[] packages = getPackages(testInfo.getVehicle()); + String[] classes = getClasses(testInfo.getVehicle()); + String packageFile = getPackageFile(); + String testClasspath = testInfo.getTestClasspath(); + String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore(); + + // unlisted optional packages are technology packages for those optional + // technologies (e.g. jsr-88) that might not have been specified by the + // user. + // We want to ensure there are no full or partial implementations of an + // optional technology which were not declared + ArrayList<String> unlistedTechnologyPkgs = getUnlistedOptionalPackages(); + + // If testing with Java 9+, extract the JDK's modules so they can be used + // on the testcase's classpath. + Properties sysProps = System.getProperties(); + String version = (String) sysProps.get("java.version"); + if (!version.startsWith("1.")) { + String jimageDir = testInfo.getJImageDir(); + File f = new File(jimageDir); + f.mkdirs(); + + String javaHome = (String) sysProps.get("java.home"); + System.out.println("Executing JImage"); + + try { + ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/jimage", "extract", "--dir=" + jimageDir, javaHome + "/lib/modules"); + System.out.println(javaHome + "/bin/jimage extract --dir=" + jimageDir + " " + javaHome + "/lib/modules"); + pb.redirectErrorStream(true); + Process proc = pb.start(); + BufferedReader out = new BufferedReader(new InputStreamReader(proc.getInputStream())); + String line = null; + while ((line = out.readLine()) != null) { + System.out.println(line); + } + + int rc = proc.waitFor(); + System.out.println("JImage RC = " + rc); + out.close(); + } catch (Exception e) { + System.out.println("Exception while executing JImage! Some tests may fail."); + e.printStackTrace(); + } + } + + try { + results = getSigTestDriver().executeSigTest(packageFile, mapFile, + repositoryDir, packages, classes, testClasspath, + unlistedTechnologyPkgs, optionalPkgToIgnore); + System.out.println(results.toString()); + if (!results.passed()) { + System.out.println("results.passed() returned false"); + throw new Exception(); + } + + // Call verifyJtaJarTest based on some conditions, please check the + // comment for verifyJtaJarTest. + if ("standalone".equalsIgnoreCase(testInfo.getVehicle())) { + Properties mapFileAsProps = getSigTestDriver().loadMapFile(mapFile); + if (mapFileAsProps == null || mapFileAsProps.size() == 0) { + // empty signature file, something unusual + System.out.println("SigTestEE.signatureTest() returning, " + + "as signature map file is empty."); + return; + } + + boolean isJTASigTest = false; + + // Determine whether the signature map file contains package + // jakarta.transaction + String jtaVersion = mapFileAsProps.getProperty("jakarta.transaction"); + if (jtaVersion == null || "".equals(jtaVersion.trim())) { + System.out.println("SigTestEE.signatureTest() returning, " + + "as this is neither JTA TCK run, not Java EE CTS run."); + return; + } + + System.out.println("jtaVersion " + jtaVersion); + // Signature map packaged in JTA TCK will contain a single package + // jakarta.transaction + if (mapFileAsProps.size() == 1) { + isJTASigTest = true; + } + + if (isJTASigTest || !jtaVersion.startsWith("1.2")) { + verifyJtaJarTest(); + } + } + System.out.println("$$$ SigTestEE.signatureTest() returning"); + } catch (Exception e) { + if (results != null && !results.passed()) { + throw new Fault("SigTestEE.signatureTest() failed!, diffs found"); + } else { + System.out.println("Unexpected exception " + e.getMessage()); + throw new Fault("signatureTest failed with an unexpected exception", e); + } + } + } + + /** + * Called by the test framework to run this test. This method utilizes the + * state information set in the setup method to run. This test validates + * that the javax.transaction.xa type is not in the JTA API jar + * + * This method is called only for standaone vehicle, as calling the same + * for all the vehicles in the CTS run is not necessary. + * + * This method is called always from JTA 1.3 TCK. The test will be run as + * part of Java EE Signature Test only when the signature map in the CTS + * bundle is using JTA 1.3 (or higher) signature file. + * + * If property ts.jte jtaJarClasspath is removed in ts.jte of the JTA 1.3 TCK, + * this test will display the available options to call SignatureTest and + * fail. Similar failure will be seen in CTS run, if the signature map points + * to JTA 1.3 signature file and the property jtaJarClasspath is removed from + * ts.jte of CTS bundle. + * + * @throws Fault When an error occurs executing the signature tests. + */ + public void verifyJtaJarTest() throws Exception { + System.out.println("SigTestEE#verifyJtaJarTest - Starting:"); + String repositoryDir = getRepositoryDir(); + String jtaJarClasspath = testInfo.getJtaJarClasspath(); + boolean result = getSigTestDriver().verifyJTAJarForNoXA( + testInfo.getJtaJarClasspath(), repositoryDir); + if(result) { + System.out.println("PASS: javax.transaction.xa not found in API jar"); + } else { + System.out.println("FAIL: javax.transaction.xa found in API jar"); + throw new Fault("javax.transaction.xa validation failed"); + } + System.out.println("SigTestEE#verifyJtaJarTest returning"); + } + + /** + * Called by the test framework to cleanup any outstanding state. This method + * simply passes the message through to the utility class so the + * implementation can be used by both framework base classes. + * + * @throws Fault + * When an error occurs cleaning up the state of this test. + */ + public void cleanup() throws Fault { + System.out.println("$$$ SigTestEE.cleanup() called"); + try { + getSigTestDriver().cleanupImpl(); + System.out.println("$$$ SigTestEE.cleanup() returning"); + } catch (Exception e) { + throw new Fault("Cleanup failed!", e); + } + } + + + public static class Fault extends Exception { + private static final long serialVersionUID = -1574745208867827913L; + + public Throwable t; + + /** + * creates a Fault with a message + */ + public Fault(String msg) { + super(msg); + System.out.println(msg); + } + + /** + * creates a Fault with a message. + * + * @param msg + * the message + * @param t + * prints this exception's stacktrace + */ + public Fault(String msg, Throwable t) { + super(msg); + this.t = t; + System.out.println(msg); + t.printStackTrace(); + } + + /** + * creates a Fault with a Throwable. + * + * @param t + * the Throwable + */ + public Fault(Throwable t) { + super(t); + this.t = t; + } + + /** + * Prints this Throwable and its backtrace to the standard error stream. + * + */ + public void printStackTrace() { + if (this.t != null) { + this.t.printStackTrace(); + } else { + super.printStackTrace(); + } + } + + /** + * Prints this throwable and its backtrace to the specified print stream. + * + * @param s + * <code>PrintStream</code> to use for output + */ + public void printStackTrace(PrintStream s) { + if (this.t != null) { + this.t.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + /** + * Prints this throwable and its backtrace to the specified print writer. + * + * @param s + * <code>PrintWriter</code> to use for output + */ + public void printStackTrace(PrintWriter s) { + if (this.t != null) { + this.t.printStackTrace(s); + } else { + super.printStackTrace(s); + } + } + + @Override + public Throwable getCause() { + return t; + } + + @Override + public synchronized Throwable initCause(Throwable cause) { + if (t != null) + throw new IllegalStateException("Can't overwrite cause"); + if (!Exception.class.isInstance(cause)) + throw new IllegalArgumentException("Cause not permitted"); + this.t = (Exception) cause; + return this; + } + } + +} // end class SigTestEE
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestRecorder.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestRecorder.java new file mode 100644 index 0000000..3234f5f --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestRecorder.java
@@ -0,0 +1,96 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * @(#)SigTestRecorder.java 1.1 03/03/05 + */ +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.File; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; + +/** + * <p> + * This implementation of {@link Recorder} will record signatures using the + * <code>Signature Test</code> framework. + * </p> + */ +public class SigTestRecorder extends Recorder { + + // ------------------------------------------------------------ Constructors + + public SigTestRecorder(String[] args) { + + super(args); + + } // END SigTestRecorder + + // ------------------------------------------------------- Protected Methods + + protected String[] createCommandLine(String version, String classpath, + String outputFileName, String packageName) { + + List command = new ArrayList(); + + // command.add("-xReflection"); + command.add("-static"); + command.add("-debug"); + command.add("-verbose"); + command.add("-classpath"); + command.add(classpath); + + command.add("-FileName"); + try { + command.add(new File(outputFileName).toURI().toURL().toExternalForm()); + } catch (Exception e) { + throw new RuntimeException(e); + } + + command.add("-package"); + command.add(packageName); + + command.add("-apiVersion"); + command.add(version); + + return ((String[]) command.toArray(new String[command.size()])); + + } // END getCommandLine + + protected void writePackageListFile(String basePackageName, + String signatureFile, String packageListFile) throws Exception { + + PackageList packageList = new PackageList(basePackageName, signatureFile, + packageListFile); + packageList.writePkgListFile(); + + } // END writePackageListFile + + protected void doRecord(String[] commandLine) throws Exception { + + Class batchSetup = Class.forName("com.sun.tdk.signaturetest.Setup"); + Object batchSetupInstance = batchSetup.newInstance(); + Method runMethod = batchSetup.getDeclaredMethod("run", + new Class[] { String[].class, PrintWriter.class, PrintWriter.class }); + + runMethod.invoke(batchSetupInstance, new Object[] { commandLine, + new PrintWriter(System.out, true), new PrintWriter(System.err, true) }); + + } // END doRecord + +} // END SigTestRecorder
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestResult.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestResult.java new file mode 100644 index 0000000..76c6154 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SigTestResult.java
@@ -0,0 +1,134 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +public class SigTestResult implements Serializable { + + private static final String NL = System.getProperty("line.separator", "\n"); + + private List failedPkgs = new ArrayList(); + + private List passedPkgs = new ArrayList(); + + private List failedClasses = new ArrayList(); + + private List passedClasses = new ArrayList(); + + // ---------------------------------------------------------- Public Methods + + public synchronized boolean passed() { + + return (failedPkgs.size() == 0 && failedClasses.size() == 0); + + } // end passed + + public synchronized void addFailedPkg(String pkg) { + + failedPkgs.add(pkg); + + } // END addFailedPkg + + public synchronized void addPassedPkg(String pkg) { + + passedPkgs.add(pkg); + + } // END addPassedPkg + + public synchronized void addFailedClass(String className) { + + failedClasses.add(className); + + } // END addFailedClass + + public synchronized void addPassedClass(String className) { + + passedClasses.add(className); + + } // END addPassedClass + + public String toString() { + + String delim = "******************************************************" + + NL; + if (!pkgsTested() && !classesTested()) { + return (delim + "******** No packages or classes were tested **********" + + NL + delim); + } + StringBuffer buf = new StringBuffer(); + buf.append(delim); + buf.append(delim); + if (passed()) { + buf.append("All package signatures passed.").append(NL); + } else { + buf.append("Some signatures failed.").append(NL); + if (failedPkgs.size() > 0) { + buf.append("\tFailed packages listed below: ").append(NL); + formatList(failedPkgs, buf); + } + if (failedClasses.size() > 0) { + buf.append("\tFailed classes listed below: ").append(NL); + formatList(failedClasses, buf); + } + } + if (passedPkgs.size() > 0) { + buf.append("\tPassed packages listed below: ").append(NL); + formatList(passedPkgs, buf); + } + if (passedClasses.size() > 0) { + buf.append("\tPassed classes listed below: ").append(NL); + formatList(passedClasses, buf); + } + buf.append("\t"); + buf.append(delim); + buf.append(delim); + return buf.toString(); + + } // END toString + + // --------------------------------------------------------- Private Methods + + private synchronized void formatList(List list, StringBuffer buf) { + + synchronized (this) { + for (int i = 0; i < list.size(); i++) { + String pkg = (String) (list.get(i)); + buf.append("\t\t").append(pkg).append(NL); + } + } + + } // END formatList + + private synchronized boolean pkgsTested() { + + return (failedPkgs.size() != 0 || passedPkgs.size() != 0); + + } // END pkgsTested + + private synchronized boolean classesTested() { + + return (failedClasses.size() != 0 || passedClasses.size() != 0); + + } // END classesTested + +} // end class SigTestResult
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SignatureTestDriver.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SignatureTestDriver.java new file mode 100644 index 0000000..e831325 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SignatureTestDriver.java
@@ -0,0 +1,690 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates and others. + * All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.Properties; + + +/** + * Allows the sigtest framework to be extended using different signature test + * implementations (e.g. ApiCheck, or SigTest) + */ +public abstract class SignatureTestDriver { + + private static final String SIG_FILE_EXT = ".sig"; + + private static final String SIG_FILE_VER_SEP = "_"; + + // ---------------------------------------------------------- Public Methods + + /** + * Implementation of the getPackageFile method defined in both the SigTest and + * SigTestEE class. + */ + public String getPackageFileImpl(String binDir) { + + String thePkgListFile = "sig-test-pkg-list.txt"; + + System.out.println( + "Using the following as the SigTest Package file: " + thePkgListFile); + + String theFile = binDir + File.separator + thePkgListFile; + File ff = new File(theFile); + if (!ff.exists()) { + // we could not find the map file that coresponded to our SE version so + // lets + // try to default to use the sig-test-pkg-list.txt + System.out.println("The SigTest Package file does not exist: " + thePkgListFile); + theFile = binDir + File.separator + "sig-test-pkg-list.txt"; + File ff2 = new File(theFile); + if (!ff2.exists()) { + System.out.println("The Default SigTest Package file does not exist either: " + + theFile); + } else { + System.out.println("Defaulting to using SigTest Package file: " + theFile); + } + } + + return (theFile); + + } // END getPackageFileImpl + + /** + * Implementation of the getMapFile method defined in both the SigTest and + * SigTestEE class. + */ + public String getMapFileImpl(String binDir) { + + String theMapFile = "sig-test.map"; + + System.out.println("Using the following as the sig-Test map file: " + theMapFile); + + String theFile = binDir + File.separator + theMapFile; + File ff = new File(theFile); + if (!ff.exists()) { + // we could not find the map file that coresponded to our SE version so + // lets + // try to default to use the sig-test.map + System.out.println("The SigTest Map file does not exist: " + theMapFile); + theFile = binDir + File.separator + "sig-test.map"; + File ff2 = new File(theFile); + if (!ff2.exists()) { + System.out.println("The SigTest Map file does not exist either: " + theFile); + } else { + System.out.println("Defaulting to using SigTest Map file: " + theFile); + } + } + + return (theFile); + + } // END getMapFileImpl + + /** + * Returns true if the passed in version matches the current Java version + * being used. + * + */ + public Boolean isJavaSEVersion(String ver) { + + String strOSVersion = System.getProperty("java.version"); + if (strOSVersion.startsWith(ver)) { + return true; + } else { + return false; + } + } + + /** + * Implementation of the getRepositoryDir method defined in both the SigTest + * and SigTestEE class. + */ + public String getRepositoryDirImpl(String tsHome) { + + return (tsHome + File.separator + "src" + File.separator + "com" + + File.separator + "sun" + File.separator + "ts" + File.separator + + "tests" + File.separator + "signaturetest" + File.separator + + "signature-repository" + File.separator); + + } // END getRepositoryDirImpl + + /** + * Implementation of the cleanup method defined in both the SigTest and + * SigTestEE class. + */ + public void cleanupImpl() throws Exception { + + try { + System.out.println("cleanup"); + } catch (Exception e) { + System.out.println("Exception in cleanup method" + e); + throw e; + } + + } // END cleanupImpl + + /** + * <p> + * Execute the signature test. By default, this method passes the result of + * {@link #createTestArguments(String, String, String, String, String)} and + * passes the result to {@link #runSignatureTest(String, String[])}. + * + * @param packageListFile + * - file containing the packages/classes that are to be verified + * @param mapFile + * sig-test.map file + * @param signatureRepositoryDir + * directory containing the recorded signatures + * @param packagesUnderTest + * packages, defined by the test client, that should be tested + * @param classesUnderTest + * classes, defined by the test client, that should be tested + * @param classpath + * The location of the API being verified. Normally the checked API + * will be available in the test environment and testClasspath will + * be null. In some rare cases the tested API may not be part of the + * test environment and will have to specified using this parameter. + * @param unaccountedTechPkgs + * packages that should not exist within the technology under test. + * These will be searched for and if found, will be flagged as error + * since they were not explicitly declared as being under test. Their + * existence requires explicit testing. + * + * @return a {@link SigTestResult} containing the result of the test execution + */ + public SigTestResult executeSigTest(String packageListFile, String mapFile, + String signatureRepositoryDir, String[] packagesUnderTest, + String[] classesUnderTest, String classpath, + ArrayList<String> unaccountedTechPkgs, String optionalPkgToIgnore) + throws Exception { + + SigTestResult result = new SigTestResult(); + + System.out.println("optionalPkgToIgnore = " + optionalPkgToIgnore); + String[] arrayOptionalPkgsToIgnore = null; + if (optionalPkgToIgnore != null) { + arrayOptionalPkgsToIgnore = optionalPkgToIgnore.split(","); + } + + if (packagesUnderTest != null && packagesUnderTest.length > 0) { + System.out.println("********** BEGIN PACKAGE LEVEL SIGNATURE " + + "VALIDATION **********\n\n"); + for (int i = 0; i < packagesUnderTest.length; i++) { + + String packageName = packagesUnderTest[i]; + + System.out.println("********** BEGIN VALIDATE PACKAGE '" + + packagesUnderTest[i] + "' **********\n"); + + System.out.println( + "********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES ****"); + System.out.println("Static mode supports checks of static constants values "); + + String[] args = createTestArguments(packageListFile, mapFile, + signatureRepositoryDir, packageName, classpath, true); + dumpTestArguments(args); + + if (runSignatureTest(packageName, args)) { + System.out.println("********** Package '" + packageName + + "' - PASSED (STATIC MODE) **********"); + result.addPassedPkg(packageName + "(static mode)"); + } else { + result.addFailedPkg(packageName + "(static mode)"); + System.out.println("********** Package '" + packageName + + "' - FAILED (STATIC MODE) **********"); + } + + System.out.println("\n\n"); + System.out.println("********** VALIDATE IN REFLECTIVE MODE ****"); + System.out.println( + "Reflective mode supports verification within containers (ie ejb, servlet, etc)"); + + String[] args2 = createTestArguments(packageListFile, mapFile, + signatureRepositoryDir, packageName, classpath, false); + dumpTestArguments(args2); + + if (runSignatureTest(packageName, args2)) { + System.out.println("********** Package '" + packageName + + "' - PASSED (REFLECTION MODE) **********"); + result.addPassedPkg(packageName + "(reflection mode)"); + } else { + result.addFailedPkg(packageName + "(reflection mode)"); + System.out.println("********** Package '" + packageName + + "' - FAILED (REFLECTION MODE) **********"); + } + + System.out.println("********** END VALIDATE PACKAGE '" + + packagesUnderTest[i] + "' **********\n"); + + System.out.println("\n"); + System.out.println("\n"); + + } + } + + if (classesUnderTest != null && classesUnderTest.length > 0) { + System.out.println("********** BEGIN CLASS LEVEL SIGNATURE " + + "VALIDATION **********\n\n"); + + for (int i = 0; i < classesUnderTest.length; i++) { + + String className = classesUnderTest[i]; + + System.out.println("********** BEGIN VALIDATE CLASS '" + + classesUnderTest[i] + "' **********\n"); + + System.out.println( + "********** VALIDATE IN STATIC MODE - TO CHECK CONSANT VALUES ****"); + System.out.println("Static mode supports checks of static constants values "); + + String[] args = createTestArguments(packageListFile, mapFile, + signatureRepositoryDir, className, classpath, true); + dumpTestArguments(args); + + if (runSignatureTest(className, args)) { + System.out.println("********** Class '" + className + + "' - PASSED (STATIC MODE) **********"); + result.addPassedClass(className + "(static mode)"); + } else { + System.out.println("********** Class '" + className + + "' - FAILED (STATIC MODE) **********"); + result.addFailedClass(className + "(static mode)"); + } + + System.out.println("\n\n"); + System.out.println("********** VALIDATE IN REFLECTIVE MODE ****"); + System.out.println( + "Reflective mode supports verification within containers (ie ejb, servlet, etc)"); + + String[] args2 = createTestArguments(packageListFile, mapFile, + signatureRepositoryDir, className, classpath, false); + dumpTestArguments(args2); + + if (runSignatureTest(className, args2)) { + System.out.println("********** Class '" + className + + "' - PASSED (REFLECTION MODE) **********"); + result.addPassedClass(className + "(reflection mode)"); + } else { + System.out.println("********** Class '" + className + + "' - FAILED (REFLECTION MODE) **********"); + result.addFailedClass(className + "(reflection mode)"); + } + + System.out.println("********** END VALIDATE CLASS '" + classesUnderTest[i] + + "' **********\n"); + + System.out.println("\n"); + System.out.println("\n"); + + } + } + + /* + * The following will check if there are Optional Technologies being + * implemented but not explicitly defined thru (ts.jte) javaee.level + * property. This is a problem because if an optional technolgy is defined + * (either whole or partially) than the TCK tests (and sig tests) for those + * Optional Technology(s) MUST be run according to related specs. + */ + if (unaccountedTechPkgs != null) { + for (int ii = 0; ii < unaccountedTechPkgs.size(); ii++) { + // 'unaccountedTechPkgs' are t hose packages which do not beling to + // base technology nor one of the *declared* optionalal technologies. + // 'unaccountedTechPkgs' refers to packages for Optional Technologies + // which were not defined thru (ts.jte) javaee.level property. + // So, make sure there are no whole or partial implementations of + // undeclared optional technologies in the implementation + + String packageName = unaccountedTechPkgs.get(ii); + + // this is a special case exception to our validation of Optional + // Technologies. Normally any partial technology implementations + // would be a compatibility failure. HOWEVER, EE 7 Spec (see section + // EE 6.1.2 of the Platform spec in the footnote on p. 156.) + // requires us to add special handling to avoid testing 'certain' pkgs + // within an optional technology. + if (isIgnorePackageUnderTest(packageName, arrayOptionalPkgsToIgnore)) { + System.out.println( + "Ignoring special optional technology package: " + packageName); + continue; + } + + System.out.println("\n\n"); + System.out.println( + "********** CHECK IF OPTIONAL TECHNOLOGIES EXIST IN REFLECTIVE MODE ****"); + System.out.println( + "Reflective mode supports verification within containers (ie ejb, servlet, etc)"); + + String[] args3 = createTestArguments(packageListFile, mapFile, + signatureRepositoryDir, packageName, classpath, false); + dumpTestArguments(args3); + + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // - - - - + // NOTE: this is the opposite of above in that *if* we find that an + // undeclared + // optional technology package exists - then we want to raise a red + // flag. + // The user would have to either remove the technology from the impl if + // they do not want to include it in their impl -OR- they must + // explicitly + // set javaee.level (in ts.jte) to include that Optional Technology AND + // after setting this property, they have to pass all related TCK tests. + if (runPackageSearch(packageName, args3)) { + // if this passed we have an issue because it should not exist - thus + // should NOT pass. + System.out.println("********** Package '" + packageName + + "' - WAS FOUND BUT SHOULD NOT BE (REFLECTION MODE) **********"); + String err = "ERROR: An area of concern has been identified. "; + err += "You must run sigtests with (ts.jte) javaee.level set to "; + err += "include all optional technology keywords. Whole and/or "; + err += "partial implementations of Optional Technologies "; + err += "must be implemented according to the specs AND must pass "; + err += "all related TCK tests. To properly pass the "; + err += "signature tests - you must identify all Optional Technology "; + err += "areas (via javaee.level) that you wish to pass signature tests for."; + System.out.println(err); + result.addFailedPkg(packageName + + " (Undeclared Optional Technology package found in reflection mode)"); + } else { + System.out.println("********** Undeclared Optional Technology package '" + + packageName + "' - PASSED (REFLECTION MODE) **********"); + } + } + } + + return result; + + } // END executeSigTest + + // ------------------------------------------------------- Protected Methods + + /** + * Using a common set of information, create arguments that are appropriate to + * be used with the underlying signature test framework. + * + * @param packageListFile + * - file containing the packages/classes that are to be verified + * @param mapFile + * sig-test.map file + * @param signatureRepositoryDir + * directory containing the recorded signatures + * @param packageOrClassUnderTest + * the class or package + * @param classpath + * The location of the API being verified. Normally the checked API + * will be available in the test environment and testClasspath will + * be null. In some rare cases the tested API may not be part of the + * test environment and will have to specified using this parameter. + */ + protected abstract String[] createTestArguments(String packageListFile, + String mapFile, String signatureRepositoryDir, + String packageOrClassUnderTest, String classpath, boolean bStaticMode) + throws Exception; + + /** + * Invoke the underlying signature test framework for the specified package or + * class. + * + * @param packageOrClassName + * the package or class to be validated + * @param testArguments + * the arguments necessary to invoke the signature test framework + * + * @return <code>true</code> if the test passed, otherwise <code>false</code> + */ + protected abstract boolean runSignatureTest(String packageOrClassName, + String[] testArguments) throws Exception; + + /** + * This checks if a class exists or not within the impl. + * + * @param packageOrClassName + * the package or class to be validated + * + * @return <code>true</code> if the package was found to exist, otherwise + * <code>false</code> + */ + protected abstract boolean runPackageSearch(String packageOrClassName, + String[] testArguments) throws Exception; + + + /** + * This method checks whether JTA API jar contains classes from + * javax.transaction.xa package + * + * @param classpath + * the classpath, pointing JTA API jar + * @param repositoryDir + * the directory containing an empty signature file + * + * @return <code>true</code> if the package javax.transaction.xa is not + * found in the JTA API jar, otherwise <code>false</code> + */ + protected abstract boolean verifyJTAJarForNoXA(String classpath, + String repositoryDir) throws Exception; + + /** + * Loads the specified file into a Properties object provided the specified + * file exists and is a regular file. The call to new FileInputStream verifies + * that the specfied file is a regular file and exists. + * + * @param mapFile + * the path and name of the map file to be loaded + * + * @return Properties The Properties object initialized with the contents of + * the specified file + * + * @throws java.io.IOException + * If the specified map file does not exist or is not a regular + * file, can also be thrown if there is an error creating an input + * stream from the specified file. + */ + public Properties loadMapFile(String mapFile) + throws IOException, FileNotFoundException { + + FileInputStream in = null; + try { + File map = new File(mapFile); + Properties props = new Properties(); + in = new FileInputStream(map); + props.load(in); + return props; + } finally { + try { + if (in != null) { + in.close(); + } + } catch (Throwable t) { + // do nothing + } + } + + } // END loadMapFile + + /** + * This method will attempt to build a fully-qualified filename in the format + * of <code>respositoryDir</code> + </code>baseName</code> + + * <code>.sig_</code> + </code>version</code>. + * + * @param baseName + * the base portion of the signature filename + * @param repositoryDir + * the directory in which the signatures are stored + * @param version + * the version of the signature file + * @throws FileNotFoundException + * if the file cannot be validated as existing and is in fact a file + * @return a valid, fully qualified filename, appropriate for the system the + * test is being run on + */ + protected String getSigFileName(String baseName, String repositoryDir, + String version) throws FileNotFoundException { + + String sigFile; + if (repositoryDir.endsWith(File.separator)) { + sigFile = repositoryDir + baseName + SIG_FILE_EXT + SIG_FILE_VER_SEP + + version; + } else { + sigFile = repositoryDir + File.separator + baseName + SIG_FILE_EXT + + SIG_FILE_VER_SEP + version; + } + + File testFile = new File(sigFile); + + if (!testFile.exists() && !testFile.isFile()) { + throw new FileNotFoundException( + "Signature file \"" + sigFile + "\" does not exist."); + } + + // we are actually requiring this normalizeFileName call to get + // things working on Windows. Without this, if we just return the + // testFile; we will fail on windows. (Solaris works either way) + // IMPORTANT UPDATE!! (4/5/2011) + // in sigtest 2.2: they stopped supporting the normalized version which + // created a string filename = + // "file://com/sun/ts/tests/signaturetest/foo.sig" + // so now use file path and name only. + // return normalizeFileName(testFile); + return testFile.toString(); + + } // END getSigFileName + + protected abstract String normalizeFileName(File f); + + /** + * Returns the name and path to the signature file that contains the specified + * package's signatures. + * + * @param packageName + * The package under test + * @param mapFile + * The name of the file that maps package names to versions + * @param repositoryDir + * The directory that conatisn all signature files + * + * @return String The path and name of the siganture file that contains the + * specified package's signatures + * + * @throws Exception + * if the determined signature file is not a regular file or does + * not exist + */ + protected SignatureFileInfo getSigFileInfo(String packageName, String mapFile, + String repositoryDir) throws Exception { + + String originalPackage = packageName; + String name = null; + String version = null; + Properties props = loadMapFile(mapFile); + + while (true) { + boolean packageFound = false; + for (Enumeration<?> e = props.propertyNames(); e.hasMoreElements();) { + name = (String) (e.nextElement()); + if (name.equals(packageName)) { + version = props.getProperty(name); + packageFound = true; + break; + } // end if + } // end for + + if (packageFound) { + break; + } + + /* + * If we get here we did not find a package name in the properties file + * that matches the package name under test. So we look for a package name + * in the properties file that could be the parent package for the package + * under test. We do this by removing the specified packages last package + * name section. So jakarta.ejb.spi would become jakarta.ejb + */ + int index = packageName.lastIndexOf("."); + if (index <= 0) { + throw new Exception("Package \"" + originalPackage + + "\" not specified in mapping file \"" + mapFile + "\"."); + } + packageName = packageName.substring(0, index); + } // end while + + /* Return the expected name of the signature file */ + + return new SignatureFileInfo(getSigFileName(name, repositoryDir, version), + version); + + } // END getSigFileInfo + + // --------------------------------------------------------- Private Methods + + /* + * This returns true is the passed in packageName matches one of the packages + * that are listed in the arrayOptionalPkgsToIgnore. arrayOptionalPkgsToIgnore + * is ultimately defined in the ts.jte property + * 'optional.tech.packages.to.ignore' If one of the entries in + * arrayOptionalPkgsToIgnore matches the packageName then that means we return + * TRUE to indicate we should ignore and NOT TEST that particular package. + */ + private static boolean isIgnorePackageUnderTest(String packageName, + String[] arrayOptionalPkgsToIgnore) { + + // if anything is null - consider no match + if ((packageName == null) || (arrayOptionalPkgsToIgnore == null)) { + return false; + } + + for (int ii = 0; ii < arrayOptionalPkgsToIgnore.length; ii++) { + if (packageName.equals(arrayOptionalPkgsToIgnore[ii])) { + // we found a match - + return true; + } + } + + return false; + } + + /** + * Prints the specified list of parameters to the message log. Used for + * debugging purposes only. + * + * @param params + * The list of parameters to dump. + */ + private static void dumpTestArguments(String[] params) { + + if (params != null && params.length > 0) { + System.out.println("----------------- BEGIN SIG PARAM DUMP -----------------"); + for (int i = 0; i < params.length; i++) { + System.out.println(" Param[" + i + "]: " + params[i]); + } + System.out.println("------------------ END SIG PARAM DUMP ------------------"); + } + + } // END dumpTestArguments + + // ----------------------------------------------------------- Inner Classes + + /** + * A simple data structure containing the fully qualified path to the + * signature file as well as the version being tested. + */ + protected static class SignatureFileInfo { + + private String file; + + private String version; + + // -------------------------------------------------------- Constructors + + public SignatureFileInfo(String file, String version) { + + if (file == null) { + throw new IllegalArgumentException("'file' argument cannot be null"); + } + + if (version == null) { + throw new IllegalArgumentException("'version' argument cannot be null"); + } + + this.file = file; + this.version = version; + + } // END SignatureFileInfo + + // ------------------------------------------------------ Public Methods + + public String getFile() { + + return file; + + } // END getFileIncludingPath + + public String getVersion() { + + return version; + + } // END getVersion + + } + +} // END SigTestDriver
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SignatureTestDriverFactory.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SignatureTestDriverFactory.java new file mode 100644 index 0000000..f952969 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/SignatureTestDriverFactory.java
@@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +/* + * $Id$ + */ + +package ee.jakarta.tck.json.bind.signaturetest; + +/** + * <p> + * Factory to obtain SignatureTestDriver implementations. + * </p> + */ +public class SignatureTestDriverFactory { + + /** + * <p> + * Identifier for the driver that uses API Check to perform signature + * validation. + * </p> + */ + public static final String API_CHECK = "apicheck"; + + /** + * <p> + * Identifier for the driver that uses the Signature Test framwork for + * signature validation. + * </p> + */ + public static final String SIG_TEST = "sigtest"; + + // ------------------------------------------------------------ Constructors + + // Access via factory method + private SignatureTestDriverFactory() { + } // END SignatureTestDriverFactory + + // ---------------------------------------------------------- Public Methods + + /** + * <p> + * Obtain a {@link SignatureTestDriver} instance based on the + * <code>type</code> argument. + * + * @param type + * the driver type to create + * @return a {@link SignatureTestDriver} implementation + */ + public static SignatureTestDriver getInstance(String type) { + + if (type == null || type.length() == 0) { + throw new IllegalArgumentException("Type was null or empty"); + } + + if (API_CHECK.equals(type)) { + return new ApiCheckDriver(); + } else if (SIG_TEST.equals(type)) { + return new SigTestDriver(); + } else { + throw new IllegalArgumentException("Unknown Type: '" + type + '\''); + } + + } // END getInstance + +} // END SignatureTestDriverFactory
diff --git a/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/jsonb/JSONBSigTest.java b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/jsonb/JSONBSigTest.java new file mode 100644 index 0000000..7817a8f --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/json/bind/signaturetest/jsonb/JSONBSigTest.java
@@ -0,0 +1,293 @@ +/* + * Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + + +package ee.jakarta.tck.json.bind.signaturetest.jsonb; + +import java.io.PrintWriter; +import java.util.Properties; + +import org.junit.jupiter.api.Test; + +import ee.jakarta.tck.json.bind.signaturetest.SigTestEE; +import ee.jakarta.tck.json.bind.signaturetest.SignatureTestDriver; +import ee.jakarta.tck.json.bind.signaturetest.SignatureTestDriverFactory; +import ee.jakarta.tck.json.bind.signaturetest.SigTestResult; + + +import java.io.*; + +import java.util.ArrayList; +import java.util.Properties; + + +/* + * This class is a simple example of a signature test that extends the + * SigTest framework class. This signature test is run outside of the + * Java EE containers. This class also contains the boilerplate + * code necessary to create a signature test using the test framework. + * To see a complete TCK example see the javaee directory for the Java EE + * TCK signature test class. + */ +public class JSONBSigTest extends SigTestEE { + + public JSONBSigTest(){ + setup(); + } + + /***** Abstract Method Implementation *****/ + + /** + * Returns a list of strings where each string represents a package name. Each + * package name will have it's signature tested by the signature test + * framework. + * + * @return String[] The names of the packages whose signatures should be + * verified. + */ + protected String[] getPackages(String vehicleName) { + return new String[] { "jakarta.json.bind", "jakarta.json.bind.adapter", + "jakarta.json.bind.annotation", "jakarta.json.bind.config", + "jakarta.json.bind.serializer", "jakarta.json.bind.spi" }; + + } + + public File writeStreamToTempFile(InputStream inputStream, String tempFilePrefix, String tempFileSuffix) throws IOException { + FileOutputStream outputStream = null; + + try { + File file = File.createTempFile(tempFilePrefix, tempFileSuffix); + outputStream = new FileOutputStream(file); + byte[] buffer = new byte[1024]; + while (true) { + int bytesRead = inputStream.read(buffer); + if (bytesRead == -1) { + break; + } + outputStream.write(buffer, 0, bytesRead); + } + return file; + } + + finally { + if (outputStream != null) { + outputStream.close(); + } + } + } + + public File writeStreamToSigFile(InputStream inputStream, String packageVersion) throws IOException { + FileOutputStream outputStream = null; + String tmpdir = System.getProperty("java.io.tmpdir"); + try { + File sigfile = new File(tmpdir+File.separator+"jakarta.json.bind.sig_"+packageVersion); + if(sigfile.exists()){ + sigfile.delete(); + System.out.println("Existing signature file deleted to create new one"); + } + if(!sigfile.createNewFile()){ + System.out.println("signature file is not created"); + } + outputStream = new FileOutputStream(sigfile); + byte[] buffer = new byte[1024]; + while (true) { + int bytesRead = inputStream.read(buffer); + if (bytesRead == -1) { + break; + } + outputStream.write(buffer, 0, bytesRead); + } + return sigfile; + } + + finally { + if (outputStream != null) { + outputStream.close(); + } + } + } + + + + /***** Boilerplate Code *****/ + + + /* + * The following comments are specified in the base class that defines the + * signature tests. This is done so the test finders will find the right class + * to run. The implementation of these methods is inherited from the super + * class which is part of the signature test framework. + */ + + // NOTE: If the API under test is not part of your testing runtime + // environment, you may use the property sigTestClasspath to specify + // where the API under test lives. This should almost never be used. + // Normally the API under test should be specified in the classpath + // of the VM running the signature tests. Use either the first + // comment or the one below it depending on which properties your + // signature tests need. Please do not use both comments. + + /* + * @class.setup_props: ts_home, The base path of this TCK; sigTestClasspath; + */ + /* + * @testName: signatureTest + * + * @assertion: A JSONB container must implement the required classes and APIs + * specified in the JSONB Specification. + * + * @test_Strategy: Using reflection, gather the implementation specific + * classes and APIs. Compare these results with the expected (required) + * classes and APIs. + * + */ + @Test + public void signatureTest() throws Fault { + System.out.println("$$$ JSONBSigTest.signatureTest() called"); + SigTestResult results = null; + String mapFile = null; + String packageFile = null; + String repositoryDir = null; + Properties mapFileAsProps = null; + try { + + InputStream inStreamMapfile = JSONBSigTest.class.getClassLoader().getResourceAsStream("ee/jakarta/tck/json/bind/signaturetest/sig-test.map"); + File mFile = writeStreamToTempFile(inStreamMapfile, "sig-test", ".map"); + mapFile = mFile.getCanonicalPath(); + System.out.println("mapFile location is :"+mapFile); + + InputStream inStreamPackageFile = JSONBSigTest.class.getClassLoader().getResourceAsStream("ee/jakarta/tck/json/bind/signaturetest/sig-test-pkg-list.txt"); + File pFile = writeStreamToTempFile(inStreamPackageFile, "sig-test-pkg-list", ".txt"); + packageFile = pFile.getCanonicalPath(); + System.out.println("packageFile location is :"+packageFile); + + mapFileAsProps = getSigTestDriver().loadMapFile(mapFile); + String packageVersion = mapFileAsProps.getProperty("jakarta.json.bind"); + System.out.println("Package version from mapfile :"+ packageVersion); + + InputStream inStreamSigFile = JSONBSigTest.class.getClassLoader().getResourceAsStream("ee/jakarta/tck/json/bind/signaturetest/jakarta.json.bind.sig_"+packageVersion); + File sigFile = writeStreamToSigFile(inStreamSigFile, packageVersion); + System.out.println("signature File location is :"+sigFile.getCanonicalPath()); + repositoryDir = System.getProperty("java.io.tmpdir"); + + + } catch(IOException ex){ + System.out.println("Exception while creating temp files :"+ex); + } + + String[] packages = getPackages(testInfo.getVehicle()); + String[] classes = getClasses(testInfo.getVehicle()); + String testClasspath = System.getProperty("signature.sigTestClasspath"); + String optionalPkgToIgnore = testInfo.getOptionalTechPackagesToIgnore(); + + // unlisted optional packages are technology packages for those optional + // technologies (e.g. jsr-88) that might not have been specified by the + // user. + // We want to ensure there are no full or partial implementations of an + // optional technology which were not declared + ArrayList<String> unlistedTechnologyPkgs = getUnlistedOptionalPackages(); + + // If testing with Java 9+, extract the JDK's modules so they can be used + // on the testcase's classpath. + Properties sysProps = System.getProperties(); + String version = (String) sysProps.get("java.version"); + if (!version.startsWith("1.")) { + String jimageDir = testInfo.getJImageDir(); + File f = new File(jimageDir); + f.mkdirs(); + + String javaHome = (String) sysProps.get("java.home"); + System.out.println("Executing JImage"); + + try { + ProcessBuilder pb = new ProcessBuilder(javaHome + "/bin/jimage", "extract", "--dir=" + jimageDir, javaHome + "/lib/modules"); + System.out.println(javaHome + "/bin/jimage extract --dir=" + jimageDir + " " + javaHome + "/lib/modules"); + pb.redirectErrorStream(true); + Process proc = pb.start(); + BufferedReader out = new BufferedReader(new InputStreamReader(proc.getInputStream())); + String line = null; + while ((line = out.readLine()) != null) { + System.out.println(line); + } + + int rc = proc.waitFor(); + System.out.println("JImage RC = " + rc); + out.close(); + } catch (Exception e) { + System.out.println("Exception while executing JImage! Some tests may fail."); + e.printStackTrace(); + } + } + + try { + results = getSigTestDriver().executeSigTest(packageFile, mapFile, + repositoryDir, packages, classes, testClasspath, + unlistedTechnologyPkgs, optionalPkgToIgnore); + System.out.println(results.toString()); + if (!results.passed()) { + System.out.println("results.passed() returned false"); + throw new Exception(); + } + + // Call verifyJtaJarTest based on some conditions, please check the + // comment for verifyJtaJarTest. + if ("standalone".equalsIgnoreCase(testInfo.getVehicle())) { + if (mapFileAsProps == null || mapFileAsProps.size() == 0) { + // empty signature file, something unusual + System.out.println("JSONBSigTest.signatureTest() returning, " + + "as signature map file is empty."); + return; + } + + boolean isJTASigTest = false; + + // Determine whether the signature map file contains package + // jakarta.transaction + String jtaVersion = mapFileAsProps.getProperty("jakarta.transaction"); + if (jtaVersion == null || "".equals(jtaVersion.trim())) { + System.out.println("JSONBSigTest.signatureTest() returning, " + + "as this is neither JTA TCK run, not Java EE CTS run."); + return; + } + + System.out.println("jtaVersion " + jtaVersion); + // Signature map packaged in JTA TCK will contain a single package + // jakarta.transaction + if (mapFileAsProps.size() == 1) { + isJTASigTest = true; + } + + if (isJTASigTest || !jtaVersion.startsWith("1.2")) { + verifyJtaJarTest(); + } + } + System.out.println("$$$ JSONBSigTest.signatureTest() returning"); + } catch (Exception e) { + if (results != null && !results.passed()) { + throw new Fault("JSONBSigTest.signatureTest() failed!, diffs found"); + } else { + System.out.println("Unexpected exception " + e.getMessage()); + throw new Fault("signatureTest failed with an unexpected exception", e); + } + } + } + + /* + * Call the parent class's cleanup method. + */ + + +} // end class JSONBSigTest
diff --git a/tck/src/main/resources/META-INF/beans.xml b/tck/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000..6d933a5 --- /dev/null +++ b/tck/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Copyright (c) 2021, 2022 Oracle and/or its affiliates. All rights reserved. + + This program and the accompanying materials are made available under the + terms of the Eclipse Public License v. 2.0, which is available at + http://www.eclipse.org/legal/epl-2.0. + + This Source Code may also be made available under the following Secondary + Licenses when the conditions for such availability set forth in the + Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + version 2 with the GNU Classpath Exception, which is available at + https://www.gnu.org/software/classpath/license.html. + + SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + +--> +<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_2_0.xsd" + bean-discovery-mode="all"> +</beans>
diff --git a/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/jakarta.json.bind.sig_3.0.0 b/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/jakarta.json.bind.sig_3.0.0 new file mode 100644 index 0000000..89866e6 --- /dev/null +++ b/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/jakarta.json.bind.sig_3.0.0
@@ -0,0 +1,311 @@ +#Signature file v4.1 +#Version 3.0 + +CLSS public abstract interface jakarta.json.bind.Jsonb +intf java.lang.AutoCloseable +meth public abstract <%0 extends java.lang.Object> {%%0} fromJson(java.io.InputStream,java.lang.Class<{%%0}>) +meth public abstract <%0 extends java.lang.Object> {%%0} fromJson(java.io.InputStream,java.lang.reflect.Type) +meth public abstract <%0 extends java.lang.Object> {%%0} fromJson(java.io.Reader,java.lang.Class<{%%0}>) +meth public abstract <%0 extends java.lang.Object> {%%0} fromJson(java.io.Reader,java.lang.reflect.Type) +meth public abstract <%0 extends java.lang.Object> {%%0} fromJson(java.lang.String,java.lang.Class<{%%0}>) +meth public abstract <%0 extends java.lang.Object> {%%0} fromJson(java.lang.String,java.lang.reflect.Type) +meth public abstract java.lang.String toJson(java.lang.Object) +meth public abstract java.lang.String toJson(java.lang.Object,java.lang.reflect.Type) +meth public abstract void toJson(java.lang.Object,java.io.OutputStream) +meth public abstract void toJson(java.lang.Object,java.io.Writer) +meth public abstract void toJson(java.lang.Object,java.lang.reflect.Type,java.io.OutputStream) +meth public abstract void toJson(java.lang.Object,java.lang.reflect.Type,java.io.Writer) + +CLSS public abstract interface jakarta.json.bind.JsonbBuilder +meth public abstract jakarta.json.bind.Jsonb build() +meth public abstract jakarta.json.bind.JsonbBuilder withConfig(jakarta.json.bind.JsonbConfig) +meth public abstract jakarta.json.bind.JsonbBuilder withProvider(jakarta.json.spi.JsonProvider) +meth public static jakarta.json.bind.Jsonb create() +meth public static jakarta.json.bind.Jsonb create(jakarta.json.bind.JsonbConfig) +meth public static jakarta.json.bind.JsonbBuilder newBuilder() +meth public static jakarta.json.bind.JsonbBuilder newBuilder(jakarta.json.bind.spi.JsonbProvider) +meth public static jakarta.json.bind.JsonbBuilder newBuilder(java.lang.String) + +CLSS public jakarta.json.bind.JsonbConfig +cons public init() +fld public final static java.lang.String ADAPTERS = "jsonb.adapters" +fld public final static java.lang.String BINARY_DATA_STRATEGY = "jsonb.binary-data-strategy" +fld public final static java.lang.String CREATOR_PARAMETERS_REQUIRED = "jsonb.creator-parameters-required" +fld public final static java.lang.String DATE_FORMAT = "jsonb.date-format" +fld public final static java.lang.String DESERIALIZERS = "jsonb.derializers" +fld public final static java.lang.String ENCODING = "jsonb.encoding" +fld public final static java.lang.String FORMATTING = "jsonb.formatting" +fld public final static java.lang.String LOCALE = "jsonb.locale" +fld public final static java.lang.String NULL_VALUES = "jsonb.null-values" +fld public final static java.lang.String PROPERTY_NAMING_STRATEGY = "jsonb.property-naming-strategy" +fld public final static java.lang.String PROPERTY_ORDER_STRATEGY = "jsonb.property-order-strategy" +fld public final static java.lang.String PROPERTY_VISIBILITY_STRATEGY = "jsonb.property-visibility-strategy" +fld public final static java.lang.String SERIALIZERS = "jsonb.serializers" +fld public final static java.lang.String STRICT_IJSON = "jsonb.strict-ijson" +meth public !varargs final jakarta.json.bind.JsonbConfig withAdapters(jakarta.json.bind.adapter.JsonbAdapter[]) +meth public !varargs final jakarta.json.bind.JsonbConfig withDeserializers(jakarta.json.bind.serializer.JsonbDeserializer[]) +meth public !varargs final jakarta.json.bind.JsonbConfig withSerializers(jakarta.json.bind.serializer.JsonbSerializer[]) +meth public final jakarta.json.bind.JsonbConfig setProperty(java.lang.String,java.lang.Object) +meth public final jakarta.json.bind.JsonbConfig withBinaryDataStrategy(java.lang.String) +meth public final jakarta.json.bind.JsonbConfig withCreatorParametersRequired(boolean) +meth public final jakarta.json.bind.JsonbConfig withDateFormat(java.lang.String,java.util.Locale) +meth public final jakarta.json.bind.JsonbConfig withEncoding(java.lang.String) +meth public final jakarta.json.bind.JsonbConfig withFormatting(java.lang.Boolean) +meth public final jakarta.json.bind.JsonbConfig withLocale(java.util.Locale) +meth public final jakarta.json.bind.JsonbConfig withNullValues(java.lang.Boolean) +meth public final jakarta.json.bind.JsonbConfig withPropertyNamingStrategy(jakarta.json.bind.config.PropertyNamingStrategy) +meth public final jakarta.json.bind.JsonbConfig withPropertyNamingStrategy(java.lang.String) +meth public final jakarta.json.bind.JsonbConfig withPropertyOrderStrategy(java.lang.String) +meth public final jakarta.json.bind.JsonbConfig withPropertyVisibilityStrategy(jakarta.json.bind.config.PropertyVisibilityStrategy) +meth public final jakarta.json.bind.JsonbConfig withStrictIJSON(java.lang.Boolean) +meth public final java.util.Map<java.lang.String,java.lang.Object> getAsMap() +meth public final java.util.Optional<java.lang.Object> getProperty(java.lang.String) +supr java.lang.Object +hfds configuration + +CLSS public jakarta.json.bind.JsonbException +cons public init(java.lang.String) +cons public init(java.lang.String,java.lang.Throwable) +supr java.lang.RuntimeException +hfds serialVersionUID + +CLSS public abstract interface jakarta.json.bind.adapter.JsonbAdapter<%0 extends java.lang.Object, %1 extends java.lang.Object> +meth public abstract {jakarta.json.bind.adapter.JsonbAdapter%0} adaptFromJson({jakarta.json.bind.adapter.JsonbAdapter%1}) throws java.lang.Exception +meth public abstract {jakarta.json.bind.adapter.JsonbAdapter%1} adaptToJson({jakarta.json.bind.adapter.JsonbAdapter%0}) throws java.lang.Exception + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbAnnotation + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) +intf java.lang.annotation.Annotation + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbCreator + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, METHOD, CONSTRUCTOR]) +intf java.lang.annotation.Annotation + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbDateFormat + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, FIELD, METHOD, TYPE, PARAMETER, PACKAGE]) +fld public final static java.lang.String DEFAULT_FORMAT = "##default" +fld public final static java.lang.String DEFAULT_LOCALE = "##default" +fld public final static java.lang.String TIME_IN_MILLIS = "##time-in-millis" +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.String locale() +meth public abstract !hasdefault java.lang.String value() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbNillable + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, FIELD, METHOD, TYPE, PACKAGE]) +intf java.lang.annotation.Annotation +meth public abstract !hasdefault boolean value() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbNumberFormat + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, FIELD, METHOD, TYPE, PARAMETER, PACKAGE]) +fld public final static java.lang.String DEFAULT_LOCALE = "##default" +intf java.lang.annotation.Annotation +meth public abstract !hasdefault java.lang.String locale() +meth public abstract !hasdefault java.lang.String value() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbProperty + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, METHOD, FIELD, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract !hasdefault boolean nillable() + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="2.1") +meth public abstract !hasdefault java.lang.String value() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbPropertyOrder + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.String[] value() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbSubtype + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class<?> type() +meth public abstract java.lang.String alias() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbTransient + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, FIELD, METHOD]) +intf java.lang.annotation.Annotation + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbTypeAdapter + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, TYPE, FIELD, METHOD, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class<? extends jakarta.json.bind.adapter.JsonbAdapter> value() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbTypeDeserializer + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, TYPE, FIELD, METHOD, PARAMETER]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class<? extends jakarta.json.bind.serializer.JsonbDeserializer> value() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbTypeInfo + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, TYPE]) +fld public final static java.lang.String DEFAULT_KEY_NAME = "@type" +intf java.lang.annotation.Annotation +meth public abstract !hasdefault jakarta.json.bind.annotation.JsonbSubtype[] value() +meth public abstract !hasdefault java.lang.String key() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbTypeSerializer + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, TYPE, FIELD, METHOD]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class<? extends jakarta.json.bind.serializer.JsonbSerializer> value() + +CLSS public abstract interface !annotation jakarta.json.bind.annotation.JsonbVisibility + anno 0 jakarta.json.bind.annotation.JsonbAnnotation() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE, TYPE, PACKAGE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.Class<? extends jakarta.json.bind.config.PropertyVisibilityStrategy> value() + +CLSS public final jakarta.json.bind.config.BinaryDataStrategy +fld public final static java.lang.String BASE_64 = "BASE_64" +fld public final static java.lang.String BASE_64_URL = "BASE_64_URL" +fld public final static java.lang.String BYTE = "BYTE" +supr java.lang.Object + +CLSS public abstract interface jakarta.json.bind.config.PropertyNamingStrategy +fld public final static java.lang.String CASE_INSENSITIVE = "CASE_INSENSITIVE" +fld public final static java.lang.String IDENTITY = "IDENTITY" +fld public final static java.lang.String LOWER_CASE_WITH_DASHES = "LOWER_CASE_WITH_DASHES" +fld public final static java.lang.String LOWER_CASE_WITH_UNDERSCORES = "LOWER_CASE_WITH_UNDERSCORES" +fld public final static java.lang.String UPPER_CAMEL_CASE = "UPPER_CAMEL_CASE" +fld public final static java.lang.String UPPER_CAMEL_CASE_WITH_SPACES = "UPPER_CAMEL_CASE_WITH_SPACES" +meth public abstract java.lang.String translateName(java.lang.String) + +CLSS public final jakarta.json.bind.config.PropertyOrderStrategy +fld public final static java.lang.String ANY = "ANY" +fld public final static java.lang.String LEXICOGRAPHICAL = "LEXICOGRAPHICAL" +fld public final static java.lang.String REVERSE = "REVERSE" +supr java.lang.Object + +CLSS public abstract interface jakarta.json.bind.config.PropertyVisibilityStrategy +meth public abstract boolean isVisible(java.lang.reflect.Field) +meth public abstract boolean isVisible(java.lang.reflect.Method) + +CLSS public abstract interface jakarta.json.bind.serializer.DeserializationContext +meth public abstract <%0 extends java.lang.Object> {%%0} deserialize(java.lang.Class<{%%0}>,jakarta.json.stream.JsonParser) +meth public abstract <%0 extends java.lang.Object> {%%0} deserialize(java.lang.reflect.Type,jakarta.json.stream.JsonParser) + +CLSS public abstract interface jakarta.json.bind.serializer.JsonbDeserializer<%0 extends java.lang.Object> +meth public abstract {jakarta.json.bind.serializer.JsonbDeserializer%0} deserialize(jakarta.json.stream.JsonParser,jakarta.json.bind.serializer.DeserializationContext,java.lang.reflect.Type) + +CLSS public abstract interface jakarta.json.bind.serializer.JsonbSerializer<%0 extends java.lang.Object> +meth public abstract void serialize({jakarta.json.bind.serializer.JsonbSerializer%0},jakarta.json.stream.JsonGenerator,jakarta.json.bind.serializer.SerializationContext) + +CLSS public abstract interface jakarta.json.bind.serializer.SerializationContext +meth public abstract <%0 extends java.lang.Object> void serialize(java.lang.String,{%%0},jakarta.json.stream.JsonGenerator) +meth public abstract <%0 extends java.lang.Object> void serialize({%%0},jakarta.json.stream.JsonGenerator) + +CLSS public abstract jakarta.json.bind.spi.JsonbProvider +cons protected init() +meth public abstract jakarta.json.bind.JsonbBuilder create() +meth public static jakarta.json.bind.spi.JsonbProvider provider() +meth public static jakarta.json.bind.spi.JsonbProvider provider(java.lang.String) +supr java.lang.Object +hfds DEFAULT_PROVIDER + +CLSS public abstract interface java.io.Serializable + +CLSS public abstract interface java.lang.AutoCloseable +meth public abstract void close() throws java.lang.Exception + +CLSS public java.lang.Exception +cons protected init(java.lang.String,java.lang.Throwable,boolean,boolean) +cons public init() +cons public init(java.lang.String) +cons public init(java.lang.String,java.lang.Throwable) +cons public init(java.lang.Throwable) +supr java.lang.Throwable + +CLSS public java.lang.Object +cons public init() +meth protected java.lang.Object clone() throws java.lang.CloneNotSupportedException +meth protected void finalize() throws java.lang.Throwable + anno 0 java.lang.Deprecated(boolean forRemoval=false, java.lang.String since="9") +meth public boolean equals(java.lang.Object) +meth public final java.lang.Class<?> getClass() +meth public final void notify() +meth public final void notifyAll() +meth public final void wait() throws java.lang.InterruptedException +meth public final void wait(long) throws java.lang.InterruptedException +meth public final void wait(long,int) throws java.lang.InterruptedException +meth public int hashCode() +meth public java.lang.String toString() + +CLSS public java.lang.RuntimeException +cons protected init(java.lang.String,java.lang.Throwable,boolean,boolean) +cons public init() +cons public init(java.lang.String) +cons public init(java.lang.String,java.lang.Throwable) +cons public init(java.lang.Throwable) +supr java.lang.Exception + +CLSS public java.lang.Throwable +cons protected init(java.lang.String,java.lang.Throwable,boolean,boolean) +cons public init() +cons public init(java.lang.String) +cons public init(java.lang.String,java.lang.Throwable) +cons public init(java.lang.Throwable) +intf java.io.Serializable +meth public final java.lang.Throwable[] getSuppressed() +meth public final void addSuppressed(java.lang.Throwable) +meth public java.lang.StackTraceElement[] getStackTrace() +meth public java.lang.String getLocalizedMessage() +meth public java.lang.String getMessage() +meth public java.lang.String toString() +meth public java.lang.Throwable fillInStackTrace() +meth public java.lang.Throwable getCause() +meth public java.lang.Throwable initCause(java.lang.Throwable) +meth public void printStackTrace() +meth public void printStackTrace(java.io.PrintStream) +meth public void printStackTrace(java.io.PrintWriter) +meth public void setStackTrace(java.lang.StackTraceElement[]) +supr java.lang.Object + +CLSS public abstract interface java.lang.annotation.Annotation +meth public abstract boolean equals(java.lang.Object) +meth public abstract int hashCode() +meth public abstract java.lang.Class<? extends java.lang.annotation.Annotation> annotationType() +meth public abstract java.lang.String toString() + +CLSS public abstract interface !annotation java.lang.annotation.Documented + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation + +CLSS public abstract interface !annotation java.lang.annotation.Retention + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.annotation.RetentionPolicy value() + +CLSS public abstract interface !annotation java.lang.annotation.Target + anno 0 java.lang.annotation.Documented() + anno 0 java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy value=RUNTIME) + anno 0 java.lang.annotation.Target(java.lang.annotation.ElementType[] value=[ANNOTATION_TYPE]) +intf java.lang.annotation.Annotation +meth public abstract java.lang.annotation.ElementType[] value() +
diff --git a/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/sig-test-pkg-list.txt b/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/sig-test-pkg-list.txt new file mode 100644 index 0000000..c96c9a1 --- /dev/null +++ b/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/sig-test-pkg-list.txt
@@ -0,0 +1,34 @@ +# +# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +# +# $Id$ +# + +## +# This file contains a list of all the packages +# contained in the signature files for this +# deliverable. This file is used to exclude valid +# sub-packages from being verified when their +# parent package's signature is checked. +## + +jakarta.json.bind +jakarta.json.bind.adapter +jakarta.json.bind.annotation +jakarta.json.bind.config +jakarta.json.bind.serializer +jakarta.json.bind.spi
diff --git a/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/sig-test.map b/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/sig-test.map new file mode 100644 index 0000000..a719130 --- /dev/null +++ b/tck/src/main/resources/ee/jakarta/tck/json/bind/signaturetest/sig-test.map
@@ -0,0 +1,20 @@ +# +# Copyright (c) 2022 Oracle and/or its affiliates. All rights reserved. +# +# This program and the accompanying materials are made available under the +# terms of the Eclipse Public License v. 2.0, which is available at +# http://www.eclipse.org/legal/epl-2.0. +# +# This Source Code may also be made available under the following Secondary +# Licenses when the conditions for such availability set forth in the +# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, +# version 2 with the GNU Classpath Exception, which is available at +# https://www.gnu.org/software/classpath/license.html. +# +# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 +# + +############################################################### +# The signature test mapping file for the JSONB TCK. +############################################################### +jakarta.json.bind=3.0.0