You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by eb...@apache.org on 2020/04/06 17:52:38 UTC
[tomcat-jakartaee-migration] branch master updated: Added a unit
test checking the migration of a single source file
This is an automated email from the ASF dual-hosted git repository.
ebourg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git
The following commit(s) were added to refs/heads/master by this push:
new f6294dd Added a unit test checking the migration of a single source file
f6294dd is described below
commit f6294dd5583e2912eac533adec8a8ee3aefb260d
Author: Emmanuel Bourg <eb...@apache.org>
AuthorDate: Mon Apr 6 19:52:21 2020 +0200
Added a unit test checking the migration of a single source file
---
pom.xml | 8 +++++
.../org/apache/tomcat/jakartaee/MigrationTest.java | 40 ++++++++++++++++++++++
src/test/resources/HelloServlet.java | 30 ++++++++++++++++
3 files changed, 78 insertions(+)
diff --git a/pom.xml b/pom.xml
index 8ba872a..dfbbaf2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,6 +76,14 @@
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.13</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
diff --git a/src/test/java/org/apache/tomcat/jakartaee/MigrationTest.java b/src/test/java/org/apache/tomcat/jakartaee/MigrationTest.java
new file mode 100644
index 0000000..a531d1d
--- /dev/null
+++ b/src/test/java/org/apache/tomcat/jakartaee/MigrationTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.apache.tomcat.jakartaee;
+
+import java.io.File;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class MigrationTest {
+
+ @Test
+ public void testMigrateSingleSourceFile() throws Exception {
+ File migratedFile = new File("target/test-classes/HelloServlet.migrated.java");
+ Migration.main(new String[] {"target/test-classes/HelloServlet.java", migratedFile.getAbsolutePath()});
+
+ assertTrue("Migrated file not found", migratedFile.exists());
+
+ String migratedSource = FileUtils.readFileToString(migratedFile);
+ assertFalse("Imports not migrated", migratedSource.contains("import javax.servlet"));
+ assertTrue("Migrated imports not found", migratedSource.contains("import jakarta.servlet"));
+ }
+}
diff --git a/src/test/resources/HelloServlet.java b/src/test/resources/HelloServlet.java
new file mode 100644
index 0000000..4ab645c
--- /dev/null
+++ b/src/test/resources/HelloServlet.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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.
+ */
+
+import java.io.IOException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.GenericServlet;
+
+public class HelloServlet extends GenericServlet {
+
+ public void service(ServletRequest request, ServletResponse response) throws IOException, ServletException {
+ response.setContentType("text/plain");
+ response.getWriter().print("Hello JakartaEE!");
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org