Skip to content

Commit

Permalink
[MSHADE-327] improved integration test coverage for relocation and mi…
Browse files Browse the repository at this point in the history
…nification (#27)

* adds an integration test that verifies relocation and minifying work together

* reference the jira issue

* upgraded to latest jdependency version 2.3.0,
added me to the list of contributors

* removed me as author
  • Loading branch information
tcurdt authored and olamy committed Sep 11, 2019
1 parent 57d78de commit b68b24c
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 3 deletions.
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<contributor>
<name>Markus Karg</name>
</contributor>
<contributor>
<name>Torsten Curdt</name>
</contributor>
</contributors>

<dependencies>
Expand Down Expand Up @@ -156,7 +159,7 @@
<dependency>
<groupId>org.vafer</groupId>
<artifactId>jdependency</artifactId>
<version>2.1.1</version>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
18 changes: 18 additions & 0 deletions src/it/reloc-and-mini/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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.

invoker.java.version = 1.8+
77 changes: 77 additions & 0 deletions src/it/reloc-and-mini/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?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>

<parent>
<groupId>org.apache.maven.plugins.shade.its</groupId>
<artifactId>shade-parent</artifactId>
<version>1.0</version>
<relativePath>../setup-parent</relativePath>
</parent>

<groupId>org.apache.maven.its.shade.mini</groupId>
<artifactId>test</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<name>MSHADE-327</name>
<description>
Test handling of relocations and minification.
</description>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.2</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>attach-shade</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
<shadedArtifactAttached>false</shadedArtifactAttached>
<relocations>
<relocation>
<pattern>junit.framework</pattern>
<shadedPattern>a.junit.framework</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.apache.maven.plugins.shade.its;

/*
* 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 junit.framework.TestResult;

public class App
{
public static void main( String[] args )
{
TestResult result = new TestResult();
System.out.println("Failures: " + result.failureCount());
}
}
50 changes: 50 additions & 0 deletions src/it/reloc-and-mini/verify.bsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.jar.*;

String[] wanted =
{
"a/junit/framework/TestResult.class",
};

String[] unwanted =
{
"junit/framework/TestResult.class",
};

JarFile jarFile = new JarFile( new File( basedir, "target/test-1.0.jar" ) );

for ( String path : wanted )
{
if ( jarFile.getEntry( path ) == null )
{
throw new IllegalStateException( "wanted path is missing: " + path );
}
}

for ( String path : unwanted )
{
if ( jarFile.getEntry( path ) != null )
{
throw new IllegalStateException( "unwanted path is present: " + path );
}
}

jarFile.close();
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

/**
* A filter that prevents the inclusion of classes not required in the final jar.
*
* @author Torsten Curdt
*/
public class MinijarFilter
implements Filter
Expand Down

0 comments on commit b68b24c

Please sign in to comment.