From 4362cb2b1a0791dc3126e5b49b4afa60182b6e7d Mon Sep 17 00:00:00 2001 From: Robert Gemmell Date: Fri, 11 Apr 2014 16:08:20 +0000 Subject: QPID-5048: remove enforcer rule, it is no longer used git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1586707 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/java/maven/qpid-enforcer-plugin-rules/pom.xml | 93 ------------- .../rule/RequireFileContentsAreEquivalent.java | 104 -------------- .../rule/TestRequireFileContentsAreEquivalent.java | 149 --------------------- 3 files changed, 346 deletions(-) delete mode 100644 qpid/java/maven/qpid-enforcer-plugin-rules/pom.xml delete mode 100644 qpid/java/maven/qpid-enforcer-plugin-rules/src/main/java/org/apache/qpid/maven/enforcer/rule/RequireFileContentsAreEquivalent.java delete mode 100644 qpid/java/maven/qpid-enforcer-plugin-rules/src/test/java/org/apache/qpid/maven/enforcer/rule/TestRequireFileContentsAreEquivalent.java (limited to 'qpid/java') diff --git a/qpid/java/maven/qpid-enforcer-plugin-rules/pom.xml b/qpid/java/maven/qpid-enforcer-plugin-rules/pom.xml deleted file mode 100644 index 47a393b888..0000000000 --- a/qpid/java/maven/qpid-enforcer-plugin-rules/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - - 4.0.0 - - org.apache.qpid.enforcer - qpid-enforcer-plugin-rules - 1.0-SNAPSHOT - Qpid Maven Enforcer Plugin Rules - Custom maven enforcer plugin rules for the Qpid maven build. - - - 1.3.1 - 2.2.1 - 1.5.5 - 4.11 - - - - - org.apache.maven.enforcer - enforcer-rules - ${api.version} - - - org.apache.commons - commons-io - 1.3.2 - - - org.apache.maven.enforcer - enforcer-api - ${api.version} - - - org.apache.maven - maven-project - ${maven.version} - - - org.apache.maven - maven-core - ${maven.version} - - - org.apache.maven - maven-artifact - ${maven.version} - - - org.apache.maven - maven-plugin-api - ${maven.version} - - - org.codehaus.plexus - plexus-container-default - ${plexus.container.version} - - - junit - junit - ${junit.version} - test - - - org.apache.maven.enforcer - enforcer-rules - ${api.version} - test-jar - test - - - - - - - diff --git a/qpid/java/maven/qpid-enforcer-plugin-rules/src/main/java/org/apache/qpid/maven/enforcer/rule/RequireFileContentsAreEquivalent.java b/qpid/java/maven/qpid-enforcer-plugin-rules/src/main/java/org/apache/qpid/maven/enforcer/rule/RequireFileContentsAreEquivalent.java deleted file mode 100644 index 11186a5c7f..0000000000 --- a/qpid/java/maven/qpid-enforcer-plugin-rules/src/main/java/org/apache/qpid/maven/enforcer/rule/RequireFileContentsAreEquivalent.java +++ /dev/null @@ -1,104 +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.qpid.maven.enforcer.rule; - -import java.io.File; -import java.io.IOException; -import java.util.Arrays; - -import org.apache.commons.io.FileUtils; -import org.apache.maven.enforcer.rule.api.EnforcerRule; -import org.apache.maven.enforcer.rule.api.EnforcerRuleException; -import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper; -import org.apache.maven.plugins.enforcer.AbstractStandardEnforcerRule; - -public class RequireFileContentsAreEquivalent extends AbstractStandardEnforcerRule -{ - - final static String WHITESPACE_REGEX = "\\s+"; - final static String EMPTY_STRING = ""; - - File[] files; - - @Override - public void execute(final EnforcerRuleHelper enforcerRuleHelper) throws EnforcerRuleException - { - if (files.length < 2) - { - throw new EnforcerRuleException("The file list must contain at least two files for comparison."); - } - - boolean success = true; - boolean firstTime = true; - String referenceContent = null; - - for (final File file : files) - { - try - { - final String fileContent = FileUtils.readFileToString(file); - if (firstTime) - { - referenceContent = fileContent; - firstTime = false; - } - else if (referenceContent != null && fileContent != null) - { - final String strippedReferenceContent = referenceContent.replaceAll(WHITESPACE_REGEX, EMPTY_STRING); - final String strippedFileContent = fileContent.replaceAll(WHITESPACE_REGEX, EMPTY_STRING); - if (!strippedReferenceContent.equalsIgnoreCase(strippedFileContent)) - { - success = false; - break; - } - } - else - { - throw new EnforcerRuleException("Unable to read file contents"); - } - } - catch (final IOException ioe) - { - throw new EnforcerRuleException("Cannot process file : " + file.getName(), ioe); - } - } - - if (!success) - { - throw new EnforcerRuleException("Files specified are not equal in content"); - } - } - - @Override - public String getCacheId() - { - return Integer.toString(Arrays.hashCode(files)); - } - - @Override - public boolean isCacheable() - { - return true; - } - - @Override - public boolean isResultValid(EnforcerRule arg0) - { - return true; - } - -} diff --git a/qpid/java/maven/qpid-enforcer-plugin-rules/src/test/java/org/apache/qpid/maven/enforcer/rule/TestRequireFileContentsAreEquivalent.java b/qpid/java/maven/qpid-enforcer-plugin-rules/src/test/java/org/apache/qpid/maven/enforcer/rule/TestRequireFileContentsAreEquivalent.java deleted file mode 100644 index 7a5d214972..0000000000 --- a/qpid/java/maven/qpid-enforcer-plugin-rules/src/test/java/org/apache/qpid/maven/enforcer/rule/TestRequireFileContentsAreEquivalent.java +++ /dev/null @@ -1,149 +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.qpid.maven.enforcer.rule; - -import java.io.File; -import java.io.IOException; - -import org.apache.commons.io.FileUtils; -import org.apache.maven.enforcer.rule.api.EnforcerRuleException; -import org.apache.maven.plugins.enforcer.EnforcerTestUtils; -import org.junit.After; -import org.junit.Assert; -import org.junit.Test; - -public class TestRequireFileContentsAreEquivalent -{ - final RequireFileContentsAreEquivalent rule = new RequireFileContentsAreEquivalent(); - - final static String TEST_TEXT = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."; - final static String TEST_TEXT_WHITESPACE = "Lorem ipsum dolor sit amet,\n consectetur adipiscing \t elit. "; - final static String ALTERNATE_TEST_TEXT_WHITESPACE = " Lorem \t ip sum dolor \n sit amet,\n consectetur adipiscing \t elit."; - final static String DIFFERENT_TEST_TEXT = "Donec velit felis, semper dapibus mattis vitae"; - - @Test - public void testDifferentContentFiles() throws Exception - { - final File f1 = createTestFile(1, TEST_TEXT); - final File f2 = createTestFile(2, DIFFERENT_TEST_TEXT); - - rule.files = new File[] - { f1, f2 }; - - try - { - rule.execute(EnforcerTestUtils.getHelper()); - Assert.fail("Files with different content should have failed enforcer rule"); - } - catch (final EnforcerRuleException ere) - { - // do nothing - } - } - - @Test - public void testIdenticalContentFiles() throws Exception - { - final File f1 = createTestFile(1, TEST_TEXT); - final File f2 = createTestFile(2, TEST_TEXT); - - rule.files = new File[] - { f1, f2 }; - - rule.execute(EnforcerTestUtils.getHelper()); - } - - @Test - public void testUsingOneFileTwice() throws Exception - { - final File f1 = createTestFile(1, TEST_TEXT); - - rule.files = new File[] - { f1, f1 }; - - rule.execute(EnforcerTestUtils.getHelper()); - } - - @Test - public void testSimilarFiles() throws Exception - { - final File f1 = createTestFile(1, TEST_TEXT); - final File f2 = createTestFile(2, TEST_TEXT_WHITESPACE); - - rule.files = new File[] - { f1, f2 }; - - rule.execute(EnforcerTestUtils.getHelper()); - } - - @Test - public void testMultipleFilesOneDifferent() throws Exception - { - final File f1 = createTestFile(1, TEST_TEXT); - final File f2 = createTestFile(2, TEST_TEXT_WHITESPACE); - final File f3 = createTestFile(3, ALTERNATE_TEST_TEXT_WHITESPACE); - final File f4 = createTestFile(4, DIFFERENT_TEST_TEXT); - - rule.files = new File[] - { f1, f2, f3, f4 }; - - try - { - rule.execute(EnforcerTestUtils.getHelper()); - Assert.fail("Files with different content should have failed enforcer rule"); - } - catch (final EnforcerRuleException ere) - { - // do nothing - } - } - - @Test - public void testMultipleFilesAllSimilar() throws Exception - { - final File f1 = createTestFile(1, TEST_TEXT); - final File f2 = createTestFile(2, TEST_TEXT); - final File f3 = createTestFile(3, TEST_TEXT_WHITESPACE); - final File f4 = createTestFile(4, ALTERNATE_TEST_TEXT_WHITESPACE); - - rule.files = new File[] - { f1, f2, f3, f4 }; - - rule.execute(EnforcerTestUtils.getHelper()); - } - - @After - public void deleteTestFiles() throws Exception - { - for (File file : rule.files) - { - if (file.exists()) - { - file.delete(); - } - } - } - - private File createTestFile(final int id, final String content) throws IOException - { - final File file = File.createTempFile(TestRequireFileContentsAreEquivalent.class.getName() + - "-testfile" + id, "tmp"); - file.deleteOnExit(); - FileUtils.writeStringToFile(file, content); - return file; - } -} -- cgit v1.2.1