Skip to content

Commit d894923

Browse files
committed
IDCS automatizovane test + veci co je potreba smazat
Signed-off-by: David Kral <[email protected]>
1 parent 6e4e3c4 commit d894923

File tree

18 files changed

+1033
-3
lines changed

18 files changed

+1033
-3
lines changed

jersey/connector/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@
8383
<artifactId>helidon-config-yaml</artifactId>
8484
<scope>test</scope>
8585
</dependency>
86+
<dependency>
87+
<groupId>org.glassfish.jersey.core</groupId>
88+
<artifactId>jersey-server</artifactId>
89+
<scope>test</scope>
90+
</dependency>
91+
<dependency>
92+
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
93+
<artifactId>jersey-test-framework-provider-grizzly2</artifactId>
94+
<scope>test</scope>
95+
</dependency>
96+
<dependency>
97+
<groupId>org.glassfish.jersey.media</groupId>
98+
<artifactId>jersey-media-sse</artifactId>
99+
<scope>test</scope>
100+
</dependency>
101+
<dependency>
102+
<groupId>io.helidon.logging</groupId>
103+
<artifactId>helidon-logging-jul</artifactId>
104+
<scope>runtime</scope>
105+
</dependency>
86106
</dependencies>
87107

88108
<build>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Copyright (c) 2021, 2024 Oracle and/or its affiliates.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
# Example Logging Configuration File
18+
# For more information see $JAVA_HOME/jre/lib/logging.properties
19+
20+
# Send messages to the console
21+
handlers=io.helidon.logging.jul.HelidonConsoleHandler
22+
#
23+
## HelidonConsoleHandler uses a SimpleFormatter subclass that replaces "!thread!" with the current thread
24+
java.util.logging.SimpleFormatter.format=%1$tY.%1$tm.%1$td %1$tH:%1$tM:%1$tS %4$s %3$s !thread!: %5$s%6$s%n
25+
#
26+
## Global logging level. Can be overridden by specific loggers
27+
.level=INFO
28+
29+
# Component specific log levels
30+
io.helidon.webclient.level=FINEST
31+
#io.helidon.config.level=INFO
32+
#io.helidon.security.level=INFO
33+
#io.helidon.common.level=INFO
34+
#io.helidon.microprofile.metrics.MetricsCdiExtension.level=FINEST
35+
#io.helidon.microprofile.metrics.MetricsInterceptorBase.level=FINEST
36+
#org.jboss.weld.Bootstrap.level = FINEST
37+
#org.jboss.weld.Bean.level=FINEST
38+
#org.jboss.weld.Context.level=FINEST
39+
#org.jboss.weld.Utilties.level=FINEST

tests/functional/context-propagation/src/main/java/io/helidon/tests/functional/context/hello/HelloResource.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@
1616

1717
package io.helidon.tests.functional.context.hello;
1818

19+
import java.util.logging.Logger;
20+
1921
import io.helidon.webserver.http.ServerRequest;
2022

2123
import jakarta.inject.Inject;
2224
import jakarta.ws.rs.GET;
25+
import jakarta.ws.rs.POST;
2326
import jakarta.ws.rs.Path;
27+
import jakarta.ws.rs.container.AsyncResponse;
28+
import jakarta.ws.rs.container.Suspended;
2429
import org.eclipse.microprofile.faulttolerance.CircuitBreaker;
2530
import org.eclipse.microprofile.faulttolerance.Retry;
2631

@@ -93,4 +98,41 @@ public String getRemoteAddress() {
9398
ServerRequest serverRequest = supplier.get();
9499
return serverRequest.remotePeer().host();
95100
}
101+
102+
103+
private static final Logger LOGGER = Logger.getLogger(HelloResource.class.getName());
104+
105+
/**
106+
* Long-running asynchronous post.
107+
*
108+
* @param asyncResponse async response.
109+
* @param id post request id (received as request payload).
110+
*/
111+
@POST
112+
@Path("async")
113+
public void asyncPost(@Suspended final AsyncResponse asyncResponse, final String id) {
114+
System.out.println("PRDEEEEL - " + id);
115+
LOGGER.info("Long running post operation called with id " + id + " on thread " + Thread.currentThread().getName());
116+
new Thread(new Runnable() {
117+
118+
@Override
119+
public void run() {
120+
final String result = veryExpensiveOperation();
121+
asyncResponse.resume(result);
122+
}
123+
124+
private String veryExpensiveOperation() {
125+
// ... very expensive operation that typically finishes within 1 seconds, simulated using sleep()
126+
try {
127+
Thread.sleep(1000);
128+
return "DONE-" + id;
129+
} catch (final InterruptedException e) {
130+
Thread.currentThread().interrupt();
131+
return "INTERRUPTED-" + id;
132+
} finally {
133+
LOGGER.info("Long running post operation finished on thread " + Thread.currentThread().getName());
134+
}
135+
}
136+
}, "async-post-runner-" + id).start();
137+
}
96138
}

tests/functional/context-propagation/src/test/java/io/helidon/tests/functional/context/hello/HelloTest.java

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@
1616

1717
package io.helidon.tests.functional.context.hello;
1818

19+
import java.util.concurrent.Future;
20+
1921
import io.helidon.microprofile.testing.junit5.HelidonTest;
2022

2123
import jakarta.inject.Inject;
24+
import jakarta.ws.rs.client.Entity;
2225
import jakarta.ws.rs.client.WebTarget;
2326
import jakarta.ws.rs.core.Response;
2427
import org.junit.jupiter.api.Test;
2528

2629
import static org.hamcrest.CoreMatchers.is;
2730
import static org.hamcrest.MatcherAssert.assertThat;
31+
import static org.junit.jupiter.api.Assertions.assertEquals;
2832

2933
/**
3034
* Unit test for {@link HelloResource}.
@@ -66,4 +70,58 @@ private void assertOk(Response response, String expectedMessage) {
6670
assertThat(response.getStatus(), is(200));
6771
assertThat(response.readEntity(String.class), is(expectedMessage));
6872
}
73+
74+
@Test
75+
public void testAsyncPost() throws Exception {
76+
final Future<Response> warmUp1 = baseTarget.path("async").request().async().post(Entity.text("100"));
77+
final Future<Response> warmUp2 = baseTarget.path("async").request().async().post(Entity.text("200"));
78+
final Future<Response> warmUp3 = baseTarget.path("async").request().async().post(Entity.text("300"));
79+
// final Future<Response> warmUp4 = target(PATH).request().async().post(Entity.text("1"));
80+
// final Future<Response> warmUp5 = target(PATH).request().async().post(Entity.text("300"));
81+
// final Future<Response> warmUp6 = target(PATH).request().async().post(Entity.text("300"));
82+
// final Future<Response> warmUp7 = target(PATH).request().async().post(Entity.text("300"));
83+
84+
assertEquals("DONE-100", warmUp1.get().readEntity(String.class));
85+
assertEquals("DONE-200", warmUp2.get().readEntity(String.class));
86+
assertEquals("DONE-300", warmUp3.get().readEntity(String.class));
87+
// assertEquals("DONE-1", warmUp4.get().readEntity(String.class));
88+
// assertEquals("DONE-300", warmUp5.get().readEntity(String.class));
89+
// assertEquals("DONE-300", warmUp6.get().readEntity(String.class));
90+
// assertEquals("DONE-300", warmUp7.get().readEntity(String.class));
91+
final Future<Response> rf1 = baseTarget.path("async").request().async().post(Entity.text("1"));
92+
final Future<Response> rf2 = baseTarget.path("async").request().async().post(Entity.text("2"));
93+
final Future<Response> rf3 = baseTarget.path("async").request().async().post(Entity.text("3"));
94+
95+
96+
final String r1 = rf1.get().readEntity(String.class);
97+
final String r2 = rf2.get().readEntity(String.class);
98+
final String r3 = rf3.get().readEntity(String.class);
99+
100+
assertEquals("DONE-1", r1);
101+
assertEquals("DONE-2", r2);
102+
assertEquals("DONE-3", r3);
103+
//
104+
// final long tic = System.currentTimeMillis();
105+
//
106+
// // Submit requests asynchronously.
107+
// final Future<Response> rf1 = target(PATH).request().async().post(Entity.text("1"));
108+
// final Future<Response> rf2 = target(PATH).request().async().post(Entity.text("2"));
109+
// final Future<Response> rf3 = target(PATH).request().async().post(Entity.text("3"));
110+
//
111+
// // get() waits for the response
112+
// final String r1 = rf1.get().readEntity(String.class);
113+
// final String r2 = rf2.get().readEntity(String.class);
114+
// final String r3 = rf3.get().readEntity(String.class);
115+
//
116+
// final long toc = System.currentTimeMillis();
117+
//
118+
// assertEquals("DONE-1", r1);
119+
// assertEquals("DONE-2", r2);
120+
// assertEquals("DONE-3", r3);
121+
//
122+
// assertThat("Async processing took too long.", toc - tic, Matchers.lessThan(3 * AsyncResource.OPERATION_DURATION));
123+
}
124+
125+
126+
69127
}

tests/integration/idcs/pom.xml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright (c) 2023, 2024 Oracle and/or its affiliates.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
-->
17+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
22+
<parent>
23+
<groupId>io.helidon.tests.integration</groupId>
24+
<artifactId>helidon-tests-integration-project</artifactId>
25+
<version>4.2.0-SNAPSHOT</version>
26+
</parent>
27+
<modelVersion>4.0.0</modelVersion>
28+
29+
<name>Helidon Tests Integration IDCS</name>
30+
<artifactId>helidon-tests-integration-idcs</artifactId>
31+
32+
<dependencies>
33+
<dependency>
34+
<groupId>io.helidon.microprofile.bundles</groupId>
35+
<artifactId>helidon-microprofile</artifactId>
36+
</dependency>
37+
<dependency>
38+
<groupId>io.helidon.microprofile</groupId>
39+
<artifactId>helidon-microprofile-oidc</artifactId>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.glassfish.jersey.core</groupId>
43+
<artifactId>jersey-client</artifactId>
44+
</dependency>
45+
<dependency>
46+
<groupId>io.smallrye</groupId>
47+
<artifactId>jandex</artifactId>
48+
<scope>runtime</scope>
49+
<optional>true</optional>
50+
</dependency>
51+
<dependency>
52+
<groupId>org.junit.jupiter</groupId>
53+
<artifactId>junit-jupiter-api</artifactId>
54+
<scope>test</scope>
55+
</dependency>
56+
<dependency>
57+
<groupId>org.hamcrest</groupId>
58+
<artifactId>hamcrest-all</artifactId>
59+
<scope>test</scope>
60+
</dependency>
61+
<dependency>
62+
<groupId>io.helidon.microprofile.testing</groupId>
63+
<artifactId>helidon-microprofile-testing-junit5</artifactId>
64+
<scope>test</scope>
65+
</dependency>
66+
<dependency>
67+
<groupId>org.jsoup</groupId>
68+
<artifactId>jsoup</artifactId>
69+
<scope>test</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>io.helidon.jersey</groupId>
73+
<artifactId>helidon-jersey-connector</artifactId>
74+
<scope>test</scope>
75+
</dependency>
76+
<dependency>
77+
<groupId>io.helidon.security.providers</groupId>
78+
<artifactId>helidon-security-providers-idcs-mapper</artifactId>
79+
</dependency>
80+
<dependency>
81+
<groupId>org.seleniumhq.selenium</groupId>
82+
<artifactId>selenium-java</artifactId>
83+
<version>4.17.0</version>
84+
<scope>test</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>io.github.bonigarcia</groupId>
88+
<artifactId>webdrivermanager</artifactId>
89+
<version>5.6.3</version>
90+
<scope>test</scope>
91+
</dependency>
92+
</dependencies>
93+
94+
<build>
95+
<plugins>
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-failsafe-plugin</artifactId>
99+
<configuration>
100+
<reuseForks>false</reuseForks>
101+
<includes>
102+
<include>**/*IT.java</include>
103+
</includes>
104+
</configuration>
105+
<executions>
106+
<execution>
107+
<id>verify</id>
108+
<phase>verify</phase>
109+
<goals>
110+
<goal>integration-test</goal>
111+
<goal>verify</goal>
112+
</goals>
113+
</execution>
114+
</executions>
115+
</plugin>
116+
</plugins>
117+
</build>
118+
119+
</project>

0 commit comments

Comments
 (0)