Author: rdonkin
Date: Sun Dec 8 21:51:47 2013
New Revision: 1549342
URL: http://svn.apache.org/r1549342
Log:
Delete RatException
Removed:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/api/RatException.java
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/Report.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/AbstractReport.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/IReportable.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java
creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java
creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/Report.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/Report.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/Report.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/Report.java
Sun Dec 8 21:51:47 2013
@@ -18,6 +18,21 @@
*/
package org.apache.rat;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.PipedReader;
+import java.io.PipedWriter;
+import java.io.PrintStream;
+import java.io.Writer;
+import java.util.List;
+
+import javax.xml.transform.TransformerConfigurationException;
+
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
@@ -31,7 +46,6 @@ import org.apache.commons.io.filefilter.
import org.apache.commons.io.filefilter.OrFileFilter;
import org.apache.commons.io.filefilter.RegexFileFilter;
import org.apache.commons.io.filefilter.WildcardFileFilter;
-import org.apache.rat.api.RatException;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.RatReport;
import org.apache.rat.report.claim.ClaimStatistic;
@@ -41,10 +55,6 @@ import org.apache.rat.report.xml.writer.
import org.apache.rat.walker.ArchiveWalker;
import org.apache.rat.walker.DirectoryWalker;
-import javax.xml.transform.TransformerConfigurationException;
-import java.io.*;
-import java.util.List;
-
public class Report {
private static final char EXCLUDE_CLI = 'e';
@@ -350,7 +360,8 @@ public class Report {
*/
public static void report(PrintStream out, IReportable base, final
InputStream style,
ReportConfiguration pConfiguration)
- throws IOException, TransformerConfigurationException,
InterruptedException, RatException {
+ throws IOException, TransformerConfigurationException,
+ InterruptedException {
report(new OutputStreamWriter(out), base, style, pConfiguration);
}
@@ -369,7 +380,8 @@ public class Report {
*/
public static ClaimStatistic report(Writer out, IReportable base, final
InputStream style,
ReportConfiguration pConfiguration)
- throws IOException, TransformerConfigurationException,
FileNotFoundException, InterruptedException, RatException {
+ throws IOException, TransformerConfigurationException,
+ FileNotFoundException, InterruptedException {
PipedReader reader = new PipedReader();
PipedWriter writer = new PipedWriter(reader);
ReportTransformer transformer = new ReportTransformer(out, style,
reader);
@@ -390,7 +402,8 @@ public class Report {
* @throws RatException
*/
public static ClaimStatistic report(final IReportable container, final
Writer out,
- ReportConfiguration pConfiguration) throws IOException,
RatException {
+ ReportConfiguration pConfiguration)
+ throws IOException {
IXmlWriter writer = new XmlWriter(out);
final ClaimStatistic statistic = new ClaimStatistic();
RatReport report = new XmlReportFactory().createStandardReport(writer,
statistic, pConfiguration);
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
Sun Dec 8 21:51:47 2013
@@ -79,7 +79,7 @@ public class ReportConfiguration {
*/
public void setApprovedLicenseNames(
final ILicenseFamily... approvedLicenseNames) {
- this.approvedLicenseNames = approvedLicenseNames.clone();
+ this.approvedLicenseNames = approvedLicenseNames;
}
/**
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/AbstractReport.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/AbstractReport.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/AbstractReport.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/AbstractReport.java
Sun Dec 8 21:51:47 2013
@@ -21,7 +21,6 @@ package org.apache.rat.report;
import java.io.IOException;
import org.apache.rat.api.Document;
-import org.apache.rat.api.RatException;
/**
* Abstract base class for deriving implementations of {@link RatReport}.
@@ -33,7 +32,7 @@ public abstract class AbstractReport imp
*
* @see org.apache.rat.report.RatReport#startReport()
*/
- public void startReport() throws RatException {
+ public void startReport() throws IOException {
// Does nothing
}
@@ -49,7 +48,7 @@ public abstract class AbstractReport imp
*
* @see org.apache.rat.report.RatReport#endReport()
*/
- public void endReport() throws RatException {
+ public void endReport() throws IOException {
// Does nothing
}
}
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/IReportable.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/IReportable.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/IReportable.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/IReportable.java
Sun Dec 8 21:51:47 2013
@@ -20,8 +20,6 @@ package org.apache.rat.report;
import java.io.IOException;
-import org.apache.rat.api.RatException;
-
/**
* The Interface IReportable.
*/
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/RatReport.java
Sun Dec 8 21:51:47 2013
@@ -21,7 +21,6 @@ package org.apache.rat.report;
import java.io.IOException;
import org.apache.rat.api.Document;
-import org.apache.rat.api.RatException;
/**
* The Interface RatReport.
@@ -34,7 +33,7 @@ public interface RatReport {
* @throws RatException
* the rat exception
*/
- void startReport() throws RatException;
+ void startReport() throws IOException;
/**
* Report.
@@ -52,5 +51,5 @@ public interface RatReport {
* @throws RatException
* the rat exception
*/
- void endReport() throws RatException;
+ void endReport() throws IOException;
}
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/ClaimAggregator.java
Sun Dec 8 21:51:47 2013
@@ -19,11 +19,11 @@
package org.apache.rat.report.claim.impl;
+import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.rat.api.MetaData;
-import org.apache.rat.api.RatException;
import org.apache.rat.report.claim.ClaimStatistic;
/**
@@ -157,7 +157,7 @@ public class ClaimAggregator extends Abs
* @see org.apache.rat.report.AbstractReport#endReport()
*/
@Override
- public void endReport() throws RatException {
+ public void endReport() throws IOException {
super.endReport();
fillClaimStatistic(statistic);
}
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporter.java
Sun Dec 8 21:51:47 2013
@@ -24,7 +24,6 @@ import java.util.Calendar;
import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.rat.api.Document;
import org.apache.rat.api.MetaData;
-import org.apache.rat.api.RatException;
import org.apache.rat.report.AbstractReport;
import org.apache.rat.report.xml.writer.IXmlWriter;
@@ -224,15 +223,11 @@ public class SimpleXmlClaimReporter exte
* @see org.apache.rat.report.AbstractReport#startReport()
*/
@Override
- public void startReport() throws RatException {
- try {
- writer.openElement("rat-report").attribute(
- "timestamp",
-
DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT
-
.format(Calendar.getInstance()));
- } catch (IOException e) {
- throw new RatException("Cannot open start element", e);
- }
+ public void startReport() throws IOException {
+ writer.openElement("rat-report").attribute(
+ "timestamp",
+
DateFormatUtils.ISO_DATETIME_TIME_ZONE_FORMAT.format(Calendar
+ .getInstance()));
}
/*
@@ -241,11 +236,7 @@ public class SimpleXmlClaimReporter exte
* @see org.apache.rat.report.AbstractReport#endReport()
*/
@Override
- public void endReport() throws RatException {
- try {
- writer.closeDocument();
- } catch (IOException e) {
- throw new RatException("Cannot close last element", e);
- }
+ public void endReport() throws IOException {
+ writer.closeDocument();
}
}
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java
Sun Dec 8 21:51:47 2013
@@ -23,7 +23,6 @@ import java.util.List;
import org.apache.rat.analysis.DefaultAnalyser;
import org.apache.rat.api.Document;
-import org.apache.rat.api.RatException;
import org.apache.rat.policy.DefaultPolicy;
import org.apache.rat.report.RatReport;
@@ -83,7 +82,7 @@ public class Pipeline implements RatRepo
*
* @see org.apache.rat.report.RatReport#startReport()
*/
- public void startReport() throws RatException {
+ public void startReport() throws IOException {
for (RatReport report : this.reporters) {
report.startReport();
}
@@ -94,7 +93,7 @@ public class Pipeline implements RatRepo
*
* @see org.apache.rat.report.RatReport#endReport()
*/
- public void endReport() throws RatException {
+ public void endReport() throws IOException {
for (RatReport report : this.reporters) {
report.endReport();
}
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/ArchiveWalker.java
Sun Dec 8 21:51:47 2013
@@ -32,7 +32,6 @@ import org.apache.commons.compress.archi
import
org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
import org.apache.rat.api.Document;
-import org.apache.rat.api.RatException;
import org.apache.rat.document.impl.ArchiveEntryDocument;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.RatReport;
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
Sun Dec 8 21:51:47 2013
@@ -26,7 +26,6 @@ import java.util.Arrays;
import java.util.regex.Pattern;
import org.apache.rat.api.Document;
-import org.apache.rat.api.RatException;
import org.apache.rat.document.impl.FileDocument;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.RatReport;
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/analysis/AnalyserFactoryTest.java
Sun Dec 8 21:51:47 2013
@@ -25,7 +25,6 @@ import java.io.IOException;
import java.io.StringWriter;
import org.apache.rat.api.Document;
-import org.apache.rat.api.RatException;
import org.apache.rat.document.impl.MonolithicFileDocument;
import org.apache.rat.report.claim.impl.xml.SimpleXmlClaimReporter;
import org.apache.rat.report.xml.writer.impl.base.XmlWriter;
@@ -38,189 +37,180 @@ import org.junit.Test;
*/
public class AnalyserFactoryTest {
- /** The out. */
- private StringWriter out;
+ /** The out. */
+ private StringWriter out;
- /** The reporter. */
- private SimpleXmlClaimReporter reporter;
+ /** The reporter. */
+ private SimpleXmlClaimReporter reporter;
- /** The matcher stub. */
- private IHeaderMatcher matcherStub;
+ /** The matcher stub. */
+ private IHeaderMatcher matcherStub;
- /**
- * Sets the up.
- *
- * @throws Exception
- * the exception
- */
- @Before
- public void setUp() throws Exception {
- this.out = new StringWriter();
- final XmlWriter writer = new XmlWriter(this.out);
- this.reporter = new SimpleXmlClaimReporter(writer);
- this.matcherStub = new IHeaderMatcher() {
- public boolean match(final Document subject, final String line) {
- return false;
- }
-
- public void reset() {
- }
- };
- }
-
- /**
- * Standard type analyser.
- *
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws RatException
- * the rat exception
- */
- @Test
- public void testStandardTypeAnalyser() throws IOException, RatException {
- final MonolithicFileDocument document =
- new MonolithicFileDocument(new File(
- "src/test/resources/elements/Text.txt"));
- final DefaultAnalyser analyser = new DefaultAnalyser(this.matcherStub);
- analyser.analyse(document);
- this.reporter.report(document);
- assertEquals(
- "Open standard element",
- "<resource
name='src/test/resources/elements/Text.txt'><header-sample>/*\n"
- + " * Licensed to the Apache Software Foundation (ASF)
under one\n"
- + " * or more contributor license agreements. See the
NOTICE file\n"
- + " * distributed with this work for additional
information\n"
- + " * regarding copyright ownership. The ASF licenses
this file\n"
- + " * to you under the Apache License, Version 2.0
(the \"License\");\n"
- + " * you may not use this file except in compliance
with the License.\n"
- + " * You may obtain a copy of the License at\n"
- + " *\n"
- + " * http://www.apache.org/licenses/LICENSE-2.0\n"
- + " *\n"
- + " * Unless required by applicable law or agreed to
in writing,\n"
- + " * software distributed under the License is
distributed on an\n"
- + " * \"AS IS\" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY\n"
- + " * KIND, either express or implied. See the
License for the\n"
- + " * specific language governing permissions and
limitations\n"
- + " * under the License. \n"
- + " */\n"
- + "\n"
- + " \n"
- + "</header-sample><header-type
name='?????'/><license-family name='?????'/><type name='standard'/>",
- this.out.toString());
- }
-
- /**
- * Note type analyser.
- *
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws RatException
- * the rat exception
- */
- @Test
- public void testNoteTypeAnalyser() throws IOException, RatException {
- final MonolithicFileDocument document =
- new MonolithicFileDocument(
- new File("src/test/elements/LICENSE"));
- final DefaultAnalyser analyser = new DefaultAnalyser(this.matcherStub);
- analyser.analyse(document);
- this.reporter.report(document);
- assertEquals(
- "Open note element",
- "<resource name='src/test/elements/LICENSE'><type
name='notice'/>",
- this.out.toString());
- }
-
- /**
- * Binary type analyser.
- *
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws RatException
- * the rat exception
- */
- @Test
- public void testBinaryTypeAnalyser() throws IOException, RatException {
- final MonolithicFileDocument document =
- new MonolithicFileDocument(new File(
- "src/test/elements/Image.png"));
- final DefaultAnalyser analyser = new DefaultAnalyser(this.matcherStub);
- analyser.analyse(document);
- this.reporter.report(document);
- assertEquals(
- "Open binary element",
- "<resource name='src/test/elements/Image.png'><type
name='binary'/>",
- this.out.toString());
- }
-
- /**
- * Archive type analyser.
- *
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws RatException
- * the rat exception
- */
- @Test
- public void testArchiveTypeAnalyser() throws IOException, RatException {
- final MonolithicFileDocument document =
- new MonolithicFileDocument(new File(
- "src/test/elements/Dummy.jar"));
- final DefaultAnalyser analyser = new DefaultAnalyser(this.matcherStub);
- analyser.analyse(document);
- this.reporter.report(document);
- assertEquals(
- "Open archive element",
- "<resource name='src/test/elements/Dummy.jar'><type
name='archive'/>",
- this.out.toString());
- }
-
- /**
- * Test abstract monolithicis composite.
- */
- @Test
- public void testAbstractMonolithicisComposite() {
- final MonolithicFileDocument document =
- new MonolithicFileDocument(new File(
- "src/test/elements/Dummy.jar"));
- Assert.assertFalse(document.isComposite());
- }
-
- /**
- * Test standard type analyser exception.
- *
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws RatException
- * the rat exception
- */
- @Test(expected = IOException.class)
- public void testStandardTypeAnalyserFileException() throws IOException,
- RatException {
- final MonolithicFileDocument document =
- new MonolithicFileDocument(new File(
- "src/test/resources/elements/Text.txtt"));
- final DefaultAnalyser analyser = new DefaultAnalyser(this.matcherStub);
- analyser.analyse(document);
- }
-
- /**
- * Test note guesser file extensions.
- *
- * @throws IOException
- * Signals that an I/O exception has occurred.
- * @throws RatException
- * the rat exception
- */
- @Test
- public void testNoteGuesserFileExtensions() throws IOException,
- RatException {
- final MonolithicFileDocument document =
- new MonolithicFileDocument(new File(
- "src/test/resources/elements/test.LICENSE"));
- final DefaultAnalyser analyser = new DefaultAnalyser(this.matcherStub);
- analyser.analyse(document);
- Assert.assertEquals(document.getMetaData().getData().size(), 1);
- }
+ /**
+ * Sets the up.
+ *
+ * @throws Exception
+ * the exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ this.out = new StringWriter();
+ final XmlWriter writer = new XmlWriter(this.out);
+ this.reporter = new SimpleXmlClaimReporter(writer);
+ this.matcherStub = new IHeaderMatcher() {
+ public boolean match(final Document subject, final
String line) {
+ return false;
+ }
+
+ public void reset() {
+ }
+ };
+ }
+
+ /**
+ * Standard type analyser.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws RatException
+ * the rat exception
+ */
+ @Test
+ public void testStandardTypeAnalyser() throws IOException {
+ final MonolithicFileDocument document = new
MonolithicFileDocument(
+ new
File("src/test/resources/elements/Text.txt"));
+ final DefaultAnalyser analyser = new
DefaultAnalyser(this.matcherStub);
+ analyser.analyse(document);
+ this.reporter.report(document);
+ assertEquals(
+ "Open standard element",
+ "<resource
name='src/test/resources/elements/Text.txt'><header-sample>/*\n"
+ + " * Licensed to the Apache
Software Foundation (ASF) under one\n"
+ + " * or more contributor
license agreements. See the NOTICE file\n"
+ + " * distributed with this
work for additional information\n"
+ + " * regarding copyright
ownership. The ASF licenses this file\n"
+ + " * to you under the Apache
License, Version 2.0 (the \"License\");\n"
+ + " * you may not use this file
except in compliance with the License.\n"
+ + " * You may obtain a copy of
the License at\n"
+ + " *\n"
+ + " *
http://www.apache.org/licenses/LICENSE-2.0\n"
+ + " *\n"
+ + " * Unless required by
applicable law or agreed to in writing,\n"
+ + " * software distributed
under the License is distributed on an\n"
+ + " * \"AS IS\" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY\n"
+ + " * KIND, either express or
implied. See the License for the\n"
+ + " * specific language
governing permissions and limitations\n"
+ + " * under the License. \n"
+ + " */\n"
+ + "\n"
+ + " \n"
+ + "</header-sample><header-type
name='?????'/><license-family name='?????'/><type name='standard'/>",
+ this.out.toString());
+ }
+
+ /**
+ * Note type analyser.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws RatException
+ * the rat exception
+ */
+ @Test
+ public void testNoteTypeAnalyser() throws IOException {
+ final MonolithicFileDocument document = new
MonolithicFileDocument(
+ new File("src/test/elements/LICENSE"));
+ final DefaultAnalyser analyser = new
DefaultAnalyser(this.matcherStub);
+ analyser.analyse(document);
+ this.reporter.report(document);
+ assertEquals(
+ "Open note element",
+ "<resource
name='src/test/elements/LICENSE'><type name='notice'/>",
+ this.out.toString());
+ }
+
+ /**
+ * Binary type analyser.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws RatException
+ * the rat exception
+ */
+ @Test
+ public void testBinaryTypeAnalyser() throws IOException {
+ final MonolithicFileDocument document = new
MonolithicFileDocument(
+ new File("src/test/elements/Image.png"));
+ final DefaultAnalyser analyser = new
DefaultAnalyser(this.matcherStub);
+ analyser.analyse(document);
+ this.reporter.report(document);
+ assertEquals(
+ "Open binary element",
+ "<resource
name='src/test/elements/Image.png'><type name='binary'/>",
+ this.out.toString());
+ }
+
+ /**
+ * Archive type analyser.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws RatException
+ * the rat exception
+ */
+ @Test
+ public void testArchiveTypeAnalyser() throws IOException {
+ final MonolithicFileDocument document = new
MonolithicFileDocument(
+ new File("src/test/elements/Dummy.jar"));
+ final DefaultAnalyser analyser = new
DefaultAnalyser(this.matcherStub);
+ analyser.analyse(document);
+ this.reporter.report(document);
+ assertEquals(
+ "Open archive element",
+ "<resource
name='src/test/elements/Dummy.jar'><type name='archive'/>",
+ this.out.toString());
+ }
+
+ /**
+ * Test abstract monolithicis composite.
+ */
+ @Test
+ public void testAbstractMonolithicisComposite() {
+ final MonolithicFileDocument document = new
MonolithicFileDocument(
+ new File("src/test/elements/Dummy.jar"));
+ Assert.assertFalse(document.isComposite());
+ }
+
+ /**
+ * Test standard type analyser exception.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws RatException
+ * the rat exception
+ */
+ @Test(expected = IOException.class)
+ public void testStandardTypeAnalyserFileException() throws IOException {
+ final MonolithicFileDocument document = new
MonolithicFileDocument(
+ new
File("src/test/resources/elements/Text.txtt"));
+ final DefaultAnalyser analyser = new
DefaultAnalyser(this.matcherStub);
+ analyser.analyse(document);
+ }
+
+ /**
+ * Test note guesser file extensions.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws RatException
+ * the rat exception
+ */
+ @Test
+ public void testNoteGuesserFileExtensions() throws IOException {
+ final MonolithicFileDocument document = new
MonolithicFileDocument(
+ new
File("src/test/resources/elements/test.LICENSE"));
+ final DefaultAnalyser analyser = new
DefaultAnalyser(this.matcherStub);
+ analyser.analyse(document);
+ Assert.assertEquals(document.getMetaData().getData().size(), 1);
+ }
}
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java
Sun Dec 8 21:51:47 2013
@@ -29,7 +29,6 @@ import java.util.regex.Pattern;
import org.apache.rat.ReportConfiguration;
import org.apache.rat.analysis.MockLicenseMatcher;
import org.apache.rat.api.MetaData;
-import org.apache.rat.api.RatException;
import org.apache.rat.report.RatReport;
import org.apache.rat.report.claim.ClaimStatistic;
import org.apache.rat.report.xml.writer.IXmlWriter;
@@ -91,7 +90,7 @@ public class XmlReportFactoryTest {
* Signals that an I/O exception has occurred.
*/
@Test
- public void testStandardReport() throws RatException, IOException {
+ public void testStandardReport() throws IOException {
final String elementsPath = Resources
.getResourceDirectory("elements/Source.java");
final MockLicenseMatcher mockLicenseMatcher = new
MockLicenseMatcher();
Modified:
creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
Sun Dec 8 21:51:47 2013
@@ -30,7 +30,6 @@ import org.apache.rat.Report;
import org.apache.rat.ReportConfiguration;
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.analysis.util.HeaderMatcherMultiplexer;
-import org.apache.rat.api.RatException;
import org.apache.rat.license.ILicenseFamily;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.claim.ClaimStatistic;
@@ -478,10 +477,6 @@ public abstract class AbstractRatMojo ex
{
throw new MojoExecutionException( e.getMessage(), e );
}
- catch ( RatException e )
- {
- throw new MojoExecutionException( e.getMessage(), e );
- }
}
protected ReportConfiguration getConfiguration() throws
MojoFailureException,
Modified:
creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-plugin/src/main/java/org/apache/rat/mp/FilesReportable.java
Sun Dec 8 21:51:47 2013
@@ -21,7 +21,6 @@ package org.apache.rat.mp;
import org.apache.rat.api.Document;
import org.apache.rat.api.MetaData;
-import org.apache.rat.api.RatException;
import org.apache.rat.document.impl.DocumentImplUtils;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.RatReport;
@@ -59,7 +58,7 @@ class FilesReportable implements IReport
this.files = files;
}
- public void run( RatReport report ) throws RatException
+ public void run( RatReport report ) throws IOException
{
FileDocument document = new FileDocument();
for (String file : files) {
@@ -80,7 +79,7 @@ class FilesReportable implements IReport
}
public boolean isComposite() {
- return DocumentImplUtils.isZip(file);
+ return new DocumentImplUtils().isZip(file);
}
public Reader reader() throws IOException
Modified:
creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
Sun Dec 8 21:51:47 2013
@@ -42,7 +42,6 @@ import org.apache.rat.Defaults;
import org.apache.rat.ReportConfiguration;
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.analysis.util.HeaderMatcherMultiplexer;
-import org.apache.rat.api.RatException;
import org.apache.rat.license.ILicenseFamily;
/**
@@ -199,8 +198,6 @@ public class Report extends Task {
throw new BuildException(e);
} catch (InterruptedException e) {
throw new BuildException(e);
- } catch (RatException e) {
- throw new BuildException(e);
} finally {
if (reportFile != null) {
FileUtils.close(out);
@@ -241,7 +238,7 @@ public class Report extends Task {
* @throws TransformerException
* @throws RatException
*/
- private void createReport(PrintWriter out) throws IOException,
TransformerException, InterruptedException, RatException {
+ private void createReport(PrintWriter out) throws IOException,
TransformerException, InterruptedException {
final ReportConfiguration configuration = new ReportConfiguration();
configuration.setHeaderMatcher(new
HeaderMatcherMultiplexer(getLicenseMatchers()));
configuration.setApprovedLicenseNames(getApprovedLicenseNames());
Modified:
creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java?rev=1549342&r1=1549341&r2=1549342&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/ResourceCollectionContainer.java
Sun Dec 8 21:51:47 2013
@@ -27,7 +27,6 @@ import java.util.Iterator;
import org.apache.rat.api.Document;
import org.apache.rat.api.MetaData;
-import org.apache.rat.api.RatException;
import org.apache.rat.document.impl.DocumentImplUtils;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.RatReport;
@@ -46,7 +45,7 @@ class ResourceCollectionContainer implem
this.rc = rc;
}
- public void run(RatReport report) throws RatException {
+ public void run(RatReport report) throws IOException {
ResourceDocument document = new ResourceDocument();
for (Iterator<?> iter = rc.iterator(); iter.hasNext(); ) {
Resource r = (Resource) iter.next();
@@ -89,7 +88,7 @@ class ResourceCollectionContainer implem
if (resource instanceof FileResource) {
final FileResource fileResource = (FileResource) resource;
final File file = fileResource.getFile();
- return DocumentImplUtils.isZip(file);
+ return new DocumentImplUtils().isZip(file);
}
return false;
}