diff --git a/Jenkinsfile b/Jenkinsfile index d9bdcca42b..26a38e6022 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,8 @@ env.label = "jakartaee-tck-pod-${UUID.randomUUID().toString()}" default_suites=[ "samples", "signaturetest/javaee" ] -default_tcks=["caj", "concurrency", "connector", "el", "jacc", "jaspic", "jaxws", "jms", "jpa", "jsf", "jsp", "jsonb", "jsonp", "jstl", "jta", "saaj", "securityapi", "servlet", "websocket"] +default_tcks=["caj", "concurrency", "connector", "el", "jacc", "jaspic", "jaxws", "jms", "jpa", "jsf", "jsp", "jsonb", "jstl", "jta", "saaj", "securityapi", "servlet", "websocket"] + def cts_suites = params.test_suites != null ? params.test_suites.split() : default_suites def tcks = params.standalone_tcks != null ? params.standalone_tcks.split() : default_tcks @@ -192,7 +193,7 @@ spec: description: 'Run the full EE compliance testsuite or a standalone tck' ) string(name: 'test_suites', defaultValue: 'concurrency connector ejb ejb30/bb ejb30/lite/appexception ejb30/lite/async ejb30/lite/basic ejb30/lite/ejbcontext ejb30/lite/enventry ejb30/lite/interceptor ejb30/lite/lookup ejb30/lite/naming ejb30/lite/nointerface ejb30/lite/packaging ejb30/lite/singleton ejb30/lite/stateful ejb30/lite/tx ejb30/lite/view ejb30/lite/xmloverride ejb30/assembly ejb30/timer ejb30/webservice ejb30/zombie ejb30/misc ejb30/sec ejb32 el integration jacc jaspic javaee javamail jaxrs jbatch jdbc_appclient jdbc_ejb jdbc_jsp jdbc_servlet jms_appclient jms_ejb jms_jsp jms_servlet jpa_appmanaged jpa_appmanagedNoTx jpa_pmservlet jpa_puservlet jpa_stateful3 jpa_stateless3 jsf jsonb jsonp jsp jstl jta jws samples securityapi servlet signaturetest/javaee webservices12 webservices13 websocket xa', description: 'Space separated list of Test suites to run') - string(name: 'standalone_tcks', defaultValue: 'caj concurrency connector el jacc jaspic jaxws jms jpa jsf jsp jsonb jsonp jstl jta saaj securityapi servlet websocket', + string(name: 'standalone_tcks', defaultValue: 'caj concurrency connector el jacc jaspic jaxws jms jpa jsf jsp jsonb jstl jta saaj securityapi servlet websocket', description: 'Space separated list of standalone TCKs to build and run') string(name: 'USER_KEYWORDS', defaultValue: '', diff --git a/bin/coverage-build.xml b/bin/coverage-build.xml index a27a41f80b..3797911228 100644 --- a/bin/coverage-build.xml +++ b/bin/coverage-build.xml @@ -313,7 +313,7 @@ @@ -416,14 +416,6 @@ - - - - - - - - diff --git a/docker/build_standalone-tcks.sh b/docker/build_standalone-tcks.sh index dad93bd0d6..55537dadb0 100755 --- a/docker/build_standalone-tcks.sh +++ b/docker/build_standalone-tcks.sh @@ -68,7 +68,7 @@ fi echo "The option selected to build is $TCK_NAME TCK" if [ "All" == "$TCK_NAME" ];then - TCK_LIST=( jsonp jsonb websocket el concurrency connector jacc jaspic caj jms jsp jstl jaxws saaj servlet jsf securityapi jpa jta ) + TCK_LIST=( jsonb websocket el concurrency connector jacc jaspic caj jms jsp jstl jaxws saaj servlet jsf securityapi jpa jta ) else TCK_LIST=( ${TCK_NAME} ) fi @@ -126,11 +126,6 @@ for tck in ${TCK_LIST[@]}; do TCK_SPECIFIC_PROPS="-Djsf.classes=$JAKARTA_JARS/modules/jakarta.enterprise.cdi-api.jar:$JAKARTA_JARS/modules/jakarta.servlet.jsp.jstl-api.jar:$JAKARTA_JARS/modules/jakarta.inject-api.jar:$JAKARTA_JARS/modules/jakarta.faces-api.jar:$JAKARTA_JARS/modules/jakarta.servlet.jsp-api.jar:$JAKARTA_JARS/modules/jakarta.servlet-api.jar:$JAKARTA_JARS/modules/jakarta.el-api.jar:$JAKARTA_JARS/modules/jakarta.annotation-api.jar:$JAKARTA_JARS/modules/glassfish-corba-omgapi.jar" DOC_SPECIFIC_PROPS="" JAXWS_SPECIFIC_PROPS="" - elif [ "jsonp" == "$tck" ] - then - TCK_SPECIFIC_PROPS="-Djsonp.classes=$JAKARTA_JARS/modules/jakarta.json-api.jar:$JAKARTA_JARS/modules/jakarta.json.bind-api.jar:$JAKARTA_JARS/modules/glassfish-corba-omgapi.jar" - DOC_SPECIFIC_PROPS="" - JAXWS_SPECIFIC_PROPS="" elif [ "jsonb" == "$tck" ] then TCK_SPECIFIC_PROPS="-Djsonb.classes=$JAKARTA_JARS/modules/jakarta.json-api.jar:$JAKARTA_JARS/modules/jakarta.json.bind-api.jar:$JAKARTA_JARS/modules/jakarta.inject-api.jar:$JAKARTA_JARS/modules/jakarta.servlet-api.jar:$JAKARTA_JARS/modules/glassfish-corba-omgapi.jar" diff --git a/docker/jsonptck.sh b/docker/jsonptck.sh deleted file mode 100644 index 19fd7b5d82..0000000000 --- a/docker/jsonptck.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -x - -# Copyright (c) 2018, 2022 Oracle and/or its affiliates. All rights reserved. -# -# This program and the accompanying materials are made available under the -# terms of the Eclipse Public License v. 2.0, which is available at -# http://www.eclipse.org/legal/epl-2.0. -# -# This Source Code may also be made available under the following Secondary -# Licenses when the conditions for such availability set forth in the -# Eclipse Public License v. 2.0 are satisfied: GNU General Public License, -# version 2 with the GNU Classpath Exception, which is available at -# https://www.gnu.org/software/classpath/license.html. -# -# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 - -export TCK_HOME=${WORKSPACE} -echo "TCK_HOME in jsonptck.sh $TCK_HOME" -echo "ANT_HOME in jsonptck.sh $ANT_HOME" -echo "PATH in jsonptck.sh $PATH" -echo "ANT_OPTS in jsonptck.sh $ANT_OPTS" - -cd $TCK_HOME - -if ls ${WORKSPACE}/standalone-bundles/*jsonptck*.zip 1> /dev/null 2>&1; then - echo "Using stashed bundle for jsonptck created during the build phase" - unzip -q ${WORKSPACE}/standalone-bundles/*jsonptck*.zip -d ${TCK_HOME} - TCK_NAME=jsonptck -elif ls ${WORKSPACE}/standalone-bundles/*jsonp-tck*.zip 1> /dev/null 2>&1; then - echo "Using stashed bundle for jsonp-tck created during the build phase" - unzip -q ${WORKSPACE}/standalone-bundles/*jsonp-tck*.zip -d ${TCK_HOME} - TCK_NAME=jsonp-tck -else - echo "[ERROR] TCK bundle not found" - exit 1 -fi - -if [ -z "$GF_TOPLEVEL_DIR" ]; then - export GF_TOPLEVEL_DIR=glassfish7 -fi - -##### installRI.sh starts here ##### -echo "Download and install GlassFish 7.0.0 ..." -if [ -z "${GF_BUNDLE_URL}" ]; then - echo "[ERROR] GF_BUNDLE_URL not set" - exit 1 -fi -wget --progress=bar:force --no-cache $GF_BUNDLE_URL -O latest-glassfish.zip -unzip -q ${TCK_HOME}/latest-glassfish.zip -d ${TCK_HOME} - -TS_HOME=$TCK_HOME/$TCK_NAME -echo "TS_HOME $TS_HOME" - -chmod -R 777 $TS_HOME -cd $TS_HOME/bin - -if [[ "$JDK" == "JDK17" || "$JDK" == "jdk17" ]];then - export JAVA_HOME=${JDK17_HOME} -fi -export PATH=$JAVA_HOME/bin:$PATH - -which java -java -version - -sed -i "s#^report.dir=.*#report.dir=$TCK_HOME/${TCK_NAME}report/${TCK_NAME}/#g" ts.jte -sed -i "s#^work.dir=.*#work.dir=$TCK_HOME/${TCK_NAME}work/${TCK_NAME}#g" ts.jte -sed -i "s#jsonp\.classes=.*#jsonp.classes=$TCK_HOME/$GF_TOPLEVEL_DIR/glassfish/modules/jakarta.json.jar:$TCK_HOME/$GF_TOPLEVEL_DIR/glassfish/modules/jakarta.json.jar#g" ts.jte - -if [[ "$PROFILE" == "web" || "$PROFILE" == "WEB" ]]; then - echo "javaee.level=web" >> ts.jte -fi - -mkdir -p $TCK_HOME/${TCK_NAME}report/${TCK_NAME} -mkdir -p $TCK_HOME/${TCK_NAME}work/${TCK_NAME} - -cd $TS_HOME/bin -#ant config.vi -cd $TS_HOME/src/com/sun/ts/tests/ -# ant deploy.all -ant run.all -echo "Test run complete" - -JT_REPORT_DIR=$TCK_HOME/${TCK_NAME}report -export HOST=`hostname -f` -echo "1 ${TCK_NAME} ${HOST}" > ${WORKSPACE}/args.txt -mkdir -p ${WORKSPACE}/results/junitreports/ -${JAVA_HOME}/bin/java -Djunit.embed.sysout=true -jar ${WORKSPACE}/docker/JTReportParser/JTReportParser.jar ${WORKSPACE}/args.txt ${JT_REPORT_DIR} ${WORKSPACE}/results/junitreports/ - -tar zcvf ${WORKSPACE}/${TCK_NAME}-results.tar.gz ${TCK_HOME}/${TCK_NAME}report ${TCK_HOME}/${TCK_NAME}work ${WORKSPACE}/results/junitreports/ ${TCK_HOME}/$GF_TOPLEVEL_DIR/glassfish/domains/domain1 $TCK_HOME/$TCK_NAME/bin/ts.* diff --git a/docker/scripts/tcks/docker-entrypoint.sh b/docker/scripts/tcks/docker-entrypoint.sh index c360219e5b..6d7402dfb5 100755 --- a/docker/scripts/tcks/docker-entrypoint.sh +++ b/docker/scripts/tcks/docker-entrypoint.sh @@ -69,11 +69,6 @@ if [ "$TCK_NAME" == "securityapi" ];then exit 0 fi -if [ "$TCK_NAME" == "jsonp" ];then - source jsonptck.sh - exit 0 -fi - if [ "$TCK_NAME" == "websocket" ];then source websockettck.sh exit 0 diff --git a/docker/scripts/tcks/jsonptck.sh b/docker/scripts/tcks/jsonptck.sh deleted file mode 100644 index cb97175305..0000000000 --- a/docker/scripts/tcks/jsonptck.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -x -# -# Copyright (c) 2018, 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 -# - -cd $TCK_HOME -echo "Download and install JSON-P TCK Bundle ..." -if [ -z "$TCK_BUNDLE_URL" ]; then - wget http:///jsonptck-1.1_Latest.zip -else - echo "Downloading the TCK bundle from $TCK_BUNDLE_URL" - wget $TCK_BUNDLE_URL -O jsonptck-1.1_Latest.zip -fi -unzip jsonptck-1.1_Latest.zip - -TS_HOME=$TCK_HOME/jsonptck -echo "TS_HOME $TS_HOME" - -chmod -R 777 $TS_HOME -cd $TS_HOME/bin - -sed -i "s#^report.dir=.*#report.dir=$TCK_HOME/jsonptckreport#g" ts.jte -sed -i "s#^work.dir=.*#work.dir=$TCK_HOME/jsonptckwork#g" ts.jte -sed -i "s#jsonp\.classes=.*#jsonp.classes=$TCK_HOME/glassfish7/glassfish/modules/javax.json.jar#g" ts.jte - -mkdir $TCK_HOME/jsonptckreport -mkdir $TCK_HOME/jsonptckwork - -cd $TS_HOME/bin -cd $TS_HOME/src/com/sun/ts/tests/ -ant run.all diff --git a/install/jakartaee/bin/sig-test.map b/install/jakartaee/bin/sig-test.map index a1f15ba0a4..c85b640c55 100755 --- a/install/jakartaee/bin/sig-test.map +++ b/install/jakartaee/bin/sig-test.map @@ -151,7 +151,7 @@ jakarta.json=2.1 # JSON-B # (This is JSR-367) -jakarta.json.bind=2.1 +jakarta.json.bind=3.0 # WebSocket 2.1 # (This is JSR-356) diff --git a/install/jsonp/LICENSE.md b/install/jsonp/LICENSE.md deleted file mode 100644 index 5de3d1b40c..0000000000 --- a/install/jsonp/LICENSE.md +++ /dev/null @@ -1,637 +0,0 @@ -# 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) - - 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/install/jsonp/bin/build.xml b/install/jsonp/bin/build.xml deleted file mode 100644 index a6579d2680..0000000000 --- a/install/jsonp/bin/build.xml +++ /dev/null @@ -1,325 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/install/jsonp/bin/harness.policy b/install/jsonp/bin/harness.policy deleted file mode 100644 index 16a8bfabdd..0000000000 --- a/install/jsonp/bin/harness.policy +++ /dev/null @@ -1,4 +0,0 @@ -grant { - // "standard" properies that can be read by anyone - permission java.security.AllPermission ; -}; diff --git a/install/jsonp/bin/java.policy b/install/jsonp/bin/java.policy deleted file mode 100644 index 35733e010f..0000000000 --- a/install/jsonp/bin/java.policy +++ /dev/null @@ -1,5 +0,0 @@ -grant { - // "standard" properies that can be read by anyone - permission java.security.AllPermission ; -}; - diff --git a/install/jsonp/bin/sig-test-pkg-list.txt b/install/jsonp/bin/sig-test-pkg-list.txt deleted file mode 100644 index c4dda85af7..0000000000 --- a/install/jsonp/bin/sig-test-pkg-list.txt +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2017, 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 -# - -# -# $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 -jakarta.json.spi -jakarta.json.stream diff --git a/install/jsonp/bin/sig-test.map b/install/jsonp/bin/sig-test.map deleted file mode 100644 index 041a478b71..0000000000 --- a/install/jsonp/bin/sig-test.map +++ /dev/null @@ -1,35 +0,0 @@ -# -# 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 -# - -############################################################### -# -# -# The signature test mapping file for the JSON-P TCK. This file -# should be formatted as a standard java properties file. The -# name is the package name and the value is the version of the -# package that should be tested by the signature tests. -# -# The resultant signature file name has a name that complies -# with the following format: -# .sig -# Given this format, the following example breaks down as follows: -# jakarta.json.sig: -# = jakarta.json -# = 2.0.0 (for JSON-P) -# -# -############################################################### -jakarta.json=2.1 diff --git a/install/jsonp/bin/smoke.xml b/install/jsonp/bin/smoke.xml deleted file mode 100644 index f095c36dbc..0000000000 --- a/install/jsonp/bin/smoke.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/install/jsonp/bin/ts.jte b/install/jsonp/bin/ts.jte deleted file mode 100644 index 246da6dd07..0000000000 --- a/install/jsonp/bin/ts.jte +++ /dev/null @@ -1,246 +0,0 @@ -# -# Copyright (c) 2018, 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 -# - -######################################################################### -# # -# JavaTest Environment file for JSON-P Compatibility Test Suite # -# # -# Environment specific properties in this file will likely # -# have to be modified prior to running the JSON-P TCK. Instructions # -# for modifying these properties are contained in this file. # -# # -######################################################################### - -############################################################################ -# Properties to set prior to running the JSON-P TCK tests -# -# @jsonp.classes -- Classes of the JSON-P RI Implementation needed to -# build and run the JSON-P TCK -# -# Added to ts.classpath, ts.run.classpath and -# sigTestClasspath below. -############################################################################ -jsonp.classes= - -############################################################################### -# DO NOT MODIFY -# -# @jsonp.resources -- Location of resources used by JSON-P TCK tests -# @jsonp.alt.provider.classes -- Specify location of alternate JsonProvider. -# This is done automatically by run.pluggability -# target in ${ts.home}/bin/build.xml. This target -# in turn calls enable.alternate.jsonp.provider and -# disable.alternate.jsonp.provider targets to enable -# the alternate Json test provider when running the -# pluggability tests for SPI testing and to disable -# it after testing is complete. -# -# Added to ts.run.classpath below. -############################################################################### -jsonp.resources=${ts.home}/src/com/sun/ts/tests/jsonp/resources -jsonp.alt.provider.classes=jsonp.alt.provider.classes - -#################################################################### -# The jars/classes for the TS harness/javatest and the test classes -# @ts.harness.classpath -- Classes required by javatest -# @ts.classpath -- Classes used to build the JSON-P tests -# @ts.run.classpath -- Classes needed by test run -#################################################################### -ts.harness.classpath=${ts.home}/lib/javatest.jar${pathsep}${ts.home}/lib/tsharness.jar${pathsep}${ts.home}/lib/jsonptck.jar${pathsep}${ant.home}/lib/ant.jar${pathsep}${ts.home}/lib/jaxb-api.jar${pathsep}${ts.home}/lib/jaxb-xjc.jar${pathsep}${ts.home}/lib/jaxb-libs.jar${pathsep}${ts.home}/lib/jaxb-impl.jar - -ts.classpath=${jsonp.classes}${pathsep}${ts.home}/lib/tsharness.jar${pathsep}${ts.home}/lib/jsonptck.jar - -ts.run.classpath=${ts.home}/lib/tsharness.jar${pathsep}${ts.home}/lib/sigtest.jar${pathsep}${ts.home}/lib/jsonptck.jar${pathsep}${ts.home}/classes${pathsep}${ts.home}/bin${pathsep}${jsonp.alt.provider.classes}${pathsep}${jsonp.resources}${pathsep}${jsonp.classes} - -########################################################################### -# @tools.jar should be set to the location of the tools.jar from the -# installed jdk -########################################################################### -tools.jar=${jdk.home}/lib/tools.jar - -######################################################################## -## Javatest batch mode work directory and report directory, and policy for -## handling existing work and report directories. These properties affects -## runclient and report targets, but not gui target. -## To disable generating test report, unset report.dir, or set it to "none" -## either here or from command line, as in the following command: -## ant runclient -Dreport.dir="none" -## -# @work.dir The directory used to store Javatest test results and test -# information. -# @report.dir The directory used to store Javatest summary reports of -# test results. -# @if.existing.work.report.dirs specifies how existing work.dir and -# report.dir will be handled, and it must be one of the following values: -# overwrite overwrites all content in work.dir and report.dir -# backup moves all content in work.dir and report.dir to -# work.dir_time_day_bak and report.dir_time_day_bak, -# respectively -# append reuses and preserves the existing work.dir and report.dir -# auto lets the build files decide which mode to use -# (overwrite, backup or append). the value is determined -# like this: -# if.existing.work.report.dirs == auto -# if in JSON-P workspace -# if.existing.work.report.dirs = overwrite -# else we are in a distribution bundle -# if.existing.work.report.dirs = append -# end if -# else -# if.existing.work.report.dirs = value in this file -# end if -######################################################################## -work.dir=/tmp/JTworkjsonp -report.dir=/tmp/JTreportjsonp -if.existing.work.report.dirs=append - -############################################################### -## These properties must be set to tell the Test harness the -## class names of your porting class implementations. By default -## the property settings below point to Sun RI specific classes. -## both property sets below point to Sun RI specific classes. -############################################################### -porting.ts.url.class.1=com.sun.ts.lib.implementation.sun.common.SunRIURL - -######################################################################### -# @jimage.dir: This property specifies the directory where Java 11+ -# modules will be expanded by the jimage tool for use -# in sigTestClasspath -# @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). -######################################################################### -jimage.dir=${ts.home}/tmp/jdk-bundles - -sigTestClasspath=${jsonp.classes}${pathsep}${jimage.dir}/java.base${pathsep}${jimage.dir}/java.rmi${pathsep}${jimage.dir}/java.sql${pathsep}${jimage.dir}/java.naming - -######################################################################## -# These properties are used by the harness. "harness.log.port" -# specifies the port that server components use to send logging -# output back to JavaTest. If the default port # is not available -# on the machine running JavaTest, then you can set it here. -# -# @harness.temp.directory directory location used by the -# harness to store temporary files -# -# @harness.log.port the port the harness listens on for log mesages -# from remote clients -# -# @harness.log.traceflag used to turn on/off verbose debugging output -# for the tests. -# -# @harness.log.delayseconds Number of seconds to delay to allow -# reporting from remote clients to finish. -# -# @harness.executeMode used to run the harness in the following modes -# of execution: 2 - run only -# -# @harness.socket.retry.count - denotes the number of time we should -# attempt to create a server socket when intilizing a test -# client. The socket is used for logging purposes. -######################################################################## -harness.temp.directory=${ts.home}/tmp -harness.log.port=2000 -harness.log.traceflag=false -harness.log.delayseconds=1 -harness.executeMode=2 -harness.socket.retry.count=10 - -############################################################### -# @tz - your local timezone. For valid values, consult your -# Operating System documentation. -############################################################### -tz=US/Eastern - -######################################################################## -# @javatest.timeout.factor This property specifies the scale factor used by -# Javatest to adjust the time JavaTest will wait for a given test to -# complete before returning failure. For instance if the default test timeout -# is 5 minutes, this value will be multiplied by 5 minutes to determine -# the total timeout delay. Note: this value only works with Javatest's -# batch mode (runclient). When using the Javatest GUI users must change -# this timeout factor in the GUI. Configure -> Edit Configuration -> View -# -> choose Standard Values -> select tab Execution -> set Time Factor. -######################################################################## -javatest.timeout.factor=1.0 - -####################################################################### -#build level -####################################################################### -#1: compile only -#2: compile and build component archives (e.g., jar's, war's) -build.level=2 - -############################################################### -# @ts.display -- location to display JSON-P output on Unix -############################################################### -ts.display=:0.0 - -####################################################################### -# default deliverable class -####################################################################### -deliverable.class=com.sun.ts.lib.deliverable.jsonp.JSONPDeliverable - -############################################################### -## This command allows the test clients to be run in -## the same JVM as JavaTest in this case. This mode can be -## enabled by passing "-Dsame.jvm=true" to the runclient or gui -## targets. NOTE: This option is only to be used for sanity -## checking and not when running the TCK for compatibility. -############################################################### -command.testExecuteSameJVM=com.sun.ts.lib.harness.ExecuteTSTestSameJVMCmd \ - $testExecuteClass $testExecuteArgs - -######################################################################## -## Common environment for both ts_unix and ts_win32 -######################################################################## -command.testExecute=com.sun.ts.lib.harness.ExecTSTestCmd \ - CLASSPATH=${ts.run.classpath} \ - DISPLAY="${ts.display}" \ - HOME="${user.home}" \ - windir=${windir} \ - SYSTEMROOT=${SYSTEMROOT} \ - ${JAVA_HOME}/bin/java \ - -Djava.security.policy="${bin.dir}/harness.policy" \ - -Djava.security.manager \ - -Ddeliverable.class=${deliverable.class} \ - $testExecuteClass $testExecuteArgs - -######################################################################### -## Environment for ts_unix -## The test execution commands inherit from common environment -## defined above: testExecute. -## If you need to override it, uncomment it in the following section. -######################################################################### -env.ts_unix.menu=true - -######################################################################## -## Environment for ts_win32 -## The test execution commands inherit from common environment -## defined above: testExecute. -## If you need to override it, uncomment it in the following section. -######################################################################## -env.ts_win32.menu=true - -###################################################################### -## Deliverables must set this property to the name of the deliverable -## specific library jar file (if create.manifest.extension.entries -## is set to true) -###################################################################### -tslib.name=jsonptck diff --git a/install/jsonp/bin/ts.jtx b/install/jsonp/bin/ts.jtx deleted file mode 100644 index fda070d098..0000000000 --- a/install/jsonp/bin/ts.jtx +++ /dev/null @@ -1,20 +0,0 @@ -# -# Copyright (c) 2013, 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 -# - -# -# $Id$ -# - diff --git a/install/jsonp/docs/JSONP2.0-ReleaseNotes.html b/install/jsonp/docs/JSONP2.0-ReleaseNotes.html deleted file mode 100644 index 28c43e5602..0000000000 --- a/install/jsonp/docs/JSONP2.0-ReleaseNotes.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Jakarta JSON Processing TCK Release Notes - - - -
-

Jakarta EE JSON Processing Technology Compatibility Kit, Version 2.0

-

Release Notes, May 2021

-

-
-

Kit Contents

-

The Jakarta EE JSON Processing, Version 2.0 Technology Compatibility Kit - (TCK) includes the following items:

-
    -
  • -

    Jakarta EE JSON Processing TCK tests signature, API, and - pluggability tests:

    -
  • -
      -
    • -

      A signature test that checks that all of the - public APIs are supported in the Jakarta EE JSON Processing Version - 2.0 implementation that is being tested

      -
    • -
    • -

      API tests for all of the public APIs under the jakarta.json, - jakarta.json.spi, jakarta.json.stream - package

      -
    • -
    • -

      Pluggability tests for testing the SPI provider - interface for supplying your own JsonProvider

      -
    • -
    -
-
-

Jakarta EE JSON Processing TCK Facts

-
-

The test suite bundle contains the following:

-
    -
  • 187 total tests
  • -
-
-
-

Platform Notes

-

The Jakarta EE JSON Processing TCK tests have been built with JDK 8 (1.8) - and tested with JavaTM Platform, - Standard Edition 8 and 11

-

The Jakarta EE JSON Processing TCK tests have been run on the following - platforms:

-
    -
  • CentOS 7
  • -
  • Alpine Linux v3.12
  • -
-

The Jakarta EE JSON Processing TCK tests have been run against the - following Jakarta EE JSON Processing 2.0 Compatible Implementations:

-
    -
  • Jakarta EE JSON Processing Compatible Implementation Version 2.0.1
  • -
-
-

Installing, Setting Up, and Running the - JSON-P TCK

-

Refer to the JSON-P TCK 2.0 - User's Guide (or PDF) - for complete instructions on installing, setting up, and running the - JSON-P TCK.

-

The online version of the JT Harness version 5.0 documentation is - available here.

-
-

Copyright 2013, 2021 Oracle and/or its affiliates. All - rights reserved.

- - diff --git a/install/jsonp/docs/assertions/JSONP2.0JavadocAssertions.html b/install/jsonp/docs/assertions/JSONP2.0JavadocAssertions.html deleted file mode 100644 index 42d9ce2dbf..0000000000 --- a/install/jsonp/docs/assertions/JSONP2.0JavadocAssertions.html +++ /dev/null @@ -1,2659 +0,0 @@ - - - - - -JavaDoc Assertion Detail - - -
-
-

Jakarta JSON Processing - 2.0
- JavaDoc Assertion Detail -

-
- - - - - - - - - - - -
TotalsTotalActiveDeprecatedRemoved
- # of Assertions - 4122820130
- # of Required Assertions - 4122820130
- # of Optional Assertions - 0000
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IDReturnMethod/FieldDescriptionRequiredDeprecatedTestable
JSONP:JAVADOC:6JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - JsonValue - ) -
Adds a value to the array.true -
-
true
JSONP:JAVADOC:8JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - String - ) -
Adds a value to the array as a JsonString.true -
-
true
JSONP:JAVADOC:10JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - BigDecimal - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:12JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - BigInteger - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:14JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:16JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - long - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:18JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - double - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:21JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - boolean - ) -
Adds a JsonValue#TRUE or JsonValue#FALSE value to the array.true -
-
true
JSONP:JAVADOC:25JsonArrayBuilderjakarta.json.JsonArrayBuilder.addNull
-
Adds a JsonValue#NULL value to the array.true -
-
true
JSONP:JAVADOC:37JsonExceptionjakarta.json.JsonException.JsonException
- - ( - String - ) -
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.true -
-
true
JSONP:JAVADOC:38JsonExceptionjakarta.json.JsonException.JsonException
- - ( - String - ,
Throwable - ) -
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.true -
-
true
JSONP:JAVADOC:40BigDecimaljakarta.json.JsonNumber.bigDecimalValue
-
Returns this JSON number as a BigDecimal object.true -
-
true
JSONP:JAVADOC:41BigIntegerjakarta.json.JsonNumber.bigIntegerValue
-
Returns this JSON number as a BigInteger object. This is a a convenience method for bigDecimalValue().toBigInteger(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:42BigIntegerjakarta.json.JsonNumber.bigIntegerValueExact
-
Returns this JSON number as a BigInteger object. This is a convenience method for bigDecimalValue().toBigIntegerExact().true -
-
true
JSONP:JAVADOC:44doublejakarta.json.JsonNumber.doubleValue
-
Returns this JSON number as a double. This is a a convenience method for bigDecimalValue().doubleValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:45intjakarta.json.JsonNumber.intValue
-
Returns this JSON number as an int. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:46intjakarta.json.JsonNumber.intValueExact
-
Returns this JSON number as an int.true -
-
true
JSONP:JAVADOC:48longjakarta.json.JsonNumber.longValue
-
Returns this JSON number as a long. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:49longjakarta.json.JsonNumber.longValueExact
-
Returns this JSON number as a long.true -
-
true
JSONP:JAVADOC:51booleanjakarta.json.JsonNumber.isIntegral
-
Returns true if this JSON number is a integral number. This method semantics are defined using bigDecimalValue().scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonNumber num = ... if (num.isIntegral()) { num.longValue(); // or other methods to get integral value } else { num.doubleValue(); // or other methods to get decimal number value }true -
-
true
JSONP:JAVADOC:58JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
JsonValue - ) -
Adds a name/JsonValue pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:61JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
String - ) -
Adds a name/JsonString pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:64JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
BigInteger - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:67JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
BigDecimal - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:70JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
int - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:73JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
long - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:76JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
double - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:80JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
boolean - ) -
Adds a name/JsonValue#TRUE or name/JsonValue#FALSE pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:86JsonObjectBuilderjakarta.json.JsonObjectBuilder.addNull
- - ( - String - ) -
Adds a name/JsonValue#NULL pair to the JSON object associated with this object builder where the value is null. If the object contains a mapping for the specified name, this method replaces the old value with null.true -
-
true
JSONP:JAVADOC:96voidjakarta.json.JsonReader.close
-
Closes this reader and frees any resources associated with the reader. This method closes the underlying input source.true -
-
true
JSONP:JAVADOC:97JsonReaderjakarta.json.Json.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream.true -
-
true
JSONP:JAVADOC:101Stringjakarta.json.JsonString.getString
-
Returns the JSON string value.true -
-
true
JSONP:JAVADOC:102ValueTypejakarta.json.JsonValue.getValueType
-
Returns the value type of this JSON value.true -
-
true
JSONP:JAVADOC:103ValueTypejakarta.json.JsonValue.ValueType.valueOf
- - ( - String - ) -
-
-
true -
-
true
JSONP:JAVADOC:104ValueType[]jakarta.json.JsonValue.ValueType.values
-
-
-
true -
-
true
JSONP:JAVADOC:105voidjakarta.json.JsonWriter.close
-
-
-
true -
-
true
JSONP:JAVADOC:106JsonWriterjakarta.json.Json.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream.true -
-
true
JSONP:JAVADOC:107voidjakarta.json.JsonWriter.writeArray
- - ( - JsonArray - ) -
Writes the specified JSON JsonArray array to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:110voidjakarta.json.JsonWriter.writeObject
- - ( - JsonObject - ) -
Writes the specified JSON JsonObject object to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:115voidjakarta.json.stream.JsonGenerator.close
-
Closes this generator and frees any resources associated with it. This method closes the underlying output source.true -
-
true
JSONP:JAVADOC:117voidjakarta.json.stream.JsonParser.close
-
Closes this parser and frees any resources associated with the parser. This method closes the underlying input source.true -
-
true
JSONP:JAVADOC:120booleanjakarta.json.stream.JsonParser.isIntegralNumber
-
Returns true if the JSON number at the current parser state is a integral number. A BigDecimal may be used to store the value internally and this method semantics are defined using its scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonParser parser = ... if (parser.isIntegralNumber()) { parser.getInt(); // or other methods to get integral value } else { parser.getBigDecimal(); }true -
-
true
JSONP:JAVADOC:122Stringjakarta.json.stream.JsonParser.getString
-
Returns a String for the name in a name/value pair, for a string value or a number value. This method should only be called when the parser state is Event#KEY_NAME, Event#VALUE_STRING, or Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:128Eventjakarta.json.stream.JsonParser.Event.valueOf
- - ( - String - ) -
-
-
true -
-
true
JSONP:JAVADOC:129Event[]jakarta.json.stream.JsonParser.Event.values
-
-
-
true -
-
true
JSONP:JAVADOC:131JsonGeneratorjakarta.json.Json.createGenerator
- - ( - Writer - ) -
Creates a JSON generator for writing JSON to a character stream.true -
-
true
JSONP:JAVADOC:133JsonParserjakarta.json.Json.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:144JsonGeneratorjakarta.json.spi.JsonProvider.createGenerator
- - ( - Writer - ) -
Creates a JSON generator for writing JSON text to a character stream.true -
-
true
JSONP:JAVADOC:146JsonParserjakarta.json.spi.JsonProvider.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:152JsonProviderjakarta.json.spi.JsonProvider.provider
-
Creates a JSON provider object. The provider is loaded using the ServiceLoader#load(Class) method. If there are no available service providers, this method returns the default service provider. Users are recommended to cache the result of this method.true -
-
true
JSONP:JAVADOC:162JsonGeneratorjakarta.json.stream.JsonGeneratorFactory.createGenerator
- - ( - Writer - ) -
Creates a JSON generator to write JSON text to a character stream. The generator is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:163JsonGeneratorjakarta.json.stream.JsonGeneratorFactory.createGenerator
- - ( - OutputStream - ,
Charset - ) -
Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using the specified charset. The generator is configured with the factory's configuration.true -
-
true
JSONP:JAVADOC:164JsonParserjakarta.json.stream.JsonParserFactory.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:165JsonParserjakarta.json.stream.JsonParserFactory.createParser
- - ( - InputStream - ) -
Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as specified in RFC 7159.true -
-
true
JSONP:JAVADOC:166JsonParserjakarta.json.stream.JsonParserFactory.createParser
- - ( - JsonObject - ) -
Creates a JSON parser from the specified JSON object.true -
-
true
JSONP:JAVADOC:167JsonParserjakarta.json.stream.JsonParserFactory.createParser
- - ( - JsonArray - ) -
Creates a JSON parser from the specified JSON array.true -
-
true
JSONP:JAVADOC:168JsonGeneratorjakarta.json.Json.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator for writing JSON to a byte stream.true -
-
true
JSONP:JAVADOC:172JsonParserjakarta.json.Json.createParser
- - ( - InputStream - ) -
Creates a JSON parser from a byte stream. The character encoding of the stream is determined as specified in RFC 7159.true -
-
true
JSONP:JAVADOC:178JsonReaderjakarta.json.Json.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159.true -
-
true
JSONP:JAVADOC:181JsonStructurejakarta.json.JsonReader.read
-
Returns a JSON array or object that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:184JsonArrayjakarta.json.JsonReader.readArray
-
Returns a JSON array that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:185JsonObjectjakarta.json.JsonReader.readObject
-
Returns a JSON object that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:187JsonWriterjakarta.json.Json.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding.true -
-
true
JSONP:JAVADOC:191voidjakarta.json.JsonWriter.write
- - ( - JsonStructure - ) -
Writes the specified JSON JsonObject object or JsonArray array to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:192JsonGeneratorjakarta.json.spi.JsonProvider.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator for writing JSON text to a byte stream.true -
-
true
JSONP:JAVADOC:196JsonParserjakarta.json.spi.JsonProvider.createParser
- - ( - InputStream - ) -
Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as defined in RFC 7159 .true -
-
true
JSONP:JAVADOC:200JsonGeneratorjakarta.json.stream.JsonGeneratorFactory.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The generator is configured with the factory's configuration.true -
-
true
JSONP:JAVADOC:201JsonParserjakarta.json.stream.JsonParserFactory.createParser
- - ( - InputStream - ,
Charset - ) -
Creates a JSON parser from the specified byte stream. The bytes of the stream are decoded to characters using the specified charset.true -
-
true
JSONP:JAVADOC:215Stringjakarta.json.JsonNumber.toString
-
Returns a JSON text representation of the JSON number. The representation is equivalent to BigDecimal#toString().true -
-
true
JSONP:JAVADOC:235BigDecimaljakarta.json.stream.JsonParser.getBigDecimal
-
Returns a JSON number as a BigDecimal. The BigDecimal is created using new BigDecimal(getString()). This method should only called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:237intjakarta.json.stream.JsonParser.getInt
-
Returns a JSON number as an integer. The returned value is equal to new BigDecimal(getString()).intValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method should only be called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:239longjakarta.json.stream.JsonParser.getLong
-
Returns a JSON number as a long. The returned value is equal to new BigDecimal(getString()).longValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method is only called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:250booleanjakarta.json.JsonNumber.equals
- - ( - Object - ) -
Compares the specified object with this JsonNumber object for equality. Returns true if and only if the type of the specified object is also JsonNumber and their #bigDecimalValue() objects are equaltrue -
-
true
JSONP:JAVADOC:251intjakarta.json.JsonNumber.hashCode
-
Returns the hash code value for this JsonNumber object. The hash code of a JsonNumber object is defined as the hash code of its #bigDecimalValue() object.true -
-
true
JSONP:JAVADOC:254booleanjakarta.json.JsonString.equals
- - ( - Object - ) -
Compares the specified object with this JsonString for equality. Returns true if and only if the specified object is also a JsonString, and their #getString() objects are equal.true -
-
true
JSONP:JAVADOC:255intjakarta.json.JsonString.hashCode
-
Returns the hash code value for this JsonString object. The hash code of a JsonString object is defined to be its #getString() object's hash code.true -
-
true
JSONP:JAVADOC:262intjakarta.json.JsonArray.getInt
- - ( - int - ) -
A convenience method for getJsonNumber(index).intValue().true -
-
true
JSONP:JAVADOC:263Stringjakarta.json.JsonArray.getString
- - ( - int - ) -
A convenience method for getJsonString(index).getString().true -
-
true
JSONP:JAVADOC:264intjakarta.json.JsonObject.getInt
- - ( - String - ) -
A convenience method for getJsonNumber(name).intValue()true -
-
true
JSONP:JAVADOC:265Stringjakarta.json.JsonObject.getString
- - ( - String - ) -
A convenience method for getJsonString(name).getString()true -
-
true
JSONP:JAVADOC:278JsonGenerationExceptionjakarta.json.stream.JsonGenerationException.JsonGenerationException
- - ( - String - ) -
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.true -
-
true
JSONP:JAVADOC:279JsonGenerationExceptionjakarta.json.stream.JsonGenerationException.JsonGenerationException
- - ( - String - ,
Throwable - ) -
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.true -
-
true
JSONP:JAVADOC:285JsonParsingExceptionjakarta.json.stream.JsonParsingException.JsonParsingException
- - ( - String - ,
JsonLocation - ) -
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.true -
-
true
JSONP:JAVADOC:286JsonParsingExceptionjakarta.json.stream.JsonParsingException.JsonParsingException
- - ( - String - ,
Throwable - ,
JsonLocation - ) -
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.true -
-
true
JSONP:JAVADOC:288Stringjakarta.json.JsonValue.toString
-
Returns JSON text for this JSON value.true -
-
true
JSONP:JAVADOC:289JsonGeneratorjakarta.json.stream.JsonGenerator.writeEnd
-
Writes the end of the current context. If the current context is an array context, this method writes the end-of-array character (']'). If the current context is an object context, this method writes the end-of-object character ('}'). After writing the end of the current context, the parent context becomes the new current context. If parent context is field context, it is closed.true -
-
true
JSONP:JAVADOC:291voidjakarta.json.stream.JsonGenerator.flush
-
Flushes the underlying output source. If the generator has saved any characters in a buffer, writes them immediately to the underlying output source before flushing it.true -
-
true
JSONP:JAVADOC:292JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ,
JsonValue - ) -
Writes a JSON name/value pair in the current object context.true -
-
true
JSONP:JAVADOC:295JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ,
String - ) -
Writes a JSON name/string value pair in the current object context. The specified value is written as JSON string value.true -
-
true
JSONP:JAVADOC:298JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ,
BigInteger - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:301JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ,
BigDecimal - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The specified value's toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:304JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ,
int - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:307JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ,
long - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:310JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ,
double - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string BigDecimal.valueOf(double).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:314JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ,
boolean - ) -
Writes a JSON name/boolean value pair in the current object context. If value is true, it writes the JSON true value, otherwise it writes the JSON false value.true -
-
true
JSONP:JAVADOC:317JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - JsonValue - ) -
Writes the specified value as a JSON value within the current array, field or root context.true -
-
true
JSONP:JAVADOC:319JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - String - ) -
Writes the specified value as a JSON string value within the current array, field or root context.true -
-
true
JSONP:JAVADOC:321JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - BigDecimal - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The specified value's toString() is used as the the text value for writing.true -
-
true
JSONP:JAVADOC:323JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - BigInteger - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:325JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - int - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:327JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - long - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:329JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - double - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The string BigDecimal.valueOf(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:332JsonGeneratorjakarta.json.stream.JsonGenerator.write
- - ( - boolean - ) -
Writes a JSON true or false value within the current array, field or root context. If value is true, this method writes the JSON true value, otherwise it writes the JSON false value.true -
-
true
JSONP:JAVADOC:334JsonGeneratorjakarta.json.stream.JsonGenerator.writeNull
- - ( - String - ) -
Writes a JSON name/null value pair in an current object context.true -
-
true
JSONP:JAVADOC:337JsonGeneratorjakarta.json.stream.JsonGenerator.writeNull
-
Writes a JSON null value within the current array, field or root context.true -
-
true
JSONP:JAVADOC:339JsonGeneratorjakarta.json.stream.JsonGenerator.writeStartArray
-
Writes the JSON start array character. It starts a new child array context within which JSON values can be written to the array. This method is valid only in an array context, field context or in no context (when a context is not yet started). This method can only be called once in no context.true -
-
true
JSONP:JAVADOC:340JsonGeneratorjakarta.json.stream.JsonGenerator.writeStartArray
- - ( - String - ) -
Writes the JSON name/start array character pair with in the current object context. It starts a new child array context within which JSON values can be written to the array.true -
-
true
JSONP:JAVADOC:341JsonGeneratorjakarta.json.stream.JsonGenerator.writeStartObject
-
Writes the JSON start object character. It starts a new child object context within which JSON name/value pairs can be written to the object. This method is valid only in an array context, field context or in no context (when a context is not yet started). This method can only be called once in no context.true -
-
true
JSONP:JAVADOC:342JsonGeneratorjakarta.json.stream.JsonGenerator.writeStartObject
- - ( - String - ) -
Writes the JSON name/start object character pair in the current object context. It starts a new child object context within which JSON name/value pairs can be written to the object.true -
-
true
JSONP:JAVADOC:375booleanjakarta.json.stream.JsonParser.hasNext
-
Returns true if there are more parsing states. This method returns false if the parser reaches the end of the JSON text.true -
-
true
JSONP:JAVADOC:376Eventjakarta.json.stream.JsonParser.next
-
Returns the event for the next parsing state.true -
-
true
JSONP:JAVADOC:383CharSequencejakarta.json.JsonString.getChars
-
Returns the char sequence for the JSON String valuetrue -
-
true
JSONP:JAVADOC:400JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - JsonObjectBuilder - ) -
Adds a JsonObject from an object builder to the array.true -
-
true
JSONP:JAVADOC:401JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - JsonArrayBuilder - ) -
Adds a JsonArray from an array builder to the array.true -
-
true
JSONP:JAVADOC:402JsonArrayjakarta.json.JsonArrayBuilder.build
-
Returns the current array.true -
-
true
JSONP:JAVADOC:403JsonArrayBuilderjakarta.json.Json.createArrayBuilder
-
Creates a JSON array buildertrue -
-
true
JSONP:JAVADOC:404JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
JsonObjectBuilder - ) -
Adds a name/JsonObject pair to the JSON object associated with this object builder. The value JsonObject is built from the specified object builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonObject from the specified object builder.true -
-
true
JSONP:JAVADOC:406JsonObjectBuilderjakarta.json.JsonObjectBuilder.add
- - ( - String - ,
JsonArrayBuilder - ) -
Adds a name/JsonArray pair to the JSON object associated with this object builder. The value JsonArray is built from the specified array builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonArray from the specified array builder.true -
-
true
JSONP:JAVADOC:408JsonObjectjakarta.json.JsonObjectBuilder.build
-
Returns the JSON object associated with this object builder. The iteration order for the JsonObject is based on the order in which name/value pairs are added to the object using this builder.true -
-
true
JSONP:JAVADOC:409JsonObjectBuilderjakarta.json.Json.createObjectBuilder
-
Creates a JSON object buildertrue -
-
true
JSONP:JAVADOC:416JsonGeneratorFactoryjakarta.json.Json.createGeneratorFactory
- - ( - Map - ) -
Creates a generator factory for creating JsonGenerator objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:417JsonParserFactoryjakarta.json.Json.createParserFactory
- - ( - Map - ) -
Creates a parser factory for creating JsonParser objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:419JsonReaderjakarta.json.JsonReaderFactory.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:420JsonReaderjakarta.json.JsonReaderFactory.createReader
- - ( - InputStream - ,
Charset - ) -
Creates a JSON reader from a byte stream. The bytes of the stream are decoded to characters using the specified charset. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:422JsonWriterjakarta.json.JsonWriterFactory.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:423JsonWriterjakarta.json.JsonWriterFactory.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:424JsonWriterjakarta.json.JsonWriterFactory.createWriter
- - ( - OutputStream - ,
Charset - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using the specified charset. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:425JsonGeneratorFactoryjakarta.json.spi.JsonProvider.createGeneratorFactory
- - ( - Map - ) -
Creates a generator factory for creating JsonGenerator instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:426JsonParserFactoryjakarta.json.spi.JsonProvider.createParserFactory
- - ( - Map - ) -
Creates a parser factory for creating JsonParser instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:427Mapjakarta.json.stream.JsonGeneratorFactory.getConfigInUse
-
Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON generators. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:428Mapjakarta.json.stream.JsonParserFactory.getConfigInUse
-
Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON parsers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:429JsonReaderjakarta.json.JsonReaderFactory.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:430booleanjakarta.json.JsonArray.getBoolean
- - ( - int - ) -
Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false.true -
-
true
JSONP:JAVADOC:433booleanjakarta.json.JsonArray.getBoolean
- - ( - int - ,
boolean - ) -
Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false. Otherwise this method returns the specified default value.true -
-
true
JSONP:JAVADOC:434intjakarta.json.JsonArray.getInt
- - ( - int - ,
int - ) -
Returns the int value of the JsonNumber at the specified position. If the value at that position is a JsonNumber, this method returns jakarta.json.JsonNumber#intValue(). Otherwise this method returns the specified default value.true -
-
true
JSONP:JAVADOC:435Stringjakarta.json.JsonArray.getString
- - ( - int - ,
String - ) -
Returns the String value of JsonString at the specified position in this JSON array values. If JsonString is found, its jakarta.json.JsonString#getString() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:436booleanjakarta.json.JsonObject.getBoolean
- - ( - String - ) -
Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false.true -
-
true
JSONP:JAVADOC:439booleanjakarta.json.JsonObject.getBoolean
- - ( - String - ,
boolean - ) -
Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:441intjakarta.json.JsonObject.getInt
- - ( - String - ,
int - ) -
Returns the int value of the associated JsonNumber mapping for the specified name. If JsonNumber is found, then its jakarta.json.JsonNumber#intValue() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:443Stringjakarta.json.JsonObject.getString
- - ( - String - ,
String - ) -
Returns the string value of the associated JsonString mapping for the specified name. If JsonString is found, then its jakarta.json.JsonString#getString() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:445JsonBuilderFactoryjakarta.json.Json.createBuilderFactory
- - ( - Map - ) -
Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:449JsonReaderFactoryjakarta.json.Json.createReaderFactory
- - ( - Map - ) -
Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:452JsonWriterFactoryjakarta.json.Json.createWriterFactory
- - ( - Map - ) -
Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:453JsonArrayBuilderjakarta.json.JsonBuilderFactory.createArrayBuilder
-
Creates a JsonArrayBuilder instance that is used to build JsonArraytrue -
-
true
JSONP:JAVADOC:454JsonObjectBuilderjakarta.json.JsonBuilderFactory.createObjectBuilder
-
Creates a JsonObjectBuilder instance that is used to build JsonObject.true -
-
true
JSONP:JAVADOC:455Mapjakarta.json.JsonBuilderFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON builders. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:459Mapjakarta.json.JsonReaderFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON readers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:463Mapjakarta.json.JsonWriterFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON writer objects. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:464JsonArrayBuilderjakarta.json.spi.JsonProvider.createArrayBuilder
-
Creates a JSON array builder.true -
-
true
JSONP:JAVADOC:465JsonBuilderFactoryjakarta.json.spi.JsonProvider.createBuilderFactory
- - ( - Map - ) -
Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:466JsonObjectBuilderjakarta.json.spi.JsonProvider.createObjectBuilder
-
Creates a JSON object builder.true -
-
true
JSONP:JAVADOC:467JsonReaderjakarta.json.spi.JsonProvider.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream.true -
-
true
JSONP:JAVADOC:468JsonReaderjakarta.json.spi.JsonProvider.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159.true -
-
true
JSONP:JAVADOC:469JsonReaderFactoryjakarta.json.spi.JsonProvider.createReaderFactory
- - ( - Map - ) -
Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:470JsonWriterjakarta.json.spi.JsonProvider.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream.true -
-
true
JSONP:JAVADOC:471JsonWriterjakarta.json.spi.JsonProvider.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding.true -
-
true
JSONP:JAVADOC:472JsonWriterFactoryjakarta.json.spi.JsonProvider.createWriterFactory
- - ( - Map - ) -
Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:474longjakarta.json.stream.JsonLocation.getColumnNumber
-
Return the column number (starts with 1 for the first column) for the current JSON event in the input source.true -
-
true
JSONP:JAVADOC:475longjakarta.json.stream.JsonLocation.getLineNumber
-
Return the line number (starts with 1 for the first line) for the current JSON event in the input source.true -
-
true
JSONP:JAVADOC:476longjakarta.json.stream.JsonLocation.getStreamOffset
-
Return the stream offset into the input source this location is pointing to. If the input source is a file or a byte stream then this is the byte offset into that stream, but if the input source is a character media then the offset is the character offset. Returns -1 if there is no offset available.true -
-
true
JSONP:JAVADOC:477JsonLocationjakarta.json.stream.JsonParser.getLocation
-
Return the location that corresponds to the parser's current state in the JSON input source. The location information is only valid in the current parser state (or until the parser is advanced to a next state).true -
-
true
JSONP:JAVADOC:478JsonLocationjakarta.json.stream.JsonParsingException.getLocation
-
Return the location of the incorrect JSON.true -
-
true
JSONP:JAVADOC:481Listjakarta.json.JsonArray.getValuesAs
- - ( - Class - ) -
Returns a list view of the specified type for the array. This method does not verify if there is a value of wrong type in the array. Providing this typesafe view dynamically may cause a program fail with a ClassCastException, if there is a value of wrong type in this array. Unfortunately, the exception can occur at any time after this method returns.true -
-
true
JSONP:JAVADOC:490JsonArrayjakarta.json.JsonArray.getJsonArray
- - ( - int - ) -
Returns the array value at the specified position in this array. This is a convenience method for (JsonArray)get(index).true -
-
true
JSONP:JAVADOC:493JsonNumberjakarta.json.JsonArray.getJsonNumber
- - ( - int - ) -
Returns the number value at the specified position in this array. This is a convenience method for (JsonNumber)get(index).true -
-
true
JSONP:JAVADOC:496JsonObjectjakarta.json.JsonArray.getJsonObject
- - ( - int - ) -
Returns the object value at the specified position in this array. This is a convenience method for (JsonObject)get(index).true -
-
true
JSONP:JAVADOC:499JsonStringjakarta.json.JsonArray.getJsonString
- - ( - int - ) -
Returns the string value at ths specified position in this array. This is a convenience method for (JsonString)get(index).true -
-
true
JSONP:JAVADOC:506booleanjakarta.json.JsonArray.isNull
- - ( - int - ) -
Returns true if the value at the specified location in this array is JsonValue.NULL.true -
-
true
JSONP:JAVADOC:527JsonArrayjakarta.json.JsonObject.getJsonArray
- - ( - String - ) -
Returns the array value to which the specified name is mapped. This is a convenience method for (JsonArray)get(name) to get the value.true -
-
true
JSONP:JAVADOC:529JsonNumberjakarta.json.JsonObject.getJsonNumber
- - ( - String - ) -
Returns the number value to which the specified name is mapped. This is a convenience method for (JsonNumber)get(name) to get the value.true -
-
true
JSONP:JAVADOC:531JsonObjectjakarta.json.JsonObject.getJsonObject
- - ( - String - ) -
Returns the object value to which the specified name is mapped. This is a convenience method for (JsonObject)get(name) to get the value.true -
-
true
JSONP:JAVADOC:533JsonStringjakarta.json.JsonObject.getJsonString
- - ( - String - ) -
Returns the string value to which the specified name is mapped. This is a convenience method for (JsonString)get(name) to get the value.true -
-
true
JSONP:JAVADOC:539booleanjakarta.json.JsonObject.isNull
- - ( - String - ) -
Returns true if the associated value for the specified name is JsonValue.NULL.true -
-
true
JSONP:JAVADOC:572JsonArrayBuilderjakarta.json.Json.createArrayBuilder
- - ( - JsonArray - ) -
Creates a JSON array builder, initialized with the specified arraytrue -
-
true
JSONP:JAVADOC:573JsonArrayBuilderjakarta.json.Json.createArrayBuilder
- - ( - Collection - ) -
Creates a JSON array builder, initialized with the specified arraytrue -
-
true
JSONP:JAVADOC:574JsonPatchjakarta.json.Json.createDiff
- - ( - JsonStructure - ,
JsonStructure - ) -
Generates a JSON Patch (RFC 6902) from the source and target JsonStructure. The generated JSON Patch need not be unique.true -
-
true
JSONP:JAVADOC:575JsonMergePatchjakarta.json.Json.createMergeDiff
- - ( - JsonValue - ,
JsonValue - ) -
Generates a JSON Merge Patch (RFC 7396) from the source and target JsonValues which when applied to the source, yields the target.true -
-
true
JSONP:JAVADOC:576JsonMergePatchjakarta.json.Json.createMergePatch
- - ( - JsonValue - ) -
Creates JSON Merge Patch (RFC 7396) from specified JsonValue.true -
-
true
JSONP:JAVADOC:577JsonObjectBuilderjakarta.json.Json.createObjectBuilder
- - ( - JsonObject - ) -
Creates a JSON object builder, initialized with the specified object.true -
-
true
JSONP:JAVADOC:578JsonObjectBuilderjakarta.json.Json.createObjectBuilder
- - ( - Map - ) -
Creates a JSON object builder, initialized with the specified object.true -
-
true
JSONP:JAVADOC:579JsonPatchjakarta.json.Json.createPatch
- - ( - JsonArray - ) -
Creates a JSON Patch (RFC 6902) from the specified operations.true -
-
true
JSONP:JAVADOC:580JsonPatchBuilderjakarta.json.Json.createPatchBuilder
-
Creates a JSON Patch builder (RFC 6902).true -
-
true
JSONP:JAVADOC:581JsonPatchBuilderjakarta.json.Json.createPatchBuilder
- - ( - JsonArray - ) -
Creates a JSON Patch builder (RFC 6902), initialized with the specified operations.true -
-
true
JSONP:JAVADOC:582JsonPointerjakarta.json.Json.createPointer
- - ( - String - ) -
Creates JSON Pointer (RFC 6901) from given jsonPointer string. An empty jsonPointer string defines a reference to the target itself. If the jsonPointer string is non-empty, it must be a sequence of '/' prefixed tokens.true -
-
true
JSONP:JAVADOC:583JsonStringjakarta.json.Json.createValue
- - ( - String - ) -
Creates a JsonString.true -
-
true
JSONP:JAVADOC:584JsonNumberjakarta.json.Json.createValue
- - ( - int - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:585JsonNumberjakarta.json.Json.createValue
- - ( - long - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:586JsonNumberjakarta.json.Json.createValue
- - ( - double - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:587JsonNumberjakarta.json.Json.createValue
- - ( - BigDecimal - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:588JsonNumberjakarta.json.Json.createValue
- - ( - BigInteger - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:589Listjakarta.json.JsonArray.getValuesAs
- - ( - Function - ) -
Returns a list view for the array. The value and the type of the elements in the list is specified by the func argument. This method can be used to obtain a list of the unwrapped types, such as List strings = ary1.getValuesAs(JsonString::getString); List ints = ary2.getValuesAs(JsonNumber::intValue); or a list of simple projections, such as List stringsizes = ary1.getValueAs((JsonString v)->v.getString().length();true -
-
true
JSONP:JAVADOC:590JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
JsonValue - ) -
Inserts a value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:591JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
String - ) -
Adds a value to the array as a JsonString at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:592JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
BigDecimal - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:593JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
BigInteger - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:594JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
int - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:595JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
long - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:596JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
double - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:597JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
boolean - ) -
Adds a JsonValue#TRUE or JsonValue#FALSE value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:598JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
JsonObjectBuilder - ) -
Adds a JsonObject from an object builder to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:599JsonArrayBuilderjakarta.json.JsonArrayBuilder.add
- - ( - int - ,
JsonArrayBuilder - ) -
Adds a JsonArray from an array builder to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:600JsonArrayBuilderjakarta.json.JsonArrayBuilder.addAll
- - ( - JsonArrayBuilder - ) -
Adds all elements of the array in the specified array builder to the array.true -
-
true
JSONP:JAVADOC:601JsonArrayBuilderjakarta.json.JsonArrayBuilder.addNull
- - ( - int - ) -
Adds a JsonValue#NULL value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:602JsonArrayBuilderjakarta.json.JsonArrayBuilder.remove
- - ( - int - ) -
Remove the value in the array at the specified position. Shift any subsequent values to the left (subtracts one from their indices.true -
-
true
JSONP:JAVADOC:603JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
JsonValue - ) -
Replaces a value in the array with the specified value at the specified position.true -
-
true
JSONP:JAVADOC:604JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
String - ) -
Replaces a value in the array with the specified value as a JsonString at the specified position.true -
-
true
JSONP:JAVADOC:605JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
BigDecimal - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:606JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
BigInteger - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:607JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
int - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:608JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
long - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:609JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
double - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:610JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
boolean - ) -
Replaces a value in the array with a JsonValue#TRUE or JsonValue#FALSE value at the specified position.true -
-
true
JSONP:JAVADOC:611JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
JsonObjectBuilder - ) -
Replaces a value in the array with the specified value as a JsonObject from an object builder at the specified position.true -
-
true
JSONP:JAVADOC:612JsonArrayBuilderjakarta.json.JsonArrayBuilder.set
- - ( - int - ,
JsonArrayBuilder - ) -
Replaces a value in the array with the specified value as a JsonArray from an array builder at the specified position.true -
-
true
JSONP:JAVADOC:613JsonArrayBuilderjakarta.json.JsonArrayBuilder.setNull
- - ( - int - ) -
Replaces a value in the array with a JsonValue#NULL value at the specified position.true -
-
true
JSONP:JAVADOC:614JsonArrayBuilderjakarta.json.JsonBuilderFactory.createArrayBuilder
- - ( - JsonArray - ) -
Creates a JsonArrayBuilder instance, initialized with an array.true -
-
true
JSONP:JAVADOC:615JsonObjectBuilderjakarta.json.JsonBuilderFactory.createObjectBuilder
- - ( - JsonObject - ) -
Creates a JsonObjectBuilder instance, initialized with an object.true -
-
true
JSONP:JAVADOC:616JsonValuejakarta.json.JsonMergePatch.apply
- - ( - JsonValue - ) -
Applies the JSON Merge Patch to the specified target. The target is not modified by the patch.true -
-
true
JSONP:JAVADOC:617JsonValuejakarta.json.JsonMergePatch.toJsonValue
-
Returns the JsonMergePatch as JsonValue.true -
-
true
JSONP:JAVADOC:618JsonObjectBuilderjakarta.json.JsonObjectBuilder.addAll
- - ( - JsonObjectBuilder - ) -
Adds all name/value pairs in the JSON object associated with the specified object builder to the JSON object associated with this object builder. The newly added name/value pair will replace any existing name/value pair with the same name.true -
-
true
JSONP:JAVADOC:619JsonObjectBuilderjakarta.json.JsonObjectBuilder.remove
- - ( - String - ) -
Remove the name/value pair from the JSON object associated with this object builder if it is present.true -
-
true
JSONP:JAVADOC:620JsonStructurejakarta.json.JsonPatch.apply
- - ( - JsonStructure - ) -
Applies the patch operations to the specified target. The target is not modified by the patch.true -
-
true
JSONP:JAVADOC:621JsonArrayjakarta.json.JsonPatch.toJsonArray
-
Returns the JsonPatch as JsonArray.true -
-
true
JSONP:JAVADOC:622Operationjakarta.json.JsonPatch.Operation.fromOperationName
- - ( - String - ) -
Returns the enum constant with the specified name.true -
-
true
JSONP:JAVADOC:623Stringjakarta.json.JsonPatch.Operation.operationName
-
Returns enum constant name as lower case string.true -
-
true
JSONP:JAVADOC:624Operationjakarta.json.JsonPatch.Operation.valueOf
- - ( - String - ) -
-
-
true -
-
true
JSONP:JAVADOC:625Operation[]jakarta.json.JsonPatch.Operation.values
-
-
-
true -
-
true
JSONP:JAVADOC:626JsonPatchBuilderjakarta.json.JsonPatchBuilder.add
- - ( - String - ,
JsonValue - ) -
Adds an "add" JSON Patch operation.true -
-
true
JSONP:JAVADOC:627JsonPatchBuilderjakarta.json.JsonPatchBuilder.add
- - ( - String - ,
String - ) -
Adds an "add" JSON Patch operation.true -
-
true
JSONP:JAVADOC:628JsonPatchBuilderjakarta.json.JsonPatchBuilder.add
- - ( - String - ,
int - ) -
Adds an "add" JSON Patch operation.true -
-
true
JSONP:JAVADOC:629JsonPatchBuilderjakarta.json.JsonPatchBuilder.add
- - ( - String - ,
boolean - ) -
Adds an "add" JSON Patch operation.true -
-
true
JSONP:JAVADOC:630JsonPatchjakarta.json.JsonPatchBuilder.build
-
Returns the JSON Patch.true -
-
true
JSONP:JAVADOC:631JsonPatchBuilderjakarta.json.JsonPatchBuilder.copy
- - ( - String - ,
String - ) -
Adds a "copy" JSON Patch operation.true -
-
true
JSONP:JAVADOC:632JsonPatchBuilderjakarta.json.JsonPatchBuilder.move
- - ( - String - ,
String - ) -
Adds a "move" JSON Patch operation.true -
-
true
JSONP:JAVADOC:633JsonPatchBuilderjakarta.json.JsonPatchBuilder.remove
- - ( - String - ) -
Adds a "remove" JSON Patch operation.true -
-
true
JSONP:JAVADOC:634JsonPatchBuilderjakarta.json.JsonPatchBuilder.replace
- - ( - String - ,
JsonValue - ) -
Adds a "replace" JSON Patch operation.true -
-
true
JSONP:JAVADOC:635JsonPatchBuilderjakarta.json.JsonPatchBuilder.replace
- - ( - String - ,
String - ) -
Adds a "replace" JSON Patch operation.true -
-
true
JSONP:JAVADOC:636JsonPatchBuilderjakarta.json.JsonPatchBuilder.replace
- - ( - String - ,
int - ) -
Adds a "replace" JSON Patch operation.true -
-
true
JSONP:JAVADOC:637JsonPatchBuilderjakarta.json.JsonPatchBuilder.replace
- - ( - String - ,
boolean - ) -
Adds a "replace" JSON Patch operation.true -
-
true
JSONP:JAVADOC:638JsonPatchBuilderjakarta.json.JsonPatchBuilder.test
- - ( - String - ,
JsonValue - ) -
Adds a "test" JSON Patch operation.true -
-
true
JSONP:JAVADOC:639JsonPatchBuilderjakarta.json.JsonPatchBuilder.test
- - ( - String - ,
String - ) -
Adds a "test" JSON Patch operation.true -
-
true
JSONP:JAVADOC:640JsonPatchBuilderjakarta.json.JsonPatchBuilder.test
- - ( - String - ,
int - ) -
Adds a "test" JSON Patch operation.true -
-
true
JSONP:JAVADOC:641JsonPatchBuilderjakarta.json.JsonPatchBuilder.test
- - ( - String - ,
boolean - ) -
Adds a "test" JSON Patch operation.true -
-
true
JSONP:JAVADOC:642JsonStructurejakarta.json.JsonPointer.add
- - ( - JsonStructure - ,
JsonValue - ) -
Adds or replaces a value at the referenced location in the specified target with the specified value. If the reference is the target (empty JSON Pointer string), the specified value, which must be the same type as specified target, is returned. If the reference is an array element, the specified value is inserted into the array, at the referenced index. The value currently at that location, and any subsequent values, are shifted to the right (adds one to the indices). Index starts with 0. If the reference is specified with a "-", or if the index is equal to the size of the array, the value is appended to the array. If the reference is a name/value pair of a JsonObject, and the referenced value exists, the value is replaced by the specified value. If the value does not exist, a new name/value pair is added to the object.true -
-
true
JSONP:JAVADOC:643JsonValuejakarta.json.JsonPointer.getValue
- - ( - JsonStructure - ) -
Returns the value at the referenced location in the specified target.true -
-
true
JSONP:JAVADOC:644JsonStructurejakarta.json.JsonPointer.remove
- - ( - JsonStructure - ) -
Removes the value at the reference location in the specified target.true -
-
true
JSONP:JAVADOC:645JsonStructurejakarta.json.JsonPointer.replace
- - ( - JsonStructure - ,
JsonValue - ) -
Replaces the value at the referenced location in the specified target with the specified value.true -
-
true
JSONP:JAVADOC:646JsonValuejakarta.json.JsonReader.readValue
-
Returns a JSON value that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:647JsonValuejakarta.json.JsonStructure.getValue
- - ( - String - ) -
Get the value referenced by the provided JSON Pointer in the JsonStructure.true -
-
true
JSONP:JAVADOC:648JsonArrayjakarta.json.JsonValue.asJsonArray
-
Return the JsonValue as a JsonArraytrue -
-
true
JSONP:JAVADOC:649JsonObjectjakarta.json.JsonValue.asJsonObject
-
Return the JsonValue as a JsonObjecttrue -
-
true
JSONP:JAVADOC:650voidjakarta.json.JsonWriter.write
- - ( - JsonValue - ) -
Writes the specified JsonValue to the output source. method needs to be called only once for a write instance.true -
-
true
JSONP:JAVADOC:651JsonArrayBuilderjakarta.json.spi.JsonProvider.createArrayBuilder
- - ( - JsonArray - ) -
Creates a JSON array builder, initialized with the specified array.true -
-
true
JSONP:JAVADOC:652JsonArrayBuilderjakarta.json.spi.JsonProvider.createArrayBuilder
- - ( - Collection - ) -
Creates a JSON array builder, initialized with the specified collection.true -
-
true
JSONP:JAVADOC:653JsonPatchjakarta.json.spi.JsonProvider.createDiff
- - ( - JsonStructure - ,
JsonStructure - ) -
Generates a JSON Patch (RFC 6902) from the source and target JsonStructure. The generated JSON Patch need not be unique.true -
-
true
JSONP:JAVADOC:654JsonMergePatchjakarta.json.spi.JsonProvider.createMergeDiff
- - ( - JsonValue - ,
JsonValue - ) -
Generates a JSON Merge Patch (RFC 7396) from the source and target JsonValues which when applied to the source, yields the target.true -
-
true
JSONP:JAVADOC:655JsonMergePatchjakarta.json.spi.JsonProvider.createMergePatch
- - ( - JsonValue - ) -
Creates JSON Merge Patch (RFC 7396) from specified JsonValue.true -
-
true
JSONP:JAVADOC:656JsonObjectBuilderjakarta.json.spi.JsonProvider.createObjectBuilder
- - ( - JsonObject - ) -
Creates a JSON object builder, initialized with the specified object.true -
-
true
JSONP:JAVADOC:657JsonObjectBuilderjakarta.json.spi.JsonProvider.createObjectBuilder
- - ( - Map - ) -
Creates a JSON object builder, initialized with the specified Map.true -
-
true
JSONP:JAVADOC:658JsonPatchjakarta.json.spi.JsonProvider.createPatch
- - ( - JsonArray - ) -
Creates a JSON Patch (RFC 6902) from the specified operations.true -
-
true
JSONP:JAVADOC:659JsonPatchBuilderjakarta.json.spi.JsonProvider.createPatchBuilder
-
Creates a JSON Patch builder (RFC 6902).true -
-
true
JSONP:JAVADOC:660JsonPatchBuilderjakarta.json.spi.JsonProvider.createPatchBuilder
- - ( - JsonArray - ) -
Creates a JSON Patch builder (RFC 6902), initialized with the specified operations.true -
-
true
JSONP:JAVADOC:661JsonPointerjakarta.json.spi.JsonProvider.createPointer
- - ( - String - ) -
Creates JSON Pointer (RFC 6901) from given jsonPointer string. An empty jsonPointer string defines a reference to the target itself. If the jsonPointer string is non-empty, it must be a sequence of '/' prefixed tokens.true -
-
true
JSONP:JAVADOC:662JsonStringjakarta.json.spi.JsonProvider.createValue
- - ( - String - ) -
Creates a JsonString.true -
-
true
JSONP:JAVADOC:663JsonNumberjakarta.json.spi.JsonProvider.createValue
- - ( - int - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:664JsonNumberjakarta.json.spi.JsonProvider.createValue
- - ( - long - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:665JsonNumberjakarta.json.spi.JsonProvider.createValue
- - ( - double - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:666JsonNumberjakarta.json.spi.JsonProvider.createValue
- - ( - BigDecimal - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:667JsonNumberjakarta.json.spi.JsonProvider.createValue
- - ( - BigInteger - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:668Collectorjakarta.json.stream.JsonCollectors.groupingBy
- - ( - Function - ,
Collector - ) -
Constructs a java.util.stream.Collector that implements a "group by" operation on the input JsonValue elements. A classifier function maps the input JsonValues to keys, and the JsonValues are partitioned into groups according to the value of the key. A reduction operation is performed on the JsonValues in each group, using the downstream Collector. For each group, the key and the results of the reduction operation become the name/value pairs of the resultant JsonObject.true -
-
true
JSONP:JAVADOC:669Collectorjakarta.json.stream.JsonCollectors.groupingBy
- - ( - Function - ) -
Constructs a java.util.stream.Collector that implements a "group by" operation on the input JsonValue elements. A classifier function maps the input JsonValues to keys, and the JsonValues are partitioned into groups according to the value of the key. The JsonValues in each group are added to a JsonArray. The key and the JsonArray in each group becomes the name/value pair of the resultant JsonObject.true -
-
true
JSONP:JAVADOC:670Collectorjakarta.json.stream.JsonCollectors.toJsonArray
-
Constructs a java.util.stream.Collector that accumulates the input JsonValue elements into a JsonArray.true -
-
true
JSONP:JAVADOC:671Collectorjakarta.json.stream.JsonCollectors.toJsonObject
- - ( - Function - ,
Function - ) -
Constructs a java.util.stream.Collector that accumulates the input JsonValue elements into a JsonObject. The name/value pairs of the JsonObject are computed by applying the provided mapping functions.true -
-
true
JSONP:JAVADOC:672JsonGeneratorjakarta.json.stream.JsonGenerator.writeKey
- - ( - String - ) -
Writes the JSON name with a colon. It starts a field context, in which valid options are writing a value, starting an object or an array. Writing value closes field context, if object or array is started after field name, field context will be closed after object/array close.true -
-
true
JSONP:JAVADOC:673JsonArrayjakarta.json.stream.JsonParser.getArray
-
Returns a JsonArray and advance the parser to the the corresponding END_ARRAY.true -
-
true
JSONP:JAVADOC:674Streamjakarta.json.stream.JsonParser.getArrayStream
-
Returns a stream of the JsonArray elements. The parser state must be START_ARRAY. The elements are read lazily, on an as-needed basis, as required by the stream operations. If the stream operations do not consume all of the array elements, skipArray can be used to skip the unprocessed array elements.true -
-
true
JSONP:JAVADOC:675JsonObjectjakarta.json.stream.JsonParser.getObject
-
Returns a JsonObject and advances the parser to the corresponding END_OBJECT.true -
-
true
JSONP:JAVADOC:676Streamjakarta.json.stream.JsonParser.getObjectStream
-
Returns a stream of the JsonObject's name/value pairs. The parser state must be START_OBJECT. The name/value pairs are read lazily, on an as-needed basis, as required by the stream operations. If the stream operations do not consume all of the object's name/value pairs, skipObject can be used to skip the unprocessed elements.true -
-
true
JSONP:JAVADOC:677JsonValuejakarta.json.stream.JsonParser.getValue
-
Returns a JsonValue at the current parser position. If the parser state is START_ARRAY, the behavior is the same as #getArray. If the parser state is START_OBJECT, the behavior is the same as #getObject. For all other cases, if applicable, the JSON value is read and returned.true -
-
true
JSONP:JAVADOC:678Streamjakarta.json.stream.JsonParser.getValueStream
-
Returns a stream of JsonValue from a sequence of JSON values. The values are read lazily, on an as-needed basis, as needed by the stream operations.true -
-
true
JSONP:JAVADOC:679voidjakarta.json.stream.JsonParser.skipArray
-
Advance the parser to END_ARRAY. If the parser is in array context, i.e. it has previously encountered a START_ARRAY without encountering the corresponding END_ARRAY, the parser is advanced to the corresponding END_ARRAY. If the parser is not in any array context, nothing happens.true -
-
true
JSONP:JAVADOC:680voidjakarta.json.stream.JsonParser.skipObject
-
Advance the parser to END_OBJECT. If the parser is in object context, i.e. it has previously encountered a START_OBJECT without encountering the corresponding END_OBJECT, the parser is advanced to the corresponding END_OBJECT. If the parser is not in any object context, nothing happens.true -
-
true
- - diff --git a/install/jsonp/docs/index.html b/install/jsonp/docs/index.html deleted file mode 100644 index 55fd6dd959..0000000000 --- a/install/jsonp/docs/index.html +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - Welcome to the Jakarta EE JSON Processing TCK - - - -
-

Welcome to the Jakarta EE JSON Processing TCK, Version 2.0

-

- Your Starting Point

-
-
-

Guide to Jakarta EE JSON Processing TCK 2.0 Documentation

-

The Jakarta EE JSON Processing TCK 2.0 documentation includes the - following:

- -

JT Harness Documentation

-

The online version of the JT Harness version 5.0 documentation is - available here.

-
-

-
- Copyright 2013, 2021 Oracle and/or its affiliates. All rights - reserved. -
- -

-
- - diff --git a/install/jsonp/other/testsuite.jtt b/install/jsonp/other/testsuite.jtt deleted file mode 100644 index b58d2a680c..0000000000 --- a/install/jsonp/other/testsuite.jtt +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (c) 2013, 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 -# - -# -# $Id$ -# - -name=JSON-P Compatibility Test Suite Version 1.1 -classpath=$TS_HOME/lib/tsharness.jar -testsuite=com.sun.ts.lib.harness.TS diff --git a/install/jsonp/other/vehicle.properties b/install/jsonp/other/vehicle.properties deleted file mode 100644 index bec2c5b407..0000000000 --- a/install/jsonp/other/vehicle.properties +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (c) 2013, 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 -# - -# -# $Id$ -# - -# A properties file to determine whether a test directory is service test -# directory, and if so the vehicles in which the tests should be run. -# -# An entry key is a test directory relative to the testsutie root (i.e., -# ${TS_HOME}/src) with unix file separator (forward slash). An entry value -# is a list of vehilce names separated by a space. Althoug other reasonable -# delimiters may also work, a single space is recommended for consistency. -# Acceptable vehicle names are combinations of the following strings: -# ejb, servlet, jsp, appclient, and standalone. Each item may only appear -# once in one entry vale. -# -# For examples, some invalid entries: -# /files/ts/src/com/sun/ts/tests/samples/jdbc = ejb jsp servlet appclient -# com\sun\ts\tests\samples\jdbc = ejb jsp servlet appclient -# com\\sun\\ts\\tests\\samples\\jdbc = ejb jsp servlet appclient -# samples/jdbc = ejb jsp servlet appclient -# /com/sun/ts/tests/samples/jdbc = ejb servlet jsp appclient -# com/sun/ts/tests/samples/jdbc = ejb.servlet.jsp.appclient -# com/sun/ts/tests/samples/jdbc = ejb/servlet/jsp/appclient -# -# Entry order is insignificant. As a good practice, make the entry key -# (test directory) specific. For example, -# com/sun/ts/tests = ejb jsp servlet -# conveys to the harness that all tests under com/sun/ts/tests are service -# tests that should be run in 3 vehicles: ejb jsp servlet. -# -# This file may be modified for debugging purpose only. When testing for -# compatibility certification, the original version of this file must be -# used. Do NOT make modifications without maintaining a backup copy. -# - -com/sun/ts/tests/jsonp = standalone -com/sun/ts/tests/signaturetest/jsonp = standalone - -# If any test (sub-)directories that have been covered by entries above -# are not service test directories, list them in exclude.dir. It shoule -# arise rarely, and one possible senario could be: -# com/sun/ts/tests/foo is listed above as service tests, but later a -# non-service test dir com/sun/ts/tests/foo/non_service_tests is added, -# and you do not want to list a large number of subdirectories of foo -# in this properties file. -# If you get into this situation often, start questioning the test design -# The syntax: exclude.dir = com/sun/ts/tests/foo/non_service_test com/sun/ -# ts/tests/bar/non_service_test com/sun/ts/tests/buz/non_service_test -# - -exclude.dir = diff --git a/internal/docs/jsonp/JSONP1.0JavadocAssertions.html b/internal/docs/jsonp/JSONP1.0JavadocAssertions.html deleted file mode 100644 index 9e9c842ac8..0000000000 --- a/internal/docs/jsonp/JSONP1.0JavadocAssertions.html +++ /dev/null @@ -1,3041 +0,0 @@ - - - - - -JavaDoc Assertion Detail - - -
-
-

Java API for JSON Processing
JSON-P - 1.0
- JavaDoc Assertion Detail -

-
- - - - - - - - - - - -
TotalsTotalActiveDeprecatedRemoved
- # of Assertions - 30330300
- # of Required Assertions - 30330300
- # of Optional Assertions - 0000
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IDReturnMethod/FieldDescriptionRequiredDeprecatedTestable
JSONP:JAVADOC:6JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonValue - ) -
Adds a value to the array.true -
-
true
JSONP:JAVADOC:8JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - String - ) -
Adds a value to the array as a JsonString.true -
-
true
JSONP:JAVADOC:10JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - BigDecimal - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:12JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - BigInteger - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:14JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:16JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - long - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:18JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - double - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:20JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - double - ) -
throws - NumberFormatException
-
if the value is Not-a-Number(NaN) or infinitytrue -
-
true
JSONP:JAVADOC:21JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - boolean - ) -
Adds a JsonValue#TRUE or JsonValue#FALSE value to the array.true -
-
true
JSONP:JAVADOC:25JsonArrayBuilderjavax.json.JsonArrayBuilder.addNull
-
Adds a JsonValue#NULL value to the array.true -
-
true
JSONP:JAVADOC:37JsonExceptionjavax.json.JsonException.JsonException
- - ( - String - ) -
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.true -
-
true
JSONP:JAVADOC:38JsonExceptionjavax.json.JsonException.JsonException
- - ( - String - ,
Throwable - ) -
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.true -
-
true
JSONP:JAVADOC:40BigDecimaljavax.json.JsonNumber.bigDecimalValue
-
Returns this JSON number as a BigDecimal object.true -
-
true
JSONP:JAVADOC:41BigIntegerjavax.json.JsonNumber.bigIntegerValue
-
Returns this JSON number as a BigInteger object. This is a a convenience method for bigDecimalValue().toBigInteger(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:42BigIntegerjavax.json.JsonNumber.bigIntegerValueExact
-
Returns this JSON number as a BigDecimal object. This is a convenience method for bigDecimalValue().toBigIntegerExact().true -
-
true
JSONP:JAVADOC:43BigIntegerjavax.json.JsonNumber.bigIntegerValueExact
-
throws - ArithmeticException
-
if the number has a nonzero fractional parttrue -
-
true
JSONP:JAVADOC:44doublejavax.json.JsonNumber.doubleValue
-
Returns this JSON number as a double. This is a a convenience method for bigDecimalValue().doubleValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:45intjavax.json.JsonNumber.intValue
-
Returns this JSON number as an int. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:46intjavax.json.JsonNumber.intValueExact
-
Returns this JSON number as an int.true -
-
true
JSONP:JAVADOC:47intjavax.json.JsonNumber.intValueExact
-
throws - ArithmeticException
-
if the number has a nonzero fractional part or if it does not fit in an inttrue -
-
true
JSONP:JAVADOC:48longjavax.json.JsonNumber.longValue
-
Returns this JSON number as a long. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:49longjavax.json.JsonNumber.longValueExact
-
Returns this JSON number as a long.true -
-
true
JSONP:JAVADOC:50longjavax.json.JsonNumber.longValueExact
-
throws - ArithmeticException
-
if the number has a non-zero fractional part or if it does not fit in a longtrue -
-
true
JSONP:JAVADOC:51booleanjavax.json.JsonNumber.isIntegral
-
Returns true if this JSON number is a integral number. This method semantics are defined using bigDecimalValue().scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonNumber num = ... if (num.isIntegral()) { num.longValue(); // or other methods to get integral value } else { num.doubleValue(); // or other methods to get decimal number value }true -
-
true
JSONP:JAVADOC:58JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonValue - ) -
Adds a name/JsonValue pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:61JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
String - ) -
Adds a name/JsonString pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:64JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
BigInteger - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:67JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
BigDecimal - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:70JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
int - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:73JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
long - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:76JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
double - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:79JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
double - ) -
throws - NumberFormatException
-
if the value is Not-a-Number(NaN) or infinitytrue -
-
true
JSONP:JAVADOC:80JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
boolean - ) -
Adds a name/JsonValue#TRUE or name/JsonValue#FALSE pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:86JsonObjectBuilderjavax.json.JsonObjectBuilder.addNull
- - ( - String - ) -
Adds a name/JsonValue#NULL pair to the JSON object associated with this object builder where the value is null. If the object contains a mapping for the specified name, this method replaces the old value with null.true -
-
true
JSONP:JAVADOC:96voidjavax.json.JsonReader.close
-
Closes this reader and frees any resources associated with the reader. This method closes the underlying input source.true -
-
true
JSONP:JAVADOC:97JsonReaderjavax.json.Json.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream.true -
-
true
JSONP:JAVADOC:101Stringjavax.json.JsonString.getString
-
Returns the JSON string value.true -
-
true
JSONP:JAVADOC:102ValueTypejavax.json.JsonValue.getValueType
-
Returns the value type of this JSON value.true -
-
true
JSONP:JAVADOC:103ValueTypejavax.json.JsonValue.ValueType.valueOf
- - ( - String - ) -
-
-
true -
-
true
JSONP:JAVADOC:104ValueType[]javax.json.JsonValue.ValueType.values
-
-
-
true -
-
true
JSONP:JAVADOC:105voidjavax.json.JsonWriter.close
-
Closes this JSON writer and frees any resources associated with the writer. This method closes the underlying output source.true -
-
true
JSONP:JAVADOC:106JsonWriterjavax.json.Json.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream.true -
-
true
JSONP:JAVADOC:107voidjavax.json.JsonWriter.writeArray
- - ( - JsonArray - ) -
Writes the specified JSON JsonArray array to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:108voidjavax.json.JsonWriter.writeArray
- - ( - JsonArray - ) -
throws - JsonException
-
if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:109voidjavax.json.JsonWriter.writeArray
- - ( - JsonArray - ) -
throws - IllegalStateException
-
if writeArray, writeObject, write or close method is already calledtrue -
-
true
JSONP:JAVADOC:110voidjavax.json.JsonWriter.writeObject
- - ( - JsonObject - ) -
Writes the specified JSON JsonObject object to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:111voidjavax.json.JsonWriter.writeObject
- - ( - JsonObject - ) -
throws - JsonException
-
if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:112voidjavax.json.JsonWriter.writeObject
- - ( - JsonObject - ) -
throws - IllegalStateException
-
if writeArray, writeObject, write or close method is already calledtrue -
-
true
JSONP:JAVADOC:115voidjavax.json.stream.JsonGenerator.close
-
Closes this generator and frees any resources associated with it. This method closes the underlying output source.true -
-
true
JSONP:JAVADOC:117voidjavax.json.stream.JsonParser.close
-
Closes this parser and frees any resources associated with the parser. This method closes the underlying input source.true -
-
true
JSONP:JAVADOC:120booleanjavax.json.stream.JsonParser.isIntegralNumber
-
Returns true if the JSON number at the current parser state is a integral number. A BigDecimal may be used to store the value internally and this method semantics are defined using its scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonParser parser = ... if (parser.isIntegralNumber()) { parser.getInt(); // or other methods to get integral value } else { parser.getBigDecimal(); }true -
-
true
JSONP:JAVADOC:121booleanjavax.json.stream.JsonParser.isIntegralNumber
-
throws - IllegalStateException
-
when the parser state is not VALUE_NUMBERtrue -
-
true
JSONP:JAVADOC:122Stringjavax.json.stream.JsonParser.getString
-
Returns a String for the name in a name/value pair, for a string value or a number value. This method should only be called when the parser state is Event#KEY_NAME, Event#VALUE_STRING, or Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:123Stringjavax.json.stream.JsonParser.getString
-
throws - IllegalStateException
-
when the parser state is not KEY_NAME, VALUE_STRING, or VALUE_NUMBERtrue -
-
true
JSONP:JAVADOC:128Eventjavax.json.stream.JsonParser.Event.valueOf
- - ( - String - ) -
-
-
true -
-
true
JSONP:JAVADOC:129Event[]javax.json.stream.JsonParser.Event.values
-
-
-
true -
-
true
JSONP:JAVADOC:131JsonGeneratorjavax.json.Json.createGenerator
- - ( - Writer - ) -
Creates a JSON generator for writing JSON to a character stream.true -
-
true
JSONP:JAVADOC:133JsonParserjavax.json.Json.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:144JsonGeneratorjavax.json.spi.JsonProvider.createGenerator
- - ( - Writer - ) -
Creates a JSON generator for writing JSON text to a character stream.true -
-
true
JSONP:JAVADOC:146JsonParserjavax.json.spi.JsonProvider.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:152JsonProviderjavax.json.spi.JsonProvider.provider
-
Creates a JSON provider object. The provider is loaded using the ServiceLoader#load(Class) method. If there are no available service providers, this method returns the default service provider.true -
-
true
JSONP:JAVADOC:162JsonGeneratorjavax.json.stream.JsonGeneratorFactory.createGenerator
- - ( - Writer - ) -
Creates a JSON generator to write JSON text to a character stream. The generator is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:163JsonGeneratorjavax.json.stream.JsonGeneratorFactory.createGenerator
- - ( - OutputStream - ,
Charset - ) -
Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using the specified charset. The generator is configured with the factory's configuration.true -
-
true
JSONP:JAVADOC:164JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:165JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - InputStream - ) -
Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as specified in RFC 4627.true -
-
true
JSONP:JAVADOC:166JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - JsonObject - ) -
Creates a JSON parser from the specified JSON object.true -
-
true
JSONP:JAVADOC:167JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - JsonArray - ) -
Creates a JSON parser from the specified JSON array.true -
-
true
JSONP:JAVADOC:168JsonGeneratorjavax.json.Json.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator for writing JSON to a byte stream.true -
-
true
JSONP:JAVADOC:172JsonParserjavax.json.Json.createParser
- - ( - InputStream - ) -
Creates a JSON parser from a byte stream. The character encoding of the stream is determined as specified in RFC 4627.true -
-
true
JSONP:JAVADOC:178JsonReaderjavax.json.Json.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 4627.true -
-
true
JSONP:JAVADOC:181JsonStructurejavax.json.JsonReader.read
-
Returns a JSON array or object that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:182JsonStructurejavax.json.JsonReader.read
-
throws - JsonException
-
if a JSON object or array cannot be created due to i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:183JsonStructurejavax.json.JsonReader.read
-
throws - IllegalStateException
-
if read, readObject, readArray or close method is already calledtrue -
-
true
JSONP:JAVADOC:184JsonArrayjavax.json.JsonReader.readArray
-
Returns a JSON array that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:185JsonObjectjavax.json.JsonReader.readObject
-
Returns a JSON object that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:187JsonWriterjavax.json.Json.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding.true -
-
true
JSONP:JAVADOC:191voidjavax.json.JsonWriter.write
- - ( - JsonStructure - ) -
Writes the specified JSON JsonObject object or JsonArray array to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:192JsonGeneratorjavax.json.spi.JsonProvider.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator for writing JSON text to a byte stream.true -
-
true
JSONP:JAVADOC:196JsonParserjavax.json.spi.JsonProvider.createParser
- - ( - InputStream - ) -
Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as defined in RFC 4627 .true -
-
true
JSONP:JAVADOC:200JsonGeneratorjavax.json.stream.JsonGeneratorFactory.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The generator is configured with the factory's configuration.true -
-
true
JSONP:JAVADOC:201JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - InputStream - ,
Charset - ) -
Creates a JSON parser from the specified byte stream. The bytes of the stream are decoded to characters using the specified charset.true -
-
true
JSONP:JAVADOC:207JsonParserjavax.json.Json.createParser
- - ( - InputStream - ) -
throws - JsonException
-
if encoding cannot be determined or i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:215Stringjavax.json.JsonNumber.toString
-
Returns a JSON text representation of the JSON number. The representation is equivalent to BigDecimal#toString().true -
-
true
JSONP:JAVADOC:217JsonArrayjavax.json.JsonReader.readArray
-
throws - JsonException
-
if a JSON array cannot be created due to i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:218JsonArrayjavax.json.JsonReader.readArray
-
throws - IllegalStateException
-
if read, readObject, readArray or close method is already calledtrue -
-
true
JSONP:JAVADOC:219JsonObjectjavax.json.JsonReader.readObject
-
throws - JsonException
-
if a JSON object cannot be created due to i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:220JsonObjectjavax.json.JsonReader.readObject
-
throws - IllegalStateException
-
if read, readObject, readArray or close method is already calledtrue -
-
true
JSONP:JAVADOC:221voidjavax.json.JsonWriter.write
- - ( - JsonStructure - ) -
throws - JsonException
-
if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:222voidjavax.json.JsonWriter.write
- - ( - JsonStructure - ) -
throws - IllegalStateException
-
if writeArray, writeObject, write or close method is already calledtrue -
-
true
JSONP:JAVADOC:223JsonParserjavax.json.spi.JsonProvider.createParser
- - ( - InputStream - ) -
throws - JsonException
-
if encoding cannot be determined or i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:225JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - InputStream - ) -
throws - JsonException
-
if encoding cannot be determined or i/o error (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:235BigDecimaljavax.json.stream.JsonParser.getBigDecimal
-
Returns a JSON number as a BigDecimal. The BigDecimal is created using new BigDecimal(getString()). This method should only called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:236BigDecimaljavax.json.stream.JsonParser.getBigDecimal
-
throws - IllegalStateException
-
when the parser state is not VALUE_NUMBERtrue -
-
true
JSONP:JAVADOC:237intjavax.json.stream.JsonParser.getInt
-
Returns a JSON number as an integer. The returned value is equal to new BigDecimal(getString()).intValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method should only be called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:238intjavax.json.stream.JsonParser.getInt
-
throws - IllegalStateException
-
when the parser state is not VALUE_NUMBERtrue -
-
true
JSONP:JAVADOC:239longjavax.json.stream.JsonParser.getLong
-
Returns a JSON number as a long. The returned value is equal to new BigDecimal(getString()).longValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method is only called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:240longjavax.json.stream.JsonParser.getLong
-
throws - IllegalStateException
-
when the parser state is not VALUE_NUMBERtrue -
-
true
JSONP:JAVADOC:250booleanjavax.json.JsonNumber.equals
- - ( - Object - ) -
Compares the specified object with this JsonNumber object for equality. Returns true if and only if the type of the specified object is also JsonNumber and their #bigDecimalValue() objects are equaltrue -
-
true
JSONP:JAVADOC:251intjavax.json.JsonNumber.hashCode
-
Returns the hash code value for this JsonNumber object. The hash code of a JsonNumber object is defined as the hash code of its #bigDecimalValue() object.true -
-
true
JSONP:JAVADOC:254booleanjavax.json.JsonString.equals
- - ( - Object - ) -
Compares the specified object with this JsonString for equality. Returns true if and only if the specified object is also a JsonString, and their #getString() objects are equal.true -
-
true
JSONP:JAVADOC:255intjavax.json.JsonString.hashCode
-
Returns the hash code value for this JsonString object. The hash code of a JsonString object is defined to be its #getString() object's hash code.true -
-
true
JSONP:JAVADOC:262intjavax.json.JsonArray.getInt
- - ( - int - ) -
A convenience method for getJsonNumber(index).intValue().true -
-
true
JSONP:JAVADOC:263Stringjavax.json.JsonArray.getString
- - ( - int - ) -
A convenience method for getJsonString(index).getString().true -
-
true
JSONP:JAVADOC:264intjavax.json.JsonObject.getInt
- - ( - String - ) -
A convenience method for getJsonNumber(name).intValue()true -
-
true
JSONP:JAVADOC:265Stringjavax.json.JsonObject.getString
- - ( - String - ) -
A convenience method for getJsonString(name).getString()true -
-
true
JSONP:JAVADOC:278JsonGenerationExceptionjavax.json.stream.JsonGenerationException.JsonGenerationException
- - ( - String - ) -
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.true -
-
true
JSONP:JAVADOC:279JsonGenerationExceptionjavax.json.stream.JsonGenerationException.JsonGenerationException
- - ( - String - ,
Throwable - ) -
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.true -
-
true
JSONP:JAVADOC:285JsonParsingExceptionjavax.json.stream.JsonParsingException.JsonParsingException
- - ( - String - ,
JsonLocation - ) -
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.true -
-
true
JSONP:JAVADOC:286JsonParsingExceptionjavax.json.stream.JsonParsingException.JsonParsingException
- - ( - String - ,
Throwable - ,
JsonLocation - ) -
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.true -
-
true
JSONP:JAVADOC:288Stringjavax.json.JsonValue.toString
-
Returns JSON text for this JSON value.true -
-
true
JSONP:JAVADOC:289JsonGeneratorjavax.json.stream.JsonGenerator.writeEnd
-
Writes the end of the current context. If the current context is an array context, this method writes the end-of-array character (']'). If the current context is an object context, this method writes the end-of-object character ('}'). After writing the end of the current context, the parent context becomes the new current context.true -
-
true
JSONP:JAVADOC:290JsonGeneratorjavax.json.stream.JsonGenerator.writeEnd
-
throws - JsonGenerationException
-
if this method is called in no context.true -
-
true
JSONP:JAVADOC:291voidjavax.json.stream.JsonGenerator.flush
-
Flushes the underlying output source. If the generator has saved any characters in a buffer, writes them immediately to the underlying output source before flushing it.true -
-
true
JSONP:JAVADOC:292JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
JsonValue - ) -
Writes a JSON name/value pair in the current object context.true -
-
true
JSONP:JAVADOC:293JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
JsonValue - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:295JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
String - ) -
Writes a JSON name/string value pair in the current object context. The specified value is written as JSON string value.true -
-
true
JSONP:JAVADOC:296JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
String - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:297JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
String - ) -
throws - JsonGenerationException
-
if this method is not called within an object contexttrue -
-
true
JSONP:JAVADOC:298JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
BigInteger - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:299JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
BigInteger - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:301JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
BigDecimal - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The specified value's toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:302JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
BigDecimal - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:303JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
BigDecimal - ) -
throws - JsonGenerationException
-
if this method is not called within an object context.true -
-
true
JSONP:JAVADOC:304JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
int - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:305JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
int - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:306JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
int - ) -
throws - JsonGenerationException
-
if this method is not called within an object context.true -
-
true
JSONP:JAVADOC:307JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
long - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:308JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
long - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:309JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
long - ) -
throws - JsonGenerationException
-
if this method is not called within an object context.true -
-
true
JSONP:JAVADOC:310JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
double - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string BigDecimal.valueOf(double).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:311JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
double - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:312JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
double - ) -
throws - JsonGenerationException
-
if this method is not called within an object contexttrue -
-
true
JSONP:JAVADOC:314JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
boolean - ) -
Writes a JSON name/boolean value pair in the current object context. If value is true, it writes the JSON true value, otherwise it writes the JSON false value.true -
-
true
JSONP:JAVADOC:315JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
boolean - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:316JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
boolean - ) -
throws - JsonGenerationException
-
if this method is not called within an object context.true -
-
true
JSONP:JAVADOC:317JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - JsonValue - ) -
Writes the specified value as a JSON value within the current array context.true -
-
true
JSONP:JAVADOC:319JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ) -
Writes the specified value as a JSON string value within the current array context.true -
-
true
JSONP:JAVADOC:321JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - BigDecimal - ) -
Writes the specified value as a JSON number value within the current array context. The specified value's toString() is used as the the text value for writing.true -
-
true
JSONP:JAVADOC:323JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - BigInteger - ) -
Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:325JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - int - ) -
Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:327JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - long - ) -
Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:329JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - double - ) -
Writes the specified value as a JSON number value within the current array context. The string BigDecimal.valueOf(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:331JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - double - ) -
throws - NumberFormatException
-
if the value is Not-a-Number(NaN) or infinity.true -
-
true
JSONP:JAVADOC:332JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - boolean - ) -
Writes a JSON true or false value within the current array context. If value is true, this method writes the JSON true value, otherwise it writes the JSON false value.true -
-
true
JSONP:JAVADOC:334JsonGeneratorjavax.json.stream.JsonGenerator.writeNull
- - ( - String - ) -
Writes a JSON name/null value pair in an current object context.true -
-
true
JSONP:JAVADOC:335JsonGeneratorjavax.json.stream.JsonGenerator.writeNull
- - ( - String - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:336JsonGeneratorjavax.json.stream.JsonGenerator.writeNull
- - ( - String - ) -
throws - JsonGenerationException
-
if this method is not called within an object contexttrue -
-
true
JSONP:JAVADOC:337JsonGeneratorjavax.json.stream.JsonGenerator.writeNull
-
Writes a JSON null value within the current array context.true -
-
true
JSONP:JAVADOC:339JsonGeneratorjavax.json.stream.JsonGenerator.writeStartArray
-
Writes the JSON start array character. It starts a new child array context within which JSON values can be written to the array. This method is valid only in an array context or in no context (when a context is not yet started). This method can only be called once in no context.true -
-
true
JSONP:JAVADOC:340JsonGeneratorjavax.json.stream.JsonGenerator.writeStartArray
- - ( - String - ) -
Writes the JSON name/start array character pair with in the current object context. It starts a new child array context within which JSON values can be written to the array.true -
-
true
JSONP:JAVADOC:341JsonGeneratorjavax.json.stream.JsonGenerator.writeStartObject
-
Writes the JSON start object character. It starts a new child object context within which JSON name/value pairs can be written to the object. This method is valid only in an array context or in no context (when a context is not yet started). This method can only be called once in no context.true -
-
true
JSONP:JAVADOC:342JsonGeneratorjavax.json.stream.JsonGenerator.writeStartObject
- - ( - String - ) -
Writes the JSON name/start object character pair in the current object context. It starts a new child object context within which JSON name/value pairs can be written to the object.true -
-
true
JSONP:JAVADOC:343JsonGeneratorjavax.json.stream.JsonGenerator.writeEnd
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:344intjavax.json.JsonObject.getInt
- - ( - String - ) -
throws - ClassCastException
-
if the value for specified name mapping is not assignable to JsonNumbertrue -
-
true
JSONP:JAVADOC:345Stringjavax.json.JsonObject.getString
- - ( - String - ) -
throws - ClassCastException
-
if the value for specified name mapping is not assignable to JsonStringtrue -
-
true
JSONP:JAVADOC:346voidjavax.json.stream.JsonGenerator.close
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:347JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
JsonValue - ) -
throws - JsonGenerationException
-
if this method is not called within an object contexttrue -
-
true
JSONP:JAVADOC:348JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
BigInteger - ) -
throws - JsonGenerationException
-
if this method is not called within an object context.true -
-
true
JSONP:JAVADOC:349JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - JsonValue - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:350JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - JsonValue - ) -
throws - JsonGenerationException
-
if this method is not called within an array context.true -
-
true
JSONP:JAVADOC:351JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:352JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ) -
throws - JsonGenerationException
-
if this method is not called within an array contexttrue -
-
true
JSONP:JAVADOC:353JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - BigDecimal - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:354JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - BigDecimal - ) -
throws - JsonGenerationException
-
if this method is not called within an array contexttrue -
-
true
JSONP:JAVADOC:355JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - BigInteger - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:356JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - BigInteger - ) -
throws - JsonGenerationException
-
if this method is not called within an array contexttrue -
-
true
JSONP:JAVADOC:357JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - int - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:358JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - int - ) -
throws - JsonGenerationException
-
if this method is not called within an array contexttrue -
-
true
JSONP:JAVADOC:359JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - long - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:360JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - long - ) -
throws - JsonGenerationException
-
if this method is not called within an array contexttrue -
-
true
JSONP:JAVADOC:361JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - double - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:362JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - double - ) -
throws - JsonGenerationException
-
if this method is not called within an array contexttrue -
-
true
JSONP:JAVADOC:363JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - boolean - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:364JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - boolean - ) -
throws - JsonGenerationException
-
if this method is not called within an array context.true -
-
true
JSONP:JAVADOC:365JsonGeneratorjavax.json.stream.JsonGenerator.writeNull
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:366JsonGeneratorjavax.json.stream.JsonGenerator.writeNull
-
throws - JsonGenerationException
-
if this method is not called within an array contexttrue -
-
true
JSONP:JAVADOC:367JsonGeneratorjavax.json.stream.JsonGenerator.writeStartArray
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:368JsonGeneratorjavax.json.stream.JsonGenerator.writeStartArray
-
throws - JsonGenerationException
-
if this method is called within an object context or if called more than once in no contexttrue -
-
true
JSONP:JAVADOC:369JsonGeneratorjavax.json.stream.JsonGenerator.writeStartArray
- - ( - String - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:370JsonGeneratorjavax.json.stream.JsonGenerator.writeStartArray
- - ( - String - ) -
throws - JsonGenerationException
-
if this method is not called within an object contexttrue -
-
true
JSONP:JAVADOC:371JsonGeneratorjavax.json.stream.JsonGenerator.writeStartObject
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:372JsonGeneratorjavax.json.stream.JsonGenerator.writeStartObject
-
throws - JsonGenerationException
-
if this method is called within an object context or if it is called more than once in no context.true -
-
true
JSONP:JAVADOC:373JsonGeneratorjavax.json.stream.JsonGenerator.writeStartObject
- - ( - String - ) -
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:374JsonGeneratorjavax.json.stream.JsonGenerator.writeStartObject
- - ( - String - ) -
throws - JsonGenerationException
-
if this method is not called within an object contexttrue -
-
true
JSONP:JAVADOC:375booleanjavax.json.stream.JsonParser.hasNext
-
Returns true if there are more parsing states. This method returns false if the parser reaches the end of the JSON text.true -
-
true
JSONP:JAVADOC:376Eventjavax.json.stream.JsonParser.next
-
Returns the event for the next parsing state.true -
-
true
JSONP:JAVADOC:377intjavax.json.JsonArray.getInt
- - ( - int - ) -
throws - IndexOutOfBoundsException
-
if the index is out of rangetrue -
-
true
JSONP:JAVADOC:378intjavax.json.JsonArray.getInt
- - ( - int - ) -
throws - ClassCastException
-
if the value at the specified position is not assignable to JsonNumbertrue -
-
true
JSONP:JAVADOC:379Stringjavax.json.JsonArray.getString
- - ( - int - ) -
throws - IndexOutOfBoundsException
-
if the index is out of rangetrue -
-
true
JSONP:JAVADOC:380Stringjavax.json.JsonArray.getString
- - ( - int - ) -
throws - ClassCastException
-
if the value at the specified position is not assignable to JsonStringtrue -
-
true
JSONP:JAVADOC:381voidjavax.json.stream.JsonGenerator.close
-
throws - JsonGenerationException
-
if an incomplete JSON is generatedtrue -
-
true
JSONP:JAVADOC:382JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
double - ) -
throws - NumberFormatException
-
if the value is Not-a-Number(NaN) or infinity.true -
-
true
JSONP:JAVADOC:383CharSequencejavax.json.JsonString.getChars
-
Returns the char sequence for the JSON String valuetrue -
-
true
JSONP:JAVADOC:387booleanjavax.json.stream.JsonParser.hasNext
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
false
JSONP:JAVADOC:388booleanjavax.json.stream.JsonParser.hasNext
-
throws - JsonParsingException
-
if the parser encounters invalid JSON when advancing to next state.true -
-
false
JSONP:JAVADOC:389Eventjavax.json.stream.JsonParser.next
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:390Eventjavax.json.stream.JsonParser.next
-
throws - JsonParsingException
-
if the parser encounters invalid JSON when advancing to next state.true -
-
true
JSONP:JAVADOC:391Eventjavax.json.stream.JsonParser.next
-
throws - NoSuchElementException
-
if there are no more parsing states.true -
-
true
JSONP:JAVADOC:400JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonObjectBuilder - ) -
Adds a JsonObject from an object builder to the array.true -
-
true
JSONP:JAVADOC:401JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonArrayBuilder - ) -
Adds a JsonArray from an array builder to the array.true -
-
true
JSONP:JAVADOC:402JsonArrayjavax.json.JsonArrayBuilder.build
-
Returns the current array.true -
-
true
JSONP:JAVADOC:403JsonArrayBuilderjavax.json.Json.createArrayBuilder
-
Creates a JSON array buildertrue -
-
true
JSONP:JAVADOC:404JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonObjectBuilder - ) -
Adds a name/JsonObject pair to the JSON object associated with this object builder. The value JsonObject is built from the specified object builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonObject from the specified object builder.true -
-
true
JSONP:JAVADOC:406JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonArrayBuilder - ) -
Adds a name/JsonArray pair to the JSON object associated with this object builder. The value JsonArray is built from the specified array builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonArray from the specified array builder.true -
-
true
JSONP:JAVADOC:408JsonObjectjavax.json.JsonObjectBuilder.build
-
Returns the JSON object associated with this object builder. The iteration order for the JsonObject is based on the order in which name/value pairs are added to the object using this builder.true -
-
true
JSONP:JAVADOC:409JsonObjectBuilderjavax.json.Json.createObjectBuilder
-
Creates a JSON object buildertrue -
-
true
JSONP:JAVADOC:410voidjavax.json.JsonReader.close
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:411JsonStructurejavax.json.JsonReader.read
-
throws - JsonParsingException
-
if a JSON object or array cannot be created due to incorrect representationtrue -
-
true
JSONP:JAVADOC:412JsonArrayjavax.json.JsonReader.readArray
-
throws - JsonParsingException
-
if a JSON array cannot be created due to incorrect representationtrue -
-
true
JSONP:JAVADOC:413JsonObjectjavax.json.JsonReader.readObject
-
throws - JsonParsingException
-
if a JSON object cannot be created due to incorrect representationtrue -
-
true
JSONP:JAVADOC:414voidjavax.json.JsonWriter.close
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:415voidjavax.json.stream.JsonParser.close
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:416JsonGeneratorFactoryjavax.json.Json.createGeneratorFactory
- - ( - Map - ) -
Creates a generator factory for creating JsonGenerator objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:417JsonParserFactoryjavax.json.Json.createParserFactory
- - ( - Map - ) -
Creates a parser factory for creating JsonParser objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:419JsonReaderjavax.json.JsonReaderFactory.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:420JsonReaderjavax.json.JsonReaderFactory.createReader
- - ( - InputStream - ,
Charset - ) -
Creates a JSON reader from a byte stream. The bytes of the stream are decoded to characters using the specified charset. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:422JsonWriterjavax.json.JsonWriterFactory.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:423JsonWriterjavax.json.JsonWriterFactory.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:424JsonWriterjavax.json.JsonWriterFactory.createWriter
- - ( - OutputStream - ,
Charset - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using the specified charset. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:425JsonGeneratorFactoryjavax.json.spi.JsonProvider.createGeneratorFactory
- - ( - Map - ) -
Creates a generator factory for creating JsonGenerator instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:426JsonParserFactoryjavax.json.spi.JsonProvider.createParserFactory
- - ( - Map - ) -
Creates a parser factory for creating JsonParser instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:427Mapjavax.json.stream.JsonGeneratorFactory.getConfigInUse
-
Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON generators. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:428Mapjavax.json.stream.JsonParserFactory.getConfigInUse
-
Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON parsers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:429JsonReaderjavax.json.JsonReaderFactory.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 4627. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:430booleanjavax.json.JsonArray.getBoolean
- - ( - int - ) -
Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false.true -
-
true
JSONP:JAVADOC:431booleanjavax.json.JsonArray.getBoolean
- - ( - int - ) -
throws - IndexOutOfBoundsException
-
if the index is out of rangetrue -
-
true
JSONP:JAVADOC:432booleanjavax.json.JsonArray.getBoolean
- - ( - int - ) -
throws - ClassCastException
-
if the value at the specified position is not assignable to JsonValue.TRUE or JsonValue.FALSEtrue -
-
true
JSONP:JAVADOC:433booleanjavax.json.JsonArray.getBoolean
- - ( - int - ,
boolean - ) -
Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false. Otherwise this method returns the specified default value.true -
-
true
JSONP:JAVADOC:434intjavax.json.JsonArray.getInt
- - ( - int - ,
int - ) -
Returns the int value of the JsonNumber at the specified position. If the value at that position is a JsonNumber, this method returns javax.json.JsonNumber#intValue(). Otherwise this method returns the specified default value.true -
-
true
JSONP:JAVADOC:435Stringjavax.json.JsonArray.getString
- - ( - int - ,
String - ) -
Returns the String value of JsonString at the specified position in this JSON array values. If JsonString is found, its javax.json.JsonString#getString() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:436booleanjavax.json.JsonObject.getBoolean
- - ( - String - ) -
Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false.true -
-
true
JSONP:JAVADOC:437booleanjavax.json.JsonObject.getBoolean
- - ( - String - ) -
throws - NullPointerException
-
if the specified name doesn't have any mappingtrue -
-
true
JSONP:JAVADOC:438booleanjavax.json.JsonObject.getBoolean
- - ( - String - ) -
throws - ClassCastException
-
if the value for specified name mapping is not assignable to JsonValue.TRUE or JsonValue.FALSEtrue -
-
true
JSONP:JAVADOC:439booleanjavax.json.JsonObject.getBoolean
- - ( - String - ,
boolean - ) -
Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:440intjavax.json.JsonObject.getInt
- - ( - String - ) -
throws - NullPointerException
-
if the specified name doesn't have any mappingtrue -
-
true
JSONP:JAVADOC:441intjavax.json.JsonObject.getInt
- - ( - String - ,
int - ) -
Returns the int value of the associated JsonNumber mapping for the specified name. If JsonNumber is found, then its javax.json.JsonNumber#intValue() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:442Stringjavax.json.JsonObject.getString
- - ( - String - ) -
throws - NullPointerException
-
if the specified name doesn't have any mappingtrue -
-
true
JSONP:JAVADOC:443Stringjavax.json.JsonObject.getString
- - ( - String - ,
String - ) -
Returns the string value of the associated JsonString mapping for the specified name. If JsonString is found, then its javax.json.JsonString#getString() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:445JsonBuilderFactoryjavax.json.Json.createBuilderFactory
- - ( - Map - ) -
Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:449JsonReaderFactoryjavax.json.Json.createReaderFactory
- - ( - Map - ) -
Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:452JsonWriterFactoryjavax.json.Json.createWriterFactory
- - ( - Map - ) -
Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:453JsonArrayBuilderjavax.json.JsonBuilderFactory.createArrayBuilder
-
Creates a JsonArrayBuilder instance that is used to build JsonArraytrue -
-
true
JSONP:JAVADOC:454JsonObjectBuilderjavax.json.JsonBuilderFactory.createObjectBuilder
-
Creates a JsonObjectBuilder instance that is used to build JsonObject.true -
-
true
JSONP:JAVADOC:455Mapjavax.json.JsonBuilderFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON builders. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:459Mapjavax.json.JsonReaderFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON readers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:463Mapjavax.json.JsonWriterFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON writer objects. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:464JsonArrayBuilderjavax.json.spi.JsonProvider.createArrayBuilder
-
Creates a JSON array buildertrue -
-
true
JSONP:JAVADOC:465JsonBuilderFactoryjavax.json.spi.JsonProvider.createBuilderFactory
- - ( - Map - ) -
Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:466JsonObjectBuilderjavax.json.spi.JsonProvider.createObjectBuilder
-
Creates a JSON object buildertrue -
-
true
JSONP:JAVADOC:467JsonReaderjavax.json.spi.JsonProvider.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream.true -
-
true
JSONP:JAVADOC:468JsonReaderjavax.json.spi.JsonProvider.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 4627.true -
-
true
JSONP:JAVADOC:469JsonReaderFactoryjavax.json.spi.JsonProvider.createReaderFactory
- - ( - Map - ) -
Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:470JsonWriterjavax.json.spi.JsonProvider.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream.true -
-
true
JSONP:JAVADOC:471JsonWriterjavax.json.spi.JsonProvider.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding.true -
-
true
JSONP:JAVADOC:472JsonWriterFactoryjavax.json.spi.JsonProvider.createWriterFactory
- - ( - Map - ) -
Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:474longjavax.json.stream.JsonLocation.getColumnNumber
-
Return the column number for the current JSON event in the input source.true -
-
true
JSONP:JAVADOC:475longjavax.json.stream.JsonLocation.getLineNumber
-
Return the line number for the current JSON event in the input source.true -
-
true
JSONP:JAVADOC:476longjavax.json.stream.JsonLocation.getStreamOffset
-
Return the stream offset into the input source this location is pointing to. If the input source is a file or a byte stream then this is the byte offset into that stream, but if the input source is a character media then the offset is the character offset. Returns -1 if there is no offset available.true -
-
true
JSONP:JAVADOC:477JsonLocationjavax.json.stream.JsonParser.getLocation
-
Return the location that corresponds to the parser's current state in the JSON input source. The location information is only valid in the current parser state (or until the parser is advanced to a next state).true -
-
true
JSONP:JAVADOC:478JsonLocationjavax.json.stream.JsonParsingException.getLocation
-
Return the location of the incorrect JSON.true -
-
true
JSONP:JAVADOC:481Listjavax.json.JsonArray.getValuesAs
- - ( - Class - ) -
Returns a list a view of the specified type for the array. This method does not verify if there is a value of wrong type in the array. Providing this typesafe view dynamically may cause a program fail with a ClassCastException, if there is a value of wrong type in this array. Unfortunately, the exception can occur at any time after this method returns.true -
-
true
JSONP:JAVADOC:490JsonArrayjavax.json.JsonArray.getJsonArray
- - ( - int - ) -
Returns the array value at the specified position in this array. This is a convenience method for (JsonArray)get(index).true -
-
true
JSONP:JAVADOC:491JsonArrayjavax.json.JsonArray.getJsonArray
- - ( - int - ) -
throws - IndexOutOfBoundsException
-
if the index is out of rangetrue -
-
true
JSONP:JAVADOC:492JsonArrayjavax.json.JsonArray.getJsonArray
- - ( - int - ) -
throws - ClassCastException
-
if the value at the specified position is not assignable to the JsonArray typetrue -
-
true
JSONP:JAVADOC:493JsonNumberjavax.json.JsonArray.getJsonNumber
- - ( - int - ) -
Returns the number value at the specified position in this array. This is a convenience method for (JsonNumber)get(index).true -
-
true
JSONP:JAVADOC:494JsonNumberjavax.json.JsonArray.getJsonNumber
- - ( - int - ) -
throws - IndexOutOfBoundsException
-
if the index is out of rangetrue -
-
true
JSONP:JAVADOC:495JsonNumberjavax.json.JsonArray.getJsonNumber
- - ( - int - ) -
throws - ClassCastException
-
if the value at the specified position is not assignable to the JsonNumber typetrue -
-
true
JSONP:JAVADOC:496JsonObjectjavax.json.JsonArray.getJsonObject
- - ( - int - ) -
Returns the object value at the specified position in this array. This is a convenience method for (JsonObject)get(index).true -
-
true
JSONP:JAVADOC:497JsonObjectjavax.json.JsonArray.getJsonObject
- - ( - int - ) -
throws - IndexOutOfBoundsException
-
if the index is out of rangetrue -
-
true
JSONP:JAVADOC:498JsonObjectjavax.json.JsonArray.getJsonObject
- - ( - int - ) -
throws - ClassCastException
-
if the value at the specified position is not assignable to the JsonObject typetrue -
-
true
JSONP:JAVADOC:499JsonStringjavax.json.JsonArray.getJsonString
- - ( - int - ) -
Returns the string value at ths specified position in this array. This is a convenience method for (JsonString)get(index).true -
-
true
JSONP:JAVADOC:500JsonStringjavax.json.JsonArray.getJsonString
- - ( - int - ) -
throws - IndexOutOfBoundsException
-
if the index is out of rangetrue -
-
true
JSONP:JAVADOC:501JsonStringjavax.json.JsonArray.getJsonString
- - ( - int - ) -
throws - ClassCastException
-
if the value at the specified position is not assignable to the JsonString typetrue -
-
true
JSONP:JAVADOC:506booleanjavax.json.JsonArray.isNull
- - ( - int - ) -
Returns true if the value at the specified location in this array is JsonValue.NULL.true -
-
true
JSONP:JAVADOC:507booleanjavax.json.JsonArray.isNull
- - ( - int - ) -
throws - IndexOutOfBoundsException
-
if the index is out of rangetrue -
-
true
JSONP:JAVADOC:527JsonArrayjavax.json.JsonObject.getJsonArray
- - ( - String - ) -
Returns the array value to which the specified name is mapped. This is a convenience method for (JsonArray)get(name) to get the value.true -
-
true
JSONP:JAVADOC:528JsonArrayjavax.json.JsonObject.getJsonArray
- - ( - String - ) -
throws - ClassCastException
-
if the value to which the specified name is mapped is not assignable to JsonArray typetrue -
-
true
JSONP:JAVADOC:529JsonNumberjavax.json.JsonObject.getJsonNumber
- - ( - String - ) -
Returns the number value to which the specified name is mapped. This is a convenience method for (JsonNumber)get(name) to get the value.true -
-
true
JSONP:JAVADOC:530JsonNumberjavax.json.JsonObject.getJsonNumber
- - ( - String - ) -
throws - ClassCastException
-
if the value to which the specified name is mapped is not assignable to JsonNumber typetrue -
-
true
JSONP:JAVADOC:531JsonObjectjavax.json.JsonObject.getJsonObject
- - ( - String - ) -
Returns the object value to which the specified name is mapped. This is a convenience method for (JsonObject)get(name) to get the value.true -
-
true
JSONP:JAVADOC:532JsonObjectjavax.json.JsonObject.getJsonObject
- - ( - String - ) -
throws - ClassCastException
-
if the value to which the specified name is mapped is not assignable to JsonObject typetrue -
-
true
JSONP:JAVADOC:533JsonStringjavax.json.JsonObject.getJsonString
- - ( - String - ) -
Returns the string value to which the specified name is mapped. This is a convenience method for (JsonString)get(name) to get the value.true -
-
true
JSONP:JAVADOC:534JsonStringjavax.json.JsonObject.getJsonString
- - ( - String - ) -
throws - ClassCastException
-
if the value to which the specified name is mapped is not assignable to JsonString typetrue -
-
true
JSONP:JAVADOC:539booleanjavax.json.JsonObject.isNull
- - ( - String - ) -
Returns true if the associated value for the specified name is JsonValue.NULL.true -
-
true
JSONP:JAVADOC:540booleanjavax.json.JsonObject.isNull
- - ( - String - ) -
throws - NullPointerException
-
if the specified name doesn't have any mappingtrue -
-
true
JSONP:JAVADOC:551voidjavax.json.stream.JsonGenerator.flush
-
throws - JsonException
-
if an i/o error occurs (IOException would be cause of JsonException)true -
-
true
JSONP:JAVADOC:555JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonValue - ) -
throws - NullPointerException
-
if the specified value is nulltrue -
-
true
JSONP:JAVADOC:556JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - String - ) -
throws - NullPointerException
-
if the specified value is nulltrue -
-
true
JSONP:JAVADOC:557JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - BigDecimal - ) -
throws - NullPointerException
-
if the specified value is nulltrue -
-
true
JSONP:JAVADOC:558JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - BigInteger - ) -
throws - NullPointerException
-
if the specified value is nulltrue -
-
true
JSONP:JAVADOC:559JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonObjectBuilder - ) -
throws - NullPointerException
-
if the specified builder is nulltrue -
-
true
JSONP:JAVADOC:560JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonArrayBuilder - ) -
throws - NullPointerException
-
if the specified builder is nulltrue -
-
true
JSONP:JAVADOC:561JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonValue - ) -
throws - NullPointerException
-
if the specified name or value is nulltrue -
-
true
JSONP:JAVADOC:562JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
String - ) -
throws - NullPointerException
-
if the specified name or value is nulltrue -
-
true
JSONP:JAVADOC:563JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
BigInteger - ) -
throws - NullPointerException
-
if the specified name or value is nulltrue -
-
true
JSONP:JAVADOC:564JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
BigDecimal - ) -
throws - NullPointerException
-
if the specified name or value is nulltrue -
-
true
JSONP:JAVADOC:565JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
int - ) -
throws - NullPointerException
-
if the specified name is nulltrue -
-
true
JSONP:JAVADOC:566JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
long - ) -
throws - NullPointerException
-
if the specified name is nulltrue -
-
true
JSONP:JAVADOC:567JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
double - ) -
throws - NullPointerException
-
if the specified name is nulltrue -
-
true
JSONP:JAVADOC:568JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
boolean - ) -
throws - NullPointerException
-
if the specified name is nulltrue -
-
true
JSONP:JAVADOC:569JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonObjectBuilder - ) -
throws - NullPointerException
-
if the specified name or builder is nulltrue -
-
true
JSONP:JAVADOC:570JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonArrayBuilder - ) -
throws - NullPointerException
-
if the specified name or builder is nulltrue -
-
true
JSONP:JAVADOC:571JsonObjectBuilderjavax.json.JsonObjectBuilder.addNull
- - ( - String - ) -
throws - NullPointerException
-
if the specified name is nulltrue -
-
true
- - diff --git a/internal/docs/jsonp/JSONP1.0JavadocAssertions.xml b/internal/docs/jsonp/JSONP1.0JavadocAssertions.xml deleted file mode 100644 index eac8c431fe..0000000000 --- a/internal/docs/jsonp/JSONP1.0JavadocAssertions.xml +++ /dev/null @@ -1,3218 +0,0 @@ - - - - - - 572 - 555 - JSONP - JSON-P - Java API for JSON Processing - 1.0 - - - JSONP:JAVADOC:6 - Adds a value to the array. - javax.json - JsonArrayBuilder - - - javax.json.JsonValue - - - - - JSONP:JAVADOC:8 - Adds a value to the array as a JsonString. - javax.json - JsonArrayBuilder - - - java.lang.String - - - - - JSONP:JAVADOC:10 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - java.math.BigDecimal - - - - - JSONP:JAVADOC:12 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - java.math.BigInteger - - - - - JSONP:JAVADOC:14 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - int - - - - - JSONP:JAVADOC:16 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - long - - - - - JSONP:JAVADOC:18 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - double - - - - - JSONP:JAVADOC:20 - if the value is Not-a-Number(NaN) or infinity - javax.json - JsonArrayBuilder - - - double - - java.lang.NumberFormatException - - - - JSONP:JAVADOC:21 - Adds a JsonValue#TRUE or JsonValue#FALSE value to the array. - javax.json - JsonArrayBuilder - - - boolean - - - - - JSONP:JAVADOC:25 - Adds a JsonValue#NULL value to the array. - javax.json - JsonArrayBuilder - - - - JSONP:JAVADOC:37 - 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. - javax.json - JsonException - - - java.lang.String - - - - - JSONP:JAVADOC:38 - 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. - javax.json - JsonException - - - java.lang.String - java.lang.Throwable - - - - - JSONP:JAVADOC:40 - Returns this JSON number as a BigDecimal object. - javax.json - JsonNumber - - - - JSONP:JAVADOC:41 - Returns this JSON number as a BigInteger object. This is a a convenience method for bigDecimalValue().toBigInteger(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. - javax.json - JsonNumber - - - - JSONP:JAVADOC:42 - Returns this JSON number as a BigDecimal object. This is a convenience method for bigDecimalValue().toBigIntegerExact(). - javax.json - JsonNumber - - - - JSONP:JAVADOC:43 - if the number has a nonzero fractional part - javax.json - JsonNumber - - java.lang.ArithmeticException - - - - JSONP:JAVADOC:44 - Returns this JSON number as a double. This is a a convenience method for bigDecimalValue().doubleValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. - javax.json - JsonNumber - - - - JSONP:JAVADOC:45 - Returns this JSON number as an int. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. - javax.json - JsonNumber - - - - JSONP:JAVADOC:46 - Returns this JSON number as an int. - javax.json - JsonNumber - - - - JSONP:JAVADOC:47 - if the number has a nonzero fractional part or if it does not fit in an int - javax.json - JsonNumber - - java.lang.ArithmeticException - - - - JSONP:JAVADOC:48 - Returns this JSON number as a long. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. - javax.json - JsonNumber - - - - JSONP:JAVADOC:49 - Returns this JSON number as a long. - javax.json - JsonNumber - - - - JSONP:JAVADOC:50 - if the number has a non-zero fractional part or if it does not fit in a long - javax.json - JsonNumber - - java.lang.ArithmeticException - - - - JSONP:JAVADOC:51 - Returns true if this JSON number is a integral number. This method semantics are defined using bigDecimalValue().scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonNumber num = ... if (num.isIntegral()) { num.longValue(); // or other methods to get integral value } else { num.doubleValue(); // or other methods to get decimal number value } - javax.json - JsonNumber - - - - JSONP:JAVADOC:58 - Adds a name/JsonValue pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonValue - - - - - JSONP:JAVADOC:61 - Adds a name/JsonString pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - java.lang.String - - - - - JSONP:JAVADOC:64 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - java.math.BigInteger - - - - - JSONP:JAVADOC:67 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - java.math.BigDecimal - - - - - JSONP:JAVADOC:70 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - int - - - - - JSONP:JAVADOC:73 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - long - - - - - JSONP:JAVADOC:76 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - double - - - - - JSONP:JAVADOC:79 - if the value is Not-a-Number(NaN) or infinity - javax.json - JsonObjectBuilder - - - java.lang.String - double - - java.lang.NumberFormatException - - - - JSONP:JAVADOC:80 - Adds a name/JsonValue#TRUE or name/JsonValue#FALSE pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - boolean - - - - - JSONP:JAVADOC:86 - Adds a name/JsonValue#NULL pair to the JSON object associated with this object builder where the value is null. If the object contains a mapping for the specified name, this method replaces the old value with null. - javax.json - JsonObjectBuilder - - - java.lang.String - - - - - JSONP:JAVADOC:96 - Closes this reader and frees any resources associated with the reader. This method closes the underlying input source. - javax.json - JsonReader - - - - JSONP:JAVADOC:97 - Creates a JSON reader from a character stream. - javax.json - Json - - - java.io.Reader - - - - - JSONP:JAVADOC:101 - Returns the JSON string value. - javax.json - JsonString - - - - JSONP:JAVADOC:102 - Returns the value type of this JSON value. - javax.json - JsonValue - - - - JSONP:JAVADOC:103 - - javax.json - JsonValue.ValueType - - - java.lang.String - - - - - JSONP:JAVADOC:104 - - javax.json - JsonValue.ValueType - - - - JSONP:JAVADOC:105 - Closes this JSON writer and frees any resources associated with the writer. This method closes the underlying output source. - javax.json - JsonWriter - - - - JSONP:JAVADOC:106 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. - javax.json - Json - - - java.io.Writer - - - - - JSONP:JAVADOC:107 - Writes the specified JSON JsonArray array to the output source. This method needs to be called only once for a writer instance. - javax.json - JsonWriter - - - javax.json.JsonArray - - - - - JSONP:JAVADOC:108 - if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException) - javax.json - JsonWriter - - - javax.json.JsonArray - - javax.json.JsonException - - - - JSONP:JAVADOC:109 - if writeArray, writeObject, write or close method is already called - javax.json - JsonWriter - - - javax.json.JsonArray - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:110 - Writes the specified JSON JsonObject object to the output source. This method needs to be called only once for a writer instance. - javax.json - JsonWriter - - - javax.json.JsonObject - - - - - JSONP:JAVADOC:111 - if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException) - javax.json - JsonWriter - - - javax.json.JsonObject - - javax.json.JsonException - - - - JSONP:JAVADOC:112 - if writeArray, writeObject, write or close method is already called - javax.json - JsonWriter - - - javax.json.JsonObject - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:115 - Closes this generator and frees any resources associated with it. This method closes the underlying output source. - javax.json.stream - JsonGenerator - - - - JSONP:JAVADOC:117 - Closes this parser and frees any resources associated with the parser. This method closes the underlying input source. - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:120 - Returns true if the JSON number at the current parser state is a integral number. A BigDecimal may be used to store the value internally and this method semantics are defined using its scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonParser parser = ... if (parser.isIntegralNumber()) { parser.getInt(); // or other methods to get integral value } else { parser.getBigDecimal(); } - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:121 - when the parser state is not VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:122 - Returns a String for the name in a name/value pair, for a string value or a number value. This method should only be called when the parser state is Event#KEY_NAME, Event#VALUE_STRING, or Event#VALUE_NUMBER. - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:123 - when the parser state is not KEY_NAME, VALUE_STRING, or VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:128 - - javax.json.stream - JsonParser.Event - - - java.lang.String - - - - - JSONP:JAVADOC:129 - - javax.json.stream - JsonParser.Event - - - - JSONP:JAVADOC:131 - Creates a JSON generator for writing JSON to a character stream. - javax.json - Json - - - java.io.Writer - - - - - JSONP:JAVADOC:133 - Creates a JSON parser from a character stream. - javax.json - Json - - - java.io.Reader - - - - - JSONP:JAVADOC:144 - Creates a JSON generator for writing JSON text to a character stream. - javax.json.spi - JsonProvider - - - java.io.Writer - - - - - JSONP:JAVADOC:146 - Creates a JSON parser from a character stream. - javax.json.spi - JsonProvider - - - java.io.Reader - - - - - JSONP:JAVADOC:152 - Creates a JSON provider object. The provider is loaded using the ServiceLoader#load(Class) method. If there are no available service providers, this method returns the default service provider. - javax.json.spi - JsonProvider - - - - JSONP:JAVADOC:162 - Creates a JSON generator to write JSON text to a character stream. The generator is configured with the factory configuration. - javax.json.stream - JsonGeneratorFactory - - - java.io.Writer - - - - - JSONP:JAVADOC:163 - Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using the specified charset. The generator is configured with the factory's configuration. - javax.json.stream - JsonGeneratorFactory - - - java.io.OutputStream - java.nio.charset.Charset - - - - - JSONP:JAVADOC:164 - Creates a JSON parser from a character stream. - javax.json.stream - JsonParserFactory - - - java.io.Reader - - - - - JSONP:JAVADOC:165 - Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as specified in RFC 4627. - javax.json.stream - JsonParserFactory - - - java.io.InputStream - - - - - JSONP:JAVADOC:166 - Creates a JSON parser from the specified JSON object. - javax.json.stream - JsonParserFactory - - - javax.json.JsonObject - - - - - JSONP:JAVADOC:167 - Creates a JSON parser from the specified JSON array. - javax.json.stream - JsonParserFactory - - - javax.json.JsonArray - - - - - JSONP:JAVADOC:168 - Creates a JSON generator for writing JSON to a byte stream. - javax.json - Json - - - java.io.OutputStream - - - - - JSONP:JAVADOC:172 - Creates a JSON parser from a byte stream. The character encoding of the stream is determined as specified in RFC 4627. - javax.json - Json - - - java.io.InputStream - - - - - JSONP:JAVADOC:178 - Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 4627. - javax.json - Json - - - java.io.InputStream - - - - - JSONP:JAVADOC:181 - Returns a JSON array or object that is represented in the input source. This method needs to be called only once for a reader instance. - javax.json - JsonReader - - - - JSONP:JAVADOC:182 - if a JSON object or array cannot be created due to i/o error (IOException would be cause of JsonException) - javax.json - JsonReader - - javax.json.JsonException - - - - JSONP:JAVADOC:183 - if read, readObject, readArray or close method is already called - javax.json - JsonReader - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:184 - Returns a JSON array that is represented in the input source. This method needs to be called only once for a reader instance. - javax.json - JsonReader - - - - JSONP:JAVADOC:185 - Returns a JSON object that is represented in the input source. This method needs to be called only once for a reader instance. - javax.json - JsonReader - - - - JSONP:JAVADOC:187 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. - javax.json - Json - - - java.io.OutputStream - - - - - JSONP:JAVADOC:191 - Writes the specified JSON JsonObject object or JsonArray array to the output source. This method needs to be called only once for a writer instance. - javax.json - JsonWriter - - - javax.json.JsonStructure - - - - - JSONP:JAVADOC:192 - Creates a JSON generator for writing JSON text to a byte stream. - javax.json.spi - JsonProvider - - - java.io.OutputStream - - - - - JSONP:JAVADOC:196 - Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as defined in RFC 4627 . - javax.json.spi - JsonProvider - - - java.io.InputStream - - - - - JSONP:JAVADOC:200 - Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The generator is configured with the factory's configuration. - javax.json.stream - JsonGeneratorFactory - - - java.io.OutputStream - - - - - JSONP:JAVADOC:201 - Creates a JSON parser from the specified byte stream. The bytes of the stream are decoded to characters using the specified charset. - javax.json.stream - JsonParserFactory - - - java.io.InputStream - java.nio.charset.Charset - - - - - JSONP:JAVADOC:207 - if encoding cannot be determined or i/o error (IOException would be cause of JsonException) - javax.json - Json - - - java.io.InputStream - - javax.json.JsonException - - - - JSONP:JAVADOC:215 - Returns a JSON text representation of the JSON number. The representation is equivalent to BigDecimal#toString(). - javax.json - JsonNumber - - - - JSONP:JAVADOC:217 - if a JSON array cannot be created due to i/o error (IOException would be cause of JsonException) - javax.json - JsonReader - - javax.json.JsonException - - - - JSONP:JAVADOC:218 - if read, readObject, readArray or close method is already called - javax.json - JsonReader - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:219 - if a JSON object cannot be created due to i/o error (IOException would be cause of JsonException) - javax.json - JsonReader - - javax.json.JsonException - - - - JSONP:JAVADOC:220 - if read, readObject, readArray or close method is already called - javax.json - JsonReader - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:221 - if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException) - javax.json - JsonWriter - - - javax.json.JsonStructure - - javax.json.JsonException - - - - JSONP:JAVADOC:222 - if writeArray, writeObject, write or close method is already called - javax.json - JsonWriter - - - javax.json.JsonStructure - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:223 - if encoding cannot be determined or i/o error (IOException would be cause of JsonException) - javax.json.spi - JsonProvider - - - java.io.InputStream - - javax.json.JsonException - - - - JSONP:JAVADOC:225 - if encoding cannot be determined or i/o error (IOException would be cause of JsonException) - javax.json.stream - JsonParserFactory - - - java.io.InputStream - - javax.json.JsonException - - - - JSONP:JAVADOC:235 - Returns a JSON number as a BigDecimal. The BigDecimal is created using new BigDecimal(getString()). This method should only called when the parser state is Event#VALUE_NUMBER. - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:236 - when the parser state is not VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:237 - Returns a JSON number as an integer. The returned value is equal to new BigDecimal(getString()).intValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method should only be called when the parser state is Event#VALUE_NUMBER. - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:238 - when the parser state is not VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:239 - Returns a JSON number as a long. The returned value is equal to new BigDecimal(getString()).longValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method is only called when the parser state is Event#VALUE_NUMBER. - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:240 - when the parser state is not VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - JSONP:JAVADOC:250 - Compares the specified object with this JsonNumber object for equality. Returns true if and only if the type of the specified object is also JsonNumber and their #bigDecimalValue() objects are equal - javax.json - JsonNumber - - - java.lang.Object - - - - - JSONP:JAVADOC:251 - Returns the hash code value for this JsonNumber object. The hash code of a JsonNumber object is defined as the hash code of its #bigDecimalValue() object. - javax.json - JsonNumber - - - - JSONP:JAVADOC:254 - Compares the specified object with this JsonString for equality. Returns true if and only if the specified object is also a JsonString, and their #getString() objects are equal. - javax.json - JsonString - - - java.lang.Object - - - - - JSONP:JAVADOC:255 - Returns the hash code value for this JsonString object. The hash code of a JsonString object is defined to be its #getString() object's hash code. - javax.json - JsonString - - - - JSONP:JAVADOC:262 - A convenience method for getJsonNumber(index).intValue(). - javax.json - JsonArray - - - int - - - - - JSONP:JAVADOC:263 - A convenience method for getJsonString(index).getString(). - javax.json - JsonArray - - - int - - - - - JSONP:JAVADOC:264 - A convenience method for getJsonNumber(name).intValue() - javax.json - JsonObject - - - java.lang.String - - - - - JSONP:JAVADOC:265 - A convenience method for getJsonString(name).getString() - javax.json - JsonObject - - - java.lang.String - - - - - JSONP:JAVADOC:278 - 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. - javax.json.stream - JsonGenerationException - - - java.lang.String - - - - - JSONP:JAVADOC:279 - 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. - javax.json.stream - JsonGenerationException - - - java.lang.String - java.lang.Throwable - - - - - JSONP:JAVADOC:285 - 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. - javax.json.stream - JsonParsingException - - - java.lang.String - javax.json.stream.JsonLocation - - - - - JSONP:JAVADOC:286 - 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. - javax.json.stream - JsonParsingException - - - java.lang.String - java.lang.Throwable - javax.json.stream.JsonLocation - - - - - JSONP:JAVADOC:288 - Returns JSON text for this JSON value. - javax.json - JsonValue - - - - JSONP:JAVADOC:289 - Writes the end of the current context. If the current context is an array context, this method writes the end-of-array character (']'). If the current context is an object context, this method writes the end-of-object character ('}'). After writing the end of the current context, the parent context becomes the new current context. - javax.json.stream - JsonGenerator - - - - JSONP:JAVADOC:290 - if this method is called in no context. - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:291 - Flushes the underlying output source. If the generator has saved any characters in a buffer, writes them immediately to the underlying output source before flushing it. - javax.json.stream - JsonGenerator - - - - JSONP:JAVADOC:292 - Writes a JSON name/value pair in the current object context. - javax.json.stream - JsonGenerator - - - java.lang.String - javax.json.JsonValue - - - - - JSONP:JAVADOC:293 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - javax.json.JsonValue - - javax.json.JsonException - - - - JSONP:JAVADOC:295 - Writes a JSON name/string value pair in the current object context. The specified value is written as JSON string value. - javax.json.stream - JsonGenerator - - - java.lang.String - java.lang.String - - - - - JSONP:JAVADOC:296 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - java.lang.String - - javax.json.JsonException - - - - JSONP:JAVADOC:297 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - java.lang.String - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:298 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigInteger - - - - - JSONP:JAVADOC:299 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigInteger - - javax.json.JsonException - - - - JSONP:JAVADOC:301 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The specified value's toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigDecimal - - - - - JSONP:JAVADOC:302 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigDecimal - - javax.json.JsonException - - - - JSONP:JAVADOC:303 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigDecimal - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:304 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - int - - - - - JSONP:JAVADOC:305 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - int - - javax.json.JsonException - - - - JSONP:JAVADOC:306 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - int - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:307 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - long - - - - - JSONP:JAVADOC:308 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - long - - javax.json.JsonException - - - - JSONP:JAVADOC:309 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - long - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:310 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string BigDecimal.valueOf(double).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - double - - - - - JSONP:JAVADOC:311 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - double - - javax.json.JsonException - - - - JSONP:JAVADOC:312 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - double - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:314 - Writes a JSON name/boolean value pair in the current object context. If value is true, it writes the JSON true value, otherwise it writes the JSON false value. - javax.json.stream - JsonGenerator - - - java.lang.String - boolean - - - - - JSONP:JAVADOC:315 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - boolean - - javax.json.JsonException - - - - JSONP:JAVADOC:316 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - boolean - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:317 - Writes the specified value as a JSON value within the current array context. - javax.json.stream - JsonGenerator - - - javax.json.JsonValue - - - - - JSONP:JAVADOC:319 - Writes the specified value as a JSON string value within the current array context. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - JSONP:JAVADOC:321 - Writes the specified value as a JSON number value within the current array context. The specified value's toString() is used as the the text value for writing. - javax.json.stream - JsonGenerator - - - java.math.BigDecimal - - - - - JSONP:JAVADOC:323 - Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.math.BigInteger - - - - - JSONP:JAVADOC:325 - Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - int - - - - - JSONP:JAVADOC:327 - Writes the specified value as a JSON number value within the current array context. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - long - - - - - JSONP:JAVADOC:329 - Writes the specified value as a JSON number value within the current array context. The string BigDecimal.valueOf(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - double - - - - - JSONP:JAVADOC:331 - if the value is Not-a-Number(NaN) or infinity. - javax.json.stream - JsonGenerator - - - double - - java.lang.NumberFormatException - - - - JSONP:JAVADOC:332 - Writes a JSON true or false value within the current array context. If value is true, this method writes the JSON true value, otherwise it writes the JSON false value. - javax.json.stream - JsonGenerator - - - boolean - - - - - JSONP:JAVADOC:334 - Writes a JSON name/null value pair in an current object context. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - JSONP:JAVADOC:335 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.JsonException - - - - JSONP:JAVADOC:336 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:337 - Writes a JSON null value within the current array context. - javax.json.stream - JsonGenerator - - - - JSONP:JAVADOC:339 - Writes the JSON start array character. It starts a new child array context within which JSON values can be written to the array. This method is valid only in an array context or in no context (when a context is not yet started). This method can only be called once in no context. - javax.json.stream - JsonGenerator - - - - JSONP:JAVADOC:340 - Writes the JSON name/start array character pair with in the current object context. It starts a new child array context within which JSON values can be written to the array. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - JSONP:JAVADOC:341 - Writes the JSON start object character. It starts a new child object context within which JSON name/value pairs can be written to the object. This method is valid only in an array context or in no context (when a context is not yet started). This method can only be called once in no context. - javax.json.stream - JsonGenerator - - - - JSONP:JAVADOC:342 - Writes the JSON name/start object character pair in the current object context. It starts a new child object context within which JSON name/value pairs can be written to the object. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - JSONP:JAVADOC:343 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - JSONP:JAVADOC:344 - if the value for specified name mapping is not assignable to JsonNumber - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - JSONP:JAVADOC:345 - if the value for specified name mapping is not assignable to JsonString - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - JSONP:JAVADOC:346 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - JSONP:JAVADOC:347 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - javax.json.JsonValue - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:348 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigInteger - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:349 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - javax.json.JsonValue - - javax.json.JsonException - - - - JSONP:JAVADOC:350 - if this method is not called within an array context. - javax.json.stream - JsonGenerator - - - javax.json.JsonValue - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:351 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.JsonException - - - - JSONP:JAVADOC:352 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:353 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.math.BigDecimal - - javax.json.JsonException - - - - JSONP:JAVADOC:354 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - java.math.BigDecimal - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:355 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.math.BigInteger - - javax.json.JsonException - - - - JSONP:JAVADOC:356 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - java.math.BigInteger - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:357 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - int - - javax.json.JsonException - - - - JSONP:JAVADOC:358 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - int - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:359 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - long - - javax.json.JsonException - - - - JSONP:JAVADOC:360 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - long - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:361 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - double - - javax.json.JsonException - - - - JSONP:JAVADOC:362 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - double - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:363 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - boolean - - javax.json.JsonException - - - - JSONP:JAVADOC:364 - if this method is not called within an array context. - javax.json.stream - JsonGenerator - - - boolean - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:365 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - JSONP:JAVADOC:366 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:367 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - JSONP:JAVADOC:368 - if this method is called within an object context or if called more than once in no context - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:369 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.JsonException - - - - JSONP:JAVADOC:370 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:371 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - JSONP:JAVADOC:372 - if this method is called within an object context or if it is called more than once in no context. - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:373 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.JsonException - - - - JSONP:JAVADOC:374 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:375 - Returns true if there are more parsing states. This method returns false if the parser reaches the end of the JSON text. - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:376 - Returns the event for the next parsing state. - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:377 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - JSONP:JAVADOC:378 - if the value at the specified position is not assignable to JsonNumber - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - JSONP:JAVADOC:379 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - JSONP:JAVADOC:380 - if the value at the specified position is not assignable to JsonString - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - JSONP:JAVADOC:381 - if an incomplete JSON is generated - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - JSONP:JAVADOC:382 - if the value is Not-a-Number(NaN) or infinity. - javax.json.stream - JsonGenerator - - - java.lang.String - double - - java.lang.NumberFormatException - - - - JSONP:JAVADOC:383 - Returns the char sequence for the JSON String value - javax.json - JsonString - - - - JSONP:JAVADOC:387 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonParser - - javax.json.JsonException - - - - JSONP:JAVADOC:388 - if the parser encounters invalid JSON when advancing to next state. - javax.json.stream - JsonParser - - javax.json.stream.JsonParsingException - - - - JSONP:JAVADOC:389 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonParser - - javax.json.JsonException - - - - JSONP:JAVADOC:390 - if the parser encounters invalid JSON when advancing to next state. - javax.json.stream - JsonParser - - javax.json.stream.JsonParsingException - - - - JSONP:JAVADOC:391 - if there are no more parsing states. - javax.json.stream - JsonParser - - java.util.NoSuchElementException - - - - JSONP:JAVADOC:400 - Adds a JsonObject from an object builder to the array. - javax.json - JsonArrayBuilder - - - javax.json.JsonObjectBuilder - - - - - JSONP:JAVADOC:401 - Adds a JsonArray from an array builder to the array. - javax.json - JsonArrayBuilder - - - javax.json.JsonArrayBuilder - - - - - JSONP:JAVADOC:402 - Returns the current array. - javax.json - JsonArrayBuilder - - - - JSONP:JAVADOC:403 - Creates a JSON array builder - javax.json - Json - - - - JSONP:JAVADOC:404 - Adds a name/JsonObject pair to the JSON object associated with this object builder. The value JsonObject is built from the specified object builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonObject from the specified object builder. - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonObjectBuilder - - - - - JSONP:JAVADOC:406 - Adds a name/JsonArray pair to the JSON object associated with this object builder. The value JsonArray is built from the specified array builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonArray from the specified array builder. - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonArrayBuilder - - - - - JSONP:JAVADOC:408 - Returns the JSON object associated with this object builder. The iteration order for the JsonObject is based on the order in which name/value pairs are added to the object using this builder. - javax.json - JsonObjectBuilder - - - - JSONP:JAVADOC:409 - Creates a JSON object builder - javax.json - Json - - - - JSONP:JAVADOC:410 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json - JsonReader - - javax.json.JsonException - - - - JSONP:JAVADOC:411 - if a JSON object or array cannot be created due to incorrect representation - javax.json - JsonReader - - javax.json.stream.JsonParsingException - - - - JSONP:JAVADOC:412 - if a JSON array cannot be created due to incorrect representation - javax.json - JsonReader - - javax.json.stream.JsonParsingException - - - - JSONP:JAVADOC:413 - if a JSON object cannot be created due to incorrect representation - javax.json - JsonReader - - javax.json.stream.JsonParsingException - - - - JSONP:JAVADOC:414 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json - JsonWriter - - javax.json.JsonException - - - - JSONP:JAVADOC:415 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonParser - - javax.json.JsonException - - - - JSONP:JAVADOC:416 - Creates a generator factory for creating JsonGenerator objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - JSONP:JAVADOC:417 - Creates a parser factory for creating JsonParser objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - JSONP:JAVADOC:419 - Creates a JSON reader from a character stream. The reader is configured with the factory configuration. - javax.json - JsonReaderFactory - - - java.io.Reader - - - - - JSONP:JAVADOC:420 - Creates a JSON reader from a byte stream. The bytes of the stream are decoded to characters using the specified charset. The reader is configured with the factory configuration. - javax.json - JsonReaderFactory - - - java.io.InputStream - java.nio.charset.Charset - - - - - JSONP:JAVADOC:422 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. The writer is configured with the factory configuration. - javax.json - JsonWriterFactory - - - java.io.Writer - - - - - JSONP:JAVADOC:423 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The writer is configured with the factory configuration. - javax.json - JsonWriterFactory - - - java.io.OutputStream - - - - - JSONP:JAVADOC:424 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using the specified charset. The writer is configured with the factory configuration. - javax.json - JsonWriterFactory - - - java.io.OutputStream - java.nio.charset.Charset - - - - - JSONP:JAVADOC:425 - Creates a generator factory for creating JsonGenerator instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - JSONP:JAVADOC:426 - Creates a parser factory for creating JsonParser instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - JSONP:JAVADOC:427 - Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON generators. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json.stream - JsonGeneratorFactory - - - - JSONP:JAVADOC:428 - Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON parsers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json.stream - JsonParserFactory - - - - JSONP:JAVADOC:429 - Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 4627. The reader is configured with the factory configuration. - javax.json - JsonReaderFactory - - - java.io.InputStream - - - - - JSONP:JAVADOC:430 - Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false. - javax.json - JsonArray - - - int - - - - - JSONP:JAVADOC:431 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - JSONP:JAVADOC:432 - if the value at the specified position is not assignable to JsonValue.TRUE or JsonValue.FALSE - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - JSONP:JAVADOC:433 - Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false. Otherwise this method returns the specified default value. - javax.json - JsonArray - - - int - boolean - - - - - JSONP:JAVADOC:434 - Returns the int value of the JsonNumber at the specified position. If the value at that position is a JsonNumber, this method returns javax.json.JsonNumber#intValue(). Otherwise this method returns the specified default value. - javax.json - JsonArray - - - int - int - - - - - JSONP:JAVADOC:435 - Returns the String value of JsonString at the specified position in this JSON array values. If JsonString is found, its javax.json.JsonString#getString() is returned. Otherwise, the specified default value is returned. - javax.json - JsonArray - - - int - java.lang.String - - - - - JSONP:JAVADOC:436 - Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false. - javax.json - JsonObject - - - java.lang.String - - - - - JSONP:JAVADOC:437 - if the specified name doesn't have any mapping - javax.json - JsonObject - - - java.lang.String - - java.lang.NullPointerException - - - - JSONP:JAVADOC:438 - if the value for specified name mapping is not assignable to JsonValue.TRUE or JsonValue.FALSE - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - JSONP:JAVADOC:439 - Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false. Otherwise, the specified default value is returned. - javax.json - JsonObject - - - java.lang.String - boolean - - - - - JSONP:JAVADOC:440 - if the specified name doesn't have any mapping - javax.json - JsonObject - - - java.lang.String - - java.lang.NullPointerException - - - - JSONP:JAVADOC:441 - Returns the int value of the associated JsonNumber mapping for the specified name. If JsonNumber is found, then its javax.json.JsonNumber#intValue() is returned. Otherwise, the specified default value is returned. - javax.json - JsonObject - - - java.lang.String - int - - - - - JSONP:JAVADOC:442 - if the specified name doesn't have any mapping - javax.json - JsonObject - - - java.lang.String - - java.lang.NullPointerException - - - - JSONP:JAVADOC:443 - Returns the string value of the associated JsonString mapping for the specified name. If JsonString is found, then its javax.json.JsonString#getString() is returned. Otherwise, the specified default value is returned. - javax.json - JsonObject - - - java.lang.String - java.lang.String - - - - - JSONP:JAVADOC:445 - Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - JSONP:JAVADOC:449 - Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - JSONP:JAVADOC:452 - Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - JSONP:JAVADOC:453 - Creates a JsonArrayBuilder instance that is used to build JsonArray - javax.json - JsonBuilderFactory - - - - JSONP:JAVADOC:454 - Creates a JsonObjectBuilder instance that is used to build JsonObject. - javax.json - JsonBuilderFactory - - - - JSONP:JAVADOC:455 - Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON builders. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json - JsonBuilderFactory - - - - JSONP:JAVADOC:459 - Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON readers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json - JsonReaderFactory - - - - JSONP:JAVADOC:463 - Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON writer objects. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json - JsonWriterFactory - - - - JSONP:JAVADOC:464 - Creates a JSON array builder - javax.json.spi - JsonProvider - - - - JSONP:JAVADOC:465 - Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - JSONP:JAVADOC:466 - Creates a JSON object builder - javax.json.spi - JsonProvider - - - - JSONP:JAVADOC:467 - Creates a JSON reader from a character stream. - javax.json.spi - JsonProvider - - - java.io.Reader - - - - - JSONP:JAVADOC:468 - Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 4627. - javax.json.spi - JsonProvider - - - java.io.InputStream - - - - - JSONP:JAVADOC:469 - Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - JSONP:JAVADOC:470 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. - javax.json.spi - JsonProvider - - - java.io.Writer - - - - - JSONP:JAVADOC:471 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. - javax.json.spi - JsonProvider - - - java.io.OutputStream - - - - - JSONP:JAVADOC:472 - Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - JSONP:JAVADOC:474 - Return the column number for the current JSON event in the input source. - javax.json.stream - JsonLocation - - - - JSONP:JAVADOC:475 - Return the line number for the current JSON event in the input source. - javax.json.stream - JsonLocation - - - - JSONP:JAVADOC:476 - Return the stream offset into the input source this location is pointing to. If the input source is a file or a byte stream then this is the byte offset into that stream, but if the input source is a character media then the offset is the character offset. Returns -1 if there is no offset available. - javax.json.stream - JsonLocation - - - - JSONP:JAVADOC:477 - Return the location that corresponds to the parser's current state in the JSON input source. The location information is only valid in the current parser state (or until the parser is advanced to a next state). - javax.json.stream - JsonParser - - - - JSONP:JAVADOC:478 - Return the location of the incorrect JSON. - javax.json.stream - JsonParsingException - - - - JSONP:JAVADOC:481 - Returns a list a view of the specified type for the array. This method does not verify if there is a value of wrong type in the array. Providing this typesafe view dynamically may cause a program fail with a ClassCastException, if there is a value of wrong type in this array. Unfortunately, the exception can occur at any time after this method returns. - javax.json - JsonArray - - - java.lang.Class - - - - - JSONP:JAVADOC:490 - Returns the array value at the specified position in this array. This is a convenience method for (JsonArray)get(index). - javax.json - JsonArray - - - int - - - - - JSONP:JAVADOC:491 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - JSONP:JAVADOC:492 - if the value at the specified position is not assignable to the JsonArray type - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - JSONP:JAVADOC:493 - Returns the number value at the specified position in this array. This is a convenience method for (JsonNumber)get(index). - javax.json - JsonArray - - - int - - - - - JSONP:JAVADOC:494 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - JSONP:JAVADOC:495 - if the value at the specified position is not assignable to the JsonNumber type - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - JSONP:JAVADOC:496 - Returns the object value at the specified position in this array. This is a convenience method for (JsonObject)get(index). - javax.json - JsonArray - - - int - - - - - JSONP:JAVADOC:497 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - JSONP:JAVADOC:498 - if the value at the specified position is not assignable to the JsonObject type - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - JSONP:JAVADOC:499 - Returns the string value at ths specified position in this array. This is a convenience method for (JsonString)get(index). - javax.json - JsonArray - - - int - - - - - JSONP:JAVADOC:500 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - JSONP:JAVADOC:501 - if the value at the specified position is not assignable to the JsonString type - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - JSONP:JAVADOC:506 - Returns true if the value at the specified location in this array is JsonValue.NULL. - javax.json - JsonArray - - - int - - - - - JSONP:JAVADOC:507 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - JSONP:JAVADOC:527 - Returns the array value to which the specified name is mapped. This is a convenience method for (JsonArray)get(name) to get the value. - javax.json - JsonObject - - - java.lang.String - - - - - JSONP:JAVADOC:528 - if the value to which the specified name is mapped is not assignable to JsonArray type - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - JSONP:JAVADOC:529 - Returns the number value to which the specified name is mapped. This is a convenience method for (JsonNumber)get(name) to get the value. - javax.json - JsonObject - - - java.lang.String - - - - - JSONP:JAVADOC:530 - if the value to which the specified name is mapped is not assignable to JsonNumber type - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - JSONP:JAVADOC:531 - Returns the object value to which the specified name is mapped. This is a convenience method for (JsonObject)get(name) to get the value. - javax.json - JsonObject - - - java.lang.String - - - - - JSONP:JAVADOC:532 - if the value to which the specified name is mapped is not assignable to JsonObject type - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - JSONP:JAVADOC:533 - Returns the string value to which the specified name is mapped. This is a convenience method for (JsonString)get(name) to get the value. - javax.json - JsonObject - - - java.lang.String - - - - - JSONP:JAVADOC:534 - if the value to which the specified name is mapped is not assignable to JsonString type - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - JSONP:JAVADOC:539 - Returns true if the associated value for the specified name is JsonValue.NULL. - javax.json - JsonObject - - - java.lang.String - - - - - JSONP:JAVADOC:540 - if the specified name doesn't have any mapping - javax.json - JsonObject - - - java.lang.String - - java.lang.NullPointerException - - - - JSONP:JAVADOC:551 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - JSONP:JAVADOC:555 - if the specified value is null - javax.json - JsonArrayBuilder - - - javax.json.JsonValue - - java.lang.NullPointerException - - - - JSONP:JAVADOC:556 - if the specified value is null - javax.json - JsonArrayBuilder - - - java.lang.String - - java.lang.NullPointerException - - - - JSONP:JAVADOC:557 - if the specified value is null - javax.json - JsonArrayBuilder - - - java.math.BigDecimal - - java.lang.NullPointerException - - - - JSONP:JAVADOC:558 - if the specified value is null - javax.json - JsonArrayBuilder - - - java.math.BigInteger - - java.lang.NullPointerException - - - - JSONP:JAVADOC:559 - if the specified builder is null - javax.json - JsonArrayBuilder - - - javax.json.JsonObjectBuilder - - java.lang.NullPointerException - - - - JSONP:JAVADOC:560 - if the specified builder is null - javax.json - JsonArrayBuilder - - - javax.json.JsonArrayBuilder - - java.lang.NullPointerException - - - - JSONP:JAVADOC:561 - if the specified name or value is null - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonValue - - java.lang.NullPointerException - - - - JSONP:JAVADOC:562 - if the specified name or value is null - javax.json - JsonObjectBuilder - - - java.lang.String - java.lang.String - - java.lang.NullPointerException - - - - JSONP:JAVADOC:563 - if the specified name or value is null - javax.json - JsonObjectBuilder - - - java.lang.String - java.math.BigInteger - - java.lang.NullPointerException - - - - JSONP:JAVADOC:564 - if the specified name or value is null - javax.json - JsonObjectBuilder - - - java.lang.String - java.math.BigDecimal - - java.lang.NullPointerException - - - - JSONP:JAVADOC:565 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - int - - java.lang.NullPointerException - - - - JSONP:JAVADOC:566 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - long - - java.lang.NullPointerException - - - - JSONP:JAVADOC:567 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - double - - java.lang.NullPointerException - - - - JSONP:JAVADOC:568 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - boolean - - java.lang.NullPointerException - - - - JSONP:JAVADOC:569 - if the specified name or builder is null - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonObjectBuilder - - java.lang.NullPointerException - - - - JSONP:JAVADOC:570 - if the specified name or builder is null - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonArrayBuilder - - java.lang.NullPointerException - - - - JSONP:JAVADOC:571 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - - java.lang.NullPointerException - - - - diff --git a/internal/docs/jsonp/JSONP1.1.TCD.txt b/internal/docs/jsonp/JSONP1.1.TCD.txt deleted file mode 100644 index ab273940f5..0000000000 --- a/internal/docs/jsonp/JSONP1.1.TCD.txt +++ /dev/null @@ -1,72 +0,0 @@ -TCK Coverage Document for JSR-374 Java API for JSON Processing (JSON-P) 1.1 Specification - - -TCK Components: ---------------- -- User's Guide -- Compatibility Rules -- Configuration Instructions -- Test Suite -- API Tests -- Signature Tests -- Pluggability Tests -- Framework Code -- JavaTest TM Harness - - -Terminology of Metrics ----------------------- -- Assertion: A specific statement of functionality or behavior derived from a - specification. A testable assertion is one that can be validated in an - implementation by testing. -- Test: A binary application (or script) comprised of one or more Test Cases. -- Test Case: A single set of test inputs, execution conditions, and expected - results developed to verify an implementation's conformance with a specific - assertion. -- Specification Assertion Coverage: Ratio of all assertions tested by at least - one test case to the total number of testable assertions defined by the - specification. -- API Coverage: Ratio of methods directly exercised by test cases to the total - number of methods defined by the specification. - - --------- -Coverage --------- -******************************************************************************** -Assertion details. These details will be removed from the final TCD but are -checked into revision history so we can backtrack the numbers later, if we need to. - -Assertions found by the coverage tools (March 31st, 2017 coverage report): ------------------------------------------------------------------------ - api total : 289 - api tested total : 284 - api percentage tested : 98,27% - -Number of tests in JSON-P 1.1 TCK: 187 - - -Quality Assurance ------------------ -- TCK was run on the following platforms, note all platforms use Java Platform, Standard Edition 8 - (Java SE 8): - * Oracle Linux 7.1 - * Windows 10 - - -- Code quality was demonstrated through the use of code reviews and inspections -- User's Guide was constructed from the standard TCK User's Guide template -- Documentation instructions were verified and tested - - -Justification of Adequacy -------------------------- -The JSON-P TCK Version 1.1 provides a comprehensive set of tests to ensure that all -implementations of the Java API for JSON Processing 1.1 Specification are compatible. As -with all TCKs it is impossible to provide tests for 100% assertion coverage. Note, -while the TCK may not have tests for all assertions in the Java API for JSON Processing -1.1 Specification, all implementations must be compatible with the specification. - -Untested assertions are due to the effects of late specification changes, optional -functionality, conditions that cannot be easily tested, and the availability and -cost of test development resources. diff --git a/internal/docs/jsonp/JSONP1.1JavadocAssertions.html b/internal/docs/jsonp/JSONP1.1JavadocAssertions.html deleted file mode 100644 index b40534c793..0000000000 --- a/internal/docs/jsonp/JSONP1.1JavadocAssertions.html +++ /dev/null @@ -1,2721 +0,0 @@ - - - - - -JavaDoc Assertion Detail - - -
-
-

Java API for JSON Processing
JSON-P - 1.1
- JavaDoc Assertion Detail -

-
- - - - - - - - - - - -
TotalsTotalActiveDeprecatedRemoved
- # of Assertions - 4192890130
- # of Required Assertions - 4192890130
- # of Optional Assertions - 0000
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IDReturnMethod/FieldDescriptionRequiredDeprecatedTestable
JSONP:JAVADOC:6JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonValue - ) -
Adds a value to the array.true -
-
true
JSONP:JAVADOC:8JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - String - ) -
Adds a value to the array as a JsonString.true -
-
true
JSONP:JAVADOC:10JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - BigDecimal - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:12JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - BigInteger - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:14JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:16JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - long - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:18JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - double - ) -
Adds a value to the array as a JsonNumber.true -
-
true
JSONP:JAVADOC:21JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - boolean - ) -
Adds a JsonValue#TRUE or JsonValue#FALSE value to the array.true -
-
true
JSONP:JAVADOC:25JsonArrayBuilderjavax.json.JsonArrayBuilder.addNull
-
Adds a JsonValue#NULL value to the array.true -
-
true
JSONP:JAVADOC:37JsonExceptionjavax.json.JsonException.JsonException
- - ( - String - ) -
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.true -
-
true
JSONP:JAVADOC:38JsonExceptionjavax.json.JsonException.JsonException
- - ( - String - ,
Throwable - ) -
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.true -
-
true
JSONP:JAVADOC:40BigDecimaljavax.json.JsonNumber.bigDecimalValue
-
Returns this JSON number as a BigDecimal object.true -
-
true
JSONP:JAVADOC:41BigIntegerjavax.json.JsonNumber.bigIntegerValue
-
Returns this JSON number as a BigInteger object. This is a a convenience method for bigDecimalValue().toBigInteger(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:42BigIntegerjavax.json.JsonNumber.bigIntegerValueExact
-
Returns this JSON number as a BigInteger object. This is a convenience method for bigDecimalValue().toBigIntegerExact().true -
-
true
JSONP:JAVADOC:44doublejavax.json.JsonNumber.doubleValue
-
Returns this JSON number as a double. This is a a convenience method for bigDecimalValue().doubleValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:45intjavax.json.JsonNumber.intValue
-
Returns this JSON number as an int. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:46intjavax.json.JsonNumber.intValueExact
-
Returns this JSON number as an int.true -
-
true
JSONP:JAVADOC:48longjavax.json.JsonNumber.longValue
-
Returns this JSON number as a long. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign.true -
-
true
JSONP:JAVADOC:49longjavax.json.JsonNumber.longValueExact
-
Returns this JSON number as a long.true -
-
true
JSONP:JAVADOC:51booleanjavax.json.JsonNumber.isIntegral
-
Returns true if this JSON number is a integral number. This method semantics are defined using bigDecimalValue().scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonNumber num = ... if (num.isIntegral()) { num.longValue(); // or other methods to get integral value } else { num.doubleValue(); // or other methods to get decimal number value }true -
-
true
JSONP:JAVADOC:58JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonValue - ) -
Adds a name/JsonValue pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:61JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
String - ) -
Adds a name/JsonString pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:64JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
BigInteger - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:67JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
BigDecimal - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:70JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
int - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:73JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
long - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:76JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
double - ) -
Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:80JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
boolean - ) -
Adds a name/JsonValue#TRUE or name/JsonValue#FALSE pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value.true -
-
true
JSONP:JAVADOC:86JsonObjectBuilderjavax.json.JsonObjectBuilder.addNull
- - ( - String - ) -
Adds a name/JsonValue#NULL pair to the JSON object associated with this object builder where the value is null. If the object contains a mapping for the specified name, this method replaces the old value with null.true -
-
true
JSONP:JAVADOC:96voidjavax.json.JsonReader.close
-
Closes this reader and frees any resources associated with the reader. This method closes the underlying input source.true -
-
true
JSONP:JAVADOC:97JsonReaderjavax.json.Json.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream.true -
-
true
JSONP:JAVADOC:101Stringjavax.json.JsonString.getString
-
Returns the JSON string value.true -
-
true
JSONP:JAVADOC:102ValueTypejavax.json.JsonValue.getValueType
-
Returns the value type of this JSON value.true -
-
true
JSONP:JAVADOC:103ValueTypejavax.json.JsonValue.ValueType.valueOf
- - ( - String - ) -
-
-
true -
-
true
JSONP:JAVADOC:104ValueType[]javax.json.JsonValue.ValueType.values
-
-
-
true -
-
true
JSONP:JAVADOC:105voidjavax.json.JsonWriter.close
-
-
-
true -
-
true
JSONP:JAVADOC:106JsonWriterjavax.json.Json.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream.true -
-
true
JSONP:JAVADOC:107voidjavax.json.JsonWriter.writeArray
- - ( - JsonArray - ) -
Writes the specified JSON JsonArray array to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:110voidjavax.json.JsonWriter.writeObject
- - ( - JsonObject - ) -
Writes the specified JSON JsonObject object to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:115voidjavax.json.stream.JsonGenerator.close
-
Closes this generator and frees any resources associated with it. This method closes the underlying output source.true -
-
true
JSONP:JAVADOC:117voidjavax.json.stream.JsonParser.close
-
Closes this parser and frees any resources associated with the parser. This method closes the underlying input source.true -
-
true
JSONP:JAVADOC:120booleanjavax.json.stream.JsonParser.isIntegralNumber
-
Returns true if the JSON number at the current parser state is a integral number. A BigDecimal may be used to store the value internally and this method semantics are defined using its scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonParser parser = ... if (parser.isIntegralNumber()) { parser.getInt(); // or other methods to get integral value } else { parser.getBigDecimal(); }true -
-
true
JSONP:JAVADOC:122Stringjavax.json.stream.JsonParser.getString
-
Returns a String for the name in a name/value pair, for a string value or a number value. This method should only be called when the parser state is Event#KEY_NAME, Event#VALUE_STRING, or Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:128Eventjavax.json.stream.JsonParser.Event.valueOf
- - ( - String - ) -
-
-
true -
-
true
JSONP:JAVADOC:129Event[]javax.json.stream.JsonParser.Event.values
-
-
-
true -
-
true
JSONP:JAVADOC:131JsonGeneratorjavax.json.Json.createGenerator
- - ( - Writer - ) -
Creates a JSON generator for writing JSON to a character stream.true -
-
true
JSONP:JAVADOC:133JsonParserjavax.json.Json.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:144JsonGeneratorjavax.json.spi.JsonProvider.createGenerator
- - ( - Writer - ) -
Creates a JSON generator for writing JSON text to a character stream.true -
-
true
JSONP:JAVADOC:146JsonParserjavax.json.spi.JsonProvider.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:152JsonProviderjavax.json.spi.JsonProvider.provider
-
Creates a JSON provider object. The provider is loaded using the ServiceLoader#load(Class) method. If there are no available service providers, this method returns the default service provider. Users are recommended to cache the result of this method.true -
-
true
JSONP:JAVADOC:162JsonGeneratorjavax.json.stream.JsonGeneratorFactory.createGenerator
- - ( - Writer - ) -
Creates a JSON generator to write JSON text to a character stream. The generator is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:163JsonGeneratorjavax.json.stream.JsonGeneratorFactory.createGenerator
- - ( - OutputStream - ,
Charset - ) -
Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using the specified charset. The generator is configured with the factory's configuration.true -
-
true
JSONP:JAVADOC:164JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - Reader - ) -
Creates a JSON parser from a character stream.true -
-
true
JSONP:JAVADOC:165JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - InputStream - ) -
Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as specified in RFC 7159.true -
-
true
JSONP:JAVADOC:166JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - JsonObject - ) -
Creates a JSON parser from the specified JSON object.true -
-
true
JSONP:JAVADOC:167JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - JsonArray - ) -
Creates a JSON parser from the specified JSON array.true -
-
true
JSONP:JAVADOC:168JsonGeneratorjavax.json.Json.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator for writing JSON to a byte stream.true -
-
true
JSONP:JAVADOC:172JsonParserjavax.json.Json.createParser
- - ( - InputStream - ) -
Creates a JSON parser from a byte stream. The character encoding of the stream is determined as specified in RFC 7159.true -
-
true
JSONP:JAVADOC:178JsonReaderjavax.json.Json.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159.true -
-
true
JSONP:JAVADOC:181JsonStructurejavax.json.JsonReader.read
-
Returns a JSON array or object that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:184JsonArrayjavax.json.JsonReader.readArray
-
Returns a JSON array that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:185JsonObjectjavax.json.JsonReader.readObject
-
Returns a JSON object that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:187JsonWriterjavax.json.Json.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding.true -
-
true
JSONP:JAVADOC:191voidjavax.json.JsonWriter.write
- - ( - JsonStructure - ) -
Writes the specified JSON JsonObject object or JsonArray array to the output source. This method needs to be called only once for a writer instance.true -
-
true
JSONP:JAVADOC:192JsonGeneratorjavax.json.spi.JsonProvider.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator for writing JSON text to a byte stream.true -
-
true
JSONP:JAVADOC:196JsonParserjavax.json.spi.JsonProvider.createParser
- - ( - InputStream - ) -
Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as defined in RFC 7159 .true -
-
true
JSONP:JAVADOC:200JsonGeneratorjavax.json.stream.JsonGeneratorFactory.createGenerator
- - ( - OutputStream - ) -
Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The generator is configured with the factory's configuration.true -
-
true
JSONP:JAVADOC:201JsonParserjavax.json.stream.JsonParserFactory.createParser
- - ( - InputStream - ,
Charset - ) -
Creates a JSON parser from the specified byte stream. The bytes of the stream are decoded to characters using the specified charset.true -
-
true
JSONP:JAVADOC:215Stringjavax.json.JsonNumber.toString
-
Returns a JSON text representation of the JSON number. The representation is equivalent to BigDecimal#toString().true -
-
true
JSONP:JAVADOC:235BigDecimaljavax.json.stream.JsonParser.getBigDecimal
-
Returns a JSON number as a BigDecimal. The BigDecimal is created using new BigDecimal(getString()). This method should only called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:237intjavax.json.stream.JsonParser.getInt
-
Returns a JSON number as an integer. The returned value is equal to new BigDecimal(getString()).intValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method should only be called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:239longjavax.json.stream.JsonParser.getLong
-
Returns a JSON number as a long. The returned value is equal to new BigDecimal(getString()).longValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method is only called when the parser state is Event#VALUE_NUMBER.true -
-
true
JSONP:JAVADOC:250booleanjavax.json.JsonNumber.equals
- - ( - Object - ) -
Compares the specified object with this JsonNumber object for equality. Returns true if and only if the type of the specified object is also JsonNumber and their #bigDecimalValue() objects are equaltrue -
-
true
JSONP:JAVADOC:251intjavax.json.JsonNumber.hashCode
-
Returns the hash code value for this JsonNumber object. The hash code of a JsonNumber object is defined as the hash code of its #bigDecimalValue() object.true -
-
true
JSONP:JAVADOC:254booleanjavax.json.JsonString.equals
- - ( - Object - ) -
Compares the specified object with this JsonString for equality. Returns true if and only if the specified object is also a JsonString, and their #getString() objects are equal.true -
-
true
JSONP:JAVADOC:255intjavax.json.JsonString.hashCode
-
Returns the hash code value for this JsonString object. The hash code of a JsonString object is defined to be its #getString() object's hash code.true -
-
true
JSONP:JAVADOC:262intjavax.json.JsonArray.getInt
- - ( - int - ) -
A convenience method for getJsonNumber(index).intValue().true -
-
true
JSONP:JAVADOC:263Stringjavax.json.JsonArray.getString
- - ( - int - ) -
A convenience method for getJsonString(index).getString().true -
-
true
JSONP:JAVADOC:264intjavax.json.JsonObject.getInt
- - ( - String - ) -
A convenience method for getJsonNumber(name).intValue()true -
-
true
JSONP:JAVADOC:265Stringjavax.json.JsonObject.getString
- - ( - String - ) -
A convenience method for getJsonString(name).getString()true -
-
true
JSONP:JAVADOC:278JsonGenerationExceptionjavax.json.stream.JsonGenerationException.JsonGenerationException
- - ( - String - ) -
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.true -
-
true
JSONP:JAVADOC:279JsonGenerationExceptionjavax.json.stream.JsonGenerationException.JsonGenerationException
- - ( - String - ,
Throwable - ) -
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.true -
-
true
JSONP:JAVADOC:285JsonParsingExceptionjavax.json.stream.JsonParsingException.JsonParsingException
- - ( - String - ,
JsonLocation - ) -
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.true -
-
true
JSONP:JAVADOC:286JsonParsingExceptionjavax.json.stream.JsonParsingException.JsonParsingException
- - ( - String - ,
Throwable - ,
JsonLocation - ) -
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.true -
-
true
JSONP:JAVADOC:288Stringjavax.json.JsonValue.toString
-
Returns JSON text for this JSON value.true -
-
true
JSONP:JAVADOC:289JsonGeneratorjavax.json.stream.JsonGenerator.writeEnd
-
Writes the end of the current context. If the current context is an array context, this method writes the end-of-array character (']'). If the current context is an object context, this method writes the end-of-object character ('}'). After writing the end of the current context, the parent context becomes the new current context. If parent context is field context, it is closed.true -
-
true
JSONP:JAVADOC:291voidjavax.json.stream.JsonGenerator.flush
-
Flushes the underlying output source. If the generator has saved any characters in a buffer, writes them immediately to the underlying output source before flushing it.true -
-
true
JSONP:JAVADOC:292JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
JsonValue - ) -
Writes a JSON name/value pair in the current object context.true -
-
true
JSONP:JAVADOC:295JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
String - ) -
Writes a JSON name/string value pair in the current object context. The specified value is written as JSON string value.true -
-
true
JSONP:JAVADOC:298JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
BigInteger - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:301JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
BigDecimal - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The specified value's toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:304JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
int - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:307JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
long - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:310JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
double - ) -
Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string BigDecimal.valueOf(double).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:314JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ,
boolean - ) -
Writes a JSON name/boolean value pair in the current object context. If value is true, it writes the JSON true value, otherwise it writes the JSON false value.true -
-
true
JSONP:JAVADOC:317JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - JsonValue - ) -
Writes the specified value as a JSON value within the current array, field or root context.true -
-
true
JSONP:JAVADOC:319JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - String - ) -
Writes the specified value as a JSON string value within the current array, field or root context.true -
-
true
JSONP:JAVADOC:321JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - BigDecimal - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The specified value's toString() is used as the the text value for writing.true -
-
true
JSONP:JAVADOC:323JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - BigInteger - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:325JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - int - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:327JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - long - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:329JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - double - ) -
Writes the specified value as a JSON number value within the current array, field or root context. The string BigDecimal.valueOf(value).toString() is used as the text value for writing.true -
-
true
JSONP:JAVADOC:332JsonGeneratorjavax.json.stream.JsonGenerator.write
- - ( - boolean - ) -
Writes a JSON true or false value within the current array, field or root context. If value is true, this method writes the JSON true value, otherwise it writes the JSON false value.true -
-
true
JSONP:JAVADOC:334JsonGeneratorjavax.json.stream.JsonGenerator.writeNull
- - ( - String - ) -
Writes a JSON name/null value pair in an current object context.true -
-
true
JSONP:JAVADOC:337JsonGeneratorjavax.json.stream.JsonGenerator.writeNull
-
Writes a JSON null value within the current array, field or root context.true -
-
true
JSONP:JAVADOC:339JsonGeneratorjavax.json.stream.JsonGenerator.writeStartArray
-
Writes the JSON start array character. It starts a new child array context within which JSON values can be written to the array. This method is valid only in an array context, field context or in no context (when a context is not yet started). This method can only be called once in no context.true -
-
true
JSONP:JAVADOC:340JsonGeneratorjavax.json.stream.JsonGenerator.writeStartArray
- - ( - String - ) -
Writes the JSON name/start array character pair with in the current object context. It starts a new child array context within which JSON values can be written to the array.true -
-
true
JSONP:JAVADOC:341JsonGeneratorjavax.json.stream.JsonGenerator.writeStartObject
-
Writes the JSON start object character. It starts a new child object context within which JSON name/value pairs can be written to the object. This method is valid only in an array context, field context or in no context (when a context is not yet started). This method can only be called once in no context.true -
-
true
JSONP:JAVADOC:342JsonGeneratorjavax.json.stream.JsonGenerator.writeStartObject
- - ( - String - ) -
Writes the JSON name/start object character pair in the current object context. It starts a new child object context within which JSON name/value pairs can be written to the object.true -
-
true
JSONP:JAVADOC:375booleanjavax.json.stream.JsonParser.hasNext
-
Returns true if there are more parsing states. This method returns false if the parser reaches the end of the JSON text.true -
-
true
JSONP:JAVADOC:376Eventjavax.json.stream.JsonParser.next
-
Returns the event for the next parsing state.true -
-
true
JSONP:JAVADOC:383CharSequencejavax.json.JsonString.getChars
-
Returns the char sequence for the JSON String valuetrue -
-
true
JSONP:JAVADOC:400JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonObjectBuilder - ) -
Adds a JsonObject from an object builder to the array.true -
-
true
JSONP:JAVADOC:401JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - JsonArrayBuilder - ) -
Adds a JsonArray from an array builder to the array.true -
-
true
JSONP:JAVADOC:402JsonArrayjavax.json.JsonArrayBuilder.build
-
Returns the current array.true -
-
true
JSONP:JAVADOC:403JsonArrayBuilderjavax.json.Json.createArrayBuilder
-
Creates a JSON array buildertrue -
-
true
JSONP:JAVADOC:404JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonObjectBuilder - ) -
Adds a name/JsonObject pair to the JSON object associated with this object builder. The value JsonObject is built from the specified object builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonObject from the specified object builder.true -
-
true
JSONP:JAVADOC:406JsonObjectBuilderjavax.json.JsonObjectBuilder.add
- - ( - String - ,
JsonArrayBuilder - ) -
Adds a name/JsonArray pair to the JSON object associated with this object builder. The value JsonArray is built from the specified array builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonArray from the specified array builder.true -
-
true
JSONP:JAVADOC:408JsonObjectjavax.json.JsonObjectBuilder.build
-
Returns the JSON object associated with this object builder. The iteration order for the JsonObject is based on the order in which name/value pairs are added to the object using this builder.true -
-
true
JSONP:JAVADOC:409JsonObjectBuilderjavax.json.Json.createObjectBuilder
-
Creates a JSON object buildertrue -
-
true
JSONP:JAVADOC:416JsonGeneratorFactoryjavax.json.Json.createGeneratorFactory
- - ( - Map - ) -
Creates a generator factory for creating JsonGenerator objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:417JsonParserFactoryjavax.json.Json.createParserFactory
- - ( - Map - ) -
Creates a parser factory for creating JsonParser objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:419JsonReaderjavax.json.JsonReaderFactory.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:420JsonReaderjavax.json.JsonReaderFactory.createReader
- - ( - InputStream - ,
Charset - ) -
Creates a JSON reader from a byte stream. The bytes of the stream are decoded to characters using the specified charset. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:422JsonWriterjavax.json.JsonWriterFactory.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:423JsonWriterjavax.json.JsonWriterFactory.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:424JsonWriterjavax.json.JsonWriterFactory.createWriter
- - ( - OutputStream - ,
Charset - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using the specified charset. The writer is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:425JsonGeneratorFactoryjavax.json.spi.JsonProvider.createGeneratorFactory
- - ( - Map - ) -
Creates a generator factory for creating JsonGenerator instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:426JsonParserFactoryjavax.json.spi.JsonProvider.createParserFactory
- - ( - Map - ) -
Creates a parser factory for creating JsonParser instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:427Mapjavax.json.stream.JsonGeneratorFactory.getConfigInUse
-
Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON generators. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:428Mapjavax.json.stream.JsonParserFactory.getConfigInUse
-
Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON parsers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:429JsonReaderjavax.json.JsonReaderFactory.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159. The reader is configured with the factory configuration.true -
-
true
JSONP:JAVADOC:430booleanjavax.json.JsonArray.getBoolean
- - ( - int - ) -
Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false.true -
-
true
JSONP:JAVADOC:433booleanjavax.json.JsonArray.getBoolean
- - ( - int - ,
boolean - ) -
Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false. Otherwise this method returns the specified default value.true -
-
true
JSONP:JAVADOC:434intjavax.json.JsonArray.getInt
- - ( - int - ,
int - ) -
Returns the int value of the JsonNumber at the specified position. If the value at that position is a JsonNumber, this method returns javax.json.JsonNumber#intValue(). Otherwise this method returns the specified default value.true -
-
true
JSONP:JAVADOC:435Stringjavax.json.JsonArray.getString
- - ( - int - ,
String - ) -
Returns the String value of JsonString at the specified position in this JSON array values. If JsonString is found, its javax.json.JsonString#getString() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:436booleanjavax.json.JsonObject.getBoolean
- - ( - String - ) -
Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false.true -
-
true
JSONP:JAVADOC:439booleanjavax.json.JsonObject.getBoolean
- - ( - String - ,
boolean - ) -
Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:441intjavax.json.JsonObject.getInt
- - ( - String - ,
int - ) -
Returns the int value of the associated JsonNumber mapping for the specified name. If JsonNumber is found, then its javax.json.JsonNumber#intValue() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:443Stringjavax.json.JsonObject.getString
- - ( - String - ,
String - ) -
Returns the string value of the associated JsonString mapping for the specified name. If JsonString is found, then its javax.json.JsonString#getString() is returned. Otherwise, the specified default value is returned.true -
-
true
JSONP:JAVADOC:445JsonBuilderFactoryjavax.json.Json.createBuilderFactory
- - ( - Map - ) -
Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:449JsonReaderFactoryjavax.json.Json.createReaderFactory
- - ( - Map - ) -
Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:452JsonWriterFactoryjavax.json.Json.createWriterFactory
- - ( - Map - ) -
Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:453JsonArrayBuilderjavax.json.JsonBuilderFactory.createArrayBuilder
-
Creates a JsonArrayBuilder instance that is used to build JsonArraytrue -
-
true
JSONP:JAVADOC:454JsonObjectBuilderjavax.json.JsonBuilderFactory.createObjectBuilder
-
Creates a JsonObjectBuilder instance that is used to build JsonObject.true -
-
true
JSONP:JAVADOC:455Mapjavax.json.JsonBuilderFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON builders. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:459Mapjavax.json.JsonReaderFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON readers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:463Mapjavax.json.JsonWriterFactory.getConfigInUse
-
Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON writer objects. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map.true -
-
true
JSONP:JAVADOC:464JsonArrayBuilderjavax.json.spi.JsonProvider.createArrayBuilder
-
Creates a JSON array builder.true -
-
true
JSONP:JAVADOC:465JsonBuilderFactoryjavax.json.spi.JsonProvider.createBuilderFactory
- - ( - Map - ) -
Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:466JsonObjectBuilderjavax.json.spi.JsonProvider.createObjectBuilder
-
Creates a JSON object builder.true -
-
true
JSONP:JAVADOC:467JsonReaderjavax.json.spi.JsonProvider.createReader
- - ( - Reader - ) -
Creates a JSON reader from a character stream.true -
-
true
JSONP:JAVADOC:468JsonReaderjavax.json.spi.JsonProvider.createReader
- - ( - InputStream - ) -
Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159.true -
-
true
JSONP:JAVADOC:469JsonReaderFactoryjavax.json.spi.JsonProvider.createReaderFactory
- - ( - Map - ) -
Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:470JsonWriterjavax.json.spi.JsonProvider.createWriter
- - ( - Writer - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream.true -
-
true
JSONP:JAVADOC:471JsonWriterjavax.json.spi.JsonProvider.createWriter
- - ( - OutputStream - ) -
Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding.true -
-
true
JSONP:JAVADOC:472JsonWriterFactoryjavax.json.spi.JsonProvider.createWriterFactory
- - ( - Map - ) -
Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map.true -
-
true
JSONP:JAVADOC:474longjavax.json.stream.JsonLocation.getColumnNumber
-
Return the column number (starts with 1 for the first column) for the current JSON event in the input source.true -
-
true
JSONP:JAVADOC:475longjavax.json.stream.JsonLocation.getLineNumber
-
Return the line number (starts with 1 for the first line) for the current JSON event in the input source.true -
-
true
JSONP:JAVADOC:476longjavax.json.stream.JsonLocation.getStreamOffset
-
Return the stream offset into the input source this location is pointing to. If the input source is a file or a byte stream then this is the byte offset into that stream, but if the input source is a character media then the offset is the character offset. Returns -1 if there is no offset available.true -
-
true
JSONP:JAVADOC:477JsonLocationjavax.json.stream.JsonParser.getLocation
-
Return the location that corresponds to the parser's current state in the JSON input source. The location information is only valid in the current parser state (or until the parser is advanced to a next state).true -
-
true
JSONP:JAVADOC:478JsonLocationjavax.json.stream.JsonParsingException.getLocation
-
Return the location of the incorrect JSON.true -
-
true
JSONP:JAVADOC:481Listjavax.json.JsonArray.getValuesAs
- - ( - Class - ) -
Returns a list view of the specified type for the array. This method does not verify if there is a value of wrong type in the array. Providing this typesafe view dynamically may cause a program fail with a ClassCastException, if there is a value of wrong type in this array. Unfortunately, the exception can occur at any time after this method returns.true -
-
true
JSONP:JAVADOC:490JsonArrayjavax.json.JsonArray.getJsonArray
- - ( - int - ) -
Returns the array value at the specified position in this array. This is a convenience method for (JsonArray)get(index).true -
-
true
JSONP:JAVADOC:493JsonNumberjavax.json.JsonArray.getJsonNumber
- - ( - int - ) -
Returns the number value at the specified position in this array. This is a convenience method for (JsonNumber)get(index).true -
-
true
JSONP:JAVADOC:496JsonObjectjavax.json.JsonArray.getJsonObject
- - ( - int - ) -
Returns the object value at the specified position in this array. This is a convenience method for (JsonObject)get(index).true -
-
true
JSONP:JAVADOC:499JsonStringjavax.json.JsonArray.getJsonString
- - ( - int - ) -
Returns the string value at ths specified position in this array. This is a convenience method for (JsonString)get(index).true -
-
true
JSONP:JAVADOC:506booleanjavax.json.JsonArray.isNull
- - ( - int - ) -
Returns true if the value at the specified location in this array is JsonValue.NULL.true -
-
true
JSONP:JAVADOC:527JsonArrayjavax.json.JsonObject.getJsonArray
- - ( - String - ) -
Returns the array value to which the specified name is mapped. This is a convenience method for (JsonArray)get(name) to get the value.true -
-
true
JSONP:JAVADOC:529JsonNumberjavax.json.JsonObject.getJsonNumber
- - ( - String - ) -
Returns the number value to which the specified name is mapped. This is a convenience method for (JsonNumber)get(name) to get the value.true -
-
true
JSONP:JAVADOC:531JsonObjectjavax.json.JsonObject.getJsonObject
- - ( - String - ) -
Returns the object value to which the specified name is mapped. This is a convenience method for (JsonObject)get(name) to get the value.true -
-
true
JSONP:JAVADOC:533JsonStringjavax.json.JsonObject.getJsonString
- - ( - String - ) -
Returns the string value to which the specified name is mapped. This is a convenience method for (JsonString)get(name) to get the value.true -
-
true
JSONP:JAVADOC:539booleanjavax.json.JsonObject.isNull
- - ( - String - ) -
Returns true if the associated value for the specified name is JsonValue.NULL.true -
-
true
JSONP:JAVADOC:572JsonArrayBuilderjavax.json.Json.createArrayBuilder
- - ( - JsonArray - ) -
Creates a JSON array builder, initialized with the specified arraytrue -
-
true
JSONP:JAVADOC:573JsonArrayBuilderjavax.json.Json.createArrayBuilder
- - ( - Collection - ) -
Creates a JSON array builder, initialized with the content of specified collection.true -
-
true
JSONP:JAVADOC:574JsonPatchjavax.json.Json.createDiff
- - ( - JsonStructure - ,
JsonStructure - ) -
Generates a JSON Patch (RFC 6902) from the source and target JsonStructure. The generated JSON Patch need not be unique.true -
-
true
JSONP:JAVADOC:575JsonMergePatchjavax.json.Json.createMergeDiff
- - ( - JsonValue - ,
JsonValue - ) -
Generates a JSON Merge Patch (RFC 7396) from the source and target JsonValues which when applied to the source, yields the target.true -
-
true
JSONP:JAVADOC:576JsonMergePatchjavax.json.Json.createMergePatch
- - ( - JsonValue - ) -
Creates JSON Merge Patch (RFC 7396) from specified JsonValue.true -
-
true
JSONP:JAVADOC:577JsonObjectBuilderjavax.json.Json.createObjectBuilder
- - ( - JsonObject - ) -
Creates a JSON object builder, initialized with the specified object.true -
-
true
JSONP:JAVADOC:578JsonObjectBuilderjavax.json.Json.createObjectBuilder
- - ( - Map - ) -
Creates a JSON object builder, initialized with the specified object.true -
-
true
JSONP:JAVADOC:579JsonPatchjavax.json.Json.createPatch
- - ( - JsonArray - ) -
Creates a JSON Patch (RFC 6902) from the specified operations.true -
-
true
JSONP:JAVADOC:580JsonPatchBuilderjavax.json.Json.createPatchBuilder
-
Creates a JSON Patch builder (RFC 6902).true -
-
true
JSONP:JAVADOC:581JsonPatchBuilderjavax.json.Json.createPatchBuilder
- - ( - JsonArray - ) -
Creates a JSON Patch builder (RFC 6902), initialized with the specified operations.true -
-
true
JSONP:JAVADOC:582JsonPointerjavax.json.Json.createPointer
- - ( - String - ) -
Creates JSON Pointer (RFC 6901) from given jsonPointer string. An empty jsonPointer string defines a reference to the target itself. If the jsonPointer string is non-empty, it must be a sequence of '/' prefixed tokens.true -
-
true
JSONP:JAVADOC:583JsonStringjavax.json.Json.createValue
- - ( - String - ) -
Creates a JsonString.true -
-
true
JSONP:JAVADOC:584JsonNumberjavax.json.Json.createValue
- - ( - int - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:585JsonNumberjavax.json.Json.createValue
- - ( - long - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:586JsonNumberjavax.json.Json.createValue
- - ( - double - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:587JsonNumberjavax.json.Json.createValue
- - ( - BigDecimal - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:588JsonNumberjavax.json.Json.createValue
- - ( - BigInteger - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:589Listjavax.json.JsonArray.getValuesAs
- - ( - Function - ) -
Returns a list view for the array. The value and the type of the elements in the list is specified by the func argument. This method can be used to obtain a list of the unwrapped types, such as List strings = ary1.getValuesAs(JsonString::getString); List ints = ary2.getValuesAs(JsonNumber::intValue); or a list of simple projections, such as List stringsizes = ary1.getValueAs((JsonString v)->v.getString().length();true -
-
true
JSONP:JAVADOC:590JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
JsonValue - ) -
Inserts a value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:591JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
String - ) -
Adds a value to the array as a JsonString at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:592JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
BigDecimal - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:593JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
BigInteger - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:594JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
int - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:595JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
long - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:596JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
double - ) -
Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:597JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
boolean - ) -
Adds a JsonValue#TRUE or JsonValue#FALSE value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:598JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
JsonObjectBuilder - ) -
Adds a JsonObject from an object builder to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:599JsonArrayBuilderjavax.json.JsonArrayBuilder.add
- - ( - int - ,
JsonArrayBuilder - ) -
Adds a JsonArray from an array builder to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:600JsonArrayBuilderjavax.json.JsonArrayBuilder.addAll
- - ( - JsonArrayBuilder - ) -
Adds all elements of the array in the specified array builder to the array.true -
-
true
JSONP:JAVADOC:601JsonArrayBuilderjavax.json.JsonArrayBuilder.addNull
- - ( - int - ) -
Adds a JsonValue#NULL value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0.true -
-
true
JSONP:JAVADOC:602JsonArrayBuilderjavax.json.JsonArrayBuilder.remove
- - ( - int - ) -
Remove the value in the array at the specified position. Shift any subsequent values to the left (subtracts one from their indices.true -
-
true
JSONP:JAVADOC:603JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
JsonValue - ) -
Replaces a value in the array with the specified value at the specified position.true -
-
true
JSONP:JAVADOC:604JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
String - ) -
Replaces a value in the array with the specified value as a JsonString at the specified position.true -
-
true
JSONP:JAVADOC:605JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
BigDecimal - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:606JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
BigInteger - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:607JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
int - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:608JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
long - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:609JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
double - ) -
Replaces a value in the array with the specified value as a JsonNumber at the specified position.true -
-
true
JSONP:JAVADOC:610JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
boolean - ) -
Replaces a value in the array with a JsonValue#TRUE or JsonValue#FALSE value at the specified position.true -
-
true
JSONP:JAVADOC:611JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
JsonObjectBuilder - ) -
Replaces a value in the array with the specified value as a JsonObject from an object builder at the specified position.true -
-
true
JSONP:JAVADOC:612JsonArrayBuilderjavax.json.JsonArrayBuilder.set
- - ( - int - ,
JsonArrayBuilder - ) -
Replaces a value in the array with the specified value as a JsonArray from an array builder at the specified position.true -
-
true
JSONP:JAVADOC:613JsonArrayBuilderjavax.json.JsonArrayBuilder.setNull
- - ( - int - ) -
Replaces a value in the array with a JsonValue#NULL value at the specified position.true -
-
true
JSONP:JAVADOC:614JsonArrayBuilderjavax.json.JsonBuilderFactory.createArrayBuilder
- - ( - JsonArray - ) -
Creates a JsonArrayBuilder instance, initialized with an array.true -
-
true
JSONP:JAVADOC:615JsonObjectBuilderjavax.json.JsonBuilderFactory.createObjectBuilder
- - ( - JsonObject - ) -
Creates a JsonObjectBuilder instance, initialized with an object.true -
-
true
JSONP:JAVADOC:616JsonValuejavax.json.JsonMergePatch.apply
- - ( - JsonValue - ) -
Applies the JSON Merge Patch to the specified target. The target is not modified by the patch.true -
-
true
JSONP:JAVADOC:617JsonValuejavax.json.JsonMergePatch.toJsonValue
-
Returns the JsonMergePatch as JsonValue.true -
-
true
JSONP:JAVADOC:618JsonObjectBuilderjavax.json.JsonObjectBuilder.addAll
- - ( - JsonObjectBuilder - ) -
Adds all name/value pairs in the JSON object associated with the specified object builder to the JSON object associated with this object builder. The newly added name/value pair will replace any existing name/value pair with the same name.true -
-
true
JSONP:JAVADOC:619JsonObjectBuilderjavax.json.JsonObjectBuilder.remove
- - ( - String - ) -
Remove the name/value pair from the JSON object associated with this object builder if it is present.true -
-
true
JSONP:JAVADOC:620JsonStructurejavax.json.JsonPatch.apply
- - ( - JsonStructure - ) -
Applies the patch operations to the specified target. The target is not modified by the patch.true -
-
true
JSONP:JAVADOC:621JsonArrayjavax.json.JsonPatch.toJsonArray
-
Returns the JsonPatch as JsonArray.true -
-
true
JSONP:JAVADOC:622Operationjavax.json.JsonPatch.Operation.fromOperationName
- - ( - String - ) -
Returns the enum constant with the specified name.true -
-
true
JSONP:JAVADOC:623Stringjavax.json.JsonPatch.Operation.operationName
-
Returns enum constant name as lower case string.true -
-
true
JSONP:JAVADOC:624Operationjavax.json.JsonPatch.Operation.valueOf
- - ( - String - ) -
-
-
true -
-
true
JSONP:JAVADOC:625Operation[]javax.json.JsonPatch.Operation.values
-
-
-
true -
-
true
JSONP:JAVADOC:626JsonPatchBuilderjavax.json.JsonPatchBuilder.add
- - ( - String - ,
JsonValue - ) -
Adds an "add" JSON Patch operation.true -
-
true
JSONP:JAVADOC:627JsonPatchBuilderjavax.json.JsonPatchBuilder.add
- - ( - String - ,
String - ) -
Adds an "add" JSON Patch operation.true -
-
true
JSONP:JAVADOC:628JsonPatchBuilderjavax.json.JsonPatchBuilder.add
- - ( - String - ,
int - ) -
Adds an "add" JSON Patch operation.true -
-
true
JSONP:JAVADOC:629JsonPatchBuilderjavax.json.JsonPatchBuilder.add
- - ( - String - ,
boolean - ) -
Adds an "add" JSON Patch operation.true -
-
true
JSONP:JAVADOC:630JsonPatchjavax.json.JsonPatchBuilder.build
-
Returns the JSON Patch.true -
-
true
JSONP:JAVADOC:631JsonPatchBuilderjavax.json.JsonPatchBuilder.copy
- - ( - String - ,
String - ) -
Adds a "copy" JSON Patch operation.true -
-
true
JSONP:JAVADOC:632JsonPatchBuilderjavax.json.JsonPatchBuilder.move
- - ( - String - ,
String - ) -
Adds a "move" JSON Patch operation.true -
-
true
JSONP:JAVADOC:633JsonPatchBuilderjavax.json.JsonPatchBuilder.remove
- - ( - String - ) -
Adds a "remove" JSON Patch operation.true -
-
true
JSONP:JAVADOC:634JsonPatchBuilderjavax.json.JsonPatchBuilder.replace
- - ( - String - ,
JsonValue - ) -
Adds a "replace" JSON Patch operation.true -
-
true
JSONP:JAVADOC:635JsonPatchBuilderjavax.json.JsonPatchBuilder.replace
- - ( - String - ,
String - ) -
Adds a "replace" JSON Patch operation.true -
-
true
JSONP:JAVADOC:636JsonPatchBuilderjavax.json.JsonPatchBuilder.replace
- - ( - String - ,
int - ) -
Adds a "replace" JSON Patch operation.true -
-
true
JSONP:JAVADOC:637JsonPatchBuilderjavax.json.JsonPatchBuilder.replace
- - ( - String - ,
boolean - ) -
Adds a "replace" JSON Patch operation.true -
-
true
JSONP:JAVADOC:638JsonPatchBuilderjavax.json.JsonPatchBuilder.test
- - ( - String - ,
JsonValue - ) -
Adds a "test" JSON Patch operation.true -
-
true
JSONP:JAVADOC:639JsonPatchBuilderjavax.json.JsonPatchBuilder.test
- - ( - String - ,
String - ) -
Adds a "test" JSON Patch operation.true -
-
true
JSONP:JAVADOC:640JsonPatchBuilderjavax.json.JsonPatchBuilder.test
- - ( - String - ,
int - ) -
Adds a "test" JSON Patch operation.true -
-
true
JSONP:JAVADOC:641JsonPatchBuilderjavax.json.JsonPatchBuilder.test
- - ( - String - ,
boolean - ) -
Adds a "test" JSON Patch operation.true -
-
true
JSONP:JAVADOC:642JsonStructurejavax.json.JsonPointer.add
- - ( - JsonStructure - ,
JsonValue - ) -
Adds or replaces a value at the referenced location in the specified target with the specified value. If the reference is the target (empty JSON Pointer string), the specified value, which must be the same type as specified target, is returned. If the reference is an array element, the specified value is inserted into the array, at the referenced index. The value currently at that location, and any subsequent values, are shifted to the right (adds one to the indices). Index starts with 0. If the reference is specified with a "-", or if the index is equal to the size of the array, the value is appended to the array. If the reference is a name/value pair of a JsonObject, and the referenced value exists, the value is replaced by the specified value. If the value does not exist, a new name/value pair is added to the object.true -
-
true
JSONP:JAVADOC:643JsonValuejavax.json.JsonPointer.getValue
- - ( - JsonStructure - ) -
Returns the value at the referenced location in the specified target.true -
-
true
JSONP:JAVADOC:644JsonStructurejavax.json.JsonPointer.remove
- - ( - JsonStructure - ) -
Removes the value at the reference location in the specified target.true -
-
true
JSONP:JAVADOC:645JsonStructurejavax.json.JsonPointer.replace
- - ( - JsonStructure - ,
JsonValue - ) -
Replaces the value at the referenced location in the specified target with the specified value.true -
-
true
JSONP:JAVADOC:646JsonValuejavax.json.JsonReader.readValue
-
Returns a JSON value that is represented in the input source. This method needs to be called only once for a reader instance.true -
-
true
JSONP:JAVADOC:647JsonValuejavax.json.JsonStructure.getValue
- - ( - String - ) -
Get the value referenced by the provided JSON Pointer in the JsonStructure.true -
-
true
JSONP:JAVADOC:648JsonArrayjavax.json.JsonValue.asJsonArray
-
Return the JsonValue as a JsonArraytrue -
-
true
JSONP:JAVADOC:649JsonObjectjavax.json.JsonValue.asJsonObject
-
Return the JsonValue as a JsonObjecttrue -
-
true
JSONP:JAVADOC:650voidjavax.json.JsonWriter.write
- - ( - JsonValue - ) -
Writes the specified JsonValue to the output source. method needs to be called only once for a write instance.true -
-
true
JSONP:JAVADOC:651JsonArrayBuilderjavax.json.spi.JsonProvider.createArrayBuilder
- - ( - JsonArray - ) -
Creates a JSON array builder, initialized with the specified array.true -
-
true
JSONP:JAVADOC:652JsonArrayBuilderjavax.json.spi.JsonProvider.createArrayBuilder
- - ( - Collection - ) -
Creates a JSON array builder, initialized with the specified collection.true -
-
true
JSONP:JAVADOC:653JsonPatchjavax.json.spi.JsonProvider.createDiff
- - ( - JsonStructure - ,
JsonStructure - ) -
Generates a JSON Patch (RFC 6902) from the source and target JsonStructure. The generated JSON Patch need not be unique.true -
-
true
JSONP:JAVADOC:654JsonMergePatchjavax.json.spi.JsonProvider.createMergeDiff
- - ( - JsonValue - ,
JsonValue - ) -
Generates a JSON Merge Patch (RFC 7396) from the source and target JsonValues which when applied to the source, yields the target.true -
-
true
JSONP:JAVADOC:655JsonMergePatchjavax.json.spi.JsonProvider.createMergePatch
- - ( - JsonValue - ) -
Creates JSON Merge Patch (RFC 7396) from specified JsonValue.true -
-
true
JSONP:JAVADOC:656JsonObjectBuilderjavax.json.spi.JsonProvider.createObjectBuilder
- - ( - JsonObject - ) -
Creates a JSON object builder, initialized with the specified object.true -
-
true
JSONP:JAVADOC:657JsonObjectBuilderjavax.json.spi.JsonProvider.createObjectBuilder
- - ( - Map - ) -
Creates a JSON object builder, initialized with the specified Map.true -
-
true
JSONP:JAVADOC:658JsonPatchjavax.json.spi.JsonProvider.createPatch
- - ( - JsonArray - ) -
Creates a JSON Patch (RFC 6902) from the specified operations.true -
-
true
JSONP:JAVADOC:659JsonPatchBuilderjavax.json.spi.JsonProvider.createPatchBuilder
-
Creates a JSON Patch builder (RFC 6902).true -
-
true
JSONP:JAVADOC:660JsonPatchBuilderjavax.json.spi.JsonProvider.createPatchBuilder
- - ( - JsonArray - ) -
Creates a JSON Patch builder (RFC 6902), initialized with the specified operations.true -
-
true
JSONP:JAVADOC:661JsonPointerjavax.json.spi.JsonProvider.createPointer
- - ( - String - ) -
Creates JSON Pointer (RFC 6901) from given jsonPointer string. An empty jsonPointer string defines a reference to the target itself. If the jsonPointer string is non-empty, it must be a sequence of '/' prefixed tokens.true -
-
true
JSONP:JAVADOC:662JsonStringjavax.json.spi.JsonProvider.createValue
- - ( - String - ) -
Creates a JsonString.true -
-
true
JSONP:JAVADOC:663JsonNumberjavax.json.spi.JsonProvider.createValue
- - ( - int - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:664JsonNumberjavax.json.spi.JsonProvider.createValue
- - ( - long - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:665JsonNumberjavax.json.spi.JsonProvider.createValue
- - ( - double - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:666JsonNumberjavax.json.spi.JsonProvider.createValue
- - ( - BigDecimal - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:667JsonNumberjavax.json.spi.JsonProvider.createValue
- - ( - BigInteger - ) -
Creates a JsonNumber.true -
-
true
JSONP:JAVADOC:668Collectorjavax.json.stream.JsonCollectors.groupingBy
- - ( - Function - ,
Collector - ) -
Constructs a java.util.stream.Collector that implements a "group by" operation on the input JsonValue elements. A classifier function maps the input JsonValues to keys, and the JsonValues are partitioned into groups according to the value of the key. A reduction operation is performed on the JsonValues in each group, using the downstream Collector. For each group, the key and the results of the reduction operation become the name/value pairs of the resultant JsonObject.true -
-
true
JSONP:JAVADOC:669Collectorjavax.json.stream.JsonCollectors.groupingBy
- - ( - Function - ) -
Constructs a java.util.stream.Collector that implements a "group by" operation on the input JsonValue elements. A classifier function maps the input JsonValues to keys, and the JsonValues are partitioned into groups according to the value of the key. The JsonValues in each group are added to a JsonArray. The key and the JsonArray in each group becomes the name/value pair of the resultant JsonObject.true -
-
true
JSONP:JAVADOC:670Collectorjavax.json.stream.JsonCollectors.toJsonArray
-
Constructs a java.util.stream.Collector that accumulates the input JsonValue elements into a JsonArray.true -
-
true
JSONP:JAVADOC:671Collectorjavax.json.stream.JsonCollectors.toJsonObject
- - ( - Function - ,
Function - ) -
Constructs a java.util.stream.Collector that accumulates the input JsonValue elements into a JsonObject. The name/value pairs of the JsonObject are computed by applying the provided mapping functions.true -
-
true
JSONP:JAVADOC:672JsonGeneratorjavax.json.stream.JsonGenerator.writeKey
- - ( - String - ) -
Writes the JSON name with a colon. It starts a field context, in which valid options are writing a value, starting an object or an array. Writing value closes field context, if object or array is started after field name, field context will be closed after object/array close.true -
-
true
JSONP:JAVADOC:673JsonArrayjavax.json.stream.JsonParser.getArray
-
Returns a JsonArray and advance the parser to the the corresponding END_ARRAY.true -
-
true
JSONP:JAVADOC:674Streamjavax.json.stream.JsonParser.getArrayStream
-
Returns a stream of the JsonArray elements. The parser state must be START_ARRAY. The elements are read lazily, on an as-needed basis, as required by the stream operations. If the stream operations do not consume all of the array elements, #skipArray() can be used to skip the unprocessed array elements.true -
-
true
JSONP:JAVADOC:675JsonObjectjavax.json.stream.JsonParser.getObject
-
Returns a JsonObject and advances the parser to the corresponding END_OBJECT.true -
-
true
JSONP:JAVADOC:676Streamjavax.json.stream.JsonParser.getObjectStream
-
Returns a stream of the JsonObject's name/value pairs. The parser state must be START_OBJECT. The name/value pairs are read lazily, on an as-needed basis, as required by the stream operations. If the stream operations do not consume all of the object's name/value pairs, #skipObject() can be used to skip the unprocessed elements.true -
-
true
JSONP:JAVADOC:677JsonValuejavax.json.stream.JsonParser.getValue
-
Returns a JsonValue at the current parser position. If the parser state is START_ARRAY, the behavior is the same as #getArray. If the parser state is START_OBJECT, the behavior is the same as #getObject. For all other cases, if applicable, the JSON value is read and returned.true -
-
true
JSONP:JAVADOC:678Streamjavax.json.stream.JsonParser.getValueStream
-
Returns a stream of JsonValue from a sequence of JSON values. The values are read lazily, on an as-needed basis, as needed by the stream operations.true -
-
true
JSONP:JAVADOC:679voidjavax.json.stream.JsonParser.skipArray
-
Advance the parser to END_ARRAY. If the parser is in array context, i.e. it has previously encountered a START_ARRAY without encountering the corresponding END_ARRAY, the parser is advanced to the corresponding END_ARRAY. If the parser is not in any array context, nothing happens.true -
-
true
JSONP:JAVADOC:680voidjavax.json.stream.JsonParser.skipObject
-
Advance the parser to END_OBJECT. If the parser is in object context, i.e. it has previously encountered a START_OBJECT without encountering the corresponding END_OBJECT, the parser is advanced to the corresponding END_OBJECT. If the parser is not in any object context, nothing happens.true -
-
true
JSONP:JAVADOC:681Stringjavax.json.Json.decodePointer
- - ( - String - ) -
Decodes a passed JSON-pointer string as defined by RFC 6901. This method doesn't validate the passed JSON-pointer string.true -
-
true
JSONP:JAVADOC:682Stringjavax.json.Json.encodePointer
- - ( - String - ) -
Encodes (escapes) a passed string as defined by RFC 6901. This method doesn't validate the passed JSON-pointer string.true -
-
true
JSONP:JAVADOC:683JsonArrayBuilderjavax.json.JsonBuilderFactory.createArrayBuilder
- - ( - Collection - ) -
Creates a JsonArrayBuilder instance, initialized with the content of specified collection.true -
-
true
JSONP:JAVADOC:684JsonObjectBuilderjavax.json.JsonBuilderFactory.createObjectBuilder
- - ( - Map - ) -
Creates a JsonObjectBuilder instance, initialized with the specified object.true -
-
true
JSONP:JAVADOC:685Numberjavax.json.JsonNumber.numberValue
-
Returns this JSON number as a Number object.true -
-
true
JSONP:JAVADOC:686booleanjavax.json.JsonPointer.containsValue
- - ( - JsonStructure - ) -
Returns true if there is a value at the referenced location in the specified target.true -
-
true
JSONP:JAVADOC:687Collectorjavax.json.stream.JsonCollectors.toJsonObject
-
Constructs a java.util.stream.Collector that accumulates the input Map.Entry elements into a JsonObject.true -
-
true
- - diff --git a/internal/docs/jsonp/JSONP1.1JavadocAssertions.xml b/internal/docs/jsonp/JSONP1.1JavadocAssertions.xml deleted file mode 100644 index a816070281..0000000000 --- a/internal/docs/jsonp/JSONP1.1JavadocAssertions.xml +++ /dev/null @@ -1,4465 +0,0 @@ - - - - - - 688 - 681 - JSONP - JSON-P - Java API for JSON Processing - 1.1 - - - - - - - 6 - Adds a value to the array. - javax.json - JsonArrayBuilder - - - javax.json.JsonValue - - - - - 8 - Adds a value to the array as a JsonString. - javax.json - JsonArrayBuilder - - - java.lang.String - - - - - 10 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - java.math.BigDecimal - - - - - 12 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - java.math.BigInteger - - - - - 14 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - int - - - - - 16 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - long - - - - - 18 - Adds a value to the array as a JsonNumber. - javax.json - JsonArrayBuilder - - - double - - - - - 21 - Adds a JsonValue#TRUE or JsonValue#FALSE value to the array. - javax.json - JsonArrayBuilder - - - boolean - - - - - 25 - Adds a JsonValue#NULL value to the array. - javax.json - JsonArrayBuilder - - - - 37 - 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. - javax.json - JsonException - - - java.lang.String - - - - - 38 - 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. - javax.json - JsonException - - - java.lang.String - java.lang.Throwable - - - - - 40 - Returns this JSON number as a BigDecimal object. - javax.json - JsonNumber - - - - 41 - Returns this JSON number as a BigInteger object. This is a a convenience method for bigDecimalValue().toBigInteger(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. - javax.json - JsonNumber - - - - 42 - Returns this JSON number as a BigInteger object. This is a convenience method for bigDecimalValue().toBigIntegerExact(). - javax.json - JsonNumber - - - - 44 - Returns this JSON number as a double. This is a a convenience method for bigDecimalValue().doubleValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. - javax.json - JsonNumber - - - - 45 - Returns this JSON number as an int. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. - javax.json - JsonNumber - - - - 46 - Returns this JSON number as an int. - javax.json - JsonNumber - - - - 48 - Returns this JSON number as a long. Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. - javax.json - JsonNumber - - - - 49 - Returns this JSON number as a long. - javax.json - JsonNumber - - - - 51 - Returns true if this JSON number is a integral number. This method semantics are defined using bigDecimalValue().scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonNumber num = ... if (num.isIntegral()) { num.longValue(); // or other methods to get integral value } else { num.doubleValue(); // or other methods to get decimal number value } - javax.json - JsonNumber - - - - 58 - Adds a name/JsonValue pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonValue - - - - - 61 - Adds a name/JsonString pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - java.lang.String - - - - - 64 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - java.math.BigInteger - - - - - 67 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - java.math.BigDecimal - - - - - 70 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - int - - - - - 73 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - long - - - - - 76 - Adds a name/JsonNumber pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - double - - - - - 80 - Adds a name/JsonValue#TRUE or name/JsonValue#FALSE pair to the JSON object associated with this object builder. If the object contains a mapping for the specified name, this method replaces the old value with the specified value. - javax.json - JsonObjectBuilder - - - java.lang.String - boolean - - - - - 86 - Adds a name/JsonValue#NULL pair to the JSON object associated with this object builder where the value is null. If the object contains a mapping for the specified name, this method replaces the old value with null. - javax.json - JsonObjectBuilder - - - java.lang.String - - - - - 96 - Closes this reader and frees any resources associated with the reader. This method closes the underlying input source. - javax.json - JsonReader - - - - 97 - Creates a JSON reader from a character stream. - javax.json - Json - - - java.io.Reader - - - - - 101 - Returns the JSON string value. - javax.json - JsonString - - - - 102 - Returns the value type of this JSON value. - javax.json - JsonValue - - - - 103 - - javax.json - JsonValue.ValueType - - - java.lang.String - - - - - 104 - - javax.json - JsonValue.ValueType - - - - 105 - - javax.json - JsonWriter - - - - 106 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. - javax.json - Json - - - java.io.Writer - - - - - 107 - Writes the specified JSON JsonArray array to the output source. This method needs to be called only once for a writer instance. - javax.json - JsonWriter - - - javax.json.JsonArray - - - - - 110 - Writes the specified JSON JsonObject object to the output source. This method needs to be called only once for a writer instance. - javax.json - JsonWriter - - - javax.json.JsonObject - - - - - 115 - Closes this generator and frees any resources associated with it. This method closes the underlying output source. - javax.json.stream - JsonGenerator - - - - 117 - Closes this parser and frees any resources associated with the parser. This method closes the underlying input source. - javax.json.stream - JsonParser - - - - 120 - Returns true if the JSON number at the current parser state is a integral number. A BigDecimal may be used to store the value internally and this method semantics are defined using its scale(). If the scale is zero, then it is considered integral type. This integral type information can be used to invoke an appropriate accessor method to obtain a numeric value as in the following example: JsonParser parser = ... if (parser.isIntegralNumber()) { parser.getInt(); // or other methods to get integral value } else { parser.getBigDecimal(); } - javax.json.stream - JsonParser - - - - 122 - Returns a String for the name in a name/value pair, for a string value or a number value. This method should only be called when the parser state is Event#KEY_NAME, Event#VALUE_STRING, or Event#VALUE_NUMBER. - javax.json.stream - JsonParser - - - - 128 - - javax.json.stream - JsonParser.Event - - - java.lang.String - - - - - 129 - - javax.json.stream - JsonParser.Event - - - - 131 - Creates a JSON generator for writing JSON to a character stream. - javax.json - Json - - - java.io.Writer - - - - - 133 - Creates a JSON parser from a character stream. - javax.json - Json - - - java.io.Reader - - - - - 144 - Creates a JSON generator for writing JSON text to a character stream. - javax.json.spi - JsonProvider - - - java.io.Writer - - - - - 146 - Creates a JSON parser from a character stream. - javax.json.spi - JsonProvider - - - java.io.Reader - - - - - 152 - Creates a JSON provider object. The provider is loaded using the ServiceLoader#load(Class) method. If there are no available service providers, this method returns the default service provider. Users are recommended to cache the result of this method. - javax.json.spi - JsonProvider - - - - 162 - Creates a JSON generator to write JSON text to a character stream. The generator is configured with the factory configuration. - javax.json.stream - JsonGeneratorFactory - - - java.io.Writer - - - - - 163 - Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using the specified charset. The generator is configured with the factory's configuration. - javax.json.stream - JsonGeneratorFactory - - - java.io.OutputStream - java.nio.charset.Charset - - - - - 164 - Creates a JSON parser from a character stream. - javax.json.stream - JsonParserFactory - - - java.io.Reader - - - - - 165 - Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as specified in RFC 7159. - javax.json.stream - JsonParserFactory - - - java.io.InputStream - - - - - 166 - Creates a JSON parser from the specified JSON object. - javax.json.stream - JsonParserFactory - - - javax.json.JsonObject - - - - - 167 - Creates a JSON parser from the specified JSON array. - javax.json.stream - JsonParserFactory - - - javax.json.JsonArray - - - - - 168 - Creates a JSON generator for writing JSON to a byte stream. - javax.json - Json - - - java.io.OutputStream - - - - - 172 - Creates a JSON parser from a byte stream. The character encoding of the stream is determined as specified in RFC 7159. - javax.json - Json - - - java.io.InputStream - - - - - 178 - Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159. - javax.json - Json - - - java.io.InputStream - - - - - 181 - Returns a JSON array or object that is represented in the input source. This method needs to be called only once for a reader instance. - javax.json - JsonReader - - - - 184 - Returns a JSON array that is represented in the input source. This method needs to be called only once for a reader instance. - javax.json - JsonReader - - - - 185 - Returns a JSON object that is represented in the input source. This method needs to be called only once for a reader instance. - javax.json - JsonReader - - - - 187 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. - javax.json - Json - - - java.io.OutputStream - - - - - 191 - Writes the specified JSON JsonObject object or JsonArray array to the output source. This method needs to be called only once for a writer instance. - javax.json - JsonWriter - - - javax.json.JsonStructure - - - - - 192 - Creates a JSON generator for writing JSON text to a byte stream. - javax.json.spi - JsonProvider - - - java.io.OutputStream - - - - - 196 - Creates a JSON parser from the specified byte stream. The character encoding of the stream is determined as defined in RFC 7159 . - javax.json.spi - JsonProvider - - - java.io.InputStream - - - - - 200 - Creates a JSON generator to write JSON text to a byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The generator is configured with the factory's configuration. - javax.json.stream - JsonGeneratorFactory - - - java.io.OutputStream - - - - - 201 - Creates a JSON parser from the specified byte stream. The bytes of the stream are decoded to characters using the specified charset. - javax.json.stream - JsonParserFactory - - - java.io.InputStream - java.nio.charset.Charset - - - - - 215 - Returns a JSON text representation of the JSON number. The representation is equivalent to BigDecimal#toString(). - javax.json - JsonNumber - - - - 235 - Returns a JSON number as a BigDecimal. The BigDecimal is created using new BigDecimal(getString()). This method should only called when the parser state is Event#VALUE_NUMBER. - javax.json.stream - JsonParser - - - - 237 - Returns a JSON number as an integer. The returned value is equal to new BigDecimal(getString()).intValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method should only be called when the parser state is Event#VALUE_NUMBER. - javax.json.stream - JsonParser - - - - 239 - Returns a JSON number as a long. The returned value is equal to new BigDecimal(getString()).longValue(). Note that this conversion can lose information about the overall magnitude and precision of the number value as well as return a result with the opposite sign. This method is only called when the parser state is Event#VALUE_NUMBER. - javax.json.stream - JsonParser - - - - 250 - Compares the specified object with this JsonNumber object for equality. Returns true if and only if the type of the specified object is also JsonNumber and their #bigDecimalValue() objects are equal - javax.json - JsonNumber - - - java.lang.Object - - - - - 251 - Returns the hash code value for this JsonNumber object. The hash code of a JsonNumber object is defined as the hash code of its #bigDecimalValue() object. - javax.json - JsonNumber - - - - 254 - Compares the specified object with this JsonString for equality. Returns true if and only if the specified object is also a JsonString, and their #getString() objects are equal. - javax.json - JsonString - - - java.lang.Object - - - - - 255 - Returns the hash code value for this JsonString object. The hash code of a JsonString object is defined to be its #getString() object's hash code. - javax.json - JsonString - - - - 262 - A convenience method for getJsonNumber(index).intValue(). - javax.json - JsonArray - - - int - - - - - 263 - A convenience method for getJsonString(index).getString(). - javax.json - JsonArray - - - int - - - - - 264 - A convenience method for getJsonNumber(name).intValue() - javax.json - JsonObject - - - java.lang.String - - - - - 265 - A convenience method for getJsonString(name).getString() - javax.json - JsonObject - - - java.lang.String - - - - - 278 - 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. - javax.json.stream - JsonGenerationException - - - java.lang.String - - - - - 279 - 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. - javax.json.stream - JsonGenerationException - - - java.lang.String - java.lang.Throwable - - - - - 285 - 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. - javax.json.stream - JsonParsingException - - - java.lang.String - javax.json.stream.JsonLocation - - - - - 286 - 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. - javax.json.stream - JsonParsingException - - - java.lang.String - java.lang.Throwable - javax.json.stream.JsonLocation - - - - - 288 - Returns JSON text for this JSON value. - javax.json - JsonValue - - - - 289 - Writes the end of the current context. If the current context is an array context, this method writes the end-of-array character (']'). If the current context is an object context, this method writes the end-of-object character ('}'). After writing the end of the current context, the parent context becomes the new current context. If parent context is field context, it is closed. - javax.json.stream - JsonGenerator - - - - 291 - Flushes the underlying output source. If the generator has saved any characters in a buffer, writes them immediately to the underlying output source before flushing it. - javax.json.stream - JsonGenerator - - - - 292 - Writes a JSON name/value pair in the current object context. - javax.json.stream - JsonGenerator - - - java.lang.String - javax.json.JsonValue - - - - - 295 - Writes a JSON name/string value pair in the current object context. The specified value is written as JSON string value. - javax.json.stream - JsonGenerator - - - java.lang.String - java.lang.String - - - - - 298 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigInteger - - - - - 301 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The specified value's toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigDecimal - - - - - 304 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - int - - - - - 307 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - long - - - - - 310 - Writes a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The string BigDecimal.valueOf(double).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.lang.String - double - - - - - 314 - Writes a JSON name/boolean value pair in the current object context. If value is true, it writes the JSON true value, otherwise it writes the JSON false value. - javax.json.stream - JsonGenerator - - - java.lang.String - boolean - - - - - 317 - Writes the specified value as a JSON value within the current array, field or root context. - javax.json.stream - JsonGenerator - - - javax.json.JsonValue - - - - - 319 - Writes the specified value as a JSON string value within the current array, field or root context. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - 321 - Writes the specified value as a JSON number value within the current array, field or root context. The specified value's toString() is used as the the text value for writing. - javax.json.stream - JsonGenerator - - - java.math.BigDecimal - - - - - 323 - Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - java.math.BigInteger - - - - - 325 - Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - int - - - - - 327 - Writes the specified value as a JSON number value within the current array, field or root context. The string new BigDecimal(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - long - - - - - 329 - Writes the specified value as a JSON number value within the current array, field or root context. The string BigDecimal.valueOf(value).toString() is used as the text value for writing. - javax.json.stream - JsonGenerator - - - double - - - - - 332 - Writes a JSON true or false value within the current array, field or root context. If value is true, this method writes the JSON true value, otherwise it writes the JSON false value. - javax.json.stream - JsonGenerator - - - boolean - - - - - 334 - Writes a JSON name/null value pair in an current object context. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - 337 - Writes a JSON null value within the current array, field or root context. - javax.json.stream - JsonGenerator - - - - 339 - Writes the JSON start array character. It starts a new child array context within which JSON values can be written to the array. This method is valid only in an array context, field context or in no context (when a context is not yet started). This method can only be called once in no context. - javax.json.stream - JsonGenerator - - - - 340 - Writes the JSON name/start array character pair with in the current object context. It starts a new child array context within which JSON values can be written to the array. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - 341 - Writes the JSON start object character. It starts a new child object context within which JSON name/value pairs can be written to the object. This method is valid only in an array context, field context or in no context (when a context is not yet started). This method can only be called once in no context. - javax.json.stream - JsonGenerator - - - - 342 - Writes the JSON name/start object character pair in the current object context. It starts a new child object context within which JSON name/value pairs can be written to the object. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - 375 - Returns true if there are more parsing states. This method returns false if the parser reaches the end of the JSON text. - javax.json.stream - JsonParser - - - - 376 - Returns the event for the next parsing state. - javax.json.stream - JsonParser - - - - 383 - Returns the char sequence for the JSON String value - javax.json - JsonString - - - - 400 - Adds a JsonObject from an object builder to the array. - javax.json - JsonArrayBuilder - - - javax.json.JsonObjectBuilder - - - - - 401 - Adds a JsonArray from an array builder to the array. - javax.json - JsonArrayBuilder - - - javax.json.JsonArrayBuilder - - - - - 402 - Returns the current array. - javax.json - JsonArrayBuilder - - - - 403 - Creates a JSON array builder - javax.json - Json - - - - 404 - Adds a name/JsonObject pair to the JSON object associated with this object builder. The value JsonObject is built from the specified object builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonObject from the specified object builder. - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonObjectBuilder - - - - - 406 - Adds a name/JsonArray pair to the JSON object associated with this object builder. The value JsonArray is built from the specified array builder. If the object contains a mapping for the specified name, this method replaces the old value with the JsonArray from the specified array builder. - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonArrayBuilder - - - - - 408 - Returns the JSON object associated with this object builder. The iteration order for the JsonObject is based on the order in which name/value pairs are added to the object using this builder. - javax.json - JsonObjectBuilder - - - - 409 - Creates a JSON object builder - javax.json - Json - - - - 416 - Creates a generator factory for creating JsonGenerator objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - 417 - Creates a parser factory for creating JsonParser objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - 419 - Creates a JSON reader from a character stream. The reader is configured with the factory configuration. - javax.json - JsonReaderFactory - - - java.io.Reader - - - - - 420 - Creates a JSON reader from a byte stream. The bytes of the stream are decoded to characters using the specified charset. The reader is configured with the factory configuration. - javax.json - JsonReaderFactory - - - java.io.InputStream - java.nio.charset.Charset - - - - - 422 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. The writer is configured with the factory configuration. - javax.json - JsonWriterFactory - - - java.io.Writer - - - - - 423 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. The writer is configured with the factory configuration. - javax.json - JsonWriterFactory - - - java.io.OutputStream - - - - - 424 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using the specified charset. The writer is configured with the factory configuration. - javax.json - JsonWriterFactory - - - java.io.OutputStream - java.nio.charset.Charset - - - - - 425 - Creates a generator factory for creating JsonGenerator instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - 426 - Creates a parser factory for creating JsonParser instances. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - 427 - Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON generators. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json.stream - JsonGeneratorFactory - - - - 428 - Returns a read-only map of supported provider specific configuration properties that are used to configure the JSON parsers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json.stream - JsonParserFactory - - - - 429 - Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159. The reader is configured with the factory configuration. - javax.json - JsonReaderFactory - - - java.io.InputStream - - - - - 430 - Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false. - javax.json - JsonArray - - - int - - - - - 433 - Returns the boolean value at the specified position. If the value at the specified position is JsonValue.TRUE this method returns true. If the value at the specified position is JsonValue.FALSE this method returns false. Otherwise this method returns the specified default value. - javax.json - JsonArray - - - int - boolean - - - - - 434 - Returns the int value of the JsonNumber at the specified position. If the value at that position is a JsonNumber, this method returns javax.json.JsonNumber#intValue(). Otherwise this method returns the specified default value. - javax.json - JsonArray - - - int - int - - - - - 435 - Returns the String value of JsonString at the specified position in this JSON array values. If JsonString is found, its javax.json.JsonString#getString() is returned. Otherwise, the specified default value is returned. - javax.json - JsonArray - - - int - java.lang.String - - - - - 436 - Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false. - javax.json - JsonObject - - - java.lang.String - - - - - 439 - Returns the boolean value of the associated mapping for the specified name. If the associated mapping is JsonValue.TRUE, then returns true. If the associated mapping is JsonValue.FALSE, then returns false. Otherwise, the specified default value is returned. - javax.json - JsonObject - - - java.lang.String - boolean - - - - - 441 - Returns the int value of the associated JsonNumber mapping for the specified name. If JsonNumber is found, then its javax.json.JsonNumber#intValue() is returned. Otherwise, the specified default value is returned. - javax.json - JsonObject - - - java.lang.String - int - - - - - 443 - Returns the string value of the associated JsonString mapping for the specified name. If JsonString is found, then its javax.json.JsonString#getString() is returned. Otherwise, the specified default value is returned. - javax.json - JsonObject - - - java.lang.String - java.lang.String - - - - - 445 - Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - 449 - Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - 452 - Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json - Json - - - java.util.Map - - - - - 453 - Creates a JsonArrayBuilder instance that is used to build JsonArray - javax.json - JsonBuilderFactory - - - - 454 - Creates a JsonObjectBuilder instance that is used to build JsonObject. - javax.json - JsonBuilderFactory - - - - 455 - Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON builders. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json - JsonBuilderFactory - - - - 459 - Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON readers. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json - JsonReaderFactory - - - - 463 - Returns read-only map of supported provider specific configuration properties that are used to configure the created JSON writer objects. If there are any specified configuration properties that are not supported by the provider, they won't be part of the returned map. - javax.json - JsonWriterFactory - - - - 464 - Creates a JSON array builder. - javax.json.spi - JsonProvider - - - - 465 - Creates a builder factory for creating JsonArrayBuilder and JsonObjectBuilder objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - 466 - Creates a JSON object builder. - javax.json.spi - JsonProvider - - - - 467 - Creates a JSON reader from a character stream. - javax.json.spi - JsonProvider - - - java.io.Reader - - - - - 468 - Creates a JSON reader from a byte stream. The character encoding of the stream is determined as described in RFC 7159. - javax.json.spi - JsonProvider - - - java.io.InputStream - - - - - 469 - Creates a reader factory for creating JsonReader objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - 470 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified character stream. - javax.json.spi - JsonProvider - - - java.io.Writer - - - - - 471 - Creates a JSON writer to write a JSON JsonObject object or JsonArray array structure to the specified byte stream. Characters written to the stream are encoded into bytes using UTF-8 encoding. - javax.json.spi - JsonProvider - - - java.io.OutputStream - - - - - 472 - Creates a writer factory for creating JsonWriter objects. The factory is configured with the specified map of provider specific configuration properties. Provider implementations should ignore any unsupported configuration properties specified in the map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - 474 - Return the column number (starts with 1 for the first column) for the current JSON event in the input source. - javax.json.stream - JsonLocation - - - - 475 - Return the line number (starts with 1 for the first line) for the current JSON event in the input source. - javax.json.stream - JsonLocation - - - - 476 - Return the stream offset into the input source this location is pointing to. If the input source is a file or a byte stream then this is the byte offset into that stream, but if the input source is a character media then the offset is the character offset. Returns -1 if there is no offset available. - javax.json.stream - JsonLocation - - - - 477 - Return the location that corresponds to the parser's current state in the JSON input source. The location information is only valid in the current parser state (or until the parser is advanced to a next state). - javax.json.stream - JsonParser - - - - 478 - Return the location of the incorrect JSON. - javax.json.stream - JsonParsingException - - - - 481 - Returns a list view of the specified type for the array. This method does not verify if there is a value of wrong type in the array. Providing this typesafe view dynamically may cause a program fail with a ClassCastException, if there is a value of wrong type in this array. Unfortunately, the exception can occur at any time after this method returns. - javax.json - JsonArray - - - java.lang.Class - - - - - 490 - Returns the array value at the specified position in this array. This is a convenience method for (JsonArray)get(index). - javax.json - JsonArray - - - int - - - - - 493 - Returns the number value at the specified position in this array. This is a convenience method for (JsonNumber)get(index). - javax.json - JsonArray - - - int - - - - - 496 - Returns the object value at the specified position in this array. This is a convenience method for (JsonObject)get(index). - javax.json - JsonArray - - - int - - - - - 499 - Returns the string value at ths specified position in this array. This is a convenience method for (JsonString)get(index). - javax.json - JsonArray - - - int - - - - - 506 - Returns true if the value at the specified location in this array is JsonValue.NULL. - javax.json - JsonArray - - - int - - - - - 527 - Returns the array value to which the specified name is mapped. This is a convenience method for (JsonArray)get(name) to get the value. - javax.json - JsonObject - - - java.lang.String - - - - - 529 - Returns the number value to which the specified name is mapped. This is a convenience method for (JsonNumber)get(name) to get the value. - javax.json - JsonObject - - - java.lang.String - - - - - 531 - Returns the object value to which the specified name is mapped. This is a convenience method for (JsonObject)get(name) to get the value. - javax.json - JsonObject - - - java.lang.String - - - - - 533 - Returns the string value to which the specified name is mapped. This is a convenience method for (JsonString)get(name) to get the value. - javax.json - JsonObject - - - java.lang.String - - - - - 539 - Returns true if the associated value for the specified name is JsonValue.NULL. - javax.json - JsonObject - - - java.lang.String - - - - - 572 - Creates a JSON array builder, initialized with the specified array - javax.json - Json - - - javax.json.JsonArray - - - - - 573 - Creates a JSON array builder, initialized with the content of specified collection. - javax.json - Json - - - java.util.Collection - - - - - 574 - Generates a JSON Patch (RFC 6902) from the source and target JsonStructure. The generated JSON Patch need not be unique. - javax.json - Json - - - javax.json.JsonStructure - javax.json.JsonStructure - - - - - 575 - Generates a JSON Merge Patch (RFC 7396) from the source and target JsonValues which when applied to the source, yields the target. - javax.json - Json - - - javax.json.JsonValue - javax.json.JsonValue - - - - - 576 - Creates JSON Merge Patch (RFC 7396) from specified JsonValue. - javax.json - Json - - - javax.json.JsonValue - - - - - 577 - Creates a JSON object builder, initialized with the specified object. - javax.json - Json - - - javax.json.JsonObject - - - - - 578 - Creates a JSON object builder, initialized with the specified object. - javax.json - Json - - - java.util.Map - - - - - 579 - Creates a JSON Patch (RFC 6902) from the specified operations. - javax.json - Json - - - javax.json.JsonArray - - - - - 580 - Creates a JSON Patch builder (RFC 6902). - javax.json - Json - - - - 581 - Creates a JSON Patch builder (RFC 6902), initialized with the specified operations. - javax.json - Json - - - javax.json.JsonArray - - - - - 582 - Creates JSON Pointer (RFC 6901) from given jsonPointer string. An empty jsonPointer string defines a reference to the target itself. If the jsonPointer string is non-empty, it must be a sequence of '/' prefixed tokens. - javax.json - Json - - - java.lang.String - - - - - 583 - Creates a JsonString. - javax.json - Json - - - java.lang.String - - - - - 584 - Creates a JsonNumber. - javax.json - Json - - - int - - - - - 585 - Creates a JsonNumber. - javax.json - Json - - - long - - - - - 586 - Creates a JsonNumber. - javax.json - Json - - - double - - - - - 587 - Creates a JsonNumber. - javax.json - Json - - - java.math.BigDecimal - - - - - 588 - Creates a JsonNumber. - javax.json - Json - - - java.math.BigInteger - - - - - 589 - Returns a list view for the array. The value and the type of the elements in the list is specified by the func argument. This method can be used to obtain a list of the unwrapped types, such as List strings = ary1.getValuesAs(JsonString::getString); List ints = ary2.getValuesAs(JsonNumber::intValue); or a list of simple projections, such as List stringsizes = ary1.getValueAs((JsonString v)->v.getString().length(); - javax.json - JsonArray - - - java.util.function.Function - - - - - 590 - Inserts a value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - javax.json.JsonValue - - - - - 591 - Adds a value to the array as a JsonString at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - java.lang.String - - - - - 592 - Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - java.math.BigDecimal - - - - - 593 - Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - java.math.BigInteger - - - - - 594 - Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - int - - - - - 595 - Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - long - - - - - 596 - Adds a value to the array as a JsonNumber at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - double - - - - - 597 - Adds a JsonValue#TRUE or JsonValue#FALSE value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - boolean - - - - - 598 - Adds a JsonObject from an object builder to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - javax.json.JsonObjectBuilder - - - - - 599 - Adds a JsonArray from an array builder to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - javax.json.JsonArrayBuilder - - - - - 600 - Adds all elements of the array in the specified array builder to the array. - javax.json - JsonArrayBuilder - - - javax.json.JsonArrayBuilder - - - - - 601 - Adds a JsonValue#NULL value to the array at the specified position. Shifts the value currently at that position (if any) and any subsequent values to the right (adds one to their indices). Index starts with 0. - javax.json - JsonArrayBuilder - - - int - - - - - 602 - Remove the value in the array at the specified position. Shift any subsequent values to the left (subtracts one from their indices. - javax.json - JsonArrayBuilder - - - int - - - - - 603 - Replaces a value in the array with the specified value at the specified position. - javax.json - JsonArrayBuilder - - - int - javax.json.JsonValue - - - - - 604 - Replaces a value in the array with the specified value as a JsonString at the specified position. - javax.json - JsonArrayBuilder - - - int - java.lang.String - - - - - 605 - Replaces a value in the array with the specified value as a JsonNumber at the specified position. - javax.json - JsonArrayBuilder - - - int - java.math.BigDecimal - - - - - 606 - Replaces a value in the array with the specified value as a JsonNumber at the specified position. - javax.json - JsonArrayBuilder - - - int - java.math.BigInteger - - - - - 607 - Replaces a value in the array with the specified value as a JsonNumber at the specified position. - javax.json - JsonArrayBuilder - - - int - int - - - - - 608 - Replaces a value in the array with the specified value as a JsonNumber at the specified position. - javax.json - JsonArrayBuilder - - - int - long - - - - - 609 - Replaces a value in the array with the specified value as a JsonNumber at the specified position. - javax.json - JsonArrayBuilder - - - int - double - - - - - 610 - Replaces a value in the array with a JsonValue#TRUE or JsonValue#FALSE value at the specified position. - javax.json - JsonArrayBuilder - - - int - boolean - - - - - 611 - Replaces a value in the array with the specified value as a JsonObject from an object builder at the specified position. - javax.json - JsonArrayBuilder - - - int - javax.json.JsonObjectBuilder - - - - - 612 - Replaces a value in the array with the specified value as a JsonArray from an array builder at the specified position. - javax.json - JsonArrayBuilder - - - int - javax.json.JsonArrayBuilder - - - - - 613 - Replaces a value in the array with a JsonValue#NULL value at the specified position. - javax.json - JsonArrayBuilder - - - int - - - - - 614 - Creates a JsonArrayBuilder instance, initialized with an array. - javax.json - JsonBuilderFactory - - - javax.json.JsonArray - - - - - 615 - Creates a JsonObjectBuilder instance, initialized with an object. - javax.json - JsonBuilderFactory - - - javax.json.JsonObject - - - - - 616 - Applies the JSON Merge Patch to the specified target. The target is not modified by the patch. - javax.json - JsonMergePatch - - - javax.json.JsonValue - - - - - 617 - Returns the JsonMergePatch as JsonValue. - javax.json - JsonMergePatch - - - - 618 - Adds all name/value pairs in the JSON object associated with the specified object builder to the JSON object associated with this object builder. The newly added name/value pair will replace any existing name/value pair with the same name. - javax.json - JsonObjectBuilder - - - javax.json.JsonObjectBuilder - - - - - 619 - Remove the name/value pair from the JSON object associated with this object builder if it is present. - javax.json - JsonObjectBuilder - - - java.lang.String - - - - - 620 - Applies the patch operations to the specified target. The target is not modified by the patch. - javax.json - JsonPatch - - - javax.json.JsonStructure - - - - - 621 - Returns the JsonPatch as JsonArray. - javax.json - JsonPatch - - - - 622 - Returns the enum constant with the specified name. - javax.json - JsonPatch.Operation - - - java.lang.String - - - - - 623 - Returns enum constant name as lower case string. - javax.json - JsonPatch.Operation - - - - 624 - - javax.json - JsonPatch.Operation - - - java.lang.String - - - - - 625 - - javax.json - JsonPatch.Operation - - - - 626 - Adds an "add" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - javax.json.JsonValue - - - - - 627 - Adds an "add" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - java.lang.String - - - - - 628 - Adds an "add" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - int - - - - - 629 - Adds an "add" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - boolean - - - - - 630 - Returns the JSON Patch. - javax.json - JsonPatchBuilder - - - - 631 - Adds a "copy" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - java.lang.String - - - - - 632 - Adds a "move" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - java.lang.String - - - - - 633 - Adds a "remove" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - - - - - 634 - Adds a "replace" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - javax.json.JsonValue - - - - - 635 - Adds a "replace" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - java.lang.String - - - - - 636 - Adds a "replace" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - int - - - - - 637 - Adds a "replace" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - boolean - - - - - 638 - Adds a "test" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - javax.json.JsonValue - - - - - 639 - Adds a "test" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - java.lang.String - - - - - 640 - Adds a "test" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - int - - - - - 641 - Adds a "test" JSON Patch operation. - javax.json - JsonPatchBuilder - - - java.lang.String - boolean - - - - - 642 - Adds or replaces a value at the referenced location in the specified target with the specified value. If the reference is the target (empty JSON Pointer string), the specified value, which must be the same type as specified target, is returned. If the reference is an array element, the specified value is inserted into the array, at the referenced index. The value currently at that location, and any subsequent values, are shifted to the right (adds one to the indices). Index starts with 0. If the reference is specified with a "-", or if the index is equal to the size of the array, the value is appended to the array. If the reference is a name/value pair of a JsonObject, and the referenced value exists, the value is replaced by the specified value. If the value does not exist, a new name/value pair is added to the object. - javax.json - JsonPointer - - - javax.json.JsonStructure - javax.json.JsonValue - - - - - 643 - Returns the value at the referenced location in the specified target. - javax.json - JsonPointer - - - javax.json.JsonStructure - - - - - 644 - Removes the value at the reference location in the specified target. - javax.json - JsonPointer - - - javax.json.JsonStructure - - - - - 645 - Replaces the value at the referenced location in the specified target with the specified value. - javax.json - JsonPointer - - - javax.json.JsonStructure - javax.json.JsonValue - - - - - 646 - Returns a JSON value that is represented in the input source. This method needs to be called only once for a reader instance. - javax.json - JsonReader - - - - 647 - Get the value referenced by the provided JSON Pointer in the JsonStructure. - javax.json - JsonStructure - - - java.lang.String - - - - - 648 - Return the JsonValue as a JsonArray - javax.json - JsonValue - - - - 649 - Return the JsonValue as a JsonObject - javax.json - JsonValue - - - - 650 - Writes the specified JsonValue to the output source. method needs to be called only once for a write instance. - javax.json - JsonWriter - - - javax.json.JsonValue - - - - - 651 - Creates a JSON array builder, initialized with the specified array. - javax.json.spi - JsonProvider - - - javax.json.JsonArray - - - - - 652 - Creates a JSON array builder, initialized with the specified collection. - javax.json.spi - JsonProvider - - - java.util.Collection - - - - - 653 - Generates a JSON Patch (RFC 6902) from the source and target JsonStructure. The generated JSON Patch need not be unique. - javax.json.spi - JsonProvider - - - javax.json.JsonStructure - javax.json.JsonStructure - - - - - 654 - Generates a JSON Merge Patch (RFC 7396) from the source and target JsonValues which when applied to the source, yields the target. - javax.json.spi - JsonProvider - - - javax.json.JsonValue - javax.json.JsonValue - - - - - 655 - Creates JSON Merge Patch (RFC 7396) from specified JsonValue. - javax.json.spi - JsonProvider - - - javax.json.JsonValue - - - - - 656 - Creates a JSON object builder, initialized with the specified object. - javax.json.spi - JsonProvider - - - javax.json.JsonObject - - - - - 657 - Creates a JSON object builder, initialized with the specified Map. - javax.json.spi - JsonProvider - - - java.util.Map - - - - - 658 - Creates a JSON Patch (RFC 6902) from the specified operations. - javax.json.spi - JsonProvider - - - javax.json.JsonArray - - - - - 659 - Creates a JSON Patch builder (RFC 6902). - javax.json.spi - JsonProvider - - - - 660 - Creates a JSON Patch builder (RFC 6902), initialized with the specified operations. - javax.json.spi - JsonProvider - - - javax.json.JsonArray - - - - - 661 - Creates JSON Pointer (RFC 6901) from given jsonPointer string. An empty jsonPointer string defines a reference to the target itself. If the jsonPointer string is non-empty, it must be a sequence of '/' prefixed tokens. - javax.json.spi - JsonProvider - - - java.lang.String - - - - - 662 - Creates a JsonString. - javax.json.spi - JsonProvider - - - java.lang.String - - - - - 663 - Creates a JsonNumber. - javax.json.spi - JsonProvider - - - int - - - - - 664 - Creates a JsonNumber. - javax.json.spi - JsonProvider - - - long - - - - - 665 - Creates a JsonNumber. - javax.json.spi - JsonProvider - - - double - - - - - 666 - Creates a JsonNumber. - javax.json.spi - JsonProvider - - - java.math.BigDecimal - - - - - 667 - Creates a JsonNumber. - javax.json.spi - JsonProvider - - - java.math.BigInteger - - - - - 668 - Constructs a java.util.stream.Collector that implements a "group by" operation on the input JsonValue elements. A classifier function maps the input JsonValues to keys, and the JsonValues are partitioned into groups according to the value of the key. A reduction operation is performed on the JsonValues in each group, using the downstream Collector. For each group, the key and the results of the reduction operation become the name/value pairs of the resultant JsonObject. - javax.json.stream - JsonCollectors - - - java.util.function.Function - java.util.stream.Collector - - - - - 669 - Constructs a java.util.stream.Collector that implements a "group by" operation on the input JsonValue elements. A classifier function maps the input JsonValues to keys, and the JsonValues are partitioned into groups according to the value of the key. The JsonValues in each group are added to a JsonArray. The key and the JsonArray in each group becomes the name/value pair of the resultant JsonObject. - javax.json.stream - JsonCollectors - - - java.util.function.Function - - - - - 670 - Constructs a java.util.stream.Collector that accumulates the input JsonValue elements into a JsonArray. - javax.json.stream - JsonCollectors - - - - 671 - Constructs a java.util.stream.Collector that accumulates the input JsonValue elements into a JsonObject. The name/value pairs of the JsonObject are computed by applying the provided mapping functions. - javax.json.stream - JsonCollectors - - - java.util.function.Function - java.util.function.Function - - - - - 672 - Writes the JSON name with a colon. It starts a field context, in which valid options are writing a value, starting an object or an array. Writing value closes field context, if object or array is started after field name, field context will be closed after object/array close. - javax.json.stream - JsonGenerator - - - java.lang.String - - - - - 673 - Returns a JsonArray and advance the parser to the the corresponding END_ARRAY. - javax.json.stream - JsonParser - - - - 674 - Returns a stream of the JsonArray elements. The parser state must be START_ARRAY. The elements are read lazily, on an as-needed basis, as required by the stream operations. If the stream operations do not consume all of the array elements, #skipArray() can be used to skip the unprocessed array elements. - javax.json.stream - JsonParser - - - - 675 - Returns a JsonObject and advances the parser to the corresponding END_OBJECT. - javax.json.stream - JsonParser - - - - 676 - Returns a stream of the JsonObject's name/value pairs. The parser state must be START_OBJECT. The name/value pairs are read lazily, on an as-needed basis, as required by the stream operations. If the stream operations do not consume all of the object's name/value pairs, #skipObject() can be used to skip the unprocessed elements. - javax.json.stream - JsonParser - - - - 677 - Returns a JsonValue at the current parser position. If the parser state is START_ARRAY, the behavior is the same as #getArray. If the parser state is START_OBJECT, the behavior is the same as #getObject. For all other cases, if applicable, the JSON value is read and returned. - javax.json.stream - JsonParser - - - - 678 - Returns a stream of JsonValue from a sequence of JSON values. The values are read lazily, on an as-needed basis, as needed by the stream operations. - javax.json.stream - JsonParser - - - - 679 - Advance the parser to END_ARRAY. If the parser is in array context, i.e. it has previously encountered a START_ARRAY without encountering the corresponding END_ARRAY, the parser is advanced to the corresponding END_ARRAY. If the parser is not in any array context, nothing happens. - javax.json.stream - JsonParser - - - - 680 - Advance the parser to END_OBJECT. If the parser is in object context, i.e. it has previously encountered a START_OBJECT without encountering the corresponding END_OBJECT, the parser is advanced to the corresponding END_OBJECT. If the parser is not in any object context, nothing happens. - javax.json.stream - JsonParser - - - - - - - - 20 - if the value is Not-a-Number(NaN) or infinity - javax.json - JsonArrayBuilder - - - double - - java.lang.NumberFormatException - - - - 43 - if the number has a nonzero fractional part - javax.json - JsonNumber - - java.lang.ArithmeticException - - - - 47 - if the number has a nonzero fractional part or if it does not fit in an int - javax.json - JsonNumber - - java.lang.ArithmeticException - - - - 50 - if the number has a non-zero fractional part or if it does not fit in a long - javax.json - JsonNumber - - java.lang.ArithmeticException - - - - 79 - if the value is Not-a-Number(NaN) or infinity - javax.json - JsonObjectBuilder - - - java.lang.String - double - - java.lang.NumberFormatException - - - - 108 - if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException) - javax.json - JsonWriter - - - javax.json.JsonArray - - javax.json.JsonException - - - - 109 - if writeArray, writeObject, write or close method is already called - javax.json - JsonWriter - - - javax.json.JsonArray - - java.lang.IllegalStateException - - - - 111 - if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException) - javax.json - JsonWriter - - - javax.json.JsonObject - - javax.json.JsonException - - - - 112 - if writeArray, writeObject, write or close method is already called - javax.json - JsonWriter - - - javax.json.JsonObject - - java.lang.IllegalStateException - - - - 121 - when the parser state is not VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - 123 - when the parser state is not KEY_NAME, VALUE_STRING, or VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - 182 - if a JSON object or array cannot be created due to i/o error (IOException would be cause of JsonException) - javax.json - JsonReader - - javax.json.JsonException - - - - 183 - if read, readObject, readArray or close method is already called - javax.json - JsonReader - - java.lang.IllegalStateException - - - - 207 - if encoding cannot be determined or i/o error (IOException would be cause of JsonException) - javax.json - Json - - - java.io.InputStream - - javax.json.JsonException - - - - 217 - if a JSON array cannot be created due to i/o error (IOException would be cause of JsonException) - javax.json - JsonReader - - javax.json.JsonException - - - - 218 - if read, readObject, readArray or close method is already called - javax.json - JsonReader - - java.lang.IllegalStateException - - - - 219 - if a JSON object cannot be created due to i/o error (IOException would be cause of JsonException) - javax.json - JsonReader - - javax.json.JsonException - - - - 220 - if read, readObject, readArray or close method is already called - javax.json - JsonReader - - java.lang.IllegalStateException - - - - 221 - if the specified JSON object cannot be written due to i/o error (IOException would be cause of JsonException) - javax.json - JsonWriter - - - javax.json.JsonStructure - - javax.json.JsonException - - - - 222 - if writeArray, writeObject, write or close method is already called - javax.json - JsonWriter - - - javax.json.JsonStructure - - java.lang.IllegalStateException - - - - 223 - if encoding cannot be determined or i/o error (IOException would be cause of JsonException) - javax.json.spi - JsonProvider - - - java.io.InputStream - - javax.json.JsonException - - - - 225 - if encoding cannot be determined or i/o error (IOException would be cause of JsonException) - javax.json.stream - JsonParserFactory - - - java.io.InputStream - - javax.json.JsonException - - - - 236 - when the parser state is not VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - 238 - when the parser state is not VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - 240 - when the parser state is not VALUE_NUMBER - javax.json.stream - JsonParser - - java.lang.IllegalStateException - - - - 290 - if this method is called in no context. - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - 293 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - javax.json.JsonValue - - javax.json.JsonException - - - - 296 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - java.lang.String - - javax.json.JsonException - - - - 297 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - java.lang.String - - javax.json.stream.JsonGenerationException - - - - 299 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigInteger - - javax.json.JsonException - - - - 302 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigDecimal - - javax.json.JsonException - - - - 303 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigDecimal - - javax.json.stream.JsonGenerationException - - - - 305 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - int - - javax.json.JsonException - - - - 306 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - int - - javax.json.stream.JsonGenerationException - - - - 308 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - long - - javax.json.JsonException - - - - 309 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - long - - javax.json.stream.JsonGenerationException - - - - 311 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - double - - javax.json.JsonException - - - - 312 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - double - - javax.json.stream.JsonGenerationException - - - - 315 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - boolean - - javax.json.JsonException - - - - 316 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - boolean - - javax.json.stream.JsonGenerationException - - - - 331 - if the value is Not-a-Number(NaN) or infinity. - javax.json.stream - JsonGenerator - - - double - - java.lang.NumberFormatException - - - - 335 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.JsonException - - - - 336 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.stream.JsonGenerationException - - - - 343 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - 344 - if the value for specified name mapping is not assignable to JsonNumber - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - 345 - if the value for specified name mapping is not assignable to JsonString - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - 346 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - 347 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - javax.json.JsonValue - - javax.json.stream.JsonGenerationException - - - - 348 - if this method is not called within an object context. - javax.json.stream - JsonGenerator - - - java.lang.String - java.math.BigInteger - - javax.json.stream.JsonGenerationException - - - - 349 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - javax.json.JsonValue - - javax.json.JsonException - - - - 350 - if this method is not called within an array context. - javax.json.stream - JsonGenerator - - - javax.json.JsonValue - - javax.json.stream.JsonGenerationException - - - - 351 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.JsonException - - - - 352 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.stream.JsonGenerationException - - - - 353 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.math.BigDecimal - - javax.json.JsonException - - - - 354 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - java.math.BigDecimal - - javax.json.stream.JsonGenerationException - - - - 355 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.math.BigInteger - - javax.json.JsonException - - - - 356 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - java.math.BigInteger - - javax.json.stream.JsonGenerationException - - - - 357 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - int - - javax.json.JsonException - - - - 358 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - int - - javax.json.stream.JsonGenerationException - - - - 359 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - long - - javax.json.JsonException - - - - 360 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - long - - javax.json.stream.JsonGenerationException - - - - 361 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - double - - javax.json.JsonException - - - - 362 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - - double - - javax.json.stream.JsonGenerationException - - - - 363 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - boolean - - javax.json.JsonException - - - - 364 - if this method is not called within an array context. - javax.json.stream - JsonGenerator - - - boolean - - javax.json.stream.JsonGenerationException - - - - 365 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - 366 - if this method is not called within an array context - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - 367 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - 368 - if this method is called within an object context or if called more than once in no context - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - 369 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.JsonException - - - - 370 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.stream.JsonGenerationException - - - - 371 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - 372 - if this method is called within an object context or if it is called more than once in no context. - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - 373 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.JsonException - - - - 374 - if this method is not called within an object context - javax.json.stream - JsonGenerator - - - java.lang.String - - javax.json.stream.JsonGenerationException - - - - 377 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - 378 - if the value at the specified position is not assignable to JsonNumber - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - 379 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - 380 - if the value at the specified position is not assignable to JsonString - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - 381 - if an incomplete JSON is generated - javax.json.stream - JsonGenerator - - javax.json.stream.JsonGenerationException - - - - 382 - if the value is Not-a-Number(NaN) or infinity. - javax.json.stream - JsonGenerator - - - java.lang.String - double - - java.lang.NumberFormatException - - - - 387 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonParser - - javax.json.JsonException - - - - 388 - if the parser encounters invalid JSON when advancing to next state. - javax.json.stream - JsonParser - - javax.json.stream.JsonParsingException - - - - 389 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonParser - - javax.json.JsonException - - - - 390 - if the parser encounters invalid JSON when advancing to next state. - javax.json.stream - JsonParser - - javax.json.stream.JsonParsingException - - - - 391 - if there are no more parsing states. - javax.json.stream - JsonParser - - java.util.NoSuchElementException - - - - 410 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json - JsonReader - - javax.json.JsonException - - - - 411 - if a JSON object or array cannot be created due to incorrect representation - javax.json - JsonReader - - javax.json.stream.JsonParsingException - - - - 412 - if a JSON array cannot be created due to incorrect representation - javax.json - JsonReader - - javax.json.stream.JsonParsingException - - - - 413 - if a JSON object cannot be created due to incorrect representation - javax.json - JsonReader - - javax.json.stream.JsonParsingException - - - - 414 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json - JsonWriter - - javax.json.JsonException - - - - 415 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonParser - - javax.json.JsonException - - - - 431 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - 432 - if the value at the specified position is not assignable to JsonValue.TRUE or JsonValue.FALSE - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - 437 - if the specified name doesn't have any mapping - javax.json - JsonObject - - - java.lang.String - - java.lang.NullPointerException - - - - 438 - if the value for specified name mapping is not assignable to JsonValue.TRUE or JsonValue.FALSE - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - 440 - if the specified name doesn't have any mapping - javax.json - JsonObject - - - java.lang.String - - java.lang.NullPointerException - - - - 442 - if the specified name doesn't have any mapping - javax.json - JsonObject - - - java.lang.String - - java.lang.NullPointerException - - - - 491 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - 492 - if the value at the specified position is not assignable to the JsonArray type - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - 494 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - 495 - if the value at the specified position is not assignable to the JsonNumber type - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - 497 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - 498 - if the value at the specified position is not assignable to the JsonObject type - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - 500 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - 501 - if the value at the specified position is not assignable to the JsonString type - javax.json - JsonArray - - - int - - java.lang.ClassCastException - - - - 507 - if the index is out of range - javax.json - JsonArray - - - int - - java.lang.IndexOutOfBoundsException - - - - 528 - if the value to which the specified name is mapped is not assignable to JsonArray type - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - 530 - if the value to which the specified name is mapped is not assignable to JsonNumber type - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - 532 - if the value to which the specified name is mapped is not assignable to JsonObject type - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - 534 - if the value to which the specified name is mapped is not assignable to JsonString type - javax.json - JsonObject - - - java.lang.String - - java.lang.ClassCastException - - - - 540 - if the specified name doesn't have any mapping - javax.json - JsonObject - - - java.lang.String - - java.lang.NullPointerException - - - - 551 - if an i/o error occurs (IOException would be cause of JsonException) - javax.json.stream - JsonGenerator - - javax.json.JsonException - - - - 555 - if the specified value is null - javax.json - JsonArrayBuilder - - - javax.json.JsonValue - - java.lang.NullPointerException - - - - 556 - if the specified value is null - javax.json - JsonArrayBuilder - - - java.lang.String - - java.lang.NullPointerException - - - - 557 - if the specified value is null - javax.json - JsonArrayBuilder - - - java.math.BigDecimal - - java.lang.NullPointerException - - - - 558 - if the specified value is null - javax.json - JsonArrayBuilder - - - java.math.BigInteger - - java.lang.NullPointerException - - - - 559 - if the specified builder is null - javax.json - JsonArrayBuilder - - - javax.json.JsonObjectBuilder - - java.lang.NullPointerException - - - - 560 - if the specified builder is null - javax.json - JsonArrayBuilder - - - javax.json.JsonArrayBuilder - - java.lang.NullPointerException - - - - 561 - if the specified name or value is null - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonValue - - java.lang.NullPointerException - - - - 562 - if the specified name or value is null - javax.json - JsonObjectBuilder - - - java.lang.String - java.lang.String - - java.lang.NullPointerException - - - - 563 - if the specified name or value is null - javax.json - JsonObjectBuilder - - - java.lang.String - java.math.BigInteger - - java.lang.NullPointerException - - - - 564 - if the specified name or value is null - javax.json - JsonObjectBuilder - - - java.lang.String - java.math.BigDecimal - - java.lang.NullPointerException - - - - 565 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - int - - java.lang.NullPointerException - - - - 566 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - long - - java.lang.NullPointerException - - - - 567 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - double - - java.lang.NullPointerException - - - - 568 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - boolean - - java.lang.NullPointerException - - - - 569 - if the specified name or builder is null - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonObjectBuilder - - java.lang.NullPointerException - - - - 570 - if the specified name or builder is null - javax.json - JsonObjectBuilder - - - java.lang.String - javax.json.JsonArrayBuilder - - java.lang.NullPointerException - - - - 571 - if the specified name is null - javax.json - JsonObjectBuilder - - - java.lang.String - - java.lang.NullPointerException - - - - - - - - 681 - Decodes a passed JSON-pointer string as defined by RFC 6901. This method doesn't validate the passed JSON-pointer string. - javax.json - Json - - - java.lang.String - - - - - 682 - Encodes (escapes) a passed string as defined by RFC 6901. This method doesn't validate the passed JSON-pointer string. - javax.json - Json - - - java.lang.String - - - - - 683 - Creates a JsonArrayBuilder instance, initialized with the content of specified collection. - javax.json - JsonBuilderFactory - - - java.util.Collection - - - - - 684 - Creates a JsonObjectBuilder instance, initialized with the specified object. - javax.json - JsonBuilderFactory - - - java.util.Map - - - - - 685 - Returns this JSON number as a Number object. - javax.json - JsonNumber - - - - 686 - Returns true if there is a value at the referenced location in the specified target. - javax.json - JsonPointer - - - javax.json.JsonStructure - - - - - 687 - Constructs a java.util.stream.Collector that accumulates the input Map.Entry elements into a JsonObject. - javax.json.stream - JsonCollectors - - - - - diff --git a/internal/docs/jsonp/README.txt b/internal/docs/jsonp/README.txt deleted file mode 100644 index 3c70a4ac2c..0000000000 --- a/internal/docs/jsonp/README.txt +++ /dev/null @@ -1,80 +0,0 @@ -Simple README file with instructions to quickly install, setup, configure, -and run the JSON-P TCK 2.0 and related software against the JSON-P RI 2.0.0. For -more detailed instructions please refer to the JSON-P TCK 2.0 Users Guide. - ------------------------ -Installing the Software ------------------------ -Before you can run the JSON-P TCK tests, you need to install -and set up the following software components: - -1) Java SE 8 -2) JSON-P RI Version 2.0.0 -3) JSON-P TCK Version 2.0 - -1. Download and install Java SE 8 software. - - mkdir /javase8 - cd /javase8 - unzip - -2. Download and install the JSON-P 2.0.0 Reference Implementation. - - mkdir /ri - cd /ri - unzip - -3. Download and install the JSON-P TCK 2.0 software. - - mkdir /tck - cd /tck - unzip jsonp_tck-2.0.zip - ------------------------------------------ -Setup and Configuration of the JSON-P TCK ------------------------------------------ -1. Configure the JSON-P TCK to run against the JSON-P RI. Set the following - variables in your shell environment. - - setenv JAVA_HOME /javase8 - setenv TS_HOME /tck/jsonp-tck - setenv ANT_HOME /tck/anthome - setenv PATH $JAVA_HOME/bin:$ANT_HOME/bin:$PATH - -2. Edit the $TS_HOME/bin/ts.jte file and set the following properties: - - jsonp.classes=/ri/jakarta.json-ri-2.0/lib/jakarta.json-2.0.jar - - Add the path to the JSON-P 2.0 Reference Implementation jar - ------------------------------- -Executing the JSON-P TCK Tests ------------------------------- -At this point we are ready to run the JSON-P TCK tests against the JSON-P 2.0.0 -Reference Implementation. - -1. Execute and run the JSON-P TCK tests. - - cd $TS_HOME/bin - ant run.all | tee run.log - - This will run all the JSON-P TCK tests including the signature tests. - -2. Another way to execute and run the JSON-P TCK tests. - - Run just the jsonp tree of tests: - - cd $TS_HOME/src/com/sun/ts/tests/jsonp/api - ant runclient | tee run.log - - Run just the jsonp signature tests: - - cd $TS_HOME/src/com/sun/ts/tests/signaturetests/jsonp - ant runclient | tee run.log - -3. The third way to execute and run the JSON-P TCK tests is to use the - JavaTest GUI. - - cd $TS_HOME/bin - ant gui // Follow the JSON-P TCK Users Guide and JavaTest Harness Guide - // to configure the JSON-P TCK via the JavaTest GUI configurator diff --git a/internal/docs/jsonp/TCD.txt b/internal/docs/jsonp/TCD.txt deleted file mode 100644 index 18c0193670..0000000000 --- a/internal/docs/jsonp/TCD.txt +++ /dev/null @@ -1,77 +0,0 @@ -TCK Coverage Document for JSR-353 Java API for JSON Processing (JSON-P) Specification - - -TCK Components: ---------------- -- User's Guide -- Compatibility Rules -- Configuration Instructions -- Test Suite -- API Tests -- Signature Tests -- Pluggability Tests -- Framework Code -- JavaTest TM Harness - - -Terminology of Metrics ----------------------- -- Assertion: A specific statement of functionality or behavior derived from a - specification. A testable assertion is one that can be validated in an - implementation by testing. -- Test: A binary application (or script) comprised of one or more Test Cases. -- Test Case: A single set of test inputs, execution conditions, and expected - results developed to verify an implementation's conformance with a specific - assertion. -- Specification Assertion Coverage: Ratio of all assertions tested by at least - one test case to the total number of testable assertions defined by the - specification. -- API Coverage: Ratio of methods directly exercised by test cases to the total - number of methods defined by the specification. - - --------- -Coverage --------- -******************************************************************************** -Assertion details. These details will be removed from the final TCD but are -checked into revision history so we can backtrack the numbers later, if we need to. - -Assertions found by the coverage tools (June 4th, 2013 coverage report): ------------------------------------------------------------------------ - api total : 278 - api tested total : 278 - api percentage tested : 100% - -Number of tests in JSON-P TCK: 155 - - -Quality Assurance ------------------ -- TCK was run on the following platforms, note all platforms use Java Platform, Standard Edition 6 - (Java SE 6) or Java Platform, Standard Edition 7 (Java SE 7): - * Solaris 11 Express (x64 architecture) - * Solaris 10 Sparc - * MAC OS X Mountain Lion (10.8.1+) - * Windows XP, Windows 7, Windows 8 - * Oracle Linux 6 - * RedHat Enterprise Linux 6 - * Ubuntu Linux 12.10 - * Suse Enterprise Linux 11 - -- Code quality was demonstrated through the use of code reviews and inspections -- User's Guide was constructed from the standard TCK User's Guide template -- Documentation instructions were verified and tested - - -Justification of Adequacy -------------------------- -The JSON-P TCK Version 1.0 provides a comprehensive set of tests to ensure that all -implementations of the Java API for JSON Processing 1.0 Specification are compatible. As -with all TCKs it is impossible to provide tests for 100% assertion coverage. Note, -while the TCK may not have tests for all assertions in the Java API for JSON Processing -1.0 Specification, all implementations must be compatible with the specification. - -Untested assertions are due to the effects of late specification changes, optional -functionality, conditions that cannot be easily tested, and the availability and -cost of test development resources. diff --git a/release/tools/jsonp.xml b/release/tools/jsonp.xml deleted file mode 100644 index becdac4adb..0000000000 --- a/release/tools/jsonp.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/collectortests/CollectorTests.java b/src/com/sun/ts/tests/jsonp/api/collectortests/CollectorTests.java deleted file mode 100644 index 8a10d02657..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/collectortests/CollectorTests.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2017, 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 com.sun.ts.tests.jsonp.api.collectortests; - -import com.sun.ts.tests.jsonp.api.common.JsonPTest; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -// $Id$ -/** - * JavaScript Object Notation (JSON) Pointer compatibility tests.
- * Test {@link jakarta.json.stream.JsonCollectors} class implementation. - */ -public class CollectorTests extends JsonPTest { - - /** - * Test JSON-P {@link jakarta.json.stream.JsonCollectors} class implementation. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonCollectorTest - * @assertion_ids: JSONP:JAVADOC:668; JSONP:JAVADOC:669; JSONP:JAVADOC:670; - * JSONP:JAVADOC:671; - * @test_Strategy: Test all collectors returned by API. - */ - public void jsonCollectorTest() throws Fault { - Collectors collectorTest = new Collectors(); - final TestResult result = collectorTest.test(); - result.eval(); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/collectortests/Collectors.java b/src/com/sun/ts/tests/jsonp/api/collectortests/Collectors.java deleted file mode 100644 index e03eaf10c6..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/collectortests/Collectors.java +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Copyright (c) 2017, 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 com.sun.ts.tests.jsonp.api.collectortests; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Map; -import java.util.TreeSet; -import java.util.function.Function; -import java.util.stream.Collector; -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; -import jakarta.json.JsonValue; -import jakarta.json.stream.JsonCollectors; -import jakarta.json.stream.JsonParser; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.*; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.*; - -// $Id$ -/** - * JavaScript Object Notation (JSON) Pointer compatibility tests.
- * Test {@link jakarta.json.stream.JsonCollectors} class implementation. This - * class was added to resolve - * {@see RFE: - * Support JSON queries using JDK's stream operations}. - */ -public class Collectors { - - /** Tests input data with JsonArray instances. */ - private static final JsonArray[] ARRAY_VALUES = new JsonArray[] { - createSimpleStringArray5(), // JsonArray with String - createSimpleIntArray5(), // JsonArray with int - createSimpleBoolArray5(), // JsonArray with boolean - createSimpleObjectArray5() // JsonArray with JsonObject - }; - - /** Tests input data with JsonArray instances. */ - private static final JsonObject[] OBJ_VALUES = new JsonObject[] { - createSimpleObjectWithStr(), // JsonObject with String - createSimpleObjectWithInt(), // JsonObject with int - createSimpleObjectWithBool(), // JsonObject with boolean - createCompoundObject() // JsonObject with JsonObject - }; - - /** Test input data for {@code groupingBy} methods. */ - private static final JsonArray OBJ_ARRAY_GROUP = Json.createArrayBuilder() - .add(Json.createObjectBuilder().add("name", "Peter").add("office", - "Green")) - .add(Json.createObjectBuilder().add("name", "John").add("office", "Red")) - .add(Json.createObjectBuilder().add("name", "Bob").add("office", "Blue")) - .add(Json.createObjectBuilder().add("name", "Sarah").add("office", "Red")) - .add(Json.createObjectBuilder().add("name", "Tom").add("office", "Blue")) - .add(Json.createObjectBuilder().add("name", "Jane").add("office", "Blue")) - .add(Json.createObjectBuilder().add("name", "Peggy").add("office", - "Green")) - .add(Json.createObjectBuilder().add("name", "Rick").add("office", "Red")) - .build(); - - /** - * Creates an instance of {@link jakarta.json.stream.JsonCollectors} class - * implementation tests. - */ - Collectors() { - super(); - } - - /** - * Test {@link jakarta.json.stream.JsonCollectors} class implementation. Suite - * entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonCollectors class implementation"); - TestUtil.logMsg("JsonCollectors class implementation"); - testToJsonArrayCollector(result); - // testSimpleToJsonObjectCollector(result); - testToJsonObjectCollector(result); - testSimpleGroupingByCollector(result); - testSortingGroupingByCollector(result); - return result; - } - - /** - * Test collector returned by {@code toJsonArray()} method. This collector - * packs {@code Stream} contend into a single JsonArray instance - * which contains stream values in the same order at they were read. It can be - * considered as {@link JsonParser#getArrayStream()} counterpart. - * - * @param result - * Tests result record. - */ - private void testToJsonArrayCollector(final TestResult result) { - TestUtil.logMsg(" - Collector returned by toJsonArray()"); - for (final JsonArray in : ARRAY_VALUES) { - TestUtil.logMsg(" - Input: " + valueToString(in)); - final Collector col = JsonCollectors - .toJsonArray(); - final JsonArray out = in.getValuesAs(JsonObject.class).stream() - .collect(col); - if (operationFailed(in, out)) { - result.fail("toJsonArray()", "Output Stream value " + valueToString(out) - + " shall be " + valueToString(in)); - } - } - } - - // TCK test for https://java.net/jira/browse/JSON_PROCESSING_SPEC-82 in case - // it will be checked in. - // /** - // * Test collector returned by {@code toJsonObject()} method. - // * This collector packs {@code Stream} contend into a single - // JsonArray instance which contains - // * stream values in the same order at they were read. It can be considered - // as {@link JsonParser#getArrayStream()} - // * counterpart. - // * @param result Tests result record. - // */ - // private void testSimpleToJsonObjectCollector(final TestResult result) { - // TestUtil.logMsg(" - Collector returned by toJsonObject()"); - // for (final JsonObject in : OBJ_VALUES) { - // TestUtil.logMsg(" - Input: " + valueToString(in)); - // final Collector, JsonObjectBuilder, JsonObject> - // col = JsonCollectors.toJsonObject(); - // final JsonObject out = (in.entrySet()).stream().collect(col); - // if (operationFailed(in, out)) { - // result.fail("toJsonObject()", - // "Output Stream value " + valueToString(out) + " shall be " + - // valueToString(in)); - // } - // } - // } - - /** - * Test collector returned by - * {@code toJsonObject(Function, Function)} - * method. This collector does not pack content of - * {@code Stream>} stream of - * {@link JsonParser#getObjectStream()} output. So it's not counterpart of - * this method. It works with {@code Stream}, which is - * {@link JsonParser#getArrayStream()} output and uses two {@link Function} - * implementations to build target object keys and values from - * {@code JsonValue} in the {@code Stream}. - * - * @param result - * Tests result record. - */ - private void testToJsonObjectCollector(final TestResult result) { - TestUtil.logMsg(" - Collector returned by toJsonObject(Function,Function)"); - final JsonArray in = Json.createArrayBuilder() - .add(Json.createObjectBuilder().add("key", STR_NAME).add("value", - STR_VALUE)) - .add(Json.createObjectBuilder().add("key", INT_NAME).add("value", - INT_VALUE)) - .add(Json.createObjectBuilder().add("key", BOOL_NAME).add("value", - BOOL_VALUE)) - .add(Json.createObjectBuilder().add("key", OBJ_NAME).add("value", - OBJ_VALUE)) - .build(); - final JsonObject check = Json.createObjectBuilder().add(STR_NAME, STR_VALUE) - .add(INT_NAME, INT_VALUE).add(BOOL_NAME, BOOL_VALUE) - .add(OBJ_NAME, OBJ_VALUE).build(); - TestUtil.logMsg(" Input: " + valueToString(in)); - final Collector col = JsonCollectors - .toJsonObject( - // Build key from stream value. - (JsonValue v) -> { - if (v.getValueType() == JsonValue.ValueType.OBJECT) - return v.asJsonObject().getString("key"); - throw new IllegalStateException("Value must be JsonObject"); - }, - // Build value from stream value. - (JsonValue v) -> { - if (v.getValueType() == JsonValue.ValueType.OBJECT) - return v.asJsonObject().get("value"); - throw new IllegalStateException("Value must be JsonObject"); - }); - final JsonObject out = in.getValuesAs(JsonObject.class).stream() - .collect(col); - if (operationFailed(out, check)) { - result.fail("toJsonObject(Function,Function)", "Output Stream value " - + valueToString(out) + " shall be " + valueToString(check)); - } - } - - /** - * Test collector returned by {@code groupingBy(Function)} - * method. This collector allows grouping of {@code Stream} using - * provided {@code Function)} function to define group - * identifiers based on {@code JsonValue} content. Test just groups JSON - * objects in the stream by {@code "office"} attribute. Default - * {@code toJsonArray()} collector is used so output is unsorted. - * - * @param result - * Tests result record. - */ - private void testSimpleGroupingByCollector(final TestResult result) { - TestUtil.logMsg(" - Collector returned by groupingBy(Function)"); - final JsonObject check = Json.createObjectBuilder().add("Red", Json - .createArrayBuilder() - .add( - Json.createObjectBuilder().add("name", "John").add("office", "Red")) - .add(Json.createObjectBuilder().add("name", "Sarah").add("office", - "Red")) - .add( - Json.createObjectBuilder().add("name", "Rick").add("office", "Red")) - .build()) - .add("Blue", - Json.createArrayBuilder() - .add(Json.createObjectBuilder().add("name", "Bob").add("office", - "Blue")) - .add(Json.createObjectBuilder().add("name", "Tom").add("office", - "Blue")) - .add(Json.createObjectBuilder().add("name", "Jane") - .add("office", "Blue")) - .build()) - .add("Green", - Json.createArrayBuilder() - .add(Json.createObjectBuilder().add("name", "Peter") - .add("office", "Green")) - .add(Json.createObjectBuilder().add("name", "Peggy") - .add("office", "Green")) - .build()) - .build(); - TestUtil.logMsg(" Input: " + valueToString(OBJ_ARRAY_GROUP)); - final Collector, JsonObject> col = JsonCollectors - .groupingBy((JsonValue v) -> { - if (v.getValueType() == JsonValue.ValueType.OBJECT) - return v.asJsonObject().getString("office"); - throw new IllegalStateException("Value must be JsonObject"); - }); - final JsonObject out = OBJ_ARRAY_GROUP.getValuesAs(JsonObject.class) - .stream().collect(col); - if (operationFailed(out, check)) { - result.fail("groupingBy(Function)", "Output Stream value " - + valueToString(out) + " shall be " + valueToString(check)); - } - } - - /** - * Builder to create sorted JsonArray with ordering by {@code "name"} - * attribute of {@code JsonObject}. - */ - private class ValueBuilder implements JsonArrayBuilder { - - /** Sorted collection of values. */ - private final TreeSet values; - - private ValueBuilder() { - values = new TreeSet<>((JsonValue v1, JsonValue v2) -> { - if (v1.getValueType() == JsonValue.ValueType.OBJECT - && v1.getValueType() == JsonValue.ValueType.OBJECT) { - return v1.asJsonObject().getString("name") - .compareTo(v2.asJsonObject().getString("name")); - } - throw new IllegalStateException("Values must be JsonObject"); - }); - } - - /** - * Builder accumulator method. - * - * @param value - * Value to be added to {@code JsonArray}. - * @return This builder instance. - */ - @Override - public JsonArrayBuilder add(JsonValue value) { - values.add(value); - return this; - } - - /** - * Builder combiner method. - * - * @param builder - * Builder containing values to be added to {@code JsonArray}. - * @return This builder instance. - */ - public ValueBuilder addAll(ValueBuilder builder) { - values.addAll(builder.values); - return this; - } - - /** - * Builder finisher method. - * - * @return {@code JsonArray} from current builder content. - */ - @Override - public JsonArray build() { - JsonArrayBuilder builder = Json.createArrayBuilder(); - for (JsonValue value : values) { - builder.add(value); - } - return builder.build(); - } - - @Override - public JsonArrayBuilder add(String value) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder add(BigDecimal value) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder add(BigInteger value) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder add(int value) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder add(long value) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder add(double value) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder add(boolean value) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder addNull() { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder add(JsonObjectBuilder builder) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - @Override - public JsonArrayBuilder add(JsonArrayBuilder builder) { - throw new UnsupportedOperationException("Not supported yet."); // To - // change - // body of - // generated - // methods, - // choose - // Tools | - // Templates. - } - - } - - /** - * Test collector returned by - * {@code groupingBy(Function,Collector)} - * method. This collector allows grouping of {@code Stream} using - * provided {@code Function)} function to define group - * identifiers based on {@code JsonValue} content and - * {@code Collector)}. Test groups JSON - * objects in the stream by {@code "office"} attribute. External collector is - * building sorted {@code JsonArray} so arrays for each office group are - * sorted. - * - * @param result - * Tests result record. - */ - private void testSortingGroupingByCollector(final TestResult result) { - TestUtil.logMsg(" - Collector returned by groupingBy(Function,Collector)"); - final JsonObject check = Json.createObjectBuilder().add("Red", Json - .createArrayBuilder() - .add( - Json.createObjectBuilder().add("name", "John").add("office", "Red")) - .add( - Json.createObjectBuilder().add("name", "Rick").add("office", "Red")) - .add(Json.createObjectBuilder().add("name", "Sarah").add("office", - "Red")) - .build()) - .add("Blue", - Json.createArrayBuilder() - .add(Json.createObjectBuilder().add("name", "Bob").add("office", - "Blue")) - .add(Json.createObjectBuilder().add("name", "Jane") - .add("office", "Blue")) - .add(Json.createObjectBuilder().add("name", "Tom").add("office", - "Blue")) - .build()) - .add("Green", - Json.createArrayBuilder() - .add(Json.createObjectBuilder().add("name", "Peggy") - .add("office", "Green")) - .add(Json.createObjectBuilder().add("name", "Peter") - .add("office", "Green")) - .build()) - .build(); - Collector toArray = Collector.of( - ValueBuilder::new, JsonArrayBuilder::add, JsonArrayBuilder::addAll, - JsonArrayBuilder::build); - TestUtil.logMsg(" Input: " + valueToString(OBJ_ARRAY_GROUP)); - final Collector, JsonObject> col = JsonCollectors - .groupingBy((JsonValue v) -> { - if (v.getValueType() == JsonValue.ValueType.OBJECT) - return v.asJsonObject().getString("office"); - throw new IllegalStateException("Value must be JsonObject"); - }, toArray); - final JsonObject out = OBJ_ARRAY_GROUP.getValuesAs(JsonObject.class) - .stream().collect(col); - if (operationFailed(out, check)) { - result.fail("groupingBy(Function,Collector)", "Output Stream value " - + valueToString(out) + " shall be " + valueToString(check)); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - TestUtil.logMsg(" Checking " + valueToString(out)); - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/collectortests/build.xml b/src/com/sun/ts/tests/jsonp/api/collectortests/build.xml deleted file mode 100644 index 822de472a9..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/collectortests/build.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/exceptiontests/Client.java b/src/com/sun/ts/tests/jsonp/api/exceptiontests/Client.java deleted file mode 100644 index a20802285e..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/exceptiontests/Client.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.exceptiontests; - -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.common.JSONP_Util; -import com.sun.ts.tests.jsonp.common.MyJsonLocation; - -import jakarta.json.JsonException; -import jakarta.json.stream.JsonGenerationException; -import jakarta.json.stream.JsonLocation; -import jakarta.json.stream.JsonParsingException; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonExceptionConstructorTest1 - * - * @assertion_ids: JSONP:JAVADOC:37; - * - * @test_Strategy: Test API: JsonException ret = new JsonException(String) - */ - public void jsonExceptionConstructorTest1() throws Fault { - boolean pass = true; - - try { - String message = "This JSON is incorrect."; - - logMsg("Test JsonException(String)"); - JsonException exception = new JsonException(message); - try { - throw exception; - } catch (JsonException e) { - if (!e.getMessage().equals(message)) { - logErr("Incorrect message: expected " + message + ", received " - + e.getMessage()); - pass = false; - } - } - } catch (Exception e) { - throw new Fault("jsonExceptionConstructorTest1 Failed: ", e); - } - - if (!pass) - throw new Fault("jsonExceptionConstructorTest1 Failed:"); - } - - /* - * @testName: jsonExceptionConstructorTest2 - * - * @assertion_ids: JSONP:JAVADOC:38; - * - * @test_Strategy: Test API: JsonException ret = new JsonException(String, - * Throwable) - */ - public void jsonExceptionConstructorTest2() throws Fault { - boolean pass = true; - - try { - String message = "This JSON is incorrect due to foo."; - Exception foo = new Exception("This is a foo exception"); - - logMsg("Test JsonException(String, Throwable)"); - JsonException exception = new JsonException(message, foo); - - try { - throw exception; - } catch (JsonException e) { - if (!e.getCause().equals(foo)) { - logErr("Incorrect cause: expected " + foo + ", received " - + e.getCause()); - pass = false; - } - if (!e.getMessage().equals(message)) { - logErr("Incorrect message: expected " + message + ", received " - + e.getMessage()); - pass = false; - } - } - - } catch (Exception e) { - throw new Fault("jsonExceptionConstructorTest2 Failed: ", e); - } - - if (!pass) - throw new Fault("jsonExceptionConstructorTest2 Failed:"); - } - - /* - * @testName: jsonParsingExceptionConstructorTest1 - * - * @assertion_ids: JSONP:JAVADOC:285; JSONP:JAVADOC:478; JSONP:JAVADOC:474; - * JSONP:JAVADOC:475; JSONP:JAVADOC:476; - * - * @test_Strategy: Test API: JsonParsingException ret = new - * JsonParsingException(String, JsonLocation) - */ - public void jsonParsingExceptionConstructorTest1() throws Fault { - boolean pass = true; - - try { - String message = "This JSON is incorrect."; - MyJsonLocation expLoc = new MyJsonLocation(10, 20, 30); - logMsg("MyJsonLocation"); - JSONP_Util.dumpLocation(expLoc); - - logMsg("Test JsonParsingException(String, JsonLocation)"); - JsonParsingException exception = new JsonParsingException(message, - expLoc); - try { - throw exception; - } catch (JsonParsingException e) { - if (!e.getMessage().equals(message)) { - logErr("Incorrect message: expected " + message + ", received " - + e.getMessage()); - pass = false; - } - } - JsonLocation actLoc = exception.getLocation(); - logMsg("JsonParsingException.getLocation()"); - JSONP_Util.dumpLocation(actLoc); - if (!JSONP_Util.assertEquals(expLoc, actLoc)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParsingExceptionConstructorTest1 Failed: ", e); - } - - if (!pass) - throw new Fault("jsonParsingExceptionConstructorTest1 Failed:"); - } - - /* - * @testName: jsonParsingExceptionConstructorTest2 - * - * @assertion_ids: JSONP:JAVADOC:286; JSONP:JAVADOC:478; JSONP:JAVADOC:474; - * JSONP:JAVADOC:475; JSONP:JAVADOC:476; - * - * @test_Strategy: Test API: JsonParsingException ret = new - * JsonParsingException(String, Throwable, JsonLocation) - */ - public void jsonParsingExceptionConstructorTest2() throws Fault { - boolean pass = true; - - try { - String message = "This JSON is incorrect due to foo."; - Exception foo = new Exception("This is a foo exception"); - MyJsonLocation expLoc = new MyJsonLocation(10, 20, 30); - logMsg("MyJsonLocation"); - JSONP_Util.dumpLocation(expLoc); - - logMsg("Test JsonParsingException(String, Throwable)"); - JsonParsingException exception = new JsonParsingException(message, foo, - expLoc); - - try { - throw exception; - } catch (JsonParsingException e) { - if (!e.getCause().equals(foo)) { - logErr("Incorrect cause: expected " + foo + ", received " - + e.getCause()); - pass = false; - } - if (!e.getMessage().equals(message)) { - logErr("Incorrect message: expected " + message + ", received " - + e.getMessage()); - pass = false; - } - } - JsonLocation actLoc = exception.getLocation(); - logMsg("JsonParsingException.getLocation()"); - JSONP_Util.dumpLocation(actLoc); - if (!JSONP_Util.assertEquals(expLoc, actLoc)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParsingExceptionConstructorTest2 Failed: ", e); - } - - if (!pass) - throw new Fault("jsonParsingExceptionConstructorTest2 Failed:"); - } - - /* - * @testName: jsonGenerationExceptionConstructorTest1 - * - * @assertion_ids: JSONP:JAVADOC:278; - * - * @test_Strategy: Test API: JsonGenerationException ret = new - * JsonGenerationException(String) - */ - public void jsonGenerationExceptionConstructorTest1() throws Fault { - boolean pass = true; - - try { - String message = "This JSON is incorrect."; - - logMsg("Test JsonGenerationException(String)"); - JsonGenerationException exception = new JsonGenerationException(message); - try { - throw exception; - } catch (JsonGenerationException e) { - if (!e.getMessage().equals(message)) { - logErr("Incorrect message: expected " + message + ", received " - + e.getMessage()); - pass = false; - } - } - } catch (Exception e) { - throw new Fault("jsonGenerationExceptionConstructorTest1 Failed: ", e); - } - - if (!pass) - throw new Fault("jsonGenerationExceptionConstructorTest1 Failed:"); - } - - /* - * @testName: jsonGenerationExceptionConstructorTest2 - * - * @assertion_ids: JSONP:JAVADOC:279; - * - * @test_Strategy: Test API: JsonGenerationException ret = new - * JsonGenerationException(String, Throwable) - */ - public void jsonGenerationExceptionConstructorTest2() throws Fault { - boolean pass = true; - - try { - String message = "This JSON is incorrect due to foo."; - Exception foo = new Exception("This is a foo exception"); - - logMsg("Test JsonGenerationException(String, Throwable)"); - JsonGenerationException exception = new JsonGenerationException(message, - foo); - - try { - throw exception; - } catch (JsonGenerationException e) { - if (!e.getCause().equals(foo)) { - logErr("Incorrect cause: expected " + foo + ", received " - + e.getCause()); - pass = false; - } - if (!e.getMessage().equals(message)) { - logErr("Incorrect message: expected " + message + ", received " - + e.getMessage()); - pass = false; - } - } - - } catch (Exception e) { - throw new Fault("jsonGenerationExceptionConstructorTest2 Failed: ", e); - } - - if (!pass) - throw new Fault("jsonGenerationExceptionConstructorTest2 Failed:"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/exceptiontests/build.xml b/src/com/sun/ts/tests/jsonp/api/exceptiontests/build.xml deleted file mode 100644 index 80658364b0..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/exceptiontests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildAdd.java b/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildAdd.java deleted file mode 100644 index 22a72dcdde..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildAdd.java +++ /dev/null @@ -1,650 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonarraytests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BDC_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BIN_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_FALSE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_TRUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DBL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.LNG_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.ArrayBuilder; -import com.sun.ts.tests.jsonp.api.common.JsonIO; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests: - * {@link JsonArrayBuilder} API add() methods added in JSON-P 1.1.
- */ -public class ArrayBuildAdd extends ArrayCommon { - - /** - * Creates an instance of {@link JsonArrayBuilder} API add() methods added in - * JSON-P 1.1 test. - */ - ArrayBuildAdd() { - super(); - } - - /** - * Test {@link JsonArrayBuilder} API add() methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonArrayBuilder API add() methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonArrayBuilder API add() methods added in JSON-P 1.1."); - testAdd(result); - testAddNullBuilder(result); - testAddOutOfBounds(result); - testAddNull(result); - testAddNullOutOfBounds(result); - testAddArrayBuilder(result); - testAddArrayBuilderNull(result); - testAddArrayBuilderOutOfBounds(result); - testAddObjectBuilder(result); - testAddObjectBuilderNull(result); - testAddObjectBuilderOutOfBounds(result); - testAddAllString(result); - testAddAllInt(result); - testAddAllBool(result); - testAddAllObject(result); - testAddAllNull(result); - return result; - } - - /** - * Test {@code default JsonArrayBuilder add(int, Object)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testAdd(final TestResult result) { - final Object[] values = new Object[] { OBJ_VALUE, // add(int,JsonValue) - STR_VALUE, // add(int,String) - INT_VALUE, // add(int,int) - LNG_VALUE, // add(int,long) - DBL_VALUE, // add(int,double) - BIN_VALUE, // add(int,BigInteger) - BDC_VALUE, // add(int,BigDecimal) - BOOL_VALUE // add(int,boolean) - }; - for (Object value : values) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg(" - add(int," + typeName + ")"); - final String json = "[" + JsonValueType.toStringValue(value) + "]"; - final JsonValue check = JsonIO.read(json); - final JsonArrayBuilder builder = createArrayBuilder(0, value); - final JsonValue out = builder.build(); - if (operationFailed(check, out)) { - result.fail("add(" + typeName + ")", "Builder output " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - } - - /** - * Test {@code JsonArrayBuilder add(int, Object)} method on {@code String} - * array with index being out of range - * ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testAddOutOfBounds(final TestResult result) { - final Object[] values = new Object[] { OBJ_VALUE, // add(int,JsonValue) - STR_VALUE, // add(int,String) - INT_VALUE, // add(int,int) - LNG_VALUE, // add(int,long) - DBL_VALUE, // add(int,double) - BIN_VALUE, // add(int,BigInteger) - BDC_VALUE, // add(int,BigDecimal) - BOOL_VALUE // add(int,boolean) - }; - final int[] indexes = new int[] { -1, 2, 3 }; - for (Object value : values) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg(" - add(int," + typeName + ")"); - final String json = "[" + JsonValueType.toStringValue(value) + "]"; - // Add value into the array for the first time to het array of size 1. - JsonArrayBuilder builder = createArrayBuilder(value); - for (int index : indexes) { - try { - // Add value on out of bounds index - builder = updateOperationBuilder(builder, index, value); - result.fail("add(int," + typeName + ")", - "Calling method with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("add(int,(" + typeName + ")null)", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - } - - /** - * Test {@code JsonArrayBuilder add(int, Object)} method on {@code String} - * array with null value. - * - * @param result - * Test suite result. - */ - private void testAddNullBuilder(final TestResult result) { - final JsonValueType[] types = new JsonValueType[] { JsonValueType.JsonValue, // add(int,(JsonValue)null) - JsonValueType.String, // add(int,(String)null) - JsonValueType.BigInteger, // add(int,(BigInteger)null) - JsonValueType.BigDecimal // add(int,(BigDecimal)null) - }; - for (JsonValueType type : types) { - final String typeName = type.name(); - TestUtil.logMsg(" - add(int,(" + typeName + ")null)"); - try { - ArrayBuilder.add(Json.createArrayBuilder(), 0, type); - result.fail("add(int,(" + typeName + ")null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("add(int,(" + typeName + ")null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonArrayBuilder addNull(int)} method on {@code String} array. - * - * @param result - * Test suite result. - */ - private void testAddNull(final TestResult result) { - TestUtil.logMsg(" - addNull(int)"); - final Object value = null; - final String json = "[" + JsonValueType.toStringValue(value) + "]"; - final JsonValue check = JsonIO.read(json); - final JsonArrayBuilder builder = createArrayBuilder(0, value); - final JsonValue out = builder.build(); - if (operationFailed(check, out)) { - result.fail("addNull(int)", "Builder output " + valueToString(out) - + " value shall be " + valueToString(check)); - } - } - - /** - * Test {@code JsonArrayBuilder addNull(int)} method on {@code String} array - * with index being out of range ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testAddNullOutOfBounds(final TestResult result) { - final int[] indexes = new int[] { -1, 2, 3 }; - TestUtil.logMsg(" - addNull(int)"); - final Object value = null; - JsonArrayBuilder builder = createArrayBuilder(value); - for (int index : indexes) { - try { - // Add value on out of bounds index - builder = updateOperationBuilder(builder, index, value); - result.fail("addNull(int)", "Calling method with out of bounds index=" - + index + " argument shall throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("addNull(int)", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonArrayBuilder add(int,JsonArrayBuilder)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testAddArrayBuilder(final TestResult result) { - TestUtil.logMsg(" - add(int,JsonArrayBuilder)"); - final JsonValue checkBeg = JsonIO - .read("[[" + JsonValueType.toStringValue(STR_VALUE_1) + "," - + JsonValueType.toStringValue(STR_VALUE_2) + "," - + JsonValueType.toStringValue(STR_VALUE_3) + "," - + JsonValueType.toStringValue(STR_VALUE_4) + "]," - + JsonValueType.toStringValue(STR_VALUE_5) + "]"); - final JsonValue checkEnd = JsonIO - .read("[" + JsonValueType.toStringValue(STR_VALUE_1) + ",[" - + JsonValueType.toStringValue(STR_VALUE_2) + "," - + JsonValueType.toStringValue(STR_VALUE_3) + "," - + JsonValueType.toStringValue(STR_VALUE_4) + "," - + JsonValueType.toStringValue(STR_VALUE_5) + "]]"); - final JsonArrayBuilder inBeg = createArrayBuilder(STR_VALUE_5); - final JsonArrayBuilder inEnd = createArrayBuilder(STR_VALUE_1); - final JsonArrayBuilder argBeg = createArrayBuilder(STR_VALUE_1) - .add(STR_VALUE_2).add(STR_VALUE_3).add(STR_VALUE_4); - final JsonArrayBuilder argEnd = createArrayBuilder(STR_VALUE_2) - .add(STR_VALUE_3).add(STR_VALUE_4).add(STR_VALUE_5); - verifyAddBuilder(result, checkBeg, 0, argBeg, inBeg); - verifyAddBuilder(result, checkEnd, 1, argEnd, inEnd); - } - - /** - * Test {@code JsonArrayBuilder add(int,(JsonArrayBuilder)null)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testAddArrayBuilderNull(final TestResult result) { - TestUtil.logMsg(" - add(int,(JsonArrayBuilder)null)"); - final JsonArrayBuilder in = createArrayBuilder(DEF_VALUE); - final JsonArrayBuilder arg = null; - try { - in.add(0, arg); - result.fail("add(int,(JsonArrayBuilder)null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("add(int,(JsonArrayBuilder)null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test {@code JsonArrayBuilder add(int,JsonArrayBuilder)} method on - * {@code String} array with index being out of range - * ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testAddArrayBuilderOutOfBounds(final TestResult result) { - TestUtil.logMsg(" - add(int,JsonArrayBuilder)"); - final int[] indexes = new int[] { -1, 5, 6 }; - final JsonArrayBuilder in = createArrayBuilder(STR_VALUE_1).add(STR_VALUE_2) - .add(STR_VALUE_3).add(STR_VALUE_4); - final JsonArrayBuilder arg = createArrayBuilder(STR_VALUE_5); - for (int index : indexes) { - try { - // Add value on out of bounds index - in.add(index, arg); - result.fail("add(int,JsonArrayBuilder)", - "Calling method with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("add(int,JsonArrayBuilder)", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonArrayBuilder add(int,JsonObjectBuilder)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testAddObjectBuilder(final TestResult result) { - TestUtil.logMsg(" - add(int,JsonObjectBuilder)"); - final JsonValue checkBeg = JsonIO - .read("[{" + JsonValueType.toStringValue(STR_NAME) + ":" - + JsonValueType.toStringValue(STR_VALUE) + "}," - + JsonValueType.toStringValue(STR_VALUE_1) + "]"); - final JsonValue checkEnd = JsonIO - .read("[" + JsonValueType.toStringValue(STR_VALUE_1) + ",{" - + JsonValueType.toStringValue(STR_NAME) + ":" - + JsonValueType.toStringValue(STR_VALUE) + "}]"); - final JsonArrayBuilder inBeg = createArrayBuilder(STR_VALUE_1); - final JsonArrayBuilder inEnd = createArrayBuilder(STR_VALUE_1); - final JsonObjectBuilder argBeg = Json.createObjectBuilder().add(STR_NAME, - STR_VALUE); - final JsonObjectBuilder argEnd = Json.createObjectBuilder().add(STR_NAME, - STR_VALUE); - verifyAddBuilder(result, checkBeg, 0, argBeg, inBeg); - verifyAddBuilder(result, checkEnd, 1, argEnd, inEnd); - } - - /** - * Test {@code JsonArrayBuilder add(int,(JsonObjectBuilder)null)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testAddObjectBuilderNull(final TestResult result) { - TestUtil.logMsg(" - add(int,(JsonObjectBuilder)null)"); - final JsonArrayBuilder in = createArrayBuilder(DEF_VALUE); - final JsonObjectBuilder arg = null; - try { - in.add(0, arg); - result.fail("add(int,(JsonObjectBuilder)null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("add(int,(JsonObjectBuilder)null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test {@code JsonArrayBuilder add(int,JsonObjectBuilder)} method on - * {@code String} array with index being out of range - * ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testAddObjectBuilderOutOfBounds(final TestResult result) { - TestUtil.logMsg(" - add(int,JsonObjectBuilder)"); - final int[] indexes = new int[] { -1, 5, 6 }; - final JsonArrayBuilder in = createArrayBuilder(STR_VALUE_1).add(STR_VALUE_2) - .add(STR_VALUE_3).add(STR_VALUE_4); - final JsonObjectBuilder arg = Json.createObjectBuilder().add(STR_NAME, - STR_VALUE); - for (int index : indexes) { - try { - // Add value on out of bounds index - in.add(index, arg); - result.fail("add(int,JsonObjectBuilder)", - "Calling method with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("add(int,JsonObjectBuilder)", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonArrayBuilder)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testAddAllString(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonArrayBuilder) for String array"); - final JsonArray check = createSimpleStringArray5(); - final String[] strings = new String[] { STR_VALUE_1, STR_VALUE_2, - STR_VALUE_3, STR_VALUE_4, STR_VALUE_5 }; - verifyAddAll(result, check, strings); - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonArrayBuilder)} method on - * {@code int) array. @param result Test suite result. - */ - private void testAddAllInt(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonArrayBuilder) for int array"); - final JsonArray check = createSimpleIntArray5(); - final Integer[] ints = new Integer[] { INT_VALUE_1, INT_VALUE_2, - INT_VALUE_3, INT_VALUE_4, INT_VALUE_5 }; - verifyAddAll(result, check, ints); - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonArrayBuilder)} method on - * {@code boolean) array. @param result Test suite result. - */ - private void testAddAllBool(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonArrayBuilder) for boolean array"); - final JsonArray check = createSimpleBoolArray5(); - final Boolean[] bools = new Boolean[] { BOOL_FALSE, BOOL_TRUE, BOOL_TRUE, - BOOL_FALSE, BOOL_TRUE }; - verifyAddAll(result, check, bools); - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonArrayBuilder)} method on - * {@code JsonObject) array. @param result Test suite result. - */ - private void testAddAllObject(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonArrayBuilder) for JsonObject array"); - final JsonArray check = createSimpleObjectArray5(); - final JsonObject[] bools = new JsonObject[] { OBJ_VALUE_1, OBJ_VALUE_2, - OBJ_VALUE_3, OBJ_VALUE_4, OBJ_VALUE_5 }; - verifyAddAll(result, check, bools); - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonArrayBuilder)} method on - * {@code null} builder argument. - * - * @param result - * Test suite result. - */ - private void testAddAllNull(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonArrayBuilder) for null builder argument"); - JsonArrayBuilder builder = Json.createArrayBuilder(); - try { - builder.addAll((JsonArrayBuilder) null); - result.fail("addAll(null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("addAll(null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test helper: Verify - * {@code default JsonArrayBuilder addAll(JsonArrayBuilder)} method on - * provided array. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param values - * Values used to build JSON array builder. - */ - private void verifyAddAll(final TestResult result, final JsonArray check, - final Object[] values) { - JsonArrayBuilder builderIn = Json.createArrayBuilder(); - for (Object value : values) { - builderIn = updateOperationBuilder(builderIn, value); - } - final JsonArrayBuilder builderOut = Json.createArrayBuilder(); - builderOut.addAll(builderIn); - final JsonArray out = builderOut.build(); - if (operationFailed(check, out)) { - result.fail("addAll(JsonArrayBuilder)", "Output builder " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test helper: Verify - * {@code default JsonArrayBuilder add(int,JsonArrayBuilder)} method on - * provided builders. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param src - * Source builder (the one to be added). - * @param target - * Target builder (to which to add). - */ - private void verifyAddBuilder(final TestResult result, final JsonValue check, - final int index, final JsonArrayBuilder src, - final JsonArrayBuilder target) { - final JsonArray out = target.add(index, src).build(); - if (operationFailed(check, out)) { - result.fail("add(int,JsonArrayBuilder)", "Output builder " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test helper: Verify - * {@code default JsonArrayBuilder add(int,JsonObjectBuilder)} method on - * provided builders. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param src - * Source builder (the one to be added). - * @param target - * Target builder (to which to add). - */ - private void verifyAddBuilder(final TestResult result, final JsonValue check, - final int index, final JsonObjectBuilder src, - final JsonArrayBuilder target) { - final JsonArray out = target.add(index, src).build(); - if (operationFailed(check, out)) { - result.fail("add(int,JsonObjectBuilder)", "Output builder " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Create and initialize array builder to contain single value. Child class - * callback. - * - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder containing value. - */ - @Override - protected JsonArrayBuilder createArrayBuilder(final Object value) { - return ArrayBuilder.add(Json.createArrayBuilder(), value); - } - - /** - * Create and initialize array builder to contain single value. Child class - * callback. - * - * @param index - * Position in the array where value is added. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder containing value. - */ - @Override - protected JsonArrayBuilder createArrayBuilder(final int index, - final Object value) { - return ArrayBuilder.add(Json.createArrayBuilder(), index, value); - } - - /** - * Update array builder to contain next value. Child class callback. - * - * @param builder - * JSON array builder to update. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder with value updated. - */ - @Override - protected JsonArrayBuilder updateOperationBuilder( - final JsonArrayBuilder builder, final Object value) { - return ArrayBuilder.add(builder, value); - } - - /** - * Update array builder to contain next value. Child class callback. - * - * @param builder - * JSON array builder to update. - * @param index - * Position in the array where value is added. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder with value updated. - */ - @Override - protected JsonArrayBuilder updateOperationBuilder( - final JsonArrayBuilder builder, final int index, final Object value) { - return ArrayBuilder.add(builder, index, value); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildRemove.java b/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildRemove.java deleted file mode 100644 index 41e21fc70e..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildRemove.java +++ /dev/null @@ -1,216 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonarraytests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BDC_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BIN_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DBL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.LNG_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.ArrayBuilder; -import com.sun.ts.tests.jsonp.api.common.JsonIO; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests: - * {@link JsonArrayBuilder} API remove() methods added in JSON-P 1.1.
- */ -public class ArrayBuildRemove extends ArrayCommon { - - /** - * Creates an instance of {@link JsonArrayBuilder} API remove() methods added - * in JSON-P 1.1 test. - */ - ArrayBuildRemove() { - super(); - } - - /** - * {@link JsonArrayBuilder} API remove() methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonArrayBuilder API remove() methods added in JSON-P 1.1."); - TestUtil - .logMsg("JsonArrayBuilder API remove() methods added in JSON-P 1.1."); - testRemove(result); - testRemoveOutOfBounds(result); - return result; - } - - /** - * Test {@code default JsonArrayBuilder remove(int, Object)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testRemove(final TestResult result) { - final Object[] values = new Object[] { OBJ_VALUE, // remove(int,JsonValue) - STR_VALUE, // remove(int,String) - INT_VALUE, // remove(int,int) - LNG_VALUE, // remove(int,long) - DBL_VALUE, // remove(int,double) - BIN_VALUE, // remove(int,BigInteger) - BDC_VALUE, // remove(int,BigDecimal) - BOOL_VALUE // remove(int,boolean) - }; - for (Object value : values) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg(" - remove(int," + typeName + ")"); - final String json = "[]"; - final JsonValue check = JsonIO.read(json); - JsonArrayBuilder builder = ArrayBuilder.add(Json.createArrayBuilder(), - value); - builder = updateOperationBuilder(builder, 0, null); - final JsonValue out = builder.build(); - if (operationFailed(check, out)) { - result.fail("remove(" + typeName + ")", "Builder output " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - } - - /** - * Test {@code default JsonArrayBuilder remove(int, Object)} method on - * {@code String} array with index being out of range - * ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testRemoveOutOfBounds(final TestResult result) { - final Object[] values = new Object[] { OBJ_VALUE, // remove(int,JsonValue) - STR_VALUE, // remove(int,String) - INT_VALUE, // remove(int,int) - LNG_VALUE, // remove(int,long) - DBL_VALUE, // remove(int,double) - BIN_VALUE, // remove(int,BigInteger) - BDC_VALUE, // remove(int,BigDecimal) - BOOL_VALUE // remove(int,boolean) - }; - final int[] indexes = new int[] { -1, 2, 3 }; - for (Object value : values) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg(" - remove(int," + typeName + ")"); - final String json = "[" + JsonValueType.toStringValue(value) + "]"; - // Add value into the array for the first time to het array of size 1. - JsonArrayBuilder builder = ArrayBuilder.add(Json.createArrayBuilder(), - value); - for (int index : indexes) { - try { - // Add value on out of bounds index - builder = updateOperationBuilder(builder, index, null); - result.fail("remove(int," + typeName + ")", - "Calling method with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("remove(int,(" + typeName + ")null)", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - } - - /** - * Create and initialize array builder. Unsupported method call for remove() - * method. - * - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder containing value. - */ - @Override - protected JsonArrayBuilder createArrayBuilder(Object value) { - throw new UnsupportedOperationException( - "Method remove is not implemented."); - } - - /** - * Create and initialize array builder. Unsupported method call for remove() - * method. - * - * @param index - * Position in the array where value is added. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder containing value. - */ - @Override - protected JsonArrayBuilder createArrayBuilder(final int index, - final Object value) { - throw new UnsupportedOperationException( - "Method remove is not implemented."); - } - - /** - * Update array builder. Unsupported method call for remove() method. - * - * @param builder - * JSON array builder to update. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder with value updated. - */ - @Override - protected JsonArrayBuilder updateOperationBuilder(JsonArrayBuilder builder, - Object value) { - throw new UnsupportedOperationException( - "Method remove is not implemented."); - } - - /** - * Update array builder with value removal at specified index. Child class - * callback. - * - * @param builder - * JSON array builder to update. - * @param index - * Position in the array where value is added. - * @param value - * JSON value argument is ignored. - * @return JSON array builder with value updated. - */ - @Override - protected JsonArrayBuilder updateOperationBuilder( - final JsonArrayBuilder builder, final int index, final Object value) { - return ArrayBuilder.remove(builder, index); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildSet.java b/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildSet.java deleted file mode 100644 index da856c2590..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuildSet.java +++ /dev/null @@ -1,511 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonarraytests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BDC_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BIN_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DBL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.LNG_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.ArrayBuilder; -import com.sun.ts.tests.jsonp.api.common.JsonIO; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonObjectBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests: - * {@link JsonArrayBuilder} API set() methods added in JSON-P 1.1.
- */ -public class ArrayBuildSet extends ArrayCommon { - - /** - * Creates an instance of {@link JsonArrayBuilder} API set() methods added in - * JSON-P 1.1 test. - */ - ArrayBuildSet() { - super(); - } - - /** - * {@link JsonArrayBuilder} API set() methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonArrayBuilder API set() methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonArrayBuilder API set() methods added in JSON-P 1.1."); - testSet(result); - testSetOutOfBounds(result); - testSetNullBuilder(result); - testSetNull(result); - testSetNullOutOfBounds(result); - testSetArrayBuilder(result); - testSetArrayBuilderNull(result); - testSetArrayBuilderOutOfBounds(result); - testSetObjectBuilder(result); - testSetObjectBuilderNull(result); - testSetObjectBuilderOutOfBounds(result); - return result; - } - - /** - * Test {@code default JsonArrayBuilder set(int, Object)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testSet(final TestResult result) { - final Object[] values = new Object[] { OBJ_VALUE, // set(int,JsonValue) - STR_VALUE, // set(int,String) - INT_VALUE, // set(int,int) - LNG_VALUE, // set(int,long) - DBL_VALUE, // set(int,double) - BIN_VALUE, // set(int,BigInteger) - BDC_VALUE, // set(int,BigDecimal) - BOOL_VALUE // set(int,boolean) - }; - for (Object value : values) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg(" - set(int," + typeName + ")"); - final String json = "[" + JsonValueType.toStringValue(value) + "]"; - final JsonValue check = JsonIO.read(json); - final JsonArrayBuilder builder = updateOperationBuilder( - Json.createArrayBuilder().add(DEF_OBJ_VALUE), 0, value); - final JsonValue out = builder.build(); - if (operationFailed(check, out)) { - result.fail("set(" + typeName + ")", "Builder output " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - } - - /** - * Test {@code default JsonArrayBuilder set(int, Object)} method on - * {@code String} array with index being out of range - * ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testSetOutOfBounds(final TestResult result) { - final Object[] values = new Object[] { OBJ_VALUE, // set(int,JsonValue) - STR_VALUE, // set(int,String) - INT_VALUE, // set(int,int) - LNG_VALUE, // set(int,long) - DBL_VALUE, // set(int,double) - BIN_VALUE, // set(int,BigInteger) - BDC_VALUE, // set(int,BigDecimal) - BOOL_VALUE // set(int,boolean) - }; - final int[] indexes = new int[] { -1, 2, 3 }; - for (Object value : values) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg(" - set(int," + typeName + ")"); - final String json = "[" + JsonValueType.toStringValue(value) + "]"; - JsonArrayBuilder builder = ArrayBuilder.add(Json.createArrayBuilder(), - DEF_OBJ_VALUE); - for (int index : indexes) { - try { - builder = updateOperationBuilder( - Json.createArrayBuilder().add(DEF_OBJ_VALUE), index, value); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("set(int," + typeName + ")", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - } - - /** - * Test {@code default JsonArrayBuilder set(int, Object)} method on - * {@code String} array with null value. - * - * @param result - * Test suite result. - */ - private void testSetNullBuilder(final TestResult result) { - final JsonValueType[] types = new JsonValueType[] { JsonValueType.JsonValue, // set(int,(JsonValue)null) - JsonValueType.String, // set(int,(String)null) - JsonValueType.BigInteger, // set(int,(BigInteger)null) - JsonValueType.BigDecimal // set(int,(BigDecimal)null) - }; - for (JsonValueType type : types) { - final String typeName = type.name(); - TestUtil.logMsg(" - set(int,(" + typeName + ")null)"); - try { - ArrayBuilder.set(Json.createArrayBuilder(), 0, type); - result.fail("set(int,(" + typeName + ")null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("set(int,(" + typeName + ")null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code default JsonArrayBuilder setNull(int)} method on {@code String} - * array. - * - * @param result - * Test suite result. - */ - private void testSetNull(final TestResult result) { - TestUtil.logMsg(" - setNull(int)"); - final Object value = null; - final String json = "[" + JsonValueType.toStringValue(null) + "]"; - final JsonValue check = JsonIO.read(json); - final JsonArrayBuilder builder = ArrayBuilder - .set(Json.createArrayBuilder().add(DEF_OBJ_VALUE), 0, value); - final JsonValue out = builder.build(); - if (operationFailed(check, out)) { - result.fail("setNull(int)", "Builder output " + valueToString(out) - + " value shall be " + valueToString(check)); - } - } - - /** - * Test {@code default JsonArrayBuilder setNull(int)} method on {@code String} - * array with index being out of range - * ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testSetNullOutOfBounds(final TestResult result) { - final int[] indexes = new int[] { -1, 2, 3 }; - TestUtil.logMsg(" - setNull(int)"); - final Object value = null; - JsonArrayBuilder builder = ArrayBuilder.add(Json.createArrayBuilder(), - value); - for (int index : indexes) { - try { - // Add value on out of bounds index - builder = updateOperationBuilder(builder, index, value); - result.fail("setNull(int)", "Calling method with out of bounds index=" - + index + " argument shall throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("setNull(int)", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code default JsonArrayBuilder set(int,JsonArrayBuilder)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testSetArrayBuilder(final TestResult result) { - TestUtil.logMsg(" - set(int,JsonArrayBuilder)"); - final JsonValue check = JsonIO - .read("[[" + JsonValueType.toStringValue(STR_VALUE_1) + "," - + JsonValueType.toStringValue(STR_VALUE_2) + "," - + JsonValueType.toStringValue(STR_VALUE_3) + "," - + JsonValueType.toStringValue(STR_VALUE_4) + "]]"); - final JsonArrayBuilder in = Json.createArrayBuilder().add(STR_VALUE_5); - final JsonArrayBuilder arg = Json.createArrayBuilder().add(STR_VALUE_1) - .add(STR_VALUE_2).add(STR_VALUE_3).add(STR_VALUE_4); - verifySetBuilder(result, check, 0, arg, in); - } - - /** - * Test {@code default JsonArrayBuilder set(int,(JsonArrayBuilder)null)} - * method on {@code String} array. - * - * @param result - * Test suite result. - */ - private void testSetArrayBuilderNull(final TestResult result) { - TestUtil.logMsg(" - set(int,(JsonArrayBuilder)null)"); - final JsonArrayBuilder in = Json.createArrayBuilder().add(DEF_VALUE); - final JsonArrayBuilder arg = null; - try { - in.set(0, arg); - result.fail("set(int,(JsonArrayBuilder)null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("set(int,(JsonArrayBuilder)null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test {@code default JsonArrayBuilder set(int,JsonArrayBuilder)} method on - * {@code String} array with index being out of range - * ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testSetArrayBuilderOutOfBounds(final TestResult result) { - TestUtil.logMsg(" - set(int,JsonArrayBuilder)"); - final int[] indexes = new int[] { -1, 5, 6 }; - final JsonArrayBuilder in = Json.createArrayBuilder().add(STR_VALUE_1) - .add(STR_VALUE_2).add(STR_VALUE_3).add(STR_VALUE_4); - final JsonArrayBuilder arg = Json.createArrayBuilder().add(STR_VALUE_5); - for (int index : indexes) { - try { - // Add value on out of bounds index - in.set(index, arg); - result.fail("set(int,JsonArrayBuilder)", - "Calling method with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("set(int,JsonArrayBuilder)", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code default JsonArrayBuilder set(int,JsonObjectBuilder)} method on - * {@code String} array. - * - * @param result - * Test suite result. - */ - private void testSetObjectBuilder(final TestResult result) { - TestUtil.logMsg(" - set(int,JsonObjectBuilder)"); - final JsonValue check = JsonIO - .read("[{" + JsonValueType.toStringValue(STR_NAME) + ":" - + JsonValueType.toStringValue(STR_VALUE) + "}]"); - final JsonArrayBuilder in = Json.createArrayBuilder().add(STR_VALUE_1); - final JsonObjectBuilder arg = Json.createObjectBuilder().add(STR_NAME, - STR_VALUE); - verifySetBuilder(result, check, 0, arg, in); - } - - /** - * Test {@code default JsonArrayBuilder set(int,(JsonObjectBuilder)null)} - * method on {@code String} array. - * - * @param result - * Test suite result. - */ - private void testSetObjectBuilderNull(final TestResult result) { - TestUtil.logMsg(" - set(int,(JsonObjectBuilder)null)"); - final JsonArrayBuilder in = Json.createArrayBuilder().add(DEF_VALUE); - final JsonObjectBuilder arg = null; - try { - in.set(0, arg); - result.fail("set(int,(JsonObjectBuilder)null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("set(int,(JsonObjectBuilder)null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test {@code default JsonArrayBuilder set(int,JsonObjectBuilder)} method on - * {@code String} array with index being out of range - * ({@code index < 0 || index > array size}). - * - * @param result - * Test suite result. - */ - private void testSetObjectBuilderOutOfBounds(final TestResult result) { - TestUtil.logMsg(" - set(int,JsonObjectBuilder)"); - final int[] indexes = new int[] { -1, 5, 6 }; - final JsonArrayBuilder in = Json.createArrayBuilder().add(STR_VALUE_1) - .add(STR_VALUE_2).add(STR_VALUE_3).add(STR_VALUE_4); - final JsonObjectBuilder arg = Json.createObjectBuilder().add(STR_NAME, - STR_VALUE); - for (int index : indexes) { - try { - // Add value on out of bounds index - in.set(index, arg); - result.fail("set(int,JsonObjectBuilder)", - "Calling method with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - TestUtil.logMsg(" - Expected exception for index=" + index + ": " - + e.getMessage()); - } catch (Throwable t) { - result.fail("set(int,JsonObjectBuilder)", - "Calling method with with out of bounds index=" + index - + " argument shall throw IndexOutOfBoundsException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test helper: Verify - * {@code default JsonArrayBuilder set(int,JsonArrayBuilder)} method on - * provided builders. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param src - * Source builder (the one to be added). - * @param target - * Target builder (to which to add). - */ - private void verifySetBuilder(final TestResult result, final JsonValue check, - final int index, final JsonArrayBuilder src, - final JsonArrayBuilder target) { - final JsonArray out = target.set(index, src).build(); - if (operationFailed(check, out)) { - result.fail("set(int,JsonArrayBuilder)", "Output builder " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test helper: Verify - * {@code default JsonArrayBuilder set(int,JsonObjectBuilder)} method on - * provided builders. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param src - * Source builder (the one to be added). - * @param target - * Target builder (to which to add). - */ - private void verifySetBuilder(final TestResult result, final JsonValue check, - final int index, final JsonObjectBuilder src, - final JsonArrayBuilder target) { - final JsonArray out = target.set(index, src).build(); - if (operationFailed(check, out)) { - result.fail("set(int,JsonObjectBuilder)", "Output builder " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Create and initialize array builder to contain single value. Unsupported - * method call for set() method. - * - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder containing value. - */ - @Override - protected JsonArrayBuilder createArrayBuilder(Object value) { - throw new UnsupportedOperationException("Method set is not implemented."); - } - - /** - * Create and initialize array builder to contain single value. Child class - * callback. - * - * @param index - * Position in the array where value is added. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder containing value. - */ - @Override - protected JsonArrayBuilder createArrayBuilder(final int index, - final Object value) { - return ArrayBuilder.set(Json.createArrayBuilder(), index, value); - } - - /** - * Update array builder to contain next value. Unsupported method call for - * set() method. - * - * @param builder - * JSON array builder to update. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder with value updated. - */ - @Override - protected JsonArrayBuilder updateOperationBuilder(JsonArrayBuilder builder, - Object value) { - throw new UnsupportedOperationException("Method set is not implemented."); - } - - /** - * Update array builder to contain next value. Child class callback. - * - * @param builder - * JSON array builder to update. - * @param index - * Position in the array where value is added. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder with value updated. - */ - @Override - protected JsonArrayBuilder updateOperationBuilder( - final JsonArrayBuilder builder, final int index, final Object value) { - return ArrayBuilder.set(builder, index, value); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuilders.java b/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuilders.java deleted file mode 100644 index 858ad42dd0..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayBuilders.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (c) 2017, 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 com.sun.ts.tests.jsonp.api.jsonarraytests; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import java.util.ArrayList; -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonString; -import jakarta.json.JsonValue; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.*; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.*; -import java.util.Iterator; -import java.util.List; -import jakarta.json.JsonNumber; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests: - * {@link JsonArrayBuilder} API factory methods added in JSON-P 1.1.
- */ -public class ArrayBuilders { - - /** - * Creates an instance of {@link JsonArrayBuilder} API factory methods added - * in JSON-P 1.1 test. - */ - ArrayBuilders() { - super(); - } - - /** - * Test {@link JsonArrayBuilder} factory method added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonArrayBuilder API factory methods added in JSON-P 1.1."); - TestUtil - .logMsg("JsonArrayBuilder API factory methods added in JSON-P 1.1."); - testCreateFromCollection(result); - testCreateFromJsonArray(result); - testGetStringValuesAs(result); - testGetIntValuesAs(result); - return result; - } - - /** - * Test {@link Json#createArrayBuilder(Collection)} method. - * - * @param result - * Test suite result. - */ - private void testCreateFromCollection(final TestResult result) { - TestUtil.logMsg(" - Json#createArrayBuilder(Collection)"); - final JsonArray check = createSimpleStringArray5(); - final ArrayList values = new ArrayList<>(check.size()); - for (final JsonValue value : check) { - values.add(((JsonString) value).getString()); - } - final JsonArrayBuilder builder = Json.createArrayBuilder(values); - final JsonArray out = builder.build(); - if (operationFailed(check, out)) { - result.fail("createArrayBuilder(Collection)", "Builder output " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test {@link Json#createArrayBuilder(JsonArray)} method. - * - * @param result - * Test suite result. - */ - private void testCreateFromJsonArray(final TestResult result) { - TestUtil.logMsg(" - Json#createArrayBuilder(JsonArray)"); - final JsonArray check = createSimpleStringArray5(); - final JsonArrayBuilder builder = Json.createArrayBuilder(check); - final JsonArray out = builder.build(); - if (operationFailed(check, out)) { - result.fail("createArrayBuilder(JsonArray)", "Builder output " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test {@code default JsonArray#getValuesAs(Function)} method on - * {@code String} values. - * - * @param result - * Test suite result. - */ - private void testGetStringValuesAs(final TestResult result) { - TestUtil.logMsg(" - getValuesAs(Function on String array"); - final JsonArray in = createStringArray2(); - final List out = in.getValuesAs(JsonString::getString); - boolean failed = in.size() != out.size(); - if (!failed) { - final Iterator inIt = in.iterator(); - final Iterator outIt = out.iterator(); - while (!failed && inIt.hasNext()) { - final JsonValue inVal = inIt.next(); - final String outVal = outIt.next(); - failed = !((JsonString) inVal).getString().equals(outVal); - } - } - if (failed) { - result.fail("getValuesAs(Function)", "Returned Array " - + out.toString() + " content shall match " + valueToString(in)); - } - } - - /** - * Test {@code default JsonArray#getValuesAs(Function)} method on - * {@code int} values. - * - * @param result - * Test suite result. - */ - private void testGetIntValuesAs(final TestResult result) { - TestUtil.logMsg(" - getValuesAs(Function on int array"); - final JsonArray in = createIntArray2(); - final List out = in.getValuesAs(JsonNumber::intValue); - boolean failed = in.size() != out.size(); - if (!failed) { - final Iterator inIt = in.iterator(); - final Iterator outIt = out.iterator(); - while (!failed && inIt.hasNext()) { - final JsonValue inVal = inIt.next(); - final Integer outVal = outIt.next(); - failed = ((JsonNumber) inVal).intValue() != outVal; - } - } - if (failed) { - result.fail("getValuesAs(Function)", "Returned Array " - + out.toString() + " content shall match " + valueToString(in)); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayCommon.java b/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayCommon.java deleted file mode 100644 index dcfb1eb71f..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/ArrayCommon.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonarraytests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; - -import jakarta.json.JsonArray; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests for {@link JsonArray} - * and {@link JsonArrayBuilder}. - */ -public abstract class ArrayCommon { - - /** - * Create and initialize array builder to contain single value. Child class - * callback. - * - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder containing value. - */ - protected abstract JsonArrayBuilder createArrayBuilder(final Object value); - - /** - * Create and initialize array builder to contain single value. Child class - * callback. - * - * @param index - * Position in the array where value is added. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder containing value. - */ - protected abstract JsonArrayBuilder createArrayBuilder(final int index, - final Object value); - - /** - * Update array builder to contain next value. Child class callback. - * - * @param builder - * JSON array builder to update. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder with value updated. - */ - protected abstract JsonArrayBuilder updateOperationBuilder( - final JsonArrayBuilder builder, final Object value); - - /** - * Update array builder to contain next value. Child class callback. - * - * @param builder - * JSON array builder to update. - * @param index - * Position in the array where value is added. - * @param value - * JSON value stored in the builder. Value of {@code null} is stored - * as JSON {@code null} keyword. - * @return JSON array builder with value updated. - */ - protected abstract JsonArrayBuilder updateOperationBuilder( - final JsonArrayBuilder builder, final int index, final Object value); - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonarraytests/Client.java deleted file mode 100644 index f74bf4ccf4..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/Client.java +++ /dev/null @@ -1,1436 +0,0 @@ -/* - * Copyright (c) 2013, 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 com.sun.ts.tests.jsonp.api.jsonarraytests; - -import java.io.StringReader; -import java.io.StringWriter; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import com.sun.ts.tests.jsonp.common.JSONP_Data; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonNumber; -import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; -import jakarta.json.JsonReader; -import jakarta.json.JsonString; -import jakarta.json.JsonValue; -import jakarta.json.JsonWriter; - -//$Id$ - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonArrayTest1 - * - * @assertion_ids: JSONP:JAVADOC:6; JSONP:JAVADOC:8; JSONP:JAVADOC:10; - * JSONP:JAVADOC:12; JSONP:JAVADOC:14; JSONP:JAVADOC:16; JSONP:JAVADOC:18; - * JSONP:JAVADOC:25; JSONP:JAVADOC:21; JSONP:JAVADOC:400; JSONP:JAVADOC:401; - * JSONP:JAVADOC:402; JSONP:JAVADOC:403; JSONP:JAVADOC:404; JSONP:JAVADOC:406; - * JSONP:JAVADOC:408; JSONP:JAVADOC:409; - * - * @test_Strategy: Tests JsonArray/JsonArrayBuilder API's. Build a JsonArray - * using the JsonArrayBuilder API's then verify that the list of JsonArray - * values matches the expected list of JsonArray values. - */ - public void jsonArrayTest1() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonObject for testing"); - JsonObject object = JSONP_Util.createSampleJsonObject(); - - logMsg("Create sample JsonArray for testing"); - JsonArray array = JSONP_Util.createSampleJsonArray(); - - logMsg("Create the expected list of JsonArray values"); - List expList = new ArrayList<>(); - expList.add(JsonValue.FALSE); - expList.add(JsonValue.TRUE); - expList.add(JsonValue.NULL); - expList.add(JSONP_Util.createJsonNumber(Double.MIN_VALUE)); - expList.add(JSONP_Util.createJsonNumber(Double.MAX_VALUE)); - expList.add(JSONP_Util.createJsonNumber(Integer.MIN_VALUE)); - expList.add(JSONP_Util.createJsonNumber(Integer.MAX_VALUE)); - expList.add(JSONP_Util.createJsonNumber(Long.MIN_VALUE)); - expList.add(JSONP_Util.createJsonNumber(Long.MAX_VALUE)); - expList.add( - JSONP_Util.createJsonNumber(BigDecimal.valueOf(123456789.123456789))); - expList.add(JSONP_Util.createJsonNumber(new BigInteger("123456789"))); - expList.add(JSONP_Util.createJsonString("string1")); - expList.add(object); - expList.add(array); - JSONP_Util.dumpList(expList, "Expected List"); - - logMsg("Create JsonArray using all JsonArrayBuilder API's"); - JsonArray myJsonArray = Json.createArrayBuilder() // Indices - .add(JsonValue.FALSE) // 0 - .add(JsonValue.TRUE) // 1 - .add(JsonValue.NULL) // 2 - .add(Double.MIN_VALUE) // 3 - .add(Double.MAX_VALUE) // 4 - .add(Integer.MIN_VALUE) // 5 - .add(Integer.MAX_VALUE) // 6 - .add(Long.MIN_VALUE) // 7 - .add(Long.MAX_VALUE) // 8 - .add(BigDecimal.valueOf(123456789.123456789)) // 9 - .add(new BigInteger("123456789")) // 10 - .add("string1") // 11 - .add(object) // 12 - .add(array) // 13 - .build(); - - List actualList = myJsonArray; - JSONP_Util.dumpList(actualList, "Actual List"); - logMsg( - "Compare actual list of JsonArray values with expected list of JsonArray values"); - pass = JSONP_Util.assertEqualsList(expList, actualList); - } catch (Exception e) { - throw new Fault("jsonArrayTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonArrayTest1 Failed"); - } - - /* - * @testName: jsonArrayTest2 - * - * @assertion_ids: JSONP:JAVADOC:6; JSONP:JAVADOC:8; JSONP:JAVADOC:10; - * JSONP:JAVADOC:12; JSONP:JAVADOC:14; JSONP:JAVADOC:16; JSONP:JAVADOC:18; - * JSONP:JAVADOC:105; JSONP:JAVADOC:106; JSONP:JAVADOC:108; JSONP:JAVADOC:96; - * JSONP:JAVADOC:97; JSONP:JAVADOC:21; JSONP:JAVADOC:25; JSONP:JAVADOC:184; - * JSONP:JAVADOC:400; JSONP:JAVADOC:401; JSONP:JAVADOC:402; JSONP:JAVADOC:403; - * JSONP:JAVADOC:404; JSONP:JAVADOC:406; JSONP:JAVADOC:408; JSONP:JAVADOC:409; - * - * - * @test_Strategy: Tests JsonArray/JsonArrayBuilder API's. Build a JsonArray - * using the JsonArrayBuilder API's. Write the JsonArray to a JsonWriter and - * read it back using a JsonReader. Verify that JsonArray written to the - * JsonWriter and then read back using the JsonReader are equal. - */ - public void jsonArrayTest2() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonObject for testing"); - JsonObject object = JSONP_Util.createSampleJsonObject(); - - logMsg("Create sample JsonArray for testing"); - JsonArray array = JSONP_Util.createSampleJsonArray(); - - logMsg( - "Create JsonArray 'myJsonArray1' using all JsonArrayBuilder API's"); - JsonArray myJsonArray1 = Json.createArrayBuilder() // Indices - .add(JsonValue.FALSE) // 0 - .add(JsonValue.TRUE) // 1 - .add(JsonValue.NULL) // 2 - .add(Double.MIN_VALUE) // 3 - .add(Double.MAX_VALUE) // 4 - .add(Integer.MIN_VALUE) // 5 - .add(Integer.MAX_VALUE) // 6 - .add(Long.MIN_VALUE) // 7 - .add(Long.MAX_VALUE) // 8 - .add(BigDecimal.valueOf(123456789.123456789)) // 9 - .add(new BigInteger("123456789")) // 10 - .add("string1") // 11 - .add(object) // 12 - .add(array) // 13 - .build(); - - logMsg("Write the JsonArray 'myJsonArray1' out to a JsonWriter"); - StringWriter sw = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sw)) { - writer.writeArray(myJsonArray1); - logMsg("Close JsonWriter"); - } - logMsg("Save contents of the JsonWriter as a String"); - String contents = sw.toString(); - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + contents); - logMsg("Read the JsonArray back into 'myJsonArray2' using a JsonReader"); - JsonArray myJsonArray2; - try (JsonReader reader = Json.createReader(new StringReader(contents))) { - myJsonArray2 = reader.readArray(); - } - logMsg("Dump contents of JsonArray read from String Contents"); - JSONP_Util.dumpJsonValue(myJsonArray2); - - logMsg("Compare myJsonArray1 and myJsonArray2 for equality"); - pass = JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2); - } catch (Exception e) { - throw new Fault("jsonArrayTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonArrayTest2 Failed"); - } - - /* - * @testName: jsonArrayTest3 - * - * @assertion_ids: JSONP:JAVADOC:6; JSONP:JAVADOC:8; JSONP:JAVADOC:10; - * JSONP:JAVADOC:430; JSONP:JAVADOC:12; JSONP:JAVADOC:14; JSONP:JAVADOC:16; - * JSONP:JAVADOC:18; JSONP:JAVADOC:40; JSONP:JAVADOC:41; JSONP:JAVADOC:42; - * JSONP:JAVADOC:44; JSONP:JAVADOC:45; JSONP:JAVADOC:46; JSONP:JAVADOC:48; - * JSONP:JAVADOC:49; JSONP:JAVADOC:51; JSONP:JAVADOC:21; JSONP:JAVADOC:25; - * JSONP:JAVADOC:101; JSONP:JAVADOC:102; JSONP:JAVADOC:262; JSONP:JAVADOC:263; - * JSONP:JAVADOC:400; JSONP:JAVADOC:401; JSONP:JAVADOC:402; JSONP:JAVADOC:403; - * JSONP:JAVADOC:404; JSONP:JAVADOC:406; JSONP:JAVADOC:408; JSONP:JAVADOC:409; - * JSONP:JAVADOC:433; JSONP:JAVADOC:434; JSONP:JAVADOC:435; JSONP:JAVADOC:490; - * JSONP:JAVADOC:493; JSONP:JAVADOC:496; JSONP:JAVADOC:499; JSONP:JAVADOC:506; - * - * @test_Strategy: Tests JsonArray/JsonArrayBuilder API's. Build a JsonArray - * using the JsonArrayBuilder API's. Verify contents of JsonArray using - * JsonArray().getJsonNumber(int), JsonArray().getJsonString(int), - * JsonArray().getJsonArray(int), JsonArray().getJsonObject(). - * - * This also covers testing the following additional API's: - * - * JsonString.getString(), JsonNumber.bigDecimalValue(), - * JsonNumber.bigIntegerValue(), JsonNumber.doubleValue(), - * JsonNumber.intValue(), JsonNumber.longValue(), JsonNumber.isIntegral(), - * JsonNumber.longValueExact(), JsonNumber.intValueExact(), - * JsonNumber.bigIntegerValueExact(), JsonArray.getInt(int), - * JsonArray.getString(int), JsonArrau.getBoolean(int), - * JsonArray.getBoolean(int, boolean), JsonArray.getInt(int, int), - * JsonArray.getString(int, String) - */ - @SuppressWarnings("SuspiciousIndentAfterControlStatement") - public void jsonArrayTest3() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonObject for testing"); - JsonObject object = JSONP_Util.createSampleJsonObject(); - - logMsg("Create sample JsonArray for testing"); - JsonArray array = JSONP_Util.createSampleJsonArray(); - - int expInt[] = { -1, 1, 1, -1000, 1000, 1000, -2000, 2000, 2000, - Integer.MAX_VALUE, Integer.MIN_VALUE }; - - long expLong[] = { Long.MAX_VALUE, Long.MIN_VALUE }; - - double expDouble[] = { Double.MAX_VALUE, Double.MIN_VALUE }; - - logMsg("Create myArray Jsonarray of 23 elements"); - JsonArray myArray = Json.createArrayBuilder() // Indices - .add(-1).add(+1).add(1) // 0,1,2 - .add(-1e3).add(+1e3).add(1e3) // 3,4,5 - .add(-2E3).add(+2E3).add(2E3) // 6,7,8 - .add(Integer.MAX_VALUE) // 9 - .add(Integer.MIN_VALUE) // 10 - .add(Long.MAX_VALUE) // 11 - .add(Long.MIN_VALUE) // 12 - .add(Double.MAX_VALUE) // 13 - .add(Double.MIN_VALUE) // 14 - .add(BigDecimal.valueOf(123456789.123456789)) // 15 - .add(new BigInteger("123456789")) // 16 - .add(JsonValue.TRUE) // 17 - .add(JsonValue.FALSE) // 18 - .add(JsonValue.NULL) // 19 - .add(JSONP_Data.asciiCharacters) // 20 - .add(object) // 21 - .add(array) // 22 - .build(); - - TestUtil.logMsg("Array size=" + myArray.size()); - - // Following array is used to test for Ints that could be one of following - // types: - boolean expectedIntTypes[] = { JSONP_Util.INTEGRAL, - JSONP_Util.NON_INTEGRAL }; - // Verify JsonValueType=NUMBER and integer value equals expectedIntValue - for (int i = 0; i < 11; i++) { - logMsg("Checking getValue(" + i + ") for correctness"); - logMsg("Retrieve and verify (JsonValueType=NUMBER)"); - if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER, - myArray.getJsonNumber(i).getValueType())) - pass = false; - logMsg("Retrieve and (expect JsonNumber NumberType be one of " - + JSONP_Util.toStringJsonNumberTypes(expectedIntTypes) + ")"); - if (!JSONP_Util.assertEqualsJsonNumberTypes(expectedIntTypes, - myArray.getJsonNumber(i).isIntegral())) - pass = false; - logMsg("Retrieve and verify integer value via JsonNumber.intValue()"); - if (!JSONP_Util.assertEquals(expInt[i], - myArray.getJsonNumber(i).intValue())) - pass = false; - logMsg("Retrieve and verify integer value via JsonArray.getInt"); - if (!JSONP_Util.assertEquals(expInt[i], myArray.getInt(i))) - pass = false; - logMsg( - "Retrieve and verify integer value via JsonNumber.intValueExact()"); - if (!JSONP_Util.assertEquals(expInt[i], - myArray.getJsonNumber(i).intValueExact())) - pass = false; - } - - // Verify JsonValueType=NUMBER and long value equals expectedLongValue - for (int i = 11, j = 0; i < 13; i++, j++) { - logMsg("Checking getValue(" + i + ") for correctness"); - logMsg("Retrieve and verify (JsonValueType=NUMBER)"); - if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER, - myArray.getJsonNumber(i).getValueType())) - pass = false; - logMsg("Retrieve and (expect JsonNumber NumberType be INTEGRAL)"); - if (!JSONP_Util.assertEqualsJsonNumberType(JSONP_Util.INTEGRAL, - myArray.getJsonNumber(i).isIntegral())) - pass = false; - logMsg("Retrieve and verify long value via JsonNumber.longValue()"); - if (!JSONP_Util.assertEquals(expLong[j], - myArray.getJsonNumber(i).longValue())) - pass = false; - logMsg( - "Retrieve and verify long value via JsonNumber.longValueExact()"); - if (!JSONP_Util.assertEquals(expLong[j], - myArray.getJsonNumber(i).longValueExact())) - pass = false; - } - - // Following array is used to test for Doubles that could be one of - // following types: - boolean expectedDoubleTypes[] = { JSONP_Util.INTEGRAL, - JSONP_Util.NON_INTEGRAL }; - - // Verify JsonValueType=NUMBER and double value equals expectedDoubleValue - for (int i = 13, j = 0; i < 15; i++, j++) { - logMsg("Checking getValue(" + i + ") for correctness"); - logMsg("Retrieve and verify (JsonValueType=NUMBER)"); - if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER, - myArray.getJsonNumber(i).getValueType())) - pass = false; - logMsg("Retrieve and (expect JsonNumber NumberType be one of " - + JSONP_Util.toStringJsonNumberTypes(expectedDoubleTypes) + ")"); - if (!JSONP_Util.assertEqualsJsonNumberTypes(expectedDoubleTypes, - myArray.getJsonNumber(i).isIntegral())) - pass = false; - logMsg("Retrieve and verify double value via JsonNumber.doubleValue()"); - if (!JSONP_Util.assertEquals(expDouble[j], - myArray.getJsonNumber(i).doubleValue())) - pass = false; - } - - // Verify JsonValueType=NUMBER and BigDecimalValue equals - // expectedBigDecimal - logMsg("Checking getValue(15) for correctness"); - logMsg("Retrieve and verify (JsonValueType=NUMBER)"); - if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER, - myArray.getJsonNumber(15).getValueType())) - pass = false; - logMsg("Retrieve and (expect JsonNumber NumberType be one of " - + JSONP_Util.toStringJsonNumberTypes(expectedDoubleTypes) + ")"); - if (!JSONP_Util.assertEqualsJsonNumberTypes(expectedDoubleTypes, - myArray.getJsonNumber(15).isIntegral())) - pass = false; - logMsg( - "Retrieve and verify BigDecimal value via JsonNumber.bigDecimalValue()"); - if (!JSONP_Util.assertEquals(BigDecimal.valueOf(123456789.123456789), - myArray.getJsonNumber(15).bigDecimalValue())) - pass = false; - - // Verify JsonValueType=NUMBER and BigIntegerValue equals - // expectedBigInteger - logMsg("Checking getValue(16) for correctness"); - logMsg("Retrieve and verify (JsonValueType=NUMBER)"); - if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.NUMBER, - myArray.getJsonNumber(16).getValueType())) - pass = false; - logMsg("Retrieve and (expect JsonNumber NumberType be INTEGRAL)"); - if (!JSONP_Util.assertEqualsJsonNumberType(JSONP_Util.INTEGRAL, - myArray.getJsonNumber(16).isIntegral())) - pass = false; - logMsg( - "Retrieve and verify BigInteger value via JsonNumber.bigIntegerValue()"); - if (!JSONP_Util.assertEquals(new BigInteger("123456789"), - myArray.getJsonNumber(16).bigIntegerValue())) - pass = false; - logMsg( - "Retrieve and verify BigInteger value via JsonNumber.bigIntegerValueExact()"); - if (!JSONP_Util.assertEquals(new BigInteger("123456789"), - myArray.getJsonNumber(16).bigIntegerValueExact())) - pass = false; - - // Verify getBoolean(int)=true - logMsg("Retrieve and verify true value via JsonArray.getBoolean(int)"); - if (!JSONP_Util.assertEquals(true, myArray.getBoolean(17))) - pass = false; - - // Verify getBoolean(int)=false - logMsg("Retrieve and verify false value via JsonArray.getBoolean(int)"); - if (!JSONP_Util.assertEquals(false, myArray.getBoolean(18))) - pass = false; - - // Verify isNull(int)=true - logMsg("Retrieve and verify null value via JsonArray.isNull(int)"); - if (!JSONP_Util.assertEquals(true, myArray.isNull(19))) - pass = false; - - // Verify isNull(int)=false - logMsg("Retrieve and verify non-null value via JsonArray.isNull(int)"); - if (!JSONP_Util.assertEquals(false, myArray.isNull(20))) - pass = false; - - // Verify JsonValueType=STRING and getJsonString()=expectedString - logMsg("Checking getValue(20) for correctness"); - logMsg("Retrieve and (expect JsonValueType=STRING)"); - if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.STRING, - myArray.getJsonString(20).getValueType())) - pass = false; - logMsg("Retrieve and verify string value via JsonString.getString()"); - if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters, - myArray.getJsonString(20).getString())) - pass = false; - logMsg("Retrieve and verify string value via JsonArray.getString()"); - if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters, - myArray.getString(20))) - pass = false; - - // Verify JsonValueType=OBJECT and getJsonObject()=expectedObject - logMsg("Checking getJsonObject(21) for correctness"); - logMsg("Retrieve and (expect JsonValueType=OBJECT)"); - if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.OBJECT, - myArray.getJsonObject(21).getValueType())) - pass = false; - logMsg( - "Retrieve and verify object value via JsonArray.getJsonObject(int)"); - if (!JSONP_Util.assertEqualsJsonObjects(object, - myArray.getJsonObject(21))) - pass = false; - - // Verify JsonValueType=ARRAY and getJsonArray()=expectedArray - logMsg("Checking getJsonArray(22) for correctness"); - logMsg("Retrieve and (expect JsonValueType=ARRAY)"); - if (!JSONP_Util.assertEqualsJsonValueType(JsonValue.ValueType.ARRAY, - myArray.getJsonArray(22).getValueType())) - pass = false; - logMsg("Retrieve and verify array value via JsonArray.getJsonArray(int)"); - if (!JSONP_Util.assertEqualsJsonArrays(array, myArray.getJsonArray(22))) - pass = false; - - // Verify calls to JsonArray.getBoolean(int) - if (!JSONP_Util.assertEquals(true, myArray.getBoolean(17))) - pass = false; - if (!JSONP_Util.assertEquals(false, myArray.getBoolean(18))) - pass = false; - - // Verify calls to JsonArray.getBoolean(int, boolean) - logMsg( - "Testing JsonArray.getBoolean(int, boolean) with/without default value setting."); - if (!JSONP_Util.assertEquals(true, myArray.getBoolean(17, false))) - pass = false; - if (!JSONP_Util.assertEquals(false, myArray.getBoolean(0, false))) - pass = false; - if (!JSONP_Util.assertEquals(false, myArray.getBoolean(19, false))) - pass = false; - if (!JSONP_Util.assertEquals(false, myArray.getBoolean(20, false))) - pass = false; - if (!JSONP_Util.assertEquals(false, myArray.getBoolean(21, false))) - pass = false; - if (!JSONP_Util.assertEquals(false, myArray.getBoolean(22, false))) - pass = false; - - // Verify calls to JsonArray.getInt(int, int) - logMsg( - "Testing JsonArray.getInt(int, int) with/without default value setting."); - if (!JSONP_Util.assertEquals(-1, myArray.getInt(0, 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myArray.getInt(17, 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myArray.getInt(19, 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myArray.getInt(20, 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myArray.getInt(21, 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myArray.getInt(22, 10))) - pass = false; - - // Verify calls to JsonArray.getString(int, String) - logMsg( - "Testing JsonArray.getString(int, String) with/without default value setting."); - if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters, - myArray.getString(20, "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myArray.getString(17, "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myArray.getString(19, "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myArray.getString(2, "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myArray.getString(21, "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myArray.getString(22, "foo"))) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonArrayTest3 Failed: ", e); - } - if (!pass) - throw new Fault("jsonArrayTest3 Failed"); - } - - /* - * @testName: jsonArrayTest4 - * - * @assertion_ids: JSONP:JAVADOC:6; JSONP:JAVADOC:8; JSONP:JAVADOC:14; - * JSONP:JAVADOC:16; JSONP:JAVADOC:18; JSONP:JAVADOC:21; JSONP:JAVADOC:25; - * JSONP:JAVADOC:106; JSONP:JAVADOC:400; JSONP:JAVADOC:401; JSONP:JAVADOC:402; - * JSONP:JAVADOC:403; JSONP:JAVADOC:404; JSONP:JAVADOC:406; JSONP:JAVADOC:409; - * - * @test_Strategy: Build a JsonArray and than write the JsonArray. Compare the - * Json text from the writer contents with the expected Json text output - * expected based on the JsonArray. - */ - public void jsonArrayTest4() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonArray for testing"); - JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray(); - logMsg("Write the JsonArray 'myJsonArray1' out to a JsonWriter"); - StringWriter sw = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sw)) { - writer.writeArray(myJsonArray1); - logMsg("Close JsonWriter"); - } - logMsg("Save contents of the JsonWriter as a String"); - String contents = sw.toString(); - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + contents); - logMsg("Remove whitespace from contents."); - String actJsonText = JSONP_Util.removeWhitespace(contents); - logMsg( - "Compare expected JsonArray text with actual JsonArray text for equality"); - pass = JSONP_Util.assertEqualsJsonText( - JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonText); - } catch (Exception e) { - throw new Fault("jsonArrayTest4 Failed: ", e); - } - if (!pass) - throw new Fault("jsonArrayTest4 Failed"); - } - - /* - * @testName: jsonArrayGetValuesAsTest - * - * @assertion_ids: JSONP:JAVADOC:403; JSONP:JAVADOC:481; JSONP:JAVADOC:8; - * JSONP:JAVADOC:14; - * - * @test_Strategy: Build a Json array of values of the same type. Get the - * values as a list for that type. Compare results in list to what is expected - * for equality. - * - * APIs called: JsonArray array = Json.createArrayBuilder().add(...).build() - * List JsonArray.getValuesAs(Class) - */ - @SuppressWarnings("SuspiciousIndentAfterControlStatement") - public void jsonArrayGetValuesAsTest() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonArray of JsonNumber types for testing"); - JsonArray jsonArr = Json.createArrayBuilder().add(100).add(500).build(); - - logMsg("Create the expected list of JsonArray values"); - List expList = new ArrayList<>(); - expList.add(JSONP_Util.createJsonNumber(100)); - expList.add(JSONP_Util.createJsonNumber(500)); - JSONP_Util.dumpList(expList, "Expected List"); - - logMsg("Create the JsonNumber list of JsonArray values"); - List numList = jsonArr.getValuesAs(JsonNumber.class); - - logMsg("Create the actual list of JsonArray values"); - List actList = new ArrayList<>(); - for (JsonNumber num : numList) - actList.add(num); - - logMsg("Compare actual list with expected list for equality"); - pass = JSONP_Util.assertEqualsList(expList, actList); - - logMsg("Create sample JsonArray of JsonString types for testing"); - jsonArr = Json.createArrayBuilder().add("hello").add("world").build(); - - logMsg("Create the list of JsonString values"); - List strList = jsonArr.getValuesAs(JsonString.class); - - logMsg("Comparing JsonString list elements to expected values."); - if (!JSONP_Util.assertEquals(jsonArr.getString(0), - strList.get(0).getString())) - pass = false; - - if (!JSONP_Util.assertEquals(jsonArr.getString(1), - strList.get(1).getString())) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonArrayGetValuesAsTest Failed: ", e); - } - if (!pass) - throw new Fault("jsonArrayGetValuesAsTest Failed"); - } - - /* - * @testName: jsonArrayExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:43; JSONP:JAVADOC:47; JSONP:JAVADOC:50; - * JSONP:JAVADOC:20; JSONP:JAVADOC:377; JSONP:JAVADOC:432; JSONP:JAVADOC:379; - * JSONP:JAVADOC:378; JSONP:JAVADOC:380; JSONP:JAVADOC:431; JSONP:JAVADOC:400; - * JSONP:JAVADOC:401; JSONP:JAVADOC:402; JSONP:JAVADOC:403; JSONP:JAVADOC:404; - * JSONP:JAVADOC:406; JSONP:JAVADOC:408; JSONP:JAVADOC:409; JSONP:JAVADOC:491; - * JSONP:JAVADOC:492; JSONP:JAVADOC:494; JSONP:JAVADOC:495; JSONP:JAVADOC:497; - * JSONP:JAVADOC:498; JSONP:JAVADOC:500; JSONP:JAVADOC:501; JSONP:JAVADOC:507; - * - * @test_Strategy: Test JsonArray exception conditions. Trips the exceptions: - * java.lang.IndexOutOfBoundsException java.lang.ArithmeticException - * java.lang.NumberFormatException java.lang.ClassCastException - * java.lang.UnsupportedOperationException - */ - public void jsonArrayExceptionTests() throws Fault { - boolean pass = true; - JsonObject testObject = null; - JsonArray testArray = null; - - try { - logMsg("Create sample JsonObject for testing"); - testObject = JSONP_Util.createSampleJsonObject(); - - logMsg("Create sample JsonArray for testing"); - testArray = JSONP_Util.createSampleJsonArray(); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to JsonNumber via getJsonNumber(int)"); - JsonNumber value = testArray.getJsonNumber(0); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to JsonNumber via getJsonNumber(int)"); - JsonNumber value = testArray.getJsonNumber(15); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonNumber to JsonString via getJsonString(int)"); - JsonString value = testArray.getJsonString(4); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonString to JsonNumber via getJsonNumber(int)"); - JsonNumber value = testArray.getJsonNumber(6); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonValue.TRUE to JsonNumber via getJsonNumber(int)"); - JsonNumber value = testArray.getJsonNumber(1); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to JsonArray via getJsonArray(int)"); - JsonArray value = testArray.getJsonArray(0); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to JsonObject via getJsonObject(int)"); - JsonObject value = testArray.getJsonObject(15); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to JsonNumber via getInt(int)"); - int value = testArray.getInt(0); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to JsonString via getString(int)"); - String value = testArray.getString(0); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to JsonString via getString(int)"); - String value = testArray.getString(15); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to boolean via getBoolean(int)"); - boolean value = testArray.getBoolean(0); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to boolean via getBoolean(int)"); - boolean value = testArray.getBoolean(13); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonString to boolean via getBoolean(int)"); - boolean value = testArray.getBoolean(6); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonNumber to boolean via getBoolean(int)"); - boolean value = testArray.getBoolean(4); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing -1 as index to getJsonNumber(int)"); - int myInt = testArray.getJsonNumber(-1).intValue(); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing 10000 as index to getJsonNumber(int)"); - JsonValue myJsonValue = testArray.getJsonNumber(10000); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing -1 as index to getJsonArray(int)"); - JsonValue myJsonValue = testArray.getJsonArray(-1); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing 10000 as index to getJsonArray(int)"); - JsonValue myJsonValue = testArray.getJsonArray(10000); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing -1 as index to getJsonObject(int)"); - JsonValue myJsonValue = testArray.getJsonObject(-1); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing 10000 as index to getJsonObject(int)"); - JsonValue myJsonValue = testArray.getJsonObject(10000); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing -1 as index to getJsonString(int)"); - JsonValue myJsonValue = testArray.getJsonString(-1); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing 10000 as index to getJsonString(int)"); - JsonValue myJsonValue = testArray.getJsonString(10000); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing -1 as index to getInt(int)"); - int myInt = testArray.getInt(-1); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing 10000 as index to getInt(int)"); - int myInt = testArray.getInt(10000); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing -1 as index to getString(int)"); - String myString = testArray.getString(-1); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing 10000 as index to getString(int)"); - String myString = testArray.getString(10000); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing -1 as index to getBoolean(int)"); - boolean myBoolean = testArray.getBoolean(-1); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing 10000 as index to getBoolean(int)"); - boolean myBoolean = testArray.getBoolean(10000); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing -1 as index to isNull(int)"); - boolean myBoolean = testArray.isNull(-1); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip IndexOutOfBoundsException - try { - logMsg( - "Trip IndexOutOfBoundsException passing 10000 as index to isNull(int)"); - boolean myBoolean = testArray.isNull(10000); - pass = false; - logErr("Failed to throw IndexOutOfBoundsException"); - } catch (IndexOutOfBoundsException e) { - logMsg("Got expected IndexOutOfBoundsException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NumberFormatException calling add(Double.NaN) - try { - logMsg("Trip NumberFormatException calling add(Double.NaN)"); - JsonArray array = Json.createArrayBuilder().add(Double.NaN).build(); - pass = false; - logErr("Failed to throw NumberFormatException"); - } catch (NumberFormatException e) { - logMsg("Got expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NumberFormatException calling add(Double.NEGATIVE_INFINITY) - try { - logMsg( - "Trip NumberFormatException calling add(Double.NEGATIVE_INFINITY)"); - JsonArray array = Json.createArrayBuilder().add(Double.NEGATIVE_INFINITY) - .build(); - pass = false; - logErr("Failed to throw NumberFormatException"); - } catch (NumberFormatException e) { - logMsg("Got expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NumberFormatException calling add(Double.POSITIVE_INFINITY) - try { - logMsg( - "Trip NumberFormatException calling add(Double.POSITIVE_INFINITY)"); - JsonArray array = Json.createArrayBuilder().add(Double.POSITIVE_INFINITY) - .build(); - pass = false; - logErr("Failed to throw NumberFormatException"); - } catch (NumberFormatException e) { - logMsg("Got expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test for ArithmeticException - try { - logMsg( - "Trip ArithmeticException calling add(12345.12345) and attempting to extract as an exact integer value"); - JsonArray array = Json.createArrayBuilder().add(12345.12345).build(); - logMsg("Call JsonArray.getJsonNumber(0).intValueExact()"); - int value = array.getJsonNumber(0).intValueExact(); - pass = false; - logErr("Failed to throw ArithmeticException"); - } catch (ArithmeticException e) { - logMsg("Got expected ArithmeticException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test for ArithmeticException - try { - logMsg( - "Trip ArithmeticException calling add(12345.12345) and attempting to extract as an exact long value"); - JsonArray array = Json.createArrayBuilder().add(12345.12345).build(); - logMsg("Call JsonArray.getJsonNumber(0).longValueExact()"); - long value = array.getJsonNumber(0).longValueExact(); - pass = false; - logErr("Failed to throw ArithmeticException"); - } catch (ArithmeticException e) { - logMsg("Got expected ArithmeticException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test for ArithmeticException - try { - logMsg( - "Trip ArithmeticException calling add(12345.12345) and attempting to extract as an exact biginteger value"); - JsonArray array = Json.createArrayBuilder().add(12345.12345).build(); - logMsg("Call JsonArray.getJsonNumber(0).bigIntegerValueExact()"); - BigInteger value = array.getJsonNumber(0).bigIntegerValueExact(); - pass = false; - logErr("Failed to throw ArithmeticException"); - } catch (ArithmeticException e) { - logMsg("Got expected ArithmeticException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Tests for UnsupportedOperationException using Collection methods to - // modify JsonArray List - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonArray.add(E) trying to modify JsonArray list which should be immutable"); - testArray.add(JsonValue.FALSE); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonArray.add(int,E) trying to modify JsonArray list which should be immutable"); - testArray.add(0, JsonValue.FALSE); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonArray.addAll(C) trying to modify JsonArray list which should be immutable"); - testArray.addAll(testArray); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonArray.addAll(int, C) trying to modify JsonArray list which should be immutable"); - testArray.addAll(0, testArray); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonArray.clear() trying to modify JsonArray list which should be immutable"); - testArray.clear(); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonArray.remove(int) trying to modify JsonArray list which should be immutable"); - testArray.remove(0); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonArray.removeAll(C) trying to modify JsonArray list which should be immutable"); - testArray.removeAll(testArray); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException trying to modify JsonArray list which should be immutable"); - testArray.remove(JsonValue.TRUE); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonArrayExceptionTests Failed"); - } - - /* - * @testName: jsonArrayNullValueExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:555; JSONP:JAVADOC:556; JSONP:JAVADOC:557; - * JSONP:JAVADOC:558; JSONP:JAVADOC:559; JSONP:JAVADOC:560; - * - * @test_Strategy: Test JSON NPE exception conditions when attempting to add a - * specified value that is null. - */ - public void jsonArrayNullValueExceptionTests() throws Fault { - boolean pass = true; - JsonArrayBuilder jab = Json.createArrayBuilder(); - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonArrayBuilder.add(JsonValue) when JsonValue is null."); - jab.add((JsonValue) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - try { - logMsg( - "Trip NullPointerException for JsonArrayBuilder.add(BigInteger) when BigInteger is null."); - jab.add((BigInteger) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - try { - logMsg( - "Trip NullPointerException for JsonArrayBuilder.add(JsonArrayBuilder) when JsonArrayBuilder is null."); - jab.add((JsonArrayBuilder) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - try { - logMsg( - "Trip NullPointerException for JsonArrayBuilder.add(JsonObjectBuilder) when JsonObjectBuilder is null."); - jab.add((JsonObjectBuilder) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - try { - logMsg( - "Trip NullPointerException for JsonArrayBuilder.add(BigDecimal) when BigDecimal is null."); - jab.add((BigDecimal) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonArrayBuilder.add(String) when String is null."); - jab.add((String) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonArrayNullValueExceptionTests Failed"); - } - - /* - * @testName: jsonCreateArrayBuilder11Test - * - * @assertion_ids: JSONP:JAVADOC:572; JSONP:JAVADOC:573; JSONP:JAVADOC:651; - * JSONP:JAVADOC:652; - * - * @test_Strategy: Tests JsonArrayBuilder API factory methods added in JSON-P - * 1.1. - */ - public void jsonCreateArrayBuilder11Test() throws Fault { - ArrayBuilders createTest = new ArrayBuilders(); - final TestResult result = createTest.test(); - result.eval(); - } - - /* - * @testName: jsonArrayBuilder11AddTest - * - * @assertion_ids: JSONP:JAVADOC:589; JSONP:JAVADOC:590; JSONP:JAVADOC:591; - * JSONP:JAVADOC:592; JSONP:JAVADOC:593; JSONP:JAVADOC:594; JSONP:JAVADOC:595; - * JSONP:JAVADOC:596; JSONP:JAVADOC:597; JSONP:JAVADOC:598; JSONP:JAVADOC:599; - * JSONP:JAVADOC:600; JSONP:JAVADOC:601; - * - * @test_Strategy: Tests JsonArrayBuilder API add() methods added in JSON-P - * 1.1. - */ - public void jsonArrayBuilder11AddTest() throws Fault { - ArrayBuildAdd addTest = new ArrayBuildAdd(); - final TestResult result = addTest.test(); - result.eval(); - } - - /* - * @testName: jsonArrayBuilder11SetTest - * - * @assertion_ids: JSONP:JAVADOC:603; JSONP:JAVADOC:604; JSONP:JAVADOC:605; - * JSONP:JAVADOC:606; JSONP:JAVADOC:607; JSONP:JAVADOC:608; JSONP:JAVADOC:609; - * JSONP:JAVADOC:610; JSONP:JAVADOC:611; JSONP:JAVADOC:612; JSONP:JAVADOC:613; - * - * @test_Strategy: Tests JsonArrayBuilder API set() methods added in JSON-P - * 1.1. - */ - public void jsonArrayBuilder11SetTest() throws Fault { - ArrayBuildSet setTest = new ArrayBuildSet(); - final TestResult result = setTest.test(); - result.eval(); - } - - /* - * @testName: jsonArrayBuilder11RemoveTest - * - * @assertion_ids: JSONP:JAVADOC:602; - * - * @test_Strategy: Tests JsonArrayBuilder API remove() methods added in JSON-P - * 1.1. - */ - public void jsonArrayBuilder11RemoveTest() throws Fault { - ArrayBuildRemove removeTest = new ArrayBuildRemove(); - final TestResult result = removeTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonarraytests/build.xml deleted file mode 100644 index bc7013a4d1..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonarraytests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/BuilderFactory.java b/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/BuilderFactory.java deleted file mode 100644 index 6d11f6bc4d..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/BuilderFactory.java +++ /dev/null @@ -1,301 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonbuilderfactorytests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonBuilderFactory; -import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests for - * {@link JsonBuilderFactory}. - */ -public class BuilderFactory { - - /** - * Creates an instance of JavaScript Object Notation (JSON) compatibility - * tests for {@link JsonBuilderFactory}. - */ - BuilderFactory() { - super(); - } - - /** - * {@link JsonBuilderFactory} API methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonBuilderFactory API methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonBuilderFactory API methods added in JSON-P 1.1."); - testCreateArrayBuilderString(result); - testCreateArrayBuilderInt(result); - testCreateArrayBuilderBool(result); - testCreateArrayBuilderObject(result); - testCreateArrayBuilderNull(result); - testCreateObjectBuilderString(result); - testCreateObjectBuilderInt(result); - testCreateObjectBuilderBool(result); - testCreateObjectBuilderObject(result); - testCreateObjectBuilderNull(result); - return result; - } - - /** - * Test {@code JsonArrayBuilder createArrayBuilder(JsonArray)} method on - * {@code String} value. - * - * @param result - * Test suite result. - */ - private void testCreateArrayBuilderString(final TestResult result) { - TestUtil.logMsg(" - createArrayBuilder(JsonArray) for String"); - final JsonArray in = createStringArray2(); - final JsonArray check = createStringArray2(); - verifyCreateArrayBuilder(result, check, in); - } - - /** - * Test {@code JsonArrayBuilder createArrayBuilder(JsonArray)} method on - * {@code int} value. - * - * @param result - * Test suite result. - */ - private void testCreateArrayBuilderInt(final TestResult result) { - TestUtil.logMsg(" - createArrayBuilder(JsonArray) for int"); - final JsonArray in = createIntArray2(); - final JsonArray check = createIntArray2(); - verifyCreateArrayBuilder(result, check, in); - } - - /** - * Test {@code JsonArrayBuilder createArrayBuilder(JsonArray)} method on - * {@code boolean} value. - * - * @param result - * Test suite result. - */ - private void testCreateArrayBuilderBool(final TestResult result) { - TestUtil.logMsg(" - createArrayBuilder(JsonArray) for boolean"); - final JsonArray in = createBoolArray2(); - final JsonArray check = createBoolArray2(); - verifyCreateArrayBuilder(result, check, in); - } - - /** - * Test {@code JsonArrayBuilder createArrayBuilder(JsonArray)} method on - * {@code JsonObject} value. - * - * @param result - * Test suite result. - */ - private void testCreateArrayBuilderObject(final TestResult result) { - TestUtil.logMsg(" - createArrayBuilder(JsonArray) for JsonObject"); - final JsonArray in = createObjectArray2(); - final JsonArray check = createObjectArray2(); - verifyCreateArrayBuilder(result, check, in); - } - - /** - * Test {@code JsonArrayBuilder createArrayBuilder(JsonArray)} method on - * {@code null} value. Method shall throw NullPointerException. - * - * @param result - * Test suite result. - */ - private void testCreateArrayBuilderNull(final TestResult result) { - TestUtil.logMsg(" - createArrayBuilder(JsonArray) for null"); - final JsonArray in = null; - final JsonBuilderFactory factory = Json.createBuilderFactory(null); - try { - factory.createArrayBuilder(in); - result.fail("createArrayBuilder(JsonArray)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg( - " - Expected exception for null argument: " + e.getMessage()); - } catch (Throwable t) { - result.fail("createObjectBuilder(JsonObject)", - "Calling method with with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test {@code JsonObjectBuilder createObjectBuilder(JsonObject)} method on - * {@code String} value. - * - * @param result - * Test suite result. - */ - private void testCreateObjectBuilderString(final TestResult result) { - TestUtil.logMsg(" - createObjectBuilder(JsonObject) for String"); - final JsonObject in = createSimpleObjectStr(); - final JsonObject check = createSimpleObjectStr(); - verifyCreateObjectBuilder(result, check, in); - } - - /** - * Test {@code JsonObjectBuilder createObjectBuilder(JsonObject)} method on - * {@code int} value. - * - * @param result - * Test suite result. - */ - private void testCreateObjectBuilderInt(final TestResult result) { - TestUtil.logMsg(" - createObjectBuilder(JsonObject) for int"); - final JsonObject in = createSimpleObjectInt(); - final JsonObject check = createSimpleObjectInt(); - verifyCreateObjectBuilder(result, check, in); - } - - /** - * Test {@code JsonObjectBuilder createObjectBuilder(JsonObject)} method on - * {@code boolean} value. - * - * @param result - * Test suite result. - */ - private void testCreateObjectBuilderBool(final TestResult result) { - TestUtil.logMsg(" - createObjectBuilder(JsonObject) for boolean"); - final JsonObject in = createSimpleObjectBool(); - final JsonObject check = createSimpleObjectBool(); - verifyCreateObjectBuilder(result, check, in); - } - - /** - * Test {@code JsonObjectBuilder createObjectBuilder(JsonObject)} method on - * {@code JsonObject} value. - * - * @param result - * Test suite result. - */ - private void testCreateObjectBuilderObject(final TestResult result) { - TestUtil.logMsg(" - createObjectBuilder(JsonObject) for JsonObject"); - final JsonObject in = createSimpleObjectObject(); - final JsonObject check = createSimpleObjectObject(); - verifyCreateObjectBuilder(result, check, in); - } - - /** - * Test helper: Verify {@code JsonArrayBuilder createArrayBuilder(JsonArray)} - * method on provided array. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param in - * JSON array to pass to the method. - */ - private void verifyCreateArrayBuilder(final TestResult result, - final JsonArray check, final JsonArray in) { - final JsonBuilderFactory factory = Json.createBuilderFactory(null); - final JsonArrayBuilder builder = factory.createArrayBuilder(in); - final JsonArray out = builder.build(); - if (operationFailed(check, out)) { - result.fail("createArrayBuilder(JsonArray)", "Output builder " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test helper: Verify - * {@code JsonObjectBuilder createObjectBuilder(JsonObjecty)} method on - * provided object. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param in - * JSON object to pass to the method. - */ - private void verifyCreateObjectBuilder(final TestResult result, - final JsonObject check, final JsonObject in) { - TestUtil.logMsg(" - IN: " + valueToString(in)); - final JsonBuilderFactory factory = Json.createBuilderFactory(null); - final JsonObjectBuilder builder = factory.createObjectBuilder(in); - final JsonObject out = builder.build(); - if (operationFailed(check, out)) { - result.fail("createObjectBuilder(JsonObject)", "Output builder " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test {@code JsonObjectBuilder createObjectBuilder(JsonObject)} method on - * {@code null} value. Method shall throw NullPointerException. - * - * @param result - * Test suite result. - */ - private void testCreateObjectBuilderNull(final TestResult result) { - TestUtil.logMsg(" - createObjectBuilder(JsonObject) for null"); - final JsonObject in = null; - final JsonBuilderFactory factory = Json.createBuilderFactory(null); - try { - factory.createObjectBuilder(in); - result.fail("createObjectBuilder(JsonObject)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg( - " - Expected exception for null argument: " + e.getMessage()); - } catch (Throwable t) { - result.fail("createObjectBuilder(JsonObject)", - "Calling method with with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/Client.java deleted file mode 100644 index 708ccd4f0f..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/Client.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonbuilderfactorytests; - -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonBuilderFactory; -import jakarta.json.JsonObject; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonBuilderFactoryTest1 - * - * @assertion_ids: JSONP:JAVADOC:445; JSONP:JAVADOC:453; JSONP:JAVADOC:454; - * JSONP:JAVADOC:455; - * - * @test_Strategy: Tests the JsonBuilderFactory API. - * - * JsonBuilderFactory builderFactory = Json.createBuilderFactory(Map); JsonArray array = builderFactory.createArrayBuilder() JsonObject - * object = builderFactory.createObjectBuilder() - */ - public void jsonBuilderFactoryTest1() throws Fault { - boolean pass = true; - try { - logMsg("Create JsonBuilderFactory with Map with EMPTY config"); - JsonBuilderFactory builderFactory = Json - .createBuilderFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = builderFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("---------------------------------------------------"); - logMsg("TEST CASE [JsonBuilderFactory.createArrayBuilder()]"); - logMsg("---------------------------------------------------"); - logMsg("Create JsonArrayBuilder using JsonBuilderFactory"); - JsonArray expJsonArray = JSONP_Util.createJsonArrayFromString("[0,2]"); - JsonArray actJsonArray = builderFactory.createArrayBuilder().add(0).add(2) - .build(); - if (!JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray)) - pass = false; - - logMsg("----------------------------------------------------"); - logMsg("TEST CASE [JsonBuilderFactory.createObjectBuilder()]"); - logMsg("----------------------------------------------------"); - logMsg("Create JsonObjectBuilder using JsonBuilderFactory"); - JsonObject expJsonObject = JSONP_Util - .createJsonObjectFromString("{\"foo\":\"bar\"}"); - JsonObject actJsonObject = builderFactory.createObjectBuilder() - .add("foo", "bar").build(); - if (!JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject)) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonBuilderFactoryTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonBuilderFactoryTest1 Failed"); - } - - /* - * @testName: jsonBuilderFactoryTest2 - * - * @assertion_ids: JSONP:JAVADOC:445; JSONP:JAVADOC:455; - * - * @test_Strategy: Tests the JsonBuilderFactory API. - * - * JsonBuilderFactory builderFactory = Json.createBuilderFactory(Map); Map config = JsonBuilderFactory.getConfigInUse(); - * - * Test for the following 3 scenarios: 1) no supported provider property - * (empty config) 2) non supported provider property - */ - public void jsonBuilderFactoryTest2() throws Fault { - boolean pass = true; - JsonBuilderFactory builderFactory; - Map config; - try { - logMsg("----------------------------------------------"); - logMsg("Test scenario1: no supported provider property"); - logMsg("----------------------------------------------"); - logMsg("Create JsonBuilderFactory with Map with EMPTY config"); - builderFactory = Json.createBuilderFactory(JSONP_Util.getEmptyConfig()); - config = builderFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-----------------------------------------------"); - logMsg("Test scenario2: non supported provider property"); - logMsg("-----------------------------------------------"); - logMsg("Create JsonBuilderFactory with Map with FOO config"); - builderFactory = Json.createBuilderFactory(JSONP_Util.getFooConfig()); - config = builderFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonBuilderFactoryTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonBuilderFactoryTest2 Failed"); - } - - /* - * @testName: jsonBuilderFactory11Test - * - * @assertion_ids: JSONP:JAVADOC:614; JSONP:JAVADOC:615; - * - * @test_Strategy: Tests JsonBuilderFactory API methods added in JSON-P 1.1. - */ - public void jsonBuilderFactory11Test() throws Fault { - BuilderFactory factoryTest = new BuilderFactory(); - final TestResult result = factoryTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/build.xml deleted file mode 100644 index 1bdb3538fa..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonbuilderfactorytests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsoncoding/Client.java b/src/com/sun/ts/tests/jsonp/api/jsoncoding/Client.java deleted file mode 100644 index bf06a15369..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsoncoding/Client.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2017, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsoncoding; - -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; - -import jakarta.json.Json; - -public class Client extends ServiceEETest { - private static final long serialVersionUID = 11L; - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonEncodeTest - * - * @assertion_ids: JSONP:JAVADOC:681; JSONP:JAVADOC:682; - * - * @test_Strategy: Encode and decode Json Pointer as defined by RFC 6901 - */ - public void jsonEncodeTest() throws Fault { - String DECODED = "/a/~b/c"; - String ENCODED = "~1a~1~0b~1c"; - StringBuilder error = new StringBuilder(); - logMsg("----------------------------------------------"); - logMsg("Test encode " + DECODED); - logMsg("----------------------------------------------"); - String encoded = Json.encodePointer(DECODED); - if (!ENCODED.equals(encoded)) - error.append("The pointer ").append(DECODED) - .append(" has been encoded as ").append(encoded).append('\n'); - - logMsg("----------------------------------------------"); - logMsg("Test decode " + ENCODED); - String decoded = Json.decodePointer(ENCODED); - if (!DECODED.equals(decoded)) - error.append("The pointer ").append(ENCODED) - .append(" has been decoded as ").append(decoded).append('\n'); - if (error.length() != 0) - throw new Fault(error.toString()); - logMsg("----------------------------------------------"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsoncoding/build.xml b/src/com/sun/ts/tests/jsonp/api/jsoncoding/build.xml deleted file mode 100644 index 7d686bdae4..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsoncoding/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsongeneratorfactorytests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsongeneratorfactorytests/Client.java deleted file mode 100644 index 47b749ef57..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsongeneratorfactorytests/Client.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsongeneratorfactorytests; - -import java.io.ByteArrayOutputStream; -import java.io.StringWriter; -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.Json; -import jakarta.json.stream.JsonGenerator; -import jakarta.json.stream.JsonGeneratorFactory; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonGeneratorFactoryTest1 - * - * @assertion_ids: JSONP:JAVADOC:162; JSONP:JAVADOC:416; JSONP:JAVADOC:427; - * - * @test_Strategy: Tests the JsonGeneratorFactory API. - * - * JsonGeneratorFactory generatorFactory = - * Json.createGeneratorFactory(Map); JsonGenerator generator1 = - * generatorFactory.createGenerator(Writer) JsonGenerator generator2 = - * generatorFactory.createGenerator(Writer) - */ - public void jsonGeneratorFactoryTest1() throws Fault { - boolean pass = true; - JsonGenerator generator1 = null; - JsonGenerator generator2 = null; - String expString; - String actString; - try { - logMsg( - "Create JsonGeneratorFactory with Map with PRETTY_PRINTING config"); - JsonGeneratorFactory generatorFactory = Json - .createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig()); - logMsg("Checking factory configuration properties"); - Map config = generatorFactory.getConfigInUse(); - String[] props = { JsonGenerator.PRETTY_PRINTING, }; - if (!JSONP_Util.doConfigCheck(config, 1, props)) - pass = false; - logMsg("--------------------------------------------------------"); - logMsg("TEST CASE [JsonGeneratorFactory.createGenerator(Writer)]"); - logMsg("--------------------------------------------------------"); - logMsg("Create 1st JsonGenerator using JsonGeneratorFactory"); - StringWriter sWriter1 = new StringWriter(); - generator1 = generatorFactory.createGenerator(sWriter1); - if (generator1 == null) { - logErr("GeneratorFactory failed to create generator1"); - pass = false; - } else { - generator1.writeStartObject().writeEnd(); - generator1.close(); - } - logMsg("sWriter1=" + sWriter1.toString()); - expString = "{}"; - actString = JSONP_Util.removeWhitespace(sWriter1.toString()); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - logMsg("Create 2nd JsonGenerator using JsonGeneratorFactory"); - StringWriter sWriter2 = new StringWriter(); - generator2 = generatorFactory.createGenerator(sWriter2); - if (generator2 == null) { - logErr("GeneratorFactory failed to create generator2"); - pass = false; - } else { - generator2.writeStartArray().writeEnd(); - generator2.close(); - } - logMsg("sWriter2=" + sWriter2.toString()); - expString = "[]"; - actString = JSONP_Util.removeWhitespace(sWriter2.toString()); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonGeneratorFactoryTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorFactoryTest1 Failed"); - } - - /* - * @testName: jsonGeneratorFactoryTest2 - * - * @assertion_ids: JSONP:JAVADOC:163; JSONP:JAVADOC:416; JSONP:JAVADOC:427; - * - * @test_Strategy: Tests the JsonGeneratorFactory API. - * - * JsonGeneratorFactory generatorFactory = - * Json.createGeneratorFactory(Map); JsonGenerator generator1 = - * generatorFactory.createGenerator(OutputStream, Charset) JsonGenerator - * generator2 = generatorFactory.createGenerator(OutputStream, Charset) - * - * Create generator with both UTF-8 and UTF-16BE. - */ - public void jsonGeneratorFactoryTest2() throws Fault { - boolean pass = true; - JsonGenerator generator1 = null; - JsonGenerator generator2 = null; - String expString, actString; - try { - logMsg( - "Create JsonGeneratorFactory with Map with PRETTY_PRINTING config"); - JsonGeneratorFactory generatorFactory = Json - .createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig()); - logMsg("Checking factory configuration properties"); - Map config = generatorFactory.getConfigInUse(); - String[] props = { JsonGenerator.PRETTY_PRINTING, }; - if (!JSONP_Util.doConfigCheck(config, 1, props)) - pass = false; - - logMsg( - "-----------------------------------------------------------------------"); - logMsg( - "TEST CASE [JsonGeneratorFactory.createGenerator(OutputStream, Charset)]"); - logMsg( - "-----------------------------------------------------------------------"); - logMsg( - "Create 1st JsonGenerator using JsonGeneratorFactory with UTF-8 encoding"); - ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); - generator1 = generatorFactory.createGenerator(baos1, JSONP_Util.UTF_8); - if (generator1 == null) { - logErr("GeneratorFactory failed to create generator1"); - pass = false; - } else { - generator1.writeStartObject().writeEnd(); - generator1.close(); - } - logMsg("baos1=" + baos1.toString("UTF-8")); - expString = "{}"; - actString = JSONP_Util.removeWhitespace(baos1.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - logMsg( - "Create 2nd JsonGenerator using JsonGeneratorFactory with UTF-16BE encoding"); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - generator2 = generatorFactory.createGenerator(baos2, JSONP_Util.UTF_16BE); - if (generator2 == null) { - logErr("GeneratorFactory failed to create generator2"); - pass = false; - } else { - generator2.writeStartArray().writeEnd(); - generator2.close(); - } - logMsg("baos2=" + baos2.toString("UTF-16BE")); - expString = "[]"; - actString = JSONP_Util.removeWhitespace(baos2.toString("UTF-16BE")); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonGeneratorFactoryTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorFactoryTest2 Failed"); - } - - /* - * @testName: jsonGeneratorFactoryTest3 - * - * @assertion_ids: JSONP:JAVADOC:200; JSONP:JAVADOC:416; JSONP:JAVADOC:427; - * - * @test_Strategy: Tests the JsonGeneratorFactory API. - * - * JsonGeneratorFactory generatorFactory = - * Json.createGeneratorFactory(Map); JsonGenerator generator1 = - * generatorFactory.createGenerator(OutputStream) JsonGenerator generator2 = - * generatorFactory.createGenerator(OutputStream) - */ - public void jsonGeneratorFactoryTest3() throws Fault { - boolean pass = true; - JsonGenerator generator1 = null; - JsonGenerator generator2 = null; - String expString; - String actString; - try { - logMsg( - "Create JsonGeneratorFactory with Map with PRETTY_PRINTING config"); - JsonGeneratorFactory generatorFactory = Json - .createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig()); - logMsg("Checking factory configuration properties"); - Map config = generatorFactory.getConfigInUse(); - String[] props = { JsonGenerator.PRETTY_PRINTING, }; - if (!JSONP_Util.doConfigCheck(config, 1, props)) - pass = false; - logMsg( - "-----------------------------------------------------------------"); - logMsg( - "TEST CASE [JsonGeneratorFactory.createGenerator(OutputStream os)]"); - logMsg( - "-----------------------------------------------------------------"); - logMsg("Create 1st JsonGenerator using JsonGeneratorFactory"); - ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); - generator1 = generatorFactory.createGenerator(baos1); - if (generator1 == null) { - logErr("GeneratorFactory failed to create generator1"); - pass = false; - } else { - generator1.writeStartObject().writeEnd(); - generator1.close(); - } - logMsg("baos1=" + baos1.toString("UTF-8")); - expString = "{}"; - actString = JSONP_Util.removeWhitespace(baos1.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - logMsg("Create 2nd JsonGenerator using JsonGeneratorFactory"); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - generator2 = generatorFactory.createGenerator(baos2); - if (generator2 == null) { - logErr("GeneratorFactory failed to create generator2"); - pass = false; - } else { - generator2.writeStartArray().writeEnd(); - generator2.close(); - } - logMsg("baos2=" + baos2.toString("UTF-8")); - expString = "[]"; - actString = JSONP_Util.removeWhitespace(baos2.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonGeneratorFactoryTest3 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorFactoryTest3 Failed"); - } - - /* - * @testName: jsonGeneratorFactoryTest4 - * - * @assertion_ids: JSONP:JAVADOC:416; JSONP:JAVADOC:427; - * - * @test_Strategy: Tests the JsonGeneratorFactory API. - * - * JsonGeneratorFactory generatorFactory = - * Json.createGeneratorFactory(Map); Map config = - * JsonGeneratorFactory.getConfigInUse(); - * - * Test for the following 3 scenarios: 1) no supported provider property - * (empty config) 2) supported provider property 3) supported and non - * supported provider property - */ - public void jsonGeneratorFactoryTest4() throws Fault { - boolean pass = true; - JsonGeneratorFactory generatorFactory; - Map config; - try { - logMsg("----------------------------------------------"); - logMsg("Test scenario1: no supported provider property"); - logMsg("----------------------------------------------"); - logMsg( - "Create JsonGeneratorFactory with Map with EMPTY config"); - generatorFactory = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()); - config = generatorFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-------------------------------------------"); - logMsg("Test scenario2: supported provider property"); - logMsg("-------------------------------------------"); - logMsg( - "Create JsonGeneratorFactory with Map with PRETTY_PRINTING config"); - generatorFactory = Json - .createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig()); - config = generatorFactory.getConfigInUse(); - String[] props = { JsonGenerator.PRETTY_PRINTING, }; - if (!JSONP_Util.doConfigCheck(config, 1, props)) - pass = false; - - logMsg("-------------------------------------------------------------"); - logMsg("Test scenario3: supported and non supported provider property"); - logMsg("-------------------------------------------------------------"); - logMsg("Create JsonGeneratorFactory with Map with all config"); - generatorFactory = Json.createGeneratorFactory(JSONP_Util.getAllConfig()); - config = generatorFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 1, props)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonGeneratorFactoryTest4 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorFactoryTest4 Failed"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsongeneratorfactorytests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsongeneratorfactorytests/build.xml deleted file mode 100644 index 40735aa229..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsongeneratorfactorytests/build.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/Client.java deleted file mode 100644 index 28de0bdeae..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/Client.java +++ /dev/null @@ -1,2141 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsongeneratortests; - -import java.io.ByteArrayOutputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import com.sun.ts.tests.jsonp.common.JSONP_Util; -import com.sun.ts.tests.jsonp.common.MyBufferedWriter; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonReader; -import jakarta.json.JsonValue; -import jakarta.json.stream.JsonGenerationException; -import jakarta.json.stream.JsonGenerator; - -public class Client extends ServiceEETest { - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* private Utility methods */ - - /********************************************************************************* - * generateSimpleJsonObject - *********************************************************************************/ - private void generateSimpleJsonObject(JsonGenerator generator) { - try { - generator.writeStartObject().writeStartObject("object") - .write("string", "string").write("number", 1) - .write("true", JsonValue.TRUE).write("false", JsonValue.FALSE) - .write("null", JsonValue.NULL).writeEnd().writeStartArray("array") - .write("string").write(1).write(JsonValue.TRUE).write(JsonValue.FALSE) - .write(JsonValue.NULL).writeEnd().writeEnd(); - generator.close(); - } catch (Exception e) { - TestUtil.logErr("Exception occurred: " + e); - } - } - - /********************************************************************************* - * generateSimpleJsonArray - *********************************************************************************/ - private void generateSimpleJsonArray(JsonGenerator generator) { - try { - generator.writeStartArray().writeStartObject().write("string", "string") - .write("number", 1).write("true", JsonValue.TRUE) - .write("false", JsonValue.FALSE).write("null", JsonValue.NULL) - .writeEnd().writeStartArray().write("string").write(1) - .write(JsonValue.TRUE).write(JsonValue.FALSE).write(JsonValue.NULL) - .writeEnd().writeEnd(); - generator.close(); - } catch (Exception e) { - TestUtil.logErr("Exception occurred: " + e); - } - } - - /********************************************************************************* - * generateJsonObject - *********************************************************************************/ - private String generateJsonObject() { - try { - logMsg("Generate a JsonObject"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write("emptyString", "") - .writeStartArray("emptyArray").writeEnd() - .writeStartObject("emptyObject").writeEnd().write("string", "string") - .write("intMin", Integer.MIN_VALUE).write("intMax", Integer.MAX_VALUE) - .write("longMin", Long.MIN_VALUE).write("longMax", Long.MAX_VALUE) - .write("doubleMin", Double.MIN_VALUE) - .write("doubleMax", Double.MAX_VALUE) - .write("bigInteger", - new BigInteger(Integer.toString(Integer.MAX_VALUE))) - .write("bigDecimal", BigDecimal.valueOf(Integer.MIN_VALUE)) - .write("true", JsonValue.TRUE).write("false", JsonValue.FALSE) - .write("null", JsonValue.NULL).writeStartObject("object") - .write("emptyString", "").writeStartArray("emptyArray").writeEnd() - .writeStartObject("emptyObject").writeEnd().write("string", "string") - .write("number", 100).write("true", true).write("false", false) - .writeNull("null").writeStartObject("object").write("name", "value") - .write("objectFooBar", JSONP_Util.buildJsonObjectFooBar()) - .write("arrayFooBar", JSONP_Util.buildJsonArrayFooBar()).writeEnd() - .writeStartArray("array").write("one").write("two") - .write(JSONP_Util.buildJsonObjectFooBar()) - .write(JSONP_Util.buildJsonArrayFooBar()).writeEnd().writeEnd() - .writeStartArray("array").write("string").write(Integer.MAX_VALUE) - .write(Long.MAX_VALUE).write(Double.MAX_VALUE) - .write(new BigInteger(Integer.toString(Integer.MAX_VALUE))) - .write(JsonValue.TRUE).write(JsonValue.FALSE).write(JsonValue.NULL) - .writeStartObject().write("name", "value").writeEnd() - .writeStartArray().write("one").write("two").writeEnd().writeEnd() - .write("asciiChars", - "\\\"\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM") - .writeEnd(); - generator.close(); - return sWriter.toString(); - } catch (Exception e) { - TestUtil.logErr("Exception occurred: " + e); - return null; - } - } - - /********************************************************************************* - * buildJsonObject - *********************************************************************************/ - private JsonObject buildJsonObject() { - try { - logMsg("Build a JsonObject"); - JsonObject jsonObject = Json.createObjectBuilder().add("emptyString", "") - .add("emptyArray", Json.createArrayBuilder()) - .add("emptyObject", Json.createObjectBuilder()) - .add("string", "string").add("intMin", Integer.MIN_VALUE) - .add("intMax", Integer.MAX_VALUE).add("longMin", Long.MIN_VALUE) - .add("longMax", Long.MAX_VALUE).add("doubleMin", Double.MIN_VALUE) - .add("doubleMax", Double.MAX_VALUE) - .add("bigInteger", - new BigInteger(Integer.toString(Integer.MAX_VALUE))) - .add("bigDecimal", BigDecimal.valueOf(Integer.MIN_VALUE)) - .add("true", JsonValue.TRUE).add("false", JsonValue.FALSE) - .add("null", JsonValue.NULL) - .add("object", - Json.createObjectBuilder().add("emptyString", "") - .add("emptyArray", Json.createArrayBuilder()) - .add("emptyObject", Json.createObjectBuilder()) - .add("string", "string").add("number", 100) - .add("true", JsonValue.TRUE).add("false", JsonValue.FALSE) - .add("null", JsonValue.NULL) - .add("object", Json.createObjectBuilder().add("name", "value") - .add("objectFooBar", JSONP_Util.buildJsonObjectFooBar()) - .add("arrayFooBar", JSONP_Util.buildJsonArrayFooBar())) - .add("array", - Json.createArrayBuilder().add("one").add("two") - .add(JSONP_Util.buildJsonObjectFooBar()) - .add(JSONP_Util.buildJsonArrayFooBar()))) - .add("array", - Json.createArrayBuilder().add("string").add(Integer.MAX_VALUE) - .add(Long.MAX_VALUE).add(Double.MAX_VALUE) - .add(new BigInteger(Integer.toString(Integer.MAX_VALUE))) - .add(JsonValue.TRUE).add(JsonValue.FALSE).add(JsonValue.NULL) - .add(Json.createObjectBuilder().add("name", "value")) - .add(Json.createArrayBuilder().add("one").add("two"))) - .add("asciiChars", - "\\\"\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM") - .build(); - return jsonObject; - } catch (Exception e) { - TestUtil.logErr("Exception occurred: " + e); - return null; - } - } - - /********************************************************************************* - * generateJsonArray - *********************************************************************************/ - private String generateJsonArray() { - try { - logMsg("Generate a JsonArray"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("").writeStartArray().writeEnd() - .writeStartObject().writeEnd().write("string") - .write(Integer.MIN_VALUE).write(Integer.MAX_VALUE) - .write(Long.MIN_VALUE).write(Long.MAX_VALUE).write(Double.MIN_VALUE) - .write(Double.MAX_VALUE) - .write(new BigInteger(new Integer(Integer.MAX_VALUE).toString())) - .write(BigDecimal.valueOf(Integer.MIN_VALUE)).write(JsonValue.TRUE) - .write(JsonValue.FALSE).write(JsonValue.NULL).writeStartObject() - .write("emptyString", "").writeStartArray("emptyArray").writeEnd() - .writeStartObject("emptyObject").writeEnd().write("string", "string") - .write("number", 100).write("true", JsonValue.TRUE) - .write("false", JsonValue.FALSE).write("null", JsonValue.NULL) - .writeStartObject("object").write("name", "value") - .write("objectFooBar", JSONP_Util.buildJsonObjectFooBar()) - .write("arrayFooBar", JSONP_Util.buildJsonArrayFooBar()).writeEnd() - .writeStartArray("array").write("one").write("two") - .write(JSONP_Util.buildJsonObjectFooBar()) - .write(JSONP_Util.buildJsonArrayFooBar()).writeEnd().writeEnd() - .writeStartArray().write("string").write(Integer.MAX_VALUE) - .write(Long.MAX_VALUE).write(Double.MAX_VALUE) - .write(new BigInteger(new Integer(Integer.MAX_VALUE).toString())) - .write(true).write(false).writeNull().writeStartObject() - .write("name", "value").writeEnd().writeStartArray().write("one") - .write("two").writeEnd().writeEnd() - .write( - "\\\"\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM") - .writeEnd(); - generator.close(); - return sWriter.toString(); - } catch (Exception e) { - TestUtil.logErr("Exception occurred: " + e); - return null; - } - } - - /********************************************************************************* - * buildJsonArray - *********************************************************************************/ - private JsonArray buildJsonArray() { - try { - logMsg("Build a JsonArray"); - JsonArray jsonArray = Json.createArrayBuilder().add("") - .add(Json.createArrayBuilder()).add(Json.createObjectBuilder()) - .add("string").add(Integer.MIN_VALUE).add(Integer.MAX_VALUE) - .add(Long.MIN_VALUE).add(Long.MAX_VALUE).add(Double.MIN_VALUE) - .add(Double.MAX_VALUE) - .add(new BigInteger(new Integer(Integer.MAX_VALUE).toString())) - .add(BigDecimal.valueOf(Integer.MIN_VALUE)).add(JsonValue.TRUE) - .add(JsonValue.FALSE).add(JsonValue.NULL) - .add(Json.createObjectBuilder().add("emptyString", "") - .add("emptyArray", Json.createArrayBuilder()) - .add("emptyObject", Json.createObjectBuilder()) - .add("string", "string").add("number", 100) - .add("true", JsonValue.TRUE).add("false", JsonValue.FALSE) - .add("null", JsonValue.NULL) - .add("object", - Json.createObjectBuilder().add("name", "value") - .add("objectFooBar", JSONP_Util.buildJsonObjectFooBar()) - .add("arrayFooBar", JSONP_Util.buildJsonArrayFooBar())) - .add("array", - Json.createArrayBuilder().add("one").add("two") - .add(JSONP_Util.buildJsonObjectFooBar()) - .add(JSONP_Util.buildJsonArrayFooBar()))) - .add(Json.createArrayBuilder().add("string").add(Integer.MAX_VALUE) - .add(Long.MAX_VALUE).add(Double.MAX_VALUE) - .add(new BigInteger(new Integer(Integer.MAX_VALUE).toString())) - .add(JsonValue.TRUE).add(JsonValue.FALSE).add(JsonValue.NULL) - .add(Json.createObjectBuilder().add("name", "value")) - .add(Json.createArrayBuilder().add("one").add("two"))) - .add( - "\\\"\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM") - .build(); - return jsonArray; - } catch (Exception e) { - TestUtil.logErr("Exception occurred: " + e); - return null; - } - } - - /* Tests */ - - /* - * @testName: jsonGeneratorObjectTest1 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:131; - * JSONP:JAVADOC:289; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * The output is written to a writer, read back as a string and filtered to - * remove whitespace and is compared against an expected string. - * - * { "object":{"string":"string","number":1,"true":true,"false":false,"null": - * null}, "array":["string", 1, true, false, null] } - */ - public void jsonGeneratorObjectTest1() throws Fault { - boolean pass = true; - try { - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generateSimpleJsonObject(generator); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}"; - logMsg("Read the JSON text back from Writer removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(sWriter.toString()); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorObjectTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorObjectTest1 Failed"); - } - - /* - * @testName: jsonGeneratorObjectTest2 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:168; - * JSONP:JAVADOC:289; JSONP:JAVADOC:307; JSONP:JAVADOC:327; JSONP:JAVADOC:339; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * The output is written to a writer, read back as a string and filtered to - * remove whitespace and is compared against an expected string. - * - * { "emptyString":"", "emptyArray":[], "emptyObject":{}, "string":"string","+ - * "intMin":Integer.MIN_VALUE, "intMax":Integer.MAX_VALUE, - * "longMin":Long.MIN_VALUE, "longMax":Long.MAX_VALUE, "true":true, - * "false":false, "null":null, "object": { "emptyString":"", "emptyArray":[], - * "emptyObject":{}, "string":"string", "number":100, "true":true, - * "false":false, "null":null, "object":{"name":"value"} "array":["one","two"] - * }, "array": [ "string", Integer.MAX_VALUE, Long.MAX_VALUE, true, false, - * null, {"name":"value"}, ["one","two"] ], - * "asciiChars":"\"\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" - * } - */ - public void jsonGeneratorObjectTest2() throws Fault { - boolean pass = true; - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json.createGenerator(baos); - generator.writeStartObject().write("emptyString", "") - .writeStartArray("emptyArray").writeEnd() - .writeStartObject("emptyObject").writeEnd().write("string", "string") - .write("intMin", Integer.MIN_VALUE).write("intMax", Integer.MAX_VALUE) - .write("longMin", Long.MIN_VALUE).write("longMax", Long.MAX_VALUE) - .write("true", JsonValue.TRUE).write("false", JsonValue.FALSE) - .write("null", JsonValue.NULL).writeStartObject("object") - .write("emptyString", "").writeStartArray("emptyArray").writeEnd() - .writeStartObject("emptyObject").writeEnd().write("string", "string") - .write("number", 100).write("true", JsonValue.TRUE) - .write("false", JsonValue.FALSE).write("null", JsonValue.NULL) - .writeStartObject("object").write("name", "value").writeEnd() - .writeStartArray("array").write("one").write("two").writeEnd() - .writeEnd().writeStartArray("array").write("string") - .write(Integer.MAX_VALUE).write(Long.MAX_VALUE).write(JsonValue.TRUE) - .write(JsonValue.FALSE).write(JsonValue.NULL).writeStartObject() - .write("name", "value").writeEnd().writeStartArray().write("one") - .write("two").writeEnd().writeEnd() - .write("asciiChars", - "\\\"\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM") - .writeEnd(); - generator.close(); - - logMsg("Dump of string: " + baos.toString("UTF-8")); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "{\"emptyString\":\"\",\"emptyArray\":[],\"emptyObject\":{},\"string\":\"string\"," - + "\"intMin\":" + Integer.MIN_VALUE + "," + "\"intMax\":" - + Integer.MAX_VALUE + "," + "\"longMin\":" + Long.MIN_VALUE + "," - + "\"longMax\":" + Long.MAX_VALUE + "," - + "\"true\":true,\"false\":false,\"null\":null,\"object\":{\"emptyString\":\"\",\"emptyArray\":[]," - + "\"emptyObject\":{},\"string\":\"string\",\"number\":100,\"true\":true,\"false\":false," - + "\"null\":null,\"object\":{\"name\":\"value\"}," - + "\"array\":[\"one\",\"two\"]},\"array\":[\"string\"," - + Integer.MAX_VALUE + "," + Long.MAX_VALUE + ",true,false,null," - + "{\"name\":\"value\"},[\"one\",\"two\"]],\"asciiChars\":" - + "\"\\\\\\\"\\\\\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM\"" - + "}"; - - logMsg("Read the JSON text back from OutputStream removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8")); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorObjectTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorObjectTest2 Failed"); - } - - /* - * @testName: jsonGeneratorObjectTest3 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:131; - * JSONP:JAVADOC:289; JSONP:JAVADOC:307; JSONP:JAVADOC:327; JSONP:JAVADOC:339; - * JSONP:JAVADOC:301; JSONP:JAVADOC:310; JSONP:JAVADOC:329; JSONP:JAVADOC:323; - * JSONP:JAVADOC:298; JSONP:JAVADOC:314; JSONP:JAVADOC:334; - * - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * The output is written to a writer, read back as a JsonObject and compared - * against an expected JsonObject. - * - * { "emptyString":"", "emptyArray":[], "emptyObject":{}, "string":"string","+ - * "intMin":Integer.MIN_VALUE, "intMax":Integer.MAX_VALUE, - * "longMin":Long.MIN_VALUE, "longMax":Long.MAX_VALUE, - * "doubleMin":Double.MIN_VALUE, "doubleMax":Double.MAX_VALUE, - * "bigInteger":Integer.MAX_VALUE, "bigDecimal":Integer.MIN_VALUE, - * "true":true, "false":false, "null":null, "object": { "emptyString":"", - * "emptyArray":[], "emptyObject":{}, "string":"string", "number":100, - * "true":true, "false":false, "null":null, - * "object":{"name":"value",{"foo":"bar"}}, - * "array":["one","two",["foo","bar"]] }, "array": [ "string", - * Integer.MAX_VALUE, Long.MAX_VALUE, Double.MAX_VALUE, Integer.MAX_VALUE - * true, false, null, {"name":"value"}, ["one","two"] ], - * "asciiChars":"\\\"\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" - * } - */ - public void jsonGeneratorObjectTest3() throws Fault { - boolean pass = true; - try { - JsonObject expJsonObject = buildJsonObject(); - String jsonText = generateJsonObject(); - - JsonReader reader = Json.createReader(new StringReader(jsonText)); - JsonObject actJsonObject = (JsonObject) reader.read(); - - // Do comparison - logMsg("Compare expJsonObject and actJsonObject for equality"); - pass = JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject); - - } catch (Exception e) { - throw new Fault("jsonGeneratorObjectTest3 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorObjectTest3 Failed"); - } - - /* - * @testName: jsonGeneratorObjectTest4 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:416; - * JSONP:JAVADOC:289; JSONP:JAVADOC:163; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * Encoding is done in UTF-16BE. The output is written to an OutputStream as - * UTF-16BE encoding, read back as a string using UTF-16BE encoding and - * filtered to remove whitespace and is compared against an expected string. - * - * { "object":{"string":"string","number":1,"true":true,"false":false,"null": - * null}, "array":["string", 1, true, false, null] } Tests the following API - * call: - * - * JsonGenerator generator = - * Json.createGeneratorFactory(Map).createGenerator(OutputStream, - * Charset); - */ - public void jsonGeneratorObjectTest4() throws Fault { - boolean pass = true; - try { - logMsg("Create generator output in UTF-16BE encoding."); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_16BE); - generateSimpleJsonObject(generator); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}"; - logMsg( - "Read the JSON text back encoding from OutputStream using UTF-16BE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE")); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorObjectTest4 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorObjectTest4 Failed"); - } - - /* - * @testName: jsonGeneratorObjectTest5 - * - * @assertion_ids: JSONP:JAVADOC:131; JSONP:JAVADOC:341; JSONP:JAVADOC:295; - * JSONP:JAVADOC:289; - * - * @test_Strategy: Test generation of object data with multiple unicode chars - * in data. The output is written to a writer, read back using a reader as a - * JsonObject and extracts the JsonString value out and compares it against - * the expected JsonString value. - * - * Generate the following object of unicode char(s): - * - * {"unicodechars":"\u0000\u000f\u001f\u00ff\uff00\uffff"} - */ - public void jsonGeneratorObjectTest5() throws Fault { - boolean pass = true; - JsonReader reader = null; - String expUnicodeChars = "\u0000\u000f\u001f\u00ff\uff00\uffff"; - try { - - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject() - .write("unicodechars", "\u0000\u000f\u001f\u00ff\uff00\uffff") - .writeEnd(); - generator.close(); - sWriter.close(); - - logMsg("Testing read of " + sWriter.toString()); - reader = Json.createReader(new StringReader(sWriter.toString())); - JsonObject jsonObject = reader.readObject(); - String actUnicodeChars = jsonObject.getJsonString("unicodechars") - .getString(); - reader.close(); - TestUtil.logMsg("actUnicodeChars=" + actUnicodeChars); - - pass = JSONP_Util.assertEquals(expUnicodeChars, actUnicodeChars); - } catch (Exception e) { - logErr("Exception occurred: " + e); - pass = false; - } - if (!pass) - throw new Fault("jsonGeneratorObjectTest5 Failed"); - } - - /* - * @testName: jsonGeneratorArrayTest1 - * - * @assertion_ids: JSONP:JAVADOC:339; JSONP:JAVADOC:341; JSONP:JAVADOC:295; - * JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; JSONP:JAVADOC:325; - * JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:131; JSONP:JAVADOC:289; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonArray. - * The output is written to a writer, read back as a string and filtered to - * remove whitespace and is compared against an expected string. - * - * [ {"string":"string","number":1,"true":true,"false":false,"null":null}, - * ["string", 1, true, false, null] ] - * - */ - public void jsonGeneratorArrayTest1() throws Fault { - boolean pass = true; - try { - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generateSimpleJsonArray(generator); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "[{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},[\"string\",1,true,false,null]]"; - logMsg("Read the JSON text back from Writer removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(sWriter.toString()); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorArrayTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorArrayTest1 Failed"); - } - - /* - * @testName: jsonGeneratorArrayTest2 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:168; - * JSONP:JAVADOC:289; JSONP:JAVADOC:327; JSONP:JAVADOC:339; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonArray. - * The output is written to a writer, read back as a string and filtered to - * remove whitespace and is compared against an expected string. - * - * [ "", [], {}, "string", Integer.MIN_VALUE, Integer.MAX_VALUE, - * Long.MIN_VALUE, Long.MAX_VALUE, true, false, null, { "emptyString":"", - * "emptyArray":[], "emptyObject":{}, "string":"string", "number":100, - * "true":true, "false":false, "null":null, "object":{"name":"value"}, - * "array":["one","two"] }, [ "string", Integer.MAX_VALUE, Long.MAX_VALUE, - * true, false, null, {"name":"value"}, ["one","two"] ], - * "\"\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" - * ] - */ - public void jsonGeneratorArrayTest2() throws Fault { - boolean pass = true; - try { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json.createGenerator(baos); - generator.writeStartArray().write("").writeStartArray().writeEnd() - .writeStartObject().writeEnd().write("string") - .write(Integer.MIN_VALUE).write(Integer.MAX_VALUE) - .write(Long.MIN_VALUE).write(Long.MAX_VALUE).write(JsonValue.TRUE) - .write(JsonValue.FALSE).write(JsonValue.NULL).writeStartObject() - .write("emptyString", "").writeStartArray("emptyArray").writeEnd() - .writeStartObject("emptyObject").writeEnd().write("string", "string") - .write("number", 100).write("true", JsonValue.TRUE) - .write("false", JsonValue.FALSE).write("null", JsonValue.NULL) - .writeStartObject("object").write("name", "value").writeEnd() - .writeStartArray("array").write("one").write("two").writeEnd() - .writeEnd().writeStartArray().write("string").write(Integer.MAX_VALUE) - .write(Long.MAX_VALUE).write(JsonValue.TRUE).write(JsonValue.FALSE) - .write(JsonValue.NULL).writeStartObject().write("name", "value") - .writeEnd().writeStartArray().write("one").write("two").writeEnd() - .writeEnd() - .write( - "\\\"\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM") - .writeEnd(); - generator.close(); - - logMsg("Dump of string: " + baos.toString("UTF-8")); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "[\"\",[],{},\"string\"," + Integer.MIN_VALUE + "," - + Integer.MAX_VALUE + "," + Long.MIN_VALUE + "," + Long.MAX_VALUE - + "," + "true,false,null,{\"emptyString\":\"\",\"emptyArray\":[]," - + "\"emptyObject\":{},\"string\":\"string\",\"number\":100,\"true\":true,\"false\":false," - + "\"null\":null,\"object\":{\"name\":\"value\"}," - + "\"array\":[\"one\",\"two\"]},[\"string\"," + Integer.MAX_VALUE - + "," + Long.MAX_VALUE + ",true,false,null," - + "{\"name\":\"value\"},[\"one\",\"two\"]]," - + "\"\\\\\\\"\\\\\\\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM\"" - + "]"; - - logMsg("Read the JSON text back from Writer removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8")); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorArrayTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorArrayTest2 Failed"); - } - - /* - * @testName: jsonGeneratorArrayTest3 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:131; - * JSONP:JAVADOC:289; JSONP:JAVADOC:327; JSONP:JAVADOC:339; JSONP:JAVADOC:329; - * JSONP:JAVADOC:321; JSONP:JAVADOC:323; JSONP:JAVADOC:332; JSONP:JAVADOC:337; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonArray. - * The output is written to a writer, read back as a JsonArray and compared - * against an expected JsonArray. - * - * [ "", [], {}, "string", Integer.MIN_VALUE, Integer.MAX_VALUE, - * Long.MIN_VALUE, Long.MAX_VALUE, Double.MIN_VALUE, Double.MAX_VALUE, - * Integer.MAX_VALUE, Integer.MIN_VALUE, true, false, null, { - * "emptyString":"", "emptyArray":[], "emptyObject":{}, "string":"string", - * "number":100, "true":true, "false":false, "null":null, - * "object":{"name":"value",{"foo":"bar"}}, - * "array":["one","two",["foo","bar"]] }, [ "string", Integer.MAX_VALUE, - * Long.MAX_VALUE, Double.MAX_VALUE, Integer.MAX_VALUE true, false, null, - * {"name":"value"}, ["one","two"] ], - * "\"\\!@#$%^&*()_+|~1234567890-=`[]{}:;',./<>? qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM" - * ] - */ - public void jsonGeneratorArrayTest3() throws Fault { - boolean pass = true; - try { - JsonArray expJsonArray = buildJsonArray(); - String jsonText = generateJsonArray(); - logMsg("generator json text: " + jsonText); - - JsonReader reader = Json.createReader(new StringReader(jsonText)); - JsonArray actJsonArray = (JsonArray) reader.read(); - - // Do comparison - logMsg("Compare expJsonArray and actJsonArray for equality"); - pass = JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray); - - } catch (Exception e) { - throw new Fault("jsonGeneratorArrayTest3 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorArrayTest3 Failed"); - } - - /* - * @testName: jsonGeneratorArrayTest4 - * - * @assertion_ids: JSONP:JAVADOC:339; JSONP:JAVADOC:341; JSONP:JAVADOC:115; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:163; JSONP:JAVADOC:289; - * JSONP:JAVADOC:416; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonArray. - * Encoding is done in UTF-16BE. The output is written to an OutputStream as - * UTF-16BE encoding, read back as a string using UTF-16BE encoding and - * filtered to remove whitespace and is compared against an expected string. - * - * [ {"string":"string","number":1,"true":true,"false":false,"null":null}, - * ["string", 1, true, false, null] ] - * - */ - public void jsonGeneratorArrayTest4() throws Fault { - boolean pass = true; - try { - logMsg("Create generator output in UTF-16BE encoding."); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_16BE); - generateSimpleJsonArray(generator); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "[{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},[\"string\",1,true,false,null]]"; - logMsg( - "Read the JSON text back from OutputStream using UTF-16BE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE")); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorArrayTest4 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorArrayTest4 Failed"); - } - - /* - * @testName: jsonGeneratorArrayTest5 - * - * @assertion_ids: JSONP:JAVADOC:131; JSONP:JAVADOC:339; JSONP:JAVADOC:319; - * JSONP:JAVADOC:289; - * - * @test_Strategy: Test generation of array data with multiple unicode chars - * in data. The output is written to a writer, read back using a reader as a - * JsonArray and extracts the JsonString value out and compares it against the - * expected JsonString value. - * - * Generate the following array of unicode char(s): - * - * ["\u0000\u000f\u001f\u00ff\uff00\uffff"] - */ - public void jsonGeneratorArrayTest5() throws Fault { - boolean pass = true; - JsonReader reader = null; - String expUnicodeChars = "\u0000\u000f\u001f\u00ff\uff00\uffff"; - try { - - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("\u0000\u000f\u001f\u00ff\uff00\uffff") - .writeEnd(); - generator.close(); - sWriter.close(); - - logMsg("Testing read of " + sWriter.toString()); - reader = Json.createReader(new StringReader(sWriter.toString())); - JsonArray jsonArray = reader.readArray(); - String actUnicodeChars = jsonArray.getJsonString(0).getString(); - reader.close(); - TestUtil.logMsg("actUnicodeChars=" + actUnicodeChars); - - pass = JSONP_Util.assertEquals(expUnicodeChars, actUnicodeChars); - } catch (Exception e) { - logErr("Exception occurred: " + e); - pass = false; - } - if (!pass) - throw new Fault("jsonGeneratorArrayTest5 Failed"); - } - - /* - * @testName: jsonGeneratorObjectConfigTest1 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:289; - * JSONP:JAVADOC:162; JSONP:JAVADOC:416; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * This test uses the configuration feature to PRETTY PRINT. The output is - * written to a Writer, read back as a string and filtered to remove - * whitespace and is compared against an expected string. - * - * { "object":{"string":"string","number":1,"true":true,"false":false,"null": - * null}, "array":["string", 1, true, false, null] } Tests following API call: - * - * JsonGenerator generator = Json.createGeneratorFactory(Map).createGenerator(Writer) - */ - public void jsonGeneratorObjectConfigTest1() throws Fault { - boolean pass = true; - try { - logMsg("Create JsonGenerator using configuration with PRETTY_PRINTING"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig()) - .createGenerator(sWriter); - generateSimpleJsonObject(generator); - - // Dump JsonText output with PRETTY_PRINTING feature - TestUtil.logMsg("PRETTY_PRINTING feature\n" + sWriter.toString()); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}"; - logMsg("Read the JSON text back from Writer removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(sWriter.toString()); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorObjectConfigTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorObjectConfigTest1 Failed"); - } - - /* - * @testName: jsonGeneratorObjectConfigTest2 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:289; - * JSONP:JAVADOC:200; JSONP:JAVADOC:416; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * This test uses the configuration feature to PRETTY PRINT. The output is - * written to a OutputStream, read back as a string and filtered to remove - * whitespace and is compared against an expected string. - * - * { "object":{"string":"string","number":1,"true":true,"false":false,"null": - * null}, "array":["string", 1, true, false, null] } Tests following API call: - * - * JsonGenerator generator = Json.createGeneratorFactory(Map).createGenerator(OutputStream) - */ - public void jsonGeneratorObjectConfigTest2() throws Fault { - boolean pass = true; - try { - logMsg("Create JsonGenerator using configuration with PRETTY_PRINTING"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig()) - .createGenerator(baos); - generateSimpleJsonObject(generator); - - // Dump JsonText output with PRETTY_PRINTING feature - TestUtil.logMsg("PRETTY_PRINTING feature\n" + baos.toString("UTF-8")); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}"; - logMsg("Read the JSON text back from Writer removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8")); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorObjectConfigTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorObjectConfigTest2 Failed"); - } - - /* - * @testName: jsonGeneratorObjectEncodingTest1 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:163; - * JSONP:JAVADOC:289; JSONP:JAVADOC:416; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * The output is written to an OutputStream using UTF-8 encoding, read back as - * a string and filtered to remove whitespace and is compared against an - * expected string. - * - * { "object":{"string":"string","number":1,"true":true,"false":false,"null": - * null}, "array":["string", 1, true, false, null] } - */ - public void jsonGeneratorObjectEncodingTest1() throws Fault { - boolean pass = true; - try { - logMsg("Create JsonGenerator using UTF-8 encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_8); - generateSimpleJsonObject(generator); - - // Dump JsonText output - TestUtil.logMsg("Generator Output=" + baos.toString("UTF-8")); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}"; - logMsg( - "Read the JSON text back from OutputStream using UTF-8 encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8")); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorObjectEncodingTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorObjectEncodingTest1 Failed"); - } - - /* - * @testName: jsonGeneratorObjectEncodingTest2 - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:289; - * JSONP:JAVADOC:163; JSONP:JAVADOC:416; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * This test uses the configuration feature to PRETTY PRINT. The output is - * written to an OutputStream using UTF-16BE encoding, read back as a string - * and filtered to remove whitespace and is compared against an expected - * string. - * - * { "object":{"string":"string","number":1,"true":true,"false":false,"null": - * null}, "array":["string", 1, true, false, null] } Tests the following API - * call: - * - * JsonGenerator generator = Json.createGeneratorFactory(Map).createGenerator(OutputStream, Charset); - */ - public void jsonGeneratorObjectEncodingTest2() throws Fault { - boolean pass = true; - try { - logMsg( - "Create JsonGenerator using configuration with PRETTY_PRINTING using UTF-16BE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getPrettyPrintingConfig()) - .createGenerator(baos, JSONP_Util.UTF_16BE); - generateSimpleJsonObject(generator); - - // Dump JsonText output with PRETTY_PRINTING feature - TestUtil.logMsg("PRETTY_PRINTING feature\n" + baos.toString("UTF-16BE")); - - // Do comparison - logMsg("Create expected JSON text with no whitespace"); - String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}"; - logMsg( - "Read the JSON text back from OutputStream using UTF-16BE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE")); - pass = JSONP_Util.assertEqualsJsonText(expJson, actJson); - - } catch (Exception e) { - throw new Fault("jsonGeneratorObjectEncodingTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonGeneratorObjectEncodingTest2 Failed"); - } - - /* - * @testName: jsonGeneratorUTFEncodedTests - * - * @assertion_ids: JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * JSONP:JAVADOC:295; JSONP:JAVADOC:304; JSONP:JAVADOC:292; JSONP:JAVADOC:317; - * JSONP:JAVADOC:325; JSONP:JAVADOC:319; JSONP:JAVADOC:115; JSONP:JAVADOC:163; - * JSONP:JAVADOC:289; JSONP:JAVADOC:416; - * - * @test_Strategy: Tests various JsonGenerator API's to create a JsonObject. - * - * The output is written to an OutputStream using all supported UTF encodings - * and read back as a string and filtered to remove whitespace and is compared - * against an expected string. The following UTF encodings are tested: - * - * UTF8 UTF16 UTF16LE UTF16BE UTF32LE UTF32BE - * - * { "object":{"string":"string","number":1,"true":true,"false":false,"null": - * null}, "array":["string", 1, true, false, null] } - */ - public void jsonGeneratorUTFEncodedTests() throws Fault { - boolean pass = true; - logMsg( - "Create expected JSON text with no whitespace for use with comparison"); - String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}"; - try { - logMsg( - "-----------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createGeneratorFactory(Map).createGenerator(OutputStream, Charset) as UTF-8]"); - logMsg( - "-----------------------------------------------------------------------------------------------------"); - logMsg("Create JsonGenerator using UTF-8 encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_8); - generateSimpleJsonObject(generator); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-8")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-8 encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing generation to UTF-8 encoding: " + e); - } - try { - logMsg( - "------------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createGeneratorFactory(Map).createGenerator(OutputStream, Charset) as UTF-16]"); - logMsg( - "------------------------------------------------------------------------------------------------------"); - logMsg("Create JsonGenerator using UTF-16 encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_16); - generateSimpleJsonObject(generator); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-16")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-16 encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing generation to UTF-16 encoding: " + e); - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createGeneratorFactory(Map).createGenerator(OutputStream, Charset) as UTF-16LE]"); - logMsg( - "--------------------------------------------------------------------------------------------------------"); - logMsg("Create JsonGenerator using UTF-16LE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_16LE); - generateSimpleJsonObject(generator); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-16LE")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-16LE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16LE")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr( - "Exception occurred testing generation to UTF-16LE encoding: " + e); - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createGeneratorFactory(Map).createGenerator(OutputStream, Charset) as UTF-16BE]"); - logMsg( - "--------------------------------------------------------------------------------------------------------"); - logMsg("Create JsonGenerator using UTF-16BE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_16BE); - generateSimpleJsonObject(generator); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-16BE")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-16BE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr( - "Exception occurred testing generation to UTF-16BE encoding: " + e); - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createGeneratorFactory(Map).createGenerator(OutputStream, Charset) as UTF-32LE]"); - logMsg( - "--------------------------------------------------------------------------------------------------------"); - logMsg("Create JsonGenerator using UTF-32LE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_32LE); - generateSimpleJsonObject(generator); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-32LE")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-32LE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-32LE")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr( - "Exception occurred testing generation to UTF-32LE encoding: " + e); - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createGeneratorFactory(Map).createGenerator(OutputStream, Charset) as UTF-32BE]"); - logMsg( - "--------------------------------------------------------------------------------------------------------"); - logMsg("Create JsonGenerator using UTF-32BE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json - .createGeneratorFactory(JSONP_Util.getEmptyConfig()) - .createGenerator(baos, JSONP_Util.UTF_32BE); - generateSimpleJsonObject(generator); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-32BE")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-32BE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-32BE")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr( - "Exception occurred testing generation to UTF-32BE encoding: " + e); - } - if (!pass) - throw new Fault("jsonGeneratorUTFEncodedTests Failed"); - } - - /* - * @testName: jsonGeneratorExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:339; JSONP:JAVADOC:341; JSONP:JAVADOC:115; - * JSONP:JAVADOC:293; JSONP:JAVADOC:296; JSONP:JAVADOC:299; JSONP:JAVADOC:302; - * JSONP:JAVADOC:305; JSONP:JAVADOC:308; JSONP:JAVADOC:311; JSONP:JAVADOC:315; - * JSONP:JAVADOC:297; JSONP:JAVADOC:303; JSONP:JAVADOC:306; JSONP:JAVADOC:309; - * JSONP:JAVADOC:312; JSONP:JAVADOC:316; JSONP:JAVADOC:336; JSONP:JAVADOC:335; - * JSONP:JAVADOC:290; JSONP:JAVADOC:331; JSONP:JAVADOC:381; JSONP:JAVADOC:382; - * JSONP:JAVADOC:350; JSONP:JAVADOC:352; JSONP:JAVADOC:354; JSONP:JAVADOC:356; - * JSONP:JAVADOC:358; JSONP:JAVADOC:360; JSONP:JAVADOC:362; JSONP:JAVADOC:364; - * JSONP:JAVADOC:366; JSONP:JAVADOC:347; JSONP:JAVADOC:348; JSONP:JAVADOC:368; - * JSONP:JAVADOC:370; JSONP:JAVADOC:372; JSONP:JAVADOC:374; - * - * @test_Strategy: Tests various exception test cases. - * - * NumberFormatException JsonGenerationException - * - */ - public void jsonGeneratorExceptionTests() throws Fault { - boolean pass = true; - - // Test NumberFormatException for write(double) if value is - // Not-a-Number(NaN) or infinity - try { - logMsg( - "Trip NumberFormatException for write(double) if value is Not-a-Number(NaN) or infinity"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write(Double.NaN); - logErr("Did not get expected NumberFormatException"); - pass = false; - } catch (NumberFormatException e) { - logMsg("Caught expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test NumberFormatException for write(double) if value is - // Not-a-Number(NaN) or infinity - try { - logMsg( - "Trip NumberFormatException for write(double) if value is Not-a-Number(NaN) or infinity"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write(Double.NEGATIVE_INFINITY); - logErr("Did not get expected NumberFormatException"); - pass = false; - } catch (NumberFormatException e) { - logMsg("Caught expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test NumberFormatException for write(double) if value is - // Not-a-Number(NaN) or infinity - try { - logMsg( - "Trip NumberFormatException for write(double) if value is Not-a-Number(NaN) or infinity"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write(Double.POSITIVE_INFINITY); - logErr("Did not get expected NumberFormatException"); - pass = false; - } catch (NumberFormatException e) { - logMsg("Caught expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test NumberFormatException for write(String,double) if value is - // Not-a-Number(NaN) or infinity - try { - logMsg( - "Trip NumberFormatException for write(String,double) if value is Not-a-Number(NaN) or infinity"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write("badnumber", Double.NaN); - logErr("Did not get expected NumberFormatException"); - pass = false; - } catch (NumberFormatException e) { - logMsg("Caught expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test NumberFormatException for write(String,double) if value is - // Not-a-Number(NaN) or infinity - try { - logMsg( - "Trip NumberFormatException for write(String,double) if value is Not-a-Number(NaN) or infinity"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write("badnumber", Double.NEGATIVE_INFINITY); - logErr("Did not get expected NumberFormatException"); - pass = false; - } catch (NumberFormatException e) { - logMsg("Caught expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test NumberFormatException for write(String,double) if value is - // Not-a-Number(NaN) or infinity - try { - logMsg( - "Trip NumberFormatException for write(String,double) if value is Not-a-Number(NaN) or infinity"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write("badnumber", Double.POSITIVE_INFINITY); - logErr("Did not get expected NumberFormatException"); - pass = false; - } catch (NumberFormatException e) { - logMsg("Caught expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonGenerationExceptipn if an incomplete JSON is generated. - try { - logMsg( - "Trip JsonGenerationExceptipn if an incomplete JSON is generated."); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write("name", "value"); - generator.close(); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonGenerationExceptipn if an incomplete JSON is generated. - try { - logMsg( - "Trip JsonGenerationExceptipn if an incomplete JSON is generated."); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string"); - generator.close(); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(JsonValue) if not called within - // array context - try { - logMsg( - "Trip JsonGenerationException for write(JsonValue) if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write(JsonValue.TRUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String) if not called within array - // context - try { - logMsg( - "Trip JsonGenerationException for write(String) if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write("name"); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(BigInteger) if not called within - // array context - try { - logMsg( - "Trip JsonGenerationException for write(BigInteger) if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject() - .write(new BigInteger(new Integer(Integer.MAX_VALUE).toString())); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(BigDecimal) if not called within - // array context - try { - logMsg( - "Trip JsonGenerationException for write(BigDecimal) if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write(BigDecimal.valueOf(Integer.MIN_VALUE)); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(int) if not called within array - // context - try { - logMsg( - "Trip JsonGenerationException for write(int) if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write(Integer.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(long) if not called within array - // context - try { - logMsg( - "Trip JsonGenerationException for write(long) if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write(Long.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(double) if not called within array - // context - try { - logMsg( - "Trip JsonGenerationException for write(double) if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write(Double.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(boolean) if not called within - // array context - try { - logMsg( - "Trip JsonGenerationException for write(boolean) if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write(true); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for writeNull() if not called within array - // context - try { - logMsg( - "Trip JsonGenerationException for writeNull() if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeNull(); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for writeStartArray() if not called within - // array context - try { - logMsg( - "Trip JsonGenerationException for writeStartArray() if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeStartArray(); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for writeStartObject() if not called within - // array context - try { - logMsg( - "Trip JsonGenerationException for writeStartObject() if not called within array context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeStartObject(); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,JsonValue) if not called - // within object context - try { - logMsg( - "Trip JsonGenerationException for write(String,JsonValue) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string", JsonValue.TRUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,String) if not called - // within object context - try { - logMsg( - "Trip JsonGenerationException for write(String,String) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string", "name"); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,BigInteger) if not called - // within object context - try { - logMsg( - "Trip JsonGenerationException for write(String,BigInteger) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string", - new BigInteger(new Integer(Integer.MAX_VALUE).toString())); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,BigDecimal) if not called - // within object context - try { - logMsg( - "Trip JsonGenerationException for write(String,BigDecimal) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string", - BigDecimal.valueOf(Integer.MIN_VALUE)); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,int) if not called within - // object context - try { - logMsg( - "Trip JsonGenerationException for write(String,int) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string", Integer.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,long) if not called within - // object context - try { - logMsg( - "Trip JsonGenerationException for write(String,long) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string", Long.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,double) if not called - // within object context - try { - logMsg( - "Trip JsonGenerationException for write(String,double) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string", Double.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,boolean) if not called - // within object context - try { - logMsg( - "Trip JsonGenerationException for write(String,boolean) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write("string", true); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for writeNull(String) if not called within - // object context - try { - logMsg( - "Trip JsonGenerationException for writeNull(String) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeNull("string"); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for writeStartArray(String) if not called - // within object context - try { - logMsg( - "Trip JsonGenerationException for writeStartArray(String) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeStartArray("string"); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for writeStartObject(String) if not called - // within object context - try { - logMsg( - "Trip JsonGenerationException for writeStartObject(String) if not called within object context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeStartObject("string"); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,JsonValue) when invoked - // after the writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(String,JsonValue) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().write("name", "value"); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for writeEnd() when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for writeEnd() when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().writeEnd(); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,BigInteger) when invoked - // after the writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(String,BigInteger) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().write("name", - new BigInteger(new Integer(Integer.MAX_VALUE).toString())); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,BigDecimal) when invoked - // after the writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(String,BigDecimal) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().write("name", - BigDecimal.valueOf(Integer.MIN_VALUE)); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,int) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(String,int) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().write("name", Integer.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,long) when invoked after - // the writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(String,long) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().write("name", Long.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,double) when invoked after - // the writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(String,double) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().write("name", Double.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String,boolean) when invoked after - // the writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(String,boolean) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().write("name", false); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for writeNull(String) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for writeNull(String) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeEnd().writeNull("name"); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(JsonValue) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(JsonValue) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd().write(JsonValue.TRUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(String) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(String) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd().write(JsonValue.TRUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(BigDecimal) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(BigDecimal) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd() - .write(BigDecimal.valueOf(Integer.MIN_VALUE)); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(BigInteger) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(BigInteger) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd() - .write(new BigInteger(new Integer(Integer.MAX_VALUE).toString())); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(int) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(int) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd().write(Integer.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(long) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(long) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd().write(Long.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(double) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(double) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd().write(Double.MAX_VALUE); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for write(boolean) when invoked after the - // writeEnd method is called - try { - logMsg( - "Trip JsonGenerationException for write(boolean) when invoked after the writeEnd method is called"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd().write(true); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test JsonGenerationException for for writeNull() when invoked with no - // context - try { - logMsg( - "Trip JsonGenerationException for for writeNull() when invoked with no context"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().writeEnd().writeNull(); - logErr("Did not get expected JsonGenerationException"); - pass = false; - } catch (JsonGenerationException e) { - logMsg("Caught expected JsonGenerationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonGeneratorExceptionTests Failed"); - } - - /* - * @testName: flushTest - * - * @assertion_ids: JSONP:JAVADOC:131; JSONP:JAVADOC:289; JSONP:JAVADOC:291; - * JSONP:JAVADOC:340; JSONP:JAVADOC:341; JSONP:JAVADOC:342; - * - * @test_Strategy: Generate some partial Json, flush output and compare - * output. Generate additional Json to complete, flush output again and - * compare. Test passes if comparisons are correct. - * - * {"object":{},"array":[]} - */ - public void flushTest() throws Fault { - boolean pass = true; - try { - logMsg("Generate some partial Json and flush output."); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().writeStartObject("object").writeEnd() - .flush(); - - // Do comparison 1 - logMsg("Create expected partial JSON text with no whitespace"); - String expJson = "{\"object\":{}"; - logMsg("Read the JSON text back from Writer removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(sWriter.toString()); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - logMsg("Generate additional Json to complete and flush output."); - generator.writeStartArray("array").writeEnd().writeEnd().flush(); - - // Do comparison 2 - expJson = "{\"object\":{},\"array\":[]}"; - logMsg("Read the JSON text back from Writer removing whitespace"); - actJson = JSONP_Util.removeWhitespace(sWriter.toString()); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - generator.close(); - - } catch (Exception e) { - throw new Fault("flushTest Failed: ", e); - } - if (!pass) - throw new Fault("flushTest Failed"); - } - - /* - * @testName: jsonGeneratorIOErrorTests - * - * @assertion_ids: JSONP:JAVADOC:346; JSONP:JAVADOC:551; - * - * @test_Strategy: Tests for JsonException for testable i/o errors. - * - */ - public void jsonGeneratorIOErrorTests() throws Fault { - boolean pass = true; - - // Trip JsonException if there is an i/o error on JsonGenerator.close() - try { - logMsg( - "Trip JsonException if there is an i/o error on JsonGenerator.close()."); - MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter()); - JsonGenerator generator = Json.createGenerator(mbw); - generator.writeStartObject().writeEnd(); - mbw.setThrowIOException(true); - logMsg("Calling JsonGenerator.close()"); - generator.close(); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException if there is an i/o error on JsonGenerator.flush() - try { - logMsg( - "Trip JsonException if there is an i/o error on JsonGenerator.flush()."); - MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter()); - JsonGenerator generator = Json.createGenerator(mbw); - generator.writeStartObject().writeEnd(); - mbw.setThrowIOException(true); - logMsg("Calling JsonGenerator.flush()"); - generator.flush(); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonGeneratorIOErrorTests Failed"); - } - - /* - * @testName: jsonGeneratorDocumentRootTest - * - * @assertion_ids: JSONP:JAVADOC:317; JSONP:JAVADOC:319; JSONP:JAVADOC:321; - * JSONP:JAVADOC:323; JSONP:JAVADOC:325; JSONP:JAVADOC:327; JSONP:JAVADOC:329; - * JSONP:JAVADOC:332; JSONP:JAVADOC:583; JSONP:JAVADOC:584; JSONP:JAVADOC:585; - * JSONP:JAVADOC:586; JSONP:JAVADOC:587; JSONP:JAVADOC:588; JSONP:JAVADOC:662; - * JSONP:JAVADOC:663; JSONP:JAVADOC:664; JSONP:JAVADOC:665; JSONP:JAVADOC:666; - * JSONP:JAVADOC:667; JSONP:JAVADOC:289; JSONP:JAVADOC:341; JSONP:JAVADOC:672; - * - * @test_Strategy: Tests RFC 7159 grammar changes:
{@code - * "JSON-text = ws value ws"}
{@code - * "value = false / null / true / object / array / number / string"} - */ - public void jsonGeneratorDocumentRootTest() throws Fault { - Generator genTest = new Generator(); - final TestResult result = genTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/Generator.java b/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/Generator.java deleted file mode 100644 index a9db12d22b..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/Generator.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright (c) 2017, 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 com.sun.ts.tests.jsonp.api.jsongeneratortests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BDC_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BIN_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DBL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.LNG_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.toJsonValue; - -import java.io.StringReader; -import java.io.StringWriter; -import java.math.BigDecimal; -import java.math.BigInteger; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonObject; -import jakarta.json.JsonReader; -import jakarta.json.JsonValue; -import jakarta.json.stream.JsonGenerator; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests: {@link JsonGenerator} - * API methods. - */ -public class Generator { - - /** Tests input data. */ - private static final Object[] VALUES = new Object[] { OBJ_VALUE, // write(JsonValue) - // for - // JsonObject - createEmptyArrayWithStr(), // write(JsonValue) for simple JsonArray - STR_VALUE, // write(JsonValue) for String - INT_VALUE, // write(JsonValue) for int - LNG_VALUE, // write(JsonValue) for long - DBL_VALUE, // write(JsonValue) for double - BIN_VALUE, // write(JsonValue) for BigInteger - BDC_VALUE, // write(JsonValue) for BigDecimal - BOOL_VALUE, // write(JsonValue) for boolean - null // write(JsonValue) for null - }; - - /** - * Creates an instance of {@link JsonGenerator} API methods test. - */ - Generator() { - super(); - } - - /** - * Test {@link JsonGenerator} API methods. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonGenerator API methods for RFC 7159 grammar changes."); - TestUtil.logMsg("JsonGenerator API methods for RFC 7159 grammar changes."); - testPrimitiveTypesInRoot(result); - testWrittingObjectByParts(result); - return result; - } - - /** - * Test primitive types as JSON value stored in JSON document root. RFC 7159 - * grammar changes now allows such a values to be stored in JSON document - * root. - */ - private void testPrimitiveTypesInRoot(final TestResult result) { - for (Object value : VALUES) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil - .logMsg(" - write(JsonValue) for " + typeName + " as an argument"); - verifyJsonGeneratorForJsonValue(result, value); - verifyJsonGeneratorForSimpleType(result, value); - } - } - - /** - * Verify JSON object generation using low level methods - * {@code writeStartObject()}, {@code writeEnd()}, {@code writeKey(String)} - * and {@code write(String)}. - */ - private void testWrittingObjectByParts(final TestResult result) { - TestUtil.logMsg(" - generate JSON object"); - final StringWriter strWriter = new StringWriter(); - try (JsonGenerator generator = Json.createGenerator(strWriter)) { - generator.writeStartObject(); - generator.writeKey(STR_NAME); - generator.write(STR_VALUE); - generator.writeEnd(); - } - final String out = strWriter.toString(); - final JsonObject check = createSimpleObjectStr(); - if (operationFailed(check, out)) { - final String checkStr = check.toString(); - TestUtil.logMsg( - " Generated JSON object " + out + " shall be " + checkStr); - result.fail("generate JSON object", - "Generated value " + out + " shall be " + checkStr); - } else { - TestUtil.logMsg(" Output: " + out); - } - - } - - /** - * Verify JSON document root generation for provided JSON value. - */ - private void verifyJsonGeneratorForJsonValue(final TestResult result, - final Object value) { - final StringWriter strWriter = new StringWriter(); - final JsonValue jsonValue = toJsonValue(value); - try (JsonGenerator generator = Json.createGenerator(strWriter)) { - generator.write(jsonValue); - } - final String out = strWriter.toString(); - if (operationFailed(jsonValue, out)) { - final String check = jsonValue.toString(); - TestUtil - .logMsg(" Generated JSON value " + out + " shall be " + check); - result.fail("write(JsonValue)", - "Generated value " + out + " shall be " + check); - } else { - TestUtil.logMsg(" Output (JsonValue): " + out); - } - } - - /** - * Verify JSON document root generation for provided JSON value. - */ - @SuppressWarnings("UnnecessaryUnboxing") - private void verifyJsonGeneratorForSimpleType(final TestResult result, - final Object value) { - final StringWriter strWriter = new StringWriter(); - try (JsonGenerator generator = Json.createGenerator(strWriter)) { - switch (JsonValueType.getType(value)) { - case String: - generator.write((String) value); - break; - case Integer: - generator.write(((Integer) value).intValue()); - break; - case Long: - generator.write(((Long) value).longValue()); - break; - case BigInteger: - generator.write((BigInteger) value); - break; - case Double: - generator.write(((Double) value).doubleValue()); - break; - case BigDecimal: - generator.write((BigDecimal) value); - break; - case Boolean: - generator.write(((Boolean) value).booleanValue() ? JsonValue.TRUE - : JsonValue.FALSE); - break; - case JsonValue: - generator.write((JsonValue) value); - break; - case Null: - generator.write(JsonValue.NULL); - break; - default: - throw new IllegalArgumentException( - "Value does not match known JSON value type"); - } - } - final String out = strWriter.toString(); - if (operationFailed(value, out)) { - final String check = toJsonValue(value).toString(); - TestUtil - .logMsg(" Generated simple value " + out + " shall be " + check); - result.fail("write(JsonValue)", - "Generated value " + out + " shall be " + check); - } else { - TestUtil.logMsg(" Output (simple): " + out); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final Object check, final String out) { - return out == null || !assertEquals(check, out); - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, final String out) { - if (out == null) { - return true; - } - try (final JsonReader reader = Json.createReader(new StringReader(out))) { - final JsonValue actVal = reader.readValue(); - return !assertEquals((JsonValue) check, actVal); - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/build.xml deleted file mode 100644 index d8a93ba4c0..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsongeneratortests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonnumbertests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonnumbertests/Client.java deleted file mode 100644 index e279b9a7b7..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonnumbertests/Client.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonnumbertests; - -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.JsonNumber; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonNumberEqualsTest - * - * @assertion_ids: JSONP:JAVADOC:250; - * - * @test_Strategy: Tests JsonNumber equals method. Create 2 equal JsonNumbers - * and compare them for equality and expect true. Create 2 non-equal - * JsonNumbers and compare them for equality and expect false. - */ - public void jsonNumberEqualsTest() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonNumber 1 for testing"); - JsonNumber number1 = JSONP_Util.createJsonNumber(10); - logMsg("number1=" + JSONP_Util.toStringJsonNumber(number1)); - - logMsg("Create sample JsonNumber 2 for testing"); - JsonNumber number2 = JSONP_Util.createJsonNumber(10); - logMsg("number2=" + JSONP_Util.toStringJsonNumber(number2)); - - logMsg( - "Call JsonNumber.equals() to compare 2 equal JsonNumbers and expect true"); - if (number1.equals(number2)) { - logMsg("JsonNumbers are equal - expected."); - } else { - pass = false; - logErr("JsonNumbers are not equal - unexpected."); - } - - logMsg("Create sample JsonNumber 1 for testing"); - number1 = JSONP_Util.createJsonNumber(10); - logMsg("number1=" + JSONP_Util.toStringJsonNumber(number1)); - - logMsg("Create sample JsonNumber 2 for testing"); - number2 = JSONP_Util.createJsonNumber((double) 10.25); - logMsg("number2=" + JSONP_Util.toStringJsonNumber(number2)); - - logMsg( - "Call JsonNumber.equals() to compare 2 equal JsonNumbers and expect false"); - if (!number1.equals(number2)) { - logMsg("JsonNumbers are not equal - expected."); - } else { - pass = false; - logErr("JsonNumbers are equal - unexpected."); - } - } catch (Exception e) { - throw new Fault("jsonNumberEqualsTest Failed: ", e); - } - if (!pass) - throw new Fault("jsonNumberEqualsTest Failed"); - } - - /* - * @testName: jsonNumberHashCodeTest - * - * @assertion_ids: JSONP:JAVADOC:251; - * - * @test_Strategy: Tests JsonNumber equals method. Create 2 equal JsonNumbers - * and compare them for hashcode and expect true. Create 2 non-equal - * JsonNumbers and compare them for hashcode and expect false. - */ - public void jsonNumberHashCodeTest() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonNumber 1 for testing"); - JsonNumber number1 = JSONP_Util.createJsonNumber(10); - logMsg("number1=" + JSONP_Util.toStringJsonNumber(number1)); - logMsg("number1.hashCode()=" + number1.hashCode()); - - logMsg("Create sample JsonNumber 2 for testing"); - JsonNumber number2 = JSONP_Util.createJsonNumber(10); - logMsg("number2=" + JSONP_Util.toStringJsonNumber(number2)); - logMsg("number2.hashCode()=" + number2.hashCode()); - - logMsg( - "Call JsonNumber.hashCode() to compare 2 equal JsonNumbers and expect true"); - if (number1.hashCode() == number2.hashCode()) { - logMsg("JsonNumbers hashCode are equal - expected."); - } else { - pass = false; - logErr("JsonNumbers hashCode are not equal - unexpected."); - } - - logMsg("Create sample JsonNumber 1 for testing"); - number1 = JSONP_Util.createJsonNumber(10); - logMsg("number1=" + JSONP_Util.toStringJsonNumber(number1)); - logMsg("number1.hashCode()=" + number1.hashCode()); - - logMsg("Create sample JsonNumber 2 for testing"); - number2 = JSONP_Util.createJsonNumber((double) 10.25); - logMsg("number2=" + JSONP_Util.toStringJsonNumber(number2)); - logMsg("number2.hashCode()=" + number2.hashCode()); - - logMsg( - "Call JsonNumber.hashCode() to compare 2 equal JsonNumbers and expect false"); - if (number1.hashCode() != number2.hashCode()) { - logMsg("JsonNumbers hashCode are not equal - expected."); - } else { - pass = false; - logErr("JsonNumbers hashCode are equal - unexpected."); - } - } catch (Exception e) { - throw new Fault("jsonNumberHashCodeTest Failed: ", e); - } - if (!pass) - throw new Fault("jsonNumberHashCodeTest Failed"); - } - - /* - * @testName: jsonNumberIsIntegralTest - * - * @assertion_ids: JSONP:JAVADOC:51; - * - * @test_Strategy: Test JsonNumber.isIntegral() method. - */ - public void jsonNumberIsIntegralTest() throws Fault { - boolean pass = true; - JsonNumber jsonNumber = null; - try { - // INTEGRAL NUMBER TEST - JsonNumber number1 = JSONP_Util.createJsonNumber(123); - if (!JSONP_Util.assertEqualsJsonNumberType(number1.isIntegral(), - JSONP_Util.INTEGRAL)) - pass = false; - else { - if (!JSONP_Util.assertEquals(123, number1.intValue())) - pass = false; - } - // NON_INTEGRAL NUMBER TEST - JsonNumber number2 = JSONP_Util.createJsonNumber(12345.45); - if (!JSONP_Util.assertEqualsJsonNumberType(number2.isIntegral(), - JSONP_Util.NON_INTEGRAL)) - pass = false; - else { - if (!JSONP_Util.assertEquals(12345.45, number2.doubleValue())) - pass = false; - } - - } catch (Exception e) { - throw new Fault("jsonNumberIsIntegralTest Failed: ", e); - } - - if (!pass) - throw new Fault("jsonNumberIsIntegralTest Failed"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonnumbertests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonnumbertests/build.xml deleted file mode 100644 index c87d4fafde..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonnumbertests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/Client.java deleted file mode 100644 index fdea1a4b73..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/Client.java +++ /dev/null @@ -1,1370 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonobjecttests; - -import java.io.StringReader; -import java.io.StringWriter; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import com.sun.ts.tests.jsonp.common.JSONP_Data; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonNumber; -import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; -import jakarta.json.JsonReader; -import jakarta.json.JsonString; -import jakarta.json.JsonValue; -import jakarta.json.JsonWriter; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonObjectTest1 - * - * @assertion_ids: JSONP:JAVADOC:58; JSONP:JAVADOC:61; JSONP:JAVADOC:64; - * JSONP:JAVADOC:67; JSONP:JAVADOC:70; JSONP:JAVADOC:73; JSONP:JAVADOC:76; - * JSONP:JAVADOC:80; JSONP:JAVADOC:86; JSONP:JAVADOC:400; JSONP:JAVADOC:401; - * JSONP:JAVADOC:402; JSONP:JAVADOC:403; JSONP:JAVADOC:404; JSONP:JAVADOC:406; - * JSONP:JAVADOC:408; JSONP:JAVADOC:409; - * - * @test_Strategy: Tests JsonObject/JsonObjectBuilder API's. Build a - * JsonObject using the JsonObjectBuilder API's then verify that the Map of - * JsonObject values matches the expected Map of JsonObject values. - */ - public void jsonObjectTest1() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonObject for testing"); - JsonObject object = JSONP_Util.createSampleJsonObject(); - - logMsg("Create sample JsonArray for testing"); - JsonArray array = JSONP_Util.createSampleJsonArray(); - - logMsg("Create the expected map of JsonObject values"); - Map expMap = new HashMap<>(); - expMap.put("false", JsonValue.FALSE); - expMap.put("true", JsonValue.TRUE); - expMap.put("null", JsonValue.NULL); - expMap.put("doublemin", JSONP_Util.createJsonNumber(Double.MIN_VALUE)); - expMap.put("doublemax", JSONP_Util.createJsonNumber(Double.MAX_VALUE)); - expMap.put("intmin", JSONP_Util.createJsonNumber(Integer.MIN_VALUE)); - expMap.put("intmax", JSONP_Util.createJsonNumber(Integer.MAX_VALUE)); - expMap.put("longmin", JSONP_Util.createJsonNumber(Long.MIN_VALUE)); - expMap.put("longmax", JSONP_Util.createJsonNumber(Long.MAX_VALUE)); - expMap.put("bigdecimal", - JSONP_Util.createJsonNumber(BigDecimal.valueOf(123456789.123456789))); - expMap.put("biginteger", - JSONP_Util.createJsonNumber(new BigInteger("123456789"))); - expMap.put("string", JSONP_Util.createJsonString("string1")); - expMap.put("false2", JsonValue.FALSE); - expMap.put("true2", JsonValue.TRUE); - expMap.put("null2", JsonValue.NULL); - expMap.put("object", object); - expMap.put("array", array); - JSONP_Util.dumpMap(expMap, "Expected Map"); - - logMsg("Create JsonObject using all JsonObjectBuilder API's"); - JsonObject myJsonObject = Json.createObjectBuilder() - .add("false", JsonValue.FALSE).add("true", JsonValue.TRUE) - .add("null", JsonValue.NULL).add("doublemin", Double.MIN_VALUE) - .add("doublemax", Double.MAX_VALUE).add("intmin", Integer.MIN_VALUE) - .add("intmax", Integer.MAX_VALUE).add("longmin", Long.MIN_VALUE) - .add("longmax", Long.MAX_VALUE) - .add("bigdecimal", BigDecimal.valueOf(123456789.123456789)) - .add("biginteger", new BigInteger("123456789")) - .add("string", "string1").add("false2", false).add("true2", true) - .addNull("null2").add("object", object).add("array", array).build(); - - Map actMap = myJsonObject; - JSONP_Util.dumpMap(actMap, "Actual Map"); - logMsg( - "Compare actual Map of JsonObject values with expected Map of JsonObject values"); - pass = JSONP_Util.assertEqualsMap(expMap, actMap); - } catch (Exception e) { - throw new Fault("jsonObjectTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonObjectTest1 Failed"); - } - - /* - * @testName: jsonObjectTest2 - * - * @assertion_ids: JSONP:JAVADOC:86; JSONP:JAVADOC:58; JSONP:JAVADOC:61; - * JSONP:JAVADOC:64; JSONP:JAVADOC:67; JSONP:JAVADOC:70; JSONP:JAVADOC:73; - * JSONP:JAVADOC:76; JSONP:JAVADOC:80; JSONP:JAVADOC:185; JSONP:JAVADOC:400; - * JSONP:JAVADOC:401; JSONP:JAVADOC:402; JSONP:JAVADOC:403; JSONP:JAVADOC:404; - * JSONP:JAVADOC:406; JSONP:JAVADOC:408; JSONP:JAVADOC:409; - * - * @test_Strategy: Tests JsonObject/JsonObjectBuilder API's. Build a - * JsonObject using the JsonObjectBuilder API's. Write the JsonObject to a - * JsonWriter and read it back using a JsonReader. Verify that JsonObject - * written to the JsonWriter and then read back using the JsonReader are - * equal. - */ - public void jsonObjectTest2() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonObject for testing"); - JsonObject object = JSONP_Util.createSampleJsonObject(); - - logMsg("Create sample JsonArray for testing"); - JsonArray array = JSONP_Util.createSampleJsonArray(); - - logMsg( - "Create JsonObject 'myJsonObject1' using all JsonObjectBuilder API's"); - JsonObject myJsonObject1 = Json.createObjectBuilder() - .add("false", JsonValue.FALSE).add("true", JsonValue.TRUE) - .add("null", JsonValue.NULL).add("doublemin", Double.MIN_VALUE) - .add("doublemax", Double.MAX_VALUE).add("intmin", Integer.MIN_VALUE) - .add("intmax", Integer.MAX_VALUE).add("longmin", Long.MIN_VALUE) - .add("longmax", Long.MAX_VALUE) - .add("bigdecimal", BigDecimal.valueOf(123456789.123456789)) - .add("biginteger", new BigInteger("123456789")) - .add("string", "string1").add("false2", false).add("true2", true) - .addNull("null2").add("object", object).add("array", array).build(); - - logMsg("Write the JsonObject 'myJsonObject1' out to a JsonWriter"); - StringWriter sw = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sw)) { - writer.writeObject(myJsonObject1); - logMsg("Close JsonWriter"); - } - logMsg("Save contents of the JsonWriter as a String"); - String contents = sw.toString(); - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + contents); - logMsg( - "Read the JsonObject back into 'myJsonObject2' using a JsonReader"); - JsonObject myJsonObject2; - try (JsonReader reader = Json.createReader(new StringReader(contents))) { - myJsonObject2 = reader.readObject(); - logMsg("Save contents of the JsonReader as a String"); - contents = reader.toString(); - } - logMsg("Dump contents of JsonReader as a String"); - logMsg("JsonReaderContents=" + contents); - - logMsg("Compare myJsonObject1 and myJsonObject2 for equality"); - pass = JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2); - } catch (Exception e) { - throw new Fault("jsonObjectTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonObjectTest2 Failed"); - } - - /* - * @testName: jsonObjectTest3 - * - * @assertion_ids: JSONP:JAVADOC:58; JSONP:JAVADOC:61; JSONP:JAVADOC:64; - * JSONP:JAVADOC:67; JSONP:JAVADOC:70; JSONP:JAVADOC:73; JSONP:JAVADOC:76; - * JSONP:JAVADOC:80; JSONP:JAVADOC:86; JSONP:JAVADOC:215; JSONP:JAVADOC:101; - * JSONP:JAVADOC:403; JSONP:JAVADOC:264; JSONP:JAVADOC:265; JSONP:JAVADOC:436; - * JSONP:JAVADOC:400; JSONP:JAVADOC:401; JSONP:JAVADOC:402; JSONP:JAVADOC:404; - * JSONP:JAVADOC:406; JSONP:JAVADOC:408; JSONP:JAVADOC:409; JSONP:JAVADOC:439; - * JSONP:JAVADOC:441; JSONP:JAVADOC:443; JSONP:JAVADOC:527; JSONP:JAVADOC:529; - * JSONP:JAVADOC:531; JSONP:JAVADOC:533; JSONP:JAVADOC:539; - * - * @test_Strategy: Tests JsonObject/JsonObjectBuilder API's. Build a - * JsonObject using the JsonObjectBuilder API's. Verify contents of JsonObject - * using JsonObject().getJsonArray(String), - * JsonObject().getJsonNumber(String), JsonObject().getJsonObject(String), - * JsonObject().getJsonString(String), JsonObject.getInt(String) and - * JsonObject.getString(String), JsonObject.getBoolean(String), - * JsonObject.getBoolean(String, boolean), JsonObject.getInt(String, int), - * JsonObject.getString(String, String) - */ - public void jsonObjectTest3() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonObject for testing"); - JsonObject object = JSONP_Util.createSampleJsonObject(); - - logMsg("Create sample JsonArray for testing"); - JsonArray array = JSONP_Util.createSampleJsonArray(); - - logMsg("Create myObject JsonObject with 22 name/value pairs"); - JsonObject myObject = Json.createObjectBuilder().add("key0", -1) - .add("key1", +1).add("key2", 1).add("key3", -1e3).add("key4", +1e3) - .add("key5", 1e3).add("key6", -2E3).add("key7", +2E3).add("key8", 2E3) - .add("key9", Long.MAX_VALUE).add("key10", Long.MIN_VALUE) - .add("key11", Integer.MAX_VALUE).add("key12", Integer.MIN_VALUE) - .add("key13", Double.MAX_VALUE).add("key14", Double.MIN_VALUE) - .add("key15", BigDecimal.valueOf(123456789.123456789)) - .add("key16", new BigInteger("123456789")) - .add("key17", JsonValue.TRUE).add("key18", JsonValue.FALSE) - .add("key19", JsonValue.NULL).add("key20", JSONP_Data.asciiCharacters) - .add("key21", false).add("key22", true).addNull("key23") - .add("key24", object).add("key25", array).build(); - logMsg("Checking intValue of key0 for correctness"); - if (!JSONP_Util.assertEquals(-1, - myObject.getJsonNumber("key0").intValue())) - pass = false; - logMsg("key0 via JsonNumber.toString()=" - + myObject.getJsonNumber("key0").toString()); - logMsg("Checking intValue of key1 for correctness"); - if (!JSONP_Util.assertEquals(1, myObject.getInt("key1"))) - pass = false; - logMsg("key1 via JsonNumber.toString()=" + myObject.getInt("key1")); - logMsg("Checking intValue of key2 for correctness"); - if (!JSONP_Util.assertEquals(1, - myObject.getJsonNumber("key2").intValue())) - pass = false; - logMsg("key2 via JsonNumber.toString()=" - + myObject.getJsonNumber("key2").toString()); - logMsg("Checking intValue of key3 for correctness"); - if (!JSONP_Util.assertEquals(-1000, myObject.getInt("key3"))) - pass = false; - logMsg("key3 via JsonNumber.toString()=" - + myObject.getJsonNumber("key3").toString()); - logMsg("Checking intValue of key4 for correctness"); - if (!JSONP_Util.assertEquals(1000, - myObject.getJsonNumber("key4").intValue())) - pass = false; - logMsg("key4 via JsonNumber.toString()=" - + myObject.getJsonNumber("key4").toString()); - logMsg("Checking intValue of key5 for correctness"); - if (!JSONP_Util.assertEquals(1000, - myObject.getJsonNumber("key5").intValue())) - pass = false; - logMsg("key5 via JsonNumber.toString()=" - + myObject.getJsonNumber("key5").toString()); - logMsg("Checking intValue of key6 for correctness"); - if (!JSONP_Util.assertEquals(-2000, - myObject.getJsonNumber("key6").intValue())) - pass = false; - logMsg("key6 via JsonNumber.toString()=" - + myObject.getJsonNumber("key6").toString()); - logMsg("Checking intValue of key7 for correctness"); - if (!JSONP_Util.assertEquals(2000, - myObject.getJsonNumber("key7").intValue())) - pass = false; - logMsg("key7 via JsonNumber.toString()=" - + myObject.getJsonNumber("key7").toString()); - logMsg("Checking intValue of key8 for correctness"); - if (!JSONP_Util.assertEquals(2000, - myObject.getJsonNumber("key8").intValue())) - pass = false; - logMsg("key8 via JsonNumber.toString()=" - + myObject.getJsonNumber("key8").toString()); - logMsg("Checking longValue of key9 for correctness"); - if (!JSONP_Util.assertEquals(Long.MAX_VALUE, - myObject.getJsonNumber("key9").longValue())) - pass = false; - logMsg("LongMax via JsonNumber.toString()=" - + myObject.getJsonNumber("key9").toString()); - if (!JSONP_Util.assertEquals("" + Long.MAX_VALUE, - myObject.getJsonNumber("key9").toString())) - pass = false; - logMsg("Checking longValue of key10 for correctness"); - if (!JSONP_Util.assertEquals(Long.MIN_VALUE, - myObject.getJsonNumber("key10").longValue())) - pass = false; - logMsg("LongMin via JsonNumber.toString()=" - + myObject.getJsonNumber("key10").toString()); - if (!JSONP_Util.assertEquals("" + Long.MIN_VALUE, - myObject.getJsonNumber("key10").toString())) - pass = false; - logMsg("Checking intValue of key11 for correctness"); - if (!JSONP_Util.assertEquals(Integer.MAX_VALUE, - myObject.getJsonNumber("key11").intValue())) - pass = false; - logMsg("IntMax via JsonNumber.toString()=" - + myObject.getJsonNumber("key11").toString()); - if (!JSONP_Util.assertEquals("" + Integer.MAX_VALUE, - myObject.getJsonNumber("key11").toString())) - pass = false; - logMsg("Checking intValue of key12 for correctness"); - if (!JSONP_Util.assertEquals(Integer.MIN_VALUE, - myObject.getJsonNumber("key12").intValue())) - pass = false; - logMsg("IntMin via JsonNumber.toString()=" - + myObject.getJsonNumber("key12").toString()); - if (!JSONP_Util.assertEquals("" + Integer.MIN_VALUE, - myObject.getJsonNumber("key12").toString())) - pass = false; - logMsg("Checking doubleValue of key13 for correctness"); - if (!JSONP_Util.assertEquals(Double.MAX_VALUE, - myObject.getJsonNumber("key13").doubleValue())) - pass = false; - logMsg("Checking doubleValue of key14 for correctness"); - if (!JSONP_Util.assertEquals(Double.MIN_VALUE, - myObject.getJsonNumber("key14").doubleValue())) - pass = false; - logMsg("Checking bigDecimalValue of key15 for correctness"); - if (!JSONP_Util.assertEquals(BigDecimal.valueOf(123456789.123456789), - myObject.getJsonNumber("key15").bigDecimalValue())) - pass = false; - logMsg("Checking bigIntegerValue of key16 for correctness"); - if (!JSONP_Util.assertEquals(new BigInteger("123456789"), - myObject.getJsonNumber("key16").bigIntegerValue())) - pass = false; - logMsg("Checking getBoolean of key17 for correctness"); - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key17"))) - pass = false; - logMsg("Checking getBoolean of key18 for correctness"); - if (!JSONP_Util.assertEquals(false, myObject.getBoolean("key18"))) - pass = false; - logMsg("Checking isNull of key19 for correctness"); - if (!JSONP_Util.assertEquals(true, myObject.isNull("key19"))) - pass = false; - logMsg("Checking getJsonString of key20 for correctness"); - if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters, - myObject.getJsonString("key20").getString())) - pass = false; - logMsg("Checking getString of key20 for correctness"); - if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters, - myObject.getString("key20"))) - pass = false; - logMsg("Checking getBoolean of key21 for correctness"); - if (!JSONP_Util.assertEquals(false, myObject.getBoolean("key21"))) - pass = false; - logMsg("Checking getBoolean of key22 for correctness"); - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key22"))) - pass = false; - logMsg("Checking isNull of key23 for correctness"); - if (!JSONP_Util.assertEquals(true, myObject.isNull("key23"))) - pass = false; - logMsg("Checking getJsonObject of key24 for correctness"); - if (!JSONP_Util.assertEqualsJsonObjects(object, - myObject.getJsonObject("key24"))) - pass = false; - logMsg("Checking getJsonArray of key25 for correctness"); - if (!JSONP_Util.assertEqualsJsonArrays(array, - myObject.getJsonArray("key25"))) - pass = false; - - // Verify calls to JsonObject.getBoolean(int) - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key17"))) - pass = false; - if (!JSONP_Util.assertEquals(false, myObject.getBoolean("key18"))) - pass = false; - - // Verify calls to JsonObject.getBoolean(String, boolean) - logMsg( - "Testing JsonObject.getBoolean(String, boolean) with/without default value setting."); - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key17", false))) - pass = false; - if (!JSONP_Util.assertEquals(false, myObject.getBoolean("key18", true))) - pass = false; - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key0", true))) - pass = false; - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key19", true))) - pass = false; - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key20", true))) - pass = false; - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key24", true))) - pass = false; - if (!JSONP_Util.assertEquals(true, myObject.getBoolean("key25", true))) - pass = false; - - // Verify calls to JsonObject.getInt(String, int) - logMsg( - "Testing JsonObject.getInt(String, int) with/without default value setting."); - if (!JSONP_Util.assertEquals(-1, myObject.getInt("key0", 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myObject.getInt("key18", 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myObject.getInt("key19", 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myObject.getInt("key20", 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myObject.getInt("key24", 10))) - pass = false; - if (!JSONP_Util.assertEquals(10, myObject.getInt("key25", 10))) - pass = false; - - // Verify calls to JsonObject.getString(String, String) - logMsg( - "Testing JsonObject.getString(String, String) with/without default value setting."); - if (!JSONP_Util.assertEquals(JSONP_Data.asciiCharacters, - myObject.getString("key20", "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myObject.getString("key0", "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myObject.getString("key18", "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myObject.getString("key19", "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myObject.getString("key24", "foo"))) - pass = false; - if (!JSONP_Util.assertEquals("foo", myObject.getString("key25", "foo"))) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonObjectTest3 Failed: ", e); - } - if (!pass) - throw new Fault("jsonObjectTest3 Failed"); - } - - /* - * @testName: jsonObjectTest4 - * - * @assertion_ids: JSONP:JAVADOC:61; JSONP:JAVADOC:70; JSONP:JAVADOC:58; - * JSONP:JAVADOC:400; JSONP:JAVADOC:401; JSONP:JAVADOC:403; JSONP:JAVADOC:404; - * JSONP:JAVADOC:406; JSONP:JAVADOC:408; JSONP:JAVADOC:409; JSONP:JAVADOC:438; - * - * @test_Strategy: Build a JsonObject and than write the JsonObject. Compare - * the Json text from the writer contents with the expected Json text output - * expected based on the JsonObject. - */ - public void jsonObjectTest4() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject(); - logMsg("Write the JsonObject 'myJsonObject1' out to a JsonWriter"); - StringWriter sw = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sw)) { - writer.writeObject(myJsonObject1); - logMsg("Close JsonWriter"); - } - logMsg("Save contents of the JsonWriter as a String"); - String contents = sw.toString(); - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + contents); - logMsg("Remove whitespace from contents."); - String actJsonText = JSONP_Util.removeWhitespace(contents); - logMsg( - "Compare expected JsonObject text with actual JsonObject text for equality"); - pass = JSONP_Util.assertEqualsJsonText( - JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonText); - } catch (Exception e) { - throw new Fault("jsonObjectTest4 Failed: ", e); - } - if (!pass) - throw new Fault("jsonObjectTest4 Failed"); - } - - /* - * @testName: jsonObjectExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:43; JSONP:JAVADOC:47; JSONP:JAVADOC:50; - * JSONP:JAVADOC:344; JSONP:JAVADOC:345; JSONP:JAVADOC:79; JSONP:JAVADOC:437; - * JSONP:JAVADOC:440; JSONP:JAVADOC:442; JSONP:JAVADOC:528; JSONP:JAVADOC:530; - * JSONP:JAVADOC:532; JSONP:JAVADOC:534; JSONP:JAVADOC:540; - * - * @test_Strategy: Test JSON exception conditions. Trips the exceptions: - * java.lang.ArithmeticException java.lang.ClassCastException - * java.lang.NumberFormatException java.lang.UnsupportedOperationException - * java.lang.NullPointerException - */ - public void jsonObjectExceptionTests() throws Fault { - boolean pass = true; - JsonObject testObject = null; - JsonArray testArray = null; - - try { - logMsg("Create sample JsonObject for testing"); - testObject = JSONP_Util.createSampleJsonObject(); - - logMsg("Create sample JsonArray for testing"); - testArray = JSONP_Util.createSampleJsonArray(); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to JsonNumber via getJsonNumber(String)"); - JsonNumber value = testObject.getJsonNumber("address"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to JsonString via getJsonString(String)"); - JsonString value = testObject.getJsonString("address"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to JsonArray via getJsonArray(String)"); - JsonArray value = testObject.getJsonArray("address"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to JsonNumber via getNumber(String)"); - JsonNumber value = testObject.getJsonNumber("phoneNumber"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to JsonString via getJsonString(String)"); - JsonString value = testObject.getJsonString("phoneNumber"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to String via getString(String)"); - String value = testObject.getString("address"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to String via getString(String)"); - String value = testObject.getString("phoneNumber"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonObject to int via getInt(String)"); - int value = testObject.getInt("address"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to int via getInt(String)"); - int value = testObject.getInt("phoneNumber"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonArray to JsonObject via getJsonObject(String)"); - JsonObject value = testObject.getJsonObject("phoneNumber"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonNumber to JsonString via getJsonString(String)"); - JsonString value = testObject.getJsonString("age"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonNumber to JsonObject via getJsonNumber(String)"); - JsonObject value = testObject.getJsonObject("age"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonNumber to JsonArray via getJsonArray(String)"); - JsonArray value = testObject.getJsonArray("age"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonString to JsonNumber via getJsonNumber(String)"); - JsonNumber value = testObject.getJsonNumber("firstName"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonString to int via getInt(String)"); - int value = testObject.getInt("firstName"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonString to JsonObject via getJsonString(String)"); - JsonObject value = testObject.getJsonObject("firstName"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonString to JsonArray via getJsonArray(String)"); - JsonArray value = testObject.getJsonArray("firstName"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonValue.FALSE to JsonNumber via getJsonNumber(String)"); - JsonNumber value = testObject.getJsonNumber("elderly"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonValue.FALSE to JsonString via getJsonString(String)"); - JsonString value = testObject.getJsonString("elderly"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonValue.FALSE to JsonObject via getJsonObject(String)"); - JsonObject value = testObject.getJsonObject("elderly"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a JsonValue.FALSE to JsonArray via getJsonArray(String)"); - JsonArray value = testObject.getJsonArray("elderly"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a non JsonValue.FALSE|JsonValue.TRUE to boolean via getBoolean(String)"); - boolean value = testObject.getBoolean("firstName"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a non JsonValue.FALSE|JsonValue.TRUE to boolean via getBoolean(String)"); - boolean value = testObject.getBoolean("age"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a non JsonValue.FALSE|JsonValue.TRUE to boolean via getBoolean(String)"); - boolean value = testObject.getBoolean("objectOfFooBar"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip ClassCastException - try { - logMsg( - "Trip ClassCastException trying to cast a non JsonValue.FALSE|JsonValue.TRUE to boolean via getBoolean(String)"); - boolean value = testObject.getBoolean("arrayOfFooBar"); - pass = false; - logErr("Failed to throw ClassCastException"); - } catch (ClassCastException e) { - logMsg("Got expected ClassCastException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Testing NumberFormatException calling add(String, Double.NaN) - try { - logMsg("Trip NumberFormatException calling add(String, Double.NaN)"); - JsonObject object = Json.createObjectBuilder().add("double", Double.NaN) - .build(); - pass = false; - logErr("Failed to throw NumberFormatException"); - } catch (NumberFormatException e) { - logMsg("Got expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Testing NumberFormatException calling add(String, - // Double.NEGATIVE_INFINITY) - try { - logMsg( - "Trip NumberFormatException calling add(String, Double.NEGATIVE_INFINITY)"); - JsonObject object = Json.createObjectBuilder() - .add("double", Double.NEGATIVE_INFINITY).build(); - pass = false; - logErr("Failed to throw NumberFormatException"); - } catch (NumberFormatException e) { - logMsg("Got expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Testing NumberFormatException calling add(String, - // Double.POSITIVE_INFINITY) - try { - logMsg( - "Trip NumberFormatException calling add(String, Double.POSITIVE_INFINITY)"); - JsonObject object = Json.createObjectBuilder() - .add("double", Double.POSITIVE_INFINITY).build(); - pass = false; - logErr("Failed to throw NumberFormatException"); - } catch (NumberFormatException e) { - logMsg("Got expected NumberFormatException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test for ArithmeticException - try { - logMsg( - "Trip ArithmeticException calling add(\"number\", 12345.12345) and attempting to extract as an exact integer value"); - JsonObject object = Json.createObjectBuilder().add("number", 12345.12345) - .build(); - logMsg("Call JsonObject.getJsonNumber(\"number\").intValueExact()"); - int value = object.getJsonNumber("number").intValueExact(); - pass = false; - logErr("Failed to throw ArithmeticException"); - } catch (ArithmeticException e) { - logMsg("Got expected ArithmeticException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test for ArithmeticException - try { - logMsg( - "Trip ArithmeticException calling add(\"number\", 12345.12345) and attempting to extract as an exact long value"); - JsonObject object = Json.createObjectBuilder().add("number", 12345.12345) - .build(); - logMsg("Call JsonObject.getJsonNumber(\"number\").longValueExact()"); - long value = object.getJsonNumber("number").longValueExact(); - pass = false; - logErr("Failed to throw ArithmeticException"); - } catch (ArithmeticException e) { - logMsg("Got expected ArithmeticException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Test for ArithmeticException - try { - logMsg( - "Trip ArithmeticException calling add(\"number\", 12345.12345) and attempting to extract as an exact biginteger value"); - JsonObject object = Json.createObjectBuilder().add("number", 12345.12345) - .build(); - logMsg( - "Call JsonObject.getJsonNumber(\"number\").bigIntegerValueExact()"); - BigInteger value = object.getJsonNumber("number").bigIntegerValueExact(); - pass = false; - logErr("Failed to throw ArithmeticException"); - } catch (ArithmeticException e) { - logMsg("Got expected ArithmeticException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Tests for UnsupportedOperationException using Collection methods to - // modify JsonObject Map - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonObject.put(K,V) trying to modify JsonObject map which should be immutable"); - testObject.put("foo", JsonValue.FALSE); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonObject.putAll(Map) trying to modify JsonObject map which should be immutable"); - testObject.putAll(testObject); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonObject.clear() trying to modify JsonObject map which should be immutable"); - testObject.clear(); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip UnsupportedOperationException - try { - logMsg( - "Trip UnsupportedOperationException JsonObject.remove(K) trying to modify JsonObject map which should be immutable"); - testObject.remove("firstName"); - pass = false; - logErr("Failed to throw UnsupportedOperationException"); - } catch (UnsupportedOperationException e) { - logMsg("Got expected UnsupportedOperationException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObject.getBoolean(String) when no mapping exists for name."); - boolean value = testObject.getBoolean("foo"); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObject.getInt(String) when no mapping exists for name."); - int value = testObject.getInt("foo"); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObject.getString(String) when no mapping exists for name."); - String value = testObject.getString("foo"); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObject.isNull(String) when no mapping exists for name."); - boolean value = testObject.isNull("foo"); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonObjectExceptionTests Failed"); - } - - /* - * @testName: jsonObjectNullNameValueExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:561; JSONP:JAVADOC:562; JSONP:JAVADOC:563; - * JSONP:JAVADOC:564; JSONP:JAVADOC:565; JSONP:JAVADOC:566; JSONP:JAVADOC:567; - * JSONP:JAVADOC:568; JSONP:JAVADOC:569; JSONP:JAVADOC:570; JSONP:JAVADOC:571; - * - * @test_Strategy: Test JSON NPE exception conditions when attempting to add a - * specified name or value that is null. - */ - public void jsonObjectNullNameValueExceptionTests() throws Fault { - boolean pass = true; - JsonObjectBuilder job = Json.createObjectBuilder(); - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, JsonValue) when name is null."); - job.add(null, JsonValue.TRUE); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, JsonValue) when value is null."); - job.add("name", (JsonValue) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, String) when name is null."); - job.add(null, "value"); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, String) when value is null."); - job.add("name", (String) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, BigInteger) when name is null."); - job.add(null, new BigInteger("123456789")); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, BigInteger) when value is null."); - job.add("name", (BigInteger) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, BigDecimal) when name is null."); - job.add(null, new BigDecimal("123456789")); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, BigDecimal) when value is null."); - job.add("name", (BigDecimal) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, int) when name is null."); - job.add(null, 123456789); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, long) when name is null."); - job.add(null, 123456789L); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, double) when name is null."); - job.add(null, 123456.789); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObject.add(String, boolean) when name is null."); - job.add(null, true); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObject.addNull(String) when name is null."); - job.addNull(null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, JsonObjectBuilder) when name is null."); - job.add(null, Json.createObjectBuilder()); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonObjectBuilder.add(String, JsonObjectBuilder) when value is null."); - job.add("name", (JsonObjectBuilder) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonArrayBuilder.add(String, JsonArrayBuilder) when name is null."); - job.add(null, Json.createArrayBuilder()); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NullPointerException - try { - logMsg( - "Trip NullPointerException for JsonArrayBuilder.add(String, JsonArrayBuilder) when value is null."); - job.add("name", (JsonArrayBuilder) null); - pass = false; - logErr("Failed to throw NullPointerException"); - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonObjectNullNameValueExceptionTests Failed"); - } - - /* - * @testName: jsonCreateObjectBuilder11Test - * - * @assertion_ids: JSONP:JAVADOC:577; JSONP:JAVADOC:578; JSONP:JAVADOC:656; - * JSONP:JAVADOC:657; - * - * @test_Strategy: Tests JsonObjectBuilder API factory methods added in JSON-P - * 1.1. - */ - public void jsonCreateObjectBuilder11Test() throws Fault { - CreateObjectBuilder createTest = new CreateObjectBuilder(); - final TestResult result = createTest.test(); - result.eval(); - } - - /* - * @testName: jsonObjectBuilder11Test - * - * @assertion_ids: JSONP:JAVADOC:618; JSONP:JAVADOC:619; - * - * @test_Strategy: Tests JsonObjectBuilder API methods added in JSON-P 1.1. - */ - public void jsonObjectBuilder11Test() throws Fault { - ObjectBuild buildTest = new ObjectBuild(); - final TestResult result = buildTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/CreateObjectBuilder.java b/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/CreateObjectBuilder.java deleted file mode 100644 index 085e0d4fd1..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/CreateObjectBuilder.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2017, 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 com.sun.ts.tests.jsonp.api.jsonobjecttests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; - -import java.util.HashMap; -import java.util.Map; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests: - * {@link JsonObjectBuilder} API factory methods added in JSON-P 1.1.
- */ -public class CreateObjectBuilder { - - /** - * Creates an instance of {@link JsonObjectBuilder} API factory methods added - * in JSON-P 1.1 test. - */ - CreateObjectBuilder() { - super(); - } - - /** - * Test {@link JsonObjectBuilder} factory method added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonObjectBuilder API factory methods added in JSON-P 1.1."); - TestUtil - .logMsg("JsonObjectBuilder API factory methods added in JSON-P 1.1."); - testCreateFromMap(result); - testCreateFromJsonObject(result); - return result; - } - - /** - * Test {@link Json#createObjectBuilder(Map)} method. - * - * @param result - * Test suite result. - */ - private void testCreateFromMap(final TestResult result) { - TestUtil.logMsg(" - Json#createObjectBuilder(Map)"); - final JsonObject check = createSimpleObjectWithStr(); - Map values = new HashMap<>(2); - values.put(DEF_NAME, DEF_VALUE); - values.put(STR_NAME, STR_VALUE); - final JsonObjectBuilder builder = Json.createObjectBuilder(values); - final JsonObject out = builder.build(); - if (operationFailed(check, out)) { - result.fail("createObjectBuilder(Map)", "Builder output " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test {@link Json#createObjectBuilder(JsonObject)} method. - * - * @param result - * Test suite result. - */ - private void testCreateFromJsonObject(final TestResult result) { - TestUtil.logMsg(" - Json#createObjectBuilder(JsonObject)"); - final JsonObject check = createSimpleObjectWithStr(); - final JsonObjectBuilder builder = Json.createObjectBuilder(check); - final JsonObject out = builder.build(); - if (operationFailed(check, out)) { - result.fail("reateObjectBuilder(JsonObject)", "Builder output " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/ObjectBuild.java b/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/ObjectBuild.java deleted file mode 100644 index 1e6be28d94..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/ObjectBuild.java +++ /dev/null @@ -1,331 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonobjecttests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_OBJ_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_NAME; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.ObjectBuilder; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArrayBuilder; -import jakarta.json.JsonObject; -import jakarta.json.JsonObjectBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests for {@link JsonObject} - * and {@link JsonObjectBuilder}. - */ -public class ObjectBuild { - - /** - * Creates an instance of JavaScript Object Notation (JSON) compatibility - * tests for {@link JsonObject} and {@link JsonObjectBuilder}. - */ - ObjectBuild() { - super(); - } - - /** - * {@link JsonArrayBuilder} API remove() methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonObjectBuilder API methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonObjectBuilder API methods added in JSON-P 1.1."); - testAddString(result); - testAddInt(result); - testAddBool(result); - testAddObject(result); - testAddAllNull(result); - testRemoveString(result); - testRemoveInt(result); - testRemoveBool(result); - testRemoveObject(result); - testRemoveNull(result); - return result; - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonObjectBuilder)} method on - * {@code String} value. - * - * @param result - * Test suite result. - */ - private void testAddString(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonObjectBuilder) for String"); - final JsonObjectBuilder target = ObjectBuilder - .add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE); - final JsonObjectBuilder arg = ObjectBuilder.add(Json.createObjectBuilder(), - STR_NAME, STR_VALUE); - final JsonObject check = createSimpleObjectWithStr(); - verifyAddAll(result, check, target, arg); - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonObjectBuilder)} method on - * {@code int} value. - * - * @param result - * Test suite result. - */ - private void testAddInt(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonObjectBuilder) for int"); - final JsonObjectBuilder target = ObjectBuilder - .add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE); - final JsonObjectBuilder arg = ObjectBuilder.add(Json.createObjectBuilder(), - INT_NAME, INT_VALUE); - final JsonObject check = createSimpleObjectWithInt(); - verifyAddAll(result, check, target, arg); - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonObjectBuilder)} method on - * {@code boolean} value. - * - * @param result - * Test suite result. - */ - private void testAddBool(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonObjectBuilder) for boolean"); - final JsonObjectBuilder target = ObjectBuilder - .add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE); - final JsonObjectBuilder arg = ObjectBuilder.add(Json.createObjectBuilder(), - BOOL_NAME, BOOL_VALUE); - final JsonObject check = createSimpleObjectWithBool(); - verifyAddAll(result, check, target, arg); - } - - /** - * Test {@code JsonArrayBuilder addAll(JsonObjectBuilder)} method on - * {@code JsonObject} value. - * - * @param result - * Test suite result. - */ - private void testAddObject(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonObjectBuilder) for JsonObject"); - final JsonObjectBuilder target = ObjectBuilder - .add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE) - .add(DEF_OBJ_NAME, DEF_OBJ_VALUE); - final JsonObjectBuilder arg = ObjectBuilder.add(Json.createObjectBuilder(), - OBJ_NAME, OBJ_VALUE); - final JsonObject check = createCompoundObjectWithObject(); - verifyAddAll(result, check, target, arg); - } - - /** - * Test {@code JsonObjectBuilder addAll(JsonObjectBuilder)} method with - * {@code null} builder argument. - * - * @param result - * Test suite result. - */ - private void testAddAllNull(final TestResult result) { - TestUtil.logMsg(" - addAll(JsonObjectBuilder) for null builder argument"); - JsonObjectBuilder builder = Json.createObjectBuilder(); - try { - builder.addAll((JsonObjectBuilder) null); - result.fail("addAll(null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("addAll(null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test {@code JsonObjectBuilder remove(String)} method on {@code String} - * value. - * - * @param result - * Test suite result. - */ - private void testRemoveString(final TestResult result) { - TestUtil.logMsg(" - remove(String) for String"); - final JsonObjectBuilder in = ObjectBuilder - .add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE) - .add(STR_NAME, STR_VALUE); - final JsonObjectBuilder builder = in.remove(STR_NAME); - final JsonObject check = createSimpleObject(); - verifyRemovel(result, check, builder); - } - - /** - * Test {@code JsonObjectBuilder remove(String)} method on {@code int} value. - * - * @param result - * Test suite result. - */ - private void testRemoveInt(final TestResult result) { - TestUtil.logMsg(" - remove(String) for int"); - final JsonObjectBuilder in = ObjectBuilder - .add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE) - .add(INT_NAME, INT_VALUE); - final JsonObjectBuilder builder = in.remove(INT_NAME); - final JsonObject check = createSimpleObject(); - verifyRemovel(result, check, builder); - } - - /** - * Test {@code JsonObjectBuilder remove(String)} method on {@code boolean} - * value. - * - * @param result - * Test suite result. - */ - private void testRemoveBool(final TestResult result) { - TestUtil.logMsg(" - remove(String) for boolean"); - final JsonObjectBuilder in = ObjectBuilder - .add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE) - .add(BOOL_NAME, BOOL_VALUE); - final JsonObjectBuilder builder = in.remove(BOOL_NAME); - final JsonObject check = createSimpleObject(); - verifyRemovel(result, check, builder); - } - - /** - * Test {@code JsonObjectBuilder remove(String)} method on {@code JsonObject} - * value. - * - * @param result - * Test suite result. - */ - private void testRemoveObject(final TestResult result) { - TestUtil.logMsg(" - remove(String) for JsonObject"); - final JsonObjectBuilder in = ObjectBuilder - .add(Json.createObjectBuilder(), DEF_NAME, DEF_VALUE) - .add(DEF_OBJ_NAME, DEF_OBJ_VALUE).add(OBJ_NAME, OBJ_VALUE); - final JsonObjectBuilder builder = in.remove(OBJ_NAME); - final JsonObject check = createCompoundObject(); - verifyRemovel(result, check, builder); - } - - /** - * Test {@code JsonObjectBuilder remove(String)} method with {@code null} - * name. - * - * @param result - * Test suite result. - */ - private void testRemoveNull(final TestResult result) { - TestUtil.logMsg(" - remove(String) for null name argument"); - JsonObjectBuilder builder = Json.createObjectBuilder(); - try { - builder.remove((String) null); - result.fail("remove(null)", - "Calling method with null argument shall throw NullPointerException"); - } catch (NullPointerException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("remove(null)", - "Calling method with null argument shall throw NullPointerException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test helper: Verify {@code JsonObjectBuilder addAll(JsonObjectBuilder)} - * method on provided builders. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param target - * Builder instance used to call {@code addAll(JsonObjectBuilder)} - * method. - * @param arg - * Builder instance passed as an argument. - */ - private void verifyAddAll(final TestResult result, final JsonObject check, - JsonObjectBuilder target, final JsonObjectBuilder arg) { - target.addAll(arg); - final JsonObject out = target.build(); - if (operationFailed(check, out)) { - result.fail("addAll(JsonObjectBuilder)", "Output builder " - + valueToString(out) + " value shall be " + valueToString(check)); - } - } - - /** - * Test helper: Verify {@code JsonObjectBuilder remove(String)} method on - * provided builder. - * - * @param result - * Test suite result. - * @param check - * Expected value (used for operation check). - * @param builder - * Builder instance after {@code JsonObjectBuilder remove(String)} - * method was called. - * @param arg - * Builder instance passed as an argument. - */ - private void verifyRemovel(final TestResult result, final JsonObject check, - JsonObjectBuilder builder) { - final JsonObject out = builder.build(); - if (operationFailed(check, out)) { - result.fail("remove(String)", "Output builder " + valueToString(out) - + " value shall be " + valueToString(check)); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/build.xml deleted file mode 100644 index 91e4949977..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonobjecttests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonparsereventtests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonparsereventtests/Client.java deleted file mode 100644 index 0f84d55c7c..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonparsereventtests/Client.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonparsereventtests; - -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.stream.JsonParser; - -public class Client extends ServiceEETest { - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonValueOfTest - * - * @assertion_ids: JSONP:JAVADOC:128; - * - * @test_Strategy: Test JsonParser.Event.valueOf() API method call with all - * JsonParser.Event types. - * - */ - public void jsonValueOfTest() throws Fault { - boolean pass = true; - - String eventTypeStrings[] = { "END_ARRAY", "END_OBJECT", "KEY_NAME", - "START_ARRAY", "START_OBJECT", "VALUE_FALSE", "VALUE_NULL", - "VALUE_NUMBER", "VALUE_STRING", "VALUE_TRUE" }; - - for (String eventTypeString : eventTypeStrings) { - JsonParser.Event eventType; - try { - logMsg( - "Testing enum value for string constant name " + eventTypeString); - eventType = JsonParser.Event.valueOf(eventTypeString); - logMsg("Got enum type " + eventType + " for enum string constant named " - + eventTypeString); - } catch (Exception e) { - logErr("Caught unexpected exception: " + e); - pass = false; - } - - } - - logMsg("Testing negative test case for NullPointerException"); - try { - JsonParser.Event.valueOf(null); - logErr("did not get expected NullPointerException"); - pass = false; - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - logErr("Got unexpected exception " + e); - pass = false; - } - - logMsg("Testing negative test case for IllegalArgumentException"); - try { - JsonParser.Event.valueOf("INVALID"); - logErr("did not get expected IllegalArgumentException"); - pass = false; - } catch (IllegalArgumentException e) { - logMsg("Got expected IllegalArgumentException"); - } catch (Exception e) { - logErr("Got unexpected exception " + e); - pass = false; - } - - if (!pass) - throw new Fault("jsonValueOfTest Failed"); - } - - /* - * @testName: jsonValuesTest - * - * @assertion_ids: JSONP:JAVADOC:129; - * - * @test_Strategy: Test JsonParser.Event.values() API method call and verify - * enums returned. - * - */ - public void jsonValuesTest() throws Fault { - boolean pass = true; - - logMsg( - "Testing API method JsonParser.Event.values() to return array of enums."); - JsonParser.Event[] values = JsonParser.Event.values(); - - for (JsonParser.Event eventType : values) { - String eventString = JSONP_Util.getEventTypeString(eventType); - if (eventString == null) { - logErr("Got no value for enum " + eventType); - pass = false; - } else - logMsg("Got " + eventString + " for enum " + eventType); - } - - if (!pass) - throw new Fault("jsonValuesTest Failed"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonparsereventtests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonparsereventtests/build.xml deleted file mode 100644 index c02ca3fe98..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonparsereventtests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonparserfactorytests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonparserfactorytests/Client.java deleted file mode 100644 index aa55c03cf5..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonparserfactorytests/Client.java +++ /dev/null @@ -1,581 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id: Client.java 66863 2012-07-23 11:26:40Z adf $ - */ -package com.sun.ts.tests.jsonp.api.jsonparserfactorytests; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.io.StringReader; -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.common.JSONP_Util; -import com.sun.ts.tests.jsonp.common.MyBufferedInputStream; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.stream.JsonParser; -import jakarta.json.stream.JsonParserFactory; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonParserFactoryTest1 - * - * @assertion_ids: JSONP:JAVADOC:417; JSONP:JAVADOC:164; - * - * @test_Strategy: Tests the JsonParserFactory API. - * - * JsonParserFactory parserFactory = Json.createParserFactory(Map); - * JsonParser parser1 = parserFactory.createParser(Reader) JsonParser parser2 - * = parserFactory.createParser(Reader) - */ - public void jsonParserFactoryTest1() throws Fault { - boolean pass = true; - JsonParser parser1 = null; - JsonParser parser2 = null; - JsonParser.Event event = null; - try { - logMsg("Create JsonParserFactory with a configuration"); - JsonParserFactory parserFactory = Json - .createParserFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = parserFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("--------------------------------------------------"); - logMsg("TEST CASE [JsonParserFactory.createParser(Reader)]"); - logMsg("--------------------------------------------------"); - String jsonObjectString = "{\"foo\":\"bar\"}"; - logMsg("Create 1st JsonParser from the Reader using JsonParserFactory"); - parser1 = parserFactory.createParser(new StringReader(jsonObjectString)); - if (parser1 == null) { - logErr("ParserFactory failed to create parser1 from Reader"); - pass = false; - } else { - logMsg("Parsing " + jsonObjectString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser1, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser1, "foo", "bar"); - JSONP_Util.testEventType(parser1, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - logMsg("Create 2nd JsonParser from the Reader using JsonParserFactory"); - parser2 = parserFactory.createParser(new StringReader(jsonObjectString)); - if (parser2 == null) { - logErr("ParserFactory failed to create parser2 from Reader"); - pass = false; - } else { - logMsg("Parsing " + jsonObjectString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser2, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser2, "foo", "bar"); - JSONP_Util.testEventType(parser2, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - } catch (Exception e) { - throw new Fault("jsonParserFactoryTest1 Failed: ", e); - } finally { - try { - parser1.close(); - parser2.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserFactoryTest1 Failed"); - } - - /* - * @testName: jsonParserFactoryTest2 - * - * @assertion_ids: JSONP:JAVADOC:417; JSONP:JAVADOC:166; - * - * @test_Strategy: Tests the JsonParserFactory API. - * - * JsonParserFactory parserFactory = Json.createParserFactory(Map); - * JsonParser parser1 = parserFactory.createParser(JsonObject) JsonParser - * parser2 = parserFactory.createParser(JsonObject) - */ - public void jsonParserFactoryTest2() throws Fault { - boolean pass = true; - JsonParser parser1 = null; - JsonParser parser2 = null; - JsonParser.Event event = null; - try { - logMsg("Create JsonParserFactory with a configuration"); - JsonParserFactory parserFactory = Json - .createParserFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = parserFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("------------------------------------------------------"); - logMsg("TEST CASE [JsonParserFactory.createParser(JsonObject)]"); - logMsg("------------------------------------------------------"); - String jsonObjectString = "{\"foo\":\"bar\"}"; - JsonObject jsonObj = JSONP_Util - .createJsonObjectFromString(jsonObjectString); - logMsg( - "Create 1st JsonParser from the JsonObject using JsonParserFactory"); - parser1 = parserFactory.createParser(jsonObj); - if (parser1 == null) { - logErr("ParserFactory failed to create parser1 from JsonObject"); - pass = false; - } else { - logMsg("Parsing " + jsonObjectString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser1, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser1, "foo", "bar"); - JSONP_Util.testEventType(parser1, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - logMsg( - "Create 2nd JsonParser from the JsonObject using JsonParserFactory"); - parser2 = parserFactory.createParser(jsonObj); - if (parser2 == null) { - logErr("ParserFactory failed to create parser2 from JsonObject"); - pass = false; - } else { - logMsg("Parsing " + jsonObjectString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser2, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser2, "foo", "bar"); - JSONP_Util.testEventType(parser2, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - } catch (Exception e) { - throw new Fault("jsonParserFactoryTest2 Failed: ", e); - } finally { - try { - parser1.close(); - parser2.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserFactoryTest2 Failed"); - } - - /* - * @testName: jsonParserFactoryTest3 - * - * @assertion_ids: JSONP:JAVADOC:417; JSONP:JAVADOC:167; - * - * @test_Strategy: Tests the JsonParserFactory API. - * - * JsonParserFactory parserFactory = Json.createParserFactory(Map); - * JsonParser parser1 = parserFactory.createParser(JsonArray) JsonParser - * parser2 = parserFactory.createParser(JsonArray) - */ - public void jsonParserFactoryTest3() throws Fault { - boolean pass = true; - JsonParser parser1 = null; - JsonParser parser2 = null; - JsonParser.Event event = null; - try { - logMsg("Create JsonParserFactory with a configuration"); - JsonParserFactory parserFactory = Json - .createParserFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = parserFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-----------------------------------------------------"); - logMsg("TEST CASE [JsonParserFactory.createParser(JsonArray)]"); - logMsg("-----------------------------------------------------"); - String jsonArrayString = "[\"foo\",\"bar\"]"; - JsonArray jsonArr = JSONP_Util.createJsonArrayFromString(jsonArrayString); - logMsg( - "Create 1st JsonParser from the JsonArray using JsonParserFactory"); - parser1 = parserFactory.createParser(jsonArr); - if (parser1 == null) { - logErr("ParserFactory failed to create parser1 from JsonArray"); - pass = false; - } else { - logMsg("Parsing " + jsonArrayString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser1, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser1, "foo"); - JSONP_Util.testStringValue(parser1, "bar"); - JSONP_Util.testEventType(parser1, JsonParser.Event.END_ARRAY); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - logMsg( - "Create 2nd JsonParser from the JsonArray using JsonParserFactory"); - parser2 = parserFactory.createParser(jsonArr); - if (parser2 == null) { - logErr("ParserFactory failed to create parser2 from JsonArray"); - pass = false; - } else { - logMsg("Parsing " + jsonArrayString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser2, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser2, "foo"); - JSONP_Util.testStringValue(parser2, "bar"); - JSONP_Util.testEventType(parser2, JsonParser.Event.END_ARRAY); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - } catch (Exception e) { - throw new Fault("jsonParserFactoryTest3 Failed: ", e); - } finally { - try { - parser1.close(); - parser2.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserFactoryTest3 Failed"); - } - - /* - * @testName: jsonParserFactoryTest4 - * - * @assertion_ids: JSONP:JAVADOC:417; JSONP:JAVADOC:165; - * - * @test_Strategy: Tests the JsonParserFactory API. - * - * JsonParserFactory parserFactory = Json.createParserFactory(Map); - * JsonParser parser1 = parserFactory.createParser(InputStream) JsonParser - * parser2 = parserFactory.createParser(InputStream) - */ - public void jsonParserFactoryTest4() throws Fault { - boolean pass = true; - JsonParser parser1 = null; - JsonParser parser2 = null; - JsonParser.Event event = null; - try { - logMsg("Create JsonParserFactory with a configuration"); - JsonParserFactory parserFactory = Json - .createParserFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = parserFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-------------------------------------------------------"); - logMsg("TEST CASE [JsonParserFactory.createParser(InputStream)]"); - logMsg("-------------------------------------------------------"); - String jsonObjectString = "{\"foo\":\"bar\"}"; - logMsg( - "Create 1st JsonParser from the InputStream using JsonParserFactory"); - parser1 = parserFactory.createParser(new ByteArrayInputStream( - jsonObjectString.getBytes(JSONP_Util.UTF_8))); - if (parser1 == null) { - logErr("ParserFactory failed to create parser1 from InputStream"); - pass = false; - } else { - logMsg("Parsing " + jsonObjectString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser1, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser1, "foo", "bar"); - JSONP_Util.testEventType(parser1, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - logMsg( - "Create 2nd JsonParser from the InputStream using JsonParserFactory"); - parser2 = parserFactory.createParser(new ByteArrayInputStream( - jsonObjectString.getBytes(JSONP_Util.UTF_8))); - if (parser2 == null) { - logErr("ParserFactory failed to create parser2 from InputStream"); - pass = false; - } else { - logMsg("Parsing " + jsonObjectString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser2, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser2, "foo", "bar"); - JSONP_Util.testEventType(parser2, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - } catch (Exception e) { - throw new Fault("jsonParserFactoryTest4 Failed: ", e); - } finally { - try { - parser1.close(); - parser2.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserFactoryTest4 Failed"); - } - - /* - * @testName: jsonParserFactoryTest5 - * - * @assertion_ids: JSONP:JAVADOC:417; JSONP:JAVADOC:201; - * - * @test_Strategy: Tests the JsonParserFactory API. - * - * JsonParserFactory parserFactory = Json.createParserFactory(Map); - * JsonParser parser1 = parserFactory.createParser(InputStream, Charset) - * JsonParser parser2 = parserFactory.createParser(InputStream, Charset) - */ - public void jsonParserFactoryTest5() throws Fault { - boolean pass = true; - JsonParser parser1 = null; - JsonParser parser2 = null; - JsonParser.Event event = null; - try { - logMsg("Create JsonParserFactory with a configuration"); - JsonParserFactory parserFactory = Json - .createParserFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = parserFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg( - "----------------------------------------------------------------"); - logMsg( - "TEST CASE [JsonParserFactory.createParser(InputStream, Charset)]"); - logMsg( - "----------------------------------------------------------------"); - String jsonObjectString = "{\"foo\":\"bar\"}"; - logMsg( - "Create 1st JsonParser from the InputStream using JsonParserFactory"); - parser1 = parserFactory.createParser( - new ByteArrayInputStream(jsonObjectString.getBytes(JSONP_Util.UTF_8)), - JSONP_Util.UTF_8); - if (parser1 == null) { - logErr("ParserFactory failed to create parser1 from InputStream"); - pass = false; - } else { - logMsg("Parsing " + jsonObjectString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser1, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser1, "foo", "bar"); - JSONP_Util.testEventType(parser1, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - logMsg( - "Create 2nd JsonParser from the InputStream using JsonParserFactory"); - parser2 = parserFactory.createParser( - new ByteArrayInputStream(jsonObjectString.getBytes(JSONP_Util.UTF_8)), - JSONP_Util.UTF_8); - if (parser2 == null) { - logErr("ParserFactory failed to create parser2 from InputStream"); - pass = false; - } else { - logMsg("Parsing " + jsonObjectString); - logMsg("Verify that JSON Parser Events/Data matches"); - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser2, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser2, "foo", "bar"); - JSONP_Util.testEventType(parser2, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } - - } catch (Exception e) { - throw new Fault("jsonParserFactoryTest5 Failed: ", e); - } finally { - try { - parser1.close(); - parser2.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserFactoryTest5 Failed"); - } - - /* - * @testName: jsonParserFactoryTest6 - * - * @assertion_ids: JSONP:JAVADOC:417; JSONP:JAVADOC:164; JSONP:JAVADOC:428; - * - * @test_Strategy: Tests the JsonParserFactory API. - * - * JsonParserFactory parserFactory = Json.createParserFactory(Map); - * Map config = JsonParserFactory.getConfigInUse(); - * - * Test for the following 2 scenarios: 1) no supported provider property - * (empty config) 2) non supported provider property - */ - public void jsonParserFactoryTest6() throws Fault { - boolean pass = true; - JsonParserFactory parserFactory; - Map config; - try { - logMsg("----------------------------------------------"); - logMsg("Test scenario1: no supported provider property"); - logMsg("----------------------------------------------"); - logMsg("Create JsonParserFactory with Map with EMPTY config"); - parserFactory = Json.createParserFactory(JSONP_Util.getEmptyConfig()); - config = parserFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-----------------------------------------------"); - logMsg("Test scenario2: non supported provider property"); - logMsg("-----------------------------------------------"); - logMsg("Create JsonParserFactory with Map with FOO config"); - parserFactory = Json.createParserFactory(JSONP_Util.getFooConfig()); - config = parserFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParserFactoryTest6 Failed: ", e); - } - if (!pass) - throw new Fault("jsonParserFactoryTest6 Failed"); - } - - /* - * @testName: jsonParserFactoryExceptionTest - * - * @assertion_ids: JSONP:JAVADOC:225; - * - * @test_Strategy: Test JsonParserFactory exception conditions. Trip the - * following exception due to unknown encoding or i/o error: - * - * jakarta.json.JsonException - */ - public void jsonParserFactoryExceptionTest() throws Fault { - boolean pass = true; - - // Tests JsonParserFactory.createParser(InputStream) for JsonException if - // i/o error - try { - logMsg( - "Tests JsonParserFactory.createParser(InputStream) for JsonException if i/o error."); - JsonParserFactory parserFactory = Json - .createParserFactory(JSONP_Util.getEmptyConfig()); - MyBufferedInputStream mbi = new MyBufferedInputStream( - JSONP_Util.getInputStreamFromString("{}"), true); - JsonParser parser = parserFactory.createParser(mbi); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Tests JsonParserFactory.createParser(InputStream) for JsonException if - // unknown encoding - try { - logMsg( - "Tests JsonParserFactory.createParser(InputStream) for JsonException if unknown encoding."); - JsonParserFactory parserFactory = Json - .createParserFactory(JSONP_Util.getEmptyConfig()); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectUnknownEncoding.json"); - JsonParser parser = parserFactory.createParser(is); - logMsg("parser=" + parser); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonParserFactoryExceptionTest Failed"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonparserfactorytests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonparserfactorytests/build.xml deleted file mode 100644 index e65ca01a14..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonparserfactorytests/build.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonparsertests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonparsertests/Client.java deleted file mode 100644 index 4df1898ece..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonparsertests/Client.java +++ /dev/null @@ -1,1900 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonparsertests; - -import java.io.InputStream; -import java.io.StringReader; -import java.math.BigDecimal; -import java.util.NoSuchElementException; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import com.sun.ts.tests.jsonp.common.JSONP_Data; -import com.sun.ts.tests.jsonp.common.JSONP_Util; -import com.sun.ts.tests.jsonp.common.MyBufferedInputStream; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.stream.JsonParser; -import jakarta.json.stream.JsonParsingException; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* - * Utitity method to parse various JsonObjectUTF encoded files - */ - private boolean parseAndVerify_JsonObjectUTF(JsonParser parser) - throws Exception { - boolean pass = true; - - try { - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser, "stringName", "stringValue"); - JSONP_Util.testKeyStartObjectValue(parser, "objectName"); - JSONP_Util.testKeyStringValue(parser, "foo", "bar"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testKeyStartArrayValue(parser, "arrayName"); - JSONP_Util.testIntegerValue(parser, 1); - JSONP_Util.testIntegerValue(parser, 2); - JSONP_Util.testIntegerValue(parser, 3); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } catch (Exception e) { - throw e; - } - return pass; - } - - /* - * Utitity method to parse JsonObjectWithAllTypesOfData - */ - private boolean parseAndVerify_JsonObjectWithAllTypesOfData(JsonParser parser) - throws Exception { - boolean pass = true; - - try { - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser, "emptyString", ""); - JSONP_Util.testKeyStartArrayValue(parser, "emptyArray"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testKeyStartObjectValue(parser, "emptyObject"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testKeyStringValue(parser, "string", "string"); - JSONP_Util.testKeyIntegerValue(parser, "number", 100); - JSONP_Util.testKeyTrueValue(parser, "true"); - JSONP_Util.testKeyFalseValue(parser, "false"); - JSONP_Util.testKeyNullValue(parser, "null"); - JSONP_Util.testKeyStartObjectValue(parser, "object"); - JSONP_Util.testKeyStringValue(parser, "emptyString", ""); - JSONP_Util.testKeyStartArrayValue(parser, "emptyArray"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testKeyStartObjectValue(parser, "emptyObject"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testKeyStringValue(parser, "string", "string"); - JSONP_Util.testKeyIntegerValue(parser, "number", 100); - JSONP_Util.testKeyTrueValue(parser, "true"); - JSONP_Util.testKeyFalseValue(parser, "false"); - JSONP_Util.testKeyNullValue(parser, "null"); - JSONP_Util.testKeyStartObjectValue(parser, "object"); - JSONP_Util.testKeyStringValue(parser, "name", "value"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testKeyStartArrayValue(parser, "array"); - JSONP_Util.testStringValue(parser, "one"); - JSONP_Util.testStringValue(parser, "two"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testKeyStartArrayValue(parser, "array"); - JSONP_Util.testStringValue(parser, "string"); - JSONP_Util.testIntegerValue(parser, 100); - JSONP_Util.testTrueValue(parser, JsonParser.Event.VALUE_TRUE); - JSONP_Util.testFalseValue(parser, JsonParser.Event.VALUE_FALSE); - JSONP_Util.testNullValue(parser, JsonParser.Event.VALUE_NULL); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser, "name", "value"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser, "one"); - JSONP_Util.testStringValue(parser, "two"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testKeyIntegerValue(parser, "intPositive", 100); - JSONP_Util.testKeyIntegerValue(parser, "intNegative", -100); - JSONP_Util.testKeyLongValue(parser, "longMax", 9223372036854775807L); - JSONP_Util.testKeyLongValue(parser, "longMin", -9223372036854775808L); - JSONP_Util.testKeyDoubleValue(parser, "fracPositive", (double) 0.5); - JSONP_Util.testKeyDoubleValue(parser, "fracNegative", (double) -0.5); - JSONP_Util.testKeyDoubleValue(parser, "expPositive1", (double) 7e3); - JSONP_Util.testKeyDoubleValue(parser, "expPositive2", (double) 7e+3); - JSONP_Util.testKeyDoubleValue(parser, "expPositive3", (double) 9E3); - JSONP_Util.testKeyDoubleValue(parser, "expPositive4", (double) 9E+3); - JSONP_Util.testKeyDoubleValue(parser, "expNegative1", (double) 7e-3); - JSONP_Util.testKeyDoubleValue(parser, "expNegative2", (double) 7E-3); - JSONP_Util.testKeyStringValue(parser, "asciiChars", - JSONP_Data.asciiCharacters); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } catch (Exception e) { - throw e; - } - return pass; - } - - /* - * Utitity method to parse JsonObjectWithLotsOfNestedObjectsData - */ - private boolean parseAndVerify_JsonObjectWithLotsOfNestedObjectsData( - JsonParser parser) throws Exception { - boolean pass = true; - - try { - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - for (int i = 1; i < 31; i++) { - JSONP_Util.testKeyStartObjectValue(parser, "nested" + i); - JSONP_Util.testKeyStringValue(parser, "name" + i, "value" + i); - } - for (int i = 1; i < 31; i++) { - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - } - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } catch (Exception e) { - throw e; - } - return pass; - } - - /* - * Utitity method to parse JsonArrayWithLotsOfNestedObjectsData - */ - private boolean parseAndVerify_JsonArrayWithLotsOfNestedObjectsData( - JsonParser parser) throws Exception { - boolean pass = true; - - try { - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser, "name1", "value1"); - for (int i = 2; i < 31; i++) { - JSONP_Util.testKeyStartObjectValue(parser, "nested" + i); - JSONP_Util.testKeyStringValue(parser, "name" + i, "value" + i); - } - for (int i = 2; i < 31; i++) { - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - } - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } catch (Exception e) { - throw e; - } - return pass; - } - - /* - * Utitity method to parse JsonArrayWithLotsOfNestedArraysData - */ - private boolean parseAndVerify_JsonArrayWithLotsOfNestedArraysData( - JsonParser parser) throws Exception { - boolean pass = true; - - try { - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser, "name1"); - JSONP_Util.testStringValue(parser, "value1"); - for (int i = 2; i < 31; i++) { - JSONP_Util.testStringValue(parser, "nested" + i); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser, "name" + i); - JSONP_Util.testStringValue(parser, "value" + i); - } - for (int i = 2; i < 31; i++) { - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - } - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } catch (Exception e) { - throw e; - } - return pass; - } - - /* - * Utitity method to parse JsonArrayWithMultipleArraysData - */ - private boolean parseAndVerify_JsonArrayWithMultipleArraysData( - JsonParser parser) throws Exception { - boolean pass = true; - - try { - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser, "string"); - JSONP_Util.testIntegerValue(parser, 100); - JSONP_Util.testTrueValue(parser, JsonParser.Event.VALUE_TRUE); - JSONP_Util.testFalseValue(parser, JsonParser.Event.VALUE_FALSE); - JSONP_Util.testNullValue(parser, JsonParser.Event.VALUE_NULL); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser, "object", "object"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser, "one"); - JSONP_Util.testStringValue(parser, "two"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testIntegerValue(parser, 100); - JSONP_Util.testDoubleValue(parser, (double) 7e7); - JSONP_Util.testTrueValue(parser, JsonParser.Event.VALUE_TRUE); - JSONP_Util.testFalseValue(parser, JsonParser.Event.VALUE_FALSE); - JSONP_Util.testNullValue(parser, JsonParser.Event.VALUE_NULL); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser, "object2", "object2"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } catch (Exception e) { - throw e; - } - return pass; - } - - /* - * Utitity method to parse JsonArrayWithAllTypesOfData - */ - private boolean parseAndVerify_JsonArrayWithAllTypesOfData(JsonParser parser) - throws Exception { - boolean pass = true; - - try { - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser, ""); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testStringValue(parser, "string"); - JSONP_Util.testIntegerValue(parser, 100); - JSONP_Util.testTrueValue(parser, JsonParser.Event.VALUE_TRUE); - JSONP_Util.testFalseValue(parser, JsonParser.Event.VALUE_FALSE); - JSONP_Util.testNullValue(parser, JsonParser.Event.VALUE_NULL); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser, "emptyString", ""); - JSONP_Util.testKeyStartArrayValue(parser, "emptyArray"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testKeyStartObjectValue(parser, "emptyObject"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testKeyStringValue(parser, "string", "string"); - JSONP_Util.testKeyIntegerValue(parser, "number", 100); - JSONP_Util.testKeyTrueValue(parser, "true"); - JSONP_Util.testKeyFalseValue(parser, "false"); - JSONP_Util.testKeyNullValue(parser, "null"); - JSONP_Util.testKeyStartObjectValue(parser, "object"); - JSONP_Util.testKeyStringValue(parser, "name", "value"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testKeyStartArrayValue(parser, "array"); - JSONP_Util.testStringValue(parser, "one"); - JSONP_Util.testStringValue(parser, "two"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser, "string"); - JSONP_Util.testIntegerValue(parser, 100); - JSONP_Util.testTrueValue(parser, JsonParser.Event.VALUE_TRUE); - JSONP_Util.testFalseValue(parser, JsonParser.Event.VALUE_FALSE); - JSONP_Util.testNullValue(parser, JsonParser.Event.VALUE_NULL); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStringValue(parser, "name", "value"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.testEventType(parser, JsonParser.Event.START_ARRAY); - JSONP_Util.testStringValue(parser, "one"); - JSONP_Util.testStringValue(parser, "two"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.testIntegerValue(parser, 100); - JSONP_Util.testIntegerValue(parser, -100); - JSONP_Util.testLongValue(parser, 9223372036854775807L); - JSONP_Util.testLongValue(parser, -9223372036854775808L); - JSONP_Util.testDoubleValue(parser, (double) 0.5); - JSONP_Util.testDoubleValue(parser, (double) -0.5); - JSONP_Util.testDoubleValue(parser, (double) 7e3); - JSONP_Util.testDoubleValue(parser, (double) 7e+3); - JSONP_Util.testDoubleValue(parser, (double) 9E3); - JSONP_Util.testDoubleValue(parser, (double) 9E+3); - JSONP_Util.testDoubleValue(parser, (double) 7e-3); - JSONP_Util.testDoubleValue(parser, (double) 7E-3); - JSONP_Util.testStringValue(parser, JSONP_Data.asciiCharacters); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } catch (Exception e) { - throw e; - } - return pass; - } - - private boolean parseAndVerify_JsonHelloWorld(JsonParser parser) - throws Exception { - boolean pass = true; - - try { - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyStartObjectValue(parser, "greetingObj"); - JSONP_Util.dumpLocation(parser); - JSONP_Util.testKeyStringValue(parser, "hello", "world"); - JSONP_Util.dumpLocation(parser); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.dumpLocation(parser); - JSONP_Util.testKeyStartArrayValue(parser, "greetingArr"); - JSONP_Util.dumpLocation(parser); - JSONP_Util.testStringValue(parser, "hello"); - JSONP_Util.dumpLocation(parser); - JSONP_Util.testStringValue(parser, "world"); - JSONP_Util.dumpLocation(parser); - JSONP_Util.testEventType(parser, JsonParser.Event.END_ARRAY); - JSONP_Util.dumpLocation(parser); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - JSONP_Util.dumpLocation(parser); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - } catch (Exception e) { - throw e; - } - return pass; - } - - /* Tests */ - - /* - * @testName: jsonParserTest1 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:133; JSONP:JAVADOC:235; JSONP:JAVADOC:237; JSONP:JAVADOC:239; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in "JSONP_Data.jsonObjectWithAllTypesOfData". Creates - * the JsonParser via the API: - * - * JsonParser parser = Json.createParser(Reader) - */ - public void jsonParserTest1() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg("-------------------------------------"); - logMsg("TEST CASE [Json.createParser(Reader)]"); - logMsg("-------------------------------------"); - logMsg("Create Reader from (JSONP_Data.jsonObjectWithAllTypesOfData)"); - StringReader reader = new StringReader( - JSONP_Data.jsonObjectWithAllTypesOfData); - logMsg("Create JsonParser from the Reader"); - parser = Json.createParser(reader); - logMsg( - "Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithAllTypesOfData)"); - pass = parseAndVerify_JsonObjectWithAllTypesOfData(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest1 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest1 Failed"); - } - - /* - * @testName: jsonParserTest2 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:417; JSONP:JAVADOC:235; JSONP:JAVADOC:237; JSONP:JAVADOC:239; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; JSONP:JAVADOC:166; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in "JSONP_Data.jsonObjectWithAllTypesOfData". Creates - * the JsonParser via the API: - * - * JsonParser parser = - * Json.createParserFactory(Map).createParser(JsonObject) - */ - public void jsonParserTest2() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "----------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(JsonObject)]"); - logMsg( - "----------------------------------------------------------------------------"); - logMsg( - "Create JsonObject from (JSONP_Data.jsonObjectWithAllTypesOfData)"); - JsonObject jsonObj = JSONP_Util - .createJsonObjectFromString(JSONP_Data.jsonObjectWithAllTypesOfData); - JSONP_Util.dumpJsonObject(jsonObj); - logMsg("Create JsonParser from the JsonObject"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(jsonObj); - logMsg("parser=" + parser); - logMsg( - "Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithAllTypesOfData)"); - pass = parseAndVerify_JsonObjectWithAllTypesOfData(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest2 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest2 Failed"); - } - - /* - * @testName: jsonParserTest3 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:122; JSONP:JAVADOC:133; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in "JSONP_Data.jsonObjectWithLotsOfNestedObjectsData". - * Creates the JsonParser via the API: - * - * JsonParser parser = Json.createParser(Reader) - */ - public void jsonParserTest3() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg("-------------------------------------------"); - logMsg("TEST CASE [Json.createParser(Reader) again]"); - logMsg("-------------------------------------------"); - logMsg( - "Create Reader from (JSONP_Data.jsonObjectWithLotsOfNestedObjectsData)"); - StringReader reader = new StringReader( - JSONP_Data.jsonObjectWithLotsOfNestedObjectsData); - logMsg("Create JsonParser from the Reader"); - parser = Json.createParser(reader); - logMsg( - "Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithLotsOfNestedObjectsData)"); - pass = parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest3 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest3 Failed"); - } - - /* - * @testName: jsonParserTest4 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:122; JSONP:JAVADOC:417; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; JSONP:JAVADOC:166; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in "JSONP_Data.jsonObjectithLotsOfNestedObjectsData". - * Creates the JsonParser via the API: - * - * JsonParser parser = - * Json.createParserFactory(Map).createParser(JsonObject) - */ - public void jsonParserTest4() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "-----------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(JsonObject object) again]"); - logMsg( - "-----------------------------------------------------------------------------------------"); - logMsg( - "Create JsonObject from (JSONP_Data.jsonObjectWithLotsOfNestedObjectsData)"); - JsonObject jsonObj = JSONP_Util.createJsonObjectFromString( - JSONP_Data.jsonObjectWithLotsOfNestedObjectsData); - JSONP_Util.dumpJsonObject(jsonObj); - logMsg("Create JsonParser from the JsonObject"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(jsonObj); - logMsg( - "Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithLotsOfNestedObjectsData)"); - pass = parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest4 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest4 Failed"); - } - - /* - * @testName: jsonParserTest5 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:417; JSONP:JAVADOC:235; JSONP:JAVADOC:237; JSONP:JAVADOC:239; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; JSONP:JAVADOC:167; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonArray defined in "JSONP_Data.jsonArrayWithMultipleArraysData". Creates - * the JsonParser via the API: - * - * JsonParser parser = - * Json.createParserFactory(Map).createParser(JsonArray) - */ - public void jsonParserTest5() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "---------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(JsonArray)]"); - logMsg( - "---------------------------------------------------------------------------"); - logMsg( - "Create JsonArray from (JSONP_Data.jsonArrayWithMultipleArraysData)"); - JsonArray jsonArr = JSONP_Util.createJsonArrayFromString( - JSONP_Data.jsonArrayWithMultipleArraysData); - JSONP_Util.dumpJsonArray(jsonArr); - logMsg("Create JsonParser from the JsonArray"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(jsonArr); - logMsg( - "Verify that JSON Parser Events/Data matches (JSONP_Data.jsonArrayWithMultipleArraysData)"); - pass = parseAndVerify_JsonArrayWithMultipleArraysData(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest5 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest5 Failed"); - } - - /* - * @testName: jsonParserTest6 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:172; JSONP:JAVADOC:235; JSONP:JAVADOC:237; JSONP:JAVADOC:239; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonArray defined in resource file "jsonArrayWithAllTypesOfData.json". - * - * Creates the JsonParser via the API: - * - * JsonParser parser = Json.createParser(InputStream) - */ - public void jsonParserTest6() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg("------------------------------------------"); - logMsg("TEST CASE [Json.createParser(InputStream)]"); - logMsg("------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonArrayWithAllTypesOfData.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonArrayWithAllTypesOfData.json"); - logMsg("Create JsonParser from the InputStream"); - parser = Json.createParser(istream); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonArrayWithAllTypesOfData.json)"); - pass = parseAndVerify_JsonArrayWithAllTypesOfData(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest6 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest6 Failed"); - } - - /* - * @testName: jsonParserTest7 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:417; JSONP:JAVADOC:164; JSONP:JAVADOC:235; JSONP:JAVADOC:237; - * JSONP:JAVADOC:239; JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser with a configuration. Verifies - * PARSING of the JsonObject defined in - * "JSONP_Data.jsonObjectWithAllTypesOfData". Creates the JsonParser via the - * following API - * - * JsonParser parser = Json.createParserFactory(Map).createParser(Reader) - */ - public void jsonParserTest7() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "-------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(Reader)]"); - logMsg( - "-------------------------------------------------------------------------"); - logMsg("Create a Reader from (JSONP_Data.jsonObjectWithAllTypesOfData)"); - StringReader reader = new StringReader( - JSONP_Data.jsonObjectWithAllTypesOfData); - logMsg("Create JsonParser using Reader and a configuration"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(reader); - logMsg("Call JsonParser.toString() to print the JsonObject"); - parser.toString(); - logMsg( - "Verify that JSON Parser Events/Data matches (JSONP_Data.jsonObjectWithAllTypesOfData)"); - if (!parseAndVerify_JsonObjectWithAllTypesOfData(parser)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParserTest7 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest7 Failed"); - } - - /* - * @testName: jsonParserTest8 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:122; JSONP:JAVADOC:417; - * JSONP:JAVADOC:167; JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser with a configuration. Verifies - * PARSING of the JsonArray defined in - * "JSONP_Data.jsonArrayWithLotsOfNestedObjectsData". Creates the JsonParser - * via the following API - * - * JsonParser parser = Json.createParserFactory(Map).createParser(JsonArray) - */ - public void jsonParserTest8() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "----------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(JsonArray)]"); - logMsg( - "----------------------------------------------------------------------------"); - logMsg( - "Create a JsonArray from (JSONP_Data.jsonArrayWithLotsOfNestedObjectsData)"); - JsonArray jsonArr = JSONP_Util.createJsonArrayFromString( - JSONP_Data.jsonArrayWithLotsOfNestedObjectsData); - JSONP_Util.dumpJsonArray(jsonArr); - logMsg("Create JsonParser using JsonArray and a configuration"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(jsonArr); - logMsg("Call JsonParser.toString() to print the JsonObject"); - parser.toString(); - logMsg( - "Verify that JSON Parser Events/Data matches (JSONP_Data.jsonArrayWithLotsOfNestedObjectsData)"); - if (!parseAndVerify_JsonArrayWithLotsOfNestedObjectsData(parser)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParserTest8 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest8 Failed"); - } - - /* - * @testName: jsonParserTest9 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:417; JSONP:JAVADOC:167; JSONP:JAVADOC:235; JSONP:JAVADOC:237; - * JSONP:JAVADOC:239; JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser with an empty configuration. - * Verifies PARSING of the JsonArray defined in - * "JSONP_Data.jsonArrayWithMultipleArraysData". Creates the JsonParser via - * the following API - * - * JsonParser parser = Json.createParserFactory(Map).createParser(JsonArray) - */ - public void jsonParserTest9() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "----------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(JsonArray)]"); - logMsg( - "----------------------------------------------------------------------------"); - logMsg( - "Create JsonArray from (JSONP_Data.jsonArrayWithMultipleArraysData)"); - JsonArray jsonArr = JSONP_Util.createJsonArrayFromString( - JSONP_Data.jsonArrayWithMultipleArraysData); - JSONP_Util.dumpJsonArray(jsonArr); - logMsg("Create JsonParser using JsonArray and a configuration"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(jsonArr); - logMsg("Call JsonParser.toString() to print the JsonArray"); - parser.toString(); - logMsg( - "Verify that JSON Parser Events/Data matches (JSONP_Data.jsonArrayWithMultipleArraysData)"); - if (!parseAndVerify_JsonArrayWithMultipleArraysData(parser)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParserTest9 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest9 Failed"); - } - - /* - * @testName: jsonParserTest10 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:122; JSONP:JAVADOC:417; - * JSONP:JAVADOC:165; JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in resource file - * "jsonObjectWithLotsOfNestedObjectsData.json". Creates the JsonParser via - * the following API - * - * JsonParser parser = Json.createParserFactory(Map).createParser(InputStream) - */ - public void jsonParserTest10() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream)]"); - logMsg( - "------------------------------------------------------------------------------"); - logMsg("Create JsonParser using InputStream and a configuration"); - InputStream istream = JSONP_Util.getInputStreamFromResource( - "jsonObjectWithLotsOfNestedObjectsData.json"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream); - logMsg("Call JsonParser.toString() to print the JsonObject"); - parser.toString(); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectWithLotsOfNestedObjectsData.json)"); - if (!parseAndVerify_JsonObjectWithLotsOfNestedObjectsData(parser)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParserTest10 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest10 Failed"); - } - - /* - * @testName: jsonParserTest11 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:235; JSONP:JAVADOC:237; JSONP:JAVADOC:239; JSONP:JAVADOC:375; - * JSONP:JAVADOC:376; JSONP:JAVADOC:417; JSONP:JAVADOC:201; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonArray defined in resource file - * "jsonArrayWithAllTypesOfDataUTF16BE.json". Use UTF-16BE encoding. - * - * Creates the JsonParser via the API: - * - * JsonParser parser = - * Json.createParserFactory(Map).createParser(InputStream, Charset) - */ - public void jsonParserTest11() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "--------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset)]"); - logMsg( - "--------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonArrayWithAllTypesOfDataUTF16BE.json)"); - InputStream istream = JSONP_Util.getInputStreamFromResource( - "jsonArrayWithAllTypesOfDataUTF16BE.json"); - logMsg( - "Create JsonParser from the InputStream with character encoding UTF-16BE"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_16BE); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonArrayWithAllTypesOfDataUTF16BE.json)"); - pass = parseAndVerify_JsonArrayWithAllTypesOfData(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest11 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest11 Failed"); - } - - /* - * @testName: jsonParserTest12 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:122; JSONP:JAVADOC:417; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; JSONP:JAVADOC:201; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonArray defined in resource file - * "jsonArrayWithLotsOfNestedArraysData.json". Use UTF-8 encoding. - * - * Creates the JsonParser via the API: - * - * JsonParser parser = Json.createParserFactory(Map).createParser(InputStream, Charset) - */ - public void jsonParserTest12() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "---------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset)]"); - logMsg( - "---------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonArrayWithLotsOfNestedArraysData.json)"); - InputStream istream = JSONP_Util.getInputStreamFromResource( - "jsonArrayWithLotsOfNestedArraysData.json"); - logMsg( - "Create JsonParser from the InputStream with character encoding UTF-8 and a configuration"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_8); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonArrayWithLotsOfNestedArraysData.json)"); - if (!parseAndVerify_JsonArrayWithLotsOfNestedArraysData(parser)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParserTest12 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest12 Failed"); - } - - /* - * @testName: jsonParserTest13 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:201; JSONP:JAVADOC:235; JSONP:JAVADOC:237; JSONP:JAVADOC:239; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in UTF-16LE encoding resource file - * "jsonObjectWithAllTypesOfDataUTF16LE.json". - * - * Creates the JsonParser via the API: - * - * JsonParser parser = Json.createParserFactory(Map).createParser(InputStream, Charset) - */ - public void jsonParserTest13() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "---------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset)]"); - logMsg( - "---------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectWithAllTypesOfDataUTF16LE.json)"); - InputStream istream = JSONP_Util.getInputStreamFromResource( - "jsonObjectWithAllTypesOfDataUTF16LE.json"); - logMsg("Create JsonParser from the InputStream using UTF-16LE encoding"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_16LE); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectWithAllTypesOfDataUTF16LE.json)"); - pass = parseAndVerify_JsonObjectWithAllTypesOfData(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest13 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest13 Failed"); - } - - /* - * @testName: jsonParserTest14 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:122; JSONP:JAVADOC:172; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; JSONP:JAVADOC:477; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in resource file "jsonHelloWorld.json.json". - * - * Creates the JsonParser via the API: - * - * JsonParser parser = Json.createParser(InputStream) - */ - public void jsonParserTest14() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg("------------------------------------------"); - logMsg("TEST CASE [Json.createParser(InputStream)]"); - logMsg("------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonHelloWorld.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonHelloWorld.json"); - logMsg("Create JsonParser from the InputStream"); - parser = Json.createParser(istream); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonHelloWorld.json)"); - pass = parseAndVerify_JsonHelloWorld(parser); - } catch (Exception e) { - throw new Fault("jsonParserTest14 Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("jsonParserTest14 Failed"); - } - - /* - * @testName: parseUTFEncodedTests - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:122; JSONP:JAVADOC:417; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; JSONP:JAVADOC:201; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in resource files: - * - * jsonObjectEncodingUTF8.json jsonObjectEncodingUTF16.json - * jsonObjectEncodingUTF16LE.json jsonObjectEncodingUTF16BE.json - * jsonObjectEncodingUTF32LE.json jsonObjectEncodingUTF32BE.json - * - * Creates the JsonParser via the API: - * - * JsonParser parser = - * Json.createParserFactory(Map).createParser(InputStream, Charset) - * - * For each supported encoding supported by JSON RFC parse the JsonObject and - * verify we get the expected results. The Charset encoding is passed in as an - * argument for each encoding type tested. - */ - public void parseUTFEncodedTests() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "-----------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset) as UTF-8]"); - logMsg( - "-----------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF8.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF8.json"); - logMsg( - "Create JsonParser from the InputStream with character encoding UTF-8"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_8); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF8.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-8 encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset) as UTF-16]"); - logMsg( - "------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16.json"); - logMsg( - "Create JsonParser from the InputStream with character encoding UTF-16"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_16); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-16 encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset) as UTF-16LE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16LE.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16LE.json"); - logMsg( - "Create JsonParser from the InputStream with character encoding UTF-16LE"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_16LE); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16LE.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-16LE encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset) as UTF-16BE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16BE.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16BE.json"); - logMsg( - "Create JsonParser from the InputStream with character encoding UTF-16BE"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_16BE); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16BE.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-16BE encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset) as UTF-32LE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF32LE.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF32LE.json"); - logMsg( - "Create JsonParser from the InputStream with character encoding UTF-32LE"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_32LE); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF32LE.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-32LE encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "-------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParserFactory(Map).createParser(InputStream, Charset) as UTF-32BE]"); - logMsg( - "-------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF32BE.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF32BE.json"); - logMsg( - "Create JsonParser from the InputStream with character encoding UTF-32BE"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(istream, JSONP_Util.UTF_32BE); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF32BE.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-32BE encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("parseUTFEncodedTests Failed"); - } - - /* - * @testName: parseUTFEncodedTests2 - * - * @assertion_ids: JSONP:JAVADOC:117; JSONP:JAVADOC:120; JSONP:JAVADOC:122; - * JSONP:JAVADOC:172; JSONP:JAVADOC:235; JSONP:JAVADOC:237; JSONP:JAVADOC:239; - * JSONP:JAVADOC:375; JSONP:JAVADOC:376; - * - * @test_Strategy: Tests the JsonParser parser. Verifies PARSING of the - * JsonObject defined in resource files and auto-detecting the encoding: - * - * jsonObjectEncodingUTF8.json jsonObjectEncodingUTF16LE.json - * jsonObjectEncodingUTF16BE.json jsonObjectEncodingUTF32LE.json - * jsonObjectEncodingUTF32BE.json - * - * Creates the JsonParser via the API: - * - * JsonParser parser = Json.createParser(InputStream) - * - * For each supported encoding supported by JSON RFC the above should - * auto-detect the encoding and verify we get the expected results. - */ - public void parseUTFEncodedTests2() throws Fault { - boolean pass = true; - JsonParser parser = null; - JsonParser.Event event = null; - try { - logMsg( - "-------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-8]"); - logMsg( - "-------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF8.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF8.json"); - logMsg( - "Create JsonParser from the InputStream and auto-detect character encoding UTF-8"); - parser = Json.createParser(istream); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF8.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-8 encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "----------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-16LE]"); - logMsg( - "----------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16LE.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16LE.json"); - logMsg( - "Create JsonParser from the InputStream and auto-detect character encoding UTF-16LE"); - parser = Json.createParser(istream); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16LE.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-16LE encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "----------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-16BE]"); - logMsg( - "----------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16BE.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16BE.json"); - logMsg( - "Create JsonParser from the InputStream and auto-detect character encoding UTF-16BE"); - parser = Json.createParser(istream); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF16BE.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-16BE encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "----------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-32LE]"); - logMsg( - "----------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF32LE.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF32LE.json"); - logMsg( - "Create JsonParser from the InputStream and auto-detect character encoding UTF-32LE"); - parser = Json.createParser(istream); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF32LE.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-32LE encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "----------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createParser(InputStream) and auto-detect as UTF-32BE]"); - logMsg( - "----------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF32BE.json)"); - InputStream istream = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF32BE.json"); - logMsg( - "Create JsonParser from the InputStream and auto-detect character encoding UTF-32BE"); - parser = Json.createParser(istream); - logMsg( - "Verify that JSON Parser Events/Data matches (jsonObjectEncodingUTF32BE.json)"); - if (!parseAndVerify_JsonObjectUTF(parser)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing parsing of UTF-32BE encoding: " + e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - - if (!pass) - throw new Fault("parseUTFEncodedTests2 Failed"); - } - - /* - * @testName: jsonParserIsIntegralNumberTest - * - * @assertion_ids: JSONP:JAVADOC:120; JSONP:JAVADOC:133; JSONP:JAVADOC:375; - * JSONP:JAVADOC:376; - * - * @test_Strategy: Test JsonParser.isIntegralNumber() method. - */ - public void jsonParserIsIntegralNumberTest() throws Fault { - boolean pass = true; - JsonParser parser = null; - String jsonTestString = "[123, 12345.45]"; - try { - logMsg("Create JsonParser"); - parser = Json.createParser(new StringReader(jsonTestString)); - // INTEGRAL NUMBER TEST - JsonParser.Event event = JSONP_Util.getNextSpecificParserEvent(parser, - JsonParser.Event.VALUE_NUMBER); // e=JsonParser.Event.VALUE_NUMBER - JSONP_Util.dumpEventType(event); - if (!JSONP_Util.assertEqualsJsonNumberType(parser.isIntegralNumber(), - JSONP_Util.INTEGRAL)) - pass = false; - else { - if (!JSONP_Util.assertEquals(123, parser.getInt())) - pass = false; - } - // NON_INTEGRAL NUMBER TEST - event = JSONP_Util.getNextSpecificParserEvent(parser, - JsonParser.Event.VALUE_NUMBER); // e=JsonParser.Event.VALUE_NUMBER - JSONP_Util.dumpEventType(event); - if (!JSONP_Util.assertEqualsJsonNumberType(parser.isIntegralNumber(), - JSONP_Util.NON_INTEGRAL)) - pass = false; - else { - if (!JSONP_Util.assertEquals(12345.45, - parser.getBigDecimal().doubleValue())) - pass = false; - } - - } catch (Exception e) { - throw new Fault("jsonParserIsIntegralNumberTest Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - - if (!pass) - throw new Fault("jsonParserIsIntegralNumberTest Failed"); - } - - private boolean tripIllegalStateException(JsonParser parser, - JsonParser.Event event) { - boolean pass = true; - - // Check in case event is null - if (event == null) { - logErr("event is null - unexpected."); - return false; - } - logMsg("Event=" + JSONP_Util.getEventTypeString(event)); - logMsg("Testing call to JsonParser.getString()"); - if (event != JsonParser.Event.VALUE_STRING - && event != JsonParser.Event.VALUE_NUMBER - && event != JsonParser.Event.KEY_NAME) { - try { - logMsg("Trip IllegalStateException by calling JsonParser.getString()"); - String string = parser.getString(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - } else { - logMsg("No testing for IllegalStateException for this scenario."); - } - - logMsg("Testing call to JsonParser.isIntegralNumber()"); - if (event != JsonParser.Event.VALUE_NUMBER) { - try { - logMsg( - "Trip IllegalStateException by calling JsonParser.isIntegralNumber()"); - boolean numberType = parser.isIntegralNumber(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - } else { - logMsg("No testing for IllegalStateException for this scenario."); - } - - logMsg("Testing call to JsonParser.getBigDecimal()"); - if (event != JsonParser.Event.VALUE_NUMBER) { - try { - logMsg( - "Trip IllegalStateException by calling JsonParser.getBigDecimal()"); - BigDecimal number = parser.getBigDecimal(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - } else { - logMsg("No testing for IllegalStateException for this scenario."); - } - - logMsg("Testing call to JsonParser.getInt()"); - if (event != JsonParser.Event.VALUE_NUMBER) { - try { - logMsg("Trip IllegalStateException by calling JsonParser.getInt()"); - int number = parser.getInt(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - } else { - logMsg("No testing for IllegalStateException for this scenario."); - } - - logMsg("Testing call to JsonParser.getLong()"); - if (event != JsonParser.Event.VALUE_NUMBER) { - try { - logMsg("Trip IllegalStateException by calling JsonParser.getLong()"); - long number = parser.getLong(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - } else { - logMsg("No testing for IllegalStateException for this scenario."); - } - return pass; - } - - /* - * @testName: jsonParserIllegalExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:121; JSONP:JAVADOC:123; JSONP:JAVADOC:236; - * JSONP:JAVADOC:238; JSONP:JAVADOC:240; - * - * @test_Strategy: Test JsonParser exception conditions. Trip the following - * exceptions: - * - * java.lang.IllegalStateException - */ - public void jsonParserIllegalExceptionTests() throws Fault { - boolean pass = true; - JsonParser parser = null; - String jsonTestString = "[\"string\",100,false,null,true,{\"foo\":\"bar\"}]"; - try { - logMsg("Create JsonParser"); - parser = Json.createParserFactory(JSONP_Util.getEmptyConfig()) - .createParser(new StringReader(jsonTestString)); - JsonParser.Event event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.START_ARRAY */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.VALUE_STRING */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.VALUE_NUMBER */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.VALUE_FALSE */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.VALUE_NULL */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.VALUE_TRUE */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.START_OBJECT */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.KEY_NAME */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.VALUE_STRING */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.END_OBJECT */ - if (!tripIllegalStateException(parser, event)) - pass = false; - event = JSONP_Util - .getNextParserEvent(parser); /* e=JsonParser.Event.END_ARRAY */ - if (!tripIllegalStateException(parser, event)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonParserIllegalExceptionTests Failed: ", e); - } finally { - try { - parser.close(); - } catch (Exception e) { - } - } - - if (!pass) - throw new Fault("jsonParserIllegalExceptionTests Failed"); - } - - /* - * @testName: jsonParserIOErrorTests - * - * @assertion_ids: JSONP:JAVADOC:207; JSONP:JAVADOC:389; JSONP:JAVADOC:415; - * - * @test_Strategy: Tests for JsonException for testable i/o errors. - * - */ - @SuppressWarnings("ConvertToTryWithResources") - public void jsonParserIOErrorTests() throws Fault { - boolean pass = true; - - String jsonText = "{\"name1\":\"value1\",\"name2\":\"value2\"}"; - - // Trip JsonException if there is an i/o error on - // Json.createParser(InputStream) - try { - logMsg( - "Trip JsonException if there is an i/o error on Json.createParser(InputStream)."); - logMsg("Parsing " + jsonText); - InputStream is = JSONP_Util.getInputStreamFromString(jsonText); - MyBufferedInputStream mbi = new MyBufferedInputStream(is, true); - logMsg("Calling Json.createParser(InputStream)"); - JsonParser parser = Json.createParser(mbi); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException if there is an i/o error on JsonParser.next() - try { - logMsg( - "Trip JsonException if there is an i/o error on JsonParser.next()."); - logMsg("Parsing " + jsonText); - InputStream is = JSONP_Util.getInputStreamFromString(jsonText); - MyBufferedInputStream mbi = new MyBufferedInputStream(is, true); - JsonParser parser = Json.createParser(mbi); - logMsg("Calling JsonParser.next()"); - parser.next(); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException if there is an i/o error on JsonParser.close() - try { - logMsg( - "Trip JsonException if there is an i/o error on JsonParser.close()."); - logMsg("Parsing " + jsonText); - InputStream is = JSONP_Util.getInputStreamFromString(jsonText); - MyBufferedInputStream mbi = new MyBufferedInputStream(is); - JsonParser parser = Json.createParser(mbi); - mbi.setThrowIOException(true); - logMsg("Calling JsonParser.close()"); - parser.close(); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonParserIOErrorTests Failed"); - } - - /* - * @testName: jsonParserExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:390; JSONP:JAVADOC:391; - * - * @test_Strategy: Tests for the following exception test cases: - * - * JsonParsingException - if incorrect JSON is encountered while advancing - * parser to next state NoSuchElementException - if there are no more parsing - * states - * - */ - public void jsonParserExceptionTests() throws Fault { - boolean pass = true; - - // Trip JsonParsingException for JsonParser.next() if incorrect JSON is - // encountered - try { - logMsg( - "Trip JsonParsingException for JsonParser.next() if incorrect JSON is encountered"); - InputStream is = JSONP_Util.getInputStreamFromString("}{"); - JsonParser parser = Json.createParser(is); - parser.next(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip NoSuchElementException for JsonParser.next() if no more parsing - // states - try { - logMsg( - "Trip NoSuchElementException for JsonParser.next() if no more parsing states"); - InputStream is = JSONP_Util.getInputStreamFromString("{}"); - JsonParser parser = Json.createParser(is); - parser.next(); // Event -> START_OBJECT { - parser.next(); // Event -> END_OBJECT } - parser.next(); // Event -> NoSuchElementException should be thrown - logErr("Did not get expected NoSuchElementException"); - pass = false; - } catch (NoSuchElementException e) { - logMsg("Caught expected NoSuchElementException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonParserExceptionTests Failed"); - } - - /* - * @testName: invalidLiteralNamesTest - * - * @assertion_ids: JSONP:JAVADOC:133; JSONP:JAVADOC:390; - * - * @test_Strategy: This test trips various JsonParsingException conditions - * when parsing an uppercase literal name that must be lowercase per JSON RFC - * for the literal values (true, false or null). - * - */ - public void invalidLiteralNamesTest() throws Fault { - boolean pass = true; - - // Trip JsonParsingException for JsonParser.next() if invalid liternal TRUE - // instead of true - try { - logMsg( - "Trip JsonParsingException for JsonParser.next() if invalid liternal TRUE instead of true."); - logMsg("Reading " + "[TRUE]"); - JsonParser parser = Json.createParser(new StringReader("[TRUE]")); - parser.next(); // Event -> START_OBJECT { - parser.next(); // Event -> JsonParsingException (invalid literal TRUE) - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonParsingException for JsonParser.next() if invalid liternal FALSE - // instead of false - try { - logMsg( - "Trip JsonParsingException for JsonParser.next() if invalid liternal FALSE instead of false."); - logMsg("Reading " + "[FALSE]"); - JsonParser parser = Json.createParser(new StringReader("[FALSE]")); - parser.next(); // Event -> START_OBJECT { - parser.next(); // Event -> JsonParsingException (invalid literal FALSE) - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonParsingException for JsonParser.next() if invalid liternal NULL - // instead of null - try { - logMsg( - "Trip JsonParsingException for JsonParser.next() if invalid liternal NULL instead of null."); - logMsg("Reading " + "[NULL]"); - JsonParser parser = Json.createParser(new StringReader("[NULL]")); - parser.next(); // Event -> START_OBJECT { - parser.next(); // Event -> JsonParsingException (invalid literal NULL) - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("invalidLiteralNamesTest Failed"); - } - - /* - * @testName: jsonParser11Test - * - * @assertion_ids: JSONP:JAVADOC:673; JSONP:JAVADOC:674; JSONP:JAVADOC:675; - * JSONP:JAVADOC:676; JSONP:JAVADOC:677; JSONP:JAVADOC:678; JSONP:JAVADOC:679; - * JSONP:JAVADOC:680; JSONP:JAVADOC:583; JSONP:JAVADOC:584; JSONP:JAVADOC:585; - * JSONP:JAVADOC:586; JSONP:JAVADOC:587; JSONP:JAVADOC:588; JSONP:JAVADOC:662; - * JSONP:JAVADOC:663; JSONP:JAVADOC:664; JSONP:JAVADOC:665; JSONP:JAVADOC:666; - * JSONP:JAVADOC:667; - * - * @test_Strategy: Tests JsonParser API methods added in JSON-P 1.1. - */ - public void jsonParser11Test() throws Fault { - Parser parserTest = new Parser(); - final TestResult result = parserTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonparsertests/Parser.java b/src/com/sun/ts/tests/jsonp/api/jsonparsertests/Parser.java deleted file mode 100644 index 2d3b2d42c0..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonparsertests/Parser.java +++ /dev/null @@ -1,693 +0,0 @@ -/* - * Copyright (c) 2017, 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 com.sun.ts.tests.jsonp.api.jsonparsertests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BDC_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BIN_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DBL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.LNG_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.jsonData; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.toJsonValue; - -import java.io.StringReader; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.stream.Stream; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonStructure; -import jakarta.json.JsonValue; -import jakarta.json.stream.JsonParser; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests: {@link JsonParser} API - * methods added in JSON-P 1.1. - */ -public class Parser { - - /** Tests input data with various JsonValue instances. */ - private static final JsonValue[] VALUES = new JsonValue[] { - toJsonValue(STR_VALUE), // Non JsonObject with String - toJsonValue(INT_VALUE), // Non JsonObject with int - toJsonValue(LNG_VALUE), // Non JsonObject with long - toJsonValue(DBL_VALUE), // Non JsonObject with double - toJsonValue(BOOL_VALUE), // Non JsonObject with boolean - toJsonValue(BDC_VALUE), // Non JsonObject with BigDecimal - toJsonValue(BIN_VALUE), // Non JsonObject with BigInteger - createSimpleObjectStr(), // JsonObject with String - createSimpleObjectInt(), // JsonObject with int - createSimpleObjectBool(), // JsonObject with boolean - createSimpleObjectObject(), // JsonObject with JsonObject - createEmptyArrayWithStr(), // JsonArray with String - createEmptyArrayWithInt(), // JsonArray with int - createEmptyArrayWithBool(), // JsonArray with boolean - createEmptyArrayWithObject() // JsonArray with JsonObject - }; - - // /** Tests input data with simple JsonValue instances. */ - // private static final JsonValue[] SIMPLE_VALUES = new JsonValue[] { - // toJsonValue(STR_VALUE), // Non JsonObject with String - // toJsonValue(INT_VALUE), // Non JsonObject with int - // toJsonValue(LNG_VALUE), // Non JsonObject with long - // toJsonValue(BOOL_VALUE), // Non JsonObject with boolean - // toJsonValue(BDC_VALUE), // Non JsonObject with BigDecimal - // toJsonValue(BIN_VALUE) // Non JsonObject with BigInteger - // }; - - /** Tests input data with compound JsonValue instances (object or array). */ - private static final JsonStructure[] COMPOUND_VALUES = new JsonStructure[] { - createSimpleObjectStr(), // JsonObject with String - createSimpleObjectInt(), // JsonObject with int - createSimpleObjectBool(), // JsonObject with boolean - createSimpleObjectObject(), // JsonObject with JsonObject - createEmptyArrayWithStr(), // JsonArray with String - createEmptyArrayWithInt(), // JsonArray with int - createEmptyArrayWithBool(), // JsonArray with boolean - createEmptyArrayWithObject() // JsonArray with JsonObject - }; - - /** Tests input data with empty JsonObject and JsonArray instances. */ - private static final JsonStructure[] EMPTY_VALUES = new JsonStructure[] { - createEmptyObject(), // Empty JsonObject - createEmptyArray() // Empty JsonArray - }; - - /** Tests input data with JsonObject instances. */ - private static final JsonObject[] OBJ_VALUES = new JsonObject[] { - createSimpleObjectStr(), // JsonObject with String - createSimpleObjectInt(), // JsonObject with int - createSimpleObjectBool(), // JsonObject with boolean - createSimpleObjectObject(), // JsonObject with JsonObject - createSimpleObjectWithStr() // JsonObject with default value (String) and - // another String - - }; - - /** Tests input data with non JsonObject instances. */ - private static final JsonValue[] NON_OBJ_VALUES = new JsonValue[] { - toJsonValue(STR_VALUE), // Non JsonObject with String - toJsonValue(INT_VALUE), // Non JsonObject with int - toJsonValue(LNG_VALUE), // Non JsonObject with long - toJsonValue(DBL_VALUE), // Non JsonObject with double - toJsonValue(BOOL_VALUE), // Non JsonObject with boolean - toJsonValue(BDC_VALUE), // Non JsonObject with BigDecimal - toJsonValue(BIN_VALUE), // Non JsonObject with BigInteger - createEmptyArrayWithStr(), // JsonArray with String - createEmptyArrayWithInt(), // JsonArray with int - createEmptyArrayWithBool(), // JsonArray with boolean - createEmptyArrayWithObject() // JsonArray with JsonObject - }; - - /** Tests input data with JsonArray instances. */ - private static final JsonArray[] ARRAY_VALUES = new JsonArray[] { - createEmptyArrayWithStr(), // JsonArray with String - createEmptyArrayWithInt(), // JsonArray with int - createEmptyArrayWithBool(), // JsonArray with boolean - createEmptyArrayWithObject() // JsonArray with JsonObject - }; - - /** Tests input data with non JsonArray instances. */ - private static final JsonValue[] NON_ARRAY_VALUES = new JsonValue[] { - toJsonValue(STR_VALUE), // Non JsonObject with String - toJsonValue(INT_VALUE), // Non JsonObject with int - toJsonValue(LNG_VALUE), // Non JsonObject with long - toJsonValue(DBL_VALUE), // Non JsonObject with double - toJsonValue(BOOL_VALUE), // Non JsonObject with boolean - toJsonValue(BDC_VALUE), // Non JsonObject with BigDecimal - toJsonValue(BIN_VALUE), // Non JsonObject with BigInteger - createSimpleObjectStr(), // JsonObject with String - createSimpleObjectInt(), // JsonObject with int - createSimpleObjectBool(), // JsonObject with boolean - createSimpleObjectObject() // JsonObject with JsonObject - }; - - /** - * Creates an instance of {@link JsonParser} API methods added in JSON-P 1.1 - * test. - */ - Parser() { - super(); - } - - /** - * Test {@link JsonParser} API methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonParser API methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonParser API methods added in JSON-P 1.1."); - testGetObject(result); - testGetNonObject(result); - testGetArray(result); - testGetNonArray(result); - testGetValue(result); - testGetIllegalValue(result); - testGetObjectStream(result); - testGetNonObjectStream(result); - testGetArrayStream(result); - testGetNonArrayStream(result); - testGetValueStream(result); - testGetCompoundValueStream(result); - testSkipArray(result); - testSkipNonArray(result); - testSkipObject(result); - testSkipNonObject(result); - return result; - } - - /** - * Test {@code JsonParser getObject()} method on JSON object values. - */ - private void testGetObject(final TestResult result) { - for (JsonObject value : OBJ_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getObject() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - JsonObject out = parser.getObject(); - if (operationFailed(value, out)) { - result.fail("getObject()", "Output value " + valueToString(out) - + " shall be " + valueToString(value)); - } - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("getObject()", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - } - } - - /** - * Test {@code JsonParser getObject()} method on non JSON object values. - */ - private void testGetNonObject(final TestResult result) { - for (JsonValue value : NON_OBJ_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getObject() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.getObject(); - result.fail("getObject()", - "Calling method on non object value shall throw IllegalStateException"); - } catch (IllegalStateException e) { - TestUtil.logMsg(" Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("getObject()", - "Calling method on non object value shall throw IllegalStateException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonParser getArray()} method on JSON array values. - */ - private void testGetArray(final TestResult result) { - for (JsonArray value : ARRAY_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getArray() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - JsonArray out = parser.getArray(); - if (operationFailed(value, out)) { - result.fail("getArray()", "Output value " + valueToString(out) - + " shall be " + valueToString(value)); - } - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("getArray()", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - } - } - - /** - * Test {@code JsonParser getArray()} method on non JSON object values. - */ - private void testGetNonArray(final TestResult result) { - for (JsonValue value : NON_ARRAY_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getArray() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.getArray(); - result.fail("getArray()", - "Calling method on non array value shall throw IllegalStateException"); - } catch (IllegalStateException e) { - TestUtil.logMsg(" Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("getArray()", - "Calling method on non array value shall throw IllegalStateException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonParser getValue()} method on common JSON values. - */ - private void testGetValue(final TestResult result) { - for (JsonValue value : VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getValue() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - JsonValue out = parser.getValue(); - if (operationFailed(value, out)) { - result.fail("getValue()", "Output value " + valueToString(out) - + " shall be " + valueToString(value)); - } - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("getValue()", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - } - } - - /** - * Test {@code JsonParser getValue()} method on END_OBJECT and END_ARRAY - * lexical elements. - */ - private void testGetIllegalValue(final TestResult result) { - for (JsonValue value : EMPTY_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getValue() on 2nd lexical element of " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); // Skip to START ELEMENT - parser.next(); // Skip to END ELEMENT - parser.getValue(); - result.fail("getValue()", - "Calling method on END_OBJECT and END_ARRAY lexical elements shall throw IllegalStateException"); - } catch (IllegalStateException e) { - TestUtil.logMsg(" Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("getValue()", - "Calling method on END_OBJECT and END_ARRAY lexical elements shall throw IllegalStateException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonParser getObjectStream()} method on JSON object values. - */ - private void testGetObjectStream(final TestResult result) { - for (JsonObject value : OBJ_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getObjectStream() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - Stream> out = parser.getObjectStream(); - if (operationFailed(value, out)) { - result.fail("getObjectStream()", - "Output Stream shall contain " + valueToString(value)); - } - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("getObjectStream()", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - } - } - - /** - * Test {@code JsonParser getObjectStream()} method on non JSON object values. - */ - private void testGetNonObjectStream(final TestResult result) { - for (JsonValue value : NON_OBJ_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getObjectStream() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.getObjectStream(); - result.fail("getObjectStream()", - "Calling method on non object value shall throw IllegalStateException"); - } catch (IllegalStateException e) { - TestUtil.logMsg(" Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("getObjectStream()", - "Calling method on non object value shall throw IllegalStateException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonParser getArrayStream()} method on JSON array values. - */ - private void testGetArrayStream(final TestResult result) { - for (JsonArray value : ARRAY_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getArrayStream() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - Stream out = parser.getArrayStream(); - if (operationFailed(value, out)) { - result.fail("getArrayStream()", - "Output Stream shall contain " + valueToString(value)); - } - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("getArrayStream()", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - } - } - - /** - * Test {@code JsonParser getArrayStream()} method on non JSON array values. - */ - private void testGetNonArrayStream(final TestResult result) { - for (JsonValue value : NON_ARRAY_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getArrayStream() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.getArrayStream(); - result.fail("getArrayStream()", - "Calling method on non array value shall throw IllegalStateException"); - } catch (IllegalStateException e) { - TestUtil.logMsg(" Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("getArrayStream()", - "Calling method on non array value shall throw IllegalStateException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonParser getValueStream()} method on simple JSON values in - * document root. - */ - private void testGetValueStream(final TestResult result) { - for (final JsonValue value : VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getValueStream() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - final Stream outStream = parser.getValueStream(); - int count = 0; - for (final Iterator i = outStream.iterator(); i.hasNext();) { - final JsonValue out = i.next(); - if (operationFailed(value, out)) { - result.fail("getValueStream()", "Output Stream value " - + valueToString(out) + " shall be " + valueToString(value)); - } - count++; - } - if (count != 1) { - TestUtil.logMsg(" Output Stream contains " - + Integer.toString(count) + " values, not 1"); - result.fail("getValueStream()", - "Output Stream does not contain exactly 1 JSON value"); - } - } - } - } - - /** - * Test {@code JsonParser getValueStream()} method inside compound JSON values - * in document root. - */ - private void testGetCompoundValueStream(final TestResult result) { - for (final JsonValue value : COMPOUND_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - getValueStream() inside " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.getValueStream(); - result.fail("getValueStream()", - "Calling method on non object value shall throw IllegalStateException"); - } catch (IllegalStateException e) { - TestUtil.logMsg(" Expected exception: " + e.getMessage()); - } catch (Throwable t) { - result.fail("getValueStream()", - "Calling method on non object value shall throw IllegalStateException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonParser skipArray()} method inside JSON array values. - * Expected result: Parser shall advance to the end of the stream after - * skipping an array which is the only value in the stream. - */ - private void testSkipArray(final TestResult result) { - for (final JsonArray value : ARRAY_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - skipArray() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.skipArray(); - if (parser.hasNext()) { - result.fail("skipArray()", - "Parser did not davance to the end of the array"); - } - } catch (Throwable t) { - TestUtil.logMsg( - " " + t.getClass().getSimpleName() + ": " + t.getMessage()); - result.fail("skipArray()", - t.getClass().getSimpleName() + ": " + t.getMessage()); - } - } - } - - /** - * Test {@code JsonParser skipArray()} method outside JSON array values. - * Expected result: Parser shall not advance anywhere when called outside an - * array. Whole value shall match after {@code skipArray()} call because - * nothing shall happen in it. - */ - private void testSkipNonArray(final TestResult result) { - for (final JsonValue value : NON_ARRAY_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - skipArray() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.skipArray(); - final JsonValue out = parser.getValue(); - if (operationFailed(value, out)) { - result.fail("skipArray()", - "Output value " + valueToString(out) + " shall be " - + valueToString(value) + " even after skipArray()"); - } - } catch (Throwable t) { - TestUtil.logMsg( - " " + t.getClass().getSimpleName() + ": " + t.getMessage()); - result.fail("skipArray()", - t.getClass().getSimpleName() + ": " + t.getMessage()); - } - } - } - - /** - * Test {@code JsonParser skipObject()} method inside JSON object values. - * Expected result: Parser shall advance to the end of the stream after - * skipping an object which is the only value in the stream. - */ - private void testSkipObject(final TestResult result) { - for (final JsonObject value : OBJ_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - skipObject() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.skipObject(); - if (parser.hasNext()) { - result.fail("skipObject()", - "Parser did not davance to the end of the object"); - } - } catch (Throwable t) { - TestUtil.logMsg( - " " + t.getClass().getSimpleName() + ": " + t.getMessage()); - result.fail("skipObject()", - t.getClass().getSimpleName() + ": " + t.getMessage()); - } - } - } - - /** - * Test {@code JsonParser skipObject()} method outside JSON object values. - * Expected result: Parser shall not advance anywhere when called outside an - * object. Whole value shall match after {@code skipObject()} call because - * nothing shall happen in it. - */ - private void testSkipNonObject(final TestResult result) { - for (final JsonValue value : NON_OBJ_VALUES) { - final String data = jsonData(value); - TestUtil.logMsg(" - skipObject() on " + data); - final StringReader strReader = new StringReader(data); - try (final JsonParser parser = Json.createParser(strReader)) { - parser.next(); - parser.skipObject(); - final JsonValue out = parser.getValue(); - if (operationFailed(value, out)) { - result.fail("skipObject()", - "Output value " + valueToString(out) + " shall be " - + valueToString(value) + " even after skipObject()"); - } - } catch (Throwable t) { - TestUtil.logMsg( - " " + t.getClass().getSimpleName() + ": " + t.getMessage()); - result.fail("skipObject()", - t.getClass().getSimpleName() + ": " + t.getMessage()); - } - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - TestUtil.logMsg(" Checking " + valueToString(out)); - return out == null || !assertEquals(check, out); - } - - /** - * Operation result check. - * - * @param check - * Expected Stream content. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonObject check, - final Stream> out) { - // Operation failed for null. - if (out == null) { - TestUtil.logMsg(" Output is null"); - return true; - } - final Set keys = new HashSet<>(check.size()); - // Clone key Set - for (final String key : check.keySet()) { - keys.add(key); - } - for (final Iterator> i = out.iterator(); i - .hasNext();) { - final Map.Entry item = i.next(); - final JsonValue checkValue = check.get(item.getKey()); - TestUtil.logMsg(" Checking " + valueToString(item.getValue())); - // Operation failed if values with the same key are not equal. - if (!item.getValue().equals(checkValue)) { - TestUtil.logMsg(" check: " + valueToString(checkValue) - + " stream: " + valueToString(checkValue)); - return true; - } - keys.remove(item.getKey()); - } - // Operation failed if some unmatched keys remain in the set. - return !keys.isEmpty(); - } - - /** - * Operation result check. - * - * @param check - * Expected Stream content. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonArray check, - final Stream out) { - // Operation failed for null. - if (out == null) { - TestUtil.logMsg(" Output is null"); - return true; - } - final Iterator ci = check.iterator(); - final Iterator oi = out.iterator(); - // To exit cycle, at least one of iterators does not have next value. - while (ci.hasNext() && oi.hasNext()) { - final JsonValue checkValue = ci.next(); - final JsonValue outValue = oi.next(); - TestUtil.logMsg(" Checking " + valueToString(outValue)); - if (!checkValue.equals(outValue)) { - TestUtil.logMsg(" check: " + valueToString(checkValue) - + " stream: " + valueToString(checkValue)); - return true; - } - } - // Check still has values, something was missing in output. - if (ci.hasNext()) { - TestUtil.logMsg(" Output contains less values than expected"); - return true; - } - // Output still has values, it contains more than expected. - if (oi.hasNext()) { - TestUtil.logMsg(" Output contains more values than expected"); - return true; - } - return false; - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonparsertests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonparsertests/build.xml deleted file mode 100644 index 113d2733b2..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonparsertests/build.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonreaderfactorytests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonreaderfactorytests/Client.java deleted file mode 100644 index 4b69655c7c..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonreaderfactorytests/Client.java +++ /dev/null @@ -1,305 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonreaderfactorytests; - -import java.io.InputStream; -import java.io.StringReader; -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.Json; -import jakarta.json.JsonObject; -import jakarta.json.JsonReader; -import jakarta.json.JsonReaderFactory; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonReaderFactoryTest1 - * - * @assertion_ids: JSONP:JAVADOC:419; JSONP:JAVADOC:449; JSONP:JAVADOC:185; - * JSONP:JAVADOC:459; - * - * @test_Strategy: Tests the JsonReaderFactory API. - * - * JsonReaderFactory readerFactory = Json.createReaderFactory(Map); - * JsonReader reader1 = readerFactory.createReader(Reader) JsonReader reader2 - * = readerFactory.createReader(Reader) - */ - public void jsonReaderFactoryTest1() throws Fault { - boolean pass = true; - JsonReader reader1 = null; - JsonReader reader2 = null; - JsonObject jsonObject = null; - String jsonObjectText = "{\"foo\":\"bar\"}"; - try { - logMsg("Create JsonReaderFactory with Map with EMPTY config"); - JsonReaderFactory readerFactory = Json - .createReaderFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = readerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - logMsg("--------------------------------------------------"); - logMsg("TEST CASE [JsonReaderFactory.createReader(Reader)]"); - logMsg("--------------------------------------------------"); - logMsg("Create 1st JsonReader using JsonReaderFactory"); - reader1 = readerFactory.createReader(new StringReader(jsonObjectText)); - if (reader1 == null) { - logErr("ReaderFactory failed to create reader1"); - pass = false; - } else { - jsonObject = reader1.readObject(); - reader1.close(); - - if (!JSONP_Util.assertEquals(jsonObject.size(), 1) - || !JSONP_Util.assertEquals(jsonObject.getString("foo"), "bar")) - pass = false; - } - - logMsg("Create 2nd JsonReader using JsonReaderFactory"); - reader2 = readerFactory.createReader(new StringReader(jsonObjectText)); - if (reader2 == null) { - logErr("ReaderFactory failed to create reader2"); - pass = false; - } else { - jsonObject = reader2.readObject(); - reader2.close(); - - if (!JSONP_Util.assertEquals(jsonObject.size(), 1) - || !JSONP_Util.assertEquals(jsonObject.getString("foo"), "bar")) - pass = false; - } - - } catch (Exception e) { - throw new Fault("jsonReaderFactoryTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonReaderFactoryTest1 Failed"); - } - - /* - * @testName: jsonReaderFactoryTest2 - * - * @assertion_ids: JSONP:JAVADOC:420; JSONP:JAVADOC:449; JSONP:JAVADOC:185; - * JSONP:JAVADOC:459; - * - * @test_Strategy: Tests the JsonReaderFactory API. - * - * JsonReaderFactory readerFactory = Json.createReaderFactory(Map); - * JsonReader reader1 = readerFactory.createReader(InputStream, Charset) - * JsonReader reader2 = readerFactory.createReader(InputStream, Charset) - * - * Create reader with both UTF-8 and UTF-16BE. - */ - public void jsonReaderFactoryTest2() throws Fault { - boolean pass = true; - JsonReader reader1 = null; - JsonReader reader2 = null; - JsonObject jsonObject = null; - String jsonObjectText = "{\"foo\":\"bar\"}"; - try { - logMsg("Create JsonReaderFactory with Map with EMPTY config"); - JsonReaderFactory readerFactory = Json - .createReaderFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = readerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg( - "----------------------------------------------------------------"); - logMsg( - "TEST CASE [JsonReaderFactory.createReader(InputStream, Charset)]"); - logMsg( - "----------------------------------------------------------------"); - logMsg( - "Create 1st JsonReader using JsonReaderFactory with UTF-8 encoding"); - InputStream is1 = JSONP_Util.getInputStreamFromString(jsonObjectText); - reader1 = readerFactory.createReader(is1, JSONP_Util.UTF_8); - if (reader1 == null) { - logErr("ReaderFactory failed to create reader1"); - pass = false; - } else { - jsonObject = reader1.readObject(); - reader1.close(); - - if (!JSONP_Util.assertEquals(jsonObject.size(), 1) - || !JSONP_Util.assertEquals(jsonObject.getString("foo"), "bar")) - pass = false; - } - - logMsg( - "Create 2nd JsonReader using JsonReaderFactory with UTF-8 encoding"); - InputStream is2 = JSONP_Util.getInputStreamFromString(jsonObjectText); - reader2 = readerFactory.createReader(is2, JSONP_Util.UTF_8); - if (reader2 == null) { - logErr("ReaderFactory failed to create reader2"); - pass = false; - } else { - jsonObject = reader2.readObject(); - reader2.close(); - - if (!JSONP_Util.assertEquals(jsonObject.size(), 1) - || !JSONP_Util.assertEquals(jsonObject.getString("foo"), "bar")) - pass = false; - } - - } catch (Exception e) { - throw new Fault("jsonReaderFactoryTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonReaderFactoryTest2 Failed"); - } - - /* - * @testName: jsonReaderFactoryTest3 - * - * @assertion_ids: JSONP:JAVADOC:429; JSONP:JAVADOC:449; JSONP:JAVADOC:185; - * JSONP:JAVADOC:459; - * - * @test_Strategy: Tests the JsonReaderFactory API. - * - * JsonReaderFactory readerFactory = Json.createReaderFactory(Map); - * JsonReader reader1 = readerFactory.createReader(InputStream) JsonReader - * reader2 = readerFactory.createReader(InputStream) - */ - public void jsonReaderFactoryTest3() throws Fault { - boolean pass = true; - JsonReader reader1 = null; - JsonReader reader2 = null; - JsonObject jsonObject = null; - String jsonObjectText = "{\"foo\":\"bar\"}"; - try { - logMsg("Create JsonReaderFactory with Map with EMPTY config"); - JsonReaderFactory readerFactory = Json - .createReaderFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = readerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-------------------------------------------------------"); - logMsg("TEST CASE [JsonReaderFactory.createReader(InputStream)]"); - logMsg("-------------------------------------------------------"); - logMsg("Create 1st JsonReader using JsonReaderFactory"); - InputStream is1 = JSONP_Util.getInputStreamFromString(jsonObjectText); - reader1 = readerFactory.createReader(is1); - if (reader1 == null) { - logErr("ReaderFactory failed to create reader1"); - pass = false; - } else { - jsonObject = reader1.readObject(); - reader1.close(); - - if (!JSONP_Util.assertEquals(jsonObject.size(), 1) - || !JSONP_Util.assertEquals(jsonObject.getString("foo"), "bar")) - pass = false; - } - - logMsg("Create 2nd JsonReader using JsonReaderFactory"); - InputStream is2 = JSONP_Util.getInputStreamFromString(jsonObjectText); - reader2 = readerFactory.createReader(is2); - if (reader2 == null) { - logErr("ReaderFactory failed to create reader2"); - pass = false; - } else { - jsonObject = reader2.readObject(); - reader2.close(); - - if (!JSONP_Util.assertEquals(jsonObject.size(), 1) - || !JSONP_Util.assertEquals(jsonObject.getString("foo"), "bar")) - pass = false; - } - - } catch (Exception e) { - throw new Fault("jsonReaderFactoryTest3 Failed: ", e); - } - if (!pass) - throw new Fault("jsonReaderFactoryTest3 Failed"); - } - - /* - * @testName: jsonReaderFactoryTest4 - * - * @assertion_ids: JSONP:JAVADOC:449; JSONP:JAVADOC:459; - * - * @test_Strategy: Tests the JsonReaderFactory API. - * - * JsonReaderFactory readerFactory = Json.createReaderFactory(Map); - * Map config = JsonReaderFactory.getConfigInUse(); - * - * Test for the following 3 scenarios: 1) no supported provider property - * (empty config) 2) non supported provider property - */ - public void jsonReaderFactoryTest4() throws Fault { - boolean pass = true; - JsonReaderFactory readerFactory; - Map config; - try { - logMsg("----------------------------------------------"); - logMsg("Test scenario1: no supported provider property"); - logMsg("----------------------------------------------"); - logMsg("Create JsonReaderFactory with Map with EMPTY config"); - readerFactory = Json.createReaderFactory(JSONP_Util.getEmptyConfig()); - config = readerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-----------------------------------------------"); - logMsg("Test scenario2: non supported provider property"); - logMsg("-----------------------------------------------"); - logMsg("Create JsonReaderFactory with Map with FOO config"); - readerFactory = Json.createReaderFactory(JSONP_Util.getFooConfig()); - config = readerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonReaderFactoryTest4 Failed: ", e); - } - if (!pass) - throw new Fault("jsonReaderFactoryTest4 Failed"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonreaderfactorytests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonreaderfactorytests/build.xml deleted file mode 100644 index 7389e1189d..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonreaderfactorytests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonreadertests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonreadertests/Client.java deleted file mode 100644 index b40a283fb5..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonreadertests/Client.java +++ /dev/null @@ -1,3228 +0,0 @@ -/* - * Copyright (c) 2013, 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 com.sun.ts.tests.jsonp.api.jsonreadertests; - -import java.io.InputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import com.sun.ts.tests.jsonp.common.JSONP_Data; -import com.sun.ts.tests.jsonp.common.JSONP_Util; -import com.sun.ts.tests.jsonp.common.MyBufferedInputStream; -import com.sun.ts.tests.jsonp.common.MyBufferedReader; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonReader; -import jakarta.json.JsonStructure; -import jakarta.json.JsonValue; -import jakarta.json.JsonWriter; -import jakarta.json.stream.JsonParsingException; - -// $Id$ -public class Client extends ServiceEETest { - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Utility Methods */ - - /* - * compareJsonObjectForUTFEncodedTests - */ - private boolean compareJsonObjectForUTFEncodedTests(JsonObject jsonObject) { - boolean pass = true; - logMsg("Comparing JsonObject values to expected results."); - String expString = "stringValue"; - String actString = jsonObject.getJsonString("stringName").getString(); - if (!JSONP_Util.assertEquals(expString, actString)) - pass = false; - JsonObject actObject = jsonObject.getJsonObject("objectName"); - expString = "bar"; - actString = actObject.getJsonString("foo").getString(); - if (!JSONP_Util.assertEquals(expString, actString)) - pass = false; - JsonArray actArray = jsonObject.getJsonArray("arrayName"); - if (!JSONP_Util.assertEquals(1, actArray.getJsonNumber(0).intValue()) - || !JSONP_Util.assertEquals(2, actArray.getJsonNumber(1).intValue()) - || !JSONP_Util.assertEquals(3, actArray.getJsonNumber(2).intValue())) - pass = false; - return pass; - } - - /* Tests */ - - /* - * @testName: readEmptyArrayTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:184; - * - * @test_Strategy: Test read of an empty array "[]" from stream. Use - * JsonReader.readArray() API call. - * - */ - public void readEmptyArrayTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - String expJsonText = "[]"; - logMsg("Testing read of " + expJsonText); - reader = Json.createReader(new StringReader(expJsonText)); - JsonArray array = reader.readArray(); - pass = JSONP_Util.assertEqualsEmptyArrayList(array); - } catch (Exception e) { - throw new Fault("readEmptyArrayTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readEmptyArrayTest Failed"); - } - - /* - * @testName: readEscapeCharsInArrayTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:184; - * - * @test_Strategy: Test read of an array from a resource file with special - * chars in data. Use JsonReader.readArray() API call. Test scenario: Read - * string of JSON text containing a JSON array from resource file with - * following data: [ "popeye\"\\\/\b\f\n\r\tolive" ] - * - * These characters are backslash escape'd as follows: \" \\ \/ \b \f \n \r \t - * - * Create a JsonWriter to write above JsonArray to a string of JSON text. - * Re-read JsonWriter text back into a JsonArray Compare expected JSON array - * with actual JSON array for equality. - * - */ - public void readEscapeCharsInArrayTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - String resourceFile = "jsonArrayWithEscapeCharsData.json"; - String expString = "popeye" + JSONP_Data.escapeCharsAsString + "olive"; - try { - - logMsg("Reading contents of resource file " + resourceFile); - String readerContents = JSONP_Util - .getContentsOfResourceAsString(resourceFile); - logMsg("readerContents=" + readerContents); - - logMsg("Testing read of resource contents: " + readerContents); - reader = Json.createReader(new StringReader(readerContents)); - JsonArray expJsonArray = reader.readArray(); - - TestUtil.logMsg("Dump of expJsonArray"); - JSONP_Util.dumpJsonArray(expJsonArray); - - logMsg("Comparing JsonArray values with expected results."); - String actString = expJsonArray.getJsonString(0).getString(); - if (!JSONP_Util.assertEquals(expString, actString)) - pass = false; - - logMsg("Write the JsonArray 'expJsonArray' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeArray(expJsonArray); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = sWriter.toString(); - - logMsg("Create actJsonArray from read of writer contents: " - + writerContents); - reader = Json.createReader(new StringReader(writerContents)); - JsonArray actJsonArray = reader.readArray(); - - TestUtil.logMsg("Dump of actJsonArray"); - JSONP_Util.dumpJsonArray(actJsonArray); - - logMsg("Compare expJsonArray and actJsonArray for equality"); - if (!JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray)) - pass = false; - } catch (Exception e) { - throw new Fault("readEscapeCharsInArrayTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readEscapeCharsInArrayTest Failed"); - } - - /* - * @testName: readEscapeUnicodeCharsInArrayTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:184; - * - * @test_Strategy: Test read of an array with unicode chars escaped and not - * escaped. Use JsonReader.readArray() API call. Test scenario: Read string of - * JSON text containing a JSON array with the following data: [ - * "\\u0000\u00ff\\uff00\uffff" ] - * - * Notice unicode \u0000 and \uff00 is escaped but \u00ff and \uffff is not. - * - * Compare expected JSON String with actual JSON String for equality. - * - */ - public void readEscapeUnicodeCharsInArrayTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - String unicodeTextString = "[\"\\u0000\u00ff\\uff00\uffff\"]"; - String expResult = "\u0000\u00ff\uff00\uffff"; - try { - logMsg("Reading array of escaped and non escaped unicode chars."); - reader = Json.createReader(new StringReader(unicodeTextString)); - JsonArray array = reader.readArray(); - String actResult = array.getJsonString(0).getString(); - pass = JSONP_Util.assertEquals(expResult, actResult); - } catch (Exception e) { - throw new Fault("readEscapeUnicodeCharsInArrayTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readEscapeUnicodeCharsInArrayTest Failed"); - } - - /* - * @testName: readEscapeUnicodeControlCharsInArrayTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:184; - * - * @test_Strategy: Test read of an array with unicode control chars escaped. - * Use JsonReader.readArray() API call. Test scenario: Read string of JSON - * text containing unicode control chars escaped as a Json Array. - * - * Compare expected JSON String with actual JSON String for equality. - * - */ - public void readEscapeUnicodeControlCharsInArrayTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - String unicodeTextString = "[\"" + JSONP_Data.unicodeControlCharsEscaped - + "\"]"; - String expResult = JSONP_Data.unicodeControlCharsNonEscaped; - try { - logMsg("Reading array of escaped and non escaped unicode chars."); - reader = Json.createReader(new StringReader(unicodeTextString)); - JsonArray array = reader.readArray(); - String actResult = array.getJsonString(0).getString(); - pass = JSONP_Util.assertEquals(expResult, actResult); - } catch (Exception e) { - throw new Fault("readEscapeUnicodeControlCharsInArrayTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readEscapeUnicodeControlCharsInArrayTest Failed"); - } - - /* - * @testName: readEmptyObjectTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:185; - * - * @test_Strategy: Test read of an empty object "{}" from stream. Use - * JsonReader.readObject() API call. - * - */ - public void readEmptyObjectTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - String expJsonText = "{}"; - logMsg("Testing read of " + expJsonText); - reader = Json.createReader(new StringReader(expJsonText)); - JsonObject object = reader.readObject(); - pass = JSONP_Util.assertEqualsEmptyObjectMap(object); - } catch (Exception e) { - throw new Fault("readEmptyObjectTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readEmptyObjectTest Failed"); - } - - /* - * @testName: readEscapeCharsInObjectTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:185; - * - * @test_Strategy: Test read of an object from a resource file with special - * chars in data. Use JsonReader.readObject() API call. Test scenario: Read - * string of JSON text containing a JSON object from resource file with - * following data: { "specialChars" : "popeye\"\\\/\b\f\n\r\tolive" } - * - * These characters are backslash escape'd as follows: \" \\ \/ \b \f \n \r \t - * - * Create a JsonWriter to write above JsonObject to a string of JSON text. - * Re-read JsonWriter text back into a JsonObject Compare expected JSON object - * with actual JSON object for equality. - * - */ - public void readEscapeCharsInObjectTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - String resourceFile = "jsonObjectWithEscapeCharsData.json"; - String expString = "popeye" + JSONP_Data.escapeCharsAsString + "olive"; - try { - - logMsg("Reading contents of resource file " + resourceFile); - String readerContents = JSONP_Util - .getContentsOfResourceAsString(resourceFile); - logMsg("readerContents=" + readerContents); - - logMsg("Testing read of resource contents: " + readerContents); - reader = Json.createReader(new StringReader(readerContents)); - JsonObject expJsonObject = reader.readObject(); - - TestUtil.logMsg("Dump of expJsonObject"); - JSONP_Util.dumpJsonObject(expJsonObject); - - logMsg("Comparing JsonArray values with expected results."); - String actString = expJsonObject.getJsonString("escapeChars").getString(); - if (!JSONP_Util.assertEquals(expString, actString)) - pass = false; - - logMsg("Write the JsonObject 'expJsonObject' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeObject(expJsonObject); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = sWriter.toString(); - - logMsg("Create actJsonObject from read of writer contents: " - + writerContents); - reader = Json.createReader(new StringReader(writerContents)); - JsonObject actJsonObject = reader.readObject(); - - TestUtil.logMsg("Dump of actJsonObject"); - JSONP_Util.dumpJsonObject(actJsonObject); - - logMsg("Compare expJsonObject and actJsonObject for equality"); - if (!JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject)) - pass = false; - } catch (Exception e) { - throw new Fault("readEscapeCharsInObjectTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readEscapeCharsInObjectTest Failed"); - } - - /* - * @testName: readEscapeUnicodeCharsInObjectTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:185; - * - * @test_Strategy: Test read of an object with unicode chars escaped and not - * escaped. Use JsonReader.readObject() API call. Test scenario: Read string - * of JSON text containing a JSON object with the following data: { - * "unicodechars":"\\u0000\u00ff\\uff00\uffff" ] - * - * Notice unicode \u0000 and \uff00 is escaped but \u00ff and \uffff is not. - * - * Compare expected JSON String with actual JSON String for equality. - * - */ - public void readEscapeUnicodeCharsInObjectTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - String unicodeTextString = "{\"unicodechars\":\"\\u0000\u00ff\\uff00\uffff\"}"; - String expResult = "\u0000\u00ff\uff00\uffff"; - try { - logMsg("Reading object of escaped and non escaped unicode chars."); - reader = Json.createReader(new StringReader(unicodeTextString)); - JsonObject object = reader.readObject(); - String actResult = object.getJsonString("unicodechars").getString(); - pass = JSONP_Util.assertEquals(expResult, actResult); - } catch (Exception e) { - throw new Fault("readEscapeUnicodeCharsInObjectTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readEscapeUnicodeCharsInObjectTest Failed"); - } - - /* - * @testName: readEscapeUnicodeControlCharsInObjectTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:185; - * - * @test_Strategy: Test read of an array with unicode control chars escaped. - * Use JsonReader.readObject() API call. Test scenario: Read string of JSON - * text containing unicode control chars escaped as a Json Object. - * - * Compare expected JSON String with actual JSON String for equality. - * - */ - public void readEscapeUnicodeControlCharsInObjectTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - String unicodeTextString = "{\"unicodechars\":\"" - + JSONP_Data.unicodeControlCharsEscaped + "\"}"; - String expResult = JSONP_Data.unicodeControlCharsNonEscaped; - try { - logMsg("Reading array of escaped and non escaped unicode chars."); - reader = Json.createReader(new StringReader(unicodeTextString)); - JsonObject object = reader.readObject(); - String actResult = object.getJsonString("unicodechars").getString(); - pass = JSONP_Util.assertEquals(expResult, actResult); - } catch (Exception e) { - throw new Fault("readEscapeUnicodeControlCharsInObjectTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readEscapeUnicodeControlCharsInObjectTest Failed"); - } - - /* - * @testName: readArrayTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:184; - * - * @test_Strategy: Test read of an array containing various types from stream. - * Use JsonReader.readArray() API call. [true, false, null, "booyah", - * 2147483647, 9223372036854775807, 1.7976931348623157E308, - * [true,false,null,"bingo",-2147483648,-9223372036854775808,4.9E-324], - * {"true":true,"false":false,"null":null,"bonga":"boo","int":1,"double":10.4} - * ] Test scenario: Read string of JSON text above consisting of a JSON array - * into a JsonArray object. Create an expected List of JsonArray values for - * use in test comparison. Compare expected list of JsonArray values with - * actual list for equality. - * - */ - public void readArrayTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - String jsonText = "[true,false,null,\"booyah\",2147483647,9223372036854775807,1.7976931348623157E308," - + "[true,false,null,\"bingo\",-2147483648,-9223372036854775808,4.9E-324]," - + "{\"true\":true,\"false\":false,\"null\":null,\"bonga\":\"boo\",\"int\":1," - + "\"double\":10.4}]"; - - logMsg("Create the expected list of JsonArray values"); - List expList = new ArrayList<>(); - expList.add(JsonValue.TRUE); - expList.add(JsonValue.FALSE); - expList.add(JsonValue.NULL); - expList.add(JSONP_Util.createJsonString("booyah")); - expList.add(JSONP_Util.createJsonNumber(Integer.MAX_VALUE)); - expList.add(JSONP_Util.createJsonNumber(Long.MAX_VALUE)); - expList.add(JSONP_Util.createJsonNumber(Double.MAX_VALUE)); - JsonArray array = Json.createArrayBuilder().add(JsonValue.TRUE) - .add(JsonValue.FALSE).add(JsonValue.NULL).add("bingo") - .add(Integer.MIN_VALUE).add(Long.MIN_VALUE).add(Double.MIN_VALUE) - .build(); - JsonObject object = Json.createObjectBuilder().add("true", JsonValue.TRUE) - .add("false", JsonValue.FALSE).add("null", JsonValue.NULL) - .add("bonga", "boo").add("int", 1).add("double", 10.4).build(); - expList.add(array); - expList.add(object); - - logMsg("Testing read of " + jsonText); - reader = Json.createReader(new StringReader(jsonText)); - JsonArray myJsonArray = reader.readArray(); - - List actList = myJsonArray; - logMsg( - "Compare actual list of JsonArray values with expected list of JsonArray values"); - pass = JSONP_Util.assertEqualsList(expList, actList); - } catch (Exception e) { - throw new Fault("readArrayTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readArrayTest Failed"); - } - - /* - * @testName: readArrayTest2 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:184; - * JSONP:JAVADOC:178; - * - * @test_Strategy: Test read of an array containing various types from stream. - * Use JsonReader.readArray() API call. [true, false, null, "booyah", - * 2147483647, 9223372036854775807, 1.7976931348623157E308, - * [true,false,null,"bingo",-2147483648,-9223372036854775808,4.9E-324], - * {"true":true,"false":false,"null":null,"bonga":"boo","int":1,"double":10.4} - * ] Test Scenario: Create an expected JsonArray of the above JSON array for - * use in test comparison. Create a JsonWriter to write the above JsonArray to - * a string of JSON text. Next call JsonReader to read the JSON text from the - * JsonWriter to a JsonArray object. Compare expected JsonArray object with - * actual JsonArray object for equality. - * - */ - public void readArrayTest2() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - logMsg("Create the expected list of JsonArray values"); - JsonArray expJsonArray = Json.createArrayBuilder().add(JsonValue.TRUE) - .add(JsonValue.FALSE).add(JsonValue.NULL).add("booyah") - .add(Integer.MAX_VALUE).add(Long.MAX_VALUE).add(Double.MAX_VALUE) - .add(Json.createArrayBuilder().add(JsonValue.TRUE) - .add(JsonValue.FALSE).add(JsonValue.NULL).add("bingo") - .add(Integer.MIN_VALUE).add(Long.MIN_VALUE).add(Double.MIN_VALUE)) - .add(Json.createObjectBuilder().add("true", JsonValue.TRUE) - .add("false", JsonValue.FALSE).add("null", JsonValue.NULL) - .add("bonga", "boo").add("int", 1).add("double", 10.4)) - .build(); - - logMsg("Write the JsonArray 'expJsonArray' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeArray(expJsonArray); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String jsonText = sWriter.toString(); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + jsonText); - - logMsg("Testing read of " + jsonText); - reader = Json.createReader(JSONP_Util.getInputStreamFromString(jsonText)); - JsonArray actJsonArray = reader.readArray(); - - logMsg("Compare expJsonArray and actJsonArray for equality"); - pass = JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray); - } catch (Exception e) { - throw new Fault("readArrayTest2 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readArrayTest2 Failed"); - } - - /* - * @testName: readArrayTest3 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:449; JSONP:JAVADOC:184; - * JSONP:JAVADOC:419; - * - * @test_Strategy: Test read of an array containing various types from stream. - * Use JsonReader.readArray() API call. [true, false, null, "booyah", - * 2147483647, 9223372036854775807, - * [true,false,null,"bingo",-2147483648,-9223372036854775808], - * {"true":true,"false":false,"null":null,"bonga":"boo","int":1} ] Test - * scenario: Read string of JSON text above consisting of a JSON array into a - * JsonArray object with an empty configuration. Create a JsonWriter to write - * the above JsonArray to a string of JSON text. Compare expected JSON text - * with actual JSON text for equality. - * - * Tests the following API's: JsonReader = - * Json.createReaderFactory(Map).createReader(Reader) JsonArray - * array = JsonReader.readArray() - * - */ - public void readArrayTest3() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - String expJsonText = "[true,false,null,\"booyah\",2147483647,9223372036854775807," - + "[true,false,null,\"bingo\",-2147483648,-9223372036854775808]," - + "{\"true\":true,\"false\":false,\"null\":null,\"bonga\":\"boo\",\"int\":1}]"; - - logMsg("Testing read of " + expJsonText); - reader = Json.createReaderFactory(JSONP_Util.getEmptyConfig()) - .createReader(new StringReader(expJsonText)); - JsonArray myJsonArray = reader.readArray(); - - logMsg("Write the JsonArray 'myJsonArray' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeArray(myJsonArray); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String actJsonText = sWriter.toString(); - - logMsg("Compare actual JSON text with expected JSON text"); - pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText); - } catch (Exception e) { - throw new Fault("readArrayTest3 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readArrayTest3 Failed"); - } - - /* - * @testName: readArrayTest4 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:420; JSONP:JAVADOC:184; - * JSONP:JAVADOC:449; - * - * @test_Strategy: Test read of an array from a resource file with various - * amounts of data. Use JsonReader.readArray() API call. Test scenario: Read - * InputStream of JSON text containing a JSON array from resource file with - * various amounts of data use UTF-8 encoding. Create a JsonWriter to write - * above JsonArray to a string of JSON text. Re-read JsonWriter text back into - * a JsonArray Compare expected JSON array with actual JSON array for - * equality. - * - */ - public void readArrayTest4() throws Fault { - boolean pass = true; - JsonReader reader = null; - String resourceFile = "jsonArrayWithAllTypesOfData.json"; - try { - logMsg( - "Read contents of InputStream from resource file: " + resourceFile); - Map config = JSONP_Util.getEmptyConfig(); - reader = Json.createReaderFactory(config).createReader( - JSONP_Util.getInputStreamFromResource(resourceFile), - JSONP_Util.UTF_8); - JsonArray expJsonArray = reader.readArray(); - - TestUtil.logMsg("Dump of expJsonArray"); - JSONP_Util.dumpJsonArray(expJsonArray); - - logMsg("Write the JsonArray 'expJsonArray' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeArray(expJsonArray); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = sWriter.toString(); - - logMsg("Create actJsonArray from read of writer contents: " - + writerContents); - reader = Json.createReader(new StringReader(writerContents)); - JsonArray actJsonArray = reader.readArray(); - - TestUtil.logMsg("Dump of actJsonArray"); - JSONP_Util.dumpJsonArray(actJsonArray); - - logMsg("Compare expJsonArray and actJsonArray for equality"); - pass = JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray); - } catch (Exception e) { - throw new Fault("readArrayTest4 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readArrayTest4 Failed"); - } - - /* - * @testName: readArrayTest5 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:181; - * JSONP:JAVADOC:420; JSONP:JAVADOC:449; - * - * @test_Strategy: Test read of an array from a resource file with lots of - * nesting. Use JsonReader.read() API call. Test scenario: Read InputStream of - * JSON text containing a JSON array from resource file with lots of nesting - * use UTF-8 encoding with empty configuration. Create a JsonWriter to write - * above JsonArray to a string of JSON text. Compare expected JSON text with - * actual JSON text for equality. Filter all text output to remove whitespace - * before comparison. - * - * Tests the following API's: JsonReader = - * Json.createReaderFactory(Map).createReader(InputStream, Charset) - * JsonArray array = (JsonArray)JsonReader.read() - * - * - */ - public void readArrayTest5() throws Fault { - boolean pass = true; - JsonReader reader = null; - String resourceFile = "jsonArrayWithLotsOfNestedObjectsData.json"; - try { - logMsg("Reading contents of resource file " + resourceFile); - String readerContents = JSONP_Util - .getContentsOfResourceAsString(resourceFile); - logMsg("readerContents=" + readerContents); - - // Create expected JSON text from resource contents filtered of whitespace - // for comparison - logMsg("Filter readerContents of whitespace for comparison"); - String expJsonText = JSONP_Util.removeWhitespace(readerContents); - - logMsg( - "Read contents of InputStream from resource file: " + resourceFile); - reader = Json.createReaderFactory(JSONP_Util.getEmptyConfig()) - .createReader(JSONP_Util.getInputStreamFromResource(resourceFile), - JSONP_Util.UTF_8); - JsonArray myJsonArray = (JsonArray) reader.read(); - - logMsg("Write the JsonArray 'myJsonArray' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeArray(myJsonArray); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = sWriter.toString(); - - logMsg("Dump contents of the JsonWriter as a String"); - logMsg("writerContents=" + writerContents); - - logMsg("Filter writerContents of whitespace for comparison"); - String actJsonText = JSONP_Util.removeWhitespace(writerContents); - - logMsg("Compare actual JSON text with expected JSON text"); - pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText); - } catch (Exception e) { - throw new Fault("readArrayTest5 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readArrayTest5 Failed"); - } - - /* - * @testName: readArrayEncodingTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:420; JSONP:JAVADOC:449; - * JSONP:JAVADOC:184; - * - * @test_Strategy: Test read of a JsonArray from a resource file using both - * encodings of UTF-8 and UTF-16BE. - * - * Test scenario: For each encoding read the appropriate resource file - * containing a string value. Call JsonArray.getJsonString() to get the value - * of the JsonString. Compare expected string with actual string for equality. - */ - public void readArrayEncodingTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - String expString = "a\u65e8\u452c\u8b9e\u6589\u5c57\u5217z"; - String resourceFileUTF8 = "jsonArrayUTF8.json"; - String resourceFileUTF16BE = "jsonArrayUTF16BE.json"; - Map config = JSONP_Util.getEmptyConfig(); - try { - logMsg("Reading contents of resource file using UTF-8 encoding " - + resourceFileUTF8); - InputStream is = JSONP_Util.getInputStreamFromResource(resourceFileUTF8); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_8); - JsonArray jsonArray = reader.readArray(); - logMsg("Comparing JsonArray values with expected results."); - String actString = jsonArray.getJsonString(0).getString(); - if (!JSONP_Util.assertEquals(expString, actString)) - pass = false; - } catch (Exception e) { - throw new Fault("readArrayEncodingTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - try { - logMsg("Reading contents of resource file using UTF-16BE encoding " - + resourceFileUTF16BE); - InputStream is = JSONP_Util - .getInputStreamFromResource(resourceFileUTF16BE); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_16BE); - JsonArray jsonArray = reader.readArray(); - logMsg("Comparing JsonArray values with expected results."); - String actString = jsonArray.getJsonString(0).getString(); - if (!JSONP_Util.assertEquals(expString, actString)) - pass = false; - } catch (Exception e) { - throw new Fault("readArrayEncodingTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readArrayEncodingTest Failed"); - } - - /* - * @testName: readObjectTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:185; - * - * @test_Strategy: Test read of an object containing various types from - * stream. Use JsonReader.readObject() API call. {"true":true, "false":false, - * "null":null, "booyah":"booyah", "int":2147483647, - * "long":9223372036854775807, "double":1.7976931348623157E308, - * "array":[true,false,null,"bingo",-2147483648,-9223372036854775808,4.9E-324] - * , "object":{"true":true,"false":false,"null":null,"bonga":"boo","int":1, - * "double":10.4} } Test scenario: Read string of JSON text above consisting - * of a JSON object into a JsonObject object. Create an expected map of - * JsonObject values for use in test comparison. Compare expected map of - * JsonObject values with actual map for equality. - * - */ - public void readObjectTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - String expJsonText = "{\"true\":true,\"false\":false,\"null\":null,\"booyah\":\"booyah\",\"int\":2147483647," - + "\"long\":9223372036854775807,\"double\":1.7976931348623157E308," - + "\"array\":[true,false,null,\"bingo\",-2147483648,-9223372036854775808,4.9E-324]," - + "\"object\":{\"true\":true,\"false\":false,\"null\":null,\"bonga\":\"boo\",\"int\":1," - + "\"double\":10.4}}"; - - logMsg("Create the expected map of JsonObject values"); - Map expMap = new HashMap<>(); - expMap.put("true", JsonValue.TRUE); - expMap.put("false", JsonValue.FALSE); - expMap.put("null", JsonValue.NULL); - expMap.put("booyah", JSONP_Util.createJsonString("booyah")); - expMap.put("int", JSONP_Util.createJsonNumber(Integer.MAX_VALUE)); - expMap.put("long", JSONP_Util.createJsonNumber(Long.MAX_VALUE)); - expMap.put("double", JSONP_Util.createJsonNumber(Double.MAX_VALUE)); - JsonArray array = Json.createArrayBuilder().add(JsonValue.TRUE) - .add(JsonValue.FALSE).add(JsonValue.NULL).add("bingo") - .add(Integer.MIN_VALUE).add(Long.MIN_VALUE).add(Double.MIN_VALUE) - .build(); - JsonObject object = Json.createObjectBuilder().add("true", JsonValue.TRUE) - .add("false", JsonValue.FALSE).add("null", JsonValue.NULL) - .add("bonga", "boo").add("int", 1).add("double", 10.4).build(); - expMap.put("array", array); - expMap.put("object", object); - - logMsg("Testing read of " + expJsonText); - reader = Json.createReader(new StringReader(expJsonText)); - JsonObject myJsonObject = reader.readObject(); - - Map actMap = myJsonObject; - logMsg( - "Compare actual map of JsonObject values with expected map of JsonObject values"); - pass = JSONP_Util.assertEqualsMap(expMap, actMap); - } catch (Exception e) { - throw new Fault("readObjectTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readObjectTest Failed"); - } - - /* - * @testName: readObjectTest2 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:178; JSONP:JAVADOC:185; - * - * @test_Strategy: Test read of an object containing various types from - * stream. Use JsonReader.readObject() API call. {"true":true, "false":false, - * "null":null, "booyah":"booyah", "int":2147483647, - * "long":9223372036854775807, "double":1.7976931348623157E308, - * "array":[true,false,null,"bingo",-2147483648,-9223372036854775808,4.9E-324] - * , "object":{"true":true,"false":false,"null":null,"bonga":"boo","int":1, - * "double":10.4} } Test Scenario: Create an expected JsonObject of the above - * JSON object for use in test comparison. Create a JsonWriter to write the - * above JsonObject to a string of JSON text. Next call JsonReader to read the - * JSON text from the JsonWriter to a JsonObject object. Compare expected - * JsonObject object with actual JsonObject object for equality. - * - */ - public void readObjectTest2() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - logMsg("Create the expected list of JsonObject values"); - JsonObject expJsonObject = Json.createObjectBuilder() - .add("true", JsonValue.TRUE).add("false", JsonValue.FALSE) - .add("null", JsonValue.NULL).add("booyah", "booyah") - .add("int", Integer.MAX_VALUE).add("long", Long.MAX_VALUE) - .add("double", Double.MAX_VALUE) - .add("array", - Json.createArrayBuilder().add(JsonValue.TRUE).add(JsonValue.FALSE) - .add(JsonValue.NULL).add("bingo").add(Integer.MIN_VALUE) - .add(Long.MIN_VALUE).add(Double.MIN_VALUE)) - .add("object", - Json.createObjectBuilder().add("true", JsonValue.TRUE) - .add("false", JsonValue.FALSE).add("null", JsonValue.NULL) - .add("bonga", "boo").add("int", 1).add("double", 10.4)) - .build(); - - logMsg("Write the JsonObject 'expJsonObject' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeObject(expJsonObject); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String jsonText = sWriter.toString(); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + jsonText); - - logMsg("Testing read of " + jsonText); - reader = Json.createReader(JSONP_Util.getInputStreamFromString(jsonText)); - JsonObject actJsonObject = reader.readObject(); - - logMsg("Compare expJsonObject and actJsonObject for equality"); - pass = JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject); - } catch (Exception e) { - throw new Fault("readObjectTest2 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readObjectTest2 Failed"); - } - - /* - * @testName: readObjectTest3 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:185; JSONP:JAVADOC:419; - * JSONP:JAVADOC:449; - * - * @test_Strategy: Test read of an object containing various types from - * stream. Use JsonReader.readObject() API call. {"true":true, "false":false, - * "null":null, "booyah":"booyah", "int":2147483647, - * "long":9223372036854775807, - * "array":[true,false,null,"bingo",-2147483648,-9223372036854775808], - * "object":{"true":true,"false":false,"null":null,"bonga":"boo","int":1} } - * Test scenario: Read string of JSON text above consisting of a JSON object - * into a JsonObject object with an empty configuration. Create a JsonWriter - * to write the above JsonObject to a string of JSON text. Compare expected - * JSON text with actual JSON text for equality. - * - * Tests the following API's: JsonReader = - * Json.createReaderFactory(Map).createReader(Reader) JsonObject - * object = JsonReader.readObject() - * - * - */ - public void readObjectTest3() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - String expJsonText = "{\"true\":true,\"false\":false,\"null\":null,\"booyah\":\"booyah\",\"int\":2147483647,\"long\":9223372036854775807," - + "\"array\":[true,false,null,\"bingo\",-2147483648,-9223372036854775808]," - + "\"object\":{\"true\":true,\"false\":false,\"null\":null,\"bonga\":\"boo\",\"int\":1}}"; - - logMsg("Testing read of " + expJsonText); - reader = Json.createReaderFactory(JSONP_Util.getEmptyConfig()) - .createReader(new StringReader(expJsonText)); - JsonObject myJsonObject = reader.readObject(); - - logMsg("Write the JsonObject 'myJsonObject' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeObject(myJsonObject); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String actJsonText = sWriter.toString(); - - logMsg("Compare actual JSON text with expected JSON text"); - pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText); - } catch (Exception e) { - throw new Fault("readObjectTest3 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readObjectTest3 Failed"); - } - - /* - * @testName: readObjectTest4 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:420; - * JSONP:JAVADOC:449; - * - * @test_Strategy: Test read of an object from a resource file with various - * amounts of data. Use JsonReader.readObject() API call. Test scenario: Read - * InputStream of JSON text containing a JSON object from resource file with - * various amounts of data use UTF-8 encoding. Create a JsonWriter to write - * above JsonObject to a string of JSON text. Re-read JsonWriter text back - * into a JsonObject Compare expected JSON object with actual JSON object for - * equality. - * - */ - public void readObjectTest4() throws Fault { - boolean pass = true; - JsonReader reader = null; - String resourceFile = "jsonObjectWithAllTypesOfData.json"; - try { - logMsg( - "Read contents of InputStream from resource file: " + resourceFile); - Map config = JSONP_Util.getEmptyConfig(); - reader = Json.createReaderFactory(config).createReader( - JSONP_Util.getInputStreamFromResource(resourceFile), - JSONP_Util.UTF_8); - JsonObject expJsonObject = reader.readObject(); - - TestUtil.logMsg("Dump of expJsonObject"); - JSONP_Util.dumpJsonObject(expJsonObject); - - logMsg("Write the JsonObject 'expJsonObject' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeObject(expJsonObject); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = sWriter.toString(); - - logMsg("Create actJsonObject from read of writer contents: " - + writerContents); - reader = Json.createReader(new StringReader(writerContents)); - JsonObject actJsonObject = reader.readObject(); - - TestUtil.logMsg("Dump of actJsonObject"); - JSONP_Util.dumpJsonObject(actJsonObject); - - logMsg("Compare expJsonObject and actJsonObject for equality"); - pass = JSONP_Util.assertEqualsJsonObjects(expJsonObject, actJsonObject); - } catch (Exception e) { - throw new Fault("readObjectTest4 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readObjectTest4 Failed"); - } - - /* - * @testName: readObjectTest5 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:181; - * JSONP:JAVADOC:420; JSONP:JAVADOC:449; - * - * @test_Strategy: Test read of an object from a resource file with lots of - * nesting. Use JsonReader.read() API call. Test scenario: Read InputStream of - * JSON text containing a JSON object from resource file with lots of nesting - * use UTF-8 encoding with empty configuration. Create a JsonWriter to write - * above JsonObject to a string of JSON text. Compare expected JSON text with - * actual JSON text for equality. Filter all text output to remove whitespace - * before comparison. - * - * Tests the following API's: JsonReader = - * Json.createReaderFactory(Map).createReader(InputStream, Charset) - * JsonReader.read() JsonObject object = (JsonObject)JsonReader.read() - * - * - */ - public void readObjectTest5() throws Fault { - boolean pass = true; - JsonReader reader = null; - String resourceFile = "jsonObjectWithLotsOfNestedObjectsData.json"; - try { - logMsg("Reading contents of resource file " + resourceFile); - String readerContents = JSONP_Util - .getContentsOfResourceAsString(resourceFile); - logMsg("readerContents=" + readerContents); - - // Create expected JSON text from resource contents filtered of whitespace - // for comparison - logMsg("Filter readerContents of whitespace for comparison"); - String expJsonText = JSONP_Util.removeWhitespace(readerContents); - - logMsg( - "Read contents of InputStream from resource file: " + resourceFile); - reader = Json.createReaderFactory(JSONP_Util.getEmptyConfig()) - .createReader(JSONP_Util.getInputStreamFromResource(resourceFile), - JSONP_Util.UTF_8); - JsonObject myJsonObject = (JsonObject) reader.read(); - - logMsg("Write the JsonObject 'myJsonObject' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeObject(myJsonObject); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = sWriter.toString(); - - logMsg("Dump contents of the JsonWriter as a String"); - logMsg("writerContents=" + writerContents); - - logMsg("Filter writerContents of whitespace for comparison"); - String actJsonText = JSONP_Util.removeWhitespace(writerContents); - - logMsg("Compare actual JSON text with expected JSON text"); - pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText); - } catch (Exception e) { - throw new Fault("readObjectTest5 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readObjectTest5 Failed"); - } - - /* - * @testName: readObjectEncodingTest - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:420; JSONP:JAVADOC:185; - * JSONP:JAVADOC:449; - * - * @test_Strategy: Test read of a JsonObject from a resource file using both - * encodings of UTF-8 and UTF-16LE. - * - * Test scenario: For each encoding read the appropriate resource file - * containing a string value. Call JsonObject.getJsonString() to get the value - * of the JsonString. Compare expected string with actual string for equality. - */ - public void readObjectEncodingTest() throws Fault { - boolean pass = true; - JsonReader reader = null; - String expString = "a\u65e8\u452c\u8b9e\u6589\u5c57\u5217z"; - String resourceFileUTF8 = "jsonObjectUTF8.json"; - String resourceFileUTF16LE = "jsonObjectUTF16LE.json"; - try { - logMsg("Reading contents of resource file using UTF-8 encoding " - + resourceFileUTF8); - InputStream is = JSONP_Util.getInputStreamFromResource(resourceFileUTF8); - Map config = JSONP_Util.getEmptyConfig(); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_8); - JsonObject jsonObject = reader.readObject(); - logMsg("Comparing JsonObject values with expected results."); - String actString = jsonObject.getJsonString("unicodeChars").getString(); - if (!JSONP_Util.assertEquals(expString, actString)) - pass = false; - } catch (Exception e) { - throw new Fault("readObjectEncodingTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - try { - logMsg("Reading contents of resource file using UTF-16LE encoding " - + resourceFileUTF16LE); - InputStream is = JSONP_Util - .getInputStreamFromResource(resourceFileUTF16LE); - Map config = JSONP_Util.getEmptyConfig(); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_16LE); - JsonObject jsonObject = reader.readObject(); - logMsg("Comparing JsonObject values with expected results."); - String actString = jsonObject.getJsonString("unicodeChars").getString(); - if (!JSONP_Util.assertEquals(expString, actString)) - pass = false; - } catch (Exception e) { - throw new Fault("readObjectEncodingTest Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("readObjectEncodingTest Failed"); - } - - /* - * @testName: readUTFEncodedTests - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:420; JSONP:JAVADOC:185; - * JSONP:JAVADOC:449; - * - * @test_Strategy: Tests the JsonReader reader. Verifies READING of the - * JsonObject defined in resource files: - * - * jsonObjectEncodingUTF8.json jsonObjectEncodingUTF16.json - * jsonObjectEncodingUTF16LE.json jsonObjectEncodingUTF16BE.json - * jsonObjectEncodingUTF32LE.json jsonObjectEncodingUTF32BE.json - * - * Creates the JsonReader via the API: - * - * JsonReader reader = - * Json.createReaderFactory(Map).createReader(InputStream, Charset) - * - * For each supported encoding supported by JSON RFC read the JsonObject and - * verify we get the expected results. The Charset encoding is passed in as - * argument for each encoding type read. - */ - public void readUTFEncodedTests() throws Fault { - boolean pass = true; - JsonReader reader = null; - Map config = JSONP_Util.getEmptyConfig(); - try { - logMsg( - "-----------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createReaderFactory(Map).createReader(InputStream, Charset) as UTF-8]"); - logMsg( - "-----------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF8.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF8.json"); - logMsg( - "Create JsonReader from the InputStream with character encoding UTF-8"); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_8); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-8 encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createReaderFactory(Map).createReader(InputStream, Charset) as UTF-16]"); - logMsg( - "------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16.json"); - logMsg( - "Create JsonReader from the InputStream with character encoding UTF-16"); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_16); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-16 encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createReaderFactory(Map).createReader(InputStream, Charset) as UTF-16LE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16LE.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16LE.json"); - logMsg( - "Create JsonReader from the InputStream with character encoding UTF-16LE"); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_16LE); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-16LE encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createReaderFactory(Map).createReader(InputStream, Charset) as UTF-16BE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16BE.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16BE.json"); - logMsg( - "Create JsonReader from the InputStream with character encoding UTF-16BE"); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_16BE); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-16BE encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createReaderFactory(Map).createReader(InputStream, Charset) as UTF-32LE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF32LE.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF32LE.json"); - logMsg( - "Create JsonReader from the InputStream with character encoding UTF-32LE"); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_32LE); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-32LE encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createReaderFactory(Map).createReader(InputStream, Charset) as UTF-32BE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF32BE.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF32BE.json"); - logMsg( - "Create JsonReader from the InputStream with character encoding UTF-32BE"); - reader = Json.createReaderFactory(config).createReader(is, - JSONP_Util.UTF_32BE); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-32BE encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("readUTFEncodedTests Failed"); - } - - /* - * @testName: readUTFEncodedTests2 - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:178; JSONP:JAVADOC:185; - * - * @test_Strategy: Tests the JsonReader reader. Verifies READING of the - * JsonObject defined in resource files: - * - * jsonObjectEncodingUTF8.json jsonObjectEncodingUTF16LE.json - * jsonObjectEncodingUTF16BE.json jsonObjectEncodingUTF32LE.json - * jsonObjectEncodingUTF32BE.json - * - * Creates the JsonReader via the API: - * - * JsonReader reader = Json.createReader(InputStream istream) - * - * For each supported encoding supported by JSON RFC read the JsonObject and - * verify we get the expected results. The character encoding of the stream is - * auto-detected and determined as per the RFC. - */ - public void readUTFEncodedTests2() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - logMsg("---------------------------------------------------"); - logMsg("TEST CASE [Json.createReader(InputStream) as UTF-8]"); - logMsg("---------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF8.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF8.json"); - logMsg( - "Create JsonReader from the InputStream and auto-detect character encoding UTF-8"); - reader = Json.createReader(is); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-8 encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg("------------------------------------------------------"); - logMsg("TEST CASE [Json.createReader(InputStream) as UTF-16LE]"); - logMsg("------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16LE.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16LE.json"); - logMsg( - "Create JsonReader from the InputStream and auto-detect character encoding UTF-16LE"); - reader = Json.createReader(is); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-16LE encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg("------------------------------------------------------"); - logMsg("TEST CASE [Json.createReader(InputStream) as UTF-16BE]"); - logMsg("------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF16BE.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF16BE.json"); - logMsg( - "Create JsonReader from the InputStream and auto-detect character encoding UTF-16BE"); - reader = Json.createReader(is); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-16BE encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg("------------------------------------------------------"); - logMsg("TEST CASE [Json.createReader(InputStream) as UTF-32LE]"); - logMsg("------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF32LE.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF32LE.json"); - logMsg( - "Create JsonReader from the InputStream and auto-detect character encoding UTF-32LE"); - reader = Json.createReader(is); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-32LE encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - try { - logMsg("------------------------------------------------------"); - logMsg("TEST CASE [Json.createReader(InputStream) as UTF-32BE]"); - logMsg("------------------------------------------------------"); - logMsg( - "Get InputStream from data file as resource (jsonObjectEncodingUTF32BE.json)"); - InputStream is = JSONP_Util - .getInputStreamFromResource("jsonObjectEncodingUTF32BE.json"); - logMsg( - "Create JsonReader from the InputStream and auto-detect character encoding UTF-32BE"); - reader = Json.createReader(is); - JsonObject jsonObject = reader.readObject(); - if (!compareJsonObjectForUTFEncodedTests(jsonObject)) - pass = false; - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing reading of UTF-32BE encoding: " + e); - } finally { - try { - if (reader != null) - reader.close(); - } catch (Exception e) { - } - } - if (!pass) - throw new Fault("readUTFEncodedTests2 Failed"); - } - - /* - * @testName: negativeObjectTests - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:413; - * - * @test_Strategy: Test various Json Syntax Errors when reading a JsonObject. - * The tests trip various JsonParsingException/JsonException conditions when - * reading an object. - * - */ - public void negativeObjectTests() throws Fault { - boolean pass = true; - JsonReader reader = null; - - // Not an object [] - - try { - logMsg("Testing for not an object '[]'"); - reader = Json.createReader(new StringReader("[]")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonException"); - } catch (JsonException e) { - logMsg("Got expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Trip JsonParsingException for JsonReader.readObject() if incorrect - // representation for object - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if incorrect representation for object."); - logMsg("Reading " + "{\"name\":\"value\",1,2,3}"); - reader = Json - .createReader(new StringReader("{\"name\":\"value\",1,2,3}")); - JsonObject jsonObject = reader.readObject(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Missing [ - - try { - logMsg("Testing for missing '['"); - reader = Json.createReader(new StringReader("{1,2]}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing ] - - try { - logMsg("Testing for missing ']'"); - reader = Json.createReader(new StringReader("{[1,2}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing { - - try { - logMsg("Testing for missing '{'"); - reader = Json.createReader(new StringReader("}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing } - - try { - logMsg("Testing for missing '}'"); - reader = Json.createReader(new StringReader("{")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between array elements test case 1 - - try { - logMsg("Testing for missing ',' between array elements test case 1"); - reader = Json.createReader(new StringReader("{[5\"foo\"]}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between array elements test case 2 - - try { - logMsg("Testing for missing ',' between array elements test case 2"); - reader = Json.createReader(new StringReader("{[5{}]}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between object elements test case 1 - - try { - logMsg("Testing for missing ',' between object elements test case 1"); - reader = Json.createReader(new StringReader("{\"foo\":\"bar\"5}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between object elements test case 2 - - try { - logMsg("Testing for missing ',' between object elements test case 2"); - reader = Json.createReader(new StringReader("{\"one\":1[]}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing key name in object element - - try { - logMsg("Testing for missing key name in object element"); - reader = Json.createReader(new StringReader("{:\"bar\"}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing value name in object element - - try { - logMsg("Testing for missing value name in object element"); - reader = Json.createReader(new StringReader("{\"foo\":}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing double quote on a name - - try { - logMsg("Test for missing double quote on a name"); - reader = Json.createReader(new StringReader("{name\" : \"value\"}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing double quote on a value - - try { - logMsg("Test for missing double quote on a value"); - reader = Json.createReader(new StringReader("{\"name\" : value\"}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 1 - - try { - logMsg("Incorrect digit value -foo"); - reader = Json.createReader(new StringReader("{\"number\" : -foo}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 2 - - try { - logMsg("Incorrect digit value +foo"); - reader = Json.createReader(new StringReader("{\"number\" : +foo}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 3 - - try { - logMsg("Incorrect digit value -784foo"); - reader = Json.createReader(new StringReader("{\"number\" : -784foo}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 4 - - try { - logMsg("Incorrect digit value +784foo"); - reader = Json.createReader(new StringReader("{\"number\" : +784foo}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 5 - - try { - logMsg("Incorrect digit value 0.1E5E5"); - reader = Json.createReader(new StringReader("{\"number\" : 0.1E5E5}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 6 - - try { - logMsg("Incorrect digit value 0.F10"); - reader = Json.createReader(new StringReader("{\"number\" : 0.F10}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 7 - - try { - logMsg("Incorrect digit value string"); - reader = Json.createReader(new StringReader("{\"number\" : string}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 8 (hex numbers invalid per JSON RFC) - - try { - logMsg("Incorrect digit value hex numbers invalid per JSON RFC"); - reader = Json.createReader(new StringReader("{\"number\" : 0x137a}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 9 (octal numbers invalid per JSON RFC) - - try { - logMsg("Incorrect digit value octal numbers invalid per JSON RFC"); - reader = Json.createReader(new StringReader("{\"number\" : 0137}")); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - if (!pass) - throw new Fault("negativeObjectTests Failed"); - } - - /* - * @testName: negativeArrayTests - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:412; - * - * @test_Strategy: Test various Json Syntax Errors when reading a JsonArray. - * The tests trip various JsonParsingException/JsonException conditions when - * reading an array. - * - */ - public void negativeArrayTests() throws Fault { - boolean pass = true; - JsonReader reader = null; - - // Not an array {} - - try { - logMsg("Testing for not an array '{}'"); - reader = Json.createReader(new StringReader("{}")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonException"); - } catch (JsonException e) { - logMsg("Got expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Trip JsonParsingException for JsonReader.readArray() if incorrect - // representation for array - try { - logMsg( - "Trip JsonParsingException for JsonReader.readArray() if incorrect representation for array."); - logMsg("Reading " + "[foo,10,\"name\":\"value\"]"); - reader = Json - .createReader(new StringReader("[foo,10,\"name\":\"value\"]")); - JsonArray jsonArray = reader.readArray(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Missing [ - - try { - logMsg("Testing for missing '['"); - reader = Json.createReader(new StringReader("]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing ] - - try { - logMsg("Testing for missing ']'"); - reader = Json.createReader(new StringReader("[")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing { - - try { - logMsg("Testing for missing '{'"); - reader = Json.createReader(new StringReader("[1,\"name\":\"value\"}]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing } - - try { - logMsg("Testing for missing '}'"); - reader = Json.createReader(new StringReader("[1,{\"name\":\"value\"]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between array elements test case 1 - - try { - logMsg("Testing for missing ',' between array elements test case 1"); - reader = Json.createReader(new StringReader("[5\"foo\"]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between array elements test case 2 - - try { - logMsg("Testing for missing ',' between array elements test case 2"); - reader = Json.createReader(new StringReader("[5{}]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between object elements test case 1 - - try { - logMsg("Testing for missing ',' between object elements test case 1"); - reader = Json.createReader(new StringReader("[{\"foo\":\"bar\"5}]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between object elements test case 2 - - try { - logMsg("Testing for missing ',' between object elements test case 2"); - reader = Json.createReader(new StringReader("[{\"one\":1[]}]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing key name in object element - - try { - logMsg("Testing for missing key name in object element"); - reader = Json.createReader(new StringReader("[{:\"bar\"}]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing value name in object element - - try { - logMsg("Testing for missing value name in object element"); - reader = Json.createReader(new StringReader("[{\"foo\":}]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing double quote on a name - - try { - logMsg("Test for missing double quote on a name"); - reader = Json.createReader(new StringReader("[{name\" : \"value\"}]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing double quote on a value - - try { - logMsg("Test for missing double quote on a value"); - reader = Json.createReader(new StringReader("[{\"name\" : value\"}]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 1 - - try { - logMsg("Incorrect digit value -foo"); - reader = Json.createReader(new StringReader("[-foo]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 2 - - try { - logMsg("Incorrect digit value +foo"); - reader = Json.createReader(new StringReader("[+foo]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 3 - - try { - logMsg("Incorrect digit value -784foo"); - reader = Json.createReader(new StringReader("[-784foo]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 4 - - try { - logMsg("Incorrect digit value +784foo"); - reader = Json.createReader(new StringReader("[+784foo]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 5 - - try { - logMsg("Incorrect digit value 0.1E5E5"); - reader = Json.createReader(new StringReader("[0.1E5E5]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 6 - - try { - logMsg("Incorrect digit value 0.F10"); - reader = Json.createReader(new StringReader("[0.F10]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 7 - - try { - logMsg("Incorrect digit value string"); - reader = Json.createReader(new StringReader("[string]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 8 (hex numbers invalid per JSON RFC) - - try { - logMsg("Incorrect digit value hex numbers invalid per JSON RFC"); - reader = Json.createReader(new StringReader("[0x137a]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 9 (octal numbers invalid per JSON RFC) - - try { - logMsg("Incorrect digit value octal numbers invalid per JSON RFC"); - reader = Json.createReader(new StringReader("[0137]")); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - if (!pass) - throw new Fault("negativeArrayTests Failed"); - } - - /* - * @testName: illegalStateExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:218; - * JSONP:JAVADOC:220; JSONP:JAVADOC:183; - * - * @test_Strategy: Test IllegalStateException test conditions. - * - */ - public void illegalStateExceptionTests() throws Fault { - boolean pass = true; - JsonReader reader = null; - - // IllegalStateException if reader.close() called before reader.read() - try { - reader = Json.createReader(new StringReader("{}")); - reader.close(); - logMsg( - "Calling reader.read() after reader.close() is called is illegal."); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // IllegalStateException if reader.read() called after reader.readObject() - try { - reader = Json.createReader(new StringReader("{}")); - JsonObject value = reader.readObject(); - logMsg( - "Calling reader.readObject() after reader.readObject() was called is illegal."); - value = (JsonObject) reader.read(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // IllegalStateException if reader.read() called after reader.readArray() - try { - reader = Json.createReader(new StringReader("[]")); - JsonArray value = reader.readArray(); - logMsg( - "Calling reader.read() after reader.readArray() was called is illegal."); - value = (JsonArray) reader.read(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // IllegalStateException if reader.close() called before reader.readObject() - try { - reader = Json.createReader(new StringReader("{}")); - reader.close(); - logMsg( - "Calling reader.readObject() after reader.close() is called is illegal."); - JsonObject value = reader.readObject(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // IllegalStateException if reader.readObject() called after - // reader.readObject() - try { - reader = Json.createReader(new StringReader("{}")); - JsonObject value = reader.readObject(); - logMsg( - "Calling reader.readObject() after reader.readObject() was called is illegal."); - value = reader.readObject(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // IllegalStateException if reader.readArray() called after - // reader.readObject() - try { - reader = Json.createReader(new StringReader("{}")); - JsonObject obj = reader.readObject(); - logMsg( - "Calling reader.readArray() after reader.readObject() was called is illegal."); - JsonArray arr = reader.readArray(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // IllegalStateException if reader.close() called before reader.readArray() - try { - reader = Json.createReader(new StringReader("[]")); - reader.close(); - logMsg( - "Calling reader.readArray() after reader.close() is called is illegal."); - JsonArray value = reader.readArray(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // IllegalStateException if reader.readArray() called after - // reader.readArray() - try { - reader = Json.createReader(new StringReader("[]")); - JsonArray value = reader.readArray(); - logMsg( - "Calling reader.readArray() after reader.readArray() was called is illegal."); - value = reader.readArray(); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // IllegalStateException if reader.readObject() called after - // reader.readArray() - try { - reader = Json.createReader(new StringReader("[]")); - JsonArray arr = reader.readArray(); - logMsg( - "Calling reader.readObject() after reader.readArray() was called is illegal."); - JsonObject obj = reader.readObject(); - pass = false; - logMsg("obj=" + obj); - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - if (!pass) - throw new Fault("illegalStateExceptionTests Failed"); - } - - /* - * @testName: negativeJsonStructureTests - * - * @assertion_ids: JSONP:JAVADOC:96; JSONP:JAVADOC:97; JSONP:JAVADOC:411; - * - * @test_Strategy: Test various Json Syntax Errors when reading a - * JsonStructure. The tests trip various JsonParsingException conditions when - * doing a read. - * - */ - public void negativeJsonStructureTests() throws Fault { - boolean pass = true; - JsonReader reader = null; - - // Trip JsonParsingException for JsonReader.read() if incorrect - // representation for array - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if incorrect representation for array."); - logMsg("Reading " + "[foo,10,\"name\":\"value\"]"); - reader = Json - .createReader(new StringReader("[foo,10,\"name\":\"value\"]")); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonParsingException for JsonReader.read() if incorrect - // representation for object - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if incorrect representation for object."); - logMsg("Reading " + "{\"name\":\"value\",1,2,3}"); - reader = Json - .createReader(new StringReader("{\"name\":\"value\",1,2,3}")); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // incorrect representation {] - try { - logMsg("Testing for incorrect representation '{]'"); - reader = Json.createReader(new StringReader("{]")); - logMsg( - "Calling reader.read() with incorrect representation should throw JsonParsingException"); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Missing [ - - try { - logMsg("Testing for missing '['"); - reader = Json.createReader(new StringReader("{1,2]}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing ] - - try { - logMsg("Testing for missing ']'"); - reader = Json.createReader(new StringReader("{[1,2}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing { - - try { - logMsg("Testing for missing '{'"); - reader = Json.createReader(new StringReader("}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing } - - try { - logMsg("Testing for missing '}'"); - reader = Json.createReader(new StringReader("{")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between array elements test case 1 - - try { - logMsg("Testing for missing ',' between array elements test case 1"); - reader = Json.createReader(new StringReader("{[5\"foo\"]}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between array elements test case 2 - - try { - logMsg("Testing for missing ',' between array elements test case 2"); - reader = Json.createReader(new StringReader("{[5{}]}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between object elements test case 1 - - try { - logMsg("Testing for missing ',' between object elements test case 1"); - reader = Json.createReader(new StringReader("{\"foo\":\"bar\"5}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing , between object elements test case 2 - - try { - logMsg("Testing for missing ',' between object elements test case 2"); - reader = Json.createReader(new StringReader("{\"one\":1[]}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing key name in object element - - try { - logMsg("Testing for missing key name in object element"); - reader = Json.createReader(new StringReader("{:\"bar\"}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing value name in object element - - try { - logMsg("Testing for missing value name in object element"); - reader = Json.createReader(new StringReader("{\"foo\":}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing double quote on a name - - try { - logMsg("Test for missing double quote on a name"); - reader = Json.createReader(new StringReader("{name\" : \"value\"}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Missing double quote on a value - - try { - logMsg("Test for missing double quote on a value"); - reader = Json.createReader(new StringReader("{\"name\" : value\"}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 1 - - try { - logMsg("Incorrect digit value -foo"); - reader = Json.createReader(new StringReader("{\"number\" : -foo}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 2 - - try { - logMsg("Incorrect digit value +foo"); - reader = Json.createReader(new StringReader("{\"number\" : +foo}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 3 - - try { - logMsg("Incorrect digit value -784foo"); - reader = Json.createReader(new StringReader("{\"number\" : -784foo}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 4 - - try { - logMsg("Incorrect digit value +784foo"); - reader = Json.createReader(new StringReader("{\"number\" : +784foo}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 5 - - try { - logMsg("Incorrect digit value 0.1E5E5"); - reader = Json.createReader(new StringReader("{\"number\" : 0.1E5E5}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 6 - - try { - logMsg("Incorrect digit value 0.F10"); - reader = Json.createReader(new StringReader("{\"number\" : 0.F10}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - // Incorrect digit value test case 7 - - try { - logMsg("Incorrect digit value string"); - reader = Json.createReader(new StringReader("{\"number\" : string}")); - JsonStructure value = reader.read(); - pass = false; - logErr("Failed to throw JsonParsingException"); - } catch (JsonParsingException e) { - logMsg("Got expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (reader != null) - reader.close(); - } - - if (!pass) - throw new Fault("negativeJsonStructureTests Failed"); - } - - /* - * @testName: jsonReaderIOErrorTests - * - * @assertion_ids: JSONP:JAVADOC:182; JSONP:JAVADOC:217; JSONP:JAVADOC:219; - * JSONP:JAVADOC:410; - * - * @test_Strategy: Tests for JsonException for testable i/o errors. - * - */ - public void jsonReaderIOErrorTests() throws Fault { - boolean pass = true; - - String jsonArrayText = "[\"name1\",\"value1\"]"; - String jsonObjectText = "{\"name1\":\"value1\"}"; - - // Trip JsonException if there is an i/o error on JsonReader.close() - try { - logMsg( - "Trip JsonException if there is an i/o error on JsonReader.close()."); - logMsg("Reading object " + jsonObjectText); - InputStream is = JSONP_Util.getInputStreamFromString(jsonObjectText); - MyBufferedInputStream mbi = new MyBufferedInputStream(is); - try (JsonReader reader = Json.createReader(mbi)) { - JsonObject jsonObject = reader.readObject(); - logMsg("jsonObject=" + jsonObject); - mbi.setThrowIOException(true); - logMsg("Calling JsonReader.close()"); - mbi.setThrowIOException(true); - } - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException for JsonReader.read() if i/o error - try { - logMsg("Trip JsonException for JsonReader.read() if i/o error."); - logMsg("Reading array " + jsonArrayText); - MyBufferedReader mbr = new MyBufferedReader( - new StringReader(jsonArrayText)); - JsonReader reader = Json.createReader(mbr); - mbr.setThrowIOException(true); - logMsg("Calling JsonReader.read()"); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException for JsonReader.readArray() if i/o error - try { - logMsg("Trip JsonException for JsonReader.readArray() if i/o error."); - logMsg("Reading array " + jsonArrayText); - MyBufferedReader mbr = new MyBufferedReader( - new StringReader(jsonArrayText)); - JsonReader reader = Json.createReader(mbr); - mbr.setThrowIOException(true); - logMsg("Calling JsonReader.readArray()"); - JsonArray jsonArray = reader.readArray(); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException for JsonReader.readObject() if i/o error - try { - logMsg("Trip JsonException for JsonReader.read() if i/o error."); - logMsg("Reading object " + jsonObjectText); - MyBufferedReader mbr = new MyBufferedReader( - new StringReader(jsonObjectText)); - JsonReader reader = Json.createReader(mbr); - mbr.setThrowIOException(true); - logMsg("Calling JsonReader.readObject()"); - JsonObject jsonObject = reader.readObject(); - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonReaderIOErrorTests Failed"); - } - - /* - * @testName: invalidLiteralNamesTest - * - * @assertion_ids: JSONP:JAVADOC:97; JSONP:JAVADOC:411; - * - * @test_Strategy: This test trips various JsonParsingException conditions - * when reading an uppercase literal name that must be lowercase per JSON RFC - * for the literal values (true, false or null). - * - */ - public void invalidLiteralNamesTest() throws Fault { - boolean pass = true; - JsonReader reader; - - // Trip JsonParsingException for JsonReader.read() if invalid liternal TRUE - // instead of true - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if invalid liternal TRUE instead of true."); - logMsg("Reading " + "[TRUE]"); - reader = Json.createReader(new StringReader("[TRUE]")); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonParsingException for JsonReader.read() if invalid liternal FALSE - // instead of false - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if invalid liternal FALSE instead of false."); - logMsg("Reading " + "[FALSE]"); - reader = Json.createReader(new StringReader("[FALSE]")); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonParsingException for JsonReader.read() if invalid liternal NULL - // instead of null - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if invalid liternal NULL instead of null."); - logMsg("Reading " + "[NULL]"); - reader = Json.createReader(new StringReader("[NULL]")); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonParsingException for JsonReader.read() if invalid liternal TRUE - // instead of true - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if invalid liternal TRUE instead of true."); - logMsg("Reading " + "{\"true\":TRUE}"); - reader = Json.createReader(new StringReader("{\"true\":TRUE}")); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonParsingException for JsonReader.read() if invalid liternal FALSE - // instead of false - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if invalid liternal FALSE instead of false."); - logMsg("Reading " + "{\"false\":FALSE}"); - reader = Json.createReader(new StringReader("{\"false\":FALSE}")); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonParsingException for JsonReader.read() if invalid liternal NULL - // instead of null - try { - logMsg( - "Trip JsonParsingException for JsonReader.read() if invalid liternal NULL instead of null."); - logMsg("Reading " + "{\"null\":NULL}"); - reader = Json.createReader(new StringReader("{\"null\":NULL}")); - JsonStructure jsonStructure = reader.read(); - logErr("Did not get expected JsonParsingException"); - pass = false; - } catch (JsonParsingException e) { - logMsg("Caught expected JsonParsingException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("invalidLiteralNamesTest Failed"); - } - - /* - * @testName: jsonReader11Test - * - * @assertion_ids: JSONP:JAVADOC:646; JSONP:JAVADOC:583; JSONP:JAVADOC:584; - * JSONP:JAVADOC:585; JSONP:JAVADOC:586; JSONP:JAVADOC:587; JSONP:JAVADOC:588; - * JSONP:JAVADOC:662; JSONP:JAVADOC:663; JSONP:JAVADOC:664; JSONP:JAVADOC:665; - * JSONP:JAVADOC:666; JSONP:JAVADOC:667; - * - * @test_Strategy: Tests JsonReader API methods added in JSON-P 1.1. - */ - public void jsonReader11Test() throws Fault { - Reader readerTest = new Reader(); - final TestResult result = readerTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonreadertests/Reader.java b/src/com/sun/ts/tests/jsonp/api/jsonreadertests/Reader.java deleted file mode 100644 index 01dd649a94..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonreadertests/Reader.java +++ /dev/null @@ -1,248 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonreadertests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BDC_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BIN_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DBL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.LNG_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringReader; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.SimpleValues; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonException; -import jakarta.json.JsonReader; -import jakarta.json.JsonValue; -import jakarta.json.stream.JsonParsingException; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests for {@link JsonReader}. - */ -public class Reader { - - /** Tests input data. */ - private static final Object[] VALUES = new Object[] { OBJ_VALUE, // readValue() - // for - // JsonObject - createEmptyArrayWithStr(), // readValue() for simple JsonArray - STR_VALUE, // readValue() for String - INT_VALUE, // readValue() for int - LNG_VALUE, // readValue() for long - DBL_VALUE, // readValue() for double - BIN_VALUE, // readValue() for BigInteger - BDC_VALUE, // readValue() for BigDecimal - BOOL_VALUE, // readValue() for boolean - null // readValue() for null - }; - - /** - * Creates an instance of JavaScript Object Notation (JSON) compatibility - * tests for {@link JsonReader}. - */ - Reader() { - super(); - } - - /** - * {@link JsonReader} API methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonReader API methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonReader API methods added in JSON-P 1.1."); - testReadValue(result); - testDoubleReadValue(result); - testIOExceptionOnReadValue(result); - testReadInvalidValue(result); - return result; - } - - /** - * Test {@code JsonValue readValue()} method on all child types stored in - * source data. - * - * @param result - * Test suite result. - */ - private void testReadValue(final TestResult result) { - for (Object value : VALUES) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg(" - readValue() for " + typeName + " in source data"); - final JsonValue jsonValue = SimpleValues.toJsonValue(value); - final String data = JsonValueType.toStringValue(value); - TestUtil.logMsg(" - Data: " + data); - final StringReader strReader = new StringReader(data); - JsonValue outValue = null; - try (final JsonReader reader = Json.createReader(strReader)) { - outValue = reader.readValue(); - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("readValue()", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - if (operationFailed(jsonValue, outValue)) { - result.fail("readValue()", "Reader output " + valueToString(outValue) - + " value shall be " + valueToString(jsonValue)); - } - } - } - - /** - * Test {@code JsonValue readValue()} method with duplicated {@code JsonValue} - * read call. Second call is expected to throw {@code IllegalStateException} - * exception. - * - * @param result - * Test suite result. - */ - private void testDoubleReadValue(final TestResult result) { - for (Object value : VALUES) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg( - " - duplicate readValue() for " + typeName + " in source data"); - final String data = JsonValueType.toStringValue(value); - final StringReader strReader = new StringReader(data); - try (final JsonReader reader = Json.createReader(strReader)) { - // 1st attempt to read the data shall pass - reader.readValue(); - try { - // 2nd attempt to read the data shall throw IllegalStateException - reader.readValue(); - result.fail("readValue()", - "Duplicate call of readValue() shall throw IllegalStateException"); - } catch (IllegalStateException ex) { - TestUtil.logMsg(" - Expected exception: " + ex.getMessage()); - } catch (Throwable t) { - result.fail("readValue()", - "Duplicate call of readValue() shall throw IllegalStateException, not " - + t.getClass().getSimpleName()); - } - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("readValue()", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - } - } - - /** - * Test {@code JsonValue readValue()} method with read call that causes - * IOException. IOException shall be encapsulated in JsonException. - * - * @param result - * Test suite result. - */ - @SuppressWarnings("ConvertToTryWithResources") - private void testIOExceptionOnReadValue(final TestResult result) { - TestUtil.logMsg(" - readValue() from already closed file reader"); - File temp = null; - JsonReader reader; - // Close writer before calling write method. - try { - temp = File.createTempFile("testIOExceptionOnReadValue", ".txt"); - TestUtil.logMsg(" - Temporary file: " + temp.getAbsolutePath()); - try (final FileWriter fileWriter = new FileWriter(temp)) { - fileWriter.write(JsonValueType.toStringValue(DEF_VALUE)); - } - final FileReader fileReader = new FileReader(temp); - reader = Json.createReader(fileReader); - fileReader.close(); - } catch (IOException ex) { - TestUtil.logMsg("Caught IOException: " + ex.getLocalizedMessage()); - result.fail("write(JsonValue)", - "Caught IOException: " + ex.getLocalizedMessage()); - return; - } finally { - if (temp != null) { - temp.delete(); - } - } - try { - reader.readValue(); - result.fail("readValue()", - "Call of readValue() on already closed file reader shall throw JsonException"); - } catch (JsonException ex) { - TestUtil.logMsg(" - Expected exception: " + ex.getMessage()); - } catch (Throwable t) { - result.fail("readValue()", - "Call of readValue() on already closed file reader shall throw JsonException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Test {@code JsonValue readValue()} method with read call on invalid JSON - * data. JsonParsingException shall be thrown when reading invalid data. - * - * @param result - * Test suite result. - */ - private void testReadInvalidValue(final TestResult result) { - TestUtil.logMsg(" - readValue() on invalid JSON data"); - // Invalid JSON: starting an array, closing an object. - final String data = "[" + SimpleValues.toJsonValue(DEF_VALUE) + "}"; - final StringReader strReader = new StringReader(data); - JsonValue outValue = null; - try (final JsonReader reader = Json.createReader(strReader)) { - reader.readValue(); - result.fail("readValue()", - "Call of readValue() on invalid data shall throw JsonParsingException"); - } catch (JsonParsingException ex) { - TestUtil.logMsg(" - Expected exception: " + ex.getMessage()); - } catch (Throwable t) { - result.fail("readValue()", - "Call of readValue() on invalid data shall throw JsonParsingException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonreadertests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonreadertests/build.xml deleted file mode 100644 index e1dbd34595..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonreadertests/build.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonstreamingtests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonstreamingtests/Client.java deleted file mode 100644 index a4f93b7f99..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonstreamingtests/Client.java +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonstreamingtests; - -import java.io.ByteArrayOutputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonReader; -import jakarta.json.JsonWriter; -import jakarta.json.stream.JsonGenerator; -import jakarta.json.stream.JsonParser; - -public class Client extends ServiceEETest { - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* - * @testName: streamingTest1 - * - * @assertion_ids: JSONP:JAVADOC:97; JSONP:JAVADOC:106; JSONP:JAVADOC:107; - * JSONP:JAVADOC:184; - * - * @test_Strategy: Test Scenario: Generate stream of Json Text containing a - * JsonArray Compare actual Json Text generated with expected Json Text for - * equality Test passes if both JsonArray comparisons of Json Text are equal. - * - */ - public void streamingTest1() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - // Set expected result - String expJsonText = "[1,2,3,4,5,6,7,8,9,10]"; - logMsg("expJsonText=" + expJsonText); - - logMsg("Generate stream of Json Text containing a JsonArray"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write(1).write(2).write(3).write(4).write(5) - .write(6).write(7).write(8).write(9).write(10).writeEnd(); - generator.close(); - - // Get actual result - String actJsonText = JSONP_Util.removeWhitespace(sWriter.toString()); - logMsg("actJsonText=" + actJsonText); - - logMsg("Compare expJsonText and actJsonText for equality"); - pass = JSONP_Util.assertEqualsJsonText(expJsonText, actJsonText); - } catch (Exception e) { - throw new Fault("streamingTest1 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("streamingTest1 Failed"); - } - - /* - * @testName: streamingTest2 - * - * @assertion_ids: JSONP:JAVADOC:97; JSONP:JAVADOC:106; JSONP:JAVADOC:107; - * JSONP:JAVADOC:131; - * - * @test_Strategy: Test Scenario: Generate data containing a JsonArray to a - * Writer stream. Read data from Writer stream containing a JsonArray. Write - * JsonArray out to a Writer stream. Re-read data from Writer stream - * containing a JsonArray. Compare initial JsonArray with subsequent JsonArray - * for equality. Test passes if both JsonArrays are equal. - * - */ - public void streamingTest2() throws Fault { - boolean pass = true; - JsonReader reader = null; - try { - logMsg("Generate data containing a JsonArray"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartArray().write(2).write(4).write(6).write(8).write(10) - .writeEnd(); - generator.close(); - - logMsg("Read data from Writer stream containing a JsonArray"); - reader = Json.createReader(new StringReader(sWriter.toString())); - JsonArray expJsonArray = reader.readArray(); - - TestUtil.logMsg("Dump of expJsonArray"); - JSONP_Util.dumpJsonArray(expJsonArray); - - logMsg("Write JsonArray out to a Writer stream"); - sWriter = new StringWriter(); - JsonWriter writer = Json.createWriter(sWriter); - writer.writeArray(expJsonArray); - logMsg("Close JsonWriter"); - writer.close(); - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = sWriter.toString(); - logMsg("writerContents=" + writerContents); - - logMsg("Re-read data from Writer stream containing a JsonArray"); - reader = Json.createReader(new StringReader(writerContents)); - JsonArray actJsonArray = reader.readArray(); - - TestUtil.logMsg("Dump of actJsonArray"); - JSONP_Util.dumpJsonArray(actJsonArray); - - logMsg("Compare expJsonArray and actJsonArray for equality"); - pass = JSONP_Util.assertEqualsJsonArrays(expJsonArray, actJsonArray); - } catch (Exception e) { - throw new Fault("streamingTest2 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("streamingTest2 Failed"); - } - - /* - * @testName: streamingTest3 - * - * @assertion_ids: JSONP:JAVADOC:97; JSONP:JAVADOC:106; JSONP:JAVADOC:110; - * JSONP:JAVADOC:131; JSONP:JAVADOC:172; - * - * @test_Strategy: Test Scenario: Generate data containing a JsonObject to a - * Write stream. Read data from Writer stream containing a JsonObject. Write - * JsonObject out to a Writer stream. Parse data from Writer stream containing - * a JsonObject stream. Test passes if parsing JsonObject events are correct. - * - */ - public void streamingTest3() throws Fault { - boolean pass = true; - JsonReader reader = null; - JsonParser parser = null; - try { - logMsg("Generate data containing a JsonObject"); - StringWriter sWriter = new StringWriter(); - JsonGenerator generator = Json.createGenerator(sWriter); - generator.writeStartObject().write("two", 2).write("false", false) - .writeEnd(); - generator.close(); - - logMsg("Read data from Writer stream containing a JsonObject"); - reader = Json.createReader(new StringReader(sWriter.toString())); - JsonObject expJsonObject = reader.readObject(); - - TestUtil.logMsg("Dump of expJsonObject"); - JSONP_Util.dumpJsonObject(expJsonObject); - - logMsg("Write JsonObject out to a Writer stream"); - sWriter = new StringWriter(); - JsonWriter writer = Json.createWriter(sWriter); - writer.writeObject(expJsonObject); - logMsg("Close JsonWriter"); - writer.close(); - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = sWriter.toString(); - logMsg("writerContents=" + writerContents); - - logMsg("Parse data from Writer stream containing a JsonObject"); - parser = Json - .createParser(JSONP_Util.getInputStreamFromString((writerContents))); - - JSONP_Util.resetParseErrs(); - JSONP_Util.testEventType(parser, JsonParser.Event.START_OBJECT); - JSONP_Util.testKeyIntegerValue(parser, "two", 2); - JSONP_Util.testKeyFalseValue(parser, "false"); - JSONP_Util.testEventType(parser, JsonParser.Event.END_OBJECT); - int parseErrs = JSONP_Util.getParseErrs(); - if (parseErrs != 0) { - logErr("There were " + parseErrs + " parser errors that occurred."); - pass = false; - } - - } catch (Exception e) { - throw new Fault("streamingTest3 Failed: ", e); - } finally { - if (reader != null) - reader.close(); - } - if (!pass) - throw new Fault("streamingTest3 Failed"); - } - - /* - * @testName: streamingTest4 - * - * @assertion_ids: JSONP:JAVADOC:178; JSONP:JAVADOC:187; JSONP:JAVADOC:110; - * JSONP:JAVADOC:168; - * - * @test_Strategy: Test Scenario: Generate data containing a JsonObject to an - * OutputStream. Compare expected JSON text from what was generated. Read data - * from InputStream containing a JsonObject. Write JsonObject again out to an - * OutputStream. Compare again expected JSON text from what was generated. - * Test passes if JSON text comparisons are correct. - * - */ - public void streamingTest4() throws Fault { - boolean pass = true; - JsonReader reader = null; - JsonParser parser = null; - String expJsonText = "{\"two\":2,\"false\":false}"; - try { - logMsg("Generate data containing a JsonObject to an OutputStream"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonGenerator generator = Json.createGenerator(baos); - generator.writeStartObject().write("two", 2).write("false", false) - .writeEnd(); - baos.close(); - generator.close(); - - logMsg("Compare JSON text generated to what is expected."); - if (!JSONP_Util.assertEqualsJsonText(expJsonText, - JSONP_Util.removeWhitespace(baos.toString("UTF-8")))) - pass = false; - - logMsg("Read data from InputStream containing a JsonObject"); - reader = Json.createReader( - JSONP_Util.getInputStreamFromString(baos.toString("UTF-8"))); - JsonObject expJsonObject = reader.readObject(); - logMsg("Close JsonReader"); - reader.close(); - - TestUtil.logMsg("Dump of expJsonObject"); - JSONP_Util.dumpJsonObject(expJsonObject); - - logMsg("Write JsonObject back out to an OutputStream"); - baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriter(baos); - writer.writeObject(expJsonObject); - logMsg("Close JsonWriter"); - baos.close(); - writer.close(); - - logMsg("Save contents of the JsonWriter as a String"); - String writerContents = baos.toString("UTF-8"); - logMsg("writerContents=" + writerContents); - - logMsg("Compare again JSON text generated to what is expected."); - if (!JSONP_Util.assertEqualsJsonText(expJsonText, - JSONP_Util.removeWhitespace(writerContents))) - pass = false; - - } catch (Exception e) { - throw new Fault("streamingTest4 Failed: ", e); - } - - if (!pass) - throw new Fault("streamingTest4 Failed"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonstreamingtests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonstreamingtests/build.xml deleted file mode 100644 index 221a81bed1..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonstreamingtests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonstringtests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonstringtests/Client.java deleted file mode 100644 index 9d87e54cd6..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonstringtests/Client.java +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonstringtests; - -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.JsonString; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonStringEqualsTest - * - * @assertion_ids: JSONP:JAVADOC:254; - * - * @test_Strategy: Tests JsonString equals method. Create 2 equal JsonStrings - * and compare them for equality and expect true. Create 2 non-equal - * JsonStrings and compare them for equality and expect false. - */ - public void jsonStringEqualsTest() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonString 1 for testing"); - JsonString string1 = (JsonString) JSONP_Util - .createJsonString("Hello World"); - logMsg("string1=" + JSONP_Util.toStringJsonString(string1)); - - logMsg("Create sample JsonString 2 for testing"); - JsonString string2 = JSONP_Util.createJsonString("Hello World"); - logMsg("string2=" + JSONP_Util.toStringJsonString(string2)); - - logMsg( - "Call JsonString.equals() to compare 2 equal JsonStrings and expect true"); - if (string1.equals(string2)) { - logMsg("JsonStrings are equal - expected."); - } else { - pass = false; - logErr("JsonStrings are not equal - unexpected."); - } - - logMsg("Create sample JsonString 1 for testing"); - string1 = JSONP_Util.createJsonString("Hello World"); - logMsg("string1=" + JSONP_Util.toStringJsonString(string1)); - - logMsg("Create sample JsonString 2 for testing"); - string2 = JSONP_Util.createJsonString("Hello USA"); - logMsg("string2=" + JSONP_Util.toStringJsonString(string2)); - - logMsg( - "Call JsonString.equals() to compare 2 equal JsonStrings and expect false"); - if (!string1.equals(string2)) { - logMsg("JsonStrings are not equal - expected."); - } else { - pass = false; - logErr("JsonStrings are equal - unexpected."); - } - } catch (Exception e) { - throw new Fault("jsonStringEqualsTest Failed: ", e); - } - if (!pass) - throw new Fault("jsonStringEqualsTest Failed"); - } - - /* - * @testName: jsonStringHashCodeTest - * - * @assertion_ids: JSONP:JAVADOC:255; - * - * @test_Strategy: Tests JsonString equals method. Create 2 equal JsonStrings - * and compare them for hashcode and expect true. Create 2 non-equal - * JsonStrings and compare them for hashcode and expect false. - */ - public void jsonStringHashCodeTest() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonString 1 for testing"); - JsonString string1 = JSONP_Util.createJsonString("Hello World"); - logMsg("string1=" + JSONP_Util.toStringJsonString(string1)); - logMsg("string1.hashCode()=" + string1.hashCode()); - - logMsg("Create sample JsonString 2 for testing"); - JsonString string2 = JSONP_Util.createJsonString("Hello World"); - logMsg("string2=" + JSONP_Util.toStringJsonString(string2)); - logMsg("string2.hashCode()=" + string2.hashCode()); - - logMsg( - "Call JsonString.hashCode() to compare 2 equal JsonStrings and expect true"); - if (string1.hashCode() == string2.hashCode()) { - logMsg("JsonStrings hashCode are equal - expected."); - } else { - pass = false; - logErr("JsonStrings hashCode are not equal - unexpected."); - } - - logMsg("Create sample JsonString 1 for testing"); - string1 = JSONP_Util.createJsonString("Hello World"); - logMsg("string1=" + JSONP_Util.toStringJsonString(string1)); - logMsg("string1.hashCode()=" + string1.hashCode()); - - logMsg("Create sample JsonString 2 for testing"); - string2 = JSONP_Util.createJsonString("Hello USA"); - logMsg("string2=" + JSONP_Util.toStringJsonString(string2)); - logMsg("string2.hashCode()=" + string2.hashCode()); - - logMsg( - "Call JsonString.hashCode() to compare 2 equal JsonStrings and expect false"); - if (string1.hashCode() != string2.hashCode()) { - logMsg("JsonStrings hashCode are not equal - expected."); - } else { - pass = false; - logErr("JsonStrings hashCode are equal - unexpected."); - } - } catch (Exception e) { - throw new Fault("jsonStringHashCodeTest Failed: ", e); - } - if (!pass) - throw new Fault("jsonStringHashCodeTest Failed"); - } - - /* - * @testName: jsonStringGetCharsTest - * - * @assertion_ids: JSONP:JAVADOC:383; - * - * @test_Strategy: Tests JsonString getChars method. - */ - public void jsonStringGetCharsTest() throws Fault { - boolean pass = true; - String helloWorld = "Hello World"; - - try { - logMsg("Create sample JsonString for testing"); - JsonString string = JSONP_Util.createJsonString(helloWorld); - logMsg("string=" + JSONP_Util.toStringJsonString(string)); - - logMsg( - "Call JsonString.getChars() to return the char sequence for the JSON string"); - CharSequence cs = string.getChars(); - logMsg("charSequence=" + cs.toString()); - - logMsg("Checking char sequence for equality to expected string contents"); - if (!JSONP_Util.assertEquals(helloWorld, cs.toString())) - pass = false; - - logMsg("Checking char sequence for expected equality to string length"); - if (!JSONP_Util.assertEquals(helloWorld.length(), cs.length())) - pass = false; - } catch (Exception e) { - throw new Fault("jsonStringGetCharsTest Failed: ", e); - } - if (!pass) - throw new Fault("jsonStringGetCharsTest Failed"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonstringtests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonstringtests/build.xml deleted file mode 100644 index 94e3293798..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonstringtests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Client.java deleted file mode 100644 index be76b9c6ea..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Client.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonvaluetests; - -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.JsonValue; - -public class Client extends ServiceEETest { - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonValueTypesTest - * - * @assertion_ids: JSONP:JAVADOC:102; - * - * @test_Strategy: Test JsonValue.getValueType() API method call with all - * JsonValue types. - * - */ - public void jsonValueTypesTest() throws Fault { - boolean pass = true; - try { - - JsonValue.ValueType valueType; - - // Testing JsonValue.FALSE case - logMsg("Testing getValueType for JsonValue.FALSE value"); - valueType = JsonValue.FALSE.getValueType(); - if (valueType != JsonValue.ValueType.FALSE) { - logErr("Expected JSON FALSE value type but got instead " + valueType); - pass = false; - } else - logMsg("Got expected value type for JSON FALSE value"); - - // Testing JsonValue.TRUE case - logMsg("Testing getValueType for JsonValue.TRUE value"); - valueType = JsonValue.TRUE.getValueType(); - if (valueType != JsonValue.ValueType.TRUE) { - logErr("Expected JSON TRUE value type but got instead " + valueType); - pass = false; - } else - logMsg("Got expected value type for JSON TRUE value"); - - // Testing JsonValue.NULL case - logMsg("Testing getValueType for JsonValue.NULL value"); - valueType = JsonValue.NULL.getValueType(); - if (valueType != JsonValue.ValueType.NULL) { - logErr("Expected JSON NULL value type but got instead " + valueType); - pass = false; - } else - logMsg("Got expected value type for JSON NULL value"); - - // Testing JsonValue.String case - logMsg("Testing getValueType for JsonValue.String value"); - valueType = JSONP_Util.createJsonString("string").getValueType(); - if (valueType != JsonValue.ValueType.STRING) { - logErr("Expected JSON STRING value type but got instead " + valueType); - pass = false; - } else - logMsg("Got expected value type for JSON STRING value"); - - // Testing JsonValue.Number case - logMsg("Testing getValueType for JsonValue.Number value"); - valueType = JSONP_Util.createJsonNumber(Integer.MAX_VALUE).getValueType(); - if (valueType != JsonValue.ValueType.NUMBER) { - logErr("Expected JSON NUMBER value type but got instead " + valueType); - pass = false; - } else - logMsg("Got expected value type for JSON NUMBER value"); - - // Testing JsonValue.Array case - logMsg("Testing getValueType for JsonValue.Array value"); - valueType = JSONP_Util.createJsonArrayFromString("[]").getValueType(); - if (valueType != JsonValue.ValueType.ARRAY) { - logErr("Expected JSON ARRAY value type but got instead " + valueType); - pass = false; - } else - logMsg("Got expected value type for JSON ARRAY value"); - - // Testing JsonValue.Object case - logMsg("Testing getValueType for JsonValue.Object value"); - valueType = JSONP_Util.createJsonObjectFromString("{}").getValueType(); - if (valueType != JsonValue.ValueType.OBJECT) { - logErr("Expected JSON OBJECT value type but got instead " + valueType); - pass = false; - } else - logMsg("Got expected value type for JSON OBJECT value"); - - } catch (Exception e) { - throw new Fault("jsonValueTypesTest Failed: ", e); - } - if (!pass) - throw new Fault("jsonValueTypesTest Failed"); - } - - /* - * @testName: jsonValueOfTest - * - * @assertion_ids: JSONP:JAVADOC:103; - * - * @test_Strategy: Test JsonValue.ValueType.valueOf() API method call with all - * JsonValue types. - * - */ - public void jsonValueOfTest() throws Fault { - boolean pass = true; - - String valueTypeStrings[] = { "ARRAY", "FALSE", "NULL", "NUMBER", "OBJECT", - "STRING", "TRUE" }; - - for (String valueTypeString : valueTypeStrings) { - JsonValue.ValueType valueType; - try { - logMsg( - "Testing enum value for string constant name " + valueTypeString); - valueType = JsonValue.ValueType.valueOf(valueTypeString); - logMsg("Got enum type " + valueType + " for enum string constant named " - + valueTypeString); - } catch (Exception e) { - logErr("Caught unexpected exception: " + e); - pass = false; - } - - } - - logMsg("Testing negative test case for NullPointerException"); - try { - JsonValue.ValueType.valueOf(null); - logErr("did not get expected NullPointerException"); - pass = false; - } catch (NullPointerException e) { - logMsg("Got expected NullPointerException"); - } catch (Exception e) { - logErr("Got unexpected exception " + e); - pass = false; - } - - logMsg("Testing negative test case for IllegalArgumentException"); - try { - JsonValue.ValueType.valueOf("INVALID"); - logErr("did not get expected IllegalArgumentException"); - pass = false; - } catch (IllegalArgumentException e) { - logMsg("Got expected IllegalArgumentException"); - } catch (Exception e) { - logErr("Got unexpected exception " + e); - pass = false; - } - - if (!pass) - throw new Fault("jsonValueOfTest Failed"); - } - - /* - * @testName: jsonValuesTest - * - * @assertion_ids: JSONP:JAVADOC:104; - * - * @test_Strategy: Test JsonValue.ValueType.values() API method call and - * verify enums returned. - * - */ - public void jsonValuesTest() throws Fault { - boolean pass = true; - - logMsg( - "Testing API method JsonValue.ValueType.values() to return array of enums."); - JsonValue.ValueType[] values = JsonValue.ValueType.values(); - - for (JsonValue.ValueType valueType : values) { - String valueString = JSONP_Util.getValueTypeString(valueType); - if (valueString == null) { - logErr("Got no value for enum " + valueType); - pass = false; - } else - logMsg("Got " + valueString + " for enum " + valueType); - } - - if (!pass) - throw new Fault("jsonValuesTest Failed"); - } - - /* - * @testName: jsonValueToStringTest - * - * @assertion_ids: JSONP:JAVADOC:288; - * - * @test_Strategy: Test JsonValue.toString() API method call with various - * JsonValue types. - * - */ - public void jsonValueToStringTest() throws Fault { - boolean pass = true; - try { - String stringValue; - JsonValue jsonValue; - - // Testing JsonValue.FALSE case - logMsg("Testing JsonValue.toString() for JsonValue.FALSE value"); - stringValue = JsonValue.FALSE.toString(); - logMsg("stringValue=" + stringValue); - if (!stringValue.equals("false")) { - logErr("Expected false"); - pass = false; - } else { - logMsg("Got " + stringValue); - } - - // Testing JsonValue.TRUE case - logMsg("Testing JsonValue.toString() for JsonValue.TRUE value"); - stringValue = JsonValue.TRUE.toString(); - logMsg("stringValue=" + stringValue); - if (!stringValue.equals("true")) { - logErr("Expected true"); - pass = false; - } else { - logMsg("Got " + stringValue); - } - - // Testing JsonValue.NULL case - logMsg("Testing JsonValue.toString() for JsonValue.NULL value"); - stringValue = JsonValue.NULL.toString(); - logMsg("stringValue=" + stringValue); - if (!stringValue.equals("null")) { - logErr("Expected null"); - pass = false; - } else { - logMsg("Got " + stringValue); - } - - // Testing JsonString case - logMsg("Testing JsonValue.toString() for JsonString value"); - jsonValue = JSONP_Util.createJsonString("string"); - stringValue = jsonValue.toString(); - logMsg("stringValue=" + stringValue); - if (!stringValue.equals("\"string\"")) { - logErr("Expected \"string\""); - pass = false; - } else { - logMsg("Got " + stringValue); - } - - // Testing JsonNumber case - logMsg("Testing JsonValue.toString() for JsonNumber value"); - jsonValue = JSONP_Util.createJsonNumber(10); - stringValue = jsonValue.toString(); - logMsg("stringValue=" + stringValue); - if (!stringValue.equals("10")) { - logErr("Expected 10"); - pass = false; - } else { - logMsg("Got " + stringValue); - } - - // Testing JsonArray case - logMsg("Testing JsonValue.toString() for JsonArray value"); - jsonValue = JSONP_Util.createJsonArrayFromString("[]"); - stringValue = jsonValue.toString(); - logMsg("stringValue=" + stringValue); - if (!stringValue.equals("[]")) { - logErr("Expected []"); - pass = false; - } else { - logMsg("Got " + stringValue); - } - - // Testing JsonObject case - logMsg("Testing JsonValue.toString() for JsonObject value"); - jsonValue = JSONP_Util.createJsonObjectFromString("{}"); - stringValue = jsonValue.toString(); - logMsg("stringValue=" + stringValue); - if (!stringValue.equals("{}")) { - logErr("Expected {}"); - pass = false; - } else { - logMsg("Got " + stringValue); - } - - } catch (Exception e) { - throw new Fault("jsonValueToStringTest Failed: ", e); - } - if (!pass) - throw new Fault("jsonValueToStringTest Failed"); - } - - /* - * @testName: jsonValue11Test - * - * @assertion_ids: JSONP:JAVADOC:648; JSONP:JAVADOC:649; - * - * @test_Strategy: Tests JsonValue API methods added in JSON-P 1.1. - */ - public void jsonValue11Test() throws Fault { - Value valueTest = new Value(); - final TestResult result = valueTest.test(); - result.eval(); - } - - /* - * @testName: jsonStructure11Test - * - * @assertion_ids: JSONP:JAVADOC:647; - * - * @test_Strategy: Tests JsonStructure API methods added in JSON-P 1.1. - */ - public void jsonStructure11Test() throws Fault { - Structure structTest = new Structure(); - final TestResult result = structTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Structure.java b/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Structure.java deleted file mode 100644 index daa85eb9ed..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Structure.java +++ /dev/null @@ -1,542 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonvaluetests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_KEY10; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_KEY10_ENC; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_KEY_WHOLE; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR1; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR10; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR11_ENC; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR1_ITEM1; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR1_ITEM2; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR2; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR3; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR3_ENC; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR4; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR5; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR6; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR7; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR8; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR9; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL1; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL10; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL11; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL1_ITEM1; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL1_ITEM2; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL2; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL3; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL4; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL5; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL6; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL7; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL8; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL9; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.createRFC6901Object; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_FALSE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_TRUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.toJsonValue; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonStructure; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests for - * {@link JsonStructure}. RFC 6901 JSON Pointer is being passed to - * {@code JsonValue getValue(String)} method so whole JSON Pointer resolving - * sample is being used to test this method. - */ -public class Structure { - /** - * Creates an instance of JavaScript Object Notation (JSON) compatibility - * tests for {@link JsonStructure}. - */ - Structure() { - super(); - } - - /** - * {@link JsonStructure} API methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonStructure API methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonStructure API methods added in JSON-P 1.1."); - testResolveWholeDocument(result); - testResolveEmptyName(result); - testResolveSimpleArray(result); - testResolveSimpleArrayItems(result); - testResolvePathWithEncodedSlash(result); - testResolvePathWithSlash(result); - testResolvePathWithPercent(result); - testResolvePathWithCaret(result); - testResolvePathWithVerticalBar(result); - testResolvePathWithBackSlash(result); - testResolvePathWithDoubleQuotes(result); - testResolvePathWithSpace(result); - testResolvePathWithTilde(result); - testResolvePathWithEncodedTilde(result); - testResolvePathWithEncodedTildeOne(result); - testResolveValidNumericIndexInArray(result); - testResolveMemberAfterLastInArray(result); - testResolveNonNumericIndexInArray(result); - return result; - } - - /** - * Test RFC 6901 JSON Pointer resolving for the whole document path using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolveWholeDocument(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = value; - verifyGetValue(result, check, value, RFC_KEY_WHOLE); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "": 0} using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolveEmptyName(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL2); - verifyGetValue(result, check, value, RFC_PTR2); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "foo": ["bar", "baz"]} using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolveSimpleArray(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = RFC_VAL1; - verifyGetValue(result, check, value, RFC_PTR1); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "foo": ["bar", "baz"]} array - * elements using {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolveSimpleArrayItems(final TestResult result) { - final String[] itemPtrs = new String[] { RFC_PTR1_ITEM1, RFC_PTR1_ITEM2 }; - final String[] itemVals = new String[] { RFC_VAL1_ITEM1, RFC_VAL1_ITEM2 }; - final JsonObject value = createRFC6901Object(); - for (int i = 0; i < itemPtrs.length; i++) { - final JsonValue check = Json.createValue(itemVals[i]); - verifyGetValue(result, check, value, itemPtrs[i]); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "a/b": 1} using - * {@code JsonValue getValue(String)}. Character {@code '/'} is encoded as - * {@code "~1"} string. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithEncodedSlash(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL3); - verifyGetValue(result, check, value, RFC_PTR3_ENC); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "a/b": 1} using - * {@code JsonValue getValue(String)}. Character {@code '/'} is not encoded as - * {@code "~1"} string. This results in invalid {@code "/a/b"} path and - * resolving such path must throw an exception. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithSlash(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - verifyGetValueFail(result, value, RFC_PTR3); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "c%d": 2} using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithPercent(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL4); - verifyGetValue(result, check, value, RFC_PTR4); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "e^f": 3} using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithCaret(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL5); - verifyGetValue(result, check, value, RFC_PTR5); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "g|h": 4} using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithVerticalBar(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL6); - verifyGetValue(result, check, value, RFC_PTR6); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "i\\j": 5} using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithBackSlash(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL7); - verifyGetValue(result, check, value, RFC_PTR7); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "k\"l": 6} using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithDoubleQuotes(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL8); - verifyGetValue(result, check, value, RFC_PTR8); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code " ": 7} using - * {@code JsonValue getValue(String)}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithSpace(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL9); - verifyGetValue(result, check, value, RFC_PTR9); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "m~n": 8} without encoding - * using {@code JsonValue getValue(String)}. Passing this test is not - * mandatory. - * {@see RFC 6901: 3. - * Syntax} defines JSON pointer grammar as:
- * {@code json-pointer = *( "/" reference-token )}
- * {@code reference-token = *( unescaped / escaped )}
- * {@code unescaped = %x00-2E / %x30-7D / %x7F-10FFFF}
- * {@code escaped = "~" ( "0" / "1" )}
- * Characters {@code '/'} and {@code '~'} are excluded from {@code unescaped}. - * But having {@code '~'} outside escape sequence may be acceptable. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithTilde(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR10 + "\" pointer (optional)"); - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL10); - boolean noError = true; - try { - final JsonValue out = value.getValue(RFC_PTR10); - if (operationFailed(check, out)) { - noError = false; - TestUtil.logMsg(" - Pointer \"" + RFC_KEY10 - + "\" did not return expected value"); - } - } catch (JsonException e) { - noError = false; - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } - if (noError) { - TestUtil.logMsg( - " - Pointer resolving accepts '~' outside escape sequence"); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "m~n": 8} using - * {@code JsonValue getValue(String)}. Character {@code '~'} is encoded as - * {@code "~0"} string. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithEncodedTilde(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL10); - verifyGetValue(result, check, value, RFC_KEY10_ENC); - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "o~1p": 9} using - * {@code JsonValue getValue(String)}. String {@code "~1"} is encoded as - * {@code "~01"} String. Proper encoded sequences transformation is described - * in chapter: - * {@code "the string '~01' correctly becomes '~1' after transformation"}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithEncodedTildeOne(final TestResult result) { - final JsonStructure value = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL11); - verifyGetValue(result, check, value, RFC_PTR11_ENC); - } - - /** - * Test RFC 6901 JSON Pointer resolver for existing numeric indexes of an - * array. {@see RFC - * 6901: 4. Evaluation} chapter:
- * If the currently referenced value is a JSON array, the reference token MUST - * contain either: - *
    - *
  • characters comprised of digits (see ABNF below; note that leading zeros - * are not allowed) that represent an unsigned base-10 integer value, making - * the new referenced value the array element with the zero-based index - * identified by the token
  • - *
- */ - private void testResolveValidNumericIndexInArray(final TestResult result) { - TestUtil.logMsg( - " - getValue(String) resolving of pointer containing existing numeric array index"); - final JsonArray[] arraysIn = new JsonArray[] { createSimpleStringArray5(), - createSimpleIntArray5(), createSimpleBoolArray5(), - createSimpleObjectArray5() }; - final JsonValue[] strings = new JsonValue[] { toJsonValue(STR_VALUE_1), - toJsonValue(STR_VALUE_2), toJsonValue(STR_VALUE_3), - toJsonValue(STR_VALUE_4), toJsonValue(STR_VALUE_5) }; - final JsonValue[] ints = new JsonValue[] { toJsonValue(INT_VALUE_1), - toJsonValue(INT_VALUE_2), toJsonValue(INT_VALUE_3), - toJsonValue(INT_VALUE_4), toJsonValue(INT_VALUE_5) }; - final JsonValue[] bools = new JsonValue[] { toJsonValue(BOOL_FALSE), - toJsonValue(BOOL_TRUE), toJsonValue(BOOL_TRUE), toJsonValue(BOOL_FALSE), - toJsonValue(BOOL_TRUE) }; - final JsonValue[] objs = new JsonValue[] { OBJ_VALUE_1, OBJ_VALUE_2, - OBJ_VALUE_3, OBJ_VALUE_4, OBJ_VALUE_5 }; - final JsonValue[][] checks = new JsonValue[][] { strings, ints, bools, - objs }; - // Go trough all array types - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all valid indexes in arrays - for (int j = 0; j < 5; j++) { - final String path = "/" + Integer.toString(j); - try { - final JsonValue out = arraysIn[i].getValue(path); - if (operationFailed(checks[i][j], out)) { - result.fail("getValue(String)", "Failed for \"" + path + "\" path"); - } - } catch (JsonException e) { - result.fail("getValue(String)", "Exception: " + e.getMessage()); - } - } - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for character {@code '-'} marking the - * end of an array. - * {@see RFC 6901: 4. - * Evaluation} chapter:
- * If the currently referenced value is a JSON array, the reference token MUST - * contain either: - *
    - *
  • exactly the single character "-", making the new referenced value the - * (nonexistent) member after the last array element
  • - *
- * Note that the use of the "-" character to index an array will always result - * in such an error condition because by definition it refers to a nonexistent - * array element. Thus, applications of JSON Pointer need to specify how that - * character is to be handled, if it is to be useful. - */ - private void testResolveMemberAfterLastInArray(final TestResult result) { - TestUtil.logMsg(" - getValue(String) resolving of array \"/-\" pointer"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray(), createSimpleIntArray5(), createBoolArray2(), - createSimpleObjectArray5() }; - for (int i = 0; i < arraysIn.length; i++) { - try { - arraysIn[i].getValue("/-"); - result.fail("getValue(String)", "Call of getValue(String) on \"" + "/-" - + "\" shall throw JsonException"); - } catch (JsonException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for invalid index containing non - * numeric characters on array. - * {@see RFC 6901: 4. - * Evaluation} chapter:
- * {@code array-index = %x30 / ( %x31-39 *(%x30-39) )} grammar rule prohibits - * indexes with anything else than sequence of digits. Index {@code '-'} is - * being checked in another tests. The only exception is path for whole - * document ({@code ""}) which must return the whole array. - */ - private void testResolveNonNumericIndexInArray(final TestResult result) { - TestUtil.logMsg( - " - getValue(String) resolving of pointer containing non numeric array index"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray(), createSimpleIntArray5(), createBoolArray2(), - createSimpleObjectArray5() }; - final String[] typeNames = new String[] { "empty", "String", "int", - "boolean", "JsonObject" }; - final String wholeDocument = ""; - final String[] paths = new String[] { "/", "/1a", "/b4", "/name" }; - // Go trough all array types - for (int i = 0; i < arraysIn.length; i++) { - try { - final JsonValue wholeOut = arraysIn[i].getValue(wholeDocument); - if (operationFailed(wholeOut, arraysIn[i])) { - result.fail("getValue(String)", "Failed for \"" + wholeDocument - + "\" path on " + typeNames[i] + " array"); - } - } catch (JsonException e) { - result.fail("getValue(String)", "Failed for \"" + wholeDocument - + "\" path on " + typeNames[i] + " array: " + e.getMessage()); - } - for (int j = 0; j < paths.length; j++) { - try { - final JsonValue out = arraysIn[i].getValue(paths[j]); - result.fail("getValue(String)", "Succeeded for \"" + paths[j] - + "\" path on " + typeNames[i] + " array"); - } catch (JsonException e) { - // There are too many combinations to log them. - } - } - } - } - - /** - * Test helper: Verify {@code JsonValue getValue(String)} for given JSON path. - * - * @param result - * Tests result record. - */ - private void verifyGetValue(final TestResult result, final JsonValue check, - final JsonStructure value, final String path) { - TestUtil - .logMsg(" - getValue(String) resolving of \"" + path + "\" pointer"); - try { - final JsonValue out = value.getValue(path); - if (operationFailed(check, out)) { - result.fail("getValue(String)", "Failed for \"" + path + "\" path"); - } - } catch (JsonException e) { - result.fail("getValue(String)", "Exception: " + e.getMessage()); - } - } - - /** - * Test helper: Verify {@code JsonValue getValue(String)} for given JSON path. - * - * @param result - * Tests result record. - */ - private void verifyGetValueFail(final TestResult result, - final JsonStructure value, final String path) { - TestUtil.logMsg( - " - getValue(String) resolving of invalid \"" + path + "\" pointer"); - try { - value.getValue(path); - result.fail("getValue(String)", "Call of getValue(String) on \"" + path - + "\" shall throw JsonException"); - } catch (JsonException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Value.java b/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Value.java deleted file mode 100644 index a9f574c248..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/Value.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonvaluetests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BDC_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BIN_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DBL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.LNG_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.toJsonValue; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests for {@link JsonValue}. - */ -public class Value { - - /** - * Creates an instance of JavaScript Object Notation (JSON) compatibility - * tests for {@link JsonValue}. - */ - Value() { - super(); - } - - /** - * {@link JsonValue} API methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonValue API methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonValue API methods added in JSON-P 1.1."); - testAsJsonObject(result); - testAsJsonObjectOnNonObject(result); - testAsJsonArray(result); - testAsJsonArrayOnNonArray(result); - return result; - } - - /** - * Test {@code JsonObject asJsonObject()} method on {@code JsonObject} - * instances. - * - * @param result - * Test suite result. - */ - private void testAsJsonObject(final TestResult result) { - TestUtil.logMsg(" - asJsonObject() on JsonObject instances"); - final JsonObject[] values = { createEmptyObject(), createSimpleObjectStr(), - createSimpleObjectInt(), createSimpleObjectBool(), - createSimpleObjectObject(), createCompoundObject() }; - for (final JsonObject objValue : values) { - final JsonValue value = objValue; - final JsonObject out = objValue.asJsonObject(); - if (operationFailed(objValue, out)) { - result.fail("asJsonObject()", "Output " + valueToString(out) - + " value shall be " + valueToString(objValue)); - } - } - } - - /** - * Test {@code JsonObject asJsonObject()} method on non {@code JsonObject} - * instances. - * - * @param result - * Test suite result. - */ - private void testAsJsonObjectOnNonObject(final TestResult result) { - TestUtil.logMsg(" - asJsonObject() on non JsonObject instances"); - final JsonValue[] values = { createEmptyArrayWithStr(), - createEmptyArrayWithInt(), createEmptyArrayWithBool(), - createEmptyArrayWithObject(), toJsonValue(STR_VALUE), - toJsonValue(INT_VALUE), toJsonValue(LNG_VALUE), toJsonValue(DBL_VALUE), - toJsonValue(BIN_VALUE), toJsonValue(BDC_VALUE), toJsonValue(BOOL_VALUE), - toJsonValue(null) }; - for (final JsonValue value : values) { - try { - value.asJsonObject(); - result.fail("asJsonObject()", - "Call of asJsonObject() on non JsonObject instance shall throw ClassCastException"); - } catch (ClassCastException ex) { - TestUtil.logMsg(" - Expected exception: " + ex.getMessage()); - } catch (Throwable t) { - result.fail("asJsonObject()", - "Call of asJsonObject() on non JsonObject instance shall throw ClassCastException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Test {@code JsonObject asJsonArray()} method on {@code JsonArray} - * instances. - * - * @param result - * Test suite result. - */ - private void testAsJsonArray(final TestResult result) { - TestUtil.logMsg(" - asJsonArray() on JsonArray instances"); - final JsonArray[] values = { createEmptyArray(), createEmptyArrayWithStr(), - createEmptyArrayWithInt(), createEmptyArrayWithBool(), - createEmptyArrayWithObject(), createSimpleStringArray5(), - createSimpleIntArray5(), createSimpleBoolArray5(), - createSimpleObjectArray5() }; - for (final JsonArray objValue : values) { - final JsonValue value = objValue; - final JsonArray out = objValue.asJsonArray(); - if (operationFailed(objValue, out)) { - result.fail("asJsonArray()", "Output " + valueToString(out) - + " value shall be " + valueToString(objValue)); - } - } - } - - /** - * Test {@code JsonObject asJsonArray()} method on non {@code JsonArray} - * instances. - * - * @param result - * Test suite result. - */ - private void testAsJsonArrayOnNonArray(final TestResult result) { - TestUtil.logMsg(" - asJsonArray() on non JsonArray instances"); - final JsonValue[] values = { createSimpleObjectStr(), - createSimpleObjectInt(), createSimpleObjectBool(), - createSimpleObjectObject(), createCompoundObject(), - toJsonValue(STR_VALUE), toJsonValue(INT_VALUE), toJsonValue(LNG_VALUE), - toJsonValue(DBL_VALUE), toJsonValue(BIN_VALUE), toJsonValue(BDC_VALUE), - toJsonValue(BOOL_VALUE), toJsonValue(null) }; - for (final JsonValue value : values) { - try { - value.asJsonArray(); - result.fail("asJsonArray()", - "Call of asJsonArray() on non JsonArray instance shall throw ClassCastException"); - } catch (ClassCastException ex) { - TestUtil.logMsg(" - Expected exception: " + ex.getMessage()); - } catch (Throwable t) { - result.fail("asJsonArray()", - "Call of asJsonArray() on non JsonArray instance shall throw ClassCastException, not " - + t.getClass().getSimpleName()); - } - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/build.xml deleted file mode 100644 index 232b01eb41..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonvaluetests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonwriterfactorytests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonwriterfactorytests/Client.java deleted file mode 100644 index ed0e3c7616..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonwriterfactorytests/Client.java +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ -package com.sun.ts.tests.jsonp.api.jsonwriterfactorytests; - -import java.io.ByteArrayOutputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.io.Writer; -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.tests.jsonp.common.JSONP_Util; - -import jakarta.json.Json; -import jakarta.json.JsonObject; -import jakarta.json.JsonWriter; -import jakarta.json.JsonWriterFactory; -import jakarta.json.stream.JsonGenerator; - -public class Client extends ServiceEETest { - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonWriterFactoryTest1 - * - * @assertion_ids: JSONP:JAVADOC:110; JSONP:JAVADOC:414; JSONP:JAVADOC:422; - * JSONP:JAVADOC:452; JSONP:JAVADOC:463; - * - * @test_Strategy: Tests the JsonWriterFactory API. - * - * JsonWriterFactory writerFactory = Json.createWriterFactory(Map); - * JsonWriter writer1 = writerFactory.createWriter(Writer) JsonWriter writer2 - * = writerFactory.createWriter(Writer) - */ - public void jsonWriterFactoryTest1() throws Fault { - boolean pass = true; - JsonWriter writer1 = null; - JsonWriter writer2 = null; - String expString = "{}"; - String actString; - JsonObject jsonObject = Json.createReader(new StringReader(expString)) - .readObject(); - try { - logMsg("Create JsonWriterFactory with Map with EMPTY config"); - JsonWriterFactory writerFactory = Json - .createWriterFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = writerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - logMsg("--------------------------------------------------"); - logMsg("TEST CASE [JsonWriterFactory.createWriter(Writer)]"); - logMsg("--------------------------------------------------"); - logMsg("Create 1st JsonWriter using JsonWriterFactory"); - Writer sWriter1 = new StringWriter(); - writer1 = writerFactory.createWriter(sWriter1); - if (writer1 == null) { - logErr("WriterFactory failed to create writer1"); - pass = false; - } else { - writer1.writeObject(jsonObject); - writer1.close(); - } - logMsg("sWriter1=" + sWriter1.toString()); - actString = JSONP_Util.removeWhitespace(sWriter1.toString()); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - logMsg("Create 2nd JsonWriter using JsonWriterFactory"); - Writer sWriter2 = new StringWriter(); - writer2 = writerFactory.createWriter(sWriter2); - if (writer2 == null) { - logErr("WriterFactory failed to create writer2"); - pass = false; - } else { - writer2.writeObject(jsonObject); - writer2.close(); - } - logMsg("sWriter2=" + sWriter2.toString()); - actString = JSONP_Util.removeWhitespace(sWriter2.toString()); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonWriterFactoryTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterFactoryTest1 Failed"); - } - - /* - * @testName: jsonWriterFactoryTest2 - * - * @assertion_ids: JSONP:JAVADOC:110; JSONP:JAVADOC:414; JSONP:JAVADOC:424; - * JSONP:JAVADOC:452; JSONP:JAVADOC:463; - * - * @test_Strategy: Tests the JsonWriterFactory API. - * - * JsonWriterFactory writerFactory = Json.createWriterFactory(Map); - * JsonWriter writer1 = writerFactory.createWriter(OutputStream, Charset) - * JsonWriter writer2 = writerFactory.createWriter(OutputStream, Charset) - * - * Create writer with both UTF-8 and UTF-16BE. - */ - public void jsonWriterFactoryTest2() throws Fault { - boolean pass = true; - JsonWriter writer1 = null; - JsonWriter writer2 = null; - String expString = "{}"; - String actString; - JsonObject jsonObject = Json.createReader(new StringReader(expString)) - .readObject(); - try { - logMsg("Create JsonWriterFactory with Map with EMPTY config"); - JsonWriterFactory writerFactory = Json - .createWriterFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = writerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg( - "-----------------------------------------------------------------"); - logMsg( - "TEST CASE [JsonWriterFactory.createWriter(OutputStream, Charset)]"); - logMsg( - "-----------------------------------------------------------------"); - logMsg( - "Create 1st JsonWriter using JsonWriterFactory with UTF-8 encoding"); - ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); - writer1 = writerFactory.createWriter(baos1, JSONP_Util.UTF_8); - if (writer1 == null) { - logErr("WriterFactory failed to create writer1"); - pass = false; - } else { - writer1.writeObject(jsonObject); - writer1.close(); - } - logMsg("baos1=" + baos1.toString("UTF-8")); - actString = JSONP_Util.removeWhitespace(baos1.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - logMsg( - "Create 2nd JsonWriter using JsonWriterFactory with UTF-8 encoding"); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - writer2 = writerFactory.createWriter(baos2, JSONP_Util.UTF_8); - if (writer2 == null) { - logErr("WriterFactory failed to create writer2"); - pass = false; - } else { - writer2.writeObject(jsonObject); - writer2.close(); - } - logMsg("baos2=" + baos2.toString("UTF-8")); - actString = JSONP_Util.removeWhitespace(baos2.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonWriterFactoryTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterFactoryTest2 Failed"); - } - - /* - * @testName: jsonWriterFactoryTest3 - * - * @assertion_ids: JSONP:JAVADOC:110; JSONP:JAVADOC:414; JSONP:JAVADOC:423; - * JSONP:JAVADOC:452; JSONP:JAVADOC:463; - * - * @test_Strategy: Tests the JsonWriterFactory API. - * - * JsonWriterFactory writerFactory = Json.createWriterFactory(Map); - * JsonWriter writer1 = writerFactory.createWriter(OutputStream) JsonWriter - * writer2 = writerFactory.createWriter(OutputStream) - */ - public void jsonWriterFactoryTest3() throws Fault { - boolean pass = true; - JsonWriter writer1 = null; - JsonWriter writer2 = null; - String expString = "{}"; - String actString; - JsonObject jsonObject = Json.createReader(new StringReader(expString)) - .readObject(); - try { - logMsg("Create JsonWriterFactory with Map with EMPTY config"); - JsonWriterFactory writerFactory = Json - .createWriterFactory(JSONP_Util.getEmptyConfig()); - logMsg("Checking factory configuration properties"); - Map config = writerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("--------------------------------------------------------"); - logMsg("TEST CASE [JsonWriterFactory.createWriter(OutputStream)]"); - logMsg("--------------------------------------------------------"); - logMsg("Create 1st JsonWriter using JsonWriterFactory"); - ByteArrayOutputStream baos1 = new ByteArrayOutputStream(); - writer1 = writerFactory.createWriter(baos1); - if (writer1 == null) { - logErr("WriterFactory failed to create writer1"); - pass = false; - } else { - writer1.writeObject(jsonObject); - writer1.close(); - } - logMsg("baos1=" + baos1.toString("UTF-8")); - actString = JSONP_Util.removeWhitespace(baos1.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - logMsg("Create 2nd JsonWriter using JsonWriterFactory"); - ByteArrayOutputStream baos2 = new ByteArrayOutputStream(); - writer2 = writerFactory.createWriter(baos2); - if (writer2 == null) { - logErr("WriterFactory failed to create writer2"); - pass = false; - } else { - writer2.writeObject(jsonObject); - writer2.close(); - } - logMsg("baos2=" + baos2.toString("UTF-8")); - actString = JSONP_Util.removeWhitespace(baos2.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expString, actString)) - pass = false; - - } catch (Exception e) { - throw new Fault("jsonWriterFactoryTest3 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterFactoryTest3 Failed"); - } - - /* - * @testName: jsonWriterFactoryTest4 - * - * @assertion_ids: JSONP:JAVADOC:452; JSONP:JAVADOC:463; - * - * @test_Strategy: Tests the JsonWriterFactory API. - * - * JsonWriterFactory writerFactory = Json.createWriterFactory(Map); - * Map config = JsonWriterFactory.getConfigInUse(); - * - * Test for the following 3 scenarios: 1) no supported provider property - * (empty config) 2) supported provider property 3) supported and non - * supported provider property - */ - public void jsonWriterFactoryTest4() throws Fault { - boolean pass = true; - JsonWriterFactory writerFactory; - Map config; - try { - logMsg("----------------------------------------------"); - logMsg("Test scenario1: no supported provider property"); - logMsg("----------------------------------------------"); - logMsg("Create JsonWriterFactory with Map with EMPTY config"); - writerFactory = Json.createWriterFactory(JSONP_Util.getEmptyConfig()); - config = writerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-------------------------------------------"); - logMsg("Test scenario2: supported provider property"); - logMsg("-------------------------------------------"); - logMsg("Create JsonWriterFactory with Map with FOO config"); - writerFactory = Json.createWriterFactory(JSONP_Util.getFooConfig()); - config = writerFactory.getConfigInUse(); - String[] props = { JsonGenerator.PRETTY_PRINTING, }; - if (!JSONP_Util.doConfigCheck(config, 0)) - pass = false; - - logMsg("-------------------------------------------------------------"); - logMsg("Test scenario3: supported and non supported provider property"); - logMsg("-------------------------------------------------------------"); - logMsg("Create JsonGeneratorFactory with Map with all config"); - writerFactory = Json.createWriterFactory(JSONP_Util.getAllConfig()); - config = writerFactory.getConfigInUse(); - if (!JSONP_Util.doConfigCheck(config, 1, props)) - pass = false; - } catch (Exception e) { - throw new Fault("jsonWriterFactoryTest4 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterFactoryTest4 Failed"); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonwriterfactorytests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonwriterfactorytests/build.xml deleted file mode 100644 index 7a624fb916..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonwriterfactorytests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/jsonwritertests/Client.java b/src/com/sun/ts/tests/jsonp/api/jsonwritertests/Client.java deleted file mode 100644 index 432b14a817..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonwritertests/Client.java +++ /dev/null @@ -1,1112 +0,0 @@ -/* - * Copyright (c) 2013, 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 com.sun.ts.tests.jsonp.api.jsonwritertests; - -import java.io.ByteArrayOutputStream; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.Map; -import java.util.Properties; - -import com.sun.javatest.Status; -import com.sun.ts.lib.harness.ServiceEETest; -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; -import com.sun.ts.tests.jsonp.common.JSONP_Util; -import com.sun.ts.tests.jsonp.common.MyBufferedWriter; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonReader; -import jakarta.json.JsonWriter; - -// $Id$ -public class Client extends ServiceEETest { - - public static void main(String[] args) { - Client theTests = new Client(); - Status s = theTests.run(args, System.out, System.err); - s.exit(); - } - - /* Test setup */ - - /* - * @class.setup_props: - */ - - public void setup(String[] args, Properties p) throws Fault { - logMsg("setup ok"); - } - - public void cleanup() throws Fault { - logMsg("cleanup ok"); - } - - /* Tests */ - - /* - * @testName: jsonWriterTest1 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:106; JSONP:JAVADOC:110; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonObject. - * Comparison is done by reading the JsonWriter output using JsonReader and - * recreating the JsonObject and than performing a JsonObject comparison for - * equality. - * - * Tests using API methods: Json.createWriter(Writer) and - * writer.writeObject(JsonObject) - * - */ - public void jsonWriterTest1() throws Fault { - boolean pass = true; - try { - - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject(); - - logMsg("Write the JsonObject 'myJsonObject1' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeObject(myJsonObject1); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String contents = sWriter.toString(); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + contents); - - logMsg( - "Read the JsonObject back into 'myJsonObject2' using a JsonReader"); - JsonReader reader = Json.createReader(new StringReader(contents)); - JsonObject myJsonObject2 = (JsonObject) reader.read(); - - logMsg("Compare myJsonObject1 and myJsonObject2 for equality"); - pass = JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2); - } catch (Exception e) { - throw new Fault("jsonWriterTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterTest1 Failed"); - } - - /* - * @testName: jsonWriterTest2 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:187; JSONP:JAVADOC:110; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonObject. - * Comparison is done by comparing the expected JsonObject text output with - * the actual JsonObject text output from the JsonWriter for equality. - * - * Tests using API methods: Json.createWriter(OutputStream) and - * writer.writeObject(JsonObject) - * - */ - public void jsonWriterTest2() throws Fault { - boolean pass = true; - try { - - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject(); - - logMsg("Write the JsonObject 'myJsonObject1' out to a JsonWriter"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriter(baos); - writer.writeObject(myJsonObject1); - logMsg("Close JsonWriter"); - baos.close(); - writer.close(); - - logMsg("Save contents of the JsonWriter as a String"); - String actJsonObjectText = baos.toString("UTF-8"); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + actJsonObjectText); - - logMsg( - "Compare expected JsonObject text with actual JsonObject text for equality"); - pass = JSONP_Util.assertEqualsJsonText( - JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText); - } catch (Exception e) { - throw new Fault("jsonWriterTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterTest2 Failed"); - } - - /* - * @testName: jsonWriterTest3 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:106; JSONP:JAVADOC:107; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonArray. - * Comparison is done by reading the JsonWriter output using JsonReader and - * recreating the JsonArray and than performing a JsonArray comparison for - * equality. - * - * Tests using API methods: Json.createWriter(Writer) and - * writer.writeArray(JsonArray) - * - */ - public void jsonWriterTest3() throws Fault { - boolean pass = true; - try { - - logMsg("Create sample JsonArray for testing"); - JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray(); - - logMsg("Write the JsonArray 'myJsonArray1' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.writeArray(myJsonArray1); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String contents = sWriter.toString(); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + contents); - - logMsg("Read the JsonArray back into 'myJsonArray2' using a JsonReader"); - JsonArray myJsonArray2; - try (JsonReader reader = Json.createReader(new StringReader(contents))) { - myJsonArray2 = (JsonArray) reader.read(); - logMsg("Close JsonReader"); - } - - logMsg("Compare myJsonArray1 and myJsonArray2 for equality"); - pass = JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2); - } catch (Exception e) { - throw new Fault("jsonWriterTest3 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterTest3 Failed"); - } - - /* - * @testName: jsonWriterTest4 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:187; JSONP:JAVADOC:107; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonArray. - * Comparison is done by comparing the expected JsonArray text output with the - * actual JsonArray text output from the JsonWriter for equality. - * - * Tests using API methods: Json.createWriter(OutputStream) and - * writer.writeArray(JsonArray) - * - */ - public void jsonWriterTest4() throws Fault { - boolean pass = true; - try { - - logMsg("Create sample JsonArray for testing"); - JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray(); - - logMsg("Write the JsonArray 'myJsonArray1' out to a JsonWriter"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriter(baos); - writer.writeArray(myJsonArray1); - logMsg("Close JsonWriter"); - baos.close(); - writer.close(); - - logMsg("Save contents of the JsonWriter as a String"); - String actJsonArrayText = baos.toString("UTF-8"); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + actJsonArrayText); - - logMsg( - "Compare expected JsonArray text with actual JsonArray text for equality"); - pass = JSONP_Util.assertEqualsJsonText( - JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText); - } catch (Exception e) { - throw new Fault("jsonWriterTest4 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterTest4 Failed"); - } - - /* - * @testName: jsonWriterTest5 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:424; JSONP:JAVADOC:110; - * JSONP:JAVADOC:452; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonObject. - * Comparison is done by comparing the expected JsonObject text output with - * the actual JsonObject text output from the JsonWriter for equality. - * - * Tests using API methods: - * Json.createWriterFactory(Map).createWriter(OutputStream, Charset) - * writer.writeObject(JsonObject) - * - * For encoding use UTF-16BE. - */ - public void jsonWriterTest5() throws Fault { - boolean pass = true; - try { - - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject(); - - logMsg("Write the JsonObject 'myJsonObject1' out to a JsonWriter"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig()) - .createWriter(baos, JSONP_Util.UTF_16BE); - writer.writeObject(myJsonObject1); - logMsg("Close JsonWriter"); - baos.close(); - writer.close(); - - logMsg("Save contents of the JsonWriter as a String"); - String actJsonObjectText = JSONP_Util - .removeWhitespace(baos.toString("UTF-16BE")); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + actJsonObjectText); - - logMsg( - "Compare expected JsonObject text with actual JsonObject text for equality"); - pass = JSONP_Util.assertEqualsJsonText( - JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText); - } catch (Exception e) { - throw new Fault("jsonWriterTest5 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterTest5 Failed"); - } - - /* - * @testName: jsonWriterTest6 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:424; JSONP:JAVADOC:107; - * JSONP:JAVADOC:452; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonArray. - * Comparison is done by comparing the expected JsonArray text output with the - * actual JsonArray text output from the JsonWriter for equality. - * - * Tests using API methods: - * Json.createWriterFactory.createWriter(OutputStream, Charset) - * writer.writeArray(JsonArray) - * - * For encoding use UTF-8. - */ - public void jsonWriterTest6() throws Fault { - boolean pass = true; - try { - - logMsg("Create a configuration with PRETT_PRINTING enabled."); - Map config = JSONP_Util.getPrettyPrintingConfig(); - - logMsg("Create sample JsonArray for testing"); - JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray(); - - logMsg("Write the JsonArray 'myJsonArray1' out to a JsonWriter"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(config).createWriter(baos, - JSONP_Util.UTF_8); - writer.writeArray(myJsonArray1); - logMsg("Close JsonWriter"); - baos.close(); - writer.close(); - - logMsg("Save contents of the JsonWriter as a String"); - String actJsonArrayText = JSONP_Util - .removeWhitespace(baos.toString("UTF-8")); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + actJsonArrayText); - - logMsg( - "Compare expected JsonArray text with actual JsonArray text for equality"); - pass = JSONP_Util.assertEqualsJsonText( - JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText); - } catch (Exception e) { - throw new Fault("jsonWriterTest6 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterTest6 Failed"); - } - - /* - * @testName: jsonWriterTest7 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:106; JSONP:JAVADOC:191; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonObject. - * Comparison is done by reading the JsonWriter output using JsonReader and - * recreating the JsonObject and than performing a JsonObject comparison for - * equality. - * - * Tests using API methods: Json.createWriter(Writer) and - * writer.write(JsonStructure) - * - */ - public void jsonWriterTest7() throws Fault { - boolean pass = true; - try { - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject(); - - logMsg("Write the JsonObject 'myJsonObject1' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.write(myJsonObject1); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String contents = sWriter.toString(); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + contents); - - logMsg( - "Read the JsonObject back into 'myJsonObject2' using a JsonReader"); - JsonReader reader = Json.createReader(new StringReader(contents)); - JsonObject myJsonObject2 = (JsonObject) reader.read(); - - logMsg("Compare myJsonObject1 and myJsonObject2 for equality"); - pass = JSONP_Util.assertEqualsJsonObjects(myJsonObject1, myJsonObject2); - } catch (Exception e) { - throw new Fault("jsonWriterTest7 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterTest7 Failed"); - } - - /* - * @testName: jsonWriterTest8 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:106; JSONP:JAVADOC:191; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonArray. - * Comparison is done by reading the JsonWriter output using JsonReader and - * recreating the JsonArray and than performing a JsonArray comparison for - * equality. - * - * Tests using API methods: Json.createWriter(Writer) and - * writer.write(JsonStructure) - * - */ - public void jsonWriterTest8() throws Fault { - boolean pass = true; - try { - - logMsg("Create sample JsonArray for testing"); - JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray(); - - logMsg("Write the JsonArray 'myJsonArray1' out to a JsonWriter"); - StringWriter sWriter = new StringWriter(); - try (JsonWriter writer = Json.createWriter(sWriter)) { - writer.write(myJsonArray1); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String contents = sWriter.toString(); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + contents); - - logMsg("Read the JsonArray back into 'myJsonArray2' using a JsonReader"); - JsonReader reader = Json.createReader(new StringReader(contents)); - JsonArray myJsonArray2 = (JsonArray) reader.read(); - - logMsg("Compare myJsonArray1 and myJsonArray2 for equality"); - pass = JSONP_Util.assertEqualsJsonArrays(myJsonArray1, myJsonArray2); - } catch (Exception e) { - throw new Fault("jsonWriterTest8 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterTest8 Failed"); - } - - /* - * @testName: jsonWriterUTFEncodedTests - * - * @assertion_ids: JSONP:JAVADOC:110; JSONP:JAVADOC:423; JSONP:JAVADOC:452; - * - * @test_Strategy: Tests various JsonWriter API's to create a JsonObject. - * - * The output is written to an OutputStream using all supported UTF encodings - * and read back as a string and filtered to remove whitespace and is compared - * against an expected string. The following UTF encodings are tested: - * - * UTF8 UTF16 UTF16LE UTF16BE UTF32LE UTF32BE - * - * { "object":{"string":"string","number":1,"true":true,"false":false,"null": - * null}, "array":["string", 1, true, false, null] } - */ - public void jsonWriterUTFEncodedTests() throws Fault { - boolean pass = true; - logMsg( - "Create expected JSON text with no whitespace for use in comparsion"); - String expJson = "{\"object\":{\"string\":\"string\",\"number\":1,\"true\":true,\"false\":false,\"null\":null},\"array\":[\"string\",1,true,false,null]}"; - try { - logMsg( - "-----------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createWriterFactory(Map).createWriter(OutputStream, Charset) as UTF-8]"); - logMsg( - "-----------------------------------------------------------------------------------------------"); - logMsg("Create JsonWriter using UTF-8 encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig()) - .createWriter(baos, JSONP_Util.UTF_8); - JSONP_Util.writeJsonObjectFromString(writer, expJson); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-8")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-8 encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-8")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing generation to UTF-8 encoding: " + e); - } - try { - logMsg( - "------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createWriterFactory(Map).createWriter(OutputStream, Charset) as UTF-16]"); - logMsg( - "------------------------------------------------------------------------------------------------"); - logMsg("Create JsonWriter using UTF-16 encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig()) - .createWriter(baos, JSONP_Util.UTF_16); - JSONP_Util.writeJsonObjectFromString(writer, expJson); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-16")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-16 encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr("Exception occurred testing generation to UTF-16 encoding: " + e); - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createWriterFactory(Map).createWriter(OutputStream, Charset) as UTF-16LE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg("Create JsonWriter using UTF-16LE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig()) - .createWriter(baos, JSONP_Util.UTF_16LE); - JSONP_Util.writeJsonObjectFromString(writer, expJson); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-16LE")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-16LE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16LE")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr( - "Exception occurred testing generation to UTF-16LE encoding: " + e); - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createWriterFactory(Map).createWriter(OutputStream, Charset) as UTF-16BE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg("Create JsonWriter using UTF-16BE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig()) - .createWriter(baos, JSONP_Util.UTF_16BE); - JSONP_Util.writeJsonObjectFromString(writer, expJson); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-16BE")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-16BE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-16BE")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr( - "Exception occurred testing generation to UTF-16BE encoding: " + e); - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createWriterFactory(Map).createWriter(OutputStream, Charset) as UTF-32LE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg("Create JsonWriter using UTF-32LE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig()) - .createWriter(baos, JSONP_Util.UTF_32LE); - JSONP_Util.writeJsonObjectFromString(writer, expJson); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-32LE")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-32LE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-32LE")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr( - "Exception occurred testing generation to UTF-32LE encoding: " + e); - } - try { - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg( - "TEST CASE [Json.createWriterFactory(Map).createWriter(OutputStream, Charset) as UTF-32BE]"); - logMsg( - "--------------------------------------------------------------------------------------------------"); - logMsg("Create JsonWriter using UTF-32BE encoding"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(JSONP_Util.getEmptyConfig()) - .createWriter(baos, JSONP_Util.UTF_32BE); - JSONP_Util.writeJsonObjectFromString(writer, expJson); - - // Dump JsonText output - TestUtil.logMsg("Generated Output=" + baos.toString("UTF-32BE")); - - // Do comparison - logMsg( - "Read the JSON text back from OutputStream using UTF-32BE encoding removing whitespace"); - String actJson = JSONP_Util.removeWhitespace(baos.toString("UTF-32BE")); - if (!JSONP_Util.assertEqualsJsonText(expJson, actJson)) - pass = false; - - } catch (Exception e) { - pass = false; - logErr( - "Exception occurred testing generation to UTF-32BE encoding: " + e); - } - if (!pass) - throw new Fault("jsonWriterUTFEncodedTests Failed"); - } - - /* - * @testName: jsonWriterWithConfigTest1 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:422; JSONP:JAVADOC:110; - * JSONP:JAVADOC:452; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonObject. - * Comparison is done by comparing the expected JsonObject text output with - * the actual JsonObject text output from the JsonWriter for equality. - * - * Tests using API methods: - * Json.createWriterFactory(Map).createWriter(Writer) - * writer.writeObject(JsonObject) - * - */ - public void jsonWriterWithConfigTest1() throws Fault { - boolean pass = true; - try { - - logMsg("Create a configuration with PRETT_PRINTING enabled."); - Map config = JSONP_Util.getPrettyPrintingConfig(); - - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject1 = JSONP_Util.createSampleJsonObject(); - - logMsg("Write the JsonObject 'myJsonObject1' out to a JsonWriter"); - StringWriter swriter = new StringWriter(); - try (JsonWriter writer = Json.createWriterFactory(config) - .createWriter(swriter)) { - writer.writeObject(myJsonObject1); - logMsg("Close JsonWriter"); - } - - logMsg("Save contents of the JsonWriter as a String"); - String actJsonObjectText = JSONP_Util - .removeWhitespace(swriter.toString()); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + actJsonObjectText); - - logMsg( - "Compare expected JsonObject text with actual JsonObject text for equality"); - pass = JSONP_Util.assertEqualsJsonText( - JSONP_Util.EXPECTED_SAMPLEJSONOBJECT_TEXT, actJsonObjectText); - } catch (Exception e) { - throw new Fault("jsonWriterWithConfigTest1 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterWithConfigTest1 Failed"); - } - - /* - * @testName: jsonWriterWithConfigTest2 - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:423; JSONP:JAVADOC:107; - * - * @test_Strategy: Tests JsonWriter API's for writing out a JsonArray. - * Comparison is done by comparing the expected JsonArray text output with the - * actual JsonArray text output from the JsonWriter for equality. - * - * Tests using API methods: - * Json.createWriterFactory(Map).creatWriter(OutputStream) - * writer.writeArray(JsonArray) - * - */ - public void jsonWriterWithConfigTest2() throws Fault { - boolean pass = true; - try { - - logMsg("Create a configuration with PRETT_PRINTING enabled."); - Map config = JSONP_Util.getPrettyPrintingConfig(); - - logMsg("Create sample JsonArray for testing"); - JsonArray myJsonArray1 = JSONP_Util.createSampleJsonArray(); - - logMsg("Write the JsonArray 'myJsonArray1' out to a JsonWriter"); - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - JsonWriter writer = Json.createWriterFactory(config).createWriter(baos); - writer.writeArray(myJsonArray1); - logMsg("Close JsonWriter"); - baos.close(); - writer.close(); - - logMsg("Save contents of the JsonWriter as a String"); - String actJsonArrayText = JSONP_Util - .removeWhitespace(baos.toString("UTF-8")); - - logMsg("Dump contents of JsonWriter as a String"); - logMsg("JsonWriterContents=" + actJsonArrayText); - - logMsg( - "Compare expected JsonArray text with actual JsonArray text for equality"); - pass = JSONP_Util.assertEqualsJsonText( - JSONP_Util.EXPECTED_SAMPLEJSONARRAY_TEXT, actJsonArrayText); - } catch (Exception e) { - throw new Fault("jsonWriterWithConfigTest2 Failed: ", e); - } - if (!pass) - throw new Fault("jsonWriterWithConfigTest2 Failed"); - } - - /* - * @testName: jsonWriterExceptionTests - * - * @assertion_ids: JSONP:JAVADOC:105; JSONP:JAVADOC:106; JSONP:JAVADOC:109; - * JSONP:JAVADOC:112; JSONP:JAVADOC:222; - * - * @test_Strategy: Test for JsonWriter exception test conditions. o - * IllegalStateException - * - */ - public void jsonWriterExceptionTests() throws Fault { - boolean pass = true; - JsonWriter writer = null; - - // IllegalStateException if writer.close() already called before - // writer.writeArray(JsonArray) - try { - logMsg("Create sample JsonArray for testing"); - JsonArray jsonArray = JSONP_Util.createSampleJsonArray(); - - logMsg("Create JsonWriter, write something and close it"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.writeArray(jsonArray); - writer.close(); - - logMsg( - "IllegalStateException if writer.close() already called before writer.writeArray(JsonArray)"); - writer.writeArray(jsonArray); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // IllegalStateException if writer.writeArray() called after - // writer.writeArray(JsonArray) - try { - logMsg("Create sample JsonArray for testing"); - JsonArray jsonArray = JSONP_Util.createSampleJsonArray(); - - logMsg("Create JsonWriter and write out array"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.writeArray(jsonArray); - - logMsg( - "IllegalStateException if writer.writeArray(JsonArray) called after writer.writeArray(JsonArray)"); - writer.writeArray(jsonArray); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (writer != null) - writer.close(); - } - - // IllegalStateException if writer.writeObject() called after - // writer.writeArray(JsonArray) - try { - logMsg("Create sample JsonArray for testing"); - JsonArray jsonArray = JSONP_Util.createSampleJsonArray(); - - logMsg("Create sample JsonObject for testing"); - JsonObject jsonObject = JSONP_Util.createSampleJsonObject(); - - logMsg("Create JsonWriter and write out array"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.writeArray(jsonArray); - - logMsg( - "IllegalStateException if writer.writeObject(JsonObject) called after writer.writeArray(JsonArray)"); - writer.writeObject(jsonObject); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (writer != null) - writer.close(); - } - - // IllegalStateException if writer.close() already called before - // writer.writeObject(JsonArray) - try { - logMsg("Create sample JsonObject for testing"); - JsonObject jsonObject = JSONP_Util.createSampleJsonObject(); - - logMsg("Create JsonWriter, write something and close it"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.writeObject(jsonObject); - writer.close(); - - logMsg( - "IllegalStateException if writer.close() already called before writer.writeObject(JsonObject)"); - writer.writeObject(jsonObject); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // IllegalStateException if writer.writeObject() called after - // writer.writeObject(JsonObject) - try { - logMsg("Create sample JsonObject for testing"); - JsonObject jsonObject = JSONP_Util.createSampleJsonObject(); - - logMsg("Create JsonWriter and write out object"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.writeObject(jsonObject); - - logMsg( - "IllegalStateException if writer.writeObject(JsonObject) called after writer.writeObject(JsonObject)"); - writer.writeObject(jsonObject); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (writer != null) - writer.close(); - } - - // IllegalStateException if writer.writeArray() called after - // writer.writeObject(JsonObject) - try { - logMsg("Create sample JsonArray for testing"); - JsonArray jsonArray = JSONP_Util.createSampleJsonArray(); - - logMsg("Create sample JsonObject for testing"); - JsonObject jsonObject = JSONP_Util.createSampleJsonObject(); - - logMsg("Create JsonWriter and write out object"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.writeObject(jsonObject); - - logMsg( - "IllegalStateException if writer.writeArray(JsonArray) called after writer.writeObject(JsonObject)"); - writer.writeArray(jsonArray); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (writer != null) - writer.close(); - } - - // IllegalStateException if writer.close() already called before - // writer.write(JsonArray) - try { - logMsg("Create sample JsonArray for testing"); - JsonArray jsonArray = JSONP_Util.createSampleJsonArray(); - - logMsg("Create JsonWriter, write something and close it"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.write(jsonArray); - writer.close(); - - logMsg( - "IllegalStateException if writer.close() already called before writer.write(JsonArray)"); - writer.write(jsonArray); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // IllegalStateException if writer.write(JsonArray) called after - // writer.writeArray(JsonArray) - try { - logMsg("Create sample JsonArray for testing"); - JsonArray jsonArray = JSONP_Util.createSampleJsonArray(); - - logMsg("Create JsonWriter and write out array"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.writeArray(jsonArray); - - logMsg( - "IllegalStateException if writer.write(JsonArray) called after writer.writeArray(JsonArray)"); - writer.write(jsonArray); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (writer != null) - writer.close(); - } - - // IllegalStateException if writer.write(JsonObject) called after - // writer.writeJsonObject(JsonObject) - try { - logMsg("Create sample JsonObject for testing"); - JsonObject jsonObject = JSONP_Util.createSampleJsonObject(); - - logMsg("Create JsonWriter and write out object"); - StringWriter sWriter = new StringWriter(); - writer = Json.createWriter(sWriter); - writer.writeObject(jsonObject); - - logMsg( - "IllegalStateException if writer.write(JsonObject) called after writer.writeObject(JsonObject)"); - writer.write(jsonObject); - pass = false; - logErr("Failed to throw IllegalStateException"); - } catch (IllegalStateException e) { - logMsg("Got expected IllegalStateException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } finally { - if (writer != null) - writer.close(); - } - - if (!pass) - throw new Fault("jsonWriterExceptionTests Failed"); - } - - /* - * @testName: jsonWriterIOErrorTests - * - * @assertion_ids: JSONP:JAVADOC:108; JSONP:JAVADOC:111; JSONP:JAVADOC:221; - * JSONP:JAVADOC:414; - * - * @test_Strategy: Tests for JsonException for testable i/o errors. - * - */ - public void jsonWriterIOErrorTests() throws Fault { - boolean pass = true; - - // Trip JsonException if there is an i/o error on JsonWriter.close() - try { - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject = JSONP_Util.createSampleJsonObject(); - logMsg( - "Trip JsonException if there is an i/o error on JsonWriter.close()."); - MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter()); - try (JsonWriter writer = Json.createWriter(mbw)) { - writer.writeObject(myJsonObject); - mbw.setThrowIOException(true); - logMsg("Calling JsonWriter.close()"); - } - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException if there is an i/o error on - // JsonWriter.writeObject(JsonObject) - try { - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject = JSONP_Util.createSampleJsonObject(); - logMsg( - "Trip JsonException if there is an i/o error on JsonWriter.writeObject(JsonObject)."); - MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter()); - try (JsonWriter writer = Json.createWriter(mbw)) { - mbw.setThrowIOException(true); - logMsg("Calling JsonWriter.writeObject(JsonObject)"); - writer.writeObject(myJsonObject); - } - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException if there is an i/o error on - // JsonWriter.writeArray(JsonArray) - try { - logMsg("Create sample JsonArray for testing"); - JsonArray myJsonArray = JSONP_Util.createSampleJsonArray(); - logMsg( - "Trip JsonException if there is an i/o error on JsonWriter.writeArray(JsonArray)."); - MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter()); - try (JsonWriter writer = Json.createWriter(mbw)) { - mbw.setThrowIOException(true); - logMsg("Calling JsonWriter.writeArray(JsonArray)"); - writer.writeArray(myJsonArray); - } - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - // Trip JsonException if there is an i/o error on - // JsonWriter.write(JsonStructure) - try { - logMsg("Create sample JsonObject for testing"); - JsonObject myJsonObject = JSONP_Util.createSampleJsonObject(); - logMsg( - "Trip JsonException if there is an i/o error on JsonWriter.write(JsonStructure)."); - MyBufferedWriter mbw = new MyBufferedWriter(new StringWriter()); - try (JsonWriter writer = Json.createWriter(mbw)) { - mbw.setThrowIOException(true); - logMsg("Calling JsonWriter.write(JsonStructure)"); - writer.write(myJsonObject); - } - logErr("Did not get expected JsonException"); - pass = false; - } catch (JsonException e) { - logMsg("Caught expected JsonException"); - } catch (Exception e) { - pass = false; - logErr("Caught unexpected exception: " + e); - } - - if (!pass) - throw new Fault("jsonWriterIOErrorTests Failed"); - } - - /* - * @testName: jsonWriter11Test - * - * @assertion_ids: JSONP:JAVADOC:650; JSONP:JAVADOC:583; JSONP:JAVADOC:584; - * JSONP:JAVADOC:585; JSONP:JAVADOC:586; JSONP:JAVADOC:587; JSONP:JAVADOC:588; - * JSONP:JAVADOC:662; JSONP:JAVADOC:663; JSONP:JAVADOC:664; JSONP:JAVADOC:665; - * JSONP:JAVADOC:666; JSONP:JAVADOC:667; - * - * @test_Strategy: Tests JsonWriter API methods added in JSON-P 1.1. - */ - public void jsonWriter11Test() throws Fault { - Writer writerTest = new Writer(); - final TestResult result = writerTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonwritertests/Writer.java b/src/com/sun/ts/tests/jsonp/api/jsonwritertests/Writer.java deleted file mode 100644 index 713d79cdab..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonwritertests/Writer.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.jsonwritertests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BDC_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BIN_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DBL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.LNG_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.SimpleValues; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonException; -import jakarta.json.JsonValue; -import jakarta.json.JsonWriter; -import jakarta.json.stream.JsonParser; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests for {@link JsonWriter}. - */ -public class Writer { - - /** Tests input data. */ - private static final Object[] VALUES = new Object[] { OBJ_VALUE, // write(JsonValue) - // for - // JsonObject - createEmptyArrayWithStr(), // write(JsonValue) for simple JsonArray - STR_VALUE, // write(JsonValue) for String - INT_VALUE, // write(JsonValue) for int - LNG_VALUE, // write(JsonValue) for long - DBL_VALUE, // write(JsonValue) for double - BIN_VALUE, // write(JsonValue) for BigInteger - BDC_VALUE, // write(JsonValue) for BigDecimal - BOOL_VALUE, // write(JsonValue) for boolean - null // write(JsonValue) for null - }; - - /** - * Creates an instance of JavaScript Object Notation (JSON) compatibility - * tests for {@link JsonWriter}. - */ - Writer() { - super(); - } - - /** - * {@link JsonWriter} API methods added in JSON-P 1.1. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonWriter API methods added in JSON-P 1.1."); - TestUtil.logMsg("JsonWriter API methods added in JSON-P 1.1."); - testWriteValue(result); - testDoubleWriteValue(result); - testIOExceptionOnWriteValue(result); - return result; - } - - /** - * Test {@code void write(JsonValue)} method on all child types of - * {@code JsonValue}. - * - * @param result - * Test suite result. - */ - private void testWriteValue(final TestResult result) { - for (Object value : VALUES) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil - .logMsg(" - write(JsonValue) for " + typeName + " as an argument"); - final JsonValue jsonValue = SimpleValues.toJsonValue(value); - final StringWriter strWriter = new StringWriter(); - try (final JsonWriter writer = Json.createWriter(strWriter)) { - writer.write(jsonValue); - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("write(JsonValue)", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - final String data = strWriter.toString(); - TestUtil.logMsg(" - Data: " + data); - final JsonParser parser = Json.createParser(new StringReader(data)); - parser.next(); - final JsonValue outValue = parser.getValue(); - if (operationFailed(jsonValue, outValue)) { - result.fail("write(JsonValue)", - "Writer output " + valueToString(outValue) + " value shall be " - + valueToString(jsonValue)); - } - } - } - - /** - * Test {@code void write(JsonValue)} method with duplicated {@code JsonValue} - * write call. Second call is expected to throw {@code IllegalStateException} - * exception. - * - * @param result - * Test suite result. - */ - private void testDoubleWriteValue(final TestResult result) { - for (Object value : VALUES) { - final String typeName = JsonValueType.getType(value).name(); - TestUtil.logMsg( - " - duplicate write(JsonValue) for " + typeName + " as an argument"); - final JsonValue jsonValue = SimpleValues.toJsonValue(value); - final StringWriter strWriter = new StringWriter(); - try (final JsonWriter writer = Json.createWriter(strWriter)) { - // 1st attempt to write the data shall pass - writer.write(jsonValue); - try { - // 2nd attempt to write the data shall throw IllegalStateException - writer.write(jsonValue); - result.fail("write(JsonValue)", - "Duplicate call of write(JsonValue) shall throw IllegalStateException"); - } catch (IllegalStateException ex) { - TestUtil.logMsg(" - Expected exception: " + ex.getMessage()); - } catch (Throwable t) { - result.fail("write(JsonValue)", - "Duplicate call of write(JsonValue) shall throw IllegalStateException, not " - + t.getClass().getSimpleName()); - } - } catch (JsonException ex) { - TestUtil.logMsg("Caught JsonException: " + ex.getLocalizedMessage()); - result.fail("write(JsonValue)", - "Caught JsonException: " + ex.getLocalizedMessage()); - } - } - } - - /** - * Test {@code void write(JsonValue)} method with write call that causes - * IOException. IOException shall be encapsulated in JsonException. - * - * @param result - * Test suite result. - */ - @SuppressWarnings("ConvertToTryWithResources") - private void testIOExceptionOnWriteValue(final TestResult result) { - TestUtil.logMsg(" - write(JsonValue) into already closed file writer"); - final JsonValue jsonValue = SimpleValues.toJsonValue(DEF_VALUE); - File temp = null; - JsonWriter writer; - // Close writer before calling write method. - try { - temp = File.createTempFile("testIOExceptionOnWriteValue", ".txt"); - TestUtil.logMsg(" - Temporary file: " + temp.getAbsolutePath()); - final FileWriter fileWriter = new FileWriter(temp); - writer = Json.createWriter(fileWriter); - fileWriter.close(); - } catch (IOException ex) { - TestUtil.logMsg("Caught IOException: " + ex.getLocalizedMessage()); - result.fail("write(JsonValue)", - "Caught IOException: " + ex.getLocalizedMessage()); - return; - } finally { - if (temp != null) { - temp.delete(); - } - } - try { - writer.write(jsonValue); - result.fail("write(JsonValue)", - "Call of write(JsonValue) on already closed file writer shall throw JsonException"); - } catch (JsonException ex) { - TestUtil.logMsg(" - Expected exception: " + ex.getMessage()); - } catch (Throwable t) { - result.fail("write(JsonValue)", - "Call of write(JsonValue) on already closed file writer shall throw JsonException, not " - + t.getClass().getSimpleName()); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null || !assertEquals(check, out); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/jsonwritertests/build.xml b/src/com/sun/ts/tests/jsonp/api/jsonwritertests/build.xml deleted file mode 100644 index 2d17d63d19..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/jsonwritertests/build.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeAddValue.java b/src/com/sun/ts/tests/jsonp/api/mergetests/MergeAddValue.java deleted file mode 100644 index 90d1633eb1..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeAddValue.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.mergetests; - -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.JsonObject; - -// $Id$ -/** - * RFC 7396: JavaScript Object Notation (JSON) Merge Patch compatibility - * tests.
- * Checks scenario described in - * {@see RFC 7396: 1. - * Introduction}: If the provided merge patch contains members that do not - * appear within the target, those members are added. - */ -public class MergeAddValue extends MergeCommon { - - /** - * Creates an instance of RFC 7396 value adding test. - */ - MergeAddValue() { - super(); - } - - /** - * Test RFC 7396: Adding non existing values. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "RFC 7396: Add non existing values"); - TestUtil.logMsg("Testing RFC 7396: Add non existing values"); - testStringOnEmptyObject(result); - testStringOnsimpleObject(result); - testIntOnEmptyObject(result); - testIntOnsimpleObject(result); - testBoolOnEmptyObject(result); - testBoolOnsimpleObject(result); - testObjectOnEmptyObject(result); - testObjectOnsimpleObject(result); - return result; - } - - /** - * Test RFC 7396 patch and diff for {@code String} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testStringOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for String on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject patch = createSimpleObjectStr(); - final JsonObject check = createSimpleObjectStr(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testStringOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject patch = createSimpleObjectStr(); - final JsonObject check = createSimpleObjectWithStr(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code int} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testIntOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for int on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject patch = createSimpleObjectInt(); - final JsonObject check = createSimpleObjectInt(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testIntOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject patch = createSimpleObjectInt(); - final JsonObject check = createSimpleObjectWithInt(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code boolean} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testBoolOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject patch = createSimpleObjectBool(); - final JsonObject check = createSimpleObjectBool(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testBoolOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject patch = createSimpleObjectBool(); - final JsonObject check = createSimpleObjectWithBool(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code JsonObject} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testObjectOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject patch = createSimpleObjectObject(); - final JsonObject check = createSimpleObjectObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code JsonObject} on compound JSON - * object. - * - * @param result - * Tests result record. - */ - private void testObjectOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on compound JSON object"); - final JsonObject in = createCompoundObject(); - final JsonObject patch = createSimpleObjectObject(); - final JsonObject check = createCompoundObjectWithObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeCommon.java b/src/com/sun/ts/tests/jsonp/api/mergetests/MergeCommon.java deleted file mode 100644 index 0fd73ac5e9..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeCommon.java +++ /dev/null @@ -1,205 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.mergetests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.valueToString; - -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonValue; - -// $Id$ -/** - * JavaScript Object Notation (JSON) compatibility tests.
- */ -public abstract class MergeCommon { - - /** Message content: "MERGE" operation. */ - private static final String MERGE_STR = "MERGE"; - - /** Message content: "DIFF" operation. */ - private static final String DIFF_STR = "DIFF"; - - /** Message content template for test failure log message: patch. */ - private static final String TEST_FAIL_PATCH = "Patch "; - - /** Message content template for test failure log message: failed on. */ - private static final String TEST_FAIL_ON = " failed on "; - - /** Message content template for test failure log message: value. */ - private static final String TEST_FAIL_VAL = " value"; - - /** Message content template for test failure log message: patch. */ - private static final String TEST_FAIL_FROM = "Diff from "; - - /** Message content template for test failure log message: failed on. */ - private static final String TEST_FAIL_TO = " to "; - - /** Message content template for test failure log message: value. */ - private static final String TEST_FAIL_FAIL = " failed"; - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @param message - * Assert message. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - protected boolean operationFailed(final JsonValue check, final JsonValue out, - final String message) { - return out == null || !assertEquals(check, out, message); - } - - /** - * Test helper: Verify merge of JSON patch on provided JSON value and verify - * result using provided expected JSON value. - * - * @param result - * Test suite result. - * @param in - * Source JSON value to be modified. - * @param patch - * JSON patch to be done on source value. - * @param check - * Expected modified JSON object (used for operation check). - */ - protected void simpleMerge(final TestResult result, final JsonValue in, - final JsonValue patch, final JsonValue check) { - final JsonValue out = Json.createMergePatch(patch).apply(in); - if (operationFailed(check, out, MERGE_STR + " mismatch")) { - final String targetClassName = in.getValueType().name().toLowerCase(); - result.fail(testName(MERGE_STR, targetClassName), - testMergeMessage(valueToString(in), valueToString(patch))); - } - } - - /** - * Test helper: Verify diff on provided JSON values and verify result using - * provided expected JSON value. - * - * @param result - * Test suite result. - * @param src - * Source JSON value for diff. - * @param target - * Target JSON value for diff. - * @param diff - * Expected diff JSON object (used for operation check). - */ - protected void simpleDiff(final TestResult result, final JsonValue src, - final JsonValue target, final JsonValue diff) { - final JsonValue out = Json.createMergeDiff(src, target).toJsonValue(); - if (operationFailed(diff, out, DIFF_STR + " mismatch")) { - final String srcClassName = src.getValueType().name().toLowerCase(); - final String targetClassName = target.getValueType().name().toLowerCase(); - result.fail(testName(DIFF_STR, srcClassName, targetClassName), - testDiffMessage(valueToString(src), valueToString(target))); - } - } - - /** - * Build test name for test failure log message. - * - * @param operation - * Name of operation. - * @param targetType - * Name of the target (JSON value being modified) value type. - * @return Test name for test failure log message. - */ - protected String testName(final String operation, final String targetType) { - final StringBuilder sb = new StringBuilder( - operation.length() + targetType.length() + 1); - sb.append(operation); - sb.append(' '); - sb.append(targetType); - return sb.toString(); - } - - /** - * Build test name for test failure log message. - * - * @param operation - * Name of operation. - * @param srcType - * Name of the source (JSON value being used for modification) value - * type. - * @param targetType - * Name of the target (JSON value being modified) value type. - * @return Test name for test failure log message. - */ - protected String testName(final String operation, final String srcType, - final String targetType) { - final StringBuilder sb = new StringBuilder( - operation.length() + srcType.length() + targetType.length() + 2); - sb.append(operation); - sb.append(' '); - sb.append(srcType); - sb.append(','); - sb.append(targetType); - return sb.toString(); - } - - /** - * Build message content for test failure log message. - * - * @param in - * Source JSON value to be modified. - * @param patch - * JSON patch to be done on source value. - * @return Log message content. - */ - protected String testMergeMessage(final String in, final String patch) { - final StringBuilder sb = new StringBuilder( - TEST_FAIL_PATCH.length() + TEST_FAIL_ON.length() - + TEST_FAIL_VAL.length() + patch.length() + in.length()); - sb.append(TEST_FAIL_PATCH); - sb.append(patch); - sb.append(TEST_FAIL_ON); - sb.append(in); - sb.append(TEST_FAIL_VAL); - return sb.toString(); - } - - /** - * Build message content for test failure log message. - * - * @param src - * Source JSON value for diff. - * @param target - * Target JSON value for diff. - * @return Log message content. - */ - protected String testDiffMessage(final String src, final String target) { - final StringBuilder sb = new StringBuilder( - TEST_FAIL_FROM.length() + TEST_FAIL_TO.length() - + TEST_FAIL_FAIL.length() + src.length() + target.length()); - sb.append(TEST_FAIL_FROM); - sb.append(src); - sb.append(TEST_FAIL_TO); - sb.append(target); - sb.append(TEST_FAIL_FAIL); - return sb.toString(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeNonObject.java b/src/com/sun/ts/tests/jsonp/api/mergetests/MergeNonObject.java deleted file mode 100644 index 2415e456fe..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeNonObject.java +++ /dev/null @@ -1,261 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.mergetests; - -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.toJsonValue; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonValue; - -// $Id$ -/** - * RFC 7396: JavaScript Object Notation (JSON) Merge Patch compatibility - * tests.
- * Checks scenario described in - * {@see RFC 7396: 1. - * Introduction}: If the patch is anything other than an object, the result - * will always be to replace the entire target with the entire patch. - */ -public class MergeNonObject extends MergeCommon { - - /** - * Creates an instance of RFC 7396 non object patch test. - */ - MergeNonObject() { - super(); - } - - /** - * Test RFC 7396: Non object patch. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 7396: Non object patch"); - TestUtil.logMsg("Testing RFC 7396: Non object patch"); - testStringOnEmptyObject(result); - testStringOnSimpleObject(result); - testStringOnSimpleArray(result); - testIntOnEmptyObject(result); - testIntOnSimpleObject(result); - testIntOnSimpleArray(result); - testBoolOnEmptyObject(result); - testBoolOnSimpleObject(result); - testBoolOnSimpleArray(result); - testArrayOnEmptyObject(result); - testArrayOnCompoundObject(result); - testArrayOnSimpleArray(result); - return result; - } - - /** - * Test RFC 7396 patch and diff for {@code String} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testStringOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for String on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonValue patch = Json.createValue(STR_VALUE); - final JsonValue check = Json.createValue(STR_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code String} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObjectWithStr(); - final JsonValue patch = Json.createValue(STR_VALUE); - final JsonValue check = Json.createValue(STR_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code String} on empty JSON array. - * - * @param result - * Tests result record. - */ - private void testStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array"); - final JsonArray in = createStringArray2(); - final JsonValue patch = Json.createValue(STR_VALUE); - final JsonValue check = Json.createValue(STR_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code int} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testIntOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for int on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonValue patch = Json.createValue(INT_VALUE); - final JsonValue check = Json.createValue(INT_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code int} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObjectWithInt(); - final JsonValue patch = Json.createValue(INT_VALUE); - final JsonValue check = Json.createValue(INT_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code int} on empty JSON array. - * - * @param result - * Tests result record. - */ - private void testIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array"); - final JsonArray in = createIntArray2(); - final JsonValue patch = Json.createValue(INT_VALUE); - final JsonValue check = Json.createValue(INT_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code boolean} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testBoolOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonValue patch = toJsonValue(BOOL_VALUE); - final JsonValue check = toJsonValue(BOOL_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code boolean} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testBoolOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObjectWithBool(); - final JsonValue patch = toJsonValue(BOOL_VALUE); - final JsonValue check = toJsonValue(BOOL_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code boolean} on empty JSON array. - * - * @param result - * Tests result record. - */ - private void testBoolOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array"); - final JsonArray in = createBoolArray2(); - final JsonValue patch = toJsonValue(BOOL_VALUE); - final JsonValue check = toJsonValue(BOOL_VALUE); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code JsonArray} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testArrayOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for JsonArray on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonArray patch = createStringArray1(); - final JsonArray check = createStringArray1(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code JsonArray} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testArrayOnCompoundObject(final TestResult result) { - TestUtil.logMsg(" - for JsonArray on compound JSON object"); - final JsonObject in = createCompoundObject(); - final JsonValue patch = createStringArray2(); - final JsonValue check = createStringArray2(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code JsonArray} on empty JSON array. - * - * @param result - * Tests result record. - */ - private void testArrayOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonArray on simple JSON array"); - final JsonArray in = createBoolArray2(); - final JsonValue patch = createIntArray2(); - final JsonValue check = createIntArray2(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } -} diff --git a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeRFCSample.java b/src/com/sun/ts/tests/jsonp/api/mergetests/MergeRFCSample.java deleted file mode 100644 index 1863081a08..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeRFCSample.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.mergetests; - -import static com.sun.ts.tests.jsonp.api.common.MergeRFCObject.createRFCPatchObject; -import static com.sun.ts.tests.jsonp.api.common.MergeRFCObject.createRFCSourceObject; -import static com.sun.ts.tests.jsonp.api.common.MergeRFCObject.createRFCTargetObject; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.JsonObject; - -// $Id$ -/** - * RFC 7396: JavaScript Object Notation (JSON) Merge Patch compatibility - * tests.
- * Test based on - * {@see RFC 7396: 3. - * Example} objects. - */ -public class MergeRFCSample extends MergeCommon { - - /** - * Creates an instance of RFC 7396 value replacing test. - */ - MergeRFCSample() { - super(); - } - - /** - * Test RFC 7396: Adding non existing values. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 7396: Example JSON object"); - TestUtil.logMsg("Testing RFC 7396: Example JSON object"); - testMerge(result); - testDiff(result); - return result; - } - - /** - * Test RFC 7396 patch for example objects. - * - * @param result - * Tests result record. - */ - private void testMerge(final TestResult result) { - TestUtil.logMsg(" - merge"); - final JsonObject in = createRFCSourceObject(); - final JsonObject patch = createRFCPatchObject(); - final JsonObject check = createRFCTargetObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 diff for example objects. - * - * @param result - * Tests result record. - */ - private void testDiff(final TestResult result) { - TestUtil.logMsg(" - diff"); - final JsonObject in = createRFCSourceObject(); - final JsonObject diff = createRFCPatchObject(); - final JsonObject out = createRFCTargetObject(); - simpleDiff(result, in, out, diff); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeRemoveValue.java b/src/com/sun/ts/tests/jsonp/api/mergetests/MergeRemoveValue.java deleted file mode 100644 index bbb5b8cd17..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeRemoveValue.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.mergetests; - -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createPatchRemoveBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createPatchRemoveInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createPatchRemoveObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createPatchRemoveStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.JsonObject; - -// $Id$ -/** - * RFC 7396: JavaScript Object Notation (JSON) Merge Patch compatibility - * tests.
- * Checks scenario described in - * {@see RFC 7396: 1. - * Introduction}: {@code null} values in the merge patch are given special - * meaning to indicate the removal of existing values in the target. - */ -public class MergeRemoveValue extends MergeCommon { - - /** - * Creates an instance of RFC 7396 value removal test. - */ - MergeRemoveValue() { - super(); - } - - /** - * Test RFC 7396: Removing existing values. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "RFC 7396: Remove existing values"); - TestUtil.logMsg("Testing RFC 7396: Remove existing values"); - testStringOnEmptyObject(result); - testStringOnsimpleObject(result); - testIntOnEmptyObject(result); - testIntOnsimpleObject(result); - testBoolOnEmptyObject(result); - testBoolOnsimpleObject(result); - testObjectOnEmptyObject(result); - testObjectOnsimpleObject(result); - return result; - } - - /** - * Test RFC 7396 patch and diff for {@code String} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testStringOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for String to produce empty JSON object"); - final JsonObject in = createSimpleObjectStr(); - final JsonObject patch = createPatchRemoveStr(); - final JsonObject check = createEmptyObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testStringOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObjectWithStr(); - final JsonObject patch = createPatchRemoveStr(); - final JsonObject check = createSimpleObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code int} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testIntOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for int to produce empty JSON object"); - final JsonObject in = createSimpleObjectInt(); - final JsonObject patch = createPatchRemoveInt(); - final JsonObject check = createEmptyObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testIntOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObjectWithInt(); - final JsonObject patch = createPatchRemoveInt(); - final JsonObject check = createSimpleObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code boolean} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testBoolOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for boolean to produce empty JSON object"); - final JsonObject in = createSimpleObjectBool(); - final JsonObject patch = createPatchRemoveBool(); - final JsonObject check = createEmptyObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testBoolOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObjectWithBool(); - final JsonObject patch = createPatchRemoveBool(); - final JsonObject check = createSimpleObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code JsonObject} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testObjectOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject to produce empty JSON object"); - final JsonObject in = createSimpleObjectObject(); - final JsonObject patch = createPatchRemoveObject(); - final JsonObject check = createEmptyObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code JsonObject} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testObjectOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on compoubnd JSON object"); - final JsonObject in = createCompoundObjectWithObject(); - final JsonObject patch = createPatchRemoveObject(); - final JsonObject check = createCompoundObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeReplaceValue.java b/src/com/sun/ts/tests/jsonp/api/mergetests/MergeReplaceValue.java deleted file mode 100644 index c82f1c3804..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeReplaceValue.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.mergetests; - -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectMoveBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectMoveInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectMoveObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectMoveStr; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.JsonObject; - -// $Id$ -/** - * RFC 7396: JavaScript Object Notation (JSON) Merge Patch compatibility - * tests.
- * Checks scenario described in - * {@see RFC 7396: 1. - * Introduction}: If the target does contain the member, the value is - * replaced. - */ -public class MergeReplaceValue extends MergeCommon { - - /** - * Creates an instance of RFC 7396 value replacing test. - */ - MergeReplaceValue() { - super(); - } - - /** - * Test RFC 7396: Adding non existing values. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "RFC 7396: Replace existing values"); - TestUtil.logMsg("Testing RFC 7396: Replace existing values"); - testStringOnsimpleObject(result); - testIntOnsimpleObject(result); - testBoolOnsimpleObject(result); - testObjectOnsimpleObject(result); - return result; - } - - /** - * Test RFC 7396 patch and diff for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testStringOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject patch = createSimpleObjectMoveStr(); - final JsonObject check = createSimpleObjectMoveStr(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testIntOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject patch = createSimpleObjectMoveInt(); - final JsonObject check = createSimpleObjectMoveInt(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testBoolOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject patch = createSimpleObjectMoveBool(); - final JsonObject check = createSimpleObjectMoveBool(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - - /** - * Test RFC 7396 patch and diff for {@code JsonObject} on compound JSON - * object. - * - * @param result - * Tests result record. - */ - private void testObjectOnsimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject patch = createSimpleObjectMoveObject(); - final JsonObject check = createSimpleObjectMoveObject(); - simpleMerge(result, in, patch, check); - simpleDiff(result, in, check, patch); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeTests.java b/src/com/sun/ts/tests/jsonp/api/mergetests/MergeTests.java deleted file mode 100644 index 641ef6edb3..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/mergetests/MergeTests.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) 2016, 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 - */ - -package com.sun.ts.tests.jsonp.api.mergetests; - -import com.sun.ts.tests.jsonp.api.common.JsonPTest; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -// $Id$ -/** - * RFC 7396: JavaScript Object Notation (JSON) Merge Patch compatibility - * tests.
- * {@see RFC 7396}. - */ -public class MergeTests extends JsonPTest { - - /** - * Test JSON-P API response on - * {@see RFC 7396: 1. - * Introduction}: If the provided merge patch contains members that do not - * appear within the target, those members are added. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonMergeAddValueTest - * @assertion_ids: JSONP:JAVADOC:575; JSONP:JAVADOC:576; JSONP:JAVADOC:616; - * JSONP:JAVADOC:617; JSONP:JAVADOC:620; JSONP:JAVADOC:654; - * JSONP:JAVADOC:655; - * @test_Strategy: Test API response on various JSON values. - */ - public void jsonMergeAddValueTest() throws Fault { - MergeAddValue addTest = new MergeAddValue(); - final TestResult result = addTest.test(); - result.eval(); - } - - /** - * Test JSON-P API response on - * {@see RFC 7396: 1. - * Introduction}: If the target does contain the member, the value is - * replaced. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonMergeReplaceValueTest - * @assertion_ids: JSONP:JAVADOC:575; JSONP:JAVADOC:576; JSONP:JAVADOC:616; - * JSONP:JAVADOC:617; JSONP:JAVADOC:654; JSONP:JAVADOC:655; - * @test_Strategy: Test API response on various JSON values. - */ - public void jsonMergeReplaceValueTest() throws Fault { - MergeReplaceValue replaceTest = new MergeReplaceValue(); - final TestResult result = replaceTest.test(); - result.eval(); - } - - /** - * Test JSON-P API response on - * {@see RFC 7396: 1. - * Introduction}: {@code null} values in the merge patch are given special - * meaning to indicate the removal of existing values in the target. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonMergeRemoveValueTest - * @assertion_ids: JSONP:JAVADOC:575; JSONP:JAVADOC:576; JSONP:JAVADOC:616; - * JSONP:JAVADOC:617; JSONP:JAVADOC:654; JSONP:JAVADOC:655; - * @test_Strategy: Test API response on various JSON values. - */ - public void jsonMergeRemoveValueTest() throws Fault { - MergeRemoveValue removeTest = new MergeRemoveValue(); - final TestResult result = removeTest.test(); - result.eval(); - } - - /** - * Test JSON-P API response on - * {@see RFC 7396: 1. - * Introduction}: If the patch is anything other than an object, the - * result will always be to replace the entire target with the entire patch. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonMergeNonObjectTest - * @assertion_ids: JSONP:JAVADOC:575; JSONP:JAVADOC:576; JSONP:JAVADOC:616; - * JSONP:JAVADOC:617; JSONP:JAVADOC:654; JSONP:JAVADOC:655; - * JSONP:JAVADOC:583; JSONP:JAVADOC:584; - * @test_Strategy: Test API response on various JSON values. - */ - public void jsonMergeNonObjectTest() throws Fault { - MergeNonObject nonObjTest = new MergeNonObject(); - final TestResult result = nonObjTest.test(); - result.eval(); - } - - /** - * Test JSON-P API response on Test based on - * {@see RFC 7396: 3. - * Example} objects. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonMergeRFCSampleTest - * @assertion_ids: JSONP:JAVADOC:575; JSONP:JAVADOC:576; JSONP:JAVADOC:616; - * JSONP:JAVADOC:617; JSONP:JAVADOC:654; JSONP:JAVADOC:655; - * @test_Strategy: Test API response on RFC example objects. - */ - public void jsonMergeRFCSampleTest() throws Fault { - MergeRFCSample rfcSampleTest = new MergeRFCSample(); - final TestResult result = rfcSampleTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/mergetests/build.xml b/src/com/sun/ts/tests/jsonp/api/mergetests/build.xml deleted file mode 100644 index a884e74450..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/mergetests/build.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationAdd.java b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationAdd.java deleted file mode 100644 index a67bde7c37..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationAdd.java +++ /dev/null @@ -1,646 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.patchtests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_FALSE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_TRUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObjectReplaced; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayWithBoolAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayWithBoolBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayWithIntAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayWithIntBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayWithObjectAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayWithObjectBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayWithStrAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayWithStrBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2WithStringArrayInTheMiddle; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringInnerArray2; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonPatch; -import jakarta.json.JsonPatchBuilder; -import jakarta.json.JsonPointer; -import jakarta.json.JsonStructure; -import jakarta.json.JsonValue; - -// $Id$ -/** - * RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.
- * {@see RFC 6902}. - *

- * Implements - * {@see RFC 6902: - * 4.1. add} tests. - */ -class PatchOperationAdd extends CommonOperation { - - /** Tested operation name. */ - private final String OPERATION = "ADD"; - - /** - * Creates an instance of RFC 6902 add operation test. - */ - PatchOperationAdd() { - super(); - } - - /** - * Test RFC 6902 add operation. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 6902 add operation"); - TestUtil.logMsg("Testing RFC 6902 add operation:"); - testAddStringOnEmptyObject(result); - testAddStringOnSimpleObject(result); - testAddStringOnEmptyArray(result); - testAddStringOnSimpleArray(result); - testAddStringOnSimpleArray2(result); - testAddIntOnEmptyObject(result); - testAddIntOnSimpleObject(result); - testAddIntOnEmptyArray(result); - testAddIntOnSimpleArray(result); - testAddIntOnSimpleArray2(result); - testAddBooleanOnEmptyObject(result); - testAddBooleanOnSimpleObject(result); - testAddBooleanOnEmptyArray(result); - testAddBooleanOnSimpleArray(result); - testAddBooleanOnSimpleArray2(result); - testAddObjectOnEmptyObject(result); - testAddObjectOnSimpleObject(result); - testAddObjectOnEmptyArray(result); - testAddObjectOnSimpleArray(result); - testAddObjectOnSimpleArray2(result); - testAddArrayToReplaceObject(result); - testAddArrayToReplaceDocument(result); - testAddStringArrayToStringArray(result); - testAddStringToNonExistingObject(result); - return result; - } - - /** - * Test RFC 6902 add operation for {@code String} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testAddStringOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for String on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject check = createSimpleObjectStr(); - simpleOperation(result, in, check, STR_PATH, STR_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code String} on empty JSON array. Only - * allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testAddStringOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for String on empty JSON array"); - final JsonArray in = createEmptyArray(); - final JsonArray check = createEmptyArrayWithStr(); - simpleOperation(result, in, check, "/0", STR_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testAddStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject check = createSimpleObjectWithStr(); - simpleOperation(result, in, check, STR_PATH, STR_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code String} on simple JSON array. Using - * index {@code 0} to add {@code String} before already existing element and - * index {@code 1} to add {@code String} after already existing element. - * - * @param result - * Tests result record. - */ - private void testAddStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 1"); - final JsonArray in = createStringArray1(); - final JsonArray checkBefore = createSimpleStringArrayWithStrBefore(); - final JsonArray checkAfter = createSimpleStringArrayWithStrAfter(); - // Add before. - simpleOperation(result, in, checkBefore, "/0", STR_VALUE); - // Add after. - simpleOperation(result, in, checkAfter, "/1", STR_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code String}s on simple JSON array. - * Starting with an array of size 2. - *

    - *
  • Adding {@code String} at the end, in the middle and at the beginning of - * this array. - *
  • Adding {@code String} at the beginning, in the middle and at the end of - * this array. - *
- * - * @param result - * Tests result record. - */ - private void testAddStringOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 2"); - final JsonArray in = createStringArray2(); - final JsonArray check = createSimpleStringArray5(); - complexOperation(result, in, check, new String[] { "/2", "/1", "/0" }, - new String[] { STR_VALUE_5, STR_VALUE_3, STR_VALUE_1 }); - complexOperation(result, in, check, new String[] { "/0", "/2", "/4" }, - new String[] { STR_VALUE_1, STR_VALUE_3, STR_VALUE_5 }); - } - - /** - * Test RFC 6902 add operation for {@code int} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testAddIntOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for int on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject check = createSimpleObjectInt(); - simpleOperation(result, in, check, INT_PATH, INT_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code int} on empty JSON array. Only - * allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testAddIntOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for int on empty JSON array"); - final JsonArray in = createEmptyArray(); - final JsonArray check = createEmptyArrayWithInt(); - simpleOperation(result, in, check, "/0", INT_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testAddIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject check = createSimpleObjectWithInt(); - simpleOperation(result, in, check, INT_PATH, INT_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code int} on simple JSON array. Using - * index {@code 0} to add {@code int} before already existing element and - * index {@code 1} to add {@code int} after already existing element. - * - * @param result - * Tests result record. - */ - private void testAddIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 1"); - final JsonArray in = createIntArray1(); - final JsonArray checkBefore = createSimpleIntArrayWithIntBefore(); - final JsonArray checkAfter = createSimpleIntArrayWithIntAfter(); - // Add before. - simpleOperation(result, in, checkBefore, "/0", INT_VALUE); - // Add after. - simpleOperation(result, in, checkAfter, "/1", INT_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code int}s on simple JSON array. Starting - * with an array of size 2. - *
    - *
  • Adding {@code int} at the end, in the middle and at the beginning of - * this array. - *
  • Adding {@code int} at the beginning, in the middle and at the end of - * this array. - *
- * - * @param result - * Tests result record. - */ - private void testAddIntOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 2"); - final JsonArray in = createIntArray2(); - final JsonArray check = createSimpleIntArray5(); - complexOperation(result, in, check, new String[] { "/2", "/1", "/0" }, - new Integer[] { INT_VALUE_5, INT_VALUE_3, INT_VALUE_1 }); - complexOperation(result, in, check, new String[] { "/0", "/2", "/4" }, - new Integer[] { INT_VALUE_1, INT_VALUE_3, INT_VALUE_5 }); - } - - /** - * Test RFC 6902 add operation for {@code boolean} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testAddBooleanOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject check = createSimpleObjectBool(); - simpleOperation(result, in, check, BOOL_PATH, BOOL_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code boolean} on empty JSON array. Only - * allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testAddBooleanOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on empty JSON array"); - final JsonArray in = createEmptyArray(); - final JsonArray check = createEmptyArrayWithBool(); - simpleOperation(result, in, check, "/0", BOOL_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testAddBooleanOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject check = createSimpleObjectWithBool(); - simpleOperation(result, in, check, BOOL_PATH, BOOL_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code boolean} on simple JSON array. Using - * index {@code 0} to add {@code boolean} before already existing element and - * index {@code 1} to add {@code boolean} after already existing element. - * - * @param result - * Tests result record. - */ - private void testAddBooleanOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 1"); - final JsonArray in = createBoolArray1(); - final JsonArray checkBefore = createSimpleBoolArrayWithBoolBefore(); - final JsonArray checkAfter = createSimpleBoolArrayWithBoolAfter(); - // Add before. - simpleOperation(result, in, checkBefore, "/0", BOOL_FALSE); - // Add after. - simpleOperation(result, in, checkAfter, "/1", BOOL_FALSE); - } - - /** - * Test RFC 6902 add operation for {@code boolean}s on simple JSON array. - * Starting with an array of size 2. - *
    - *
  • Adding {@code boolean} at the end, in the middle and at the beginning - * of this array. - *
  • Adding {@code boolean} at the beginning, in the middle and at the end - * of this array. - *
- * - * @param result - * Tests result record. - */ - private void testAddBooleanOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 2"); - final JsonArray in = createBoolArray2(); - final JsonArray check = createSimpleBoolArray5(); - complexOperation(result, in, check, new String[] { "/2", "/1", "/0" }, - new Boolean[] { BOOL_TRUE, BOOL_TRUE, BOOL_FALSE }); - complexOperation(result, in, check, new String[] { "/0", "/2", "/4" }, - new Boolean[] { BOOL_FALSE, BOOL_TRUE, BOOL_TRUE }); - } - - /** - * Test RFC 6902 add operation for {@code JsonObject} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testAddObjectOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject check = createSimpleObjectObject(); - simpleOperation(result, in, check, OBJ_PATH, OBJ_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code JsonObject} on empty JSON array. - * Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testAddObjectOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on empty JSON array"); - final JsonArray in = createEmptyArray(); - final JsonArray check = createEmptyArrayWithObject(); - simpleOperation(result, in, check, "/0", OBJ_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code JsonObject} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testAddObjectOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createCompoundObject(); - final JsonObject check = createCompoundObjectWithObject(); - simpleOperation(result, in, check, OBJ_PATH, OBJ_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code JsonObject} on simple JSON array. - * Using index {@code 0} to add {@code JsonObject} before already existing - * element and index {@code 1} to add {@code JsonObject} after already - * existing element. - * - * @param result - * Tests result record. - */ - private void testAddObjectOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 1"); - final JsonArray in = createObjectArray1(); - final JsonArray checkBefore = createSimpleObjectArrayWithObjectBefore(); - final JsonArray checkAfter = createSimpleObjectArrayWithObjectAfter(); - // Add before. - simpleOperation(result, in, checkBefore, "/0", OBJ_VALUE); - // Add after. - simpleOperation(result, in, checkAfter, "/1", OBJ_VALUE); - } - - /** - * Test RFC 6902 add operation for {@code JsonObject}s on simple JSON array. - * Starting with an array of size 2. - *
    - *
  • Adding {@code JsonObject} at the end, in the middle and at the - * beginning of this array. - *
  • Adding {@code JsonObject} at the beginning, in the middle and at the - * end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testAddObjectOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 2"); - final JsonArray in = createObjectArray2(); - final JsonArray check = createSimpleObjectArray5(); - complexOperation(result, in, check, new String[] { "/2", "/1", "/0" }, - new JsonObject[] { OBJ_VALUE_5, OBJ_VALUE_3, OBJ_VALUE_1 }); - complexOperation(result, in, check, new String[] { "/0", "/2", "/4" }, - new JsonObject[] { OBJ_VALUE_1, OBJ_VALUE_3, OBJ_VALUE_5 }); - } - - // Tests based on RFC 6902 definitions and examples. - - /** - * Test that existing target object is replaced by specified array when ADD - * operation is applied. - * {@see RFC 6902: - * 4.1. add}:
- * When the operation is applied, the target location MUST reference one of: - *
    - *
  • A member to add to an existing object - whereupon the supplied value is - * added to that object at the indicated location. If the member already - * exists, it is replaced by the specified value.
  • - *
  • ...
  • - *
- */ - private void testAddArrayToReplaceObject(final TestResult result) { - TestUtil.logMsg(" - for JsonArray to replace JsonObject"); - final JsonObject in = createCompoundObject(); - final JsonObject check = createCompoundObjectWithObjectReplaced(); - final JsonArray value = createSimpleStringArray5(); - simpleOperation(result, in, check, DEF_OBJ_PATH, value); - } - - /** - * Test that whole document is replaced by specified array when ADD operation - * is applied with root pointer. - * {@see RFC 6902: - * 4.1. add}:
- * When the operation is applied, the target location MUST reference one of: - *
    - *
  • The root of the target document - whereupon the specified value becomes - * the entire content of the target document.
  • - *
  • ...
  • - *
- */ - private void testAddArrayToReplaceDocument(final TestResult result) { - TestUtil.logMsg(" - for JsonArray to replace whole document"); - final JsonObject in = createCompoundObject(); - final JsonArray check = createSimpleStringArray5(); - final JsonArray value = createSimpleStringArray5(); - // Instance being replaced is JsonObject, instance being added is JsonArray. - // The only API method allowing - // this is the one working with JsonStructure. New builder instance is used - // for each of the cases. - final JsonPatch patch1 = builderAdd(Json.createPatchBuilder(), "", value) - .build(); - final JsonValue out1 = patch1.apply((JsonStructure) in); - if (!assertEquals(check, out1)) { - final String className = value.getClass().getSimpleName(); - result.fail("ADD " + className + " to compound object", - "ADD operation for " + className + " failed on compound value"); - } - } - - /** - * Test ADD operation of an array of {@code String}s into existing array of - * {@code String}s. This scenario is inspired by - * {@see RFC 6902: - * 4.1. add} operation example {@code { "op": "add", "path": "/a/b/c", - * "value": [ "foo", "bar" ] }} and following explanation of this operation on - * an array: - *
    - *
  • An element to add to an existing array - whereupon the supplied value - * is added to the array at the indicated location. Any elements at or above - * the specified index are shifted one position to the right. The specified - * index MUST NOT be greater than the number of elements in the array. If the - * "-" character is used to index the end of the array (see [RFC6901]), this - * has the effect of appending the value to the array.
  • - *
- */ - private void testAddStringArrayToStringArray(final TestResult result) { - TestUtil.logMsg(" - for String array to be added to existing String array"); - final JsonArray in = createStringArray2(); - final JsonArray check = createStringArray2WithStringArrayInTheMiddle(); - final JsonArray value = createStringInnerArray2(); - simpleOperation(result, in, check, "/1", value); - } - - /** - * Test ADD operation on non existing JsonObject. This scenario is described - * in {@see RFC - * 6902: 4.1. add} error handling samples. Test is trying to ADD value { - * "address" : "In a galaxy far far away"} into object { "name" : "John Smith" - * } using path "/child/address". Even "/child" path does not exist so this - * operation must fail. - * - */ - private void testAddStringToNonExistingObject(final TestResult result) { - TestUtil.logMsg(" - for String to be added to non existing JsonObject"); - final JsonObject in = createSimpleObject(); - final JsonValue value = Json.createValue(STR_VALUE); - final String path = DEF_OBJ_PATH + STR_PATH; - final JsonPointer ptr = Json.createPointer(path); - simpleOperationFail(result, in, path, value); - } - - /** - * Tested operation name {@code "MOVE"}. - * - * @return Operation name to be used in logs. - */ - @Override - protected String operationName() { - return OPERATION; - } - - /** - * Create and initialize patch builder to contain ADD operation to be applied. - * - * @param path - * JSON path of value to be added. - * @param value - * JSON Value to be added. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder createOperationBuilder(final String path, - final Object value) { - return builderAdd(Json.createPatchBuilder(), path, value); - } - - /** - * Update patch builder to contain next ADD operation to be applied. - * - * @param builder - * JSON patch builder to update. - * @param path - * JSON path of value to be added. - * @param value - * JSON Value to be added. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder updateOperationBuilder( - final JsonPatchBuilder builder, final String path, final Object value) { - return builderAdd(builder, path, value); - } - - /** - * Add {@code value} at {@code path} to provided JSON patch builder. - * - * @param builder - * Target JSON patch builder. - * @param path - * JSON path of value to be added. - * @param value - * Value to be added at given JSON path. - * @return JSON patch builder containing new {@code value} at {@code path} - * added. - */ - @SuppressWarnings("UnnecessaryUnboxing") - private static JsonPatchBuilder builderAdd(final JsonPatchBuilder builder, - final String path, final Object value) { - switch (JsonValueType.getType(value.getClass())) { - case String: - return builder.add(path, (String) value); - case Integer: - return builder.add(path, ((Integer) value).intValue()); - case Boolean: - return builder.add(path, ((Boolean) value).booleanValue()); - case JsonValue: - return builder.add(path, (JsonValue) value); - default: - throw new IllegalArgumentException( - "Value does not match known JSON value type"); - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationCopy.java b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationCopy.java deleted file mode 100644 index f1db12db39..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationCopy.java +++ /dev/null @@ -1,336 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.patchtests; - -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2Copy0to1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2Copy0to2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2Copy1to0; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectCopyValue; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2Copy0to1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2Copy0to2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2Copy1to0; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2Copy0to1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2Copy0to2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2Copy1to0; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectCopyBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectCopyInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectCopyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectCopyStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2Copy0to1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2Copy0to2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2Copy1to0; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonPatchBuilder; - -// $Id$ -/** - * RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.
- * {@see RFC 6902}. - *

- * Implements - * {@see RFC 6902: - * 4.5. copy} tests. - */ -public class PatchOperationCopy extends CommonOperation { - - /** Tested operation name. */ - private final String OPERATION = "COPY"; - - /** - * Creates an instance of RFC 6902 replace operation test. - */ - PatchOperationCopy() { - super(); - } - - /** - * Test RFC 6902 COPY operation. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 6902 copy operation"); - TestUtil.logMsg("Testing RFC 6902 copy operation:"); - testCopyStringOnSimpleObject(result); - testCopyStringOnSimpleArray(result); - testCopyIntOnSimpleObject(result); - testCopyIntOnSimpleArray(result); - testCopyBoolOnSimpleObject(result); - testCopyBoolOnSimpleArray(result); - testCopyObjectOnSimpleObject(result); - testCopyObjectOnSimpleArray(result); - testCopyStringOnCompoundObject(result); - testCopyOfNonExistingLocationInObject(result); - testCopyOfNonExistingLocationInArray(result); - - return result; - } - - /** - * Test RFC 6902 COPY operation for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testCopyStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObjectStr(); - final JsonObject check = createSimpleObjectCopyStr(); - simpleOperation(result, in, check, STR_PATH, DEF_PATH); - } - - /** - * Test RFC 6902 COPY operation for {@code String} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testCopyStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 2"); - final JsonArray in = createStringArray2(); - simpleOperation(result, in, createStringArray2Copy1to0(), "/1", "/0"); - simpleOperation(result, in, createStringArray2Copy0to2(), "/0", "/2"); - simpleOperation(result, in, createStringArray2Copy0to1(), "/0", "/1"); - } - - /** - * Test RFC 6902 COPY operation for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testCopyIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObjectInt(); - final JsonObject check = createSimpleObjectCopyInt(); - simpleOperation(result, in, check, INT_PATH, DEF_PATH); - } - - /** - * Test RFC 6902 COPY operation for {@code int} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testCopyIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 2"); - final JsonArray in = createIntArray2(); - simpleOperation(result, in, createIntArray2Copy1to0(), "/1", "/0"); - simpleOperation(result, in, createIntArray2Copy0to2(), "/0", "/2"); - simpleOperation(result, in, createIntArray2Copy0to1(), "/0", "/1"); - } - - /** - * Test RFC 6902 COPY operation for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testCopyBoolOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObjectBool(); - final JsonObject check = createSimpleObjectCopyBool(); - simpleOperation(result, in, check, BOOL_PATH, DEF_PATH); - } - - /** - * Test RFC 6902 COPY operation for {@code boolean} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testCopyBoolOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 2"); - final JsonArray in = createBoolArray2(); - simpleOperation(result, in, createBoolArray2Copy1to0(), "/1", "/0"); - simpleOperation(result, in, createBoolArray2Copy0to2(), "/0", "/2"); - simpleOperation(result, in, createBoolArray2Copy0to1(), "/0", "/1"); - } - - /** - * Test RFC 6902 COPY operation for {@code JsonObject} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testCopyObjectOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createSimpleObjectObject(); - final JsonObject check = createSimpleObjectCopyObject(); - simpleOperation(result, in, check, OBJ_PATH, DEF_PATH); - } - - /** - * Test RFC 6902 COPY operation for {@code JsonObject} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testCopyObjectOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 2"); - final JsonArray in = createObjectArray2(); - simpleOperation(result, in, createObjectArray2Copy1to0(), "/1", "/0"); - simpleOperation(result, in, createObjectArray2Copy0to2(), "/0", "/2"); - simpleOperation(result, in, createObjectArray2Copy0to1(), "/0", "/1"); - } - - /** - * Test RFC 6902 COPY operation for {@code String} on compound JSON object. - * Copied value overwrites an existing value. - * - * @param result - * Tests result record. - */ - private void testCopyStringOnCompoundObject(final TestResult result) { - TestUtil.logMsg(" - for String on compound JSON object"); - final JsonObject in = createCompoundObject(); - final JsonObject check = createCompoundObjectCopyValue(); - simpleOperation(result, in, check, DEF_PATH, DEF_OBJ_PATH + DEF_PATH); - } - - // Tests based on RFC 6902 definitions and examples. - - /** - * Test RFC 6902 COPY operation for non existing location in object. - * {@see RFC 6902: - * 4.5. copy} defines:
- * The "from" location MUST exist for the operation to be successful. - */ - private void testCopyOfNonExistingLocationInObject(final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonObject"); - final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(), - createSimpleObject(), createCompoundObject() }; - final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH, - OBJ_PATH }; - final Object[] values = new Object[] { OBJ_PATH, BOOL_PATH, INT_PATH, - STR_PATH }; - // Go trough all objects - for (int i = 0; i < objsIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - simpleOperationFail(result, objsIn[i], paths[j], values[i]); - } - } - } - - /** - * Test RFC 6902 COPY operation for non existing location in array. - * {@see RFC 6902: - * 4.5. copy} defines:
- * The "from" location MUST exist for the operation to be successful. - */ - private void testCopyOfNonExistingLocationInArray(final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonArray"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray1(), createIntArray2(), createSimpleBoolArray5(), - createObjectArray2() }; - final String[] paths = new String[] { "/", "/-1", "/-", "/5", "/0a", "/42", - STR_PATH + "/0" }; - final Object[] values = new Object[] { "/0", "/1", "/2", "/5", "/1" }; - // Go trough all arrays - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - simpleOperationFail(result, arraysIn[i], paths[j], values[i]); - } - } - } - - /** - * Tested operation name {@code "COPY"}. - * - * @return Operation name to be used in logs. - */ - @Override - protected String operationName() { - return OPERATION; - } - - /** - * Create and initialize patch builder to contain COPY operation to be - * applied. - * - * @param path - * Source JSON path of COPY operation. - * @param value - * Target JSON path of COPY operation. Must be instance of - * {@link String}. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder createOperationBuilder(final String path, - final Object value) { - if (value instanceof String) { - // TestUtil.logMsg(" COPY "+path+" -> "+(String)value); - return Json.createPatchBuilder().copy((String) value, path); - } else { - throw new IllegalArgumentException( - "Argument \"value\" is not an instance of String"); - } - } - - /** - * Update patch builder to contain next COPY operation to be applied. - * - * @param builder - * JSON patch builder to update. - * @param path - * Source JSON path of COPY operation. - * @param value - * Target JSON path of COPY operation. Must be instance of - * {@link String}. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder updateOperationBuilder( - final JsonPatchBuilder builder, final String path, final Object value) { - if (value instanceof String) { - // TestUtil.logMsg(" COPY "+path+" -> "+(String)value); - return builder.copy((String) value, path); - } else { - throw new IllegalArgumentException( - "Argument \"value\" is not an instance of String"); - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationEnum.java b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationEnum.java deleted file mode 100644 index 2d7f33fb96..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationEnum.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2017, 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 com.sun.ts.tests.jsonp.api.patchtests; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.JsonPatch; - -// $Id$ -/** - * RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.
- * {@see RFC 6902}. - *

- * Test {@link JsonPatch.Operation} enumeration. - */ -public class PatchOperationEnum { - - /** - * Creates an instance of {@link JsonPatch.Operation} enumeration test. - */ - PatchOperationEnum() { - super(); - } - - /** - * Test {@link JsonPatch.Operation} enumeration. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "JsonPatch.Operation enumeration test"); - TestUtil.logMsg("JsonPatch.Operation enumeration test"); - testOperationName(result); - testOperationValueOf(result); - return result; - } - - /** - * Test {@link JsonPatch.Operation#fromOperationName(String)} and - * {@link JsonPatch.Operation#operationName()} methods. - * - * @param result - * Tests result record. - */ - private void testOperationName(final TestResult result) { - TestUtil.logMsg(" - fromOperationName(String) and operationName(String)"); - for (final JsonPatch.Operation op : JsonPatch.Operation.values()) { - final String opName = op.operationName(); - final JsonPatch.Operation opOut = JsonPatch.Operation - .fromOperationName(opName); - final int opNameLen = opName.length(); - boolean opNameLc = true; - for (int i = 0; opNameLc && i < opNameLen; i++) { - opNameLc = Character.isLowerCase(opName.charAt(i)); - } - if (!opNameLc) { - result.fail("operationName(String)", - "Returned value " + opName + " is not lower case String"); - } - if (op != opOut) { - result.fail("fromOperationName(String) and operationName(String)", - "Returned operation " + opOut.name() + " shall be " + op.name()); - } - } - } - - /** - * Test {@code JsonPatch.Operation#valueOf(String)} method. - * - * @param result - * Tests result record. - */ - private void testOperationValueOf(final TestResult result) { - TestUtil.logMsg(" - valueOf(String)"); - for (final JsonPatch.Operation op : JsonPatch.Operation.values()) { - final String opName = op.name(); - final JsonPatch.Operation opOut = JsonPatch.Operation.valueOf(opName); - if (op != opOut) { - result.fail("valueOf(String)", - "Returned operation " + opOut.name() + " shall be " + op.name()); - } - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationMove.java b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationMove.java deleted file mode 100644 index be697e8f55..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationMove.java +++ /dev/null @@ -1,492 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.patchtests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectMoveValue; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectMoveBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectMoveInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectMoveObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectMoveStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2R; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonPatch; -import jakarta.json.JsonPatchBuilder; -import jakarta.json.JsonPointer; -import jakarta.json.JsonValue; - -// $Id$ -/** - * RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.
- * {@see RFC 6902}. - *

- * Implements - * {@see RFC 6902: - * 4.4. move} tests. - */ -public class PatchOperationMove extends CommonOperation { - - /** Tested operation name. */ - private final String OPERATION = "MOVE"; - - /** - * Creates an instance of RFC 6902 replace operation test. - */ - PatchOperationMove() { - super(); - } - - /** - * Test RFC 6902 MOVE operation. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 6902 move operation"); - TestUtil.logMsg("Testing RFC 6902 move operation:"); - testMoveStringOnSimpleObject(result); - testMoveStringOnSimpleArray(result); - testMoveStringOnSimpleArray2(result); - testMoveIntOnSimpleObject(result); - testMoveIntOnSimpleArray(result); - testMoveIntOnSimpleArray2(result); - testMoveBoolOnSimpleObject(result); - testMoveBoolOnSimpleArray(result); - testMoveBoolOnSimpleArray2(result); - testMoveObjectOnSimpleObject(result); - testMoveObjectOnSimpleArray(result); - testMoveObjectOnSimpleArray2(result); - testMoveStringOnCompoundObject(result); - testMoveOfNonExistingLocationInObject(result); - testMoveOfNonExistingLocationInArray(result); - testMoveVsRemoveAddOnSelfContainedPath(result); - return result; - } - - /** - * Test RFC 6902 MOVE operation for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testMoveStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObjectStr(); - final JsonObject check = createSimpleObjectMoveStr(); - simpleOperation(result, in, check, STR_PATH, DEF_PATH); - } - - /** - * Test RFC 6902 MOVE operation for {@code String} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testMoveStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 2"); - final JsonArray in = createStringArray2(); - final JsonArray check = createStringArray2R(); - simpleOperation(result, in, in, "/0", "/0"); - simpleOperation(result, in, check, "/1", "/0"); - simpleOperation(result, in, check, "/0", "/1"); - simpleOperation(result, in, check, "/0", "/-"); - } - - /** - * Test RFC 6902 MOVE operation for {@code String} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testMoveStringOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 5"); - final JsonArray in = createSimpleStringArray5(); - final JsonArray check = createSimpleStringArray5R(); - complexOperation(result, in, check, new String[] { "/3", "/0", "/3", "/4" }, - new String[] { "/1", "/2", "/1", "/0" }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/0", "/2" }, - new String[] { "/-", "/2", "/3", "/0" }); - } - - /** - * Test RFC 6902 MOVE operation for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testMoveIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObjectInt(); - final JsonObject check = createSimpleObjectMoveInt(); - simpleOperation(result, in, check, INT_PATH, DEF_PATH); - } - - /** - * Test RFC 6902 MOVE operation for {@code int} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testMoveIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 2"); - final JsonArray in = createIntArray2(); - final JsonArray check = createIntArray2R(); - simpleOperation(result, in, in, "/0", "/0"); - simpleOperation(result, in, check, "/1", "/0"); - simpleOperation(result, in, check, "/0", "/1"); - simpleOperation(result, in, check, "/0", "/-"); - } - - /** - * Test RFC 6902 MOVE operation for {@code int} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testMoveIntOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 5"); - final JsonArray in = createSimpleIntArray5(); - final JsonArray check = createSimpleIntArray5R(); - complexOperation(result, in, check, new String[] { "/3", "/0", "/3", "/4" }, - new String[] { "/1", "/2", "/1", "/0" }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/0", "/2" }, - new String[] { "/-", "/2", "/3", "/0" }); - } - - /** - * Test RFC 6902 MOVE operation for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testMoveBoolOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObjectBool(); - final JsonObject check = createSimpleObjectMoveBool(); - simpleOperation(result, in, check, BOOL_PATH, DEF_PATH); - } - - /** - * Test RFC 6902 MOVE operation for {@code boolean} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testMoveBoolOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 2"); - final JsonArray in = createBoolArray2(); - final JsonArray check = createBoolArray2R(); - simpleOperation(result, in, in, "/0", "/0"); - simpleOperation(result, in, check, "/1", "/0"); - simpleOperation(result, in, check, "/0", "/1"); - simpleOperation(result, in, check, "/0", "/-"); - } - - /** - * Test RFC 6902 MOVE operation for {@code boolean} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testMoveBoolOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 5"); - final JsonArray in = createSimpleBoolArray5(); - final JsonArray check = createSimpleBoolArray5R(); - complexOperation(result, in, check, new String[] { "/3", "/0", "/3", "/4" }, - new String[] { "/1", "/2", "/1", "/0" }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/0", "/2" }, - new String[] { "/-", "/2", "/3", "/0" }); - } - - /** - * Test RFC 6902 MOVE operation for {@code JsonObject} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testMoveObjectOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createSimpleObjectObject(); - final JsonObject check = createSimpleObjectMoveObject(); - simpleOperation(result, in, check, OBJ_PATH, DEF_PATH); - } - - /** - * Test RFC 6902 MOVE operation for {@code JsonObject} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testMoveObjectOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 2"); - final JsonArray in = createObjectArray2(); - final JsonArray check = createObjectArray2R(); - simpleOperation(result, in, in, "/0", "/0"); - simpleOperation(result, in, check, "/1", "/0"); - simpleOperation(result, in, check, "/0", "/1"); - simpleOperation(result, in, check, "/0", "/-"); - } - - /** - * Test RFC 6902 MOVE operation for {@code JsonObject} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testMoveObjectOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 5"); - final JsonArray in = createSimpleObjectArray5(); - final JsonArray check = createSimpleObjectArray5R(); - complexOperation(result, in, check, new String[] { "/3", "/0", "/3", "/4" }, - new String[] { "/1", "/2", "/1", "/0" }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/0", "/2" }, - new String[] { "/-", "/2", "/3", "/0" }); - } - - /** - * Test RFC 6902 MOVE operation for {@code String} on compound JSON object. - * Moved value overwrites an existing value. - * - * @param result - * Tests result record. - */ - private void testMoveStringOnCompoundObject(final TestResult result) { - TestUtil.logMsg(" - for String on compound JSON object"); - final JsonObject in = createCompoundObject(); - final JsonObject check = createCompoundObjectMoveValue(); - simpleOperation(result, in, check, DEF_PATH, DEF_OBJ_PATH + DEF_PATH); - } - - // Tests based on RFC 6902 definitions and examples. - - /** - * Test RFC 6902 MOVE operation for non existing location in object. - * {@see RFC 6902: - * 4.4. move} defines:
- * The "from" location MUST exist for the operation to be successful. - */ - private void testMoveOfNonExistingLocationInObject(final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonObject"); - final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(), - createSimpleObject(), createCompoundObject() }; - final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH, - OBJ_PATH }; - final Object[] values = new Object[] { OBJ_PATH, BOOL_PATH, INT_PATH, - STR_PATH }; - // Go trough all objects - for (int i = 0; i < objsIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - simpleOperationFail(result, objsIn[i], paths[j], values[i]); - } - } - } - - /** - * Test RFC 6902 MOVE operation for non existing location in array. - * {@see RFC 6902: - * 4.4. move} defines:
- * The "from" location MUST exist for the operation to be successful. - */ - private void testMoveOfNonExistingLocationInArray(final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonArray"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray1(), createIntArray2(), createSimpleBoolArray5(), - createObjectArray2() }; - final String[] paths = new String[] { "/", "/-1", "/-", "/5", "/0a", "/42", - STR_PATH + "/0" }; - final Object[] values = new Object[] { "/0", "/1", "/2", "/5", "/1" }; - // Go trough all arrays - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - simpleOperationFail(result, arraysIn[i], paths[j], values[i]); - } - } - } - - /** - * Test RFC 6902 MOVE operation for moving existing path into path containing - * source path as a prefix. - * {@see RFC 6902: - * 4.4. move} defines:
- * This operation is functionally identical to a "remove" operation on the - * "from" location, followed immediately by an "add" operation at the target - * location with the value that was just removed. - * {@see RFC 6901: 7. - * Error Handling} defines:
- * This specification does not define how errors are handled. An application - * of JSON Pointer SHOULD specify the impact and handling of each type of - * error.
- * For example, some applications might stop pointer processing upon an error, - * while others may attempt to recover from missing values by inserting - * default ones.
- * This means, that such an operation may fail on non existing target "path" - * after ADD operation, but also missing pointer error recovery may take care - * of creating missing "path" elements. In both cases MOVE and sequence of - * REMOVE and ADD operations MUST produce the same result. - */ - private void testMoveVsRemoveAddOnSelfContainedPath(final TestResult result) { - TestUtil.logMsg(" - for moving JsonObject under itself"); - final JsonObject in = createCompoundObject(); - final String targetPath = DEF_OBJ_PATH + DEF_PATH; - final JsonPointer ptr = Json.createPointer(DEF_OBJ_PATH); - final JsonValue value = ptr.getValue(in); - final JsonPatchBuilder moveBuilder = Json.createPatchBuilder() - .move(targetPath, DEF_OBJ_PATH); - final JsonPatchBuilder remAddBuilder = Json.createPatchBuilder() - .remove(DEF_OBJ_PATH).add(targetPath, value); - final JsonPatch movePatch = moveBuilder.build(); - final JsonPatch remAddPatch = remAddBuilder.build(); - // Check REMOVE and ADD sequence first. - JsonObject remAddOut; - try { - - remAddOut = remAddPatch.apply(in); - TestUtil.logMsg(" REMOVE and ADD passed"); - } catch (JsonException e) { - remAddOut = null; - TestUtil.logMsg(" REMOVE and ADD failed: " + e.getMessage()); - } - // Check MOVE second - JsonObject moveOut; - try { - moveOut = movePatch.apply(in); - TestUtil.logMsg(" MOVE passed"); - } catch (JsonException e) { - moveOut = null; - TestUtil.logMsg(" MOVE failed: " + e.getMessage()); - } - // Results evaluation - if (remAddOut != null) { - // Both output values are not null: Compare them - if (moveOut != null) { - if (!assertEquals(remAddOut, moveOut)) { - result.fail("MOVE vs REMOVE and ADD", - "Returned values are not equal"); - } - // REMOVE and ADD output is not null but MOVE output is null - } else { - result.fail("MOVE vs REMOVE and ADD", - "REMOVE and ADD failed but MOVE dit not"); - } - } else { - // REMOVE and ADD output is null but MOVE output is not null - if (moveOut != null) { - result.fail("MOVE vs REMOVE and ADD", - "MOVE failed but REMOVE and ADD dit not"); - } - // else: Both output values are null: both patch operations failed -> test - // passed - } - } - - /** - * Tested operation name {@code "MOVE"}. - * - * @return Operation name to be used in logs. - */ - @Override - protected String operationName() { - return OPERATION; - } - - /** - * Create and initialize patch builder to contain MOVE operation to be - * applied. - * - * @param path - * Source JSON path of MOVE operation. - * @param value - * Target JSON path of MOVE operation. Must be instance of - * {@link String}. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder createOperationBuilder(final String path, - final Object value) { - if (value instanceof String) { - // TestUtil.logMsg(" MOVE "+path+" -> "+(String)value); - return Json.createPatchBuilder().move((String) value, path); - } else { - throw new IllegalArgumentException( - "Argument \"value\" is not an instance of String"); - } - } - - /** - * Update patch builder to contain next MOVE operation to be applied. - * - * @param builder - * JSON patch builder to update. - * @param path - * Source JSON path of MOVE operation. - * @param value - * Target JSON path of MOVE operation. Must be instance of - * {@link String}. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder updateOperationBuilder( - final JsonPatchBuilder builder, final String path, final Object value) { - if (value instanceof String) { - // TestUtil.logMsg(" MOVE "+path+" -> "+(String)value); - return builder.move((String) value, path); - } else { - throw new IllegalArgumentException( - "Argument \"value\" is not an instance of String"); - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationRemove.java b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationRemove.java deleted file mode 100644 index 34cabf638c..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationRemove.java +++ /dev/null @@ -1,532 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.patchtests; - -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayWithBoolAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayWithBoolBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayWithIntAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayWithIntBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayWithObjectAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayWithObjectBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayWithStrAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayWithStrBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonPatchBuilder; - -// $Id$ -/* - * RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.
- * {@see RFC 6902}. - *

- * Implements {@see RFC 6902: 4.2. remove} - * tests. - */ -public class PatchOperationRemove extends CommonOperation { - - /** Tested operation name. */ - private final String OPERATION = "REMOVE"; - - /** - * Creates an instance of RFC 6902 remove operation test. - */ - PatchOperationRemove() { - super(); - } - - /** - * Test RFC 6902 remove operation. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 6902 remove operation"); - TestUtil.logMsg("Testing RFC 6902 remove operation:"); - testRemoveStringOnEmptyObject(result); - testRemoveStringOnEmptyArray(result); - testRemoveStringOnSimpleObject(result); - testRemoveStringOnSimpleArray(result); - testRemoveStringOnSimpleArray2(result); - testRemoveIntOnEmptyObject(result); - testRemoveIntOnEmptyArray(result); - testRemoveIntOnSimpleObject(result); - testRemoveIntOnSimpleArray(result); - testRemoveIntOnSimpleArray2(result); - testRemoveBoolOnEmptyObject(result); - testRemoveBoolOnEmptyArray(result); - testRemoveBoolOnSimpleObject(result); - testRemoveBoolOnSimpleArray(result); - testRemoveBoolOnSimpleArray2(result); - testRemoveObjectOnEmptyObject(result); - testRemoveObjectOnEmptyArray(result); - testRemoveObjectOnSimpleObject(result); - testRemoveObjectOnSimpleArray(result); - testRemoveObjectOnSimpleArray2(result); - testRemoveFromNonExistingLocationInObject(result); - testRemoveFromNonExistingLocationInArray(result); - return result; - } - - /** - * Test pointer remove operation for {@code String} to produce empty JSON - * object. - * - * @param result - * Tests result record. - */ - private void testRemoveStringOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for String to produce empty JSON object"); - final JsonObject in = createSimpleObjectStr(); - final JsonObject check = createEmptyObject(); - simpleOperation(result, in, check, STR_PATH, null); - } - - /** - * Test pointer remove operation for {@code String} to produce empty JSON - * array. Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testRemoveStringOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for String to produce empty JSON array"); - final JsonArray in = createEmptyArrayWithStr(); - final JsonArray check = createEmptyArray(); - simpleOperation(result, in, check, "/0", null); - } - - /** - * Test pointer remove operation for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObjectWithStr(); - final JsonObject check = createSimpleObject(); - simpleOperation(result, in, check, STR_PATH, null); - } - - /** - * Test pointer remove operation for {@code String} on simple JSON array of - * size 2. Using index {@code 0} to remove {@code String} before another - * existing element and index {@code 1} to remove {@code String} after another - * existing element. - * - * @param result - * Tests result record. - */ - private void testRemoveStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 2"); - final JsonArray inBefore = createSimpleStringArrayWithStrBefore(); - final JsonArray inAfter = createSimpleStringArrayWithStrAfter(); - final JsonArray check = createStringArray1(); - simpleOperation(result, inBefore, check, "/0", null); - simpleOperation(result, inAfter, check, "/1", null); - } - - /** - * Test pointer REMOVE for {@code String} on simple JSON array of size 5. - * Starting with an array of size 2. - *

    - *
  • Removing {@code String} at the end, at the middle and at the beginning - * of this array. - *
  • Removing {@code String} at the beginning, in the middle and at the end - * of this array. - *
- * - * @param result - * Tests result record. - */ - private void testRemoveStringOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 5"); - final JsonArray in = createSimpleStringArray5(); - final JsonArray check = createStringArray2(); - complexOperation(result, in, check, new String[] { "/4", "/2", "/0" }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/2" }); - } - - /** - * Test pointer REMOVE operation for {@code int} to produce empty JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveIntOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for int to produce empty JSON object"); - final JsonObject in = createSimpleObjectInt(); - final JsonObject check = createEmptyObject(); - simpleOperation(result, in, check, INT_PATH, null); - } - - /** - * Test pointer REMOVE operation for {@code int} to produce empty JSON array. - * Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testRemoveIntOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for int to produce empty JSON array"); - final JsonArray in = createEmptyArrayWithInt(); - final JsonArray check = createEmptyArray(); - simpleOperation(result, in, check, "/0", null); - } - - /** - * Test pointer REMOVE operation for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObjectWithInt(); - final JsonObject check = createSimpleObject(); - simpleOperation(result, in, check, INT_PATH, null); - } - - /** - * Test pointer REMOVE operation for {@code int} on simple JSON array of size - * 2. Using index {@code 0} to remove {@code int} before another existing - * element and index {@code 1} to remove {@code int} after another existing - * element. - * - * @param result - * Tests result record. - */ - private void testRemoveIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 2"); - final JsonArray inBefore = createSimpleIntArrayWithIntBefore(); - final JsonArray inAfter = createSimpleIntArrayWithIntAfter(); - final JsonArray check = createIntArray1(); - simpleOperation(result, inBefore, check, "/0", null); - simpleOperation(result, inAfter, check, "/1", null); - } - - /** - * Test pointer REMOVE for {@code int} on simple JSON array of size 5. - * Starting with an array of size 5. - *
    - *
  • Removing {@code int} at the end, at the middle and at the beginning of - * this array. - *
  • Removing {@code int} at the beginning, in the middle and at the end of - * this array. - *
- * - * @param result - * Tests result record. - */ - private void testRemoveIntOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 5"); - final JsonArray in = createSimpleIntArray5(); - final JsonArray check = createIntArray2(); - complexOperation(result, in, check, new String[] { "/4", "/2", "/0" }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/2" }); - } - - /** - * Test pointer REMOVE operation for {@code boolean} to produce empty JSON - * object. - * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for boolean to produce empty JSON object"); - final JsonObject in = createSimpleObjectBool(); - final JsonObject check = createEmptyObject(); - simpleOperation(result, in, check, BOOL_PATH, null); - } - - /** - * Test pointer REMOVE operation for {@code boolean} to produce empty JSON - * array. Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for boolean to produce empty JSON array"); - final JsonArray in = createEmptyArrayWithBool(); - final JsonArray check = createEmptyArray(); - simpleOperation(result, in, check, "/0", null); - } - - /** - * Test pointer REMOVE operation for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObjectWithBool(); - final JsonObject check = createSimpleObject(); - simpleOperation(result, in, check, BOOL_PATH, null); - } - - /** - * Test pointer REMOVE operation for {@code boolean} on simple JSON array of - * size 2. Using index {@code 0} to remove {@code boolean} before another - * existing element and index {@code 1} to remove {@code boolean} after - * another existing element. - * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 2"); - final JsonArray inBefore = createSimpleBoolArrayWithBoolBefore(); - final JsonArray inAfter = createSimpleBoolArrayWithBoolAfter(); - final JsonArray check = createBoolArray1(); - simpleOperation(result, inBefore, check, "/0", null); - simpleOperation(result, inAfter, check, "/1", null); - } - - /** - * Test pointer REMOVE for {@code boolean} on simple JSON array of size 5. - * Starting with an array of size 5. - *
    - *
  • Removing {@code boolean} at the end, at the middle and at the beginning - * of this array. - *
  • Removing {@code boolean} at the beginning, in the middle and at the end - * of this array. - *
- * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 5"); - final JsonArray in = createSimpleBoolArray5(); - final JsonArray check = createBoolArray2(); - complexOperation(result, in, check, new String[] { "/4", "/2", "/0" }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/2" }); - } - - /** - * Test pointer REMOVE operation for {@code JsonObject} to produce empty JSON - * object. - * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject to produce empty JSON object"); - final JsonObject in = createSimpleObjectObject(); - final JsonObject check = createEmptyObject(); - simpleOperation(result, in, check, OBJ_PATH, null); - } - - /** - * Test pointer REMOVE operation for {@code JsonObject} to produce empty JSON - * array. Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject to produce empty JSON array"); - final JsonArray in = createEmptyArrayWithObject(); - final JsonArray check = createEmptyArray(); - simpleOperation(result, in, check, "/0", null); - } - - /** - * Test pointer REMOVE operation for {@code JsonObject} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createCompoundObjectWithObject(); - final JsonObject check = createCompoundObject(); - simpleOperation(result, in, check, OBJ_PATH, null); - } - - /** - * Test pointer REMOVE operation for {@code JsonObject} on simple JSON array - * of size 2. Using index {@code 0} to remove {@code JsonObject} before - * another existing element and index {@code 1} to remove {@code JsonObject} - * after another existing element. - * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 2"); - final JsonArray inBefore = createSimpleObjectArrayWithObjectBefore(); - final JsonArray inAfter = createSimpleObjectArrayWithObjectAfter(); - final JsonArray check = createObjectArray1(); - simpleOperation(result, inBefore, check, "/0", null); - simpleOperation(result, inAfter, check, "/1", null); - } - - /** - * Test pointer REMOVE for {@code JsonObject} on simple JSON array of size 5. - * Starting with an array of size 5. - *
    - *
  • Removing {@code JsonObject} at the end, at the middle and at the - * beginning of this array. - *
  • Removing {@code JsonObject} at the beginning, in the middle and at the - * end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 5"); - final JsonArray in = createSimpleObjectArray5(); - final JsonArray check = createObjectArray2(); - complexOperation(result, in, check, new String[] { "/4", "/2", "/0" }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/2" }); - } - - // Tests based on RFC 6902 definitions and examples. - - /** - * Test pointer REMOVE for non existing location in object. - * {@see RFC 6902: - * 4.2. remove} defines:
- * The target location MUST exist for the operation to be successful. - */ - private void testRemoveFromNonExistingLocationInObject( - final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonObject"); - final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(), - createSimpleObject(), createCompoundObject() }; - final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH, - OBJ_PATH }; - // Go trough all objects - for (int i = 0; i < objsIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - simpleOperationFail(result, objsIn[i], paths[j], null); - } - } - } - - /** - * Test pointer REMOVE for non existing location in array. - * {@see RFC 6902: - * 4.2. remove} defines:
- * The target location MUST exist for the operation to be successful. - */ - private void testRemoveFromNonExistingLocationInArray( - final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonArray"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray1(), createIntArray2(), createSimpleBoolArray5(), - createObjectArray2() - - }; - final String[] paths = new String[] { "/", "/-1", "/-", "/5", "/0a", "/42", - STR_PATH + "/0" }; - // Go trough all arrays - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - simpleOperationFail(result, arraysIn[i], paths[j], null); - } - } - } - - /** - * Tested operation name {@code "REMOVE"}. - * - * @return Operation name to be used in logs. - */ - @Override - protected String operationName() { - return OPERATION; - } - - /** - * Create and initialize patch builder to contain REMOVE operation to be - * applied. - * - * @param path - * JSON path of value to removed. - * @param value - * Not used for REMOVE operation. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder createOperationBuilder(final String path, - final Object value) { - return Json.createPatchBuilder().remove(path); - } - - /** - * Update patch builder to contain next REMOVE operation to be applied. - * - * @param builder - * JSON patch builder to update. - * @param path - * JSON path of value to removed. - * @param value - * Not used for REMOVE operation. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder updateOperationBuilder( - final JsonPatchBuilder builder, final String path, final Object value) { - return builder.remove(path); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationReplace.java b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationReplace.java deleted file mode 100644 index 395bfa6662..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationReplace.java +++ /dev/null @@ -1,453 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.patchtests; - -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_FALSE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_TRUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectReplaceObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayReplaceBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayReplaceInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayReplaceObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectReplaceBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectReplaceInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectReplaceStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayReplaceStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonPatchBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.
- * {@see RFC 6902}. - *

- * Implements - * {@see RFC 6902: - * 4.3. replace} tests. - */ -public class PatchOperationReplace extends CommonOperation { - - /** Tested operation name. */ - private final String OPERATION = "REPLACE"; - - /** - * Creates an instance of RFC 6902 replace operation test. - */ - PatchOperationReplace() { - super(); - } - - /** - * Test RFC 6902 replace operation. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 6902 replace operation"); - TestUtil.logMsg("Testing RFC 6902 replace operation:"); - testReplaceStringOnSimpleObject(result); - testReplaceStringOnSimpleArray(result); - testReplaceStringOnSimpleArray2(result); - testReplaceIntOnSimpleObject(result); - testReplaceIntOnSimpleArray(result); - testReplaceIntOnSimpleArray2(result); - testReplaceBoolOnSimpleObject(result); - testReplaceBoolOnSimpleArray(result); - testReplaceBoolOnSimpleArray2(result); - testReplaceObjectOnCompoundObject(result); - testReplaceObjectOnSimpleArray(result); - testReplaceObjectOnSimpleArray2(result); - testReplaceOfNonExistingLocationInObject(result); - testReplaceOfNonExistingLocationInArray(result); - return result; - } - - /** - * Test pointer replace operation for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testReplaceStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObjectStr(); - final JsonObject check = createSimpleObjectReplaceStr(); - simpleOperation(result, in, check, STR_PATH, STR_VALUE2); - } - - /** - * Test pointer replace operation for {@code String} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testReplaceStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 1"); - final JsonArray in = createStringArray1(); - final JsonArray check = createSimpleStringArrayReplaceStr(); - simpleOperation(result, in, check, "/0", STR_VALUE); - } - - /** - * Test pointer replace operation for {@code String} on simple JSON array of - * size 5. Starting with an array of size 5. - *

    - *
  • Replacing {@code String} items from the end to the beginning of this - * array. - *
  • Replacing {@code String} from the beginning to the end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testReplaceStringOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 5"); - final JsonArray in = createSimpleStringArray5(); - final JsonArray check = createSimpleStringArray5R(); - complexOperation(result, in, check, new String[] { "/4", "/3", "/1", "/0" }, - new String[] { STR_VALUE_1, STR_VALUE_2, STR_VALUE_4, STR_VALUE_5 }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/3", "/4" }, - new String[] { STR_VALUE_5, STR_VALUE_4, STR_VALUE_2, STR_VALUE_1 }); - } - - /** - * Test pointer replace operation for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testReplaceIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObjectInt(); - final JsonObject check = createSimpleObjectReplaceInt(); - simpleOperation(result, in, check, INT_PATH, INT_VALUE2); - } - - /** - * Test pointer replace operation for {@code int} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testReplaceIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 1"); - final JsonArray in = createIntArray1(); - final JsonArray check = createSimpleIntArrayReplaceInt(); - simpleOperation(result, in, check, "/0", INT_VALUE); - } - - /** - * Test pointer replace operation for {@code int} on simple JSON array of size - * 5. Starting with an array of size 5. - *
    - *
  • Replacing {@code int} items from the end to the beginning of this - * array. - *
  • Replacing {@code int} from the beginning to the end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testReplaceIntOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 5"); - final JsonArray in = createSimpleIntArray5(); - final JsonArray check = createSimpleIntArray5R(); - complexOperation(result, in, check, new String[] { "/4", "/3", "/1", "/0" }, - new Integer[] { INT_VALUE_1, INT_VALUE_2, INT_VALUE_4, INT_VALUE_5 }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/3", "/4" }, - new Integer[] { INT_VALUE_5, INT_VALUE_4, INT_VALUE_2, INT_VALUE_1 }); - } - - /** - * Test pointer replace operation for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testReplaceBoolOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObjectBool(); - final JsonObject check = createSimpleObjectReplaceBool(); - simpleOperation(result, in, check, BOOL_PATH, BOOL_VALUE2); - } - - /** - * Test pointer replace operation for {@code boolean} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testReplaceBoolOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 1"); - final JsonArray in = createBoolArray1(); - final JsonArray check = createSimpleBoolArrayReplaceBool(); - simpleOperation(result, in, check, "/0", BOOL_FALSE); - } - - /** - * Test pointer replace operation for {@code boolean} on simple JSON array of - * size 5. Starting with an array of size 5. - *
    - *
  • Replacing {@code boolean} items from the end to the beginning of this - * array. - *
  • Replacing {@code boolean} from the beginning to the end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testReplaceBoolOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 5"); - final JsonArray in = createSimpleBoolArray5(); - final JsonArray check = createSimpleBoolArray5R(); - complexOperation(result, in, check, new String[] { "/4", "/3", "/1", "/0" }, - new Boolean[] { BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, BOOL_TRUE }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/3", "/4" }, - new Boolean[] { BOOL_TRUE, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE }); - } - - /** - * Test pointer replace operation for {@code JsonObject} on compound JSON - * object. - * - * @param result - * Tests result record. - */ - private void testReplaceObjectOnCompoundObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createCompoundObjectWithObject(); - final JsonObject check = createCompoundObjectReplaceObject(); - simpleOperation(result, in, check, OBJ_PATH, OBJ_VALUE2); - } - - /** - * Test pointer replace operation for {@code JsonObject} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testReplaceObjectOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 1"); - final JsonArray in = createObjectArray1(); - final JsonArray check = createSimpleObjectArrayReplaceObject(); - simpleOperation(result, in, check, "/0", OBJ_VALUE); - } - - /** - * Test pointer replace operation for {@code JsonObject} on simple JSON array - * of size 5. Starting with an array of size 5. - *
    - *
  • Replacing {@code JsonObject} items from the end to the beginning of - * this array. - *
  • Replacing {@code JsonObject} from the beginning to the end of this - * array. - *
- * - * @param result - * Tests result record. - */ - private void testReplaceObjectOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 5"); - final JsonArray in = createSimpleObjectArray5(); - final JsonArray check = createSimpleObjectArray5R(); - complexOperation(result, in, check, new String[] { "/4", "/3", "/1", "/0" }, - new JsonObject[] { OBJ_VALUE_1, OBJ_VALUE_2, OBJ_VALUE_4, - OBJ_VALUE_5 }); - complexOperation(result, in, check, new String[] { "/0", "/1", "/3", "/4" }, - new JsonObject[] { OBJ_VALUE_5, OBJ_VALUE_4, OBJ_VALUE_2, - OBJ_VALUE_1 }); - } - - // Tests based on RFC 6902 definitions and examples. - - /** - * Test pointer replace for non existing location in object. - * {@see RFC 6902: - * 4.3. replace} defines:
- * The target location MUST exist for the operation to be successful. - */ - private void testReplaceOfNonExistingLocationInObject( - final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonObject"); - final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(), - createSimpleObject(), createCompoundObject() }; - final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH, - OBJ_PATH }; - final Object[] values = new Object[] { STR_VALUE, INT_VALUE, BOOL_VALUE, - OBJ_VALUE }; - // Go trough all objects - for (int i = 0; i < objsIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - simpleOperationFail(result, objsIn[i], paths[j], values[i]); - } - } - } - - /** - * Test pointer replace for non existing location in array. - * {@see RFC 6902: - * 4.3. replace} defines:
- * The target location MUST exist for the operation to be successful. - */ - private void testReplaceOfNonExistingLocationInArray( - final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonArray"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray1(), createIntArray2(), createSimpleBoolArray5(), - createObjectArray2() }; - final String[] paths = new String[] { "/", "/-1", "/-", "/5", "/0a", "/42", - STR_PATH + "/0" }; - final Object[] values = new Object[] { STR_VALUE, STR_VALUE, INT_VALUE, - BOOL_VALUE, OBJ_VALUE }; - // Go trough all arrays - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - simpleOperationFail(result, arraysIn[i], paths[j], values[i]); - } - } - } - - /** - * Tested operation name {@code "MOVE"}. - * - * @return Operation name to be used in logs. - */ - @Override - protected String operationName() { - return OPERATION; - } - - /** - * Create and initialize patch builder to contain REPLACE operation to be - * applied. - * - * @param path - * JSON path of value to be replaced. - * @param value - * Value to replace previous one. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder createOperationBuilder(final String path, - final Object value) { - return builderReplace(Json.createPatchBuilder(), path, value); - } - - /** - * Update patch builder to contain next REPLACE operation to be applied. - * - * @param builder - * JSON patch builder to update. - * @param path - * JSON path of value to be replaced. - * @param value - * Value to replace previous one. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder updateOperationBuilder( - final JsonPatchBuilder builder, final String path, final Object value) { - return builderReplace(builder, path, value); - } - - /** - * Add REPLACE {@code value} at {@code path} operation to provided JSON patch - * builder. - * - * @param builder - * Target JSON patch builder. - * @param path - * JSON path of value to be replaced. - * @param value - * Value to be replaced at given JSON path. - * @return JSON patch builder containing new {@code value} at {@code path} - * replaced. - */ - @SuppressWarnings("UnnecessaryUnboxing") - private static JsonPatchBuilder builderReplace(final JsonPatchBuilder builder, - final String path, final Object value) { - switch (JsonValueType.getType(value.getClass())) { - case String: - return builder.replace(path, (String) value); - case Integer: - return builder.replace(path, ((Integer) value).intValue()); - case Boolean: - return builder.replace(path, ((Boolean) value).booleanValue()); - case JsonValue: - return builder.replace(path, (JsonValue) value); - default: - throw new IllegalArgumentException( - "Value does not match known JSON value type"); - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationTest.java b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationTest.java deleted file mode 100644 index b01642eb4d..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchOperationTest.java +++ /dev/null @@ -1,449 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.patchtests; - -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_FALSE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_TRUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.JsonValueType; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonObject; -import jakarta.json.JsonPatchBuilder; -import jakarta.json.JsonValue; - -// $Id$ -/** - * RFC 6902: JavaScript Object Notation (JSON) Patch compatibility tests.
- * {@see RFC 6902}. - *

- * Implements - * {@see RFC 6902: - * 4.6. test} tests. - */ -public class PatchOperationTest extends CommonOperation { - - /** Tested operation name. */ - private final String OPERATION = "TEST"; - - /** - * Creates an instance of RFC 6902 replace operation test. - */ - PatchOperationTest() { - super(); - } - - /** - * Test RFC 6902 MOVE operation. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 6902 test operation"); - TestUtil.logMsg("Testing RFC 6902 test operation:"); - testOnEmptyObject(result); - testOnEmptyArray(result); - testOnSimpleObject(result); - testOnSimpleStringArray(result); - testOnSimpleIntArray(result); - testOnSimpleBoolArray(result); - testOnSimpleObjectArray(result); - return result; - } - - /** - * Test RFC 6902 TEST operation on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - on empty JSON object"); - final JsonObject in = createEmptyObject(); - final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH, - OBJ_PATH }; - final Object[] values = new Object[] { STR_VALUE, INT_VALUE, BOOL_VALUE, - OBJ_VALUE }; - // Go trough all values. - for (int i = 0; i < values.length; i++) { - // Go trough all paths. - for (int j = 0; j < paths.length; j++) { - // Everything shall fail on empty object. - simpleOperationFail(result, in, paths[j], values[i]); - } - } - // Whole document should pass on itself. - simpleOperation(result, in, null, "", in); - } - - /** - * Test RFC 6902 TEST operation on empty JSON array. - * - * @param result - * Tests result record. - */ - private void testOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - on empty JSON array"); - final JsonArray in = createEmptyArray(); - final String[] paths = new String[] { "/-1", "/0", "/1", "/2", "/3", "/4", - "/5", "/-" }; - final Object[] values = new Object[] { STR_VALUE, INT_VALUE, BOOL_VALUE, - OBJ_VALUE }; - // Go trough all values. - for (int i = 0; i < values.length; i++) { - // Go trough all paths. - for (int j = 0; j < paths.length; j++) { - // Everything shall fail on empty object. - simpleOperationFail(result, in, paths[j], values[i]); - } - } - // Whole document should pass on itself. - simpleOperation(result, in, null, "", in); - } - - /** - * Test RFC 6902 TEST on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - on simple JSON object"); - final JsonObject[] in = new JsonObject[] { createSimpleObjectStr(), - createSimpleObjectInt(), createSimpleObjectBool(), - createSimpleObjectObject() }; - final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH, - OBJ_PATH }; - final Object[] values = new Object[] { STR_VALUE, INT_VALUE, BOOL_VALUE, - OBJ_VALUE }; - // go trough all source objects. - for (int o = 0; o < in.length; o++) { - // Go trough all values. - for (int i = 0; i < values.length; i++) { - // Go trough all paths. - for (int j = 0; j < paths.length; j++) { - if (o == i && o == j) { - // TEST must pass for matching JsonObject, path and value - simpleOperation(result, in[o], null, paths[j], values[i]); - } else { - // TEST must fail for non matching JsonObject, path and value - simpleOperationFail(result, in[o], paths[j], values[i]); - } - } - } - // Whole document should pass on itself. - simpleOperation(result, in[o], null, "", in[o]); - } - } - - /** - * Test RFC 6902 TEST on simple JSON array of {@code String}. - * - * @param result - * Tests result record. - */ - private void testOnSimpleStringArray(final TestResult result) { - TestUtil.logMsg(" - on simple JSON String array of size 5"); - final JsonArray in = createSimpleStringArray5(); - final String[] indexes = new String[] { "/-1", "/-", STR_PATH }; - final String[] values = new String[] { STR_VALUE_1, STR_VALUE_2, - STR_VALUE_3, STR_VALUE_4, STR_VALUE_5 }; - // Go trough all array indexes. - for (int i = 0; i <= 5; i++) { - final String path = arrayPtr("/", i); - // Go trough all values. - for (int v = 0; v < values.length; v++) { - if (i == v) { - // TEST must pass for matching index and value. - simpleOperation(result, in, null, path, values[v]); - } else { - // TEST must fail for non matching index and value. - simpleOperationFail(result, in, path, values[v]); - } - } - } - // Go trough all invalid indexes - for (int i = 0; i < indexes.length; i++) { - // Go trough all values. - for (int v = 0; v < values.length; v++) { - // TEST must fail for non matching index and value. - simpleOperationFail(result, in, indexes[i], values[v]); - } - } - // Whole document should pass on itself. - simpleOperation(result, in, null, "", in); - } - - /** - * Test RFC 6902 TEST on simple JSON array of {@code int}. - * - * @param result - * Tests result record. - */ - private void testOnSimpleIntArray(final TestResult result) { - TestUtil.logMsg(" - on simple JSON int array of size 5"); - final JsonArray in = createSimpleIntArray5(); - final String[] indexes = new String[] { "/-1", "/-", INT_PATH }; - final int[] values = new int[] { INT_VALUE_1, INT_VALUE_2, INT_VALUE_3, - INT_VALUE_4, INT_VALUE_5 }; - // Go trough all array indexes. - for (int i = 0; i <= 5; i++) { - final String path = arrayPtr("/", i); - // Go trough all values. - for (int v = 0; v < values.length; v++) { - if (i == v) { - // TEST must pass for matching index and value. - simpleOperation(result, in, null, path, values[v]); - } else { - // TEST must fail for non matching index and value. - simpleOperationFail(result, in, path, values[v]); - } - } - } - // Go trough all invalid indexes - for (int i = 0; i < indexes.length; i++) { - // Go trough all values. - for (int v = 0; v < values.length; v++) { - // TEST must fail for non matching index and value. - simpleOperationFail(result, in, indexes[i], values[v]); - } - } - // Whole document should pass on itself. - simpleOperation(result, in, null, "", in); - } - - /** - * Test RFC 6902 TEST on simple JSON array of {@code boolean}. - * - * @param result - * Tests result record. - */ - private void testOnSimpleBoolArray(final TestResult result) { - TestUtil.logMsg(" - on simple JSON boolean array of size 2"); - final JsonArray in = createBoolArray2(); - final String[] indexes = new String[] { "/-1", "/-", BOOL_PATH }; - final boolean[] values = new boolean[] { BOOL_TRUE, BOOL_FALSE }; - // Go trough all array indexes. - for (int i = 0; i <= 2; i++) { - final String path = arrayPtr("/", i); - // Go trough all values. - for (int v = 0; v < values.length; v++) { - if (i == v) { - // TEST must pass for matching index and value. - simpleOperation(result, in, null, path, values[v]); - } else { - // TEST must fail for non matching index and value. - simpleOperationFail(result, in, path, values[v]); - } - } - } - // Go trough all invalid indexes - for (int i = 0; i < indexes.length; i++) { - // Go trough all values. - for (int v = 0; v < values.length; v++) { - // TEST must fail for non matching index and value. - simpleOperationFail(result, in, indexes[i], values[v]); - } - } - // Whole document should pass on itself. - simpleOperation(result, in, null, "", in); - } - - /** - * Test RFC 6902 TEST on simple JSON array of {@code JsonObject}. - * - * @param result - * Tests result record. - */ - private void testOnSimpleObjectArray(final TestResult result) { - TestUtil.logMsg(" - on simple JSON JsonObject array of size 5"); - final JsonArray in = createSimpleObjectArray5(); - final String[] indexes = new String[] { "/-1", "/-", OBJ_PATH }; - final JsonObject[] values = new JsonObject[] { OBJ_VALUE_1, OBJ_VALUE_2, - OBJ_VALUE_3, OBJ_VALUE_4, OBJ_VALUE_5 }; - // Go trough all array indexes. - for (int i = 0; i <= 5; i++) { - final String path = arrayPtr("/", i); - // Go trough all values. - for (int v = 0; v < values.length; v++) { - if (i == v) { - // TEST must pass for matching index and value. - simpleOperation(result, in, null, path, values[v]); - } else { - // TEST must fail for non matching index and value. - simpleOperationFail(result, in, path, values[v]); - } - } - } - // Go trough all invalid indexes - for (int i = 0; i < indexes.length; i++) { - // Go trough all values. - for (int v = 0; v < values.length; v++) { - // TEST must fail for non matching index and value. - simpleOperationFail(result, in, indexes[i], values[v]); - } - } - // Whole document should pass on itself. - simpleOperation(result, in, null, "", in); - } - - /** - * Build JSON array pointer for given prefix and index. - * - * @param prefix - * JSON array pointer prefix. - * @param index - * JSON array pointer index. - * @return JSON array pointer. - */ - private static String arrayPtr(final String prefix, final int index) { - final int prefixLen = prefix != null ? prefix.length() : 0; - final String indexStr = Integer.toString(index); - final StringBuilder sb = new StringBuilder(prefixLen + indexStr.length()); - if (prefixLen > 0) { - sb.append(prefix); - } - sb.append(indexStr); - return sb.toString(); - } - - /** - * Tested operation name {@code "TEST"}. - * - * @return Operation name to be used in logs. - */ - @Override - protected String operationName() { - return OPERATION; - } - - /** - * Create and initialize patch builder to contain TEST operation to be - * applied. - * - * @param path - * JSON path of value to be tested. - * @param value - * Value to be compared against value on specified path. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder createOperationBuilder(final String path, - final Object value) { - return builderTest(Json.createPatchBuilder(), path, value); - } - - /** - * Update patch builder to contain next TEST operation to be applied. - * - * @param builder - * JSON patch builder to update. - * @param path - * JSON path of value to be tested. - * @param value - * Value to be compared against value on specified path. - * @return Patch builder containing operation to be applied. - */ - @Override - protected JsonPatchBuilder updateOperationBuilder( - final JsonPatchBuilder builder, final String path, final Object value) { - return builderTest(builder, path, value); - } - - /** - * Add TEST {@code value} at {@code path} operation to provided JSON patch - * builder. - * - * @param builder - * Target JSON patch builder. - * @param path - * JSON path of value to be tested. - * @param value - * Value to be compared against value on specified path. - * @return JSON patch builder containing new TEST operation. - */ - @SuppressWarnings("UnnecessaryUnboxing") - private static JsonPatchBuilder builderTest(final JsonPatchBuilder builder, - final String path, final Object value) { - switch (JsonValueType.getType(value.getClass())) { - case String: - return builder.test(path, (String) value); - case Integer: - return builder.test(path, ((Integer) value).intValue()); - case Boolean: - return builder.test(path, ((Boolean) value).booleanValue()); - case JsonValue: - return builder.test(path, (JsonValue) value); - default: - throw new IllegalArgumentException( - "Value does not match known JSON value type"); - } - } - - /** - * Operation result check. - * - * @param check - * Expected modified JSON value. - * @param out - * Operation output. - * @return Value of {@code true} if operation passed or {@code false} - * otherwise. - */ - @Override - protected boolean operationFailed(final JsonValue check, - final JsonValue out) { - return out == null; - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchTests.java b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchTests.java index 6a8b5bf256..ad77c72191 100644 --- a/src/com/sun/ts/tests/jsonp/api/patchtests/PatchTests.java +++ b/src/com/sun/ts/tests/jsonp/api/patchtests/PatchTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2020 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022 Oracle and/or its affiliates. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0, which is available at @@ -48,140 +48,4 @@ public void jsonCreatePatch11Test() throws Fault { result.eval(); } - /** - * Test {@code JsonPatch.Operation} enumeration added in JSON-P 1.1. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonJsonPatchOperation11Test - * - * @assertion_ids: JSONP:JAVADOC:622; JSONP:JAVADOC:623; JSONP:JAVADOC:624; - * JSONP:JAVADOC:625; - * - * @test_Strategy: Tests JsonPatch.Operation enumeration added in JSON-P 1.1. - */ - public void jsonJsonPatchOperation11Test() throws Fault { - PatchOperationEnum enumTest = new PatchOperationEnum(); - final TestResult result = enumTest.test(); - result.eval(); - } - - /** - * Test JSONP API response on add operation.
- * {@see RFC 6902: - * 4.1. add}. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonPatchAddTest - * @assertion_ids: JSONP:JAVADOC:626; JSONP:JAVADOC:627; JSONP:JAVADOC:628; - * JSONP:JAVADOC:629; JSONP:JAVADOC:580; JSONP:JAVADOC:659; - * JSONP:JAVADOC:620; JSONP:JAVADOC:630; - * @test_Strategy: Test API response on various usages of add operation. - */ - public void jsonPatchAddTest() throws Fault { - PatchOperationAdd addTest = new PatchOperationAdd(); - final TestResult result = addTest.test(); - result.eval(); - } - - /** - * Test JSONP API response on remove operation.
- * {@see RFC 6902: - * 4.2. remove}. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonPatchRemoveTest - * @assertion_ids: JSONP:JAVADOC:633; JSONP:JAVADOC:580; JSONP:JAVADOC:659; - * JSONP:JAVADOC:620; JSONP:JAVADOC:630; - * @test_Strategy: Test API response on various usages of remove operation. - */ - public void jsonPatchRemoveTest() throws Fault { - PatchOperationRemove removeTest = new PatchOperationRemove(); - final TestResult result = removeTest.test(); - result.eval(); - } - - /** - * Test JSONP API response on replace operation.
- * {@see RFC 6902: - * 4.3. replace}. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonPatchReplaceTest - * @assertion_ids: JSONP:JAVADOC:634; JSONP:JAVADOC:635; JSONP:JAVADOC:636; - * JSONP:JAVADOC:637; JSONP:JAVADOC:580; JSONP:JAVADOC:659; - * JSONP:JAVADOC:620; JSONP:JAVADOC:630; - * @test_Strategy: Test API response on various usages of replace operation. - */ - public void jsonPatchReplaceTest() throws Fault { - PatchOperationReplace replaceTest = new PatchOperationReplace(); - final TestResult result = replaceTest.test(); - result.eval(); - } - - /** - * Test JSONP API response on move operation.
- * {@see RFC 6902: - * 4.4. move}. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonPatchMoveTest - * @assertion_ids: JSONP:JAVADOC:632; JSONP:JAVADOC:580; JSONP:JAVADOC:659; - * JSONP:JAVADOC:620; JSONP:JAVADOC:630; - * @test_Strategy: Test API response on various usages of move operation. - */ - public void jsonPatchMoveTest() throws Fault { - PatchOperationMove moveTest = new PatchOperationMove(); - final TestResult result = moveTest.test(); - result.eval(); - } - - /** - * Test JSONP API response on copy operation.
- * {@see RFC 6902: - * 4.5. copy}. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonPatchCopyTest - * @assertion_ids: JSONP:JAVADOC:631; JSONP:JAVADOC:580; JSONP:JAVADOC:659; - * JSONP:JAVADOC:620; JSONP:JAVADOC:630; - * @test_Strategy: Test API response on various usages of copy operation. - */ - public void jsonPatchCopyTest() throws Fault { - PatchOperationCopy copyTest = new PatchOperationCopy(); - final TestResult result = copyTest.test(); - result.eval(); - } - - /** - * Test JSONP API response on test operation.
- * {@see RFC 6902: - * 4.6. test}. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonPatchTestTest - * @assertion_ids: JSONP:JAVADOC:638; JSONP:JAVADOC:639; JSONP:JAVADOC:640; - * JSONP:JAVADOC:641; JSONP:JAVADOC:580; JSONP:JAVADOC:659; - * JSONP:JAVADOC:620; JSONP:JAVADOC:630; - * @test_Strategy: Test API response on various usages of test operation. - */ - public void jsonPatchTestTest() throws Fault { - PatchOperationTest testTest = new PatchOperationTest(); - final TestResult result = testTest.test(); - result.eval(); - } - } diff --git a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerAdd.java b/src/com/sun/ts/tests/jsonp/api/pointertests/PointerAdd.java deleted file mode 100644 index 0d094d775e..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerAdd.java +++ /dev/null @@ -1,757 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.pointertests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_FALSE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_TRUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.DEF_OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObjectReplaced; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayWithBoolAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayWithBoolBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayWithIntAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayWithIntBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayWithObjectAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayWithObjectBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayWithStrAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayWithStrBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2WithStringArrayInTheMiddle; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringInnerArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.toJsonValue; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonPointer; -import jakarta.json.JsonStructure; - -// $Id$ -/** - * {@see RFC 6901}: pointer - * usage for {@see RFC 6902} - * add operation tests.
- */ -public class PointerAdd { - - /** - * Creates an instance of RFC 6901 pointer instance usage for RFC 6902 add - * operation tests. - */ - PointerAdd() { - super(); - } - - /** - * Test RFC 6901 pointer instance usage for RFC 6902 add operation. Suite - * entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "RFC 6901 pointer usage for RFC 6902 add operation"); - TestUtil - .logMsg("Testing RFC 6901 pointer usage for RFC 6902 add operation"); - testAddStringOnEmptyObject(result); - testAddStringOnEmptyArray(result); - testAddStringOnSimpleObject(result); - testAddStringOnSimpleArray(result); - testAddStringOnSimpleArray2(result); - testAddIntOnEmptyObject(result); - testAddIntOnEmptyArray(result); - testAddIntOnSimpleObject(result); - testAddIntOnSimpleArray(result); - testAddIntOnSimpleArray2(result); - testAddBoolOnEmptyObject(result); - testAddBoolOnEmptyArray(result); - testAddBoolOnSimpleObject(result); - testAddBoolOnSimpleArray(result); - testAddBoolOnSimpleArray2(result); - testAddObjectOnEmptyObject(result); - testAddObjectOnEmptyArray(result); - testAddObjectOnSimpleObject(result); - testAddObjectOnSimpleArray(result); - testAddObjectOnSimpleArray2(result); - testAddArrayToReplaceObject(result); - testAddArrayToReplaceDocument(result); - testAddStringArrayToStringArray(result); - testAddStringToNonExistingObject(result); - return result; - } - - /** - * Test pointer ADD operation for {@code String} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testAddStringOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for String on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject check = createSimpleObjectStr(); - final JsonPointer ptr = Json.createPointer(STR_PATH); - final JsonObject out = ptr.add(in, Json.createValue(STR_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + STR_PATH + "\" ADD \"" - + STR_VALUE + "\" failed on empty JSON object"); - } - } - - /** - * Test pointer ADD operation for {@code String} on empty JSON array. Only - * allowed index for empty array is {@code 0} and {@code -}. - * - * @param result - * Tests result record. - */ - private void testAddStringOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for String on empty JSON array"); - final JsonArray in = createEmptyArray(); - final JsonArray check = createEmptyArrayWithStr(); - final JsonPointer[] ptrs = new JsonPointer[] { Json.createPointer("/0"), - Json.createPointer("/-") }; - for (final JsonPointer ptr : ptrs) { - final JsonArray out = ptr.add(in, Json.createValue(STR_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + ptr + "\" ADD \"" - + STR_VALUE + "\" failed on empty JSON array"); - } - } - } - - /** - * Test pointer ADD operation for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testAddStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject check = createSimpleObjectWithStr(); - final JsonPointer ptr = Json.createPointer(STR_PATH); - final JsonObject out = ptr.add(in, Json.createValue(STR_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + STR_PATH + "\" ADD \"" - + STR_VALUE + "\" failed on simple JSON object"); - } - } - - /** - * Test pointer ADD operation for {@code String} on simple JSON array of size - * 1. Using index {@code 0} to add {@code String} before already existing - * element and indexes {@code 1} and {@code -} to add {@code String} after - * already existing element. - * - * @param result - * Tests result record. - */ - private void testAddStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 1"); - final JsonArray in = createStringArray1(); - final JsonArray checkBefore = createSimpleStringArrayWithStrBefore(); - final JsonArray checkAfter = createSimpleStringArrayWithStrAfter(); - final JsonPointer ptrBefore = Json.createPointer("/0"); - final JsonPointer[] ptrsAfter = new JsonPointer[] { - Json.createPointer("/1"), Json.createPointer("/-") }; - final JsonArray outBefore = ptrBefore.add(in, Json.createValue(STR_VALUE)); - if (!assertEquals(checkBefore, outBefore)) { - result.fail("Pointer ADD operation", "Pointer \"/0\" ADD \"" + STR_VALUE - + "\" failed on simple JSON array"); - } - for (final JsonPointer ptrAfter : ptrsAfter) { - final JsonArray outAfter = ptrAfter.add(in, Json.createValue(STR_VALUE)); - if (!assertEquals(checkAfter, outAfter)) { - result.fail("Pointer ADD operation", "Pointer \"/1\" ADD \"" + STR_VALUE - + "\" failed on simple JSON array"); - } - } - } - - /** - * Test pointer ADD operation for {@code String} on simple JSON array of size - * 2. Starting with an array of size 2. - *

    - *
  • Adding {@code String} at the end, in the middle and at the beginning of - * this array. - *
  • Adding {@code String} at the beginning, in the middle and at the end of - * this array. - *
- * - * @param result - * Tests result record. - */ - private void testAddStringOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 2"); - final JsonArray in = createStringArray2(); - final JsonArray check = createSimpleStringArray5(); - verifyAddValues(result, in, check, new String[] { "/2", "/1", "/0" }, - new String[] { STR_VALUE_5, STR_VALUE_3, STR_VALUE_1 }, - "Pointer ADD operation", - "Pointers \"/2\", \"/1\", \"/0\" ADD sequence failed on simple JSON array"); - verifyAddValues(result, in, check, new String[] { "/0", "/2", "/4" }, - new String[] { STR_VALUE_1, STR_VALUE_3, STR_VALUE_5 }, - "Pointer ADD operation", - "Pointers \"/0\", \"/2\", \"/4\" ADD sequence failed on simple JSON array"); - } - - /** - * Test pointer ADD operation for {@code int} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testAddIntOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for int on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject check = createSimpleObjectInt(); - final JsonPointer ptr = Json.createPointer(INT_PATH); - final JsonObject out = ptr.add(in, Json.createValue(INT_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + INT_PATH + "\" ADD \"" - + INT_VALUE + "\" failed on empty JSON object"); - } - } - - /** - * Test pointer ADD operation for {@code int} on empty JSON array. Only - * allowed index for empty array is {@code 0} and {@code -}. - * - * @param result - * Tests result record. - */ - private void testAddIntOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for int on empty JSON array"); - final JsonArray in = createEmptyArray(); - final JsonArray check = createEmptyArrayWithInt(); - final JsonPointer[] ptrs = new JsonPointer[] { Json.createPointer("/0"), - Json.createPointer("/-") }; - for (final JsonPointer ptr : ptrs) { - final JsonArray out = ptr.add(in, Json.createValue(INT_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + ptr + "\" ADD \"" - + INT_VALUE + "\" failed on empty JSON array"); - } - } - } - - /** - * Test pointer ADD operation for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testAddIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject check = createSimpleObjectWithInt(); - final JsonPointer ptr = Json.createPointer(INT_PATH); - final JsonObject out = ptr.add(in, Json.createValue(INT_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + INT_PATH + "\" ADD \"" - + INT_VALUE + "\" failed on simple JSON object"); - } - } - - /** - * Test pointer ADD operation for {@code int} on simple JSON array of size 1. - * Using index {@code 0} to add {@code int} before already existing element - * and index {@code 1} and {@code -} to add {@code int} after already existing - * element. - * - * @param result - * Tests result record. - */ - private void testAddIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 1"); - final JsonArray in = createIntArray1(); - final JsonArray checkBefore = createSimpleIntArrayWithIntBefore(); - final JsonArray checkAfter = createSimpleIntArrayWithIntAfter(); - final JsonPointer ptrBefore = Json.createPointer("/0"); - final JsonPointer[] ptrsAfter = new JsonPointer[] { - Json.createPointer("/1"), Json.createPointer("/-") }; - final JsonArray outBefore = ptrBefore.add(in, Json.createValue(INT_VALUE)); - if (!assertEquals(checkBefore, outBefore)) { - result.fail("Pointer ADD operation", "Pointer \"/0\" ADD \"" + INT_VALUE - + "\" failed on simple JSON array"); - } - for (final JsonPointer ptrAfter : ptrsAfter) { - final JsonArray outAfter = ptrAfter.add(in, Json.createValue(INT_VALUE)); - if (!assertEquals(checkAfter, outAfter)) { - result.fail("Pointer ADD operation", "Pointer \"/1\" ADD \"" + INT_VALUE - + "\" failed on simple JSON array"); - } - } - } - - /** - * Test pointer ADD operation for {@code int} on simple JSON array of size 2. - * Starting with an array of size 2. - *
    - *
  • Adding {@code int} at the end, in the middle and at the beginning of - * this array. - *
  • Adding {@code int} at the beginning, in the middle and at the end of - * this array. - *
- * - * @param result - * Tests result record. - */ - private void testAddIntOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 2"); - final JsonArray in = createIntArray2(); - final JsonArray check = createSimpleIntArray5(); - verifyAddValues(result, in, check, new String[] { "/2", "/1", "/0" }, - new Integer[] { INT_VALUE_5, INT_VALUE_3, INT_VALUE_1 }, - "Pointer ADD operation", - "Pointers \"/2\", \"/1\", \"/0\" ADD sequence failed on simple JSON array"); - verifyAddValues(result, in, check, new String[] { "/0", "/2", "/4" }, - new Integer[] { INT_VALUE_1, INT_VALUE_3, INT_VALUE_5 }, - "Pointer ADD operation", - "Pointers \"/0\", \"/2\", \"/4\" ADD sequence failed on simple JSON array"); - } - - /** - * Test pointer ADD operation for {@code boolean} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testAddBoolOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject check = createSimpleObjectBool(); - final JsonPointer ptr = Json.createPointer(BOOL_PATH); - final JsonObject out = ptr.add(in, toJsonValue(BOOL_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + BOOL_PATH - + "\" ADD \"" + BOOL_VALUE + "\" failed on empty JSON object"); - } - } - - /** - * Test pointer ADD operation for {@code boolean} on empty JSON array. Only - * allowed index for empty array is {@code 0} and {@code -}. - * - * @param result - * Tests result record. - */ - private void testAddBoolOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on empty JSON array"); - final JsonArray in = createEmptyArray(); - final JsonArray check = createEmptyArrayWithBool(); - final JsonPointer[] ptrs = new JsonPointer[] { Json.createPointer("/0"), - Json.createPointer("/-") }; - for (final JsonPointer ptr : ptrs) { - final JsonArray out = ptr.add(in, toJsonValue(BOOL_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + ptr + "\" ADD \"" - + BOOL_VALUE + "\" failed on empty JSON array"); - } - } - } - - /** - * Test pointer ADD operation for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testAddBoolOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObject(); - final JsonObject check = createSimpleObjectWithBool(); - final JsonPointer ptr = Json.createPointer(BOOL_PATH); - final JsonObject out = ptr.add(in, toJsonValue(BOOL_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + BOOL_PATH - + "\" ADD \"" + BOOL_VALUE + "\" failed on simple JSON object"); - } - } - - /** - * Test pointer ADD operation for {@code boolean} on simple JSON array of size - * 1. Using index {@code 0} to add {@code boolean} before already existing - * element and index {@code 1} and {@code -} to add {@code boolean} after - * already existing element. - * - * @param result - * Tests result record. - */ - private void testAddBoolOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 1"); - final JsonArray in = createBoolArray1(); - final JsonArray checkBefore = createSimpleBoolArrayWithBoolBefore(); - final JsonArray checkAfter = createSimpleBoolArrayWithBoolAfter(); - final JsonPointer ptrBefore = Json.createPointer("/0"); - final JsonPointer[] ptrsAfter = new JsonPointer[] { - Json.createPointer("/1"), Json.createPointer("/-") }; - final JsonArray outBefore = ptrBefore.add(in, toJsonValue(BOOL_FALSE)); - if (!assertEquals(checkBefore, outBefore)) { - result.fail("Pointer ADD operation", "Pointer \"/0\" ADD \"" + BOOL_FALSE - + "\" failed on simple JSON array"); - } - for (final JsonPointer ptrAfter : ptrsAfter) { - final JsonArray outAfter = ptrAfter.add(in, toJsonValue(BOOL_FALSE)); - if (!assertEquals(checkAfter, outAfter)) { - result.fail("Pointer ADD operation", "Pointer \"/1\" ADD \"" - + BOOL_FALSE + "\" failed on simple JSON array"); - } - } - } - - /** - * Test pointer ADD operation for {@code boolean} on simple JSON array of size - * 2. Starting with an array of size 2. - *
    - *
  • Adding {@code boolean} at the end, in the middle and at the beginning - * of this array. - *
  • Adding {@code boolean} at the beginning, in the middle and at the end - * of this array. - *
- * - * @param result - * Tests result record. - */ - private void testAddBoolOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 2"); - final JsonArray in = createBoolArray2(); - final JsonArray check = createSimpleBoolArray5(); - verifyAddValues(result, in, check, new String[] { "/2", "/1", "/0" }, - new Boolean[] { BOOL_TRUE, BOOL_TRUE, BOOL_FALSE }, - "Pointer ADD operation", - "Pointers \"/2\", \"/1\", \"/0\" ADD sequence failed on simple JSON array"); - verifyAddValues(result, in, check, new String[] { "/0", "/2", "/4" }, - new Boolean[] { BOOL_FALSE, BOOL_TRUE, BOOL_TRUE }, - "Pointer ADD operation", - "Pointers \"/0\", \"/2\", \"/4\" ADD sequence failed on simple JSON array"); - } - - /** - * Test pointer ADD operation for {@code JsonObject} on empty JSON object. - * - * @param result - * Tests result record. - */ - private void testAddObjectOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on empty JSON object"); - final JsonObject in = createEmptyObject(); - final JsonObject check = createSimpleObjectObject(); - final JsonPointer ptr = Json.createPointer(OBJ_PATH); - final JsonObject out = ptr.add(in, OBJ_VALUE); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + OBJ_PATH + "\" ADD \"" - + OBJ_VALUE + "\" failed on empty JSON object"); - } - } - - /** - * Test pointer ADD operation for {@code JsonObject} on empty JSON array. Only - * allowed index for empty array is {@code 0} and {@code -}. - * - * @param result - * Tests result record. - */ - private void testAddObjectOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on empty JSON array"); - final JsonArray in = createEmptyArray(); - final JsonArray check = createEmptyArrayWithObject(); - final JsonPointer[] ptrs = new JsonPointer[] { Json.createPointer("/0"), - Json.createPointer("/-") }; - for (final JsonPointer ptr : ptrs) { - final JsonArray out = ptr.add(in, OBJ_VALUE); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + ptr + "\" ADD \"" - + OBJ_VALUE + "\" failed on empty JSON array"); - } - } - } - - /** - * Test pointer ADD operation for {@code JsonObject} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testAddObjectOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createCompoundObject(); - final JsonObject check = createCompoundObjectWithObject(); - final JsonPointer ptr = Json.createPointer(OBJ_PATH); - final JsonObject out = ptr.add(in, OBJ_VALUE); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + OBJ_PATH + "\" ADD \"" - + OBJ_VALUE + "\" failed on simple JSON object"); - } - } - - /** - * Test pointer ADD operation for {@code JsonObject} on simple JSON array of - * size 1. Using index {@code 0} to add {@code JsonObject} before already - * existing element and index {@code 1} and {@code -} to add - * {@code JsonObject} after already existing element. - * - * @param result - * Tests result record. - */ - private void testAddObjectOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 1"); - final JsonArray in = createObjectArray1(); - final JsonArray checkBefore = createSimpleObjectArrayWithObjectBefore(); - final JsonArray checkAfter = createSimpleObjectArrayWithObjectAfter(); - final JsonPointer ptrBefore = Json.createPointer("/0"); - final JsonPointer[] ptrsAfter = new JsonPointer[] { - Json.createPointer("/1"), Json.createPointer("/-") }; - final JsonArray outBefore = ptrBefore.add(in, OBJ_VALUE); - if (!assertEquals(checkBefore, outBefore)) { - result.fail("Pointer ADD operation", "Pointer \"/0\" ADD \"" + OBJ_VALUE - + "\" failed on simple JSON array"); - } - for (final JsonPointer ptrAfter : ptrsAfter) { - final JsonArray outAfter = ptrAfter.add(in, OBJ_VALUE); - if (!assertEquals(checkAfter, outAfter)) { - result.fail("Pointer ADD operation", "Pointer \"/1\" ADD \"" + OBJ_VALUE - + "\" failed on simple JSON array"); - } - } - } - - /** - * Test pointer ADD operation for {@code JsonObject} on simple JSON array of - * size 2. Starting with an array of size 2. - *
    - *
  • Adding {@code JsonObject} at the end, in the middle and at the - * beginning of this array. - *
  • Adding {@code JsonObject} at the beginning, in the middle and at the - * end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testAddObjectOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 2"); - final JsonArray in = createObjectArray2(); - final JsonArray check = createSimpleObjectArray5(); - verifyAddValues(result, in, check, new String[] { "/2", "/1", "/0" }, - new JsonObject[] { OBJ_VALUE_5, OBJ_VALUE_3, OBJ_VALUE_1 }, - "Pointer ADD operation", - "Pointers \"/2\", \"/1\", \"/0\" ADD sequence failed on simple JSON array"); - verifyAddValues(result, in, check, new String[] { "/0", "/2", "/4" }, - new JsonObject[] { OBJ_VALUE_1, OBJ_VALUE_3, OBJ_VALUE_5 }, - "Pointer ADD operation", - "Pointers \"/0\", \"/2\", \"/4\" ADD sequence failed on simple JSON array"); - } - - // Tests based on RFC 6902 definitions and examples. - - /** - * Test that existing target object is replaced by specified array when ADD - * operation is applied. - * {@see RFC 6902: - * 4.1. add}:
- * When the operation is applied, the target location MUST reference one of: - *
    - *
  • A member to add to an existing object - whereupon the supplied value is - * added to that object at the indicated location. If the member already - * exists, it is replaced by the specified value.
  • - *
  • ...
  • - *
- */ - private void testAddArrayToReplaceObject(final TestResult result) { - TestUtil.logMsg(" - for JsonArray to replace JsonObject"); - final JsonObject in = createCompoundObject(); - final JsonObject check = createCompoundObjectWithObjectReplaced(); - final JsonPointer ptr = Json.createPointer(DEF_OBJ_PATH); - final JsonArray replace = createSimpleStringArray5(); - final JsonObject out = ptr.add(in, replace); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + DEF_OBJ_PATH - + "\" ADD array to replace existing object failed on compound JSON object"); - } - } - - /** - * Test that whole document is replaced by specified array when ADD operation - * is applied with root pointer. - * {@see RFC 6902: - * 4.1. add}:
- * When the operation is applied, the target location MUST reference one of: - *
    - *
  • The root of the target document - whereupon the specified value becomes - * the entire content of the target document.
  • - *
  • ...
  • - *
- */ - private void testAddArrayToReplaceDocument(final TestResult result) { - TestUtil.logMsg(" - for JsonArray to replace whole document"); - final JsonObject in = createCompoundObject(); - final JsonArray check = createSimpleStringArray5(); - final JsonPointer ptr = Json.createPointer(""); - final JsonArray replace = createSimpleStringArray5(); - // Instance being replaced is JsonObject, instance being added is JsonArray - final JsonStructure out = ptr.add((JsonStructure) in, replace); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", "Pointer \"" + DEF_OBJ_PATH - + "\" ADD array to replace existing object failed on compound JSON object"); - } - } - - /** - * Test ADD operation of an array of {@code String}s into existing array of - * {@code String}s. This scenario is inspired by - * {@see RFC 6902: - * 4.1. add} operation example {@code { "op": "add", "path": "/a/b/c", - * "value": [ "foo", "bar" ] }} and following explanation of this operation on - * an array: - *
    - *
  • An element to add to an existing array - whereupon the supplied value - * is added to the array at the indicated location. Any elements at or above - * the specified index are shifted one position to the right. The specified - * index MUST NOT be greater than the number of elements in the array. If the - * "-" character is used to index the end of the array (see [RFC6901]), this - * has the effect of appending the value to the array.
  • - *
- */ - private void testAddStringArrayToStringArray(final TestResult result) { - TestUtil.logMsg(" - for String array to be added to existing String array"); - final JsonArray in = createStringArray2(); - final JsonArray check = createStringArray2WithStringArrayInTheMiddle(); - final JsonArray arrayToAdd = createStringInnerArray2(); - final JsonPointer ptr = Json.createPointer("/1"); - final JsonArray out = ptr.add(in, arrayToAdd); - if (!assertEquals(check, out)) { - result.fail("Pointer ADD operation", - "Pointer \"/1\" ADD array failed on JSON array"); - } - } - - /** - * Test ADD operation on non existing JsonObject. This scenario is described - * in {@see RFC - * 6902: 4.1. add} error handling samples. Test is trying to ADD value { - * "address" : "In a galaxy far far away"} into object { "name" : "John Smith" - * } using path "/child/address". Even "/child" path does not exist so this - * operation must fail. - * - */ - private void testAddStringToNonExistingObject(final TestResult result) { - TestUtil.logMsg(" - for String to be added to non existing JsonObject"); - final JsonObject in = createSimpleObject(); - final JsonPointer ptr = Json.createPointer(DEF_OBJ_PATH + STR_PATH); - boolean exception = false; - try { - ptr.add(in, Json.createValue(STR_VALUE)); - } catch (JsonException e) { - exception = true; - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } - if (!exception) { - result.fail("Pointer ADD operation", - "ADD operation on non existing JsonObject \"" + DEF_OBJ_PATH - + "\" passed"); - } - } - - /** - * Test helper: Verify set of ADD operations on provided JSON array and verify - * result using provided expected JSON value. JSON pointer instance is used to - * modify the array. - * - * @param result - * Test suite result. - * @param in - * JSON array to be modified. - * @param check - * Expected modified JSON array (used for operation check). - * @param paths - * JSON array paths of values to be added. Pairs of {@code paths[i]} - * and {@code values[i]} are used for add operations. - * @param values - * JSON array values to be added on specified indexes. - * @param testName - * Name of this test. - * @param errorMessage - * Error message to be added on verification failure. - */ - private void verifyAddValues(final TestResult result, final JsonArray in, - final JsonArray check, final String[] paths, final Object[] values, - final String testName, final String errorMessage) { - if (paths.length != values.length) { - throw new IllegalArgumentException( - "Number of paths does not match number of indexes"); - } - JsonArray out = in; - for (int i = 0; i < paths.length; i++) { - final JsonPointer ptr = Json.createPointer(paths[i]); - out = ptr.add(out, toJsonValue(values[i])); - } - if (!assertEquals(check, out)) { - result.fail(testName, errorMessage); - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerRemove.java b/src/com/sun/ts/tests/jsonp/api/pointertests/PointerRemove.java deleted file mode 100644 index 010125ce58..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerRemove.java +++ /dev/null @@ -1,652 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.pointertests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArrayWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayWithBoolAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayWithBoolBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayWithIntAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayWithIntBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayWithObjectAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayWithObjectBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectWithStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayWithStrAfter; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayWithStrBefore; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray2; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonPointer; - -// $Id$ -/** - * {@see RFC 6901}: pointer - * usage for {@see RFC 6902} - * remove operation tests.
- */ -public class PointerRemove { - - /** - * Creates an instance of RFC 6901 pointer instance usage for RFC 6902 remove - * operation tests. - */ - PointerRemove() { - super(); - } - - /** - * Test RFC 6901 pointer instance usage for RFC 6902 remove operation. Suite - * entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "RFC 6901 pointer usage for RFC 6902 remove operation"); - TestUtil - .logMsg("Testing RFC 6901 pointer usage for RFC 6902 remove operation"); - testRemoveStringOnEmptyObject(result); - testRemoveStringOnEmptyArray(result); - testRemoveStringOnSimpleObject(result); - testRemoveStringOnSimpleArray(result); - testRemoveStringOnSimpleArray2(result); - testRemoveIntOnEmptyObject(result); - testRemoveIntOnEmptyArray(result); - testRemoveIntOnSimpleObject(result); - testRemoveIntOnSimpleArray(result); - testRemoveIntOnSimpleArray2(result); - testRemoveBoolOnEmptyObject(result); - testRemoveBoolOnEmptyArray(result); - testRemoveBoolOnSimpleObject(result); - testRemoveBoolOnSimpleArray(result); - testRemoveBoolOnSimpleArray2(result); - testRemoveObjectOnEmptyObject(result); - testRemoveObjectOnEmptyArray(result); - testRemoveObjectOnSimpleObject(result); - testRemoveObjectOnSimpleArray(result); - testRemoveObjectOnSimpleArray2(result); - testRemoveFromNonExistingLocationInObject(result); - testRemoveFromNonExistingLocationInArray(result); - return result; - } - - /** - * Test pointer REMOVE operation for {@code String} to produce empty JSON - * object. - * - * @param result - * Tests result record. - */ - private void testRemoveStringOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for String to produce empty JSON object"); - final JsonObject in = createSimpleObjectStr(); - final JsonObject check = createEmptyObject(); - final JsonPointer ptr = Json.createPointer(STR_PATH); - final JsonObject out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", "Pointer \"" + STR_PATH - + "\" REMOVE failed when producing empty JSON object"); - } - } - - /** - * Test pointer REMOVE operation for {@code String} to produce empty JSON - * array. Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testRemoveStringOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for String to produce empty JSON array"); - final JsonArray in = createEmptyArrayWithStr(); - final JsonArray check = createEmptyArray(); - final JsonPointer ptr = Json.createPointer("/0"); - final JsonArray out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/0\" REMOVE failed when producing empty JSON array"); - } - } - - /** - * Test pointer REMOVE operation for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObjectWithStr(); - final JsonObject check = createSimpleObject(); - final JsonPointer ptr = Json.createPointer(STR_PATH); - final JsonObject out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", - "Pointer \"" + STR_PATH + "\" REMOVE failed on simple JSON object"); - } - } - - /** - * Test pointer REMOVE operation for {@code String} on simple JSON array of - * size 2. Using index {@code 0} to remove {@code String} before another - * existing element and index {@code 1} to remove {@code String} after another - * existing element. - * - * @param result - * Tests result record. - */ - private void testRemoveStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 2"); - final JsonArray inBefore = createSimpleStringArrayWithStrBefore(); - final JsonArray inAfter = createSimpleStringArrayWithStrAfter(); - final JsonArray check = createStringArray1(); - final JsonPointer ptrBefore = Json.createPointer("/0"); - final JsonPointer ptrAfter = Json.createPointer("/1"); - final JsonArray outBefore = ptrBefore.remove(inBefore); - final JsonArray outAfter = ptrAfter.remove(inAfter); - if (!assertEquals(check, outBefore)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/0\" REMOVE failed on simple JSON array"); - } - if (!assertEquals(check, outAfter)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/1\" REMOVE failed on simple JSON array"); - } - } - - /** - * Test pointer REMOVE for {@code String} on simple JSON array of size 5. - * Starting with an array of size 2. - *
    - *
  • Removing {@code String} at the end, at the middle and at the beginning - * of this array. - *
  • Removing {@code String} at the beginning, in the middle and at the end - * of this array. - *
- * - * @param result - * Tests result record. - */ - private void testRemoveStringOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 5"); - final JsonArray in = createSimpleStringArray5(); - final JsonArray check = createStringArray2(); - verifyRemoveValues(result, in, check, new String[] { "/4", "/2", "/0" }, - "Pointer REMOVE operation", - "Pointers \"/4\", \"/2\", \"/0\" REMOVE sequence failed on simple JSON array"); - verifyRemoveValues(result, in, check, new String[] { "/0", "/1", "/2" }, - "Pointer REMOVE operation", - "Pointers \"/0\", \"/1\", \"/2\" REMOVE sequence failed on simple JSON array"); - } - - /** - * Test pointer REMOVE operation for {@code int} to produce empty JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveIntOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for int to produce empty JSON object"); - final JsonObject in = createSimpleObjectInt(); - final JsonObject check = createEmptyObject(); - final JsonPointer ptr = Json.createPointer(INT_PATH); - final JsonObject out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", "Pointer \"" + INT_PATH - + "\" REMOVE failed when producing empty JSON object"); - } - } - - /** - * Test pointer REMOVE operation for {@code int} to produce empty JSON array. - * Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testRemoveIntOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for int to produce empty JSON array"); - final JsonArray in = createEmptyArrayWithInt(); - final JsonArray check = createEmptyArray(); - final JsonPointer ptr = Json.createPointer("/0"); - final JsonArray out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/0\" REMOVE failed when producing empty JSON array"); - } - } - - /** - * Test pointer REMOVE operation for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObjectWithInt(); - final JsonObject check = createSimpleObject(); - final JsonPointer ptr = Json.createPointer(INT_PATH); - final JsonObject out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", - "Pointer \"" + INT_PATH + "\" REMOVE failed on simple JSON object"); - } - } - - /** - * Test pointer REMOVE operation for {@code int} on simple JSON array of size - * 2. Using index {@code 0} to remove {@code int} before another existing - * element and index {@code 1} to remove {@code int} after another existing - * element. - * - * @param result - * Tests result record. - */ - private void testRemoveIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 2"); - final JsonArray inBefore = createSimpleIntArrayWithIntBefore(); - final JsonArray inAfter = createSimpleIntArrayWithIntAfter(); - final JsonArray check = createIntArray1(); - final JsonPointer ptrBefore = Json.createPointer("/0"); - final JsonPointer ptrAfter = Json.createPointer("/1"); - final JsonArray outBefore = ptrBefore.remove(inBefore); - final JsonArray outAfter = ptrAfter.remove(inAfter); - if (!assertEquals(check, outBefore)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/0\" REMOVE failed on simple JSON array"); - } - if (!assertEquals(check, outAfter)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/1\" REMOVE failed on simple JSON array"); - } - } - - /** - * Test pointer REMOVE for {@code int} on simple JSON array of size 5. - * Starting with an array of size 5. - *
    - *
  • Removing {@code int} at the end, at the middle and at the beginning of - * this array. - *
  • Removing {@code int} at the beginning, in the middle and at the end of - * this array. - *
- * - * @param result - * Tests result record. - */ - private void testRemoveIntOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 5"); - final JsonArray in = createSimpleIntArray5(); - final JsonArray check = createIntArray2(); - verifyRemoveValues(result, in, check, new String[] { "/4", "/2", "/0" }, - "Pointer REMOVE operation", - "Pointers \"/4\", \"/2\", \"/0\" REMOVE sequence failed on simple JSON array"); - verifyRemoveValues(result, in, check, new String[] { "/0", "/1", "/2" }, - "Pointer REMOVE operation", - "Pointers \"/0\", \"/1\", \"/2\" REMOVE sequence failed on simple JSON array"); - } - - /** - * Test pointer REMOVE operation for {@code boolean} to produce empty JSON - * object. - * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for boolean to produce empty JSON object"); - final JsonObject in = createSimpleObjectBool(); - final JsonObject check = createEmptyObject(); - final JsonPointer ptr = Json.createPointer(BOOL_PATH); - final JsonObject out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", "Pointer \"" + BOOL_PATH - + "\" REMOVE failed when producing empty JSON object"); - } - } - - /** - * Test pointer REMOVE operation for {@code boolean} to produce empty JSON - * array. Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for boolean to produce empty JSON array"); - final JsonArray in = createEmptyArrayWithBool(); - final JsonArray check = createEmptyArray(); - final JsonPointer ptr = Json.createPointer("/0"); - final JsonArray out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/0\" REMOVE failed when producing empty JSON array"); - } - } - - /** - * Test pointer REMOVE operation for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObjectWithBool(); - final JsonObject check = createSimpleObject(); - final JsonPointer ptr = Json.createPointer(BOOL_PATH); - final JsonObject out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", - "Pointer \"" + BOOL_PATH + "\" REMOVE failed on simple JSON object"); - } - } - - /** - * Test pointer REMOVE operation for {@code boolean} on simple JSON array of - * size 2. Using index {@code 0} to remove {@code boolean} before another - * existing element and index {@code 1} to remove {@code boolean} after - * another existing element. - * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 2"); - final JsonArray inBefore = createSimpleBoolArrayWithBoolBefore(); - final JsonArray inAfter = createSimpleBoolArrayWithBoolAfter(); - final JsonArray check = createBoolArray1(); - final JsonPointer ptrBefore = Json.createPointer("/0"); - final JsonPointer ptrAfter = Json.createPointer("/1"); - final JsonArray outBefore = ptrBefore.remove(inBefore); - final JsonArray outAfter = ptrAfter.remove(inAfter); - if (!assertEquals(check, outBefore)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/0\" REMOVE failed on simple JSON array"); - } - if (!assertEquals(check, outAfter)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/1\" REMOVE failed on simple JSON array"); - } - } - - /** - * Test pointer REMOVE for {@code boolean} on simple JSON array of size 5. - * Starting with an array of size 5. - *
    - *
  • Removing {@code boolean} at the end, at the middle and at the beginning - * of this array. - *
  • Removing {@code boolean} at the beginning, in the middle and at the end - * of this array. - *
- * - * @param result - * Tests result record. - */ - private void testRemoveBoolOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 5"); - final JsonArray in = createSimpleBoolArray5(); - final JsonArray check = createBoolArray2(); - verifyRemoveValues(result, in, check, new String[] { "/4", "/2", "/0" }, - "Pointer REMOVE operation", - "Pointers \"/4\", \"/2\", \"/0\" REMOVE sequence failed on simple JSON array"); - verifyRemoveValues(result, in, check, new String[] { "/0", "/1", "/2" }, - "Pointer REMOVE operation", - "Pointers \"/0\", \"/1\", \"/2\" REMOVE sequence failed on simple JSON array"); - } - - /** - * Test pointer REMOVE operation for {@code JsonObject} to produce empty JSON - * object. - * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnEmptyObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject to produce empty JSON object"); - final JsonObject in = createSimpleObjectObject(); - final JsonObject check = createEmptyObject(); - final JsonPointer ptr = Json.createPointer(OBJ_PATH); - final JsonObject out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", "Pointer \"" + OBJ_PATH - + "\" REMOVE failed when producing empty JSON object"); - } - } - - /** - * Test pointer REMOVE operation for {@code JsonObject} to produce empty JSON - * array. Only allowed index for empty array is {@code 0}. - * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnEmptyArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject to produce empty JSON array"); - final JsonArray in = createEmptyArrayWithObject(); - final JsonArray check = createEmptyArray(); - final JsonPointer ptr = Json.createPointer("/0"); - final JsonArray out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/0\" REMOVE failed when producing empty JSON array"); - } - } - - /** - * Test pointer REMOVE operation for {@code JsonObject} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createCompoundObjectWithObject(); - final JsonObject check = createCompoundObject(); - final JsonPointer ptr = Json.createPointer(OBJ_PATH); - final JsonObject out = ptr.remove(in); - if (!assertEquals(check, out)) { - result.fail("Pointer REMOVE operation", - "Pointer \"" + OBJ_PATH + "\" REMOVE failed on simple JSON object"); - } - } - - /** - * Test pointer REMOVE operation for {@code JsonObject} on simple JSON array - * of size 2. Using index {@code 0} to remove {@code JsonObject} before - * another existing element and index {@code 1} to remove {@code JsonObject} - * after another existing element. - * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 2"); - final JsonArray inBefore = createSimpleObjectArrayWithObjectBefore(); - final JsonArray inAfter = createSimpleObjectArrayWithObjectAfter(); - final JsonArray check = createObjectArray1(); - final JsonPointer ptrBefore = Json.createPointer("/0"); - final JsonPointer ptrAfter = Json.createPointer("/1"); - final JsonArray outBefore = ptrBefore.remove(inBefore); - final JsonArray outAfter = ptrAfter.remove(inAfter); - if (!assertEquals(check, outBefore)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/0\" REMOVE failed on simple JSON array"); - } - if (!assertEquals(check, outAfter)) { - result.fail("Pointer REMOVE operation", - "Pointer \"/1\" REMOVE failed on simple JSON array"); - } - } - - /** - * Test pointer REMOVE for {@code JsonObject} on simple JSON array of size 5. - * Starting with an array of size 5. - *
    - *
  • Removing {@code JsonObject} at the end, at the middle and at the - * beginning of this array. - *
  • Removing {@code JsonObject} at the beginning, in the middle and at the - * end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testRemoveObjectOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 5"); - final JsonArray in = createSimpleObjectArray5(); - final JsonArray check = createObjectArray2(); - verifyRemoveValues(result, in, check, new String[] { "/4", "/2", "/0" }, - "Pointer REMOVE operation", - "Pointers \"/4\", \"/2\", \"/0\" REMOVE sequence failed on simple JSON array"); - verifyRemoveValues(result, in, check, new String[] { "/0", "/1", "/2" }, - "Pointer REMOVE operation", - "Pointers \"/0\", \"/1\", \"/2\" REMOVE sequence failed on simple JSON array"); - } - - // Tests based on RFC 6902 definitions and examples. - - /** - * Test pointer REMOVE for non existing location in object. - * {@see RFC 6902: - * 4.2. remove} defines:
- * The target location MUST exist for the operation to be successful. - */ - private void testRemoveFromNonExistingLocationInObject( - final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonObject"); - final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(), - createSimpleObject(), createCompoundObject() }; - final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH, - OBJ_PATH }; - // Go trough all objects - for (int i = 0; i < objsIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - final JsonPointer ptr = Json.createPointer(paths[j]); - try { - final JsonObject out = ptr.remove(objsIn[i]); - result.fail("Pointer REMOVE operation", "Pointer \"" + paths[j] - + "\" REMOVE succeeded on non existing location"); - } catch (JsonException e) { - // There are too many combinations to log them. - } - } - } - } - - /** - * Test pointer REMOVE for non existing location in array. - * {@see RFC 6902: - * 4.2. remove} defines:
- * The target location MUST exist for the operation to be successful. - */ - private void testRemoveFromNonExistingLocationInArray( - final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonArray"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray1(), createIntArray2(), createSimpleBoolArray5(), - createObjectArray2() - - }; - final String[] paths = new String[] { "/", "/-1", "/-", "/5", "/0a", "/42", - STR_PATH + "/0" }; - // Go trough all arrays - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - final JsonPointer ptr = Json.createPointer(paths[j]); - try { - final JsonArray out = ptr.remove(arraysIn[i]); - result.fail("Pointer REMOVE operation", "Pointer \"" + paths[j] - + "\" REMOVE succeeded on non existing location"); - } catch (JsonException e) { - // There are too many combinations to log them. - } - } - } - } - - /** - * Test helper: Verify set of REMOVE operations on provided JSON array and - * verify result using provided expected JSON value. JSON pointer instance is - * used to modify the array. - * - * @param result - * Test suite result. - * @param in - * JSON array to be modified. - * @param check - * Expected modified JSON array (used for operation check). - * @param paths - * JSON array paths of values to be added. Pairs of {@code paths[i]} - * and {@code values[i]} are used for add operations. - * @param testName - * Name of this test. - * @param errorMessage - * Error message to be added on verification failure. - */ - private void verifyRemoveValues(final TestResult result, final JsonArray in, - final JsonArray check, final String[] paths, final String testName, - final String errorMessage) { - JsonArray out = in; - for (int i = 0; i < paths.length; i++) { - final JsonPointer ptr = Json.createPointer(paths[i]); - out = ptr.remove(out); - } - if (!assertEquals(check, out)) { - result.fail(testName, errorMessage); - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerReplace.java b/src/com/sun/ts/tests/jsonp/api/pointertests/PointerReplace.java deleted file mode 100644 index a4d03ecaab..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerReplace.java +++ /dev/null @@ -1,496 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.pointertests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_FALSE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_TRUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_VALUE2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_PATH; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectReplaceObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createCompoundObjectWithObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createIntArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createObjectArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArrayReplaceBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArrayReplaceInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArrayReplaceObject; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectReplaceBool; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectReplaceInt; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectReplaceStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5R; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArrayReplaceStr; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.toJsonValue; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonPointer; -import jakarta.json.JsonValue; - -// $Id$ -/** - * {@see RFC 6901}: pointer - * usage for {@see RFC 6902} - * replace operation tests.
- */ -public class PointerReplace { - - /** - * Creates an instance of RFC 6901 pointer instance usage for RFC 6902 replace - * operation tests. - */ - PointerReplace() { - super(); - } - - /** - * Test RFC 6901 pointer instance usage for RFC 6902 replace operation. Suite - * entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult( - "RFC 6901 pointer usage for RFC 6902 replace operation"); - TestUtil.logMsg( - "Testing RFC 6901 pointer usage for RFC 6902 replace operation"); - testReplaceStringOnSimpleObject(result); - testReplaceStringOnSimpleArray(result); - testReplaceStringOnSimpleArray2(result); - testReplaceIntOnSimpleObject(result); - testReplaceIntOnSimpleArray(result); - testReplaceIntOnSimpleArray2(result); - testReplaceBoolOnSimpleObject(result); - testReplaceBoolOnSimpleArray(result); - testReplaceBoolOnSimpleArray2(result); - testReplaceObjectOnCompoundObject(result); - testReplaceObjectOnSimpleArray(result); - testReplaceObjectOnSimpleArray2(result); - testReplaceOfNonExistingLocationInObject(result); - testReplaceOfNonExistingLocationInArray(result); - return result; - } - - /** - * Test pointer REPLACE operation for {@code String} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testReplaceStringOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON object"); - final JsonObject in = createSimpleObjectStr(); - final JsonObject check = createSimpleObjectReplaceStr(); - final JsonPointer ptr = Json.createPointer(STR_PATH); - final JsonObject out = ptr.replace(in, Json.createValue(STR_VALUE2)); - if (!assertEquals(check, out)) { - result.fail("Pointer REPLACE operation", "Pointer \"" + STR_PATH - + "\" REPLACE \"" + STR_VALUE2 + "\" failed on simple JSON object"); - } - } - - /** - * Test pointer REPLACE operation for {@code String} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testReplaceStringOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 1"); - final JsonArray in = createStringArray1(); - final JsonArray check = createSimpleStringArrayReplaceStr(); - final JsonPointer ptr = Json.createPointer("/0"); - final JsonArray out = ptr.replace(in, Json.createValue(STR_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer REPLACE operation", "Pointer \"/0\" REPLACE \"" - + STR_VALUE + "\" failed on simple JSON array"); - } - } - - /** - * Test pointer REPLACE operation for {@code String} on simple JSON array of - * size 5. Starting with an array of size 5. - *
    - *
  • Replacing {@code String} items from the end to the beginning of this - * array. - *
  • Replacing {@code String} from the beginning to the end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testReplaceStringOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for String on simple JSON array of size 5"); - final JsonArray in = createSimpleStringArray5(); - final JsonArray check = createSimpleStringArray5R(); - verifyReplaceValues(result, in, check, - new String[] { "/4", "/3", "/1", "/0" }, - new String[] { STR_VALUE_1, STR_VALUE_2, STR_VALUE_4, STR_VALUE_5 }, - "Pointer REPLACE operation", - "Pointers \"/4\", \"/3\", \"/1\", \"/0\" REPLACE sequence failed on simple JSON array"); - verifyReplaceValues(result, in, check, - new String[] { "/0", "/1", "/3", "/4" }, - new String[] { STR_VALUE_5, STR_VALUE_4, STR_VALUE_2, STR_VALUE_1 }, - "Pointer REPLACE operation", - "Pointers \"/0\", \"/1\", \"/3\", \"/4\" REPLACE sequence failed on simple JSON array"); - } - - /** - * Test pointer REPLACE operation for {@code int} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testReplaceIntOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON object"); - final JsonObject in = createSimpleObjectInt(); - final JsonObject check = createSimpleObjectReplaceInt(); - final JsonPointer ptr = Json.createPointer(INT_PATH); - final JsonObject out = ptr.replace(in, Json.createValue(INT_VALUE2)); - if (!assertEquals(check, out)) { - result.fail("Pointer REPLACE operation", "Pointer \"" + INT_PATH - + "\" REPLACE \"" + INT_VALUE2 + "\" failed on simple JSON object"); - } - } - - /** - * Test pointer REPLACE operation for {@code int} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testReplaceIntOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 1"); - final JsonArray in = createIntArray1(); - final JsonArray check = createSimpleIntArrayReplaceInt(); - final JsonPointer ptr = Json.createPointer("/0"); - final JsonArray out = ptr.replace(in, Json.createValue(INT_VALUE)); - if (!assertEquals(check, out)) { - result.fail("Pointer REPLACE operation", "Pointer \"/0\" REPLACE \"" - + INT_VALUE + "\" failed on simple JSON array"); - } - } - - /** - * Test pointer REPLACE operation for {@code int} on simple JSON array of size - * 5. Starting with an array of size 5. - *
    - *
  • Replacing {@code int} items from the end to the beginning of this - * array. - *
  • Replacing {@code int} from the beginning to the end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testReplaceIntOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for int on simple JSON array of size 5"); - final JsonArray in = createSimpleIntArray5(); - final JsonArray check = createSimpleIntArray5R(); - verifyReplaceValues(result, in, check, - new String[] { "/4", "/3", "/1", "/0" }, - new Integer[] { INT_VALUE_1, INT_VALUE_2, INT_VALUE_4, INT_VALUE_5 }, - "Pointer REPLACE operation", - "Pointers \"/4\", \"/3\", \"/1\", \"/0\" REPLACE sequence failed on simple JSON array"); - verifyReplaceValues(result, in, check, - new String[] { "/0", "/1", "/3", "/4" }, - new Integer[] { INT_VALUE_5, INT_VALUE_4, INT_VALUE_2, INT_VALUE_1 }, - "Pointer REPLACE operation", - "Pointers \"/0\", \"/1\", \"/3\", \"/4\" REPLACE sequence failed on simple JSON array"); - } - - /** - * Test pointer REPLACE operation for {@code boolean} on simple JSON object. - * - * @param result - * Tests result record. - */ - private void testReplaceBoolOnSimpleObject(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON object"); - final JsonObject in = createSimpleObjectBool(); - final JsonObject check = createSimpleObjectReplaceBool(); - final JsonPointer ptr = Json.createPointer(BOOL_PATH); - final JsonObject out = ptr.replace(in, toJsonValue(BOOL_VALUE2)); - if (!assertEquals(check, out)) { - result.fail("Pointer REPLACE operation", "Pointer \"" + BOOL_PATH - + "\" REPLACE \"" + BOOL_VALUE2 + "\" failed on simple JSON object"); - } - } - - /** - * Test pointer REPLACE operation for {@code boolean} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testReplaceBoolOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 1"); - final JsonArray in = createBoolArray1(); - final JsonArray check = createSimpleBoolArrayReplaceBool(); - final JsonPointer ptr = Json.createPointer("/0"); - final JsonArray out = ptr.replace(in, toJsonValue(BOOL_FALSE)); - if (!assertEquals(check, out)) { - result.fail("Pointer REPLACE operation", "Pointer \"/0\" REPLACE \"" - + BOOL_FALSE + "\" failed on simple JSON array"); - } - } - - /** - * Test pointer REPLACE operation for {@code boolean} on simple JSON array of - * size 5. Starting with an array of size 5. - *
    - *
  • Replacing {@code boolean} items from the end to the beginning of this - * array. - *
  • Replacing {@code boolean} from the beginning to the end of this array. - *
- * - * @param result - * Tests result record. - */ - private void testReplaceBoolOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for boolean on simple JSON array of size 5"); - final JsonArray in = createSimpleBoolArray5(); - final JsonArray check = createSimpleBoolArray5R(); - verifyReplaceValues(result, in, check, - new String[] { "/4", "/3", "/1", "/0" }, - new Boolean[] { BOOL_FALSE, BOOL_TRUE, BOOL_FALSE, BOOL_TRUE }, - "Pointer REPLACE operation", - "Pointers \"/4\", \"/3\", \"/1\", \"/0\" REPLACE sequence failed on simple JSON array"); - verifyReplaceValues(result, in, check, - new String[] { "/0", "/1", "/3", "/4" }, - new Boolean[] { BOOL_TRUE, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE }, - "Pointer REPLACE operation", - "Pointers \"/0\", \"/1\", \"/3\", \"/4\" REPLACE sequence failed on simple JSON array"); - } - - /** - * Test pointer REPLACE operation for {@code JsonObject} on compound JSON - * object. - * - * @param result - * Tests result record. - */ - private void testReplaceObjectOnCompoundObject(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON object"); - final JsonObject in = createCompoundObjectWithObject(); - final JsonObject check = createCompoundObjectReplaceObject(); - final JsonPointer ptr = Json.createPointer(OBJ_PATH); - final JsonObject out = ptr.replace(in, OBJ_VALUE2); - if (!assertEquals(check, out)) { - result.fail("Pointer REPLACE operation", "Pointer \"" + OBJ_PATH - + "\" REPLACE \"" + OBJ_VALUE2 + "\" failed on simple JSON object"); - } - } - - /** - * Test pointer REPLACE operation for {@code JsonObject} on simple JSON array. - * - * @param result - * Tests result record. - */ - private void testReplaceObjectOnSimpleArray(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 1"); - final JsonArray in = createObjectArray1(); - final JsonArray check = createSimpleObjectArrayReplaceObject(); - final JsonPointer ptr = Json.createPointer("/0"); - final JsonArray out = ptr.replace(in, OBJ_VALUE); - if (!assertEquals(check, out)) { - result.fail("Pointer REPLACE operation", "Pointer \"/0\" REPLACE \"" - + OBJ_VALUE + "\" failed on simple JSON array"); - } - } - - /** - * Test pointer REPLACE operation for {@code JsonObject} on simple JSON array - * of size 5. Starting with an array of size 5. - *
    - *
  • Replacing {@code JsonObject} items from the end to the beginning of - * this array. - *
  • Replacing {@code JsonObject} from the beginning to the end of this - * array. - *
- * - * @param result - * Tests result record. - */ - private void testReplaceObjectOnSimpleArray2(final TestResult result) { - TestUtil.logMsg(" - for JsonObject on simple JSON array of size 5"); - final JsonArray in = createSimpleObjectArray5(); - final JsonArray check = createSimpleObjectArray5R(); - verifyReplaceValues(result, in, check, - new String[] { "/4", "/3", "/1", "/0" }, - new JsonObject[] { OBJ_VALUE_1, OBJ_VALUE_2, OBJ_VALUE_4, OBJ_VALUE_5 }, - "Pointer REPLACE operation", - "Pointers \"/4\", \"/3\", \"/1\", \"/0\" REPLACE sequence failed on simple JSON array"); - verifyReplaceValues(result, in, check, - new String[] { "/0", "/1", "/3", "/4" }, - new JsonObject[] { OBJ_VALUE_5, OBJ_VALUE_4, OBJ_VALUE_2, OBJ_VALUE_1 }, - "Pointer REPLACE operation", - "Pointers \"/0\", \"/1\", \"/3\", \"/4\" REPLACE sequence failed on simple JSON array"); - } - - // Tests based on RFC 6902 definitions and examples. - - /** - * Test pointer REPLACE for non existing location in object. - * {@see RFC 6902: - * 4.3. replace} defines:
- * The target location MUST exist for the operation to be successful. - */ - private void testReplaceOfNonExistingLocationInObject( - final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonObject"); - final JsonObject[] objsIn = new JsonObject[] { createEmptyObject(), - createSimpleObject(), createCompoundObject() }; - final String[] paths = new String[] { STR_PATH, INT_PATH, BOOL_PATH, - OBJ_PATH }; - final JsonValue[] values = new JsonValue[] { Json.createValue(STR_VALUE), - Json.createValue(INT_VALUE), toJsonValue(BOOL_VALUE), OBJ_VALUE }; - // Go trough all objects - for (int i = 0; i < objsIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - final JsonPointer ptr = Json.createPointer(paths[j]); - try { - final JsonObject out = ptr.replace(objsIn[i], values[i]); - result.fail("Pointer REPLACE operation", "Pointer \"" + paths[j] - + "\" REPLACE succeeded on non existing location"); - } catch (JsonException e) { - // There are too many combinations to log them. - } - } - } - } - - /** - * Test pointer REPLACE for non existing location in array. - * {@see RFC 6902: - * 4.2. remove} defines:
- * The target location MUST exist for the operation to be successful. - */ - private void testReplaceOfNonExistingLocationInArray( - final TestResult result) { - TestUtil.logMsg(" - for non existing location in JsonArray"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray1(), createIntArray2(), createSimpleBoolArray5(), - createObjectArray2() - - }; - final String[] paths = new String[] { "/", "/-1", "/-", "/5", "/0a", "/42", - STR_PATH + "/0" }; - final JsonValue[] values = new JsonValue[] { Json.createValue(STR_VALUE), - Json.createValue(STR_VALUE), Json.createValue(INT_VALUE), - toJsonValue(BOOL_VALUE), OBJ_VALUE }; - // Go trough all arrays - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all paths - for (int j = 0; j < paths.length; j++) { - final JsonPointer ptr = Json.createPointer(paths[j]); - try { - final JsonArray out = ptr.replace(arraysIn[i], values[i]); - result.fail("Pointer REPLACE operation", "Pointer \"" + paths[j] - + "\" REPLACE succeeded on non existing location"); - } catch (JsonException e) { - // There are too many combinations to log them. - } - } - } - } - - /** - * Test helper: Verify set of REPLACE operations on provided JSON array and - * verify result using provided expected JSON value. JSON pointer instance is - * used to modify the array. - * - * @param result - * Test suite result. - * @param in - * JSON array to be modified. - * @param check - * Expected modified JSON array (used for operation check). - * @param paths - * JSON array paths of values to be added. Pairs of {@code paths[i]} - * and {@code values[i]} are used for add operations. - * @param values - * JSON array values to be added on specified indexes. - * @param testName - * Name of this test. - * @param errorMessage - * Error message to be added on verification failure. - */ - private void verifyReplaceValues(final TestResult result, final JsonArray in, - final JsonArray check, final String[] paths, final Object[] values, - final String testName, final String errorMessage) { - if (paths.length != values.length) { - throw new IllegalArgumentException( - "Number of paths does not match number of indexes"); - } - JsonArray out = in; - for (int i = 0; i < paths.length; i++) { - final JsonPointer ptr = Json.createPointer(paths[i]); - out = ptr.replace(out, toJsonValue(values[i])); - } - if (!assertEquals(check, out)) { - result.fail(testName, errorMessage); - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerResolve.java b/src/com/sun/ts/tests/jsonp/api/pointertests/PointerResolve.java deleted file mode 100644 index 9be14fdd2f..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerResolve.java +++ /dev/null @@ -1,679 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.pointertests; - -import static com.sun.ts.tests.jsonp.api.common.JsonAssert.assertEquals; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_KEY10; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_KEY10_ENC; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_KEY_WHOLE; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR1; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR10; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR11_ENC; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR1_ITEM1; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR1_ITEM2; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR2; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR3; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR3_ENC; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR4; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR5; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR6; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR7; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR8; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_PTR9; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL1; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL10; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL11; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL1_ITEM1; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL1_ITEM2; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL2; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL3; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL4; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL5; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL6; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL7; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL8; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.RFC_VAL9; -import static com.sun.ts.tests.jsonp.api.common.PointerRFCObject.createRFC6901Object; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_FALSE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.BOOL_TRUE; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.INT_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.OBJ_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_1; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_3; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_4; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.STR_VALUE_5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createBoolArray2; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createEmptyArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleBoolArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleIntArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleObjectArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createSimpleStringArray5; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.createStringArray; -import static com.sun.ts.tests.jsonp.api.common.SimpleValues.toJsonValue; - -import com.sun.ts.lib.util.TestUtil; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -import jakarta.json.Json; -import jakarta.json.JsonArray; -import jakarta.json.JsonException; -import jakarta.json.JsonObject; -import jakarta.json.JsonPointer; -import jakarta.json.JsonValue; - -// $Id$ -/** - * {@see RFC 6901}: JavaScript - * Object Notation (JSON) Pointer resolving tests.
- */ -public class PointerResolve { - - /** - * Creates an instance of RFC 6901 JSON Pointer resolver tests. - */ - PointerResolve() { - super(); - } - - /** - * Test RFC 6901 JSON Pointer resolver tests. Suite entry point. - * - * @return Result of all tests in this suite. - */ - TestResult test() { - final TestResult result = new TestResult("RFC 6901 pointer resolving"); - TestUtil.logMsg("Testing RFC 6901 pointer resolving"); - testResolveWholeDocument(result); - testResolveEmptyName(result); - testResolveSimpleArray(result); - testResolveSimpleArrayItems(result); - testResolvePathWithSlash(result); - testResolvePathWithEncodedSlash(result); - testResolvePathWithPercent(result); - testResolvePathWithCaret(result); - testResolvePathWithVerticalBar(result); - testResolvePathWithBackSlash(result); - testResolvePathWithDoubleQuotes(result); - testResolvePathWithSpace(result); - testResolvePathWithTilde(result); - testResolvePathWithEncodedTilde(result); - testResolvePathWithEncodedTildeOne(result); - testResolveValidNumericIndexInArray(result); - testResolveMemberAfterLastInArray(result); - testResolveNumericIndexWithLeadingZeroInArray(result); - testResolvenonNumericIndexInArray(result); - return result; - } - - /** - * Test RFC 6901 JSON Pointer resolver for the whole document path. - * - * @param result - * Tests result record. - */ - private void testResolveWholeDocument(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_KEY_WHOLE + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = in; - final JsonPointer ptr = Json.createPointer(RFC_KEY_WHOLE); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_KEY_WHOLE + "\"", - "GET operation failed for \"" + RFC_KEY_WHOLE + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_KEY_WHOLE + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "": 0}. - * - * @param result - * Tests result record. - */ - private void testResolveEmptyName(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR2 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL2); - final JsonPointer ptr = Json.createPointer(RFC_PTR2); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR2 + "\"", - "GET operation failed for \"" + RFC_PTR2 + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR2 + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "foo": ["bar", "baz"]}. - * - * @param result - * Tests result record. - */ - private void testResolveSimpleArray(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR1 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = RFC_VAL1; - final JsonPointer ptr = Json.createPointer(RFC_PTR1); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR1 + "\"", - "GET operation failed for \"" + RFC_PTR1 + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR1 + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "foo": ["bar", "baz"]} array - * elements. - * - * @param result - * Tests result record. - */ - private void testResolveSimpleArrayItems(final TestResult result) { - final String[] itemPtrs = new String[] { RFC_PTR1_ITEM1, RFC_PTR1_ITEM2 }; - final String[] itemVals = new String[] { RFC_VAL1_ITEM1, RFC_VAL1_ITEM2 }; - final JsonObject in = createRFC6901Object(); - for (int i = 0; i < itemPtrs.length; i++) { - TestUtil.logMsg(" - resolving of \"" + itemPtrs[i] + "\" pointer"); - final JsonValue check = Json.createValue(itemVals[i]); - final JsonPointer ptr = Json.createPointer(itemPtrs[i]); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + itemPtrs[i] + "\"", - "GET operation failed for \"" + itemPtrs[i] + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + itemPtrs[i] + "\"", - "GET operation exception: " + e.getMessage()); - } - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "a/b": 1}. Character - * {@code '/'} is encoded as {@code "~1"} string. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithEncodedSlash(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR3_ENC + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL3); - final JsonPointer ptr = Json.createPointer(RFC_PTR3_ENC); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR3_ENC + "\"", - "GET operation failed for \"" + RFC_PTR3_ENC + "\" path"); - } - } catch (JsonException e) { - TestUtil.logMsg(" ! Exception: " + e.getMessage()); - result.fail("GET \"" + RFC_PTR3_ENC + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "a/b": 1}. Character - * {@code '/'} is not encoded as {@code "~1"} string. This results in invalid - * {@code "/a/b"} path and resolving such path must throw an exception. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithSlash(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR3 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonPointer ptr = Json.createPointer(RFC_PTR3); - try { - final JsonValue out = ptr.getValue(in); - result.fail("GET \"" + RFC_PTR3 + "\"", - "GET operation succeeded for \"" + RFC_PTR3 + "\" path"); - } catch (JsonException e) { - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "c%d": 2}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithPercent(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR4 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL4); - final JsonPointer ptr = Json.createPointer(RFC_PTR4); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR4 + "\"", - "GET operation failed for \"" + RFC_PTR4 + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR4 + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "e^f": 3}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithCaret(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR5 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL5); - final JsonPointer ptr = Json.createPointer(RFC_PTR5); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR5 + "\"", - "GET operation failed for \"" + RFC_PTR5 + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR5 + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "g|h": 4}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithVerticalBar(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR6 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL6); - final JsonPointer ptr = Json.createPointer(RFC_PTR6); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR6 + "\"", - "GET operation failed for \"" + RFC_PTR6 + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR6 + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "i\\j": 5}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithBackSlash(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR7 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL7); - final JsonPointer ptr = Json.createPointer(RFC_PTR7); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR7 + "\"", - "GET operation failed for \"" + RFC_PTR7 + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR7 + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "k\"l": 6}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithDoubleQuotes(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR8 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL8); - final JsonPointer ptr = Json.createPointer(RFC_PTR8); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR8 + "\"", - "GET operation failed for \"" + RFC_PTR8 + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR8 + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code " ": 7}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithSpace(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR9 + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL9); - final JsonPointer ptr = Json.createPointer(RFC_PTR9); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR9 + "\"", - "GET operation failed for \"" + RFC_PTR9 + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR9 + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "m~n": 8} without encoding. - * Passing this test is not mandatory. - * {@see RFC 6901: 3. - * Syntax} defines JSON pointer grammar as:
- * {@code json-pointer = *( "/" reference-token )}
- * {@code reference-token = *( unescaped / escaped )}
- * {@code unescaped = %x00-2E / %x30-7D / %x7F-10FFFF}
- * {@code escaped = "~" ( "0" / "1" )}
- * Characters {@code '/'} and {@code '~'} are excluded from {@code unescaped}. - * But having {@code '~'} outside escape sequence may be acceptable. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithTilde(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR10 + "\" pointer (optional)"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL10); - final JsonPointer ptr = Json.createPointer(RFC_PTR10); - boolean noError = true; - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - noError = false; - TestUtil.logMsg(" - Pointer \"" + RFC_KEY10 - + "\" did not return expected value"); - } - } catch (JsonException e) { - noError = false; - TestUtil.logMsg(" - Expected exception: " + e.getMessage()); - } - if (noError) { - TestUtil.logMsg( - " - Pointer resolving accepts '~' outside escape sequence"); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "m~n": 8}. Character - * {@code '~'} is encoded as {@code "~0"} string. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithEncodedTilde(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_KEY10_ENC + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL10); - final JsonPointer ptr = Json.createPointer(RFC_KEY10_ENC); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_KEY10_ENC + "\"", - "GET operation failed for \"" + RFC_KEY10_ENC + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_KEY10_ENC + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for {@code "o~1p": 9}. String - * {@code "~1"} is encoded as {@code "~01"} String. Proper encoded sequences - * transformation is described in - * {@see RFC 6901: 4. - * Evaluation} chapter: - * {@code "the string '~01' correctly becomes '~1' after transformation"}. - * - * @param result - * Tests result record. - */ - private void testResolvePathWithEncodedTildeOne(final TestResult result) { - TestUtil.logMsg(" - resolving of \"" + RFC_PTR11_ENC + "\" pointer"); - final JsonObject in = createRFC6901Object(); - final JsonValue check = Json.createValue(RFC_VAL11); - final JsonPointer ptr = Json.createPointer(RFC_PTR11_ENC); - try { - final JsonValue out = ptr.getValue(in); - if (!assertEquals(out, check)) { - result.fail("GET \"" + RFC_PTR11_ENC + "\"", - "GET operation failed for \"" + RFC_PTR11_ENC + "\" path"); - } - } catch (JsonException e) { - result.fail("GET \"" + RFC_PTR11_ENC + "\"", - "GET operation exception: " + e.getMessage()); - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for existing numeric indexes of an - * array. {@see RFC - * 6901: 4. Evaluation} chapter:
- * If the currently referenced value is a JSON array, the reference token MUST - * contain either: - *
    - *
  • characters comprised of digits (see ABNF below; note that leading zeros - * are not allowed) that represent an unsigned base-10 integer value, making - * the new referenced value the array element with the zero-based index - * identified by the token
  • - *
- */ - private void testResolveValidNumericIndexInArray(final TestResult result) { - TestUtil.logMsg( - " - resolving of pointer containing existing numeric array index"); - final JsonArray[] arraysIn = new JsonArray[] { createSimpleStringArray5(), - createSimpleIntArray5(), createSimpleBoolArray5(), - createSimpleObjectArray5() }; - final JsonValue[] strings = new JsonValue[] { toJsonValue(STR_VALUE_1), - toJsonValue(STR_VALUE_2), toJsonValue(STR_VALUE_3), - toJsonValue(STR_VALUE_4), toJsonValue(STR_VALUE_5) }; - final JsonValue[] ints = new JsonValue[] { toJsonValue(INT_VALUE_1), - toJsonValue(INT_VALUE_2), toJsonValue(INT_VALUE_3), - toJsonValue(INT_VALUE_4), toJsonValue(INT_VALUE_5) }; - final JsonValue[] bools = new JsonValue[] { toJsonValue(BOOL_FALSE), - toJsonValue(BOOL_TRUE), toJsonValue(BOOL_TRUE), toJsonValue(BOOL_FALSE), - toJsonValue(BOOL_TRUE) }; - final JsonValue[] objs = new JsonValue[] { OBJ_VALUE_1, OBJ_VALUE_2, - OBJ_VALUE_3, OBJ_VALUE_4, OBJ_VALUE_5 }; - final JsonValue[][] checks = new JsonValue[][] { strings, ints, bools, - objs }; - // Go trough all array types - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all valid indexes in arrays - for (int j = 0; j < 5; j++) { - final String path = "/" + Integer.toString(j); - final JsonPointer ptr = Json.createPointer(path); - final JsonValue out = ptr.getValue(arraysIn[i]); - if (!assertEquals(out, checks[i][j])) { - JsonValue.ValueType type = checks[i][j].getValueType(); - String typeName = type == JsonValue.ValueType.TRUE - || type == JsonValue.ValueType.FALSE ? "boolean" - : type.toString().toLowerCase(); - result.fail("GET \"" + path + "\"", "GET operation failed for \"" - + path + "\" path on " + typeName + " array"); - } - } - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for character {@code '-'} marking the - * end of an array. - * {@see RFC 6901: 4. - * Evaluation} chapter:
- * If the currently referenced value is a JSON array, the reference token MUST - * contain either: - *
    - *
  • exactly the single character "-", making the new referenced value the - * (nonexistent) member after the last array element
  • - *
- * Note that the use of the "-" character to index an array will always result - * in such an error condition because by definition it refers to a nonexistent - * array element. Thus, applications of JSON Pointer need to specify how that - * character is to be handled, if it is to be useful. - */ - private void testResolveMemberAfterLastInArray(final TestResult result) { - TestUtil.logMsg(" - resolving of array \"/-\" pointer"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray(), createSimpleIntArray5(), createBoolArray2(), - createSimpleObjectArray5() }; - final String[] typeNames = new String[] { "empty", "String", "int", - "boolean", "JsonObject" }; - // Go trough all array types - for (int i = 0; i < arraysIn.length; i++) { - final JsonPointer ptr = Json.createPointer("/-"); - try { - final JsonValue out = ptr.getValue(arraysIn[i]); - result.fail("GET \"/-\"", "GET operation succeeded for \"/-\" key"); - } catch (JsonException e) { - TestUtil.logMsg(" - Expected exception for \"/-\" path in " - + typeNames[i] + " array: " + e.getMessage()); - } - } - } - - // TODO: Consider whether passing this test is mandatory or optional. - /** - * Test RFC 6901 JSON Pointer resolver for existing index with leading - * {@code '0'} on array. - * {@see RFC 6901: 4. - * Evaluation} chapter:
- * {@code array-index = %x30 / ( %x31-39 *(%x30-39) )} grammar rule prohibits - * indexes with leading {@code '0'} except the case when index is exactly - * {@code "0"}. Exact case for {@code "0"} is being checked in other tests. - * This test checks illegal values with leading {@code '0'} followed by valid - * index numbers. - */ - private void testResolveNumericIndexWithLeadingZeroInArray( - final TestResult result) { - TestUtil.logMsg( - " - resolving of pointer containing numeric array index with leading '0' (optional)"); - final JsonArray[] arraysIn = new JsonArray[] { createSimpleStringArray5(), - createSimpleIntArray5(), createSimpleBoolArray5(), - createSimpleObjectArray5() }; - final String[] typeNames = new String[] { "String", "int", "boolean", - "JsonObject" }; - // Go trough all array types - for (int i = 0; i < arraysIn.length; i++) { - // Go trough all valid indexes in arrays - for (int j = 0; j < 5; j++) { - final String path = "/0" + Integer.toString(j); - final JsonPointer ptr = Json.createPointer(path); - try { - final JsonValue out = ptr.getValue(arraysIn[i]); - TestUtil.logMsg(" ! GET operation succeeded for \"" + path - + "\" path on " + typeNames[i] + " array"); - // result.fail("GET \""+path+"\"", - // "GET operation succeeded for \""+path+"\" key on "+typeNames[i]+" - // array"); - } catch (JsonException e) { - // There are too many combinations to log them. - } - } - } - } - - /** - * Test RFC 6901 JSON Pointer resolver for invalid index containing non - * numeric characters on array. - * {@see RFC 6901: 4. - * Evaluation} chapter:
- * {@code array-index = %x30 / ( %x31-39 *(%x30-39) )} grammar rule prohibits - * indexes with anything else than sequence of digits. Index {@code '-'} is - * being checked in another tests. The only exception is path for whole - * document ({@code ""}) which must return the whole array. - */ - private void testResolvenonNumericIndexInArray(final TestResult result) { - TestUtil - .logMsg(" - resolving of pointer containing non numeric array index"); - final JsonArray[] arraysIn = new JsonArray[] { createEmptyArray(), - createStringArray(), createSimpleIntArray5(), createBoolArray2(), - createSimpleObjectArray5() }; - final String[] typeNames = new String[] { "empty", "String", "int", - "boolean", "JsonObject" }; - final String wholeDocument = ""; - final String[] paths = new String[] { "/", "/1a", "/b4", "/name" }; - // Go trough all array types - for (int i = 0; i < arraysIn.length; i++) { - final JsonPointer wholeDocPtr = Json.createPointer(wholeDocument); - try { - final JsonValue wholeOut = wholeDocPtr.getValue(arraysIn[i]); - if (!assertEquals(wholeOut, arraysIn[i])) { - result.fail("GET \"" + wholeDocument + "\"", - "GET operation failed for \"" + wholeDocument + "\" path on " - + typeNames[i] + " array"); - } - } catch (JsonException e) { - result.fail("GET \"" + wholeDocument + "\"", - "GET operation failed for \"" + wholeDocument + "\" path on " - + typeNames[i] + " array: " + e.getMessage()); - } - for (int j = 0; j < paths.length; j++) { - final JsonPointer ptr = Json.createPointer(paths[j]); - try { - final JsonValue out = ptr.getValue(arraysIn[i]); - result.fail("GET \"" + paths[j] + "\"", - "GET operation succeeded for \"" + paths[j] + "\" path on " - + typeNames[i] + " array"); - } catch (JsonException e) { - // There are too many combinations to log them. - } - } - } - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerTests.java b/src/com/sun/ts/tests/jsonp/api/pointertests/PointerTests.java deleted file mode 100644 index 2b657abd5b..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/pointertests/PointerTests.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 com.sun.ts.tests.jsonp.api.pointertests; - -import com.sun.ts.tests.jsonp.api.common.JsonPTest; -import com.sun.ts.tests.jsonp.api.common.TestResult; - -// $Id$ -/** - * {@see RFC 6901}: JavaScript - * Object Notation (JSON) Pointer compatibility tests.
- * JSON-P API defines {@link jakarta.json.JsonPointer} interface to work with RFC - * 6901 JSON Pointer. - */ -public class PointerTests extends JsonPTest { - - /** - * Test JSON-P API response on pointer resolving.
- * Checks set of JSON pointers from sample object of RFC 6901. - * {@see RFC 6901: 4. - * Evaluation} and - * {@see RFC 6901: 5. - * JSON String Representation}. - * - * @throws Fault - * when this test failed. - * - * @testName: jsonPointerResolveTest - * @assertion_ids: JSONP:JAVADOC:643; JSONP:JAVADOC:582; JSONP:JAVADOC:583; - * JSONP:JAVADOC:584; JSONP:JAVADOC:661; JSONP:JAVADOC:662; - * JSONP:JAVADOC:663; - * @test_Strategy: Test API response on various JSON pointer values. - */ - public void jsonPointerResolveTest() throws Fault { - PointerResolve resolveTest = new PointerResolve(); - final TestResult result = resolveTest.test(); - result.eval(); - } - - /** - * Test JSON-P API response on - * {@see RFC 6902: - * 4.1. add} operation using RFC 6901 pointer instance.
- * Checks set of simple JSON values.
- * - * @throws Fault - * when this test failed. - * - * @testName: jsonPointerAddOperationTest - * @assertion_ids: JSONP:JAVADOC:642; JSONP:JAVADOC:582; JSONP:JAVADOC:583; - * JSONP:JAVADOC:584; JSONP:JAVADOC:661; JSONP:JAVADOC:662; - * JSONP:JAVADOC:663; - * @test_Strategy: Test API response on various JSON pointer values. - */ - public void jsonPointerAddOperationTest() throws Fault { - PointerAdd addTest = new PointerAdd(); - final TestResult result = addTest.test(); - result.eval(); - } - - /** - * Test JSON-P API response on - * {@see RFC 6902: - * 4.2. remove} operation using RFC 6901 pointer instance.
- * Checks set of simple JSON values.
- * - * @throws Fault - * when this test failed. - * - * @testName: jsonPointerRemoveOperationTest - * @assertion_ids: JSONP:JAVADOC:644; JSONP:JAVADOC:582; JSONP:JAVADOC:661; - * @test_Strategy: Test API response on various JSON pointer values. - */ - public void jsonPointerRemoveOperationTest() throws Fault { - PointerRemove removeTest = new PointerRemove(); - final TestResult result = removeTest.test(); - result.eval(); - } - - /** - * Test JSON-P API response on - * {@see RFC 6902: - * 4.3. replace} operation using RFC 6901 pointer instance.
- * Checks set of simple JSON values.
- * - * @throws Fault - * when this test failed. - * - * @testName: jsonPointerReplaceOperationTest - * @assertion_ids: JSONP:JAVADOC:645; JSONP:JAVADOC:582; JSONP:JAVADOC:583; - * JSONP:JAVADOC:584; JSONP:JAVADOC:661; JSONP:JAVADOC:662; - * JSONP:JAVADOC:663; - * @test_Strategy: Test API response on various JSON pointer values. - */ - public void jsonPointerReplaceOperationTest() throws Fault { - PointerReplace replaceTest = new PointerReplace(); - final TestResult result = replaceTest.test(); - result.eval(); - } - -} diff --git a/src/com/sun/ts/tests/jsonp/api/pointertests/build.xml b/src/com/sun/ts/tests/jsonp/api/pointertests/build.xml deleted file mode 100644 index c2647f990b..0000000000 --- a/src/com/sun/ts/tests/jsonp/api/pointertests/build.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/com/sun/ts/tests/jsonp/util/FileUTFConverter.java b/src/com/sun/ts/tests/jsonp/util/FileUTFConverter.java deleted file mode 100644 index fe675af735..0000000000 --- a/src/com/sun/ts/tests/jsonp/util/FileUTFConverter.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ - -/* - * Usage: java FileUTFConverter [-toUTF|-fromUTF] encoding infile outfile - * - * Utility program for converting a UTF-8 file to various UTF - * encoded files and vice-versa. - * - * Example(s): - * - * java FileUTFConverter -toUTF UTF-16 jsonObjectUTF8.json jsonObjectUTF16.json - * - * The above takes a UTF-8 encoded input file (jsonObjectUTF8.json) and converts - * it to a UTF-16 encoded output file (jsonObjectUTF16.json). - * - * java FileUTFConverter -fromUTF UTF-16 jsonObjectUTF16.json jsonObjectUTF8.json - * - * The above takes a UTF-16 encoded input file (jsonObjectUTF16.json) and - * converts it to a UTF-8 encoded output file (jsonObjectUTF8.json). - * - * All UTF encodings can be used: - * - * UTF-8 - * UTF-16 - * UTF-16BE - * UTF-16LE - * UTF-32BE - * UTF-32LE - */ - -package com.sun.ts.tests.jsonp.util; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; - -public class FileUTFConverter { - - private static final String USAGE = "Usage : java FileUTFConverter [-toUTF|-fromUTF] encoding infile outfile"; - - public static void main(String args[]) { - try { - if (args.length != 4) { - System.err.println(USAGE); - System.exit(1); - } - - // Convert UTF-8 input file to specified UTF encoded output file - if (args[0].equals("-toUTF")) { - System.out - .println("FileUTFConverter-> convert UTF-8 encoded input file (" - + args[2] + "), to encoding (" + args[1] - + ") and write to output file (" + args[3] + ")"); - FileInputStream fis = new FileInputStream(args[2]); - BufferedReader br = new BufferedReader( - new InputStreamReader(fis, "UTF-8")); - FileOutputStream fos = new FileOutputStream(args[3]); - BufferedWriter bw = new BufferedWriter( - new OutputStreamWriter(fos, args[1])); - for (String s = ""; (s = br.readLine()) != null;) { - bw.write(s + System.getProperty("line.separator")); - bw.flush(); - } - bw.close(); - br.close(); - // Convert specified UTF encoded input file to UTF-8 encoded output file - } else if (args[0].equals("-fromUTF")) { - System.out.println("FileUTFConverter-> convert UTF encoded input file (" - + args[2] + "), from encoding (" + args[1] - + ") and write to UTF-8 encoded output file (" + args[3] + ")"); - FileInputStream fis = new FileInputStream(args[2]); - BufferedReader br = new BufferedReader( - new InputStreamReader(fis, args[1])); - FileOutputStream fos = new FileOutputStream(args[3]); - BufferedWriter bw = new BufferedWriter( - new OutputStreamWriter(fos, "UTF-8")); - for (String s = ""; (s = br.readLine()) != null;) { - bw.write(s + System.getProperty("line.separator")); - bw.flush(); - } - bw.close(); - br.close(); - } else { - System.err.println(USAGE); - System.exit(1); - } - - System.exit(0); - - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - } -} diff --git a/src/com/sun/ts/tests/jsonp/util/MyEncoder.java b/src/com/sun/ts/tests/jsonp/util/MyEncoder.java deleted file mode 100644 index cd330ccdf2..0000000000 --- a/src/com/sun/ts/tests/jsonp/util/MyEncoder.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ - -package com.sun.ts.tests.jsonp.util; - -import java.io.FileReader; -import java.io.FileWriter; - -/* - * Used to generate an encoded file preceded by N null characters. - * - * This utility takes a valid Json text file as input and generates - * an encoded version as output file with N null characters preceded by - * each character. For empty files it will just output the N null chars. - * - */ -public class MyEncoder { - - private static final int NULL = '\0'; - - private static final String USAGE = "Usage : java MyEncoder #nulls infile outfile"; - - public static void main(String args[]) { - if (args.length != 3) { - System.err.println(USAGE); - System.exit(1); - } - - FileReader inputStream = null; - FileWriter outputStream = null; - - try { - int n = Integer.parseInt(args[0]); - inputStream = new FileReader(args[1]); - outputStream = new FileWriter(args[2]); - - System.out.println("Null chars: " + args[0]); - System.out.println("Input file: " + args[1]); - System.out.println("Output file: " + args[2]); - - System.out - .println("\nCreating an encoded file with each char preceded by " + n - + " null chars.\n"); - - int c; - int nchars = 0; - while ((c = inputStream.read()) != -1) { - nchars++; - for (int i = 0; i < n; i++) - outputStream.write(NULL); - outputStream.write(c); - } - if (nchars == 0) { - for (int i = 0; i < n; i++) - outputStream.write(NULL); // if empty file at least write the nulls - // out - } - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } finally { - if (inputStream != null) { - try { - inputStream.close(); - } catch (Exception e) { - } - } - if (outputStream != null) { - try { - outputStream.close(); - } catch (Exception e) { - } - } - } - System.exit(0); - } -} diff --git a/src/com/sun/ts/tests/jsonp/util/StringUTFConverter.java b/src/com/sun/ts/tests/jsonp/util/StringUTFConverter.java deleted file mode 100644 index 8fcae6c868..0000000000 --- a/src/com/sun/ts/tests/jsonp/util/StringUTFConverter.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2013, 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 - */ - -/* - * $Id$ - */ - -/* - * Usage: java StringUTFConverter inputstring encoding outputfile - * - * Utility program to convert an input string to a UTF encoded output file. - * - * Example(s): - * - * java StringUTFConverter "foo" UTF-16LE fooUTF16LE - * - * The above converts an input string "foo" and outputs to UTF-16LE encoded - * output file (fooUTF16LE). - */ - -package com.sun.ts.tests.jsonp.util; - -import java.io.BufferedWriter; -import java.io.FileOutputStream; -import java.io.OutputStreamWriter; - -public class StringUTFConverter { - - private static final String USAGE = "Usage : java StringUTFConverter inputstring encoding outputfile"; - - public static void main(String args[]) { - try { - if (args.length != 3) { - System.err.println(USAGE); - System.exit(1); - } - - // Convert string to specified UTF encoded output file - System.out.println( - "StringtoUTF-> convert string (" + args[0] + "), to encoding (" - + args[1] + ") and write to output file (" + args[2] + ")"); - FileOutputStream fos = new FileOutputStream(args[2]); - BufferedWriter bw = new BufferedWriter( - new OutputStreamWriter(fos, args[1])); - bw.write(args[0]); - bw.flush(); - bw.close(); - - System.exit(0); - - } catch (Exception e) { - e.printStackTrace(); - System.exit(1); - } - } -} diff --git a/src/com/sun/ts/tests/jsonp/util/build.xml b/src/com/sun/ts/tests/jsonp/util/build.xml deleted file mode 100644 index 29ece1a303..0000000000 --- a/src/com/sun/ts/tests/jsonp/util/build.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - diff --git a/src/com/sun/ts/tests/signaturetest/signature-repository/jakarta.json.sig b/src/com/sun/ts/tests/signaturetest/signature-repository/jakarta.json.sig index ac7005e266..3687f52806 100644 --- a/src/com/sun/ts/tests/signaturetest/signature-repository/jakarta.json.sig +++ b/src/com/sun/ts/tests/signaturetest/signature-repository/jakarta.json.sig @@ -464,6 +464,7 @@ meth public final java.lang.String name() meth public java.lang.String toString() meth public static <%0 extends java.lang.Enum<{%%0}>> {%%0} valueOf(java.lang.Class<{%%0}>,java.lang.String) supr java.lang.Object +hfds name,ordinal CLSS public java.lang.Exception cons protected init(java.lang.String,java.lang.Throwable,boolean,boolean) @@ -472,6 +473,7 @@ 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 +hfds serialVersionUID CLSS public abstract interface java.lang.Iterable<%0 extends java.lang.Object> meth public abstract java.util.Iterator<{java.lang.Iterable%0}> iterator() @@ -500,6 +502,7 @@ 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 +hfds serialVersionUID CLSS public java.lang.Throwable cons protected init(java.lang.String,java.lang.Throwable,boolean,boolean) @@ -522,6 +525,8 @@ 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 +hfds CAUSE_CAPTION,EMPTY_THROWABLE_ARRAY,NULL_CAUSE_MESSAGE,SELF_SUPPRESSION_MESSAGE,SUPPRESSED_CAPTION,SUPPRESSED_SENTINEL,UNASSIGNED_STACK,backtrace,cause,depth,detailMessage,serialVersionUID,stackTrace,suppressedExceptions +hcls PrintStreamOrWriter,SentinelHolder,WrappedPrintStream,WrappedPrintWriter CLSS public abstract interface java.util.Collection<%0 extends java.lang.Object> intf java.lang.Iterable<{java.util.Collection%0}> diff --git a/user_guides/build_tckugs.sh b/user_guides/build_tckugs.sh index a30bf56687..e4a93fa2f5 100644 --- a/user_guides/build_tckugs.sh +++ b/user_guides/build_tckugs.sh @@ -27,7 +27,7 @@ export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH cd ${WORKSPACE} export BASEDIR=`pwd` export USERGUIDEDIR=$BASEDIR/user_guides -alltcks="caj concurrency el jacc jaspic jaxws jca jms jpa jsf jsonb jsonp jsp jstl jta saaj securityapi servlet websocket" +alltcks="caj concurrency el jacc jaspic jaxws jca jms jpa jsf jsonb jsp jstl jta saaj securityapi servlet websocket" cd $USERGUIDEDIR rm -rf $USERGUIDEDIR/tmp diff --git a/user_guides/jsonp/README.md b/user_guides/jsonp/README.md deleted file mode 100644 index a3ec2b697b..0000000000 --- a/user_guides/jsonp/README.md +++ /dev/null @@ -1,77 +0,0 @@ -# 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/user_guides/jsonp/pom.xml b/user_guides/jsonp/pom.xml deleted file mode 100644 index fbb7aae6d6..0000000000 --- a/user_guides/jsonp/pom.xml +++ /dev/null @@ -1,258 +0,0 @@ - - - - - 4.0.0 - - org.eclipse.ee4j - project - 1.0.5 - - org.glassfish - tck_jsonp - pom - 2.0.1 - Eclipse Foundation Technology Compatibility Kit User's Guide for Jakarta JSON Processing for Jakarta EE, Release 2.0 - - - UTF-8 - ${project.build.directory}/staging - true - 2.4.2 - 2.1.0 - 2.1.0 - 1.5.3 - 0.3.3 - 2.3.30 - - - Jakarta-JSON-Processing-TCK-Users-Guide.pdf - true - - - - - scm:git:git@github.com:eclipse-ee4j/jakartaee-tck.git - - - - - package - - - org.apache.maven.plugins - maven-clean-plugin - - - - src/main/jbake/content - - toc.adoc - - - - - - - org.apache.maven.plugins - maven-enforcer-plugin - - - enforce-versions - - enforce - - - - - [1.8.0,) - You need JDK8 or newer - - - - - - - - org.glassfish.doc - glassfish-doc-maven-plugin - - - generate-toc - generate-resources - - toc - - - - [0-9]+\s.*,Preface.*,Part\s.* - - - - - generate-book - generate-resources - - book - - - - - - org.jbake - jbake-maven-plugin - - ${site.output.dir} - - ${status} - - - - - build-site - generate-resources - - generate - - - - - - org.asciidoctor - asciidoctor-maven-plugin - - ${project.build.directory}/book - book.adoc - - ${project.build.directory}/staging/ - pdf - ${doc.pdf} - - ${project.basedir}/src/theme - jakartaee - book - ${status} - - - font - - - font - true - - - - true - true - - - - - generate-pdf-doc - generate-resources - - process-asciidoc - - - - - - org.apache.maven.plugins - maven-scm-publish-plugin - - - deploy-site - deploy - - publish-scm - - - gh-pages - false - Update site - - - - - - - - - - org.apache.maven.plugins - maven-clean-plugin - 3.1.0 - - - org.glassfish.doc - glassfish-doc-maven-plugin - 1.3 - - - org.apache.maven.plugins - maven-enforcer-plugin - 3.0.0-M3 - - - org.apache.maven.plugins - maven-assembly-plugin - 3.3.0 - - - org.apache.maven.plugins - maven-scm-publish-plugin - 3.1.0 - - - org.jbake - jbake-maven-plugin - ${jbake.maven.plugin.version} - - - org.asciidoctor - asciidoctorj - ${asciidoctorj.version} - - - org.asciidoctor - asciidoctorj-diagram - ${asciidoctorj.diagram.version} - - - org.freemarker - freemarker - ${freemarker.version} - - - - - org.asciidoctor - asciidoctor-maven-plugin - ${asciidoctorj.maven.plugin.version} - - - org.asciidoctor - asciidoctorj-pdf - ${asciidoctorj.pdf.version} - - - - - - - diff --git a/user_guides/jsonp/src/main/jbake/assets/README.md b/user_guides/jsonp/src/main/jbake/assets/README.md deleted file mode 100644 index f8f962c0ab..0000000000 --- a/user_guides/jsonp/src/main/jbake/assets/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# About - -The {{site.title}} project contains the [AsciiDoc](http://asciidoc.org/) -source code for the ... diff --git a/user_guides/jsonp/src/main/jbake/assets/_config.yml b/user_guides/jsonp/src/main/jbake/assets/_config.yml deleted file mode 100644 index 0bf6c72c25..0000000000 --- a/user_guides/jsonp/src/main/jbake/assets/_config.yml +++ /dev/null @@ -1,13 +0,0 @@ -remote_theme: jakartaee/jekyll-theme-jakarta-ee - -title: [tck_jsonp_v2_0] -description: [Oracle Technology Compatibility Kit User's Guide for Java API for JSON Processing 2.0 for Technology Licensees, Release 2.0] - -# sidebar links url -links: - source: https://github.com/eclipse-ee4j/jsonp - download: https://github.com/eclipse-ee4j/jsonp/releases/tag/2.0.0-RELEASE - #mailinglist: https://javaee.groups.io/g/tck_jsonp_v1_1 - #javadocs: - docs: https://eclipse-ee4j.github.io/jsonp - #faq: diff --git a/user_guides/jsonp/src/main/jbake/assets/css/style.css b/user_guides/jsonp/src/main/jbake/assets/css/style.css deleted file mode 100644 index 182f7559b6..0000000000 --- a/user_guides/jsonp/src/main/jbake/assets/css/style.css +++ /dev/null @@ -1,313 +0,0 @@ -/* 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/user_guides/jsonp/src/main/jbake/assets/img/eclipse_foundation_logo_tiny.png b/user_guides/jsonp/src/main/jbake/assets/img/eclipse_foundation_logo_tiny.png deleted file mode 100644 index ee830aeb93..0000000000 Binary files a/user_guides/jsonp/src/main/jbake/assets/img/eclipse_foundation_logo_tiny.png and /dev/null differ diff --git a/user_guides/jsonp/src/main/jbake/content/README b/user_guides/jsonp/src/main/jbake/content/README deleted file mode 100644 index 05fa2c27fd..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/README +++ /dev/null @@ -1,77 +0,0 @@ -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/user_guides/jsonp/src/main/jbake/content/attributes.conf b/user_guides/jsonp/src/main/jbake/content/attributes.conf deleted file mode 100644 index 978e863c67..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/attributes.conf +++ /dev/null @@ -1,37 +0,0 @@ -:TechnologyFullName: Jakarta JSON Processing -:TechnologyShortName: JSON Processing -:LegacyAcronym: JSONP -:ReleaseDate: May 2021 -:CopyrightDates: 2017, 2021 -:TechnologyVersion: 2.0 -:TechnologyRI: Eclipse JSON Processing 2.0.1 -:TechnologyRIURL: https://projects.eclipse.org/projects/ee4j.jsonp -:SpecificationURL: https://jakarta.ee/specifications/jsonp/2.0/ -:TCKInquiryList: mailto:jakartaee-tck-dev@eclipse.org[jakartaee-tck-dev@eclipse.org] -:SpecificationInquiryList: mailto:jsonp-dev@eclipse.org[jsonp-dev@eclipse.org] -:techID: JSONP -// 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: JSONP_HOME -// Java SE version required. -:SEversion: 8 (1.8) or 11 -:AntVersion: 1.10.0+ -:JakartaEEVersion: 9.1 -:JavaTestVersion: 5.0 -:jteFileName: /bin/ts.jte -:jtxFileName: /bin/ts.jtx -:TCKPackageName: jakarta-jsonp-tck-2.0.1.zip -// Directory names used in examples in using.adoc. -:sigTestDirectoryExample: /src/com/sun/ts/tests/signaturetest/jsonp -:singleTestDirectoryExample: /src/com/sun/ts/tests/jsonp -:subsetTestDirectoryExample: /src/com/sun/ts/tests/jsonp -// Define this attribute (uncomment it) if the TCK needs the rebuild appendix. -// :rebuild: diff --git a/user_guides/jsonp/src/main/jbake/content/config.adoc b/user_guides/jsonp/src/main/jbake/content/config.adoc deleted file mode 100644 index f6c62494e9..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/config.adoc +++ /dev/null @@ -1,487 +0,0 @@ -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 and -JavaTest harness software. 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 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 Compatible Implementation -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -After configuring your environment as described in this section, -continue with the instructions in link:#GBFUY[Section 4.6, "Using the -JavaTest Harness Software."] - - -[NOTE] -======================================================================= - -In these instructions, variables in angle brackets need to be expanded -for each platform. For example, `` becomes `$TS_HOME` on -Solaris/Linux and `%TS_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 8 or 11 is installed - b. `ANT_HOME` to the directory in which Apache Ant {AntVersion} is installed - c. `TS_HOME` to the directory in which the {TechnologyShortName} TCK - {TechnologyVersion} software is installed - d. +{TechnologyHomeEnv}+ to the directory in which the {TechnologyShortName} - {TechnologyVersion} CI has been installed - e. `PATH` to include the following directories: `JAVA_HOME/bin`, - +{TechnologyHomeEnv}/bin+, and `ANT_HOME/bin` -2. Copy /bin/ts.jte.jdk11 as /bin/ts.jte if JAVA_HOME is Java SE 11. -Edit your `/bin/ts.jte` file and set the following -environment variables: - a. `jsonp.classes` to the JAR file(s) that contain your {TechnologyShortName} {TechnologyVersion} - implementation classes + - For example, if you were using the {TechnologyFullName} {TechnologyVersion} CI, you would set - this property to jsonp.classes=jakarta.json-{TechnologyVersion}.0.jar. - b. `jsonp.resources` should not be modified + - This property points to JSON resource data files that are used by the - {TechnologyShortName} {TechnologyVersion} TCK. - c. `jsonp.alt.provider.classes` should not be modified + - This property is set automatically when running the {TechnologyShortName} TCK - pluggability tests to test the SPI provider interface when using the - top-level command line `runclient` or `run.pluggability` Ant targets. - The property is included as part of the `ts.run.classpath` property and - is placed before `jsonp.classes` in the classpath so the {TechnologyShortName} TCK can - pick up the TCK-supplied provider when set, not the provider supplied - with the {TechnologyShortName} {TechnologyVersion} implementation under test. This property should only - be set when running the pluggability tests. All other tests use the - provider supplied with the {TechnologyShortName} {TechnologyVersion} implementation under test. - - -[[GCLHU]][[configuring-your-environment-to-repackage-and-run-the-tck-against-the-vendor-implementation]] - -4.2 Configuring Your Environment to Repackage and Run the TCK Against the Vendor Implementation -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -After configuring your environment as described in this section, -continue with the instructions in link:#GBFUY[Section 4.4, "Using the -JavaTest Harness Software."] - - -[NOTE] -======================================================================= - -In these instructions, variables in angle brackets need to be expanded -for each platform. For example, `` becomes `$TS_HOME` on -Solaris/Linux and `%TS_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 8 or 11 is installed - b. `ANT_HOME` to the directory in which Apache Ant {AntVersion} is installed - c. `TS_HOME` to the directory in which the {TechnologyShortName} TCK - {TechnologyVersion} software is installed - d. +{TechnologyHomeEnv}+ to the directory in which the {TechnologyShortName} - {TechnologyVersion} CI has been installed - e. `PATH` to include the following directories: `JAVA_HOME/bin`, - +{TechnologyHomeEnv}/bin+, and `ANT_HOME/bin` -2. Copy /bin/ts.jte.jdk11 as /bin/ts.jte if JAVA_HOME is Java SE 11. -Edit your `/bin/ts.jte` file and set the following -environment variables: - a. `jsonp.classes` to the JAR file(s) that contain your {TechnologyShortName} {TechnologyVersion} - implementation classes - b. `jsonp.resources` should not be modified + - This property points to JSON resource data files that are used by the - {TechnologyShortName} {TechnologyVersion} TCK. - c. `jsonp.alt.provider.classes` should not be modified + - This property is set automatically when running the {TechnologyShortName} TCK - pluggability tests to test the SPI provider interface when using the - top-level command line `runclient` or `run.pluggability` Ant targets. - The property is included as part of the `ts.run.classpath` property and - is placed before `jsonp.classes` in the classpath so the {TechnologyShortName} TCK can - pick up the TCK-supplied provider when set, not the provider supplied - with the {TechnologyShortName} {TechnologyVersion} implementation under test. This property should only - be set when running the pluggability tests. All other tests use the - provider supplied with the {TechnologyShortName} {TechnologyVersion} implementation under test. - - - -[[GHGDG]][[publishing-the-test-applications]] - -4.3 Publishing the Test Applications -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Not needed for the {TechnologyShortName} TCK. - -[[GHGDH]][[custom-configuration-handlers]] - -4.4 Custom Configuration Handlers -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Configuration handlers are used to configure and unconfigure a -{TechnologyShortName} {TechnologyVersion} implementation during the -certification process. These are similar to deployment handlers but -used for configuration. A configuration handler is an Ant build file -that contains at least the required targets listed below: - - * `config.vi` - to configure the vendor implementation - * `clean.vi` - to unconfigure the vendor implementation - -These targets are called from the `/bin/build.xml` file and -call down into the implementation-specific configuration handlers. - -To provide your own configuration handler, create a config.vi.xml file -with the necessary configuration steps for your implementation and place -the file under the `/bin/xml/impl/` directory. - -For more information, you may wish to view `/bin/xml/impl/glassfish/config.vi.xml`, -the configuration file for Jakarta EE {JakartaEEVersion} Compatible Implementation, Eclipse GlassFish. - -[[GBFWG]][[custom-deployment-handlers]] - -4.5 Custom Deployment Handlers -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Deployment handlers are used to deploy and undeploy the WAR files that -contain the tests to be run during the certification process. A deployment -handler is an Ant build file that contains at least the required targets -listed in the table below. - -The {TechnologyShortName} TCK provides these deployment handlers: - -* `/bin/xml/impl/none/deploy.xml` -* `/bin/xml/impl/glassfish/deploy.xml` -* `/bin/xml/impl/tomcat/deploy.xml` - -The `deploy.xml` files in each of these directories are used to control -deployment to a specific container (no deployment, deployment to -the Eclipse GlassFish Web container, deployment to the Tomcat Web container) -denoted by the name of the directory in which each `deploy.xml` file -resides. The primary `build.xml` file in the `/bin` directory -has a target to invoke any of the required targets (`-deploy`, `-undeploy`, -`-deploy.all`, `-undeploy.all`). - -[[GBFVA]][[create-custom-deployment-handler]] - -4.5.1 To Create a Custom Deployment Handler -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -To deploy tests to another {TechnologyShortName} implementation, you -must create a custom handler. - -1. Create a new directory in the `/bin/xml/impl` directory tree. - For example, create the `/bin/xml/impl/my_deployment_handler` directory. - Replace my_deployment_handler with the value of the impl.vi - property that you set in Step 5 of the configuration procedure - described in Section 4.2, "Configuring Your Environment to Repackage - and Run the TCK Against the Vendor Implementation". - -2. Copy the deploy.xml file from the `/bin/xml/impl/none` - directory to the directory that you created. - -3. Modify the required targets in the `deploy.xml` file. This is what - the `deploy.xml` file for the "none" deployment handler looks like. - -+ -[source,oac_no_warn] ----- - - - - - - - - - - - - - - - ----- -+ -Although this example just echoes messages, it does include the four -required Ant targets (`-deploy`, `-undeploy`, `-deploy.all`, `-undeploy.all`) -that your custom `deploy.xml` file must contain. With this as your -starting point, look at the required targets in the `deploy.xml` files -in the Tomcat and Eclipse Glassfish directories for guidance as you create -the same targets for the Web container in which you will run your -implementation of {TechnologyShortName}. - -The following Ant targets can be called from anywhere under the -`/src` directory: - -* `deploy` -* `undeploy` -* `deploy.all` -* `undeploy.all` - -The `deploy.all` and `undeploy.all` targets can also be called from the -`/bin` directory. - -[NOTE] -======================================================================= -The targets in the `deploy.xml` file are never called directly. -They are called indirectly by the targets listed above. -======================================================================= - -[[GBFUY]][[using-the-javatest-harness-software]] - -4.6 Using the JavaTest Harness Software -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -There are two general ways to run the {TechnologyShortName} TCK test -suite using the JavaTest harness software: - -* Through the JavaTest GUI; if using this method, please continue on to -link:#GBFWG[Section 4.7, "Using the JavaTest Harness Configuration -GUI."] -* In JavaTest batch mode, from the command line in your shell -environment; if using this method, please proceed directly to -link:using.html#GBFWO[Chapter 5, "Executing Tests."] - -[[GBFWG]][[using-the-javatest-harness-configuration-gui]] - -4.7 Using the JavaTest Harness Configuration GUI -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -You can use the JavaTest harness GUI to modify general test settings and -to quickly get started with the default {TechnologyShortName} TCK test -environment. This section covers the following topics: - -* link:#GBFVA[Configuration GUI Overview] -* link:#GBFVD[Starting the Configuration GUI] -* link:#GBFVX[To Configure the JavaTest Harness to Run the -{TechnologyShortName} TCK Tests] -* link:#GBFUU[Modifying the Default Test Configuration] - - -[NOTE] -======================================================================= - -It is only necessary to proceed with this section if you want to run the -JavaTest harness in GUI mode. If you plan to run the JavaTest harness in -command-line mode, skip the remainder of this chapter, and continue with -link:using.html#GBFWO[Chapter 5, "Executing Tests."] - -======================================================================= - - -[[GBFVA]][[configuration-gui-overview]] - -4.7.1 Configuration GUI Overview -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -In order for the JavaTest harness to execute the test suite, it requires -information about how your computing environment is configured. The -JavaTest harness requires two types of configuration information: - -* Test environment: This is data used by the tests. For example, the -path to the Java runtime, how to start the product being tested, network -resources, and other information required by the tests in order to run. -This information does not change frequently and usually stays constant -from test run to test run. -* Test parameters: This is information used by the JavaTest harness to -run the tests. Test parameters are values used by the JavaTest harness -that determine which tests in the test suite are run, how the tests -should be run, and where the test reports are stored. This information -often changes from test run to test run. - -The first time you run the JavaTest harness software, you are asked to -specify the test suite and work directory that you want to use. (These -parameters can be changed later from within the JavaTest harness GUI.) - -Once the JavaTest harness GUI is displayed, whenever you choose Start, -then Run Tests to begin a test run, the JavaTest harness determines -whether all of the required configuration information has been supplied: - -* If the test environment and parameters have been completely -configured, the test run starts immediately. -* If any required configuration information is missing, the -configuration editor displays a series of questions asking you the -necessary information. This is called the configuration interview. When -you have entered the configuration data, you are asked if you wish to -proceed with running the test. - -[[GBFVD]][[starting-the-configuration-gui]] - -4.7.2 Starting the Configuration GUI -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Before you start the JavaTest harness software, you must have a valid -test suite and Java SE {SEversion} installed on your system. - -The {TechnologyShortName} TCK includes an Ant script that is used to execute the -JavaTest harness from the `` directory. Using this Ant script -to start the JavaTest harness is part of the procedure described in -link:#GBFVX[Section 4.7.3, "To Configure the JavaTest Harness to Run the -TCK Tests."] - -When you execute the JavaTest harness software for the first time, the -JavaTest harness displays a Welcome dialog box that guides you through -the initial startup configuration. - -* If it is able to open a test suite, the JavaTest harness displays a -Welcome to JavaTest dialog box that guides you through the process of -either opening an existing work directory or creating a new work -directory as described in the JavaTest online help. -* If the JavaTest harness is unable to open a test suite, it displays a -Welcome to JavaTest dialog box that guides you through the process of -opening both a test suite and a work directory as described in the -JavaTest documentation. - -After you specify a work directory, you can use the Test Manager to -configure and run tests as described in link:#GBFVX[Section 4.7.3, "To -Configure the JavaTest Harness to Run the TCK Tests."] - -[[GBFVX]][[to-configure-the-javatest-harness-to-run-the-tck-tests]] - -4.7.3 To Configure the JavaTest Harness to Run the TCK Tests -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The answers you give to some of the configuration interview questions -are specific to your site. For example, the name of the host on which -the JavaTest harness is running. Other configuration parameters can be -set however you wish. For example, where you want test report files to -be stored. - -Note that you only need to complete all these steps the first time you -start the JavaTest test harness. After you complete these steps, you can -either run all of the tests by completing the steps in -link:using.html#GBFUZ[Section 5.1, "Starting JavaTest,"] or run a subset -of the tests by completing the steps in link:using.html#GBFWM[Section -5.2, "Running a Subset of the Tests."] - -1. Change to the `/bin` directory and start the JavaTest test -harness: + -`cd /bin` + -`ant gui` -2. From the File menu, click *Open Quick Start Wizard*. + -The Welcome screen displays. -3. Select *Start a new test run*, and then click *Next*. + -You are prompted to create a new configuration or use a configuration -template. -4. Select *Create a new configuration*, and then click *Next*. + -You are prompted to select a test suite. -5. Accept the default suite (`/src`), and then click *Next*. + -You are prompted to specify a work directory to use to store your test -results. -6. Type a work directory name or use the *Browse* button to select a work -directory, and then click *Next*. + -You are prompted to start the configuration editor or start a test run. -At this point, the {TechnologyShortName} TCK is configured to run the -default test suite. -7. Deselect the *Start the configuration editor* option, and then click -*Finish*. -8. Click *Run Tests*, then click *Start*. + -The JavaTest harness starts running the tests. -9. To reconfigure the JavaTest test harness, do one of the following: -* Click *Configuration*, then click *New Configuration*. -* Click *Configuration*, then click *Change Configuration*. -10. Click *Report*, and then click *Create Report*. -11. Specify the directory in which the JavaTest test harness will write -the report, and then click *OK*. + -A report is created, and you are asked whether you want to view it. -12. Click *Yes* to view the report. - -[[GBFUU]][[modifying-the-default-test-configuration]] - -4.7.4 Modifying the Default Test Configuration -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The JavaTest GUI enables you to configure numerous test options. These -options are divided into two general dialog box groups: - -* Group 1: Available from the JavaTest *Configure/Change Configuration* -submenus, the following options are displayed in a tabbed dialog box: - -** *Tests to Run* - -** *Exclude List* - -** *Keywords* - -** *Prior Status* - -** *Test Environment* - -** *Concurrency* - -** *Timeout Factor* -* Group 2: Available from the JavaTest *Configure/Change -Configuration/Other Values* submenu, or by pressing `Ctrl+E`, the following -options are displayed in a paged dialog box: - -** *Environment Files* - -** *Test Environment* - -** *Specify Tests to Run* - -** *Specify an Exclude List* - -Note that there is some overlap between the functions in these two -dialog boxes; for those functions use the dialog box that is most -convenient for you. Please refer to the JavaTest Harness documentation -or the online help for complete information about these various options. - - diff --git a/user_guides/jsonp/src/main/jbake/content/debug-tips.inc b/user_guides/jsonp/src/main/jbake/content/debug-tips.inc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/user_guides/jsonp/src/main/jbake/content/debug.adoc b/user_guides/jsonp/src/main/jbake/content/debug.adoc deleted file mode 100644 index 5208c401a6..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/debug.adoc +++ /dev/null @@ -1,174 +0,0 @@ -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:#GBFVF[Test Tree] -* link:#GBFWI[Folder Information] -* link:#GBFVP[Test Information] -* link:#GBFVZ[Report Files] -* 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 JavaTest -harness. These errors usually occur because the test environment is not -properly configured. -* Failures: Tests that fail were executed but had failing results. - -The Test Manager GUI provides you with a number of tools for effectively -troubleshooting a test run. See the JavaTest User's Guide and JavaTest -online help for detailed descriptions of the tools described in this -chapter. Ant test execution tasks provide command-line users with -immediate test execution feedback to the display. Available JTR report -files and log files can also help command-line users troubleshoot test -run problems. - -For every test run, the JavaTest harness creates a set of report files -in the reports directory, which you specified by setting the -`report.dir` property in the +{jteFileName}+ file. The report files contain -information about the test description, environment, messages, -properties used by the test, status of the test, and test result. After -a test run is completed, the JavaTest harness writes HTML reports for -the test run. You can view these files in the JavaTest ReportBrowser -when running in GUI mode, or in the Web browser of your choice outside -the JavaTest interface. To see all of the HTML report files, enter the -URL of the `report.html` file. This file is the root file that links to -all of the other HTML reports. - -The JavaTest harness also creates a `summary.txt` file in the report -directory that you can open in any text editor. The `summary.txt` file -contains a list of all tests that were run, their test results, and -their status messages. - -The work directory, which you specified by setting the `work.dir` -property in the +{jteFileName}+ file, contains several files that were -deposited there during test execution: `harness.trace`, `log.txt`, -`lastRun.txt`, and `testsuite`. Most of these files provide information -about the harness and environment in which the tests were executed. - -[NOTE] -======================================================================= - -You can set `harness.log.traceflag=true` in +{jteFileName}+ to -get more debugging information. - -======================================================================= - -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. - - -[[GBFVF]][[test-tree]] - -6.2 Test Tree -~~~~~~~~~~~~~ - -Use the test tree in the JavaTest GUI to identify specific folders and -tests that had errors or failing results. Color codes are used to -indicate status as follows: - -* Green: Passed -* Blue: Test Error -* Red: Failed to pass test -* White: Test not run -* Gray: Test filtered out (not run) - -[[GBFWI]][[folder-information]] - -6.3 Folder Information -~~~~~~~~~~~~~~~~~~~~~~ - -Click a folder in the test tree in the JavaTest GUI to display its tabs. - -Choose the Error and the Failed tabs to view the lists of all tests in -and under a folder that were not successfully run. You can double-click -a test in the lists to view its test information. - -[[GBFVP]][[test-information]] - -6.4 Test Information -~~~~~~~~~~~~~~~~~~~~ - -To display information about a test in the JavaTest GUI, click its icon -in the test tree or double-click its name in a folder status tab. The -tab contains detailed information about the test run and, at the bottom -of the window, a brief status message identifying the type of failure or -error. This message may be sufficient for you to identify the cause of -the error or failure. - -If you need more information to identify the cause of the error or -failure, use the following tabs listed in order of importance: - -* Test Run Messages contains a Message list and a Message section that -display the messages produced during the test run. -* Test Run Details contains a two-column table of name/value pairs -recorded when the test was run. -* Configuration contains a two-column table of the test environment -name/value pairs derived from the configuration data actually used to -run the test. - - -[NOTE] -======================================================================= - -You can set `harness.log.traceflag=true` in +{jteFileName}+ to -get more debugging information. - -======================================================================= - - -[[GBFVZ]][[report-files]] - -6.5 Report Files -~~~~~~~~~~~~~~~~ - -Report files are another good source of troubleshooting information. You -may view the individual test results of a batch run in the JavaTest -Summary window, but there are also a wide range of HTML report files -that you can view in the JavaTest ReportBrowser or in the external -browser or your choice following a test run. See -link:using.html#GBFVK[Section 5.5, "Test Reports,"] for more information. - -[[GBFYF]][[configuration-failures]] - -6.6 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. However, in -the case of full-scale launching problems where no tests are actually -processed, report files are usually not created (though sometimes a -small `harness.trace` file in the report directory is written). - -include::debug-tips.inc[] diff --git a/user_guides/jsonp/src/main/jbake/content/defns.inc b/user_guides/jsonp/src/main/jbake/content/defns.inc deleted file mode 100644 index 038db2dda3..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/defns.inc +++ /dev/null @@ -1,46 +0,0 @@ -// 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/user_guides/jsonp/src/main/jbake/content/faq.adoc b/user_guides/jsonp/src/main/jbake/content/faq.adoc deleted file mode 100644 index 97ca394c55..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/faq.adoc +++ /dev/null @@ -1,62 +0,0 @@ -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? -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -From the JavaTest GUI, you can view recently run tests using the Test -Results Summary, by selecting the red Failed tab or the blue Error tab. -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 `harness.trace` file. The -`harness.trace` file is in the report directory that you supplied to the -JavaTest GUI or parameter file. Examine this trace file, then change the -JavaTest GUI initial files to that location or to a directory location -below that file, and restart. This will overwrite only `.jtr` files that -you rerun. As long as you do not change the value of the GUI work -directory, you can continue testing and then later compile a complete -report to include results from all such partial runs. - -[[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 JavaTest exclude file (+{jtxFileName}+) 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/user_guides/jsonp/src/main/jbake/content/install-server-vi.inc b/user_guides/jsonp/src/main/jbake/content/install-server-vi.inc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/user_guides/jsonp/src/main/jbake/content/install-server.inc b/user_guides/jsonp/src/main/jbake/content/install-server.inc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/user_guides/jsonp/src/main/jbake/content/install.adoc b/user_guides/jsonp/src/main/jbake/content/install.adoc deleted file mode 100644 index a3b93e73ac..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/install.adoc +++ /dev/null @@ -1,86 +0,0 @@ -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. - -[[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} -* Apache Ant {AntVersion} -* 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) - -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 Apache Ant {AntVersion} software, if it is not already installed. + -Download and install Apache Ant {AntVersion} software from Apache Ant -Project. For complete information about Ant, refer to the extensive documentation -on the Apache Ant Project site. The Apache Ant Manual is available at -`http://ant.apache.org/manual/index.html`. -Apache Ant is protected under the Apache Software, License 2.0, which is -is available on the Apache Ant Project license page at -`http://ant.apache.org/license.html`. -. 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}+ + - This creates the TCK directory. The TCK is the test suite home, - ``. -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/user_guides/jsonp/src/main/jbake/content/intro.adoc b/user_guides/jsonp/src/main/jbake/content/intro.adoc deleted file mode 100644 index 774adfd371..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/intro.adoc +++ /dev/null @@ -1,349 +0,0 @@ -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: - -* JavaTest harness version {JavaTestVersion} and related documentation. See -link:https://wiki.openjdk.java.net/display/CodeTools/JT+Harness[JT Harness web site] -for additional information. -* {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[] - -[[GBFSA]][[javatest-harness]] - -1.2.3 JavaTest Harness -^^^^^^^^^^^^^^^^^^^^^^ - -The JavaTest harness version {JavaTestVersion} is a set of tools -designed to run and manage test suites on different Java platforms. -To JavaTest, Jakarta EE can be considered another platform. -The JavaTest harness can be described as both a Java application and a set -of compatibility testing tools. It can run tests on different kinds of -Java platforms and it allows the results to be browsed online within -the JavaTest GUI, or offline in the HTML reports that the JavaTest -harness generates. - -The JavaTest harness includes the applications and tools that are used -for test execution and test suite management. It supports the following -features: - -* Sequencing of tests, allowing them to be loaded and executed automatically -* Graphic user interface (GUI) for ease of use -* Automated reporting capability to minimize manual errors -* Failure analysis -* Test result auditing and auditable test specification framework -* Distributed testing environment support - -To run tests using the JavaTest harness, you specify which tests in the -test suite to run, how to run them, and where to put the results as -described in link:config.html#GBFVV[Chapter 4, "Setup and -Configuration."] - -[[GBFRA]][[tck-compatibility-test-suite]] - -1.2.4 TCK Compatibility Test Suite -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -The test suite is the collection of tests used by the JavaTest harness -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. When a test run is -started, the JavaTest harness scans through the set of tests that are -located under the directories that have been selected. While scanning, -the JavaTest harness selects the appropriate tests according to any -matches with the filters you are using and queues them up for execution. - -[[GBFSH]][[exclude-lists]] - -1.2.5 Exclude Lists -^^^^^^^^^^^^^^^^^^^ - -Each version of a TCK includes an Exclude List contained in a `.jtx` -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 JavaTest harness automatically excludes -any test on the Exclude List from being executed. - -A vendor's compatible implementation is not required to pass or run any test on the Exclude List. -The Exclude List file, +{jtxFileName}+, is included in the -{TechnologyShortName} TCK. - - -[NOTE] -======================================================================= - -From time to time, updates to the Exclude List are made available. -The exclude list is included in the Jakarta 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 (such as the JavaTest -harness, for example). - -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.6 TCK Configuration -^^^^^^^^^^^^^^^^^^^^^^^ - -You need to set several variables in your test environment, modify -properties in the +{jteFileName}+ file, and then use the JavaTest -harness to configure 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 hosting the JavaTest harness: -include::req-software.inc[] -* Java SE {SEversion} -* Apache Ant {AntVersion} -* 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) + -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. - b. Modify the required properties in the +{jteFileName}+ file. - c. Configure the JavaTest harness. -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/user_guides/jsonp/src/main/jbake/content/intro.inc b/user_guides/jsonp/src/main/jbake/content/intro.inc deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/user_guides/jsonp/src/main/jbake/content/packages.inc b/user_guides/jsonp/src/main/jbake/content/packages.inc deleted file mode 100644 index ec1f4cb2d6..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/packages.inc +++ /dev/null @@ -1,5 +0,0 @@ -** `jakarta.json` - -** `jakarta.json.spi` - -** `jakarta.json.stream` diff --git a/user_guides/jsonp/src/main/jbake/content/platforms.inc b/user_guides/jsonp/src/main/jbake/content/platforms.inc deleted file mode 100644 index 236beed78f..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/platforms.inc +++ /dev/null @@ -1 +0,0 @@ -* CentOS Linux 7 \ No newline at end of file diff --git a/user_guides/jsonp/src/main/jbake/content/preface.adoc b/user_guides/jsonp/src/main/jbake/content/preface.adoc deleted file mode 100644 index ea10c28728..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/preface.adoc +++ /dev/null @@ -1,147 +0,0 @@ -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 JavaTest harness version -{JavaTestVersion} 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}. - -Before running the tests in the {TechnologyShortName} TCK, you should -familiarize yourself with the JavaTest documentation which can be -accessed at the -link:https://wiki.openjdk.java.net/display/CodeTools/JT+Harness[JT Harness web site]. - -[[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/user_guides/jsonp/src/main/jbake/content/rebuild.adoc b/user_guides/jsonp/src/main/jbake/content/rebuild.adoc deleted file mode 100644 index e4021cfa19..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/rebuild.adoc +++ /dev/null @@ -1,20 +0,0 @@ -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/user_guides/jsonp/src/main/jbake/content/rebuild.inc b/user_guides/jsonp/src/main/jbake/content/rebuild.inc deleted file mode 100644 index 3fa38efb93..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/rebuild.inc +++ /dev/null @@ -1,7 +0,0 @@ -/////////////////////////////////////////////////////////////////////// -NOTE TO WRITERS: -The following sections should be customized for the technology. -See the JAXRS for an example of this include file -/////////////////////////////////////////////////////////////////////// - -[[GCLIZ]] diff --git a/user_guides/jsonp/src/main/jbake/content/req-software.inc b/user_guides/jsonp/src/main/jbake/content/req-software.inc deleted file mode 100644 index 48014f56ee..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/req-software.inc +++ /dev/null @@ -1,10 +0,0 @@ -/////////////////////////////////////////////////////////////////////// -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/user_guides/jsonp/src/main/jbake/content/rules.adoc b/user_guides/jsonp/src/main/jbake/content/rules.adoc deleted file mode 100644 index f6b08cebb9..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/rules.adoc +++ /dev/null @@ -1,403 +0,0 @@ -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. Properties that can be changed are identified in the JavaTest -Environment (.jte) files in the Test Suite -installation. 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/user_guides/jsonp/src/main/jbake/content/rules.inc b/user_guides/jsonp/src/main/jbake/content/rules.inc deleted file mode 100644 index b5a250f697..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/rules.inc +++ /dev/null @@ -1,78 +0,0 @@ -/////////////////////////////////////////////////////////////////////// -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/user_guides/jsonp/src/main/jbake/content/tck-packages.inc b/user_guides/jsonp/src/main/jbake/content/tck-packages.inc deleted file mode 100644 index 5ca50031cc..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/tck-packages.inc +++ /dev/null @@ -1,7 +0,0 @@ -** JDOM 1.1.3 - -** Apache Commons HTTP Client 3.1 - -** Apache Commons Logging 1.1.3 - -** Apache Commons Codec 1.9 diff --git a/user_guides/jsonp/src/main/jbake/content/title.adoc b/user_guides/jsonp/src/main/jbake/content/title.adoc deleted file mode 100644 index ec9d735727..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/title.adoc +++ /dev/null @@ -1,40 +0,0 @@ -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/user_guides/jsonp/src/main/jbake/content/title.inc b/user_guides/jsonp/src/main/jbake/content/title.inc deleted file mode 100644 index 25bf47e08d..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/title.inc +++ /dev/null @@ -1,11 +0,0 @@ -/////////////////////////////////////////////////////////////////////// -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/user_guides/jsonp/src/main/jbake/content/using-examples.inc b/user_guides/jsonp/src/main/jbake/content/using-examples.inc deleted file mode 100644 index b47962f035..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/using-examples.inc +++ /dev/null @@ -1,53 +0,0 @@ -/////////////////////////////////////////////////////////////////////// -NOTE TO WRITERS: -These CLI examples can be customized as necessary. -/////////////////////////////////////////////////////////////////////// - -1. Change to any subdirectory under `/src/com/sun/ts/tests`. -2. Start JavaTest using the following command: -+ --- -[source,oac_no_warn] ----- -ant runclient ----- --- - -[[GCMCU]] - -Example 5-1 {TechnologyShortName} TCK Signature Tests - -To run the {TechnologyShortName} TCK signature tests, enter the -following commands: - -[source,subs="attributes"] ----- -cd {sigTestDirectoryExample} -ant runclient ----- - -[[GCMBV]] - - -Example 5-2 Single Test Directory - -To run a single test directory, enter the following commands: - -[source,subs="attributes"] ----- -cd {singleTestDirectoryExample} -ant runclient ----- - -[[GCMCA]] - - -Example 5-3 Subset of Test Directories - -To run a subset of test directories, enter the following commands: - -[source,subs="attributes"] ----- -cd {subsetTestDirectoryExample} -ant runclient ----- diff --git a/user_guides/jsonp/src/main/jbake/content/using.adoc b/user_guides/jsonp/src/main/jbake/content/using.adoc deleted file mode 100644 index b0a41c51e1..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/using.adoc +++ /dev/null @@ -1,323 +0,0 @@ -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 JavaTest harness to execute the -tests in the test suite. For detailed instructions that explain how to -run and use JavaTest, see the JavaTest User's Guide and Reference in -the documentation bundle. - -This chapter includes the following topics: - -* link:#GBFUZ[Starting JavaTest] -* 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 JavaTest -~~~~~~~~~~~~~~~~~~~~~ - -There are two general ways to run the {TechnologyShortName} TCK using -the JavaTest harness software: - -* Through the JavaTest GUI -* From the command line in your shell environment - - -[NOTE] -======================================================================= - -The `ant` command referenced in the following -two procedures and elsewhere in this guide is the Apache Ant -build tool, which will need to be downloaded separately. -The `build.xml` file in `/bin` contains the various Ant -targets for the {TechnologyShortName} TCK test suite. - -======================================================================= - - -[[GBFWH]][[to-start-javatest-in-gui-mode]] - -5.1.1 To Start JavaTest in GUI Mode -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Execute the following commands: - -[source,oac_no_warn] ----- -cd /bin -ant gui ----- - -[[GBFVW]][[to-start-javatest-in-command-line-mode]] - -5.1.2 To Start JavaTest in Command-Line Mode -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -include::using-examples.inc[] - -[[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:#GBFVT[Section 5.2.1, "To Run a Subset of Tests in GUI Mode"] -* link:#GBFWK[Section 5.2.2, "To Run a Subset of Tests in Command-Line Mode"] -* link:#GBFVL[Section 5.2.3, "To Run a Subset of Tests in Batch Mode -Based on Prior Result Status"] - -[[GBFVT]][[to-run-a-subset-of-tests-in-gui-mode]] - -5.2.1 To Run a Subset of Tests in GUI Mode -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -1. From the JavaTest main menu, click *Configure*, then click *Change -Configuration*, and then click *Tests to Run*. + -The tabbed Configuration Editor dialog box is displayed. -2. Click *Specify* from the option list on the left. -3. Select the tests you want to run from the displayed test tree, and -then click *Done*. + -You can select entire branches of the test tree, or use `Ctrl+Click` or -`Shift+Click` to select multiple tests or ranges of tests, respectively, -or select just a single test. -4. Click *Save File*. -5. Click *Run Tests*, and then click *Start* to run the tests you selected. + -Alternatively, you can `right-click` the test you want from the test tree -in the left section of the JavaTest main window, and choose *Execute -These Tests* from the menu. -6. Click *Report*, and then click *Create Report*. -7. Specify the directory in which the JavaTest test harness will write -the report, and then click *OK* + -A report is created, and you are asked whether you want to view it. -8. Click *Yes* to view the report. - -[[GBFWK]][[to-run-a-subset-of-tests-in-command-line-mode]] - -5.2.2 To Run a Subset of Tests in Command-Line Mode -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -1. Change to the directory containing the tests you want to run. -2. Start the test run by executing the following command: + -+ -[source] ----- -ant runclient ----- -+ -The tests in the directory and its subdirectories are run. - -[[GBFVL]][[to-run-a-subset-of-tests-in-batch-mode-based-on-prior-result-status]] - -5.2.3 To Run a Subset of Tests in Batch Mode Based on Prior Result Status -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -You can run certain tests in batch mode based on the test's prior run -status by specifying the `priorStatus` system property when invoking -`ant` - -Invoke `ant` with the `priorStatus` property. - -The accepted values for the `priorStatus` property are any combination -of the following: - -* `fail` -* `pass` -* `error` -* `notRun` - -For example, you could run all the {TechnologyShortName} tests with a -status of failed and error by invoking the following commands: - -[source,oac_no_warn] ----- -ant -DpriorStatus="fail,error" runclient ----- - -Note that multiple `priorStatus` values must be separated by commas. - -[[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. If required, verify that you have completed the steps in -link:config.html#GCLIW[Section 4.3.2, "Deploying the Prebuilt Archives."] -3. Run the tests, as described in link:#GBFUZ[Section 5.1, "Starting -JavaTest,"] 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 -Repackage and 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 -JavaTest,"] 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 report directory you specify. After a test run is -completed, the JavaTest harness writes HTML reports for the test run. -You can view these files in the JavaTest ReportBrowser when running in -GUI mode, or in the web browser of your choice outside the JavaTest -interface. - -To see all of the HTML report files, enter the URL of the `report.html` -file. This file is the root file that links to all of the other HTML -reports. - -The JavaTest harness also creates a `summary.txt` file in the report -directory that you can open in any text editor. The `summary.txt` file -contains a list of all tests that were run, their test results, and -their status messages. - -[[GBFWD]][[creating-test-reports]] - -5.5.1 Creating Test Reports -^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Use the following modes to create test reports: - -* link:#GBFVH[Section 5.5.1.1, "To Create a Test Report in GUI Mode"] -* link:#GBFVC[Section 5.5.1.2, "To Create a Test Report in Command-Line Mode"] - -[[GBFVH]][[to-create-a-test-report-in-gui-mode]] - -5.5.1.1 To Create a Test Report in GUI Mode -+++++++++++++++++++++++++++++++++++++++++++ - -1. From the JavaTest main menu, click *Report*, then click *Create Report*. + -You are prompted to specify a directory to use for your test reports. -2. Specify the directory you want to use for your reports, and then -click *OK*. + -Use the Filter list to specify whether you want to generate reports for -the current configuration, all tests, or a custom set of tests. + -You are asked whether you want to view report now. -3. Click *Yes* to display the new report in the JavaTest ReportBrowser. - -[[GBFVC]][[to-create-a-test-report-in-command-line-mode]] - -5.5.1.2 To Create a Test Report in Command-Line Mode -++++++++++++++++++++++++++++++++++++++++++++++++++++ - -1. Specify where you want to create the test report. -a. To specify the report directory from the command line at runtime, -use: -+ -[source] ----- -ant -Dreport.dir="report_dir" ----- -+ -Reports are written for the last test run to the directory you specify. -2. To specify the default report directory, set the `report.dir` -property in +{jteFileName}+. + -For example: -+ -[source] ----- -report.dir="/home/josephine/reports" ----- -+ -3. To disable reporting, set the `report.dir` property to `"none"`, -either on the command line or in +{jteFileName}+. + -For example: -+ -[source] ----- -ant -Dreport.dir="none" ----- -+ - -[[GBFVB]][[viewing-an-existing-test-report]] - -5.5.2 Viewing an Existing Test Report -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Use the following modes to view an existing test report: - -* link:#GBFVO[Section 5.5.2.1, "To View an Existing Report in GUI Mode"] -* link:#GBFWB[Section 5.5.2.2, "To View an Existing Report in -Command-Line Mode"] - -[[GBFVO]][[to-view-an-existing-report-in-gui-mode]] - -5.5.2.1 To View an Existing Report in GUI Mode -++++++++++++++++++++++++++++++++++++++++++++++ - -1. From the JavaTest main menu, click *Report*, then click *Open Report*. + -You are prompted to specify the directory containing the report you want -to open. -2. Select the report directory you want to open, and then click *Open*. + -The selected report set is opened in the JavaTest ReportBrowser. - -[[GBFWB]][[to-view-an-existing-report-in-command-line-mode]] - -5.5.2.2 To View an Existing Report in Command-Line Mode -+++++++++++++++++++++++++++++++++++++++++++++++++++++++ - -Use the Web browser of your choice to view the `report.html` file in the -report directory you specified from the command line or in +{jteFileName}+. - -include::using.inc[] - diff --git a/user_guides/jsonp/src/main/jbake/content/using.inc b/user_guides/jsonp/src/main/jbake/content/using.inc deleted file mode 100644 index 1b35fd4d66..0000000000 --- a/user_guides/jsonp/src/main/jbake/content/using.inc +++ /dev/null @@ -1,118 +0,0 @@ -/////////////////////////////////////////////////////////////////////// -NOTE TO WRITERS: -This include file allows for additional instructions for running the TCK. -/////////////////////////////////////////////////////////////////////// - - -[[sthref9]][[running-the-pluggability-tests]] - -5.6 Running the Pluggability Tests -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Use the following modes to run the pluggability tests: - -* link:#BCGFHIDI[Section 5.6.1, "To Run the Pluggability Tests in GUI -Mode"] -* link:#BCGEGBGE[Section 5.6.2, "To Run the Pluggability Tests in -Command-Line Mode"] - -[[BCGFHIDI]][[to-run-the-pluggability-tests-in-gui-mode]] - -5.6.1 To Run the Pluggability Tests in GUI Mode -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -When running JavaTest in GUI mode as described above, you are prompted -to specify whether you want to run all or a subset of the test suite. -Since the pluggability tests must be run separately from -the other tests, select Yes. Select the tests you want to run from the -displayed test tree, then select Next. You can select entire branches -of the test tree, or use Ctrl+Click or Shift+Click to select multiple -tests or ranges of tests, respectively. Select all tests except -pluggability tests by unchecking the pluggability tests. - -After running the other tests, run the pluggability tests, which -require a separate test run: - -1. If the JavaTest GUI is running, exit the GUI. -2. Change to the `/bin` directory and reconfigure environment -to use the `JsonProvider` class that is supplied with the test suite and -restart the JavaTest GUI: + -[source,oac_no_warn] ----- -cd /bin -ant enable.alternate.jsonp.provider -ant gui ----- -3. Select Configure, then select Edit Configuration. -4. Select Tests to Run. -5. Select the tests you want to run from the displayed test tree, then -select Next. + -Select the pluggability tests only by unchecking all of the other tests. -6. Select Done. -7. Select Run Tests, then select Start. -8. Exit the JavaTest GUI when finished. -9. Disable the alternate JSON provider that you enabled in Step 2, -before you initiated the test run for the pluggability tests: + -[source,oac_no_warn] ----- -cd /bin -ant disable.alternate.jsonp.provider ----- - -[[BCGEGBGE]][[to-run-the-pluggability-tests-in-command-line-mode]] - -5.6.2 To Run the Pluggability Tests in Command-Line Mode -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -There are two ways to run the pluggability tests from the command line. -It is highly recommended to use the first method, since it automatically -calls the Ant targets to enable and disable the test provider. If you -choose to use the second method, you will need to execute those Ant -targets manually before and after you run the tests. - -The first method is by executing the `run.pluggability` target in Ant: - -1. Execute the `run.pluggability` target using Ant: + -[source,oac_no_warn] ----- -cd /bin -ant run.pluggability ----- -The `run.pluggability` target calls Ant targets that enable the test -provider, run the pluggability tests, then disable the test provider. - -The pluggability tests can also be run an alternate way, albeit one that -requires more manual intervention: - -1. Execute the `enable.alternate.jsonp.provider` target using Ant: + -[source,oac_no_warn] ----- -cd /bin -ant enable.alternate.jsonp.provider ----- -The `enable.alternate.jsonp.provider` target enables the alternate test -provider. -2. Change to the `` -directory: + -[source,oac_no_warn] ----- -cd ----- -3. Start the pluggability test run by executing the following command: + -[source,oac_no_warn] ----- -ant runclient ----- -This will run just the pluggability tests under the -<`TS_HOME/src/com/sun/ts/tests/jsonp/pluggability` directory, using a -test-supplied `JsonProvider Class` for testing the SPI. All -`JsonProvider` method calls will be invoked and verified by the tests to -ensure SPI layer is working. -4. Execute the `disable.alternate.jsonp.provider` target using Ant: + -[source,oac_no_warn] ----- -cd /bin -ant disable.alternate.jsonp.provider ----- -The `disable.alternate.jsonp.provider` target disables the alternate -test provider. diff --git a/user_guides/jsonp/src/main/jbake/jbake.properties b/user_guides/jsonp/src/main/jbake/jbake.properties deleted file mode 100644 index 05c7056f0a..0000000000 --- a/user_guides/jsonp/src/main/jbake/jbake.properties +++ /dev/null @@ -1,24 +0,0 @@ -# -# 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/user_guides/jsonp/src/main/jbake/templates/footer.ftl b/user_guides/jsonp/src/main/jbake/templates/footer.ftl deleted file mode 100644 index 236b646736..0000000000 --- a/user_guides/jsonp/src/main/jbake/templates/footer.ftl +++ /dev/null @@ -1,44 +0,0 @@ -<#-- a footer template fragment included in the page template --> -
- - - - - - - - - <#if content.prev??> - - - - <#if content.next??> - - - - - -
- - - Previous - - - - - Next - - - - - Contents - -
- - - Eclipse Foundation Logo  - Copyright © 2017, 2021 Oracle and/or its affiliates. All rights reserved. - - - - diff --git a/user_guides/jsonp/src/main/jbake/templates/header.ftl b/user_guides/jsonp/src/main/jbake/templates/header.ftl deleted file mode 100644 index 50b72ae8d0..0000000000 --- a/user_guides/jsonp/src/main/jbake/templates/header.ftl +++ /dev/null @@ -1,54 +0,0 @@ - -<#-- a header template fragment included in the page template --> - - - - <#if (content.title)??><#escape x as x?xml>${content.title}</#escape></#if> - - - - - - - - - -
- ${content.title}
-
-
- - - - - - - - - <#if content.prev??> - - - - <#if content.next??> - - - - - -
- - - Previous - - - - - Next - - - - - Contents - -
- diff --git a/user_guides/jsonp/src/main/jbake/templates/menu.ftl b/user_guides/jsonp/src/main/jbake/templates/menu.ftl deleted file mode 100644 index 888c03dcff..0000000000 --- a/user_guides/jsonp/src/main/jbake/templates/menu.ftl +++ /dev/null @@ -1 +0,0 @@ -<#-- a menu bar template fragment included in the page template --> \ No newline at end of file diff --git a/user_guides/jsonp/src/main/jbake/templates/page.ftl b/user_guides/jsonp/src/main/jbake/templates/page.ftl deleted file mode 100644 index eca51db35d..0000000000 --- a/user_guides/jsonp/src/main/jbake/templates/page.ftl +++ /dev/null @@ -1,8 +0,0 @@ -<#-- 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/user_guides/jsonp/src/theme/jakartaee-theme.yml b/user_guides/jsonp/src/theme/jakartaee-theme.yml deleted file mode 100644 index 6092a2f5c9..0000000000 --- a/user_guides/jsonp/src/theme/jakartaee-theme.yml +++ /dev/null @@ -1,299 +0,0 @@ -# -# 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: " \u203a " -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: - #head_font_color: $base_font_color - head_font_style: bold - #body_background_color: - 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: or - # 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