Skip to content

Commit 721c452

Browse files
authored
Merge pull request #25440 from arjantijms/8.0
Merge remote-tracking branch 'origin/master' into 8.0
2 parents 5343777 + 244ec6c commit 721c452

File tree

13 files changed

+344
-54
lines changed

13 files changed

+344
-54
lines changed

appserver/tests/embedded/runnable/src/test/java/org/glassfish/tests/embedded/runnable/AddLibraryTest.java

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import java.util.Optional;
2020
import java.util.concurrent.TimeUnit;
2121
import java.util.logging.Logger;
22-
import java.util.stream.Stream;
2322

23+
import org.glassfish.tests.embedded.runnable.TestArgumentProviders.GfEmbeddedJarNameProvider;
2424
import org.glassfish.tests.embedded.runnable.app.App;
2525
import org.glassfish.tests.embedded.runnable.library.MockExecutorService;
2626
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -30,10 +30,7 @@
3030
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
3131
import org.jboss.shrinkwrap.api.spec.JavaArchive;
3232
import org.jboss.shrinkwrap.api.spec.WebArchive;
33-
import org.junit.jupiter.api.extension.ExtensionContext;
3433
import org.junit.jupiter.params.ParameterizedTest;
35-
import org.junit.jupiter.params.provider.Arguments;
36-
import org.junit.jupiter.params.provider.ArgumentsProvider;
3734
import org.junit.jupiter.params.provider.ArgumentsSource;
3835

3936
import static java.lang.System.err;
@@ -63,7 +60,6 @@ void testAddLibraryForApp(String gfEmbeddedJarName) throws Exception {
6360
warFile.getAbsolutePath()
6461
);
6562
assertTrue(outputToStreamOfLines(gfEmbeddedProcess)
66-
.peek(err::println)
6763
.filter(line -> line.contains("App initialized"))
6864
.findAny().isPresent(),
6965
"A log from deployed application is present");
@@ -100,18 +96,6 @@ void testAddLibraryForGrizzlyExecutor(String gfEmbeddedJarName) throws Exception
10096
}
10197
}
10298

103-
private static class GfEmbeddedJarNameProvider implements ArgumentsProvider {
104-
105-
@Override
106-
public Stream<? extends Arguments> provideArguments(ExtensionContext ec) throws Exception {
107-
return Stream.of(
108-
Arguments.of("glassfish-embedded-all.jar"),
109-
Arguments.of("glassfish-embedded-web.jar")
110-
);
111-
}
112-
113-
}
114-
11599
private File testLibraryJavaArchive(File jarFile) throws FileExistsException, ArchiveExportException, UnknownExtensionTypeException, IllegalArgumentException {
116100
String jarName = "testLibrary.jar";
117101
JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class, jarName)
@@ -132,4 +116,4 @@ private File warArchiveThatDependsOnTestLibrary(File warFile) throws FileExistsE
132116
return warFile;
133117
}
134118

135-
}
119+
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
package org.glassfish.tests.embedded.runnable;
17+
18+
import java.io.IOException;
19+
import java.nio.file.Files;
20+
import java.nio.file.Paths;
21+
import java.nio.file.StandardCopyOption;
22+
import java.util.List;
23+
import java.util.concurrent.TimeUnit;
24+
import java.util.concurrent.atomic.AtomicReference;
25+
import java.util.function.Predicate;
26+
import java.util.stream.Collectors;
27+
28+
import org.glassfish.tests.embedded.runnable.TestArgumentProviders.GfEmbeddedJarNameProvider;
29+
import org.junit.jupiter.api.BeforeEach;
30+
import org.junit.jupiter.api.TestInfo;
31+
import org.junit.jupiter.params.ParameterizedTest;
32+
import org.junit.jupiter.params.provider.ArgumentsSource;
33+
34+
import static org.glassfish.tests.embedded.runnable.GfEmbeddedUtils.outputToStreamOfLines;
35+
import static org.glassfish.tests.embedded.runnable.GfEmbeddedUtils.runGlassFishEmbedded;
36+
import static org.junit.jupiter.api.Assertions.assertTrue;
37+
38+
/**
39+
*
40+
* @author Ondro Mihalyi
41+
*/
42+
public class ConfigFileTest {
43+
44+
String propertiesFile;
45+
46+
@BeforeEach
47+
void init(TestInfo testInfo) throws IOException {
48+
propertiesFile = "glassfish-" + testInfo.getTestMethod().get().getName() + ".properties";
49+
Files.copy(getClass().getClassLoader().getResourceAsStream(testInfo.getTestClass().get().getSimpleName() + "/" + propertiesFile),
50+
Paths.get(propertiesFile),
51+
StandardCopyOption.REPLACE_EXISTING);
52+
53+
}
54+
55+
@ParameterizedTest
56+
@ArgumentsSource(GfEmbeddedJarNameProvider.class)
57+
void testExecuteCommandsInOrderDefinedInPropertiesFile(String gfEmbeddedJarName) throws Exception {
58+
Process gfEmbeddedProcess = runGlassFishEmbedded(gfEmbeddedJarName,
59+
"--properties=" + propertiesFile,
60+
"get server.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size"
61+
);
62+
assertTrue(outputToStreamOfLines(gfEmbeddedProcess)
63+
.filter(new TwoLineMatcher(
64+
line -> line.contains("Description: get"),
65+
line -> line.contains("server.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=200")
66+
))
67+
.findAny().isPresent(),
68+
"Message about max-thread-pool-size=200 set is found");
69+
gfEmbeddedProcess
70+
.waitFor(30, TimeUnit.SECONDS);
71+
}
72+
73+
@ParameterizedTest
74+
@ArgumentsSource(GfEmbeddedJarNameProvider.class)
75+
void testPropertyNamesVariants(String gfEmbeddedJarName) throws Exception {
76+
Process gfEmbeddedProcess = runGlassFishEmbedded(gfEmbeddedJarName,
77+
"--properties=" + propertiesFile,
78+
"get server.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size",
79+
"get resources.jdbc-connection-pool.DerbyPool.connection-leak-timeout-in-seconds",
80+
"get server.network-config.protocols.protocol.http-listener.http.max-connections",
81+
"get security-configurations.authorization-service.authorizationService.default"
82+
83+
);
84+
gfEmbeddedProcess
85+
.waitFor(30, TimeUnit.SECONDS);
86+
List<String> appliedPropertyLogs = outputToStreamOfLines(gfEmbeddedProcess)
87+
.filter(new TwoLineMatcher(
88+
line -> line.contains("Description: get"),
89+
line -> true
90+
))
91+
.collect(Collectors.toList());
92+
assertTrue(appliedPropertyLogs
93+
.get(0).contains("server.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=200"));
94+
assertTrue(appliedPropertyLogs
95+
.get(1).contains("resources.jdbc-connection-pool.DerbyPool.connection-leak-timeout-in-seconds=5"));
96+
assertTrue(appliedPropertyLogs
97+
.get(2).contains("server.network-config.protocols.protocol.http-listener.http.max-connections=10000"));
98+
assertTrue(appliedPropertyLogs
99+
.get(3).contains("security-configurations.authorization-service.authorizationService.default=false"));
100+
assertTrue(appliedPropertyLogs.size() == 4,"4 properties should be logged");
101+
}
102+
103+
private class TwoLineMatcher implements Predicate<String> {
104+
105+
AtomicReference<String> previousLine = new AtomicReference<>();
106+
Predicate<String> previousLinePredicate;
107+
Predicate<String> currentLinePredicate;
108+
109+
public TwoLineMatcher(Predicate<String> previousLinePredicate, Predicate<String> currentLinePredicate) {
110+
this.previousLinePredicate = previousLinePredicate;
111+
this.currentLinePredicate = currentLinePredicate;
112+
}
113+
114+
@Override
115+
public boolean test(String line) {
116+
boolean lineMatches = previousLine.get() != null
117+
&& previousLinePredicate.test(previousLine.get())
118+
&& currentLinePredicate.test(line);
119+
previousLine.set(line);
120+
return lineMatches;
121+
}
122+
}
123+
124+
}

appserver/tests/embedded/runnable/src/test/java/org/glassfish/tests/embedded/runnable/GfEmbeddedUtils.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,20 @@
2424
import java.util.List;
2525
import java.util.stream.Stream;
2626

27+
import static java.lang.System.err;
2728

2829
/**
2930
*
3031
* @author Ondro Mihalyi
3132
*/
3233
public class GfEmbeddedUtils {
34+
3335
public static Process runGlassFishEmbedded(String glassfishEmbeddedJarName, String... additionalArguments) throws IOException {
3436
List<String> arguments = new ArrayList<>();
3537
arguments.addAll(List.of(ProcessHandle.current().info().command().get(),
36-
"-jar", glassfishEmbeddedJarName,
37-
"--stop"));
38+
// "-Xrunjdwp:transport=dt_socket,server=y,suspend=y", // enable debugging on random port
39+
"-jar", glassfishEmbeddedJarName,
40+
"--stop"));
3841
for (String argument : additionalArguments) {
3942
arguments.add(argument);
4043
}
@@ -49,7 +52,9 @@ public static Stream<String> outputToStreamOfLines(Process gfEmbeddedProcess) {
4952
InputStream gfEmbeddedOutput = gfEmbeddedProcess.getErrorStream();
5053
return new BufferedReader(
5154
new InputStreamReader(gfEmbeddedOutput, StandardCharsets.UTF_8)
52-
).lines();
55+
)
56+
.lines()
57+
.peek(err::println);
5358
}
5459

5560
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Eclipse Public License v. 2.0, which is available at
6+
* http://www.eclipse.org/legal/epl-2.0.
7+
*
8+
* This Source Code may also be made available under the following Secondary
9+
* Licenses when the conditions for such availability set forth in the
10+
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11+
* version 2 with the GNU Classpath Exception, which is available at
12+
* https://www.gnu.org/software/classpath/license.html.
13+
*
14+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15+
*/
16+
package org.glassfish.tests.embedded.runnable;
17+
18+
import java.util.stream.Stream;
19+
20+
import org.junit.jupiter.api.extension.ExtensionContext;
21+
import org.junit.jupiter.params.provider.Arguments;
22+
import org.junit.jupiter.params.provider.ArgumentsProvider;
23+
24+
/**
25+
*
26+
* @author Ondro Mihalyi
27+
*/
28+
public class TestArgumentProviders {
29+
30+
public static class GfEmbeddedJarNameProvider implements ArgumentsProvider {
31+
32+
@Override
33+
public Stream<? extends Arguments> provideArguments(ExtensionContext ec) throws Exception {
34+
return Stream.of(Arguments.of("glassfish-embedded-all.jar"), Arguments.of("glassfish-embedded-web.jar"));
35+
}
36+
37+
}
38+
39+
/**
40+
* For testing a single execution when debugging
41+
*/
42+
public static class SingleGfEmbeddedJarNameProvider implements ArgumentsProvider {
43+
44+
@Override
45+
public Stream<? extends Arguments> provideArguments(ExtensionContext ec) throws Exception {
46+
return Stream.of(Arguments.of("glassfish-embedded-all.jar"));
47+
}
48+
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
2+
#
3+
# This program and the accompanying materials are made available under the
4+
# terms of the Eclipse Public License v. 2.0, which is available at
5+
# http://www.eclipse.org/legal/epl-2.0.
6+
#
7+
# This Source Code may also be made available under the following Secondary
8+
# Licenses when the conditions for such availability set forth in the
9+
# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
10+
# version 2 with the GNU Classpath Exception, which is available at
11+
# https://www.gnu.org/software/classpath/license.html.
12+
#
13+
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14+
15+
command.pool-sizeY=set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=100
16+
command.pool-sizeX=set configs.config.server-config.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=200
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
2+
#
3+
# This program and the accompanying materials are made available under the
4+
# terms of the Eclipse Public License v. 2.0, which is available at
5+
# http://www.eclipse.org/legal/epl-2.0.
6+
#
7+
# This Source Code may also be made available under the following Secondary
8+
# Licenses when the conditions for such availability set forth in the
9+
# Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
10+
# version 2 with the GNU Classpath Exception, which is available at
11+
# https://www.gnu.org/software/classpath/license.html.
12+
#
13+
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
14+
15+
server.thread-pools.thread-pool.http-thread-pool.max-thread-pool-size=200
16+
resources.jdbc-connection-pool.DerbyPool.connection-leak-timeout-in-seconds=5
17+
embedded-glassfish-config.configs.config.server-config.network-config.protocols.protocol.http-listener.http.max-connections=10000
18+
embedded-glassfish-config.security-configurations.authorization-service.authorizationService.default=false

docs/embedded-server-guide/src/main/asciidoc/embedded-server-guide.adoc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ java -jar glassfish-embedded-all.jar [--properties=FILE]
283283
Load properties from a file. This option can be repeated to
284284
load properties from multiple files. The propertes in the file can be
285285
any of the following:
286-
- Any properties supported by Embedded ${productName}.
286+
287+
- Any properties supported by Embedded ${productName}. See xref:#supported-properties[Configuration properties supported by Embedded {productName}].
287288
- Any command line options with the name of the option as the key,
288289
without the initial hyphens, and the value of the option as the value.
289290
- Keys that start with the "command." prefix, followed by any text.
@@ -333,7 +334,7 @@ port 8080.
333334

334335
Files and directories in this directory will be deployed as
335336
applications (in random order), as if they were specified on the command
336-
line.
337+
line. The default directory name is 'autodeploy'.
337338

338339
`--logLevel=LEVEL`
339340

@@ -357,6 +358,10 @@ startup optimizations - to start the server, get it to a ready state
357358
(applications deployed, etc.), and then shut down cleanly, so that the
358359
JVM can store the cached data.
359360

361+
`--prompt`
362+
363+
Run interactive prompt that allows running admin commands. This is useful in development to manipulate a running GlassFish instance. After exiting the prompt, the server shuts down.
364+
360365
`--help`
361366

362367
Print help information
@@ -558,11 +563,17 @@ import org.glassfish.embeddable.*;
558563
// ...
559564
----
560565

561-
[[running-an-embedded-glassfish-server]]
566+
[[supported-properties]]
567+
==== Configuration properties supported by Embedded {productName}
562568

563-
==== Running an Embedded {productName}
569+
In `GlassFishProperties` and in a properties file, Embedded {productName} supports the same configuration properties as the `set` and `get` administration commands of the {productName} Server.
570+
571+
In addition, it also accepts properties with the `embedded-glassfish-config.` prefix. This prefix is removed before applying the property (e.g., `resources.jdbc-connection-pool...` can be defined as `embedded-glassfish-config.resources.jdbc-connection-pool...`). This prefix is no longer necessary and its usage is deprecated, but it's supported for backwards compatibility.
572+
573+
[[running-an-embedded-glassfish-server]]
574+
==== Running Embedded {productName} from a Java application
564575

565-
After you create an embedded {productName} as described in
576+
After you create an embedded {productName} server as described in
566577
xref:#creating-and-configuring-an-embedded-glassfish-server[Creating and Configuring an Embedded {productName}], you
567578
can perform operations such as:
568579

@@ -1322,7 +1333,7 @@ Add the following `configuration` element to your POM file:
13221333
</bootstrapProperties>
13231334
<bootstrapPropertiesFile>bootstrap.properties</bootstrapPropertiesFile>
13241335
<glassfishProperties>
1325-
<property>embedded-glassfish-config.server.jms-service.jms-host.default_JMS_host.port=17676</property>
1336+
<property>server.jms-service.jms-host.default_JMS_host.port=17676</property>
13261337
</glassfishProperties>
13271338
<glassfishPropertiesFile>glassfish.properties</glassfishPropertiesFile>
13281339
<systemProperties>

0 commit comments

Comments
 (0)