From 0bdfab5c61cf338bcf2388e416eb974a519272af Mon Sep 17 00:00:00 2001 From: anuram Date: Tue, 19 Sep 2023 16:34:58 -0400 Subject: [PATCH 1/5] adding WsWsocServerContainerDeprecationRecipe --- .gitignore | 3 +- .../classpath/WsWsocServerContainer_test.jar | Bin 0 -> 3539 bytes .../META-INF/rewrite/jakarta-ee-10.yml | 39 +++++++++ .../WsWsocServerContainerDeprecationTest.java | 79 ++++++++++++++++++ 4 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar create mode 100644 src/main/resources/META-INF/rewrite/jakarta-ee-10.yml create mode 100644 src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java diff --git a/.gitignore b/.gitignore index 0f645db17d..9e5f15aa2a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ out/ .classpath .project .settings/ -bin/ \ No newline at end of file +.DS_Store +bin/ diff --git a/src/main/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar b/src/main/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar new file mode 100644 index 0000000000000000000000000000000000000000..4f275d56cce21a7bafa869980a57ad28dc653991 GIT binary patch literal 3539 zcmb7G2V7J477m1lfb69RDoao-A%KDdWQHLEVORDrj1WlJX=TVBva6J-AR7Sz3&`G3 zrcA*gds7Hn2%Pep$8q2npvD%qz1q> zX~E_G)Oa3JDsIvN|MvqlosU0&m2}n_eb*C(5OZ{~Lqlv)*6!{%2ox3j5M#IkUF%&2w2ozBdve2_}MFN39K_CNE0ve>j1v26j>u3UT zA@0sNSSgT~OAG!uI^}zxw74wNakTue@sT8*wM9FNJK8vldn0VzF%Aefgt)gm+E(1y z-I(;Dk8txsxGAGuJggmE5N==U>(kTH;ZS7pZHLsZM+WBS@5W=hjVuz;l!;Pm}Nz;#rdK^PhZO>4~i;oBH z4670um7G2fN@v#JVKO`?wrwX7&14OkUH^q3q`wp0OAq@&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?@R72neO%A&h{aNr9!Jd3@MxI$5#hf_|vDf5(4~s_8B}66uqtT zL$1q|?Pc)(Hp~;`zid(p90Gpeyzo>$8WrM|CM#&Uw%3%k*4_RB2$d(c1^MJ~4%jedV86>)qq^QBkTSkauPzAdReLocaO$L7Cl{e%S93*D{9^07 zZvFawMlu6rzc-u6CGCDBkdgsRF2@=0{UHOqtg(l?jw0>8gNFx3T%Ghr-ha{`dI)z6 z+Ql95MLp5l&Dt$+mb9Fl(MYAMt^}KbpiQ6xL^xPEi;e~V9080SN&J<$1??*Eeuj2e zH`KR1i`M(+H|bsLb`AbF8v%70>`xW3<16(y^CNqFJB*5pCkrE*)&*`?(Ng-(rG42(96|jf`McHW-NPSHeIZ;W>o_!3J#sZ%T<$VEsJI%-0U^3@oT6| z&H3HuD-#t3;Lp4Mj-X%%qxJ5GogL{P_TS0Y8ovxv3A&V!s2-RJHFVGT=+QE&n+OtU z&ft=J3$BEKlB))Euy&7hW9d}4Vp=9aXAML-#W z@#O&AlKb^}>Mg2UOO+2?uQ2dAYj>$t+l)KZ2~RIwi)^TNn(3!8u8|Ptu>`|IoayUM z;uLUKq!;Pat=Lny?q7P#2t}#sTzPPwN2iOKpQD8;#!fBxe9g+idd}vcd;g|M=a`I3 z!@EO`#Zq~%c9Kf-|DVOvlZ!vJT^MT*2hZ5%TR;hx&{var;A)vN5jj+4c#%~z{l=PM zc~@z)ortF7o%M;@OI)UzRX(#s`z7%)%X)jkwgqa@1~!>AsuZg;UXhK`u{}2$N+O4_ z=|dT-aLxzvfNbpDCrrh2!hH5yd2{?;)KT8b)bFh|u<3)mxe+!mo=u;#sO`_(wTzwESX<{+o{%pGWc!$E_|@GTDDXX&L$e$*kChL)Kc60?CD9bN~PV literal 0 HcmV?d00001 diff --git a/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml b/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml new file mode 100644 index 0000000000..76abf080e4 --- /dev/null +++ b/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml @@ -0,0 +1,39 @@ +# +# Copyright 2023 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 +#

+# https://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. +# +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.migrate.jakarta +displayName: Migrate to Jakarta EE 10 +description: Jakarta EE 10 TBD -add description +tags: + - jakarta +recipeList: + - org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation +--- +type: specs.openrewrite.org/v1beta/recipe +name: org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation +displayName: Use `upgradeHttpToWebSocket` +description: > + This method `doUpgrade()` is deprecated. It is replaced by the new Jakarta WebSocket 2.1 specification upgradeHttpToWebSocket() +recipeList: + - org.openrewrite.java.ChangeMethodName: + methodPattern: com.ibm.websphere.wsoc.WsWsocServerContainer doUpgrade(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, com.ibm.websphere.wsoc.ServerEndpointConfig, java.util.Map) + newMethodName: upgradeHttpToWebSocket + ignoreDefinition: false + - org.openrewrite.java.ChangeType: + oldFullyQualifiedTypeName: com.ibm.websphere.wsoc.WsWsocServerContainer + newFullyQualifiedTypeName: jakarta.websocket.server.ServerContainer + ignoreDefinition: true diff --git a/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java b/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java new file mode 100644 index 0000000000..b7c82372eb --- /dev/null +++ b/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java @@ -0,0 +1,79 @@ +/* + * Copyright 2023 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 + *

+ * https://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.openrewrite.java.migrate.jakarta; + +import org.junit.jupiter.api.Test; +import org.openrewrite.InMemoryExecutionContext; +import org.openrewrite.config.Environment; +import org.openrewrite.java.JavaParser; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import static org.openrewrite.java.Assertions.java; + +class WsWsocServerContainerDeprecationTest implements RewriteTest { + + @Override + public void defaults(RecipeSpec spec) { + spec.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "WsWsocServerContainer_test")).recipe(Environment.builder().scanRuntimeClasspath("org.openrewrite.java.migrate.jakarta.").build().activateRecipes("org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation")); + } + + @Test + void deprecateWsWsocServerContainer() { + rewriteRun( + //language=java + java(""" + package com.ibm; + + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; + + import com.ibm.websphere.wsoc.ServerEndpointConfig; + import com.ibm.websphere.wsoc.WsWsocServerContainer; + + public class Test { + + void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map map){ + WsWsocServerContainer.doUpgrade(req,res,sConfig,map); + } + void doY(){ + String x = "test"; + x.toUpperCase(); + } + } + """, """ + package com.ibm; + + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; + + import com.ibm.websphere.wsoc.ServerEndpointConfig; + import jakarta.websocket.server.ServerContainer; + + public class Test { + + void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map map){ + ServerContainer.upgradeHttpToWebSocket(req,res,sConfig,map); + } + void doY(){ + String x = "test"; + x.toUpperCase(); + } + } + """)); + } + +} From 126ebc93a32d01be7e7c0997c55b9bab274cad2e Mon Sep 17 00:00:00 2001 From: anuram Date: Tue, 19 Sep 2023 16:46:23 -0400 Subject: [PATCH 2/5] adding description --- src/main/resources/META-INF/rewrite/jakarta-ee-10.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml b/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml index 76abf080e4..1361642f52 100644 --- a/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml +++ b/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml @@ -17,7 +17,7 @@ type: specs.openrewrite.org/v1beta/recipe name: org.openrewrite.java.migrate.jakarta displayName: Migrate to Jakarta EE 10 -description: Jakarta EE 10 TBD -add description +description: These recipes help with the Migration to Jakarta EE 10, flagging and updating deprecated methods. tags: - jakarta recipeList: From 8b3f7b668afae176ae8c85349d729ebb3cbbd47f Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 21 Sep 2023 13:18:11 +0200 Subject: [PATCH 3/5] Slight polish: move jar to tests; update name & description --- .../META-INF/rewrite/jakarta-ee-10.yml | 5 +- .../WsWsocServerContainerDeprecationTest.java | 61 +++++++----------- .../classpath/WsWsocServerContainer_test.jar | Bin 3 files changed, 27 insertions(+), 39 deletions(-) rename src/{main => test}/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar (100%) diff --git a/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml b/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml index 1361642f52..9b295d4b93 100644 --- a/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml +++ b/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml @@ -25,9 +25,8 @@ recipeList: --- type: specs.openrewrite.org/v1beta/recipe name: org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation -displayName: Use `upgradeHttpToWebSocket` -description: > - This method `doUpgrade()` is deprecated. It is replaced by the new Jakarta WebSocket 2.1 specification upgradeHttpToWebSocket() +displayName: Replace `doUpgrade(..)` with `ServerContainer.upgradeHttpToWebSocket(..)` +description: `WsWsocServerContainer.doUpgrade(..)` is deprecated. It is replaced by the new Jakarta WebSocket 2.1 specification `ServerContainer.upgradeHttpToWebSocket(..)`. recipeList: - org.openrewrite.java.ChangeMethodName: methodPattern: com.ibm.websphere.wsoc.WsWsocServerContainer doUpgrade(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, com.ibm.websphere.wsoc.ServerEndpointConfig, java.util.Map) diff --git a/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java b/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java index b7c82372eb..66c76ee264 100644 --- a/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java +++ b/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java @@ -35,45 +35,34 @@ public void defaults(RecipeSpec spec) { void deprecateWsWsocServerContainer() { rewriteRun( //language=java - java(""" - package com.ibm; - - import javax.servlet.http.HttpServletRequest; - import javax.servlet.http.HttpServletResponse; - - import com.ibm.websphere.wsoc.ServerEndpointConfig; - import com.ibm.websphere.wsoc.WsWsocServerContainer; - - public class Test { - - void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map map){ - WsWsocServerContainer.doUpgrade(req,res,sConfig,map); - } - void doY(){ - String x = "test"; - x.toUpperCase(); - } - } - """, """ - package com.ibm; + java( + """ + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; - import javax.servlet.http.HttpServletRequest; - import javax.servlet.http.HttpServletResponse; + import com.ibm.websphere.wsoc.ServerEndpointConfig; + import com.ibm.websphere.wsoc.WsWsocServerContainer; - import com.ibm.websphere.wsoc.ServerEndpointConfig; - import jakarta.websocket.server.ServerContainer; + class Test { + void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map map){ + WsWsocServerContainer.doUpgrade(req, res, sConfig, map); + } + } + """, """ + import javax.servlet.http.HttpServletRequest; + import javax.servlet.http.HttpServletResponse; + + import com.ibm.websphere.wsoc.ServerEndpointConfig; + import jakarta.websocket.server.ServerContainer; - public class Test { - - void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map map){ - ServerContainer.upgradeHttpToWebSocket(req,res,sConfig,map); - } - void doY(){ - String x = "test"; - x.toUpperCase(); - } - } - """)); + class Test { + void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map map){ + ServerContainer.upgradeHttpToWebSocket(req, res, sConfig, map); + } + } + """ + ) + ); } } diff --git a/src/main/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar b/src/test/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar similarity index 100% rename from src/main/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar rename to src/test/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar From 29f0b207a23f0e98ac4ddc37cf775f027b3ace28 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 21 Sep 2023 13:21:48 +0200 Subject: [PATCH 4/5] Slight polish: Add recipe name; chain in jakarta-ee-9 upgrade --- .../resources/META-INF/rewrite/jakarta-ee-10.yml | 5 +++-- .../WsWsocServerContainerDeprecationTest.java | 13 +++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml b/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml index 9b295d4b93..9dcde28649 100644 --- a/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml +++ b/src/main/resources/META-INF/rewrite/jakarta-ee-10.yml @@ -15,18 +15,19 @@ # --- type: specs.openrewrite.org/v1beta/recipe -name: org.openrewrite.java.migrate.jakarta +name: org.openrewrite.java.migrate.jakarta.JakartaEE10 displayName: Migrate to Jakarta EE 10 description: These recipes help with the Migration to Jakarta EE 10, flagging and updating deprecated methods. tags: - jakarta recipeList: + - org.openrewrite.java.migrate.jakarta.JavaxMigrationToJakarta - org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation --- type: specs.openrewrite.org/v1beta/recipe name: org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation displayName: Replace `doUpgrade(..)` with `ServerContainer.upgradeHttpToWebSocket(..)` -description: `WsWsocServerContainer.doUpgrade(..)` is deprecated. It is replaced by the new Jakarta WebSocket 2.1 specification `ServerContainer.upgradeHttpToWebSocket(..)`. +description: Deprecated `WsWsocServerContainer.doUpgrade(..)` is replaced by the Jakarta WebSocket 2.1 specification `ServerContainer.upgradeHttpToWebSocket(..)`. recipeList: - org.openrewrite.java.ChangeMethodName: methodPattern: com.ibm.websphere.wsoc.WsWsocServerContainer doUpgrade(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, com.ibm.websphere.wsoc.ServerEndpointConfig, java.util.Map) diff --git a/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java b/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java index 66c76ee264..a9f42927c1 100644 --- a/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java +++ b/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java @@ -28,7 +28,12 @@ class WsWsocServerContainerDeprecationTest implements RewriteTest { @Override public void defaults(RecipeSpec spec) { - spec.parser(JavaParser.fromJavaVersion().classpathFromResources(new InMemoryExecutionContext(), "WsWsocServerContainer_test")).recipe(Environment.builder().scanRuntimeClasspath("org.openrewrite.java.migrate.jakarta.").build().activateRecipes("org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation")); + spec.parser(JavaParser.fromJavaVersion() + .classpathFromResources(new InMemoryExecutionContext(), "WsWsocServerContainer_test")) + .recipe(Environment.builder() + .scanRuntimeClasspath("org.openrewrite.java.migrate.jakarta") + .build() + .activateRecipes("org.openrewrite.java.migrate.jakarta.WsWsocServerContainerDeprecation")); } @Test @@ -39,10 +44,10 @@ void deprecateWsWsocServerContainer() { """ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - + import com.ibm.websphere.wsoc.ServerEndpointConfig; import com.ibm.websphere.wsoc.WsWsocServerContainer; - + class Test { void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map map){ WsWsocServerContainer.doUpgrade(req, res, sConfig, map); @@ -54,7 +59,7 @@ void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig s import com.ibm.websphere.wsoc.ServerEndpointConfig; import jakarta.websocket.server.ServerContainer; - + class Test { void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map map){ ServerContainer.upgradeHttpToWebSocket(req, res, sConfig, map); From a535c9025b9c971668f4a1f64b8231840ff740c5 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Thu, 21 Sep 2023 13:22:29 +0200 Subject: [PATCH 5/5] Newline before after text block --- .../migrate/jakarta/WsWsocServerContainerDeprecationTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java b/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java index a9f42927c1..81ba156500 100644 --- a/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java +++ b/src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java @@ -53,7 +53,8 @@ void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig s WsWsocServerContainer.doUpgrade(req, res, sConfig, map); } } - """, """ + """, + """ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;