Skip to content

Commit

Permalink
[MWAR-45] add an IT testing archiveClasses result
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Jun 13, 2020
1 parent 88fe0ea commit 45a8201
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 0 deletions.
69 changes: 69 additions & 0 deletions src/it/archiveClasses/pom.xml
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
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.
-->

<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.mwar-45</groupId>
<artifactId>maven-it-mwar-45</artifactId>
<version>1.0</version>
<packaging>war</packaging>

<name>Maven Integration Test :: MWAR-45</name>
<description>Test a WAR generation with archiveClasses=true</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,35 @@
package org.apache.maven.it0016;

/*
* 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.
*/

public class Person
{
private String name;

public void setName( String name )
{
this.name = name;
}

public String getName()
{
return name;
}
}
23 changes: 23 additions & 0 deletions src/it/archiveClasses/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app >
</web-app>
23 changes: 23 additions & 0 deletions src/it/archiveClasses/src/main/webapp/index.html
@@ -0,0 +1,23 @@
<!--
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.
-->
<html>
<body>
Hello World
</body>
</html>
99 changes: 99 additions & 0 deletions src/it/archiveClasses/verify.bsh
@@ -0,0 +1,99 @@
/*
* 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.*;
import java.util.*;
import java.util.jar.*;
import java.util.regex.*;

try
{
File explodedDir = new File( basedir, "target/maven-it-mwar-45-1.0" );
System.out.println( "Checking for existence of exploded directory " + explodedDir );
if ( !explodedDir.isDirectory() )
{
System.out.println( "FAILURE!" );
return false;
}

String[] expectedPaths = {
"index.html",
"WEB-INF/lib/commons-logging-1.0.3.jar",
"WEB-INF/lib/maven-it-mwar-45-1.0.jar",
};
for ( String path : expectedPaths )
{
File file = new File( explodedDir, path );
System.out.println( "Checking for existence of " + file );
if ( !file.exists() )
{
System.out.println( "FAILURE!" );
return false;
}
}

String[] unexpectedPaths = {
"WEB-INF/classes/org/apache/maven/it0016/Person.class",
"WEB-INF/lib/servlet-api-2.4.jar",
};
for ( String path : unexpectedPaths )
{
File file = new File( explodedDir, path );
System.out.println( "Checking for absence of " + file );
if ( file.exists() )
{
System.out.println( "FAILURE!" );
return false;
}
}

File warFile = new File( basedir, "target/maven-it-mwar-45-1.0.war" );
System.out.println( "Checking for existence of " + warFile );
if ( !warFile.isFile() )
{
System.out.println( "FAILURE!" );
return false;
}

JarFile war = new JarFile( warFile );

String[] includedEntries = {
"index.html",
"WEB-INF/lib/maven-it-mwar-45-1.0.jar",
"WEB-INF/lib/commons-logging-1.0.3.jar",
};
for ( String included : includedEntries )
{
System.out.println( "Checking for existence of " + included );
if ( war.getEntry( included ) == null )
{
System.out.println( "FAILURE!" );
return false;
}
}

war.close();
}
catch( Throwable t )
{
t.printStackTrace();
return false;
}

return true;

0 comments on commit 45a8201

Please sign in to comment.