This is an automated email from the ASF dual-hosted git repository. rfscholte pushed a commit to branch MPLUGINTESTING-61 in repository https://gitbox.apache.org/repos/asf/maven-plugin-testing.git
commit f9b38234b4d972ad104a5ea56b54a5de17a12cbf Author: rfscholte <[email protected]> AuthorDate: Sat Aug 31 11:31:08 2019 +0200 [MPLUGINTESTING-65] Remove deprecated maven-test-tools module --- maven-test-tools/pom.xml | 49 ---- .../maven/shared/tools/easymock/MockManager.java | 75 ----- .../shared/tools/easymock/TestFileManager.java | 306 --------------------- .../maven/shared/tools/easymock/TestUtils.java | 104 ------- .../maven/shared/tools/test/ReflectiveSetter.java | 168 ----------- maven-test-tools/src/site/apt/index.apt | 32 --- maven-test-tools/src/site/site.xml | 33 --- pom.xml | 2 +- 8 files changed, 1 insertion(+), 768 deletions(-) diff --git a/maven-test-tools/pom.xml b/maven-test-tools/pom.xml deleted file mode 100644 index a33ff82..0000000 --- a/maven-test-tools/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?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 xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - - <parent> - <groupId>org.apache.maven.plugin-testing</groupId> - <artifactId>maven-plugin-testing</artifactId> - <version>3.4.0-SNAPSHOT</version> - </parent> - - <artifactId>maven-test-tools</artifactId> - <name>Maven Testing Tools</name> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> - <dependency> - <groupId>org.easymock</groupId> - <artifactId>easymock</artifactId> - <version>3.2</version> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> - </dependency> - </dependencies> -</project> diff --git a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/MockManager.java b/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/MockManager.java deleted file mode 100644 index 52fccaa..0000000 --- a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/MockManager.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.apache.maven.shared.tools.easymock; - -/* - * 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.util.ArrayList; -import java.util.List; - -import org.easymock.IMocksControl; - -/** - * Manager of IMocksControl - * - * @version $Id$ - * @see IMocksControl - */ -@Deprecated -public class MockManager -{ - private List<IMocksControl> mockControls = new ArrayList<IMocksControl>(); - - /** - * @param control to be add to the manager - */ - public void add( IMocksControl control ) - { - mockControls.add( control ); - } - - /** - * Clear all controls from the manager - */ - public void clear() - { - mockControls.clear(); - } - - /** - * @see MockControl#replay() - */ - public void replayAll() - { - for ( IMocksControl control : mockControls ) - { - control.replay(); - } - } - - /** - * @see MockControl#verify() - */ - public void verifyAll() - { - for ( IMocksControl control : mockControls ) - { - control.verify(); - } - } -} diff --git a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/TestFileManager.java b/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/TestFileManager.java deleted file mode 100644 index b1a3ab9..0000000 --- a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/TestFileManager.java +++ /dev/null @@ -1,306 +0,0 @@ -package org.apache.maven.shared.tools.easymock; - -/* - * 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.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import junit.framework.Assert; - -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.IOUtil; - -/** - * @version $Id$ - */ -@Deprecated -public class TestFileManager -{ - /** Temp dir from "java.io.tmpdir" property */ - public static final String TEMP_DIR_PATH = System.getProperty( "java.io.tmpdir" ); - - private List<File> filesToDelete = new ArrayList<File>(); - - private final String baseFilename; - - private final String fileSuffix; - - private StackTraceElement callerInfo; - - private Thread cleanupWarning; - - private boolean warnAboutCleanup = false; - - /** - * Default constructor - * - * @param baseFilename - * @param fileSuffix - */ - public TestFileManager( String baseFilename, String fileSuffix ) - { - this.baseFilename = baseFilename; - this.fileSuffix = fileSuffix; - - initializeCleanupMonitoring(); - } - - private void initializeCleanupMonitoring() - { - callerInfo = new NullPointerException().getStackTrace()[2]; - - Runnable warning = new Runnable() - { - /** {@inheritDoc} */ - public void run() - { - maybeWarnAboutCleanUp(); - } - - }; - - cleanupWarning = new Thread( warning ); - - Runtime.getRuntime().addShutdownHook( cleanupWarning ); - } - - protected void maybeWarnAboutCleanUp() - { - if ( warnAboutCleanup ) - { - System.out.println( "[WARNING] TestFileManager from: " + callerInfo.getClassName() + " not cleaned up!" ); - } - } - - /** - * @param toDelete - */ - public void markForDeletion( File toDelete ) - { - filesToDelete.add( toDelete ); - warnAboutCleanup = true; - } - - /** - * @return a temp dir - */ - public synchronized File createTempDir() - { - final int sleepDefault = 20; - - try - { - Thread.sleep( sleepDefault ); - } - catch ( InterruptedException e ) - { - // ignored - } - - File dir = new File( TEMP_DIR_PATH, baseFilename + System.currentTimeMillis() ); - - dir.mkdirs(); - markForDeletion( dir ); - - return dir; - } - - /** - * @return a temp file - * @throws IOException if any - * @todo maybe use {@link FileUtils#createTempFile(String, String, File)} - */ - public synchronized File createTempFile() - throws IOException - { - File tempFile = File.createTempFile( baseFilename, fileSuffix ); - tempFile.deleteOnExit(); - markForDeletion( tempFile ); - - return tempFile; - } - - /** - * @throws IOException if any - */ - public void cleanUp() - throws IOException - { - for ( Iterator<File> it = filesToDelete.iterator(); it.hasNext(); ) - { - File file = it.next(); - - if ( file.exists() ) - { - if ( file.isDirectory() ) - { - FileUtils.deleteDirectory( file ); - } - else - { - file.delete(); - } - } - - it.remove(); - } - - warnAboutCleanup = false; - } - - /** - * @param dir - * @param filename - * @param shouldExist - */ - public void assertFileExistence( File dir, String filename, boolean shouldExist ) - { - File file = new File( dir, filename ); - - if ( shouldExist ) - { - Assert.assertTrue( file.exists() ); - } - else - { - Assert.assertFalse( file.exists() ); - } - } - - /** - * @param dir - * @param filename - * @param contentsTest - * @throws IOException if any - */ - public void assertFileContents( File dir, String filename, String contentsTest ) - throws IOException - { - assertFileExistence( dir, filename, true ); - - File file = new File( dir, filename ); - - FileReader reader = null; - StringWriter writer = new StringWriter(); - - try - { - reader = new FileReader( file ); - - IOUtil.copy( reader, writer ); - } - finally - { - IOUtil.close( reader ); - } - - Assert.assertEquals( contentsTest, writer.toString() ); - } - - /** - * @param dir - * @param filename - * @param contents - * @return - * @throws IOException if any - */ - public File createFile( File dir, String filename, String contents ) - throws IOException - { - File file = new File( dir, filename ); - - file.getParentFile().mkdirs(); - - FileWriter writer = null; - - try - { - writer = new FileWriter( file ); - - IOUtil.copy( new StringReader( contents ), writer ); - } - finally - { - IOUtil.close( writer ); - } - - markForDeletion( file ); - - return file; - } - - /** - * @param file - * @return - * @throws IOException if any - */ - public String getFileContents( File file ) - throws IOException - { - String result = null; - - FileReader reader = null; - try - { - reader = new FileReader( file ); - - StringWriter writer = new StringWriter(); - - IOUtil.copy( reader, writer ); - - result = writer.toString(); - } - finally - { - IOUtil.close( reader ); - } - - return result; - } - - /** {@inheritDoc} */ - protected void finalize() - throws Throwable - { - maybeWarnAboutCleanUp(); - - super.finalize(); - } - - /** - * @param filename - * @param content - * @return - * @throws IOException if any - */ - public File createFile( String filename, String content ) - throws IOException - { - File dir = createTempDir(); - return createFile( dir, filename, content ); - } -} diff --git a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/TestUtils.java b/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/TestUtils.java deleted file mode 100644 index 08de619..0000000 --- a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/easymock/TestUtils.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.apache.maven.shared.tools.easymock; - -/* - * 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.BufferedReader; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.codehaus.plexus.util.IOUtil; - -/** - * @version $Id$ - */ -@Deprecated -public final class TestUtils -{ - private TestUtils() - { - //nop - } - - /** - * @param file - * @param testStr - * @throws IOException if any - */ - public static void writeToFile( File file, String testStr ) - throws IOException - { - FileWriter fw = null; - try - { - fw = new FileWriter( file ); - fw.write( testStr ); - } - finally - { - IOUtil.close( fw ); - } - } - - /** - * @param file - * @return - * @throws IOException if any - * @todo maybe used {@link IOUtil#toString(java.io.Reader)} - */ - public static String readFile( File file ) - throws IOException - { - StringBuffer buffer = new StringBuffer(); - - BufferedReader reader = new BufferedReader( new FileReader( file ) ); - - String line = null; - - while ( ( line = reader.readLine() ) != null ) - { - if ( buffer.length() > 0 ) - { - buffer.append( '\n' ); - } - - buffer.append( line ); - } - - return buffer.toString(); - } - - /** - * @param error - * @return - */ - public static String toString( Throwable error ) - { - StringWriter sw = new StringWriter(); - PrintWriter pw = new PrintWriter( sw ); - - error.printStackTrace( pw ); - - return sw.toString(); - } -} diff --git a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/test/ReflectiveSetter.java b/maven-test-tools/src/main/java/org/apache/maven/shared/tools/test/ReflectiveSetter.java deleted file mode 100644 index 9c7ae4b..0000000 --- a/maven-test-tools/src/main/java/org/apache/maven/shared/tools/test/ReflectiveSetter.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.apache.maven.shared.tools.test; - -/* - * 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.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import org.codehaus.plexus.util.ReflectionUtils; -import org.codehaus.plexus.util.StringUtils; - -/** - * @version $Id$ - */ -public class ReflectiveSetter -{ - private Map<String, Setter> cachedPropertySetters = new HashMap<String, Setter>(); - - private final Class<?> targetClass; - - /** - * @param targetClass - */ - public ReflectiveSetter( Class<?> targetClass ) - { - this.targetClass = targetClass; - } - - /** - * @param propertyName - * @param value - * @param target - * @throws Throwable - */ - public void setProperty( String propertyName, Object value, Object target ) - throws Throwable - { - - String preferredMethodName = "set" + StringUtils.capitalizeFirstLetter( propertyName ); - - Setter setter = null; - - Method method = ReflectionUtils.getSetter( preferredMethodName, targetClass ); - - if ( method != null ) - { - setter = new MethodSetter( propertyName, method ); - } - else - { - Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( propertyName, targetClass ); - - setter = new FieldSetter( propertyName, field ); - } - - cachedPropertySetters.put( setter.getProperty(), setter ); - - try - { - setter.set( value, target ); - } - catch ( InvocationTargetException e ) - { - throw e.getTargetException(); - } - } - - private interface Setter - { - void set( Object value, Object target ) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException; - - String getProperty(); - } - - private static class MethodSetter - implements Setter - { - private Method method; - - private String name; - - MethodSetter( String name, Method method ) - { - this.name = name; - this.method = method; - } - - /** {@inheritDoc} */ - public String getProperty() - { - return name; - } - - /** {@inheritDoc} */ - public void set( Object value, Object target ) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException - { - boolean wasAccessible = method.isAccessible(); - - method.setAccessible( true ); - try - { - method.invoke( target, new Object[] { value } ); - } - finally - { - method.setAccessible( wasAccessible ); - } - } - } - - private static class FieldSetter - implements Setter - { - private Field field; - - private String name; - - FieldSetter( String name, Field field ) - { - this.name = name; - this.field = field; - } - - /** {@inheritDoc} */ - public String getProperty() - { - return name; - } - - /** {@inheritDoc} */ - public void set( Object value, Object target ) - throws IllegalArgumentException, IllegalAccessException, InvocationTargetException - { - boolean wasAccessible = field.isAccessible(); - - field.setAccessible( true ); - try - { - field.set( target, value ); - } - finally - { - field.setAccessible( wasAccessible ); - } - } - } -} diff --git a/maven-test-tools/src/site/apt/index.apt b/maven-test-tools/src/site/apt/index.apt deleted file mode 100644 index 7cb8af1..0000000 --- a/maven-test-tools/src/site/apt/index.apt +++ /dev/null @@ -1,32 +0,0 @@ - ------ - Introduction - ------ - Vincent Siveton - ------ - 2008-07-15 - ------ - -~~ 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. - -~~ NOTE: For help with the syntax of this file, see: -~~ http://maven.apache.org/doxia/references/apt-format.html - -Maven Testing Tools - - The Maven Plugin Testing Tools is a framework which encapsulates {{{http://www.easymock.org/}Easymock}} objects to - provide testing mechanisms. diff --git a/maven-test-tools/src/site/site.xml b/maven-test-tools/src/site/site.xml deleted file mode 100644 index b6412d5..0000000 --- a/maven-test-tools/src/site/site.xml +++ /dev/null @@ -1,33 +0,0 @@ -<?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 xmlns="http://maven.apache.org/DECORATION/1.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd"> - <body> - <menu name="Overview"> - <item name="Introduction" href="index.html"/> - <item name="JavaDocs" href="apidocs/index.html"/> - <item name="Source Xref" href="xref/index.html"/> - <!--item name="FAQ" href="faq.html"/--> - </menu> - </body> -</project> diff --git a/pom.xml b/pom.xml index 290edb0..98c032d 100644 --- a/pom.xml +++ b/pom.xml @@ -117,9 +117,9 @@ under the License. <maven>3.1.1</maven> </prerequisites> + <!-- this project used to be a multimodule project. For easy of history comparison structure is kept --> <modules> <module>maven-plugin-testing-harness</module> - <module>maven-test-tools</module> </modules> <scm>
