-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding WsWsocServerContainerDeprecationRecipe (#298)
* adding WsWsocServerContainerDeprecationRecipe * adding description * Slight polish: move jar to tests; update name & description * Slight polish: Add recipe name; chain in jakarta-ee-9 upgrade * Newline before after text block --------- Co-authored-by: anuram <ranuradh@us.ibm.com> Co-authored-by: Tim te Beek <tim@moderne.io>
- Loading branch information
1 parent
19e5bc7
commit 4f1ad79
Showing
4 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ out/ | |
.classpath | ||
.project | ||
.settings/ | ||
bin/ | ||
.DS_Store | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# Copyright 2023 the original author or authors. | ||
# <p> | ||
# 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 | ||
# <p> | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# <p> | ||
# 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.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: 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) | ||
newMethodName: upgradeHttpToWebSocket | ||
ignoreDefinition: false | ||
- org.openrewrite.java.ChangeType: | ||
oldFullyQualifiedTypeName: com.ibm.websphere.wsoc.WsWsocServerContainer | ||
newFullyQualifiedTypeName: jakarta.websocket.server.ServerContainer | ||
ignoreDefinition: true |
74 changes: 74 additions & 0 deletions
74
src/test/java/org/openrewrite/java/migrate/jakarta/WsWsocServerContainerDeprecationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright 2023 the original author or authors. | ||
* <p> | ||
* 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 | ||
* <p> | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* 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( | ||
""" | ||
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<String,String> 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; | ||
class Test { | ||
void doX(HttpServletRequest req, HttpServletResponse res, ServerEndpointConfig sConfig, java.util.Map<String,String> map){ | ||
ServerContainer.upgradeHttpToWebSocket(req, res, sConfig, map); | ||
} | ||
} | ||
""" | ||
) | ||
); | ||
} | ||
|
||
} |
Binary file added
BIN
+3.46 KB
src/test/resources/META-INF/rewrite/classpath/WsWsocServerContainer_test.jar
Binary file not shown.