Scripting Examples Demonstrate a Variety of Tricks That Can Be Used When Working with Dates And/Or Times

Total Page:16

File Type:pdf, Size:1020Kb

Scripting Examples Demonstrate a Variety of Tricks That Can Be Used When Working with Dates And/Or Times SSccrriippttiinngg EExxaammpplleess Table of Contents USING VARIABLES ............................................. 5 Using Environment, Test Suite, & Data Bank Variables .............................................................................. 5 Accessing Data Source .................................................................................................................................. 6 Accessing Multiple Data Sources .................................................................................................................. 7 Using Environment Variables ....................................................................................................................... 8 Use Datasource Value & Return in XML - Jython (UG) .............................................................................. 9 Use Datasource Value & Return in XML - Javascript (UG) ....................................................................... 10 Access XML Data Bank .............................................................................................................................. 11 Sharing Data Between Two Extension Tools .............................................................................................. 12 Create Test Suite Variable ........................................................................................................................... 13 Test Suite Variables pt. 1 ............................................................................................................................ 14 Test Suite Variables pt. 2 ............................................................................................................................ 15 Test Suite Variables pt. 3 ............................................................................................................................ 16 Test Suite Variables pt. 4 ............................................................................................................................ 17 Change Test Suite Variable By Script ......................................................................................................... 18 BROWSER TESTING SCRIPTS ....................... 19 Accessing DOM of Browser Testing Tool .................................................................................................. 19 Accessing DOM of Browser - Retrieve <title> text of Frame .................................................................... 20 Return Title from Frame in Browser ........................................................................................................... 21 Get HTML Contents from Frame ................................................................................................................ 22 Access HTML Content as String (UG) ....................................................................................................... 23 Create Xpath Hook – Browser Testing (UG) .............................................................................................. 24 Using an XPath with a parameterized value (UG) ...................................................................................... 26 Scripting Element Locators (UG) ................................................................................................................ 27 How to invoke javascript in the browser context ........................................................................................ 28 BROWSER VALIDATION SCRIPTS ............... 30 Complex Browser Testing Validations (UG) .............................................................................................. 30 Validating a “Checked” property of HTML check box .............................................................................. 32 Return Actual Value for Use in Scripted Browser Validation .................................................................... 34 SCANNING TOOL .............................................. 35 Scanning Hook - Alert (UG) ....................................................................................................................... 35 Scanning Hook – Alert 2 (UG).................................................................................................................... 36 Scanning Hook – Confirm and Prompt (UG) ............................................................................................. 37 Scanning Hook – Realm Password (UG) ................................................................................................... 38 2 Scanning Hook – URL Logging (UG) ....................................................................................................... 39 READING/WRITING TO FILES ...................... 40 Writing Elements to a CSV/Excel File W/ a Timestamp ............................................................................ 40 Read Contents of File into String ................................................................................................................ 42 Log/Write Info (xml data bank) to file(old) ................................................................................................ 43 Writing information to a file ....................................................................................................................... 44 Customize File names with datasource values ............................................................................................ 45 How to read the contents of a file into a string ........................................................................................... 46 Reading Text using IOUtil.readTextFile(File) ............................................................................................ 47 Reading Binary file using IOUtil.readBinaryFile(File) ............................................................................... 48 LOAD TEST SCRIPTS ....................................... 49 Load Test Stop Script – Print to Console Merged data ............................................................................... 49 Load Test Stop Script – Print to console current data ................................................................................. 50 Load Test Stop Script – Stop if # of errors exceed N .................................................................................. 51 Load Test Stop Script – Stop if N is above threshold for M measurements ............................................... 52 Simple Monitor which Returns Memory Metrics in Current JVM Environment ....................................... 53 Returning memory metrics in the current JVM ........................................................................................... 54 DATE-TIME SCRIPTS ....................................... 55 Date/Time Scripting Tricks ......................................................................................................................... 55 Date/Time Scripting Tricks ......................................................................................................................... 56 Generates XML Schema dateTime string ................................................................................................... 57 Get a XML Representation of a date ........................................................................................................... 58 Return String containing XML schema dateTime....................................................................................... 59 JDBC SCRIPTS ................................................... 60 Calling Methods on JDBC Objects – DB tool (UG) ................................................................................... 60 How to Query a Database using Jython ...................................................................................................... 61 JDBC Programming pt.1 – Get Connection ................................................................................................ 62 JDBC Programming pt.2 - Create Table ................................................................................................... 63 JDBC Programming pt.3 - Populate Table ................................................................................................ 64 JDBC Programming pt.4 - Select Statement .............................................................................................. 65 JDBC Programming pt.5 - Test GetDriver .................................................................................................. 66 JDBC Programming pt.6 - Test GetDriver ................................................................................................ 67 JDBC Programming pt.7 - Drop Table ...................................................................................................... 68 JDBC Programming pt.8 - Close Connection ............................................................................................ 69 CHANGING PROTOCOLS ............................... 70 3 Switch all Tests’ Protocols to HTTP 1.0 ..................................................................................................... 70 Switch all Tests’ Protocols to HTTP 1.1 ..................................................................................................... 71 GENERATING UUIDS ....................................... 72 Generate & Return Universally Unique ID (UUID) ................................................................................... 72 Generating Unique Number to Write to XML Data Bank
Recommended publications
  • Testing Web Services: a Survey Technical Report TR-10-01
    Testing Web Services: A Survey Technical report TR-10-01 Mustafa Bozkurt, Mark Harman and Youssef Hassoun Centre for Research on Evolution, Search & Testing King’s College London Strand, London WC2R 2LS, UK mustafa.bozkurt,mark.harman,youssef.hassoun @kcl.ac.uk f g Abstract The Service-Oriented Computing (SOC) paradigm is allowing computer systems to interact with each other in new ways. According to the literature, SOC allows composition of distributed applications free from their platform and thus reduces the cost of such compositions and makes them easier and faster to develop. Currently web services are the most widely accepted service technology due to the level of autonomy and platform-independency they provide. However, web services also bring challenges. For example, testing web services at the client side is not as straightforward as testing traditional software due to the complex nature of web services and the absence of source code. This paper surveys the previous work undertaken on web service testing, showing the strengths and weaknesses of current web service testing strategies and identifying issues for future work. 1 Introduction This paper presents a survey of web service testing techniques. Web services is a rapidly growing concept that drives the Service-Oriented Computing (SOC) at present. Web services present important challenges to software testers. These challanges has led to much work on techniques for testing web services. The present paper seeks to provide a comprehensive survey of existing work. According to Papazoglou [110], SOC is a new computing paradigm that utilizes services as the lightweight constructs to support the development of rapid, low-cost and easy composition of distributed applications.
    [Show full text]
  • A Framework and Tool Supports for Generating Test Inputs of Aspectj Programs
    A Framework and Tool Supports for Generating Test Inputs of AspectJ Programs Tao Xie Jianjun Zhao Department of Computer Science Department of Computer Science & Engineering North Carolina State University Shanghai Jiao Tong University Raleigh, NC 27695 Shanghai 200240, China [email protected] [email protected] ABSTRACT 1. INTRODUCTION Aspect-oriented software development is gaining popularity with Aspect-oriented software development (AOSD) is a new tech- the wider adoption of languages such as AspectJ. To reduce the nique that improves separation of concerns in software develop- manual effort of testing aspects in AspectJ programs, we have de- ment [9, 18, 22, 30]. AOSD makes it possible to modularize cross- veloped a framework, called Aspectra, that automates generation of cutting concerns of a software system, thus making it easier to test inputs for testing aspectual behavior, i.e., the behavior imple- maintain and evolve. Research in AOSD has focused mostly on mented in pieces of advice or intertype methods defined in aspects. the activities of software system design, problem analysis, and lan- To test aspects, developers construct base classes into which the guage implementation. Although it is well known that testing is a aspects are woven to form woven classes. Our approach leverages labor-intensive process that can account for half the total cost of existing test-generation tools to generate test inputs for the woven software development [8], research on testing of AOSD, especially classes; these test inputs indirectly exercise the aspects. To enable automated testing, has received little attention. aspects to be exercised during test generation, Aspectra automati- Although several approaches have been proposed recently for cally synthesizes appropriate wrapper classes for woven classes.
    [Show full text]
  • Parasoft Dottest REDUCE the RISK of .NET DEVELOPMENT
    Parasoft dotTEST REDUCE THE RISK OF .NET DEVELOPMENT TRY IT https://software.parasoft.com/dottest Complement your existing Visual Studio tools with deep static INCREASE analysis and advanced PROGRAMMING EFFICIENCY: coverage. An automated, non-invasive solution that the related code, and distributed to his or her scans the application codebase to iden- IDE with direct links to the problematic code • Identify runtime bugs without tify issues before they become produc- and a description of how to fix it. executing your software tion problems, Parasoft dotTEST inte- grates into the Parasoft portfolio, helping When you send the results of dotTEST’s stat- • Automate unit and component you achieve compliance in safety-critical ic analysis, coverage, and test traceability testing for instant verification and industries. into Parasoft’s reporting and analytics plat- regression testing form (DTP), they integrate with results from Parasoft dotTEST automates a broad Parasoft Jtest and Parasoft C/C++test, allow- • Automate code analysis for range of software quality practices, in- ing you to test your entire codebase and mit- compliance cluding static code analysis, unit testing, igate risks. code review, and coverage analysis, en- abling organizations to reduce risks and boost efficiency. Tests can be run directly from Visual Stu- dio or as part of an automated process. To promote rapid remediation, each problem detected is prioritized based on configur- able severity assignments, automatical- ly assigned to the developer who wrote It snaps right into Visual Studio as though it were part of the product and it greatly reduces errors by enforcing all your favorite rules. We have stuck to the MS Guidelines and we had to do almost no work at all to have dotTEST automate our code analysis and generate the grunt work part of the unit tests so that we could focus our attention on real test-driven development.
    [Show full text]
  • Parasoft Static Application Security Testing (SAST) for .Net - C/C++ - Java Platform
    Parasoft Static Application Security Testing (SAST) for .Net - C/C++ - Java Platform Parasoft® dotTEST™ /Jtest (for Java) / C/C++test is an integrated Development Testing solution for automating a broad range of testing best practices proven to improve development team productivity and software quality. dotTEST / Java Test / C/C++ Test also seamlessly integrates with Parasoft SOAtest as an option, which enables end-to-end functional and load testing for complex distributed applications and transactions. Capabilities Overview STATIC ANALYSIS ● Broad support for languages and standards: Security | C/C++ | Java | .NET | FDA | Safety-critical ● Static analysis tool industry leader since 1994 ● Simple out-of-the-box integration into your SDLC ● Prevent and expose defects via multiple analysis techniques ● Find and fix issues rapidly, with minimal disruption ● Integrated with Parasoft's suite of development testing capabilities, including unit testing, code coverage analysis, and code review CODE COVERAGE ANALYSIS ● Track coverage during unit test execution and the data merge with coverage captured during functional and manual testing in Parasoft Development Testing Platform to measure true test coverage. ● Integrate with coverage data with static analysis violations, unit testing results, and other testing practices in Parasoft Development Testing Platform for a complete view of the risk associated with your application ● Achieve test traceability to understand the impact of change, focus testing activities based on risk, and meet compliance
    [Show full text]
  • Case Study Test the Untestable: Alaska Airlines Solves
    CASE STUDY Testing the Untestable Alaska Airlines Solves the Test Environment Dilemma Case Study Testing the Untestable Alaska Airlines Solves the Test Environment Dilemma OVERVIEW Alaska Airlines is primarily a West Coast carrier that services the states of Alaska and Hawaii with mid-continent and destinations in Canada and Mexico. Alaska Airlines received J.D. Powers' “Highest in Customer Satisfaction Among Traditional Carriers” recognition for twelve years in a row even recently winning first in all but one of the seven categories. A large part of the credit belongs to their software testing team. Their industry-leading, proactive approach to disrupting the traditional software testing process ensures that testers can test faster, earlier, and more completely. Learn how Ryan Papineau and his team used advanced automation in concert with service virtualization to rigorously test their complex flight operations manager software. The result: operations that run smoothly— even if they encounter a snowstorm in July. RELIABLE & ON-DEMAND FALSE REPEATABLE TESTS AUTOMATED TEST CASES POSITIVES 100欥 500 ELIMINATED 2 Case Study Testing the Untestable Alaska Airlines Solves the Test Environment Dilemma THE CHALLENGES At Alaska Airlines, the flight operations manager software is ultimately responsible for transporting 46 million customers to 115 global destinations via approximately 440,000 flights per year, safely and efficiently. This software coordinates a highly complex set of inputs from systems around the organization to ensure flights are on time while evaluating and managing fuel, cargo, baggage, and passenger requirements. In addition to the previously mentioned requirements, the system considers many factors including weather, aircraft characteristics, market, and fuel costs.
    [Show full text]
  • Parasoft Named an Omnichannel Functional Test Automation Leader
    Parasoft Corp. Headquarters 101 E. Huntington Drive Monrovia, CA 91016 USA www.parasoft.com [email protected] Press Release Parasoft Named an Omnichannel Functional Test Automation Leader, Recognized by major analyst firm for Impressive Roadmap Parasoft shines in evaluation specifically around effective test maintenance, strong CI/CD and application lifecycle management (ALM) platform integration MONROVIA (USA) – July 30, 2018 – Parasoft, the global leader in automated software testing, today announced its position as a leader in The Forrester Wave™: Omnichannel Functional Test Automation Tools, Q3 2018, where it received the highest scores possible in the API Testing and Automation and Product Road Map criteria. The report notes Parasoft’s “impressive and concrete road map to increase test automation from design to execution, pushing autonomous testing.” Parasoft will be showcasing its technology and discussing the future of testing in an upcoming webinar, The Future of Test Automation: Next- Generation Technologies to Use Today on August 23rd. To register, click here. According to the report, conducted by Forrester’s Diego Lo Giudice, “Parasoft shined in our evaluation specifically around effective test maintenance, strong CI/CD and application lifecycle management (ALM) platform integration, as well as reporting through its analytics system PIE. Clients like the recent changes, and all reference customers reported achieving test automation of more than 50% in the past 12 months.” After examining past research, user need assessments, and vendor and expert interviews, Forrester evaluated 15 omnichannel functional test automation tool vendors across a comprehensive 26-criteria to help organizations working on enterprise, mobile, and web applications select the right tool.
    [Show full text]
  • Interface Evolution Via Virtual Extension Methods Brian Goetz Fourth Draft, June 2011
    Interface evolution via virtual extension methods Brian Goetz Fourth draft, June 2011 1. Problem statement Once published, it is impossible to add methods to an interface without breaking existing implementations. (Specifically, adding a method to an interface is not a source- compatible change.) The longer the time since a library has been published, the more likely it is that this restriction will cause grief for its maintainers. The addition of closures to the Java language in JDK 7 place additional stress on the aging Collection interfaces; one of the most significant benefits of closures is that it enables the development of more powerful libraries. It would be disappointing to add a language feature that enables better libraries while at the same time not extending the core libraries to take advantage of that feature1. V1 of the Lambda Strawman proposed C#-style static extension methods as a means of creating the illusion of adding methods to existing classes and interfaces, but they have significant limitations – for example, they cannot be overridden by classes that implement the interface being extended, so implementations are stuck with the “one size fits all” implementation provided as an extension2, and they are not reflectively discoverable. 2. Virtual extension methods3 In this document, we outline a mechanism for adding new methods to existing interfaces, which we call virtual extension methods. Existing interfaces can be augmented without compromising backward compatibility4 by adding extension methods to the interface, whose declaration would contain instructions for finding the default implementation in the event that implementers do not provide a method body.
    [Show full text]
  • Identitymodel Documentation
    IdentityModel Documentation Dominick Baier and Brock Allen May 11, 2021 IdentityModel 1 IdentityModel 3 2 IdentityModel.AspNetCore 5 3 IdentityModel.AspNetCore.OAuth2Introspection7 4 IdentityModel.OidcClient 9 5 oidc-client.js 11 5.1 Overview................................................. 11 5.2 Discovery Endpoint........................................... 12 5.3 Token Endpoint.............................................. 14 5.4 Token Introspection Endpoint...................................... 17 5.5 Token Revocation Endpoint....................................... 17 5.6 UserInfo Endpoint............................................ 18 5.7 Dynamic Client Registration....................................... 18 5.8 Device Authorization Endpoint..................................... 19 5.9 Protocol and Claim Type Constants................................... 19 5.10 Creating Request URLs (e.g. for Authorize and EndSession endpoints)................ 20 5.11 Fluent API for the X.509 Certificate Store................................ 22 5.12 Base64 URL Encoding.......................................... 22 5.13 Epoch Time Conversion......................................... 22 5.14 Time-Constant String Comparison.................................... 22 5.15 Overview................................................. 23 5.16 Worker Applications........................................... 23 5.17 Web Applications............................................ 25 5.18 Extensibility............................................... 27 5.19 Overview................................................
    [Show full text]
  • Devsecops DEVELOPMENT & DEVOPS INFRASTRUCTURE
    DevSecOps DEVELOPMENT & DEVOPS INFRASTRUCTURE CREATE SECURE APPLICATIONS PARASOFT’S APPROACH - BUILD SECURITY IN WITHOUT DISRUPTING THE Parasoft provides tools that help teams begin their security efforts as DEVELOPMENT PROCESS soon as the code is written, starting with static application security test- ing (SAST) via static code analysis, continuing through testing as part of Parasoft makes DevSecOps possible with API and the CI/CD system via dynamic application security testing (DAST) such functional testing, service virtualization, and the as functional testing, penetration testing, API testing, and supporting in- most complete support for important security stan- frastructure like service virtualization that enables security testing be- dards like CWE, OWASP, and CERT in the industry. fore the complete application is fully available. IMPLEMENT A SECURE CODING LIFECYCLE Relying on security specialists alone prevents the entire DevSecOps team from securing software and systems. Parasoft tooling enables the BENEFIT FROM THE team with security knowledge and training to reduce dependence on PARASOFT APPROACH security specialists alone. With a centralized SAST policy based on in- dustry standards, teams can leverage Parasoft’s comprehensive docs, examples, and embedded training while the code is being developed. ✓ Leverage your existing test efforts for Then, leverage existing functional/API tests to enhance the creation of security security tests – meaning less upfront cost, as well as less maintenance along the way. ✓ Combine quality and security to fully understand your software HARDEN THE CODE (“BUILD SECURITY IN”) Getting ahead of application security means moving beyond just test- ✓ Harden the code – don’t just look for ing into building secure software in the first place.
    [Show full text]
  • Appendix a and Appendix B
    This PDF contains 2 Appendices: Appendix A and Appendix B. Appendix A Answers to the Test Your Knowledge Questions This appendix has the answers to the questions in the Test Your Knowledge section at the end of each chapter. Chapter 1 – Hello, C#! Welcome, .NET! 1. Why can a programmer use different languages, for example, C# and F#, to write applications that run on .NET? Answer: Multiple languages are supported on .NET because each one has a compiler that translates the source code into intermediate language (IL) code. This IL code is then compiled to native CPU instructions at runtime by the CLR. 2. What do you type at the prompt to create a console app? Answer: You enter dotnet new console. 3. What do you type at the prompt to build and execute C# source code? Answer: In a folder with a ProjectName.csproj file, you enter dotnet run. 4. What is the Visual Studio Code keyboard shortcut to view Terminal? Answer: Ctrl + ` (back tick). Answers to the Test Your Knowledge Questions 5. Is Visual Studio 2019 better than Visual Studio Code? Answer: No. Each is optimized for different tasks. Visual Studio 2019 is large, heavy- weight, and can create applications with graphical user interfaces, for example, Windows Forms, WPF, UWP, and Xamarin.Forms mobile apps, but it is only available on Windows. Visual Studio Code is smaller, lighter-weight, code-focused, supports many more languages, and is available cross-platform. In 2021, with the release of .NET 6 and .NET Multi-platform App User Interface (MAUI), Visual Studio Code will get an extension that enables building user interfaces for desktop and mobile apps.
    [Show full text]
  • Nested Class Modularity in Squeak/Smalltalk
    Springer, Nested Class Modularity in Squeak/Smalltalk Nested Class Modularity in Squeak/Smalltalk Modularität mit geschachtelten Klassen in Squeak/Smalltalk by Matthias Springer A thesis submitted to the Hasso Plattner Institute at the University of Potsdam, Germany in partial fulfillment of the requirements for the degree of Master of Science in ITSystems Engineering Supervisor Prof. Dr. Robert Hirschfeld Software Architecture Group Hasso Plattner Institute University of Potsdam, Germany August 17, 2015 Abstract We present the concept, the implementation, and an evaluation of Matriona, a module system for and written in Squeak/Smalltalk. Matriona is inspired by Newspeak and based on class nesting: classes are members of other classes, similarly to class instance variables. Top-level classes (modules) are globals and nested classes can be accessed using message sends to the corresponding enclosing class. Class nesting effec- tively establishes a global and hierarchical namespace, and allows for modular decomposition, resulting in better understandability, if applied properly. Classes can be parameterized, allowing for external configuration of classes, a form of dependency management. Furthermore, parameterized classes go hand in hand with mixin modularity. Mixins are a form of inter-class code reuse and based on single inheritance. We show how Matriona can be used to solve the problem of duplicate classes in different modules, to provide a versioning and dependency management mech- anism, and to improve understandability through hierarchical decomposition. v Zusammenfassung Diese Arbeit beschreibt das Konzept, die Implementierung und die Evaluierung von Matriona, einem Modulsystem für und entwickelt in Squeak/Smalltalk. Ma- triona ist an Newspeak angelehnt und basiert auf geschachtelten Klassen: Klassen, die, wie zum Beispiel auch klassenseitige Instanzvariablen, zu anderen Klassen gehören.
    [Show full text]
  • A Brief History of Parasoft Jtest
    A Brief History of Parasoft Jtest The static analysis technology for Jtest is invented The test generation technology for Jtest is invented The patent for Jtest’s test generation technology is First public release filed The patent for Jtest’s static analysis technology is filed Jtest patents awarded Jtest TM awarded Jtest introduces security rule set Jtest wins Best in Show at DevCon Jtest wins Software Magazine’s Productivity award Jtest nominated for JavaWorld Editors’ Choice awards Jtest becomes first product to use Design by Contract (Jcontract) comments to verify Java Automated JUnit test case generation is introduced classes/components at the system level Jtest wins Jolt Product Excellence Award Jtest wins Writer’s Choice Award from Java Report Jtest Tracer becomes the first tool to generate Jtest wins Software Business Magazines’s Best functional unit test cases as the user exercises the Development Tool Award working application Jtest wins Software and Information Industry Association’s Codie award for Best Software Testing Jtest wins JDJ Editors’ Choice Award Product or Service Jtest wins Software Development Magazines’s Jtest receives “Excellent” rating from Information World Productivity Award Jtest security edition released Flow-based static analysis is introduced Automated peer code review is introduced Cactus test generation is introduced Jtest is integrated into Development Testing Platform Jtest wins InfoWorld’s Technology of the Year award (DTP) Jtest wins Codie award for Best Software Testing DTP static analysis components
    [Show full text]