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/13 23:13:14 UTC

[tomcat-jakartaee-migration] branch master updated (42be387 -> 0502cc0)

This is an automated email from the ASF dual-hosted git repository.

ebourg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat-jakartaee-migration.git.


    from 42be387  Exclude the packages which have not been migrated to the new jakarta.* namespace: 'javax.annotation.processing' and 'javax.transaction.xa'
     new 9b23b2d  Removed the unused EESpecProfile.getPattern() method
     new 612a74e  Improve the test coverage
     new 0502cc0  Publish the coverage report to Coveralls

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .travis.yml                                        |  3 +
 pom.xml                                            |  5 ++
 .../org/apache/tomcat/jakartaee/EESpecProfile.java |  7 --
 .../org/apache/tomcat/jakartaee/Migration.java     |  7 +-
 .../jakarta/servlet/CommonGatewayInterface.java}   | 14 ++--
 .../javax/servlet/CommonGatewayInterface.java}     | 14 ++--
 .../tomcat/jakartaee/ClassConverterTest.java}      | 17 +++--
 .../org/apache/tomcat/jakartaee/HelloCGI.java}     | 11 +--
 .../org/apache/tomcat/jakartaee/InfoTest.java}     | 15 ++--
 .../apache/tomcat/jakartaee/MigrationTaskTest.java |  2 +-
 .../org/apache/tomcat/jakartaee/MigrationTest.java | 34 +++++++++
 ...yManager.java => PassThroughConverterTest.java} | 80 ++++++++++++----------
 .../org/apache/tomcat/jakartaee/UtilTest.java}     | 15 ++--
 src/test/resources/testbuild.xml                   |  2 +-
 14 files changed, 134 insertions(+), 92 deletions(-)
 copy src/{main/java/org/apache/tomcat/jakartaee/Converter.java => test/java/jakarta/servlet/CommonGatewayInterface.java} (73%)
 copy src/{main/java/org/apache/tomcat/jakartaee/Converter.java => test/java/javax/servlet/CommonGatewayInterface.java} (73%)
 copy src/{main/java/org/apache/tomcat/jakartaee/Converter.java => test/java/org/apache/tomcat/jakartaee/ClassConverterTest.java} (72%)
 copy src/{main/java/org/apache/tomcat/jakartaee/Converter.java => test/java/org/apache/tomcat/jakartaee/HelloCGI.java} (77%)
 copy src/{main/java/org/apache/tomcat/jakartaee/Converter.java => test/java/org/apache/tomcat/jakartaee/InfoTest.java} (76%)
 copy src/test/java/org/apache/tomcat/jakartaee/{NoExitSecurityManager.java => PassThroughConverterTest.java} (56%)
 copy src/{main/java/org/apache/tomcat/jakartaee/Converter.java => test/java/org/apache/tomcat/jakartaee/UtilTest.java} (76%)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat-jakartaee-migration] 02/03: Improve the test coverage

Posted by eb...@apache.org.
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

commit 612a74e8894ede2737ebaab5dedc1c5d2d4d2bf9
Author: Emmanuel Bourg <eb...@apache.org>
AuthorDate: Mon Apr 13 23:52:10 2020 +0200

    Improve the test coverage
---
 .../jakarta/servlet/CommonGatewayInterface.java    | 24 ++++++++++++
 .../java/javax/servlet/CommonGatewayInterface.java | 24 ++++++++++++
 .../tomcat/jakartaee/ClassConverterTest.java       | 33 ++++++++++++++++
 .../java/org/apache/tomcat/jakartaee/HelloCGI.java | 21 +++++++++++
 .../java/org/apache/tomcat/jakartaee/InfoTest.java | 31 +++++++++++++++
 .../apache/tomcat/jakartaee/MigrationTaskTest.java |  2 +-
 .../org/apache/tomcat/jakartaee/MigrationTest.java | 34 +++++++++++++++++
 .../tomcat/jakartaee/PassThroughConverterTest.java | 44 ++++++++++++++++++++++
 .../java/org/apache/tomcat/jakartaee/UtilTest.java | 31 +++++++++++++++
 src/test/resources/testbuild.xml                   |  2 +-
 10 files changed, 244 insertions(+), 2 deletions(-)

diff --git a/src/test/java/jakarta/servlet/CommonGatewayInterface.java b/src/test/java/jakarta/servlet/CommonGatewayInterface.java
new file mode 100644
index 0000000..d90bfa1
--- /dev/null
+++ b/src/test/java/jakarta/servlet/CommonGatewayInterface.java
@@ -0,0 +1,24 @@
+/*
+ * 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 jakarta.servlet;
+
+/**
+ * Bogus class in the jakarta.servlet package used by the unit tests.
+ */
+public class CommonGatewayInterface {
+}
diff --git a/src/test/java/javax/servlet/CommonGatewayInterface.java b/src/test/java/javax/servlet/CommonGatewayInterface.java
new file mode 100644
index 0000000..40d77ee
--- /dev/null
+++ b/src/test/java/javax/servlet/CommonGatewayInterface.java
@@ -0,0 +1,24 @@
+/*
+ * 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 javax.servlet;
+
+/**
+ * Bogus class in the javax.servlet package used by the unit tests.
+ */
+public class CommonGatewayInterface {
+}
diff --git a/src/test/java/org/apache/tomcat/jakartaee/ClassConverterTest.java b/src/test/java/org/apache/tomcat/jakartaee/ClassConverterTest.java
new file mode 100644
index 0000000..7b6fa0f
--- /dev/null
+++ b/src/test/java/org/apache/tomcat/jakartaee/ClassConverterTest.java
@@ -0,0 +1,33 @@
+/*
+ * 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 org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class ClassConverterTest {
+
+    @Test
+    public void testConverter() {
+        Converter converter = new ClassConverter();
+
+        assertTrue(converter.accepts("HelloServlet.class"));
+        assertFalse(converter.accepts("HelloServlet.java"));
+    }
+}
diff --git a/src/test/java/org/apache/tomcat/jakartaee/HelloCGI.java b/src/test/java/org/apache/tomcat/jakartaee/HelloCGI.java
new file mode 100644
index 0000000..fcee807
--- /dev/null
+++ b/src/test/java/org/apache/tomcat/jakartaee/HelloCGI.java
@@ -0,0 +1,21 @@
+/*
+ * 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;
+
+public class HelloCGI extends javax.servlet.CommonGatewayInterface {
+}
diff --git a/src/test/java/org/apache/tomcat/jakartaee/InfoTest.java b/src/test/java/org/apache/tomcat/jakartaee/InfoTest.java
new file mode 100644
index 0000000..3cdf66b
--- /dev/null
+++ b/src/test/java/org/apache/tomcat/jakartaee/InfoTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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 org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class InfoTest {
+
+    @Test
+    public void testGetVersion() {
+        assertNotNull(Info.getVersion());
+        assertTrue(Info.getVersion().matches("migrated-[\\d\\.]+(-SNAPSHOT)?"));
+    }
+}
diff --git a/src/test/java/org/apache/tomcat/jakartaee/MigrationTaskTest.java b/src/test/java/org/apache/tomcat/jakartaee/MigrationTaskTest.java
index 1baa1d7..23843ec 100644
--- a/src/test/java/org/apache/tomcat/jakartaee/MigrationTaskTest.java
+++ b/src/test/java/org/apache/tomcat/jakartaee/MigrationTaskTest.java
@@ -62,7 +62,7 @@ public class MigrationTaskTest {
     }
 
     @Test(expected = BuildException.class)
-    public void testUnsupportedKeyStoreType() {
+    public void testInvalidProfile() {
         project.executeTarget("invalid-profile");
     }
 
diff --git a/src/test/java/org/apache/tomcat/jakartaee/MigrationTest.java b/src/test/java/org/apache/tomcat/jakartaee/MigrationTest.java
index 813ca55..8ed4310 100644
--- a/src/test/java/org/apache/tomcat/jakartaee/MigrationTest.java
+++ b/src/test/java/org/apache/tomcat/jakartaee/MigrationTest.java
@@ -103,4 +103,38 @@ public class MigrationTest {
             assertEquals("error code", "1", e.getMessage());
         }
     }
+
+    @Test
+    public void testMigrateDirectory() throws Exception {
+        File sourceDirectory = new File("src/test/resources");
+        File destinationDirectory = new File("target/test-classes/migration");
+
+        Migration migration = new Migration();
+        migration.setSource(sourceDirectory);
+        migration.setDestination(destinationDirectory);
+        boolean success = migration.execute();
+
+        assertTrue("Migration failed", success);
+        assertTrue("Destination directory not found", destinationDirectory.exists());
+
+        File migratedFile = new File("target/test-classes/migration/HelloServlet.java");
+        assertTrue("Migrated file not found", migratedFile.exists());
+
+        String migratedSource = FileUtils.readFileToString(migratedFile, StandardCharsets.UTF_8);
+        assertFalse("Imports not migrated", migratedSource.contains("import javax.servlet"));
+        assertTrue("Migrated imports not found", migratedSource.contains("import jakarta.servlet"));
+    }
+
+    @Test
+    public void testMigrateClassFile() throws Exception {
+        File classFile = new File("target/test-classes/org/apache/tomcat/jakartaee/HelloCGI.class");
+
+        Migration migration = new Migration();
+        migration.setSource(classFile);
+        migration.setDestination(classFile);
+        migration.execute();
+
+        Class<?> cls = Class.forName("org.apache.tomcat.jakartaee.HelloCGI");
+        assertEquals("jakarta.servlet.CommonGatewayInterface", cls.getSuperclass().getName());
+    }
 }
diff --git a/src/test/java/org/apache/tomcat/jakartaee/PassThroughConverterTest.java b/src/test/java/org/apache/tomcat/jakartaee/PassThroughConverterTest.java
new file mode 100644
index 0000000..5df0687
--- /dev/null
+++ b/src/test/java/org/apache/tomcat/jakartaee/PassThroughConverterTest.java
@@ -0,0 +1,44 @@
+/*
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class PassThroughConverterTest {
+
+    @Test
+    public void testConverter() throws Exception {
+        String content = "javax.servlet";
+
+        ByteArrayInputStream in = new ByteArrayInputStream(content.getBytes());
+        ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+        Converter converter = new PassThroughConverter();
+
+        assertTrue(converter.accepts("project.properties"));
+
+        converter.convert(in, out, null);
+
+        assertArrayEquals(content.getBytes(), out.toByteArray());
+    }
+}
diff --git a/src/test/java/org/apache/tomcat/jakartaee/UtilTest.java b/src/test/java/org/apache/tomcat/jakartaee/UtilTest.java
new file mode 100644
index 0000000..ae0ef07
--- /dev/null
+++ b/src/test/java/org/apache/tomcat/jakartaee/UtilTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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 org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class UtilTest {
+
+    @Test
+    public void testGetExtension() {
+        assertEquals("java", Util.getExtension("HelloServlet.java"));
+        assertEquals("", Util.getExtension("HelloServlet"));
+    }
+}
diff --git a/src/test/resources/testbuild.xml b/src/test/resources/testbuild.xml
index 3b64b59..19b4dec 100644
--- a/src/test/resources/testbuild.xml
+++ b/src/test/resources/testbuild.xml
@@ -7,7 +7,7 @@
   </target>
 
   <target name="invalid-profile">
-    <javax2jakarta src="foo" dest="bar" profile="tOmCaT"/>
+    <javax2jakarta src="foo" dest="bar" profile="jserv"/>
   </target>
 
 </project>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat-jakartaee-migration] 01/03: Removed the unused EESpecProfile.getPattern() method

Posted by eb...@apache.org.
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

commit 9b23b2daa8aeb0c55cacb92275232bf9125cffe4
Author: Emmanuel Bourg <eb...@apache.org>
AuthorDate: Mon Apr 13 22:57:22 2020 +0200

    Removed the unused EESpecProfile.getPattern() method
---
 src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java b/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
index bdf4889..d4ae075 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/EESpecProfile.java
@@ -36,13 +36,6 @@ public enum EESpecProfile {
         this.pattern = Pattern.compile(pattern);
     }
 
-    /**
-     * @return the replacement pattern for this profile.
-     */
-    public Pattern getPattern() {
-        return pattern;
-    }
-
     public String convert(String name) {
         Matcher m = pattern.matcher(name);
         return m.replaceAll("jakarta$1");


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[tomcat-jakartaee-migration] 03/03: Publish the coverage report to Coveralls

Posted by eb...@apache.org.
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

commit 0502cc06283072083c2e8dd616c8a1caf1b2bb94
Author: Emmanuel Bourg <eb...@apache.org>
AuthorDate: Tue Apr 14 01:11:55 2020 +0200

    Publish the coverage report to Coveralls
---
 .travis.yml                                              | 3 +++
 pom.xml                                                  | 5 +++++
 src/main/java/org/apache/tomcat/jakartaee/Migration.java | 7 +++++--
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index eb98a0a..5364fff 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,3 +19,6 @@ jdk:
   - openjdk8
   - openjdk11
   - openjdk-ea
+
+after_success:
+  - mvn clean cobertura:cobertura coveralls:report
diff --git a/pom.xml b/pom.xml
index c094b75..2c6b3db 100644
--- a/pom.xml
+++ b/pom.xml
@@ -158,6 +158,11 @@
           </execution>
         </executions>
       </plugin>
+      <plugin>
+        <groupId>org.eluder.coveralls</groupId>
+        <artifactId>coveralls-maven-plugin</artifactId>
+        <version>4.3.0</version>
+      </plugin>
     </plugins>
   </build>
 
diff --git a/src/main/java/org/apache/tomcat/jakartaee/Migration.java b/src/main/java/org/apache/tomcat/jakartaee/Migration.java
index 44efc5a..a880e63 100644
--- a/src/main/java/org/apache/tomcat/jakartaee/Migration.java
+++ b/src/main/java/org/apache/tomcat/jakartaee/Migration.java
@@ -238,8 +238,11 @@ public class Migration {
                 removedSignatures = true;
             }
         }
-        signatureEntries.stream()
-            .forEach(manifestAttributeEntries::remove);
+
+        for (String entry : signatureEntries) {
+            manifestAttributeEntries.remove(entry);
+        }
+
         return removedSignatures;
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org