diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b52ce33..bd4a3c0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,6 +14,11 @@ pool: steps: - script: | echo "Starting Pipeline Execution." + mkdir temp + echo ${PWD} + echo "Copy SOAtest project contents to volume directory." + cp -R $(soatest.project) temp/. + ls -lrth cat <<'EOF' > deploy-aci.yml apiVersion: '2019-12-01' @@ -24,9 +29,9 @@ steps: - name: file-share-demo properties: environmentVariables: [] - image: mcr.microsoft.com/azuredocs/aci-hellofiles + image: lavanya93/parabank-baseline:2022 ports: - - port: 80 + - port: 8080 resources: requests: cpu: 1.0 @@ -39,8 +44,8 @@ steps: ipAddress: type: Public ports: - - port: 80 - dnsNameLabel: aci-demo1234 + - port: 8080 + dnsNameLabel: devparasoftcom volumes: - name: parasoftfiles azureFile: @@ -53,7 +58,76 @@ steps: az login az container create --resource-group ADOProject_group --file deploy-aci.yml - sleep 4m - nc -vz aci-demo1234.eastus.azurecontainer.io 80 - az container stop --name file-share-demo --resource-group ADOProject_group - az container delete --resource-group ADOProject_group --name file-share-demo + + # Set Up and write .properties file + echo -e "\n~~~\nSetting up and creating soatestcli.properties file.\n" + echo $" + dtp.url=$(license.server.url) + dtp.user=admin + dtp.password=$(license.server.password) + dtp.share.enabled=true + dtp.enabled=true + dtp.project=ADO + report.dtp.publish=true + techsupport.advanced=false + techsupport.auto_creation=true + techsupport.item.environment=true + techsupport.item.general=true + techsupport.archive_location=/temp + techsupport.send_email=false + techsupport.verbose=true + techsupport.verbose.scontrol=false + license.network.auth.enabled=true + license.network.password=$(license.server.password) + license.network.url=$(license.server.url) + license.network.use.specified.server=true + license.network.user=admin + soatest.license.network.edition=automation_edition + soatest.license.use_network=true + virtualize.license.network.edition=performance_server_edition + virtualize.license.use_network=true" >> temp/soatestcli.properties + echo -e "\nDebug -- Verify workspace contents.\n" + ls -R + echo -e "\nDebug -- Verify soatestcli.properties file contents." + cat temp/soatestcli.properties + echo -e "\n~~~\nSetting up and creating localsettings.properties file.\n" + + # Run Docker container with mount and run tests + echo -e "\n~~~\nRun SOAtestCLI Docker container & mount ./temp volume.\n" + + docker --version + + docker run -i \ + -u 0:0 \ + -e ACCEPT_EULA=true \ + -v "$(pwd)/temp:/temp" \ + parasoft/soavirt /bin/bash -c " \ + cat /temp/soatestcli.properties; \ + soatestcli \ + -settings /temp/soatestcli.properties \ + -import /temp/$(soatest.project); \ + soatestcli \ + -resource /$(soatest.project) \ + -config 'user://Example Configuration' \ + -settings /temp/soatestcli.properties \ + -report /temp \ + -publish" \ + + echo "stopping container" + az container stop --name file-share-demo --resource-group ADOProject_group + + echo "deleting container" + az container delete --resource-group ADOProject_group --name file-share-demo --yes + + docker ps \ + echo -e "\nDebug -- Verify ./temp contents\n" + + ls -R $(pwd)/temp + + displayName: Run Tests + env: + pwd: $(Build.Repository.LocalPath) + +- publish: /home/vsts/work/1/s/temp + artifact: TSA +# Publish Test Results \ No newline at end of file diff --git a/jtest_unit/Demo/.mvn/wrapper/MavenWrapperDownloader.java b/jtest_unit/Demo/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..b901097 --- /dev/null +++ b/jtest_unit/Demo/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/jtest_unit/Demo/.mvn/wrapper/maven-wrapper.jar b/jtest_unit/Demo/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..2cc7d4a Binary files /dev/null and b/jtest_unit/Demo/.mvn/wrapper/maven-wrapper.jar differ diff --git a/jtest_unit/Demo/.mvn/wrapper/maven-wrapper.properties b/jtest_unit/Demo/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..3745b11 --- /dev/null +++ b/jtest_unit/Demo/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.2/apache-maven-3.6.2-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/jtest_unit/Demo/.settings/org.eclipse.jdt.core.prefs b/jtest_unit/Demo/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..2f5cc74 --- /dev/null +++ b/jtest_unit/Demo/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/jtest_unit/Demo/META-INF/MANIFEST.MF b/jtest_unit/Demo/META-INF/MANIFEST.MF new file mode 100644 index 0000000..e688c99 --- /dev/null +++ b/jtest_unit/Demo/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.7.1 +Created-By: 11.0-b16 (Sun Microsystems Inc.) diff --git a/jtest_unit/Demo/README.txt b/jtest_unit/Demo/README.txt new file mode 100644 index 0000000..79a2eed --- /dev/null +++ b/jtest_unit/Demo/README.txt @@ -0,0 +1,242 @@ +The description of Ant, Maven, and Gradle integration is available at https://docs.parasoft.com/display/JTEST20221/Integrating+with+Build+Systems + +This document describes how to perform static analysis, run tests, and collect coverage information with Jtest - using the "demo" project shipped with the product. + +Please note that the analysis of this project is configured with the settings specified in the demo.properties file located in the [INSTALL]/examples/demo directory. +The demo.properties file is used by Ant, Maven and Gradle build scripts. The following command line examples are intended to be executed from the "demo" project directory. + + +Prerequisites +------------------------------------------------- +1. Set up the Jtest license in jtestcli.properties in the Jtest installation directory. + + +Jtest data file +------------------------------------------------- +1. Run the "Recommended Rules" test configuration to perform static analysis directly (without any build system) - using the following command: + Windows: + ..\..\jtestcli.exe -config "builtin://Recommended Rules" -data demo.data.json -report report + UNIX: + ../../jtestcli -config "builtin://Recommended Rules" -data demo.data.json -report report + + +Ant +------------------------------------------------- +1. Make sure that you have "ant" available on your path. + +2. Run "Demo Configuration" to perform static analysis and collect coverage for unit tests: + + ant -file jtest.xml -Djtest.config="builtin://Demo Configuration" + + The "demo" project will be built and unit tests will be run. The Jtest Plugin for Ant collects source code compilation data, + and unit test results with coverage to perform analysis and generate the report. + + Note: + + To only run static analysis, use the following command: + + ant -file jtest.xml jtest-sae + + To only run unit tests, use the following command: + + ant -file jtest.xml jtest-utc + + Configurations are specified in jtest.xml - see "jtest", "jtest-sae", or "jtest-utc" targets. + + +Maven +------------------------------------------------- +1. Configure your Maven setup by following the Jtest User Guide: + https://docs.parasoft.com/display/JTEST20221/Configuring+the+Jtest+Plugin+for+Maven + +2. Run "Demo Configuration" to perform static analysis and collect coverage for unit tests: + + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Demo Configuration" + + The "demo" project will be built and unit tests will be run. The Jtest Plugin for Maven will collect source code compilation data, + and test results with coverage to perform analysis and generate the report. + + Note: + + To only run static analysis, use the following command: + + mvnw jtest:jtest + + The "Recommended Rules" test configuration is used by default. + + To only run unit tests, use the following command: + + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" + + +Gradle +------------------------------------------------- +Note: The "demo" project uses JUnit 5, which requires Gradle 4.6 or higher. + +1. Configure the installed Jtest package or add the desired settings to the "jtest" block of your buildscript. + +2. Run "Demo Configuration" to perform static analysis and collect coverage for unit tests: + + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Demo Configuration" + + The "demo" project will be built and Junit tests will be run. The Jtest Plugin for Gradle will collect + source code compilation data, and test results to perform analysis and generate report. + + Note: + + To only run static analysis, use the following command: + + gradlew clean assemble jtest + + "Recommended Rules" configuration is used by default. + + To only run unit tests, use the following command: + + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" + + +================================================= + +Test Impact Analysis + +Test Impact analysis is supported for Maven and Gradle. + +Windows: + +1. Run the tests with Maven or Gradle to collect the baseline data about the tests and coverage: + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + or + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + + Note: As a result, the report.xml and coverage.xml files will be created in the 'tia' subfolder. + +2. Modify a source file from the test scope: + src\main\java\examples\mock\FileExample.java + +3. Run the following command to execute the tests affected by your change: + mvnw clean tia:affected-tests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + or + gradlew clean affectedTests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + + Tests that aren't affected by your code modification are not executed. + +UNIX: + +1. Run the tests with Maven or Gradle to collect the baseline data about the tests and coverage: + ./mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + or + ./gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + + Note: As a result, the report.xml and coverage.xml files will be created in the 'tia' subfolder. + +2. Modify a source file from the test scope: + src/main/java/examples/mock/FileExample.java + +3. Run the following command to execute the tests affected by your change: + ./mvnw clean tia:affected-tests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + or + ./gradlew clean affectedTests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + + Tests that aren't affected by your code modification are not executed. + + +For more information see: + https://docs.parasoft.com/display/JTEST20221/Testing+and+Analysis+with+Maven + https://docs.parasoft.com/display/JTEST20221/Testing+and+Analysis+with+Gradle + +================================================= + +Collecting application coverage + +Windows: + +1. Build application and collect data necessary for monitoring + ant -file jtest.xml clean jtest-monitor + or + mvnw clean package jtest:monitor + or + gradlew clean assemble jtest-monitor + + Note: As a result you should get monitor.zip file. + +2. Run the application and collect the coverage data + + a) Unpack the monitor.zip archive into the "demo" directory (the subdirectory "monitor" will be created). + ant: + Archive path: parasoft\jtest-monitor\monitor.zip + mvn: + Archive path: target\jtest\monitor\monitor.zip + gradle: + Archive path: build\jtest\monitor.zip + + b) Run agent.bat + cd monitor + agent.bat + cd .. + + c) Run the application using the Java VM argument generated in point b) + ant + java -cp demo.jar [paste argument generated in point b] examples.stackmachine.RunnableStackMachine + mvn: + java -cp target\Demo.jar [paste argument generated in point b] examples.stackmachine.RunnableStackMachine + gradle: + java -cp build\libs\demo.jar [paste argument generated in point b] examples.stackmachine.RunnableStackMachine + + d) Perform several actions using "Stack Machine Example" application: + - Insert 123 number into "Input" field + - press "push" button 5 times + - press "+", "-", "x" and "/" buttons + - exit application + +3. Generate the coverage report + + ..\..\jtestcli.exe -config "builtin://Calculate Application Coverage" -staticcoverage monitor\static_coverage.xml -runtimecoverage monitor\runtime_coverage + + Coverage details are available in report.html + +UNIX: + +1. Build the application and collect the data necessary for monitoring + ant -file jtest.xml clean jtest-monitor + or + ./mvnw clean package jtest:monitor + or + ./gradlew clean build jtest-monitor + + Note: As a result you should get monitor.zip file. + +2. Run the application and collect the coverage data + + a) Unpack monitor.zip archive into demo directory (subdirectory monitor will be created) + ant: + unzip ./parasoft/jtest-monitor/monitor.zip + mvn: + unzip ./target/jtest/monitor/monitor.zip + gradle: + unzip ./build/jtest/monitor.zip + + b) Run agent.sh + ./monitor/agent.sh + + c) Run application using Java VM argument generated in point b) + ant + java -cp ./demo.jar [paste argument generated in point b] examples.stackmachine.RunnableStackMachine + mvn: + java -cp ./target/Demo.jar [paste argument generated in point b] examples.stackmachine.RunnableStackMachine + gradle: + java -cp ./build/libs/demo.jar [paste argument generated in point b] examples.stackmachine.RunnableStackMachine + + d) Perform few actions using "Stack Machine Example" application + - Insert 123 number into "Input" field + - press "push" button 5 times + - press "+", "-", "x" and "/" buttons + - exit application + +3. Generate coverage report + + ../../jtestcli -config "builtin://Calculate Application Coverage" -staticcoverage ./monitor/static_coverage.xml -runtimecoverage ./monitor/runtime_coverage + + Coverage details are available in report.html + + +For more information see https://docs.parasoft.com/display/JTEST20221/Application+Coverage diff --git a/jtest_unit/Demo/README_ja.txt b/jtest_unit/Demo/README_ja.txt new file mode 100644 index 0000000..282ac9f --- /dev/null +++ b/jtest_unit/Demo/README_ja.txt @@ -0,0 +1,241 @@ +Ant、Maven、Gradle との統合の説明は次のページにあります。 +https://docs.parasoft.com/display/JTESTJP20221/Integrating+with+Build+Systems + +このドキュメントは、製品に付属の "demo" プロジェクトを使用して、Jtest で静的解析、テスト実行、カバレッジ情報の収集を行う方法を説明します。 + +このプロジェクトの解析設定は、[INSTALL]/examples/demo ディレクトリにある demo.properties ファイルで +設定されています。 +demo.properties ファイルは Ant、Maven、Gradle ビルド スクリプトによって使用されます。 +以下のコマンド ラインのサンプルは、"demo" プロジェクト ディレクトリで実行することを +前提にしています。 + + +前提条件 +------------------------------------------------- +1. Jtest インストール ディレクトリにある jtestcli.properties で Jtest のライセンスが設定されていること。 + + +Jtest データ ファイル +------------------------------------------------- +1. "Recommended Rules" テスト コンフィギュレーションを実行して、静的解析を直接 (ビルド システムなしで) 行います。 - 次のコマンドを使用します。 + Windows: + ..\..\jtestcli.exe -config "builtin://Recommended Rules" -data demo.data.json -report report + UNIX: + ../../jtestcli -config "builtin://Recommended Rules" -data demo.data.json -report report + + +Ant +------------------------------------------------- +1. "ant" がパスに含まれていることを確認します。 + +2. "Demo Configuration" を実行して静的解析を行い、単体テストのカバレッジを収集します。 + + ant -file jtest.xml -Djtest.config="builtin://Demo Configuration" + + "demo" プロジェクトがビルドされ、単体テストが実行されます。The Jtest Plugin for Ant がソース コードのコンパイル データとカバレッジ付きの単体テスト結果を収集して解析を行い、レポートを生成します。 + 注意: + + 静的解析だけを実行するには、次のコマンドを使用します。 + + ant -file jtest.xml jtest-sae + + 単体テストだけを実行するには、次のコマンドを使用します。 + + ant -file jtest.xml jtest-utc + + コンフィギュレーションは jtest.xml で指定されます。- "jtest"、"jtest-sae"、"jtest-utc" ターゲットを参照してください。 + + +Maven +------------------------------------------------- +1. Jtest ユーザー ガイドに従って Maven を設定します。 + https://docs.parasoft.com/display/JTEST20221/Configuring+the+Jtest+Plugin+for+Maven + +2. "Demo Configuration" を実行して、静的解析を行い、単体テストのカバレッジを収集します。 + + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Demo Configuration" + + "demo" プロジェクトがビルドされ、単体テストが実行されます。Jtest Plugin for Maven がソース コードのコンパイル データとカバレッジ付きの単体テスト結果を収集して解析を行い、レポートを生成します。 + + 注意: + + 静的解析だけを実行するには、次のコマンドを使用します。 + + mvnw jtest:jtest + + デフォルトで "Recommended Rules" テスト コンフィギュレーションが使用されます。 + + 単体テストだけを実行するには、次のコマンドを使用します。 + + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" + + +Gradle +------------------------------------------------- +注意: "demo" プロジェクトは JUnit 5 を使用します。JUnit 5 は Gradle 4.6 以上を必要とします。 + +1. インストール済みの Jtest パッケージを設定するか、ビルドスクリプトの "jtest" ブロックに設定を追加します。 + +2. "Demo Configuration" を実行して、静的解析を行い、単体テストのカバレッジを収集します。 + + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Demo Configuration" + + "demo" プロジェクトがビルドされ、単体テストが実行されます。Jtest Plugin for Gradle がソース コードのコンパイル データとカバレッジ付きの単体テスト結果を収集して解析を行い、レポートを生成します。 + + 注意: + + 静的解析だけを実行するには、次のコマンドを使用します。 + + gradlew clean assemble jtest + + デフォルトで "Recommended Rules" テスト コンフィギュレーションが使用されます。 + + 単体テストだけを実行するには、次のコマンドを使用します。 + + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" + + +================================================= + +テスト影響分析 + +テスト影響分析は Maven および Gradle でサポートされています。 + +Windows: + +1. Maven または Gradle でテストを行い、テストおよびカバレッジに関するベースライン データを収集します。 + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + または + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + + 注意: 結果として、'tia' サブフォルダーに report.xml および coverage.xml ファイルが作成されます。 + +2. テスト スコープのソース ファイルを変更します。 + src\main\java\examples\mock\FileExample.java + +3. 次のコマンドを使用して、変更の影響を受けるテストを実行します。 + mvnw clean tia:affected-tests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + または + gradlew clean affectedTests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + + コードの変更の影響を受けないテストは実行されません。 + +UNIX: + +1. Maven または Gradle でテストを行い、テストおよびカバレッジに関するベースライン データを収集します。 + ./mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + または + ./gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + + 注意: 結果として、'tia' サブフォルダーに report.xml および coverage.xml ファイルが作成されます。 + +2. テスト スコープのソース ファイルを変更します。 + src/main/java/examples/mock/FileExample.java + +3. 次のコマンドを使用して、変更の影響を受けるテストを実行します。 + ./mvnw clean tia:affected-tests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + または + ./gradlew clean affectedTests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + + コードの変更の影響を受けないテストは実行されません。 + + +詳細は以下を参照してください。 + https://docs.parasoft.com/display/JTEST20221/Testing+and+Analysis+with+Maven + https://docs.parasoft.com/display/JTEST20221/Testing+and+Analysis+with+Gradle + +================================================= + +アプリケーション カバレッジの収集 + +Windows: + +1. アプリケーションをビルドし、モニタリングに必要な情報を収集します。 + ant -file jtest.xml clean jtest-monitor + または + mvnw clean package jtest:monitor + または + gradlew clean assemble jtest-monitor + + 注意: 結果として monitor.zip ファイルが作成されます。 + +2. アプリケーションを実行してカバレッジ データを収集します。 + + a) monitor.zip アーカイブを "demo" ディレクトリに展開します ("monitor" サブディレクトリが作成されます)。 + ant: + Archive path: parasoft\jtest-monitor\monitor.zip + mvn: + Archive path: target\jtest\monitor\monitor.zip + gradle: + Archive path: build\jtest\monitor.zip + + b) agent.bat を実行します。 + cd monitor + agent.bat + cd .. + + c) b) で生成された Java VM 引数を使用してアプリケーションを実行します。 + ant + java -cp demo.jar [b で生成された引数を貼り付ける] examples.stackmachine.RunnableStackMachine + mvn: + java -cp target\Demo.jar [b で生成された引数を貼り付ける] examples.stackmachine.RunnableStackMachine + gradle: + java -cp build\libs\demo.jar [b で生成された引数を貼り付ける] examples.stackmachine.RunnableStackMachine + + d) "Stack Machine Example" アプリケーションを操作します。 + - "Input" フィールドに数字 123 を入力します。 + - "push" ボタンを 5 回押します。 + - "+"、"-"、"x"、"/" ボタンを押します。 + - アプリケーションを終了します。 + +3. カバレッジ レポートを生成します。 + + ..\..\jtestcli.exe -config "builtin://Calculate Application Coverage" -staticcoverage monitor\static_coverage.xml -runtimecoverage monitor\runtime_coverage + + カバレッジの詳細が report.html に出力されます。 + +UNIX: + +1. アプリケーションをビルドし、モニタリングに必要な情報を収集します。 + ant -file jtest.xml clean jtest-monitor + または + ./mvnw clean package jtest:monitor + または + ./gradlew clean build jtest-monitor + + 注意: 結果として monitor.zip ファイルが作成されます。 + +2. アプリケーションを実行してカバレッジ データを収集します。 + + a) monitor.zip アーカイブを "demo" ディレクトリに展開します ("monitor" サブディレクトリが作成されます)。 + unzip ./parasoft/jtest-monitor/monitor.zip + mvn: + unzip ./target/jtest/monitor/monitor.zip + gradle: + unzip ./build/jtest/monitor.zip + + b) agent.sh を実行します。 + ./monitor/agent.sh + + c) b) で生成された Java VM 引数を使用してアプリケーションを実行します。 + ant + java -cp ./demo.jar [b で生成された引数を貼り付ける] examples.stackmachine.RunnableStackMachine + mvn: + java -cp ./target/Demo.jar [b で生成された引数を貼り付ける] examples.stackmachine.RunnableStackMachine + gradle: + java -cp ./build/libs/demo.jar [b で生成された引数を貼り付ける] examples.stackmachine.RunnableStackMachine + + d) "Stack Machine Example" アプリケーションを操作します。 + - "Input" フィールドに数字 123 を入力します。 + - "push" ボタンを 5 回押します。 + - "+"、"-"、"x"、"/" ボタンを押します。 + - アプリケーションを終了します。 + +3. カバレッジ レポートを生成します。 + + ../../jtestcli -config "builtin://Calculate Application Coverage" -staticcoverage ./monitor/static_coverage.xml -runtimecoverage ./monitor/runtime_coverage + + カバレッジの詳細が report.html に出力されます。 + + +詳細は https://docs.parasoft.com/display/JTEST20221/Application+Coverage を参照してください。 diff --git a/jtest_unit/Demo/README_zh_CN.txt b/jtest_unit/Demo/README_zh_CN.txt new file mode 100644 index 0000000..38a127a --- /dev/null +++ b/jtest_unit/Demo/README_zh_CN.txt @@ -0,0 +1,242 @@ +ڶ AntMaven Gradle ɵ·ȡ +https://docs.parasoft.com/display/JTEST20221/Integrating+with+Build+Systems + +ĵʹ Jtest ִо̬вԼռ +Ϣ - ʹòƷи "demo" Ŀ + +ע⣬Ŀķʹ demo.properties ļָ +õġļλ [INSTALL]/examples/demo Ŀ¼С + + +ǰ +------------------------------------------------- +1. Jtest װĿ¼е jtestcli.properties ļ Jtest ֤ + + +Jtest ļ +------------------------------------------------- +1. "Recommended Rules" ãֱִо̬κιϵͳ- ʹ + Windows: + ..\..\jtestcli.exe -config "builtin://Recommended Rules" -data demo.data.json -report report + UNIX: + ../../jtestcli -config "builtin://Recommended Rules" -data demo.data.json -report report + + +Ant +------------------------------------------------- +1. ȷ·ϴڿõ "ant" + +2. "Demo Configuration"ִо̬ռԪԵĸʣ + + ant -file jtest.xml -Djtest.config="builtin://Demo Configuration" + + "demo" ĿеԪԡ Ant Jtest ռԴݺͰʵĵԪԽִзɱ档 + + ע⣺ + + о̬ʹ + + ant -file jtest.xml jtest-sae + + еԪԣʹ + + ant -file jtest.xml jtest-utc + + jtest.xml ָ - "jtest", "jtest-sae", "jtest-utc" Ŀꡣ + + +Maven +------------------------------------------------- +1. Jtest ûָ Maven ã + https://docs.parasoft.com/display/JTEST20221/Configuring+the+Jtest+Plugin+for+Maven + +2. "Demo Configuration" ִо̬ռڵԪԵĸʣ + + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Demo Configuration" + + "demo" ĿеԪԡ Maven Jtest ռԴݺ + ʵIJԽִзɱ档 + + ע⣺ + + о̬ʹ + + mvnw jtest:jtest + + Ĭʹ "Recommended Rules" á + + еԪԣʹ + + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" + + +Gradle +------------------------------------------------- +ע: "demo" Ŀʹ JUnit 5, Ҫ Gradle 4.6 ߰汾 + +1. Jtest װõű "jtest" 顣 + +2. "Demo Configuration"ִо̬ռڵԪԵĸʣ + + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Demo Configuration" + + "demo" ĿеԪԡGradle Jtest ռԴݺͲԽִкɱ档 + + ע⣺ + + о̬ʹ + + gradlew clean assemble jtest + + Ĭʹ "Recommended Rules" á + + еԪԣʹ + + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" + + +================================================= + +Ӱ + +Maven Gradle ֲ֧Ӱ + +Windows: + +1. ʹ Maven Gradle вԣռڲԺʵĻݣ + mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + + gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + + ע⣺ˣreport.xml cover .xml ļ 'tia' ļд + +2. IJԷΧеԴļ + src\main\java\examples\mock\FileExample.java + +3. ִܸӰIJԣ + mvnw clean tia:affected-tests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + + gradlew clean affectedTests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + + ܴӰIJԲִС + +UNIX: + +1. ʹ Maven Gradle вԣռԺʵĻݣ + ./mvnw clean test-compile jtest:agent test jtest:jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + + ./gradlew clean jtest-agent test jtest -Djtest.config="builtin://Unit Tests" -Djtest.report=tia + + ע⣺ˣreport.xml coverage.xml ļ 'tia' ļд + +2. IJԷΧеԴļ: + src/main/java/examples/mock/FileExample.java + +3. ִܸӰIJԣ + ./mvnw clean tia:affected-tests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + + ./gradlew clean affectedTests test -Djtest.referenceCoverageFile=tia/coverage.xml -Djtest.referenceReportFile=tia/report.xml + + ܴӰIJԲִС + + +йظ飬ģ + https://docs.parasoft.com/display/JTEST20221/Testing+and+Analysis+with+Maven + https://docs.parasoft.com/display/JTEST20221/Testing+and+Analysis+with+Gradle + +================================================= + +ռӦó + +Windows: + +1. Ӧóռ + ant -file jtest.xml clean jtest-monitor + + mvnw clean package jtest:monitor + + gradlew clean assemble jtest-monitor + + ע⣺ˣӦû monitor.zip ļ + +2. Ӧóռ + + a) monitor.zip 鵵ļѹ "demo" Ŀ¼УĿ¼ "monitor" + ant: + Archive path: parasoft\jtest-monitor\monitor.zip + mvn: + Archive path: target\jtest\monitor\monitor.zip + gradle: + Archive path: build\jtest\monitor.zip + + b) agent.bat + cd monitor + agent.bat + cd .. + + c) ʹ b) ɵ Java VM Ӧó + ant + java -cp demo.jar [ճ b ɵIJ] examples.stackmachine.RunnableStackMachine + mvn: + java -cp target\Demo.jar [ճ b ɵIJ] examples.stackmachine.RunnableStackMachine + gradle: + java -cp build\libs\demo.jar [ճ b ɵIJ] examples.stackmachine.RunnableStackMachine + + d) ʹ "Stack Machine Example" Ӧóִж + - 123 뵽 "Input" ֶ + - ѹ "push" ť 5 + - ѹ "+", "-", "x" "/" ť + - ˳Ӧó + +3. ɸʱ + + ..\..\jtestcli.exe -config "builtin://Calculate Application Coverage" -staticcoverage monitor\static_coverage.xml -runtimecoverage monitor\runtime_coverage + + ʵϸϢ report.html ҵ + +UNIX: + +1. Ӧóռ + ant -file jtest.xml clean jtest-monitor + + ./mvnw clean package jtest:monitor + + ./gradlew clean build jtest-monitor + + ע⣺ˣӦû monitor.zip ļ + +2. Ӧóռ + + a) monitor.zip 鵵ļѹ demo ·ϣĿ¼ӣ + ant: + unzip ./parasoft/jtest-monitor/monitor.zip + mvn: + unzip ./target/jtest/monitor/monitor.zip + gradle: + unzip ./build/jtest/monitor.zip + + b) agent.sh + ./monitor/agent.sh + + c) ʹ b) ɵ Java VM Ӧó + ant + java -cp ./demo.jar [ճ b ɵIJ] examples.stackmachine.RunnableStackMachine + mvn: + java -cp ./target/Demo.jar [ճ b ɵIJ] examples.stackmachine.RunnableStackMachine + gradle: + java -cp ./build/libs/demo.jar [ճ b ɵIJ] examples.stackmachine.RunnableStackMachine + + d) ʹ "Stack Machine Example" Ӧóִ + - 123 뵽 "Input" ֶ + - ѹ "push" ť 5 + - ѹ "+", "-", "x" "/" ť + - ˳Ӧó + +3. ɸʱ + + ../../jtestcli -config "builtin://Calculate Application Coverage" -staticcoverage ./monitor/static_coverage.xml -runtimecoverage ./monitor/runtime_coverage + + ʵϸϢ report.html ҵ + + +йظ飬 https://docs.parasoft.com/display/JTEST20221/Application+Coverage diff --git a/jtest_unit/Demo/build.gradle b/jtest_unit/Demo/build.gradle new file mode 100644 index 0000000..75f1429 --- /dev/null +++ b/jtest_unit/Demo/build.gradle @@ -0,0 +1,71 @@ + +description = '
The project contains sample source code with various errors, and bad practice examples which can be detected by Jtest analysis.
' + +apply plugin: 'java' +apply plugin: 'maven-publish' + +group = theGroup +version = theVersion + +def jtestPluginPath = projectDir.absolutePath + '/../../integration/gradle/jtest.gradle' +if(file(jtestPluginPath).exists()) { + apply from: jtestPluginPath +} else { + logger.warn('The Jtest tasks cannot be executed from the command line. Please verify if the following file is available: \'../../integration/gradle/jtest.gradle\'') +} + +sourceCompatibility = JavaVersion.VERSION_1_8 +targetCompatibility = JavaVersion.VERSION_1_8 + +compileJava.options.encoding = 'UTF-8' + + +test{ + + // print short tests summary + afterSuite { desc, result -> + if (!desc.parent) + println("Test results: ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped") + } + useJUnitPlatform() + + // ignore test failures for demo purposes + ignoreFailures = true + + // AccountDynamicTest.class is a part of AccountDynamicSuite.class and should not be launched as a separated test + exclude '**/nbank/AccountDynamicTest.class' + exclude '**/*Test*$*.class' +} + +buildscript { + repositories { + mavenCentral() + } +} + +repositories { + mavenLocal() + mavenCentral() +} + +jar { + archiveName = theName + '.jar' +} + +dependencies { + implementation 'javax.servlet:servlet-api:2.4' + testImplementation 'org.hamcrest:hamcrest:2.2' + testImplementation 'org.mockito:mockito-junit-jupiter:4.4.0' + testImplementation 'org.mockito:mockito-inline:4.4.0' + testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2' + testImplementation 'org.junit.jupiter:junit-jupiter-migrationsupport:5.8.2' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.8.2' + testImplementation 'org.junit.vintage:junit-vintage-engine:5.8.2' + testImplementation 'pl.pragmatists:JUnitParams:1.1.1' +} + +processResources { + from ('src/test/java') { + include '**/*.csv' + } +} diff --git a/jtest_unit/Demo/build.xml b/jtest_unit/Demo/build.xml new file mode 100644 index 0000000..d752e18 --- /dev/null +++ b/jtest_unit/Demo/build.xml @@ -0,0 +1,112 @@ + +
+
|
+|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The project contains sample source code with various errors, and bad practice examples which can be detected by Jtest analysis.
]]> + ++ * This example shows how enforcing BD.SECURITY.VPPD: ("Encapsulate all + * dangerous data returning methods with a validation function") helps to + * definitely secure an application from dangerous inputs. + *
+ *
+ * The main security vulnerability in this code is that the username and
+ * password entered by the user are not validated. This is very dangerous, for
+ * example anybody entering "a' OR 'a' = 'a" as username and
+ * password would be authorized.
+ *
HttpServletRequest and propagates without being validate to the
+ * SQL statement. BD.SECURITY.VPPD tell us that HttpServletRequest
+ * is returning tainted data that is not encapsulated by a validating
+ * method.PARTIAL FIX in
+ * the authorize() method.CODE ENHANCEMENT in doGet(). After that change
+ * the code would be vulnerable to an attack again. A user would still not be
+ * able to get authorized by just entering "a' OR 'a' = 'a" as the
+ * previous fix would prevent that, but somebody could instead enter
+ * "hacker" for username and
+ * "unknown'; DELETE FROM Accounts; --" for password and completely
+ * delete the "Accounts" table (or any other table) from the database.
+ *
+ * A more general fix is the one shown in DEFINITIVE FIX in
+ * doGet(), the input is validated as soon as it enters the code
+ * and before it starts propagating through different paths.
+ *
DefaultListModel.
+ */
+public abstract class AbstractStackMachine extends DefaultListModel implements StackInterface {
+
+ /**
+ * Retrive two elements from the stack and put back the add of them.Pre comment: 'add()' can only be called if there
+ * are enough elements.Post comment: top value in the stack should be
+ * the sum of the top two.
+ */
+ public int add() {
+ int op1 = popInt();
+ int op2 = popInt();
+ int result = op1 + op2;
+ pushInt(result);
+ return result;
+ }
+
+ /**
+ * Retrive two elements from the stack and put back the add of them.Pre comment: 'subtract()' can only be called if
+ * there are enough elements.Post comment: top value in the stack should be
+ * the subtraction of the top two.
+ */
+ public int subtract() {
+ int op1 = popInt();
+ int op2 = popInt();
+ int result = op1 + op2; // BUG: should be '-'
+ pushInt(result);
+ return result;
+ }
+
+ /**
+ * Retrive two elements from the stack and put back the add of them.Pre comment: 'multiply()' can only be called if
+ * there are enough elements.Post comment: top value in the stack should be
+ * the multiplication of the top two.
+ */
+ public int multiply() {
+ int op1 = popInt();
+ int op2 = popInt();
+ int result = op1 * op2;
+ // bogus assert: uncomment to try:
+ // ** @assert (result == op1 + op2) */
+ pushInt(result);
+ return result;
+ }
+
+ /**
+ * Retrive two elements from the stack and put back the add of them.Pre comment: 'divide()' can only be called if
+ * there are enough elements.Post comment: top value in the stack should be
+ * the multiplication of the top two.
+ */
+ public int divide() {
+ int op1 = popInt();
+ int op2 = popInt();
+ int result = op1 / op2;
+ pushInt(result);
+ return result;
+ }
+
+ /**
+ * Retrive an element from the stack by index.
+ *
+ * @param index
+ * of element to retrieve.
+ * @return an element of the stack.
+ */
+ protected int at(int index) {
+ return Integer.parseInt((String) elementAt(index));
+ }
+
+ /**
+ * Check the input string.
+ *
+ * @param string
+ * input string.
+ * @return true is a string is a value, false - otherwise.
+ */
+ protected boolean isInteger(String string) {
+ try {
+ Integer.parseInt(string);
+ return true;
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ }
+
+ /**
+ * Retrieve an element from the stack.true if the program should exit.
+ */
+ private static boolean processCommand(String command) {
+ String upper = command.toUpperCase();
+ if ("EXIT".equals(upper) || "E".equals(upper) || "QUIT".equals(upper) || "Q".equals(upper)) {
+ return true;
+ }
+ if ("+".equals(command) || "A".equals(upper) || "ADD".equals(upper)) {
+ _stack.add();
+ } else if ("-".equals(command) || "S".equals(upper) || "SUBTRACK".equals(upper)) {
+ _stack.subtract();
+ } else if ("*".equals(command) || "M".equals(upper) || "MULTIPLY".equals(upper)) {
+ _stack.multiply();
+ } else if ("/".equals(command) || "D".equals(upper) || "DIVIDE".equals(upper)) {
+ _stack.divide();
+ } else if ("P".equals(upper) || "POP".equals(upper)) {
+ _stack.pop();
+ } else if ("?".equals(upper) || "H".equals(upper) || "help".equals(upper)) {
+ displayMenu();
+ } else {
+ try {
+ int value = Integer.parseInt(command);
+ _stack.push(command);
+ } catch (NumberFormatException nfe) {
+ System.out.println("Error: Unknown command: " + command);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Program entry point.
+ *
+ * @param args
+ * Not used.
+ */
+ public static void main(String[] args) {
+
+ if ((args != null) && (args.length > 0)) {
+ autoMode(args);
+ return;
+ }
+
+ displayMenu();
+ boolean exit;
+ do {
+ System.out.println(getStack());
+ String command = nextCommand();
+ exit = processCommand(command);
+ } while (!exit);
+ }
+
+ private static void autoMode(String[] args)
+ {
+ if (!"-auto".equals(args[0])) {
+ System.err.println("Invalid option:" + args[0]);
+ printUsage();
+ return;
+ }
+
+ if (args.length <= 1) {
+ System.err.println("Please specify command(s) to execute");
+ printUsage();
+ return;
+ }
+
+ System.out.println("Starting Command Line Stack Machine in auto mode");
+
+ for (int i = 1; i < args.length; i++) {
+ String command = args[i];
+ System.out.println("Processing command " + command);
+ processCommand(command);
+ System.out.println(getStack());
+ }
+ System.out.println("Done - all commands executed");
+ }
+
+ static void printUsage()
+ {
+ System.out.println("");
+ System.out.println("Command Line Stack Machine");
+ System.out.println("");
+ System.out.println("usage: CommandLineStackMachine [OPTION]");
+ System.out.println("");
+ System.out.println(" -auto Pre comment: the String pushed should represent an
+ * integer.
+ *
+ * @param value
+ * to add to the stack.
+ */
+ public void push(String value);
+
+ /**
+ * Retrieve an element from the stack.Pre comment: 'pop()' can only be called if the stack is
+ * not empty.
+ */
+ public void pop();
+}
diff --git a/jtest_unit/Demo/src/main/java/examples/stackmachine/StackList.java b/jtest_unit/Demo/src/main/java/examples/stackmachine/StackList.java
new file mode 100644
index 0000000..6b6dcef
--- /dev/null
+++ b/jtest_unit/Demo/src/main/java/examples/stackmachine/StackList.java
@@ -0,0 +1,100 @@
+/*
+ * Created on Sep 10, 2003
+ */
+package examples.stackmachine;
+
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.Rectangle;
+
+import javax.swing.JList;
+import javax.swing.JViewport;
+
+public class StackList extends JList {
+
+ private final RunnableStackMachine machineGUI;
+
+ StackList(RunnableStackMachine machineGUI) {
+ updateModel(true);
+ this.machineGUI = machineGUI;
+ CustomListRenderer renderer = new CustomListRenderer();
+ renderer.setBackground(Color.yellow);
+ renderer.setForeground(Color.red);
+ renderer.setOpaque(true);
+ setCellRenderer(renderer);
+ }
+
+ void updateModel(boolean lifoModel) {
+ if (lifoModel) {
+ _currentStackModel = _lifoStackModel;
+ } else {
+ _currentStackModel = _fifoStackModel;
+ }
+ setModel(_currentStackModel);
+ }
+
+ void updateStackSizeLabel() {
+ this.machineGUI._stackSizeLabel.setText("Number of elements: " + _currentStackModel.size());
+ }
+
+ void push(String value) {
+ _currentStackModel.push(value);
+ updateStackSizeLabel();
+ adjustScroll();
+ }
+
+ void pop() {
+ _currentStackModel.pop();
+ updateStackSizeLabel();
+ adjustScroll();
+ }
+
+ void add() {
+ _currentStackModel.add();
+ updateStackSizeLabel();
+ adjustScroll();
+ }
+
+ void subtract() {
+ _currentStackModel.subtract();
+ updateStackSizeLabel();
+ adjustScroll();
+ }
+
+ void multiply() {
+ _currentStackModel.multiply();
+ updateStackSizeLabel();
+ adjustScroll();
+ }
+
+ void divide() {
+ _currentStackModel.divide();
+ updateStackSizeLabel();
+ adjustScroll();
+ }
+
+ void adjustScroll() {
+ JViewport viewport = this.machineGUI._scrollPane.getViewport();
+ viewport.setBackground(Color.white);
+ int list_size = _currentStackModel.getSize();
+ if (list_size == 0)
+ return;
+ Rectangle cell_bounds = getCellBounds(list_size - 1, list_size - 1);
+ int cell_height = cell_bounds.height;
+ int list_height = cell_height * list_size;
+ int list_component_height = this.machineGUI._scrollPane.getSize().height;
+ if (list_component_height > list_height) {
+ int position_y = -(list_component_height - list_height);
+ viewport.setViewPosition(new Point(0, position_y));
+ } else {
+ viewport.setViewPosition(new Point(0, 0));
+ }
+ viewport.repaint();
+ }
+
+ private AbstractStackMachine _currentStackModel = null;
+
+ private LifoStackMachine _lifoStackModel = new LifoStackMachine();
+
+ private FifoStackMachine _fifoStackModel = new FifoStackMachine();
+}
diff --git a/jtest_unit/Demo/src/main/java/examples/suppress/AllFileSuppress.java b/jtest_unit/Demo/src/main/java/examples/suppress/AllFileSuppress.java
new file mode 100644
index 0000000..b28ba79
--- /dev/null
+++ b/jtest_unit/Demo/src/main/java/examples/suppress/AllFileSuppress.java
@@ -0,0 +1,13 @@
+// parasoft-begin-suppress INTER.ITT
+package examples.suppress;
+
+public class AllFileSuppress {
+
+ public static void main(String[] args) {
+ String s1 = "line1";
+ String s2 = "line2";
+ System.out.println(s1);
+ System.out.println(s2);
+ }
+}
+// parasoft-end-suppress INTER.ITT
diff --git a/jtest_unit/Demo/src/main/java/examples/suppress/Example.java b/jtest_unit/Demo/src/main/java/examples/suppress/Example.java
new file mode 100644
index 0000000..79eec0b
--- /dev/null
+++ b/jtest_unit/Demo/src/main/java/examples/suppress/Example.java
@@ -0,0 +1,10 @@
+package examples.suppress;
+
+public class Example {
+
+ public int _field1;
+
+ public int _field2; // parasoft-suppress OOP.AF comment here
+
+ public int _field3;
+}
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_button.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_button.gif
new file mode 100644
index 0000000..4b6ae36
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_button.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_buttonp.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_buttonp.gif
new file mode 100644
index 0000000..1d1cfb8
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_buttonp.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_buttonr.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_buttonr.gif
new file mode 100644
index 0000000..cef3e15
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/add_buttonr.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_button.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_button.gif
new file mode 100644
index 0000000..751b144
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_button.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_buttonp.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_buttonp.gif
new file mode 100644
index 0000000..41bd050
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_buttonp.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_buttonr.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_buttonr.gif
new file mode 100644
index 0000000..f5a249a
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/divide_buttonr.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_button.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_button.gif
new file mode 100644
index 0000000..dc75dfe
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_button.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_buttonp.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_buttonp.gif
new file mode 100644
index 0000000..0c8d6d2
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_buttonp.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_buttonr.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_buttonr.gif
new file mode 100644
index 0000000..521add2
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/multiply_buttonr.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_button.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_button.gif
new file mode 100644
index 0000000..8d65f49
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_button.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_buttonp.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_buttonp.gif
new file mode 100644
index 0000000..812b8dd
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_buttonp.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_buttonr.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_buttonr.gif
new file mode 100644
index 0000000..b12c84e
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/pop_buttonr.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_button.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_button.gif
new file mode 100644
index 0000000..16288d4
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_button.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_buttonp.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_buttonp.gif
new file mode 100644
index 0000000..781b52c
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_buttonp.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_buttonr.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_buttonr.gif
new file mode 100644
index 0000000..d46ae09
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/push_buttonr.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_button.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_button.gif
new file mode 100644
index 0000000..e5becf3
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_button.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_buttonp.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_buttonp.gif
new file mode 100644
index 0000000..2ec2d79
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_buttonp.gif differ
diff --git a/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_buttonr.gif b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_buttonr.gif
new file mode 100644
index 0000000..082b20e
Binary files /dev/null and b/jtest_unit/Demo/src/main/resources/examples/stackmachine/img/subtract_buttonr.gif differ
diff --git a/jtest_unit/Demo/src/test/java/examples/junit/MoneyBagParameterizedTest.java b/jtest_unit/Demo/src/test/java/examples/junit/MoneyBagParameterizedTest.java
new file mode 100644
index 0000000..b9a099a
--- /dev/null
+++ b/jtest_unit/Demo/src/test/java/examples/junit/MoneyBagParameterizedTest.java
@@ -0,0 +1,75 @@
+package examples.junit;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.Arrays;
+import org.junit.Test;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+import org.junit.runner.RunWith;
+
+/**
+ * Parasoft Jtest UTA: Test class for MoneyBag
+ *
+ * @see examples.junit.MoneyBag
+ */
+@RunWith(Parameterized.class)
+public class MoneyBagParameterizedTest
+{
+ private int factor;
+ private int initialValue;
+
+ public MoneyBagParameterizedTest(int initialValue, int factor)
+ {
+ this.initialValue = initialValue;
+ this.factor = factor;
+ }
+
+ /**
+ * Parasoft Jtest UTA: Test for multiply(int)
+ *
+ * @see examples.junit.MoneyBag#multiply(int)
+ */
+ @Test
+ public void testMultiply()
+ throws Throwable
+ {
+ // given
+ MoneyBag underTest = new MoneyBag();
+ underTest.appendMoney(new Money(initialValue, "USD"));
+
+ MoneyBag expected = new MoneyBag();
+ expected.appendMoney(new Money(factor*initialValue, "USD"));
+
+ // when
+ IMoney result = underTest.multiply(factor);
+
+ // then
+ assertEquals(expected, result);
+ }
+
+ // Parasoft Jtest UTA: Initialize test parameters
+ @Parameters(name = "Run {index}: factor={0}")
+ public static Iterable