Skip to content

Commit

Permalink
Merge branch 'apache:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
dgetzlaf authored Sep 9, 2024
2 parents 2f2be38 + 3e9af5d commit c0dd06c
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 61 deletions.
2 changes: 1 addition & 1 deletion bin/log4j2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
~ limitations under the License.
-->

<Configuration status="WARN" packages="org.apache.jmeter.gui.logging">
<Configuration status="WARN">

<Appenders>
<!-- Uncomment to set rotating logs up to 5 files of 100 MB-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ tasks.withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
filePermissions {
unix("rw-r--r--")
}
dirPermissions {
unix("rwxr-xr-x")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,21 @@ java {
withSourcesJar()
}

val archivesBaseName = when (name) {
// We maintain the file names for backward compatibility
val archiveName = when (name) {
"jorphan", "bshclient" -> name
"launcher" -> "ApacheJMeter"
else -> "ApacheJMeter_$name"
}
setProperty("archivesBaseName", archivesBaseName)

base {
archivesName = archiveName
}

publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = archivesBaseName
artifactId = archiveName
from(components["java"])
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ plugins {
id("build-logic.publish-to-central")
}

val archivesBaseName = "ApacheJMeter_$name"
setProperty("archivesBaseName", archivesBaseName)
val archiveName = "ApacheJMeter_$name"

base {
archivesName = archiveName
}

publishing {
publications {
create<MavenPublication>("mavenJavaPlatform") {
artifactId = archivesBaseName
artifactId = archiveName
from(components["javaPlatform"])
}
}
Expand Down
5 changes: 5 additions & 0 deletions build-logic/root-build/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ plugins {
}

dependencies {
constraints {
api("xerces:xercesImpl:2.12.1") {
because("Some of the plugins might depend on an older version, and we want using a more recent one")
}
}
api(projects.buildParameters)
api(projects.verification)
api("com.github.vlsi.crlf:com.github.vlsi.crlf.gradle.plugin:1.90")
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
17 changes: 17 additions & 0 deletions src/core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.github.autostyle.gradle.AutostyleTask
import com.github.vlsi.gradle.ide.IdeExtension
import java.util.jar.JarFile

plugins {
id("java-test-fixtures")
Expand Down Expand Up @@ -45,6 +46,9 @@ dependencies {
api("org.apache.logging.log4j:log4j-core") {
because("GuiLogEventAppender is using log4j-core to implement GUI-based log appender")
}
kapt("org.apache.logging.log4j:log4j-core") {
because("Generates a plugin cache file for GuiLogEventAppender")
}
api("org.apache.logging.log4j:log4j-slf4j-impl") {
because("Both log4j and slf4j are included, so it makes sense to just add log4j->slf4j bridge as well")
}
Expand Down Expand Up @@ -188,3 +192,16 @@ tasks.jar {
from("$rootDir/xdocs/images/logo.svg")
}
}

// Checks the generated JAR for a Log4j plugin cache file.
tasks.jar {
doLast {
val jarFile = archiveFile.get().asFile
JarFile(jarFile).use { jar ->
val entryName = "META-INF/org/apache/logging/log4j/core/config/plugins/Log4j2Plugins.dat"
if (jar.getJarEntry(entryName) == null) {
throw IllegalStateException("$entryName was not found in $jarFile. The entry should be generated by log4j-core annotation processor")
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;

import javax.swing.ImageIcon;
Expand All @@ -40,7 +38,6 @@
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;

import org.apache.jmeter.gui.action.ActionNames;
import org.apache.jmeter.gui.action.HtmlReportGenerator;
import org.apache.jmeter.gui.util.EscapeDialog;
import org.apache.jmeter.gui.util.JMeterToolBar;
Expand All @@ -52,7 +49,6 @@
import org.slf4j.LoggerFactory;

public class HtmlReportUI implements ActionListener {
private static final Set<String> commands = new HashSet<>();
private static final Logger LOGGER = LoggerFactory.getLogger(HtmlReportUI.class);

private static final String CREATE_REQUEST = "CREATE_REQUEST";
Expand Down Expand Up @@ -82,11 +78,6 @@ public class HtmlReportUI implements ActionListener {
private final ImageIcon inErrorIcon = JMeterUtils.getImage(IMAGES_PREFIX + iconSize +"/dialog-error-5.png");// $NON-NLS-1$
private final ImageIcon completedIcon = JMeterUtils.getImage(IMAGES_PREFIX + iconSize +"/task-complete.png");// $NON-NLS-1$


static {
commands.add(ActionNames.HTML_REPORT);
}

public HtmlReportUI() {
super();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import java.io.IOException;
import java.io.Serializable;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.jmeter.NewDriver;
Expand All @@ -43,8 +41,6 @@ public class TestPlan extends AbstractTestElement implements Serializable, TestS

private static final String BASEDIR = "basedir";

private transient List<AbstractThreadGroup> threadGroups = new ArrayList<>();

// There's only 1 test plan, so can cache the mode here
private static volatile boolean functionalMode = false;

Expand All @@ -68,7 +64,6 @@ public TestPlanSchema getSchema() {

// create transient item
protected Object readResolve(){
threadGroups = new ArrayList<>();
return this;
}

Expand Down Expand Up @@ -213,7 +208,6 @@ public void addTestElement(TestElement tg) {
* the feature to be added to the AbstractThreadGroup attribute
*/
public void addThreadGroup(AbstractThreadGroup group) {
threadGroups.add(group);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ public AbstractProperty clone() {
@Override
public int getIntValue() {
String val = getStringValue();
if (val == null || val.length()==0) {
if (val == null || val.isEmpty()) {
return 0;
}
try {
return Integer.parseInt(val);
return Integer.parseInt(val.trim());
} catch (NumberFormatException e) {
return 0;
}
Expand All @@ -126,11 +126,11 @@ public int getIntValue() {
@Override
public long getLongValue() {
String val = getStringValue();
if (val == null || val.length()==0) {
if (val == null || val.isEmpty()) {
return 0;
}
try {
return Long.parseLong(val);
return Long.parseLong(val.trim());
} catch (NumberFormatException e) {
return 0;
}
Expand All @@ -144,11 +144,11 @@ public long getLongValue() {
@Override
public double getDoubleValue() {
String val = getStringValue();
if (val == null || val.length()==0) {
if (val == null || val.isEmpty()) {
return 0;
}
try {
return Double.parseDouble(val);
return Double.parseDouble(val.trim());
} catch (NumberFormatException e) {
log.error("Tried to parse a non-number string to an integer", e);
return 0;
Expand All @@ -163,11 +163,11 @@ public double getDoubleValue() {
@Override
public float getFloatValue() {
String val = getStringValue();
if (val == null || val.length()==0) {
if (val == null || val.isEmpty()) {
return 0;
}
try {
return Float.parseFloat(val);
return Float.parseFloat(val.trim());
} catch (NumberFormatException e) {
log.error("Tried to parse a non-number string to an integer", e);
return 0;
Expand All @@ -182,10 +182,10 @@ public float getFloatValue() {
@Override
public boolean getBooleanValue() {
String val = getStringValue();
if (val == null || val.length()==0) {
if (val == null || val.isEmpty()) {
return false;
}
return Boolean.parseBoolean(val);
return Boolean.parseBoolean(val.trim());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to you 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.
*/

package org.apache.jmeter.threads

import org.apache.jmeter.control.LoopController
import org.apache.jmeter.junit.JMeterTestCase
import org.apache.jmeter.test.assertions.executePlanAndCollectEvents
import org.apache.jmeter.test.samplers.ThreadSleep
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Test
import kotlin.time.Duration.Companion.seconds

class ThreadGroupTest : JMeterTestCase() {
@Test
fun `threadNum with trailing whitespace`() {
val events = executePlanAndCollectEvents(10.seconds) {
ThreadGroup::class {
props {
it[numThreads] = "1 "
}
rampUp = 0
scheduler = true
delay = 0
duration = 1
setSamplerController(
LoopController().apply {
loops = 1
setContinueForever(false)
}
)

ThreadSleep::class {
duration = 0.seconds
}
}
}
assertEquals(1, events.size) {
"ThreadGroup.threadNum has trailing whitespace, it should be trimmed, so one event should be generated. " +
"Actual events are $events"
}
}
}
Loading

0 comments on commit c0dd06c

Please sign in to comment.