summaryrefslogtreecommitdiff
path: root/qpid/java
diff options
context:
space:
mode:
authorRobert Gemmell <robbie@apache.org>2014-04-11 16:08:20 +0000
committerRobert Gemmell <robbie@apache.org>2014-04-11 16:08:20 +0000
commit4362cb2b1a0791dc3126e5b49b4afa60182b6e7d (patch)
tree017ae86b217b5dd0208d0b5a9dd0d464a1748382 /qpid/java
parent58a7f5e8759446fd6c2cc5876581bc414d78d9bd (diff)
downloadqpid-python-4362cb2b1a0791dc3126e5b49b4afa60182b6e7d.tar.gz
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
Diffstat (limited to 'qpid/java')
-rw-r--r--qpid/java/maven/qpid-enforcer-plugin-rules/pom.xml93
-rw-r--r--qpid/java/maven/qpid-enforcer-plugin-rules/src/main/java/org/apache/qpid/maven/enforcer/rule/RequireFileContentsAreEquivalent.java104
-rw-r--r--qpid/java/maven/qpid-enforcer-plugin-rules/src/test/java/org/apache/qpid/maven/enforcer/rule/TestRequireFileContentsAreEquivalent.java149
3 files changed, 0 insertions, 346 deletions
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 @@
-<?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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.qpid.enforcer</groupId>
- <artifactId>qpid-enforcer-plugin-rules</artifactId>
- <version>1.0-SNAPSHOT</version>
- <name>Qpid Maven Enforcer Plugin Rules</name>
- <description>Custom maven enforcer plugin rules for the Qpid maven build.</description>
-
- <properties>
- <api.version>1.3.1</api.version>
- <maven.version>2.2.1</maven.version>
- <plexus.container.version>1.5.5</plexus.container.version>
- <junit.version>4.11</junit.version>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.enforcer</groupId>
- <artifactId>enforcer-rules</artifactId>
- <version>${api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.commons</groupId>
- <artifactId>commons-io</artifactId>
- <version>1.3.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.enforcer</groupId>
- <artifactId>enforcer-api</artifactId>
- <version>${api.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>${maven.version}</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>${plexus.container.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.enforcer</groupId>
- <artifactId>enforcer-rules</artifactId>
- <version>${api.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- </build>
-
-</project>
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;
- }
-}