Using application properties in IBM Cúram Social Program Management JUnit tests

Similar documents
IBM emessage Version 8.x and higher. Account Startup Overview

Platform LSF Version 9 Release 1.3. Migrating on Windows SC

Getting Started with InfoSphere Streams Quick Start Edition (VMware)

Platform LSF Version 9 Release 1.1. Migrating on Windows SC

IBM Operational Decision Manager Version 8 Release 5. Configuring Operational Decision Manager on Java SE

IBM Cognos Dynamic Query Analyzer Version Installation and Configuration Guide IBM

IBM Copy Services Manager Version 6 Release 1. Release Notes August 2016 IBM

IBM Security QRadar Version Customizing the Right-Click Menu Technical Note

Build integration overview: Rational Team Concert and IBM UrbanCode Deploy

Installing Watson Content Analytics 3.5 Fix Pack 1 on WebSphere Application Server Network Deployment 8.5.5

IBM Geographically Dispersed Resiliency for Power Systems. Version Release Notes IBM

Migrating on UNIX and Linux

IBM LoadLeveler Version 5 Release 1. Documentation Update: IBM LoadLeveler Version 5 Release 1 IBM

ios 9 support in IBM MobileFirst Platform Foundation IBM

Version 9 Release 0. IBM i2 Analyst's Notebook Premium Configuration IBM

IBM OpenPages GRC Platform - Version Interim Fix 1. Interim Fix ReadMe

IBM Spectrum LSF Process Manager Version 10 Release 1. Release Notes IBM GI

IBM Operational Decision Manager. Version Sample deployment for Operational Decision Manager for z/os artifact migration

Version 9 Release 0. IBM i2 Analyst's Notebook Configuration IBM

IBM Security QRadar Version Forwarding Logs Using Tail2Syslog Technical Note

Version 1 Release 1 November IBM Social Marketing Solution Pack User's Guide IBM

IBM Storage Driver for OpenStack Version Release Notes

IBM License Metric Tool Enablement Guide

IBM Security QRadar Version 7 Release 3. Community Edition IBM

IBM Cloud Object Storage System Version Time Synchronization Configuration Guide IBM DSNCFG_ K

IBM Endpoint Manager Version 9.1. Patch Management for Ubuntu User's Guide

IBM. Release Notes November IBM Copy Services Manager. Version 6 Release 1

IBM OpenPages GRC Platform Version 7.0 FP2. Enhancements

IBM. Avoiding Inventory Synchronization Issues With UBA Technical Note

IBM. IBM i2 Enterprise Insight Analysis Understanding the Deployment Patterns. Version 2 Release 1 BA

Installing on Windows

IBM. Networking INETD. IBM i. Version 7.2

IBM FlashSystem V MTM 9846-AC3, 9848-AC3, 9846-AE2, 9848-AE2, F, F. Quick Start Guide IBM GI

Version 2 Release 1. IBM i2 Enterprise Insight Analysis Understanding the Deployment Patterns IBM BA

IBM Maximo Calibration Version 7 Release 6. Installation Guide

Best practices. Starting and stopping IBM Platform Symphony Developer Edition on a two-host Microsoft Windows cluster. IBM Platform Symphony

iscsi Configuration Manager Version 2.0

IBM Maximo for Service Providers Version 7 Release 6. Installation Guide

IBM FlashSystem V Quick Start Guide IBM GI

CONFIGURING SSO FOR FILENET P8 DOCUMENTS

IBM Watson Explorer Content Analytics Version Upgrading to Version IBM

IBM Netcool/OMNIbus 8.1 Web GUI Event List: sending NodeClickedOn data using Netcool/Impact. Licensed Materials Property of IBM

Netcool/Impact Version Release Notes GI

Tivoli Access Manager for Enterprise Single Sign-On

Migrating Classifications with Migration Manager

IBM Spectrum LSF Version 10 Release 1. Readme IBM

IBM Maximo for Aviation MRO Version 7 Release 6. Installation Guide IBM

IBM. Business Process Troubleshooting. IBM Sterling B2B Integrator. Release 5.2

IBM Maximo Calibration Version 7 Release 5. Installation Guide

Application and Database Protection in a VMware vsphere Environment

IBM Kenexa LCMS Premier on Cloud. Release Notes. Version 9.3

IBM Cloud Orchestrator. Content Pack for IBM Endpoint Manager for Software Distribution IBM

IBM Tealeaf UI Capture j2 Version 2 Release 1 May 15, IBM Tealeaf UI Capture j2 Release Notes

Networking Bootstrap Protocol

IBM Operations Analytics - Log Analysis: Network Manager Insight Pack Version 1 Release 4.1 GI IBM

Proposal for a Tivoli Storage Manager Client system migration from Solaris with VxFS to Linux with GPFS or AIX with GPFS or JFS2

IBM Storage Driver for OpenStack Version Installation Guide SC

Best practices. Reducing concurrent SIM connection requests to SSM for Windows IBM Platform Symphony

IBM Maximo for Service Providers Version 7 Release 6. Installation Guide IBM

IBM StoredIQ Platform Version Overview Guide GC

IBM. Networking Open Shortest Path First (OSPF) support. IBM i. Version 7.2

IBM Storage Driver for OpenStack Version Release Notes

Integrated use of IBM WebSphere Adapter for Siebel and SAP with WPS Relationship Service. Quick Start Scenarios

ReadMeFirst for IBM StoredIQ

Determining dependencies in Cúram data

IBM i2 ibridge 8 for Oracle

IBM Worklight V5.0.6 Getting Started

IBM StoredIQ Platform Version Overview Guide IBM GC

Patch Management for Solaris

IBM WebSphere Sample Adapter for Enterprise Information System Simulator Deployment and Testing on WPS 7.0. Quick Start Scenarios

IBM UrbanCode Cloud Services Security Version 3.0 Revised 12/16/2016. IBM UrbanCode Cloud Services Security

Development tools System i5 Debugger

IBM Content Analytics with Enterprise Search Version 3.0. Expanding queries and influencing how documents are ranked in the results

IBM Storage Driver for OpenStack Version Installation Guide SC

IBM OpenPages GRC Platform Version Interim Fix 5. Interim Fix ReadMe

RSE Server Installation Guide: AIX and Linux on IBM Power Systems

IBM StoredIQ Platform Version Overview Guide IBM GC

IBM Storage Device Driver for VMware VAAI. Installation Guide. Version 1.1.0

IBM Datacap Mobile SDK Developer s Guide

IBM Storage Management Pack for Microsoft System Center Operations Manager (SCOM) Version Release Notes

Tivoli Access Manager for Enterprise Single Sign-On

IBM License Metric Tool Version 9.0 (includes version 9.0.1, and ) Tuning Performance Guide

IBM Financial Transactions Repository Version IBM Financial Transactions Repository Guide IBM

IBM InfoSphere Master Data Management Reference Data Management Hub Version 11 Release 0. Upgrade Guide GI

IBM XIV Provider for Microsoft Windows Volume Shadow Copy Service. Version 2.3.x. Installation Guide. Publication: GC (August 2011)

IBM TRIRIGA Application Platform Version 3 Release 5.3. User Experience User Guide IBM

Best practices. Linux system tuning for heavilyloaded. IBM Platform Symphony

IBM i Version 7.2. Systems management Logical partitions IBM

Implementing Enhanced LDAP Security

Tivoli Endpoint Manager for Patch Management - AIX. User s Guide

IBM. IBM i2 Analyze Windows Upgrade Guide. Version 4 Release 1 SC

A Quick Look at IBM SmartCloud Monitoring. Author: Larry McWilliams, IBM Tivoli Integration of Competency Document Version 1, Update:

System i. Networking RouteD. Version 5 Release 4

Performance Tuning Guide

IBM Maximo Spatial Asset Management Version 7 Release 6. Installation Guide IBM

Limitations and Workarounds Supplement

Integrating IBM Rational Build Forge with IBM Rational ClearCase and IBM Rational ClearQuest

IBM Tivoli Directory Server Version 5.2 Client Readme

ServeRAID-MR10i SAS/SATA Controller IBM System x at-a-glance guide

IBM TRIRIGA Application Platform Version 3 Release 5.3. Graphics User Guide IBM

Transcription:

Using application properties in IBM Cúram Social Program Management JUnit tests Erika Grine (Erika.Grine@ie.ibm.com) 8 June 2015 Senior Software Engineer, IBM Cúram Social Program Management group IBM Page 1 of 11

Copyright International Business Machines Corporation 2015. US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Revision History Date Revision Reason for Change Author 08/06/2015 1 Initial Version Erika Grine Page 2 of 11

Contents Table of Contents Contents... 3 Overview... 4 Changing the application properties in a single JUnit test method... 4 Changing the application properties across multiple tests in the same test file... 5 JUnit framework version specific notes... 7 Other uses... 7 Conclusion... 7 Acknowledgments... 8 Resources... 8 About the author... 8 Notices... 9 Privacy Policy considerations... 10 Trademarks... 11 Page 3 of 11

Overview Some JUnit tests need to change Cúram application properties in order to test specific functionality. This needs to be done if application property governs the processing that you are testing. For example if you want to test that the task search returns no more records than the EnvVars.ENV_INBOX_MAX_TASK_LIST_SIZE which equals to 100 by default, then in order to avoid creating many tasks in JUnit test and to slow it down considerably you will need to set EnvVars.ENV_INBOX_MAX_TASK_LIST_SIZE to some small number say 4, then create 5 tasks, perform a search that should find all 5 tasks, and check that the search returned only 4 tasks, because of the task search limit. The problem with changing application properties in JUnit tests is the fact that these properties are cached by infrastructure at run time and this cache is not cleared by Cúram test infrastructure up to and including version 6.1. Changes to them will not be rolled back automatically once your JUnit test finishes as property cache will persist across JUnit tests. As a result the changed application property may affect other JUnit tests. So if you need to change an application property in Cúram JUnit test then at the end of the test you will need to revert this change back. This article shows you two ways to achieve this. 1. Changing the application properties in a single JUnit test method. 2. Changing the application properties across multiple tests in the same test file. Changing the application properties in a single JUnit test method Application properties can be changed and reverted back in the same test method. This is useful if: Only one or just a few test methods are affected, while other methods do not require application property changes; Different test methods need to change different application properties or the same application property but they need to set it to different values; Use try { finally block to implement this like in the following examples: For JUnit 4.x @Test public void dotestlimitsearchlist() throws Exception { // Save application property value. final Integer origlistsize = Configuration.getIntProperty( EnvVars.ENV_INBOX_MAX_TASK_LIST_SIZE); try { // Limit task search size to 4 Configuration.setProperty(EnvVars.ENV_INBOX_MAX_TASK_LIST_SIZE, "4"); Page 4 of 11

// Do task search here // Check/assert the results finally { // Revert the application property setting back. Configuration.setProperty(EnvVars.ENV_INBOX_MAX_TASK_LIST_SIZE, origlistsize.tostring()); For JUnit 3.x The code will look the same except the test method name must begin with test and there is no @Test annotation in front of it. public void testlimitsearchlist() throws Exception {... Here the test code: 1. Retrieved original application property value; 2. In the try block changed it to the value that suits the test; 3. Tested the functionality; 4. In the finally block reverted the change back. As finally statement will always be executed the application property value will be reverted back even if your code fails with exception, so errors/issues in your test will not impact other JUnit tests. Changing the application properties across multiple tests in the same test file If a number of tests require an application property change which is the same for all of them then the following approach may be simpler to use than the one described previously. In your test class override setupcuramservertest() and teardowncuramservertest() methods like in the following example.... // Class variable to save original property value to private Integer origlistsize; @Override protected void setupcuramservertest() { Page 5 of 11

// Call base class method. super.setupcuramservertest(); // Save application property value. origlistsize = Configuration.getIntProperty( EnvVars.ENV_INBOX_MAX_TASK_LIST_SIZE); // Limit task search size to 4 Configuration.setProperty(EnvVars.ENV_INBOX_MAX_TASK_LIST_SIZE, "4"); @Override protected void teardowncuramservertest() { if (null!= origlistsize) { // Revert the application property setting back. Configuration.setProperty(EnvVars.ENV_INBOX_MAX_TASK_LIST_SIZE, origlistsize.tostring()); // Call base class method. super.teardowncuramservertest(); Then implement your test method. For JUnit 4.x @Test public void domytest1() throws Exception { // Do task search here // Check/assert the results For JUnit 3.x public void testmytest1() throws Exception { // Do task search here // Check/assert the results Page 6 of 11

As setupcuramservertest() is called before your test method, and teardowncuramservertest() is called after it, the application property will be re-set back to its original value once your test method finishes. This processing will be done for each test method in the test class. Here the test code: 1. Retrieved original application property value in setupcuramservertest() method and saved it in in the test class variable; 2. Tested the functionality; 3. Reverted application property back in JUnit teardowncuramservertest() processing; Note that if error happens in setupcuramservertest() after some application properties are already set to custom values then these will not be re-set back to their defaults as teardowncuramservertest() method will not be called. You will need to implement your own clean-up code for these instances. JUnit framework version specific notes Code examples in this article are provided for both JUnit 3.x and JUnit 4.x frameworks. If you inherit your test classes from CuramServerTest then you can use examples provided for JUnit 3.x. JUnit 4.x runtime supports tests written for JUnit 3.x. Test methods written for JUnit 4.x can have any name, but must be annotated with @Test. Test methods written for JUnit 3 must have names that begin with test. Full description of the differences between JUnit 3.x and JUnit 4.x and their usage in Cúram testing is behind the scope of this document. Other uses The same approaches can be used to set and restore dates, if for whatever reason your test must be executed at a specific date. Also use these approaches for other tasks that require initialization and clean-up and are not part of the transaction processing. Both approaches can be used in the same test class. In order to avoid unintended effects use only one approach in the same JUnit test class for the same purpose. For example if you use try finally block to save and re-set a specific application property then you may still use set-up and teardown method override for other purposes, including saving and re-setting other application properties. Conclusion This article described two approaches how Cúram application properties can be changed and re-stored in Cúram JUnit tests. We learned how these approaches differ and when it is better Page 7 of 11

to select one over the other. Using these approaches it should be possible to write more robust JUnit test implementations for IBM Cúram SPM. Acknowledgments The author would like to thank the following members of Cúram product development team for their input, support and reviews: Caitriona Nic Lughadha, Functional Verification Test Manager. Ronan Mulvaney, Chief Architect of Cúram Social Program Management. Resources For more information on how to write JUnit tests for IBM Cúram Social Program Management please see developerworks article Write unit tests for IBM Cúram Social Program Management. For more information about IBM Cúram Social Program Management platform please see Cúram Social Program Management platform. For more information about JUnit test framework please see http://www.junit.org About the author Erika Grine Erika Grine is a senior software engineer in the IBM Cúram Social Program Management group. Currently Erika is a technical lead for Dynamic Evidence in SPM group. She has worked on the Cúram product for 14 years, and has been involved in many areas of the Cúram application development. Page 8 of 11

Notices Copyright IBM Corporation 2015 IBM United States of America Produced in the United States of America US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. This information was developed for products and services offered in the U.S.A. IBM may not offer the products, services, or features discussed in this document in other countries. Consult your local IBM representative for information on the products and services currently available in your area. Any reference to an IBM product, program, or service is not intended to state or imply that only that IBM product, program, or service may be used. Any functionally equivalent product, program, or service that does not infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to evaluate and verify the operation of any non-ibm product, program, or service. IBM may have patents or pending patent applications covering subject matter described in this document. The furnishing of this document does not grant you any license to these patents. You can send license inquiries, in writing, to: IBM Director of Licensing IBM Corporation North Castle Drive Armonk, NY 10504-1785 U.S.A. For license inquiries regarding double-byte (DBCS) information, contact the IBM Intellectual Property Department in your country or send inquiries, in writing, to: Intellectual Property Licensing Legal and Intellectual Property Law. IBM Japan Ltd. 19-21, Nihonbashi-Hakozakicho, Chuo-ku Tokyo 103-8510, Japan The following paragraph does not apply to the United Kingdom or any other country where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some States do not allow disclaimer of express or implied warranties in certain transactions, therefore, this statement may not apply to you. This information could include technical inaccuracies or typographical errors. Changes are periodically made to the information herein; these changes will be incorporated in new editions of the publication. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time without notice. Any references in this information to non-ibm Web sites are provided for convenience only and do not in any manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the materials for this IBM product and use of those Web sites is at your own risk. IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring any obligation to you. Licensees of this program who wish to have information about it for the purpose of enabling: (i) the exchange of information between independently created programs and other programs (including this one) and (ii) the mutual use of the information which has been exchanged, should contact: Page 9 of 11

IBM Corporation Dept F6, Bldg 1 294 Route 100 Somers NY 10589-3216 U.S.A. Such information may be available, subject to appropriate terms and conditions, including in some cases, payment of a fee. The licensed program described in this document and all licensed material available for it are provided by IBM under terms of the IBM Customer Agreement, IBM International Program License Agreement or any equivalent agreement between us. Any performance data contained herein was determined in a controlled environment. Therefore, the results obtained in other operating environments may vary significantly. Some measurements may have been made on development-level systems and there is no guarantee that these measurements will be the same on generally available systems. Furthermore, some measurements may have been estimated through extrapolation. Actual results may vary. Users of this document should verify the applicable data for their specific environment. Information concerning non-ibm products was obtained from the suppliers of those products, their published announcements or other publicly available sources. IBM has not tested those products and cannot confirm the accuracy of performance, compatibility or any other claims related to non-ibm products. Questions on the capabilities of non-ibm products should be addressed to the suppliers of those products. All statements regarding IBM's future direction or intent are subject to change or withdrawal without notice, and represent goals and objectives only All IBM prices shown are IBM's suggested retail prices, are current and are subject to change without notice. Dealer prices may vary. This information is for planning purposes only. The information herein is subject to change before the products described become available. This information contains examples of data and reports used in daily business operations. To illustrate them as completely as possible, the examples include the names of individuals, companies, brands, and products. All of these names are fictitious and any similarity to the names and addresses used by an actual business enterprise is entirely coincidental. COPYRIGHT LICENSE: This information contains sample application programs in source language, which illustrate programming techniques on various operating platforms. You may copy, modify, and distribute these sample programs in any form without payment to IBM, for the purposes of developing, using, marketing or distributing application programs conforming to the application programming interface for the operating platform for which the sample programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannot guarantee or imply reliability, serviceability, or function of these programs. The sample programs are provided "AS IS", without warranty of any kind. IBM shall not be liable for any damages arising out of your use of the sample programs. Each copy or any portion of these sample programs or any derivative work, must include a copyright notice as follows: (your company name) (year). Portions of this code are derived from IBM Corp. Sample Programs. Copyright IBM Corp. _enter the year or years_. All rights reserved. If you are viewing this information softcopy, the photographs and color illustrations may not appear. Privacy Policy considerations IBM Software products, including software as a service solutions, ( Software Offerings ) may use cookies or other technologies to collect product usage information, to help improve the end user experience, to tailor Page 10 of 11

interactions with the end user or for other purposes. In many cases no personally identifiable information is collected by the Software Offerings. Some of our Software Offerings can help enable you to collect personally identifiable information. If this Software Offering uses cookies to collect personally identifiable information, specific information about this offering s use of cookies is set forth below. Depending upon the configurations deployed, this Software Offering may use session cookies or other similar technologies that collect each user s name, user name, password, and/or other personally identifiable information for purposes of session management, authentication, enhanced user usability, single sign-on configuration and/or other usage tracking and/or functional purposes. These cookies or other similar technologies cannot be disabled. If the configurations deployed for this Software Offering provide you as customer the ability to collect personally identifiable information from end users via cookies and other technologies, you should seek your own legal advice about any laws applicable to such data collection, including any requirements for notice and consent. For more information about the use of various technologies, including cookies, for these purposes, see IBM s Privacy Policy at http://www.ibm.com/privacy and IBM s Online Privacy Statement at http://www.ibm.com/privacy/details the section entitled Cookies, Web Beacons and Other Technologies and the IBM Software Products and Software-as-a-Service Privacy Statement at http://www.ibm.com/software/info/product-privacy. Trademarks IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at Copyright and trademark information at http://www.ibm.com/legal/copytrade.shtml. Adobe, the Adobe logo, PostScript, and the PostScript logo are either registered trademarks or trademarks of Adobe Systems Incorporated in the United States, and/or other countries. Java and all Java-based trademarks and logos are trademarks or registered trademarks of Oracle and/or its affiliates. Linux is a registered trademark of Linus Torvalds in the United States, other countries, or both. UNIX is a registered trademark of The Open Group in the United States and other countries. Other names may be trademarks of their respective owners. Other company, product, and service names may be trademarks or service marks of others Page 11 of 11