Skip to content

Commit fba19ef

Browse files
committed
[#9684] Add pinpoint-agent-testweb-commons module
1 parent d5c560f commit fba19ef

File tree

17 files changed

+151
-241
lines changed

17 files changed

+151
-241
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2023 NAVER Corp.
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" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<parent>
22+
<groupId>com.navercorp.pinpoint</groupId>
23+
<artifactId>pinpoint-agent-testweb</artifactId>
24+
<version>2.5.1-SNAPSHOT</version>
25+
</parent>
26+
<artifactId>pinpoint-agent-testweb-commons</artifactId>
27+
<packaging>jar</packaging>
28+
29+
<properties>
30+
<encoding>UTF-8</encoding>
31+
<jdk.version>1.8</jdk.version>
32+
<jdk.home>${env.JAVA_8_HOME}</jdk.home>
33+
<spring-boot-build-skip>true</spring-boot-build-skip>
34+
35+
<j2html.version>1.6.0</j2html.version>
36+
</properties>
37+
38+
<dependencies>
39+
<dependency>
40+
<groupId>com.j2html</groupId>
41+
<artifactId>j2html</artifactId>
42+
<version>${j2html.version}</version>
43+
</dependency>
44+
</dependencies>
45+
46+
<build>
47+
<plugins>
48+
49+
</plugins>
50+
</build>
51+
52+
</project>

agent-testweb/vertx-3-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ApiLinkPage.java renamed to agent-testweb/agent-testweb-commons/src/main/java/com.pinpoint.test.common/view/ApiLinkPage.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package com.pinpoint.test.plugin;
1+
package com.pinpoint.test.common.view;
22

3-
import io.vertx.ext.web.Route;
43
import j2html.tags.specialized.ATag;
54
import j2html.tags.specialized.HtmlTag;
65

6+
import java.util.ArrayList;
77
import java.util.List;
88
import java.util.Objects;
99
import java.util.stream.Collectors;
@@ -22,26 +22,28 @@
2222
*/
2323
public class ApiLinkPage {
2424
private final String title;
25+
private List<ATag> aTags = new ArrayList<>();
2526

2627
public ApiLinkPage(String title) {
2728
this.title = Objects.requireNonNull(title, "title");
2829
}
2930

30-
public String buildRoute(List<Route> routes) {
31-
List<ATag> collect = routes.stream()
31+
public ApiLinkPage addHrefTag(List<HrefTag> hrefTags) {
32+
List<ATag> collect = hrefTags.stream()
3233
.map(this::aTag)
3334
.collect(Collectors.toList());
34-
return buildHtml(collect);
35+
this.aTags.addAll(collect);
36+
return this;
3537
}
3638

37-
private ATag aTag(Route route) {
39+
private ATag aTag(HrefTag hrefTag) {
3840
return a()
39-
.withText(route.getPath())
40-
.withHref(route.getPath())
41+
.withText(hrefTag.getText())
42+
.withHref(hrefTag.getPath())
4143
.withTarget("_blank");
4244
}
4345

44-
public String buildHtml(List<ATag> aTags) {
46+
public String build() {
4547

4648
HtmlTag html = html(
4749
head(title(title)),
@@ -52,4 +54,5 @@ public String buildHtml(List<ATag> aTags) {
5254
);
5355
return html.render();
5456
}
57+
5558
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.pinpoint.test.common.view;
2+
3+
public class HrefTag {
4+
private final String text;
5+
private final String path;
6+
7+
public static HrefTag of(String path) {
8+
return new HrefTag(path, path);
9+
}
10+
11+
public static HrefTag of(String text, String path) {
12+
return new HrefTag(text, path);
13+
}
14+
15+
HrefTag(String text, String path) {
16+
this.text = text;
17+
this.path = path;
18+
}
19+
20+
public String getText() {
21+
return text;
22+
}
23+
24+
public String getPath() {
25+
return path;
26+
}
27+
}

agent-testweb/bom/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
<apache.dubbo.version>2.7.2</apache.dubbo.version>
3939
<ehcache.version>2.10.6</ehcache.version>
4040
<undertow.version>2.2.17.Final</undertow.version>
41-
<j2html.version>1.6.0</j2html.version>
4241
</properties>
4342

4443
<dependencyManagement>
@@ -69,11 +68,6 @@
6968
<artifactId>springdoc-openapi-ui</artifactId>
7069
<version>1.4.4</version>
7170
</dependency>
72-
<dependency>
73-
<groupId>com.j2html</groupId>
74-
<artifactId>j2html</artifactId>
75-
<version>${j2html.version}</version>
76-
</dependency>
7771
</dependencies>
7872
</dependencyManagement>
7973
</project>

agent-testweb/mongodb-reactive-plugin-testweb/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
</dependency>
4242

4343
<dependency>
44-
<groupId>com.j2html</groupId>
45-
<artifactId>j2html</artifactId>
44+
<groupId>com.navercorp.pinpoint</groupId>
45+
<artifactId>pinpoint-agent-testweb-commons</artifactId>
4646
</dependency>
4747

4848
<dependency>

agent-testweb/mongodb-reactive-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ApiLinkPage.java

Lines changed: 0 additions & 70 deletions
This file was deleted.

agent-testweb/mongodb-reactive-plugin-testweb/src/main/java/com/pinpoint/test/plugin/MongoReactivePluginController.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import com.mongodb.client.result.InsertOneResult;
2121
import com.mongodb.reactivestreams.client.MongoCollection;
2222
import com.mongodb.reactivestreams.client.MongoDatabase;
23+
import com.pinpoint.test.common.view.ApiLinkPage;
24+
import com.pinpoint.test.common.view.HrefTag;
2325
import org.apache.logging.log4j.LogManager;
2426
import org.apache.logging.log4j.Logger;
2527
import org.bson.Document;
@@ -67,14 +69,16 @@ public MongoReactivePluginController(RequestMappingHandlerMapping handlerMapping
6769
@GetMapping("/")
6870
String welcome() {
6971
Map<RequestMappingInfo, HandlerMethod> handlerMethods = this.handlerMapping.getHandlerMethods();
70-
List<String> list = new ArrayList<>();
72+
List<HrefTag> list = new ArrayList<>();
7173
for (RequestMappingInfo info : handlerMethods.keySet()) {
7274
for (String path : info.getDirectPaths()) {
73-
list.add(path);
75+
list.add(HrefTag.of(path));
7476
}
7577
}
76-
list.sort(String::compareTo);
77-
return new ApiLinkPage("mongodb-reactive-plugin-testweb").build(list);
78+
list.sort(Comparator.comparing(HrefTag::getPath));
79+
return new ApiLinkPage("mongodb-reactive-plugin-testweb")
80+
.addHrefTag(list)
81+
.build();
7882
}
7983

8084
@GetMapping(value = "/insertOne")

agent-testweb/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151

5252
<modules>
5353
<module>bom</module>
54+
<module>agent-testweb-commons</module>
5455
<module>agentsdk-async-testweb</module>
5556
<module>thread-plugin-testweb</module>
5657
<module>paho-mqtt-plugin-testweb</module>
@@ -89,6 +90,11 @@
8990
<type>pom</type>
9091
<scope>import</scope>
9192
</dependency>
93+
<dependency>
94+
<groupId>com.navercorp.pinpoint</groupId>
95+
<artifactId>pinpoint-agent-testweb-commons</artifactId>
96+
<version>${project.version}</version>
97+
</dependency>
9298
</dependencies>
9399
</dependencyManagement>
94100

agent-testweb/redis-lettuce-plugin-testweb/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
</dependency>
4040

4141
<dependency>
42-
<groupId>com.j2html</groupId>
43-
<artifactId>j2html</artifactId>
42+
<groupId>com.navercorp.pinpoint</groupId>
43+
<artifactId>pinpoint-agent-testweb-commons</artifactId>
4444
</dependency>
4545
</dependencies>
4646

agent-testweb/redis-lettuce-plugin-testweb/src/main/java/com/pinpoint/test/plugin/ApiLinkPage.java

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)