This is an automated email from the ASF dual-hosted git repository. dblevins pushed a commit to branch redoparent in repository https://gitbox.apache.org/repos/asf/tomee-jakarta.git
commit 747504310031cb1d77021d38bc7e32dc0f6512ae Author: David Blevins <[email protected]> AuthorDate: Sun Mar 21 15:44:00 2021 -0700 Builds complete (but not yet translated) zips --- pom.xml | 180 +++++++++++ .../apache/tomee/RemoteTomEEEJBContainerIT.java | 112 ------- .../src/test/java/org/apache/tomee/Test.java | 24 -- .../test/java/org/apache/tomee/TestCommand1.java | 25 -- .../test/java/org/apache/tomee/TestCommand2.java | 26 -- .../src/test/java/org/apache/tomee/TomEECliIT.java | 328 --------------------- .../tomee/webapp/installer/InstallerServlet.java | 10 +- .../tomee/webapp/installer/test/RunnerTest.java | 86 ------ 8 files changed, 185 insertions(+), 606 deletions(-) diff --git a/pom.xml b/pom.xml index d5353d0..01b0e32 100644 --- a/pom.xml +++ b/pom.xml @@ -1149,6 +1149,186 @@ </dependency> </dependencies> </dependencyManagement> + + <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-war-plugin</artifactId> + <version>3.1.0</version> + </plugin> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <version>${maven-bundle-plugin.version}</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-shade-plugin</artifactId> + <version>2.3</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-remote-resources-plugin</artifactId> + <version>1.5</version> + <dependencies> + <dependency> <!-- java 8 NPE fix --> + <groupId>org.apache.maven.shared</groupId> + <artifactId>maven-filtering</artifactId> + <version>1.3</version> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>rat-maven-plugin</artifactId> + <version>1.0-alpha-3</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>3.0.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-ear-plugin</artifactId> + <version>2.10.1</version> + <dependencies> + <dependency> + <groupId>org.codehaus.plexus</groupId> + <artifactId>plexus-archiver</artifactId> + <version>3.4</version> + </dependency> + </dependencies> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>1.9.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <version>2.20</version> + </plugin> + <plugin> <!-- maven-dependency-plugin:properties doesn't work as well as this one for us --> + <groupId>org.apache.geronimo.buildsupport</groupId> + <artifactId>geronimo-property-plugin</artifactId> + <version>3.0.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.0.2</version> + </plugin> + <plugin> + <groupId>org.codehaus.swizzle</groupId> + <artifactId>dependency-report-plugin</artifactId> + <version>1.0.2</version> + </plugin> + <plugin> + <groupId>org.metatype.sxc</groupId> + <artifactId>sxc-jaxb-maven-plugin</artifactId> + <version>0.8</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jxr-plugin</artifactId> + <version>2.5</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-pmd-plugin</artifactId> + <version>3.4</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>jaxb2-maven-plugin</artifactId> + <version>1.6</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>exec-maven-plugin</artifactId> + <version>1.2.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-assembly-plugin</artifactId> + <version>2.4.1</version> + </plugin> + <plugin> + <groupId>com.googlecode.jslint4java</groupId> + <artifactId>jslint4java-maven-plugin</artifactId> + <version>2.0.5</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-checkstyle-plugin</artifactId> + <version>2.15</version> + </plugin> + <plugin> + <groupId>org.codehaus.gmaven</groupId> + <artifactId>groovy-maven-plugin</artifactId> + <version>2.0</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-doap-plugin</artifactId> + <version>1.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <version>2.8.2</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.6.2</version> + </plugin> + <plugin> + <groupId>org.owasp</groupId> + <artifactId>dependency-check-maven</artifactId> + <version>6.0.5</version> + <configuration> + <suppressionFile>owasp-dc-suppression.xml</suppressionFile> + </configuration> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + <version>0.8.2</version> + <executions> + <execution> + <goals> + <goal>prepare-agent</goal> + </goals> + </execution> + <!-- attached to Maven test phase --> + <execution> + <id>report</id> + <phase>test</phase> + <goals> + <goal>report</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </pluginManagement> + </build> + <pluginRepositories> <pluginRepository> <id>ossrh</id> diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/RemoteTomEEEJBContainerIT.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/RemoteTomEEEJBContainerIT.java deleted file mode 100644 index ec1cb75..0000000 --- a/tomee/apache-tomee/src/test/java/org/apache/tomee/RemoteTomEEEJBContainerIT.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * 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.tomee; - -import org.apache.openejb.loader.Files; -import org.apache.openejb.loader.IO; -import org.apache.openejb.util.NetworkUtil; -import org.junit.After; -import org.junit.Test; - -import javax.ejb.embeddable.EJBContainer; -import java.io.File; -import java.io.FileFilter; -import java.io.FileWriter; -import java.io.IOException; -import java.net.URL; -import java.util.HashMap; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -public class RemoteTomEEEJBContainerIT { - private EJBContainer container; - - @After - public void close() { - try { - if (container != null) { - container.close(); - } - } catch (final RuntimeException re) { - // no-op - } - } - - @Test(timeout = 300000) - public void run() throws IOException { - final File app = new File("target/mock/webapp"); - Files.mkdirs(app); - - final FileWriter writer = new FileWriter(new File(app, "index.html")); - writer.write("Hello"); - writer.close(); - - File work = new File("target/webprofile-work-dir/").getAbsoluteFile(); - if (!work.exists()) { - //May be running from root - work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile(); - } - - final File[] files = work.listFiles(new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-"); - } - }); - - final File tomee = (null != files ? files[0] : null); - if (tomee == null) { - fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources"); - } - - final FileWriter serverXml = new FileWriter(new File(tomee, "conf/server.xml")); - final int http = NetworkUtil.getNextAvailablePort(); - serverXml.write("<?xml version='1.0' encoding='utf-8'?>\n" + - "<Server port=\"" + NetworkUtil.getNextAvailablePort() + "\" shutdown=\"SHUTDOWN\">\n" + - " <!-- TomEE plugin for Tomcat -->\n" + - " <Listener className=\"org.apache.tomee.catalina.ServerListener\" />\n" + - " <Service name=\"Catalina\">\n" + - " <Connector port=\"" + http + "\" protocol=\"HTTP/1.1\" xpoweredBy=\"false\" server=\"Apache TomEE\" />\n" + - " <Engine name=\"Catalina\" defaultHost=\"localhost\">\n" + - " <Host name=\"localhost\" appBase=\"webapps\"\n" + - " unpackWARs=\"true\" autoDeploy=\"true\">\n" + - " </Host>\n" + - " </Engine>\n" + - " </Service>\n" + - "</Server>\n"); - serverXml.close(); - - container = null; - try { - container = EJBContainer.createEJBContainer(new HashMap<Object, Object>() {{ - put(EJBContainer.PROVIDER, "tomee-remote"); - put(EJBContainer.MODULES, app.getAbsolutePath()); - put("openejb.home", tomee.getAbsolutePath()); - put("retries", "120"); - put("debug", System.getProperty("RemoteTomEEEJBContainerIT.debug", "false")); - }}); - final URL url = new URL("http://localhost:" + http + "/webapp/index.html"); - assertEquals("Hello", IO.slurp(url)); - } finally { - if (container != null) { - container.close(); - container = null; - } - } - } -} \ No newline at end of file diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/Test.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/Test.java deleted file mode 100644 index c788582..0000000 --- a/tomee/apache-tomee/src/test/java/org/apache/tomee/Test.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * 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.tomee; - -public class Test { - - public static void main(String[] args) { - System.out.println("TESTING CLASSLOADER!!"); - } -} diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand1.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand1.java deleted file mode 100644 index 1fe2af7..0000000 --- a/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand1.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * 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.tomee; - -public class TestCommand1 { - - public static void main(String[] args) { - final Test test = new Test(); - test.main(args); - } -} diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand2.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand2.java deleted file mode 100644 index b66bedd..0000000 --- a/tomee/apache-tomee/src/test/java/org/apache/tomee/TestCommand2.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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.tomee; - -import org.apache.openejb.cli.Bootstrap; - -public class TestCommand2 { - - public static void main(String[] args) throws Exception { - new Bootstrap().main(new String[]{"classloadertest"}); - } -} diff --git a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java b/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java deleted file mode 100644 index 453e21a..0000000 --- a/tomee/apache-tomee/src/test/java/org/apache/tomee/TomEECliIT.java +++ /dev/null @@ -1,328 +0,0 @@ -/** - * 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.tomee; - -import org.apache.openejb.cli.Bootstrap; -import org.apache.openejb.loader.IO; -import org.jboss.shrinkwrap.api.ShrinkWrap; -import org.jboss.shrinkwrap.api.asset.StringAsset; -import org.jboss.shrinkwrap.api.exporter.ZipExporter; -import org.jboss.shrinkwrap.api.spec.JavaArchive; -import org.junit.Test; - -import java.io.File; -import java.io.FileFilter; -import java.io.FilenameFilter; -import java.io.IOException; -import java.nio.file.Files; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -public class TomEECliIT { - - @Test - public void testTomEECliWithJar() throws IOException, InterruptedException { - final File file = Files.createTempDirectory("tomee-test").toFile(); - final File jar = new File(file.getAbsolutePath() + "/test.jar"); - - final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar") - .addClasses(org.apache.tomee.Test.class) - .add(new StringAsset("main.class = org.apache.tomee.Test\n" + - "name = classloadertest\n" + - "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest"); - - archive.as(ZipExporter.class).exportTo(jar); - - File work = new File("target/webprofile-work-dir/").getAbsoluteFile(); - if (!work.exists()) { - work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile(); - } - - final File[] files = work.listFiles(new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-"); - } - }); - - final File tomee = (null != files ? files[0] : null); - if (tomee == null) { - fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources"); - } - - final File libDir = new File(tomee.getAbsolutePath() + File.separator + "lib"); - final String[] openejbCore = libDir.list(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("openejb-core"); - } - }); - - final String[] commonsCli = libDir.list(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("commons-cli"); - } - }); - - final String[] commonsLang = libDir.list(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("commons-lang"); - } - }); - - final ProcessBuilder builder = new ProcessBuilder() - .command("java", "-cp", jar.getAbsolutePath() + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + openejbCore[0] + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsCli[0] + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsLang[0], - "org.apache.openejb.cli.Bootstrap", "classloadertest"); - - final Process start = builder.start(); - start.waitFor(); - - final String result = IO.slurp(start.getInputStream()); - assertTrue(result.contains("TESTING CLASSLOADER!!")); - } - - @Test - public void testTomEECliWithJarDir() throws IOException, InterruptedException { - final File file = Files.createTempDirectory("tomee-test").toFile(); - final File jar = new File(file.getAbsolutePath() + "/test.jar"); - - final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar") - .addClasses(org.apache.tomee.Test.class) - .add(new StringAsset("main.class = org.apache.tomee.Test\n" + - "name = classloadertest\n" + - "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest"); - - archive.as(ZipExporter.class).exportTo(jar); - - File work = new File("target/webprofile-work-dir/").getAbsoluteFile(); - if (!work.exists()) { - work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile(); - } - - final File[] files = work.listFiles(new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-"); - } - }); - - final File tomee = (null != files ? files[0] : null); - if (tomee == null) { - fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources"); - } - - final ProcessBuilder builder = new ProcessBuilder() - .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*", - "org.apache.openejb.cli.Bootstrap", "classloadertest"); - - final Process start = builder.start(); - start.waitFor(); - - final String result = IO.slurp(start.getInputStream()); - assertTrue(result.contains("TESTING CLASSLOADER!!")); - } - - @Test - public void testTomEECliWithJarCallingAnotherMain() throws IOException, InterruptedException { - final File file = Files.createTempDirectory("tomee-test").toFile(); - final File jar = new File(file.getAbsolutePath() + "/test.jar"); - final File jar2 = new File(file.getAbsolutePath() + "/test2.jar"); - - final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar") - .addClasses(org.apache.tomee.Test.class) - .add(new StringAsset("main.class = org.apache.tomee.Test\n" + - "name = classloadertest\n" + - "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest"); - - final JavaArchive archive2 = ShrinkWrap.create(JavaArchive.class, "test2.jar") - .addClasses(org.apache.tomee.TestCommand1.class) - .add(new StringAsset("main.class = org.apache.tomee.TestCommand1\n" + - "name = classloadertest2\n" + - "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest2"); - - archive.as(ZipExporter.class).exportTo(jar); - archive2.as(ZipExporter.class).exportTo(jar2); - - File work = new File("target/webprofile-work-dir/").getAbsoluteFile(); - if (!work.exists()) { - work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile(); - } - - final File[] files = work.listFiles(new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-"); - } - }); - - final File tomee = (null != files ? files[0] : null); - if (tomee == null) { - fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources"); - } - - final File libDir = new File(tomee.getAbsolutePath() + File.separator + "lib"); - final String[] openejbCore = libDir.list(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("openejb-core"); - } - }); - - final String[] commonsCli = libDir.list(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("commons-cli"); - } - }); - - final String[] commonsLang = libDir.list(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.startsWith("commons-lang"); - } - }); - - final ProcessBuilder builder = new ProcessBuilder() - .command("java", "-cp", jar.getAbsolutePath() + File.pathSeparator + - jar2.getAbsolutePath() + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + openejbCore[0] + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsCli[0] + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + commonsLang[0], - "org.apache.openejb.cli.Bootstrap", "classloadertest2"); - - final Process start = builder.start(); - start.waitFor(); - - final String result = IO.slurp(start.getInputStream()); - assertTrue(result.contains("TESTING CLASSLOADER!!")); - } - - @Test - public void testTomEECliWithJarDirCallingAnotherMain() throws IOException, InterruptedException { - final File file = Files.createTempDirectory("tomee-test").toFile(); - final File jar = new File(file.getAbsolutePath() + "/test.jar"); - final File jar2 = new File(file.getAbsolutePath() + "/test2.jar"); - - final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar") - .addClasses(org.apache.tomee.Test.class) - .add(new StringAsset("main.class = org.apache.tomee.Test\n" + - "name = classloadertest\n" + - "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest"); - - final JavaArchive archive2 = ShrinkWrap.create(JavaArchive.class, "test2.jar") - .addClasses(org.apache.tomee.TestCommand1.class) - .add(new StringAsset("main.class = org.apache.tomee.TestCommand1\n" + - "name = classloadertest2\n" + - "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest2"); - - archive.as(ZipExporter.class).exportTo(jar); - archive2.as(ZipExporter.class).exportTo(jar2); - - File work = new File("target/webprofile-work-dir/").getAbsoluteFile(); - if (!work.exists()) { - work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile(); - } - - final File[] files = work.listFiles(new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-"); - } - }); - - final File tomee = (null != files ? files[0] : null); - if (tomee == null) { - fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources"); - } - - final ProcessBuilder builder = new ProcessBuilder() - .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*", - "org.apache.openejb.cli.Bootstrap", "classloadertest2"); - - final Process start = builder.start(); - start.waitFor(); - - final String result = IO.slurp(start.getInputStream()); - assertTrue(result.contains("TESTING CLASSLOADER!!")); - } - - @Test - public void testDelegatesToCLIMain() throws IOException, InterruptedException { - final File file = Files.createTempDirectory("tomee-test").toFile(); - final File jar = new File(file.getAbsolutePath() + "/test.jar"); - final File jar2 = new File(file.getAbsolutePath() + "/test2.jar"); - - final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "test.jar") - .addClasses(org.apache.tomee.Test.class) - .add(new StringAsset("main.class = org.apache.tomee.Test\n" + - "name = classloadertest\n" + - "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest"); - - final JavaArchive archive2 = ShrinkWrap.create(JavaArchive.class, "test2.jar") - .addClasses(org.apache.tomee.TestCommand2.class) - .add(new StringAsset("main.class = org.apache.tomee.TestCommand2\n" + - "name = classloadertest2\n" + - "description = Show a simple msg"), "META-INF/org.apache.openejb.cli/classloadertest2"); - - archive.as(ZipExporter.class).exportTo(jar); - archive2.as(ZipExporter.class).exportTo(jar2); - - File work = new File("target/webprofile-work-dir/").getAbsoluteFile(); - if (!work.exists()) { - work = new File("apache-tomee/target/webprofile-work-dir/").getAbsoluteFile(); - } - - final File[] files = work.listFiles(new FileFilter() { - @Override - public boolean accept(final File pathname) { - return pathname.isDirectory() && pathname.getName().startsWith("apache-tomcat-"); - } - }); - - final File tomee = (null != files ? files[0] : null); - if (tomee == null) { - fail("Failed to find Tomcat directory required for this test - Ensure you have run at least the maven phase: mvn process-resources"); - } - - final ProcessBuilder builder = new ProcessBuilder() - .command("java", "-cp", file.getAbsolutePath() + File.separator + "*" + File.pathSeparator + - tomee.getAbsolutePath() + File.separator + "lib" + File.separator + "*", - "org.apache.openejb.cli.Bootstrap", "classloadertest2"); - - final Process start = builder.start(); - start.waitFor(); - - final String result = IO.slurp(start.getInputStream()); - assertTrue(result.contains("TESTING CLASSLOADER!!")); - } - - @Test - public void testIfClassloaderNotChange() throws Exception { - final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader(); - new Bootstrap().main(new String[]{"cipher"}); - assertEquals(originalClassLoader, Thread.currentThread().getContextClassLoader()); - } -} diff --git a/tomee/tomee-webprofile-webapp/src/main/java/org/apache/tomee/webapp/installer/InstallerServlet.java b/tomee/tomee-webprofile-webapp/src/main/java/org/apache/tomee/webapp/installer/InstallerServlet.java index 03d5765..bedc4c9 100644 --- a/tomee/tomee-webprofile-webapp/src/main/java/org/apache/tomee/webapp/installer/InstallerServlet.java +++ b/tomee/tomee-webprofile-webapp/src/main/java/org/apache/tomee/webapp/installer/InstallerServlet.java @@ -20,11 +20,11 @@ package org.apache.tomee.webapp.installer; import org.apache.tomee.installer.Installer; import org.apache.tomee.installer.Paths; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.http.HttpServlet; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import java.io.File; import java.io.IOException; import java.util.List; diff --git a/tomee/tomee-webprofile-webapp/src/test/java/org/apache/tomee/webapp/installer/test/RunnerTest.java b/tomee/tomee-webprofile-webapp/src/test/java/org/apache/tomee/webapp/installer/test/RunnerTest.java deleted file mode 100644 index 7bc2058..0000000 --- a/tomee/tomee-webprofile-webapp/src/test/java/org/apache/tomee/webapp/installer/test/RunnerTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * 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.tomee.webapp.installer.test; - -import org.apache.tomee.installer.Alerts; -import org.apache.tomee.installer.InstallerInterface; -import org.apache.tomee.installer.PathsInterface; -import org.apache.tomee.installer.Status; -import org.apache.tomee.webapp.installer.Runner; -import org.easymock.EasyMock; -import org.junit.Assert; -import org.junit.Test; - -import java.util.List; -import java.util.Map; - -public class RunnerTest { - - private Object getValue(final String key, final List<Map<String, String>> runnerResults) { - for (final Map<String, String> result : runnerResults) { - if (key.equals(result.get("key"))) { - return result.get("value"); - } - } - return null; - } - - @Test - public void testInstaller() { - { - final PathsInterface paths = EasyMock.createNiceMock(PathsInterface.class); - paths.reset(); - EasyMock.expectLastCall(); - paths.verify(); - EasyMock.expectLastCall().andReturn(Boolean.TRUE).anyTimes(); - - final InstallerInterface installer = EasyMock.createNiceMock(InstallerInterface.class); - installer.getPaths(); - EasyMock.expectLastCall().andReturn(paths).anyTimes(); - installer.reset(); - EasyMock.expectLastCall(); - installer.getStatus(); - EasyMock.expectLastCall().andReturn(Status.NONE); - installer.getStatus(); - EasyMock.expectLastCall().andReturn(Status.NONE); - installer.getStatus(); - EasyMock.expectLastCall().andReturn(Status.REBOOT_REQUIRED); - installer.getAlerts(); - EasyMock.expectLastCall().andReturn(new Alerts()).anyTimes(); - - - final Runner runner = new Runner(installer); - EasyMock.replay(paths, installer); - Assert.assertEquals("NONE", getValue("status", runner.execute(false))); - Assert.assertEquals("NONE", getValue("status", runner.execute(false))); - Assert.assertEquals("REBOOT_REQUIRED", getValue("status", runner.execute(true))); - Assert.assertEquals("REBOOT_REQUIRED", getValue("status", runner.execute(false))); - Assert.assertEquals("REBOOT_REQUIRED", getValue("status", runner.execute(true))); - EasyMock.verify(paths, installer); - } - { - final InstallerInterface installer = EasyMock.createStrictMock(InstallerInterface.class); - final Runner runner = new Runner(installer); - EasyMock.replay(installer); - Assert.assertEquals("REBOOT_REQUIRED", getValue("status", runner.execute(false))); - Assert.assertEquals("REBOOT_REQUIRED", getValue("status", runner.execute(true))); - EasyMock.verify(installer); - } - - } - -}
