creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1549163 - in /creadur/rat/branches/gsoc/apache-rat-core/src: main/java/org/apache/rat/analysis/ main/java/org/apache/rat/document/impl/util/ main/java/org/apache/rat/policy/ main/java/org/apache/rat/report/claim/util/ main/java/org/apache/...
Date Sun, 08 Dec 2013 19:50:07 GMT
Author: rdonkin
Date: Sun Dec  8 19:50:07 2013
New Revision: 1549163

URL: http://svn.apache.org/r1549163
Log:
Moving towards a more simple and direct implementation of the pipeline.

Added:
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java
      - copied, changed from r1549162, creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java
Removed:
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/document/impl/util/DocumentAnalyserMultiplexer.java
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java
    creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/document/impl/util/DocumentAnalyserMultiplexerTest.java
Modified:
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyser.java
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java
    creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.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/XmlReportTest.java

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyser.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyser.java?rev=1549163&r1=1549162&r2=1549163&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyser.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/analysis/DefaultAnalyser.java
Sun Dec  8 19:50:07 2013
@@ -22,7 +22,6 @@ import java.io.IOException;
 
 import org.apache.rat.api.Document;
 import org.apache.rat.api.MetaData;
-import org.apache.rat.document.IDocumentAnalyser;
 import org.apache.rat.document.impl.guesser.ArchiveGuesser;
 import org.apache.rat.document.impl.guesser.BinaryGuesser;
 import org.apache.rat.document.impl.guesser.NoteGuesser;
@@ -30,7 +29,7 @@ import org.apache.rat.document.impl.gues
 /**
  * The Class DefaultAnalyser.
  */
-public final class DefaultAnalyser implements IDocumentAnalyser {
+public final class DefaultAnalyser {
 
     /** The matcher. */
     private final IHeaderMatcher matcher;

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java?rev=1549163&r1=1549162&r2=1549163&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java
Sun Dec  8 19:50:07 2013
@@ -18,7 +18,6 @@
  */
 package org.apache.rat.policy;
 
-
 import static org.apache.rat.api.domain.RatLicenseFamily.APACHE;
 import static org.apache.rat.api.domain.RatLicenseFamily.CDDL1;
 import static org.apache.rat.api.domain.RatLicenseFamily.MIT;
@@ -32,22 +31,20 @@ import java.util.Arrays;
 import org.apache.rat.api.Document;
 import org.apache.rat.api.MetaData;
 import org.apache.rat.api.MetaData.Datum;
-import org.apache.rat.document.IDocumentAnalyser;
 import org.apache.rat.license.ILicenseFamily;
 
-public class DefaultPolicy implements IDocumentAnalyser {
-       private static final String[] APPROVED_LICENSES = { APACHE.getName(),
-                   OASIS.getName(),
-                   W3C.getName(), W3C_DOCUMENTATION.getName(),
-                   TMF854.getName(),
-                   MIT.getName(), CDDL1.getName(), };
+public class DefaultPolicy {
+    private static final String[] APPROVED_LICENSES = { APACHE.getName(),
+            OASIS.getName(), W3C.getName(), W3C_DOCUMENTATION.getName(),
+            TMF854.getName(), MIT.getName(), CDDL1.getName(), };
 
-    private static final String[] toNames(final ILicenseFamily[] approvedLicenses) {
+    private static final String[] toNames(
+            final ILicenseFamily[] approvedLicenses) {
         String[] results = null;
         if (approvedLicenses != null) {
             final int length = approvedLicenses.length;
             results = new String[length];
-            for (int i=0;i<length;i++) {
+            for (int i = 0; i < length; i++) {
                 results[i] = approvedLicenses[i].getFamilyName();
             }
         }
@@ -70,12 +67,14 @@ public class DefaultPolicy implements ID
         } else {
             final int length = approvedLicenseNames.length;
             this.approvedLicenseNames = new String[length];
-            System.arraycopy(approvedLicenseNames, 0, this.approvedLicenseNames, 0, length);
+            System.arraycopy(approvedLicenseNames, 0,
+                    this.approvedLicenseNames, 0, length);
         }
         Arrays.sort(this.approvedLicenseNames);
     }
 
-    public void reportLicenseApprovalClaim(final Document subject, final boolean isAcceptable)
{
+    public void reportLicenseApprovalClaim(final Document subject,
+            final boolean isAcceptable) {
         final Datum datum;
         if (isAcceptable) {
             datum = MetaData.RAT_APPROVED_LICENSE_DATIM_TRUE;
@@ -87,9 +86,11 @@ public class DefaultPolicy implements ID
 
     public void analyse(final Document subject) {
         if (subject != null) {
-            final String name = subject.getMetaData().value(MetaData.RAT_URL_LICENSE_FAMILY_NAME);
+            final String name = subject.getMetaData().value(
+                    MetaData.RAT_URL_LICENSE_FAMILY_NAME);
             if (name != null) {
-                final boolean isApproved = Arrays.binarySearch(approvedLicenseNames, name)
>= 0;
+                final boolean isApproved = Arrays.binarySearch(
+                        approvedLicenseNames, name) >= 0;
                 reportLicenseApprovalClaim(subject, isApproved);
             }
         }

Copied: creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java
(from r1549162, creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.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?p2=creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java&p1=creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java&r1=1549162&r2=1549163&rev=1549163&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexer.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/claim/util/Pipeline.java
Sun Dec  8 19:50:07 2013
@@ -15,48 +15,59 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.report.claim.util;
 
+import java.io.IOException;
+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.document.IDocumentAnalyser;
+import org.apache.rat.policy.DefaultPolicy;
 import org.apache.rat.report.RatReport;
 
-import java.util.List;
+public class Pipeline implements RatReport {
 
-
-public class ClaimReporterMultiplexer implements RatReport {
-    private final IDocumentAnalyser analyser;
+    private final DefaultAnalyser analyser;
+    private final DefaultPolicy policy;
     private final List<? extends RatReport> reporters;
 
-    public ClaimReporterMultiplexer(final IDocumentAnalyser pAnalyser, final List<? extends
RatReport> reporters) {
-        analyser = pAnalyser;
+    public Pipeline(final DefaultAnalyser analyser, final DefaultPolicy policy,
+            final List<? extends RatReport> reporters) {
+        super();
+        this.analyser = analyser;
+        this.policy = policy;
         this.reporters = reporters;
     }
 
-    public void report(Document document) throws RatException {
-        if (analyser != null) {
+    public void report(final Document document) throws RatException {
+        if (this.analyser != null) {
             try {
-                analyser.analyse(document);
-            } catch (Exception e) {
+                this.analyser.analyse(document);
+            } catch (final IOException e) {
                 throw new RatException(e.getMessage(), e);
             }
         }
-        for (RatReport report : reporters) {
+
+        if (this.policy != null) {
+            this.policy.analyse(document);
+        }
+
+        for (final RatReport report : this.reporters) {
             report.report(document);
-        } 
+        }
     }
 
     public void startReport() throws RatException {
-        for (RatReport report : reporters) {
+        for (final RatReport report : this.reporters) {
             report.startReport();
-        } 
+        }
     }
 
     public void endReport() throws RatException {
-        for (RatReport report : reporters) {
+        for (final RatReport report : this.reporters) {
             report.endReport();
-        } 
+        }
     }
 }

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java?rev=1549163&r1=1549162&r2=1549163&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java
Sun Dec  8 19:50:07 2013
@@ -23,15 +23,13 @@ import java.util.List;
 
 import org.apache.rat.ReportConfiguration;
 import org.apache.rat.analysis.DefaultAnalyser;
-import org.apache.rat.document.IDocumentAnalyser;
-import org.apache.rat.document.impl.util.DocumentAnalyserMultiplexer;
 import org.apache.rat.policy.DefaultPolicy;
 import org.apache.rat.report.RatReport;
 import org.apache.rat.report.claim.ClaimStatistic;
 import org.apache.rat.report.claim.impl.ClaimAggregator;
 import org.apache.rat.report.claim.impl.xml.SimpleXmlClaimReporter;
-import org.apache.rat.report.claim.util.ClaimReporterMultiplexer;
 import org.apache.rat.report.claim.util.LicenseAddingReport;
+import org.apache.rat.report.claim.util.Pipeline;
 import org.apache.rat.report.xml.writer.IXmlWriter;
 
 /**
@@ -52,13 +50,10 @@ public class XmlReportFactory {
                     .isAddingLicensesForced()));
         }
         reporters.add(new SimpleXmlClaimReporter(writer));
-        final IDocumentAnalyser analyser =
+        final DefaultAnalyser analyser =
                 new DefaultAnalyser(pConfiguration.getHeaderMatcher());
         final DefaultPolicy policy =
                 new DefaultPolicy(pConfiguration.getApprovedLicenseNames());
-        final IDocumentAnalyser[] analysers = { analyser, policy };
-        final DocumentAnalyserMultiplexer analysisMultiplexer =
-                new DocumentAnalyserMultiplexer(analysers);
-        return new ClaimReporterMultiplexer(analysisMultiplexer, reporters);
+        return new Pipeline(analyser, policy, reporters);
     }
 }

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=1549163&r1=1549162&r2=1549163&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 19:50:07 2013
@@ -26,7 +26,6 @@ import java.io.StringWriter;
 
 import org.apache.rat.api.Document;
 import org.apache.rat.api.RatException;
-import org.apache.rat.document.IDocumentAnalyser;
 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;
@@ -39,181 +38,189 @@ 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 {
-		out = new StringWriter();
-		XmlWriter writer = new XmlWriter(out);
-		reporter = new SimpleXmlClaimReporter(writer);
-		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 {
-		MonolithicFileDocument document = new MonolithicFileDocument(new File(
-				"src/test/resources/elements/Text.txt"));
-		IDocumentAnalyser analyser = new DefaultAnalyser(matcherStub);
-		analyser.analyse(document);
-		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'/>",
-				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 {
-		MonolithicFileDocument document = new MonolithicFileDocument(new File(
-				"src/test/elements/LICENSE"));
-		IDocumentAnalyser analyser = new DefaultAnalyser(matcherStub);
-		analyser.analyse(document);
-		reporter.report(document);
-		assertEquals(
-				"Open note element",
-				"<resource name='src/test/elements/LICENSE'><type name='notice'/>",
-				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 {
-		MonolithicFileDocument document = new MonolithicFileDocument(new File(
-				"src/test/elements/Image.png"));
-		IDocumentAnalyser analyser = new DefaultAnalyser(matcherStub);
-		analyser.analyse(document);
-		reporter.report(document);
-		assertEquals(
-				"Open binary element",
-				"<resource name='src/test/elements/Image.png'><type name='binary'/>",
-				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 {
-		MonolithicFileDocument document = new MonolithicFileDocument(new File(
-				"src/test/elements/Dummy.jar"));
-		IDocumentAnalyser analyser = new DefaultAnalyser(matcherStub);
-		analyser.analyse(document);
-		reporter.report(document);
-		assertEquals(
-				"Open archive element",
-				"<resource name='src/test/elements/Dummy.jar'><type name='archive'/>",
-				out.toString());
-	}
-
-	/**
-	 * Test abstract monolithicis composite.
-	 */
-	@Test
-	public void testAbstractMonolithicisComposite() {
-		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 {
-		MonolithicFileDocument document = new MonolithicFileDocument(new File(
-				"src/test/resources/elements/Text.txtt"));
-		IDocumentAnalyser analyser = new DefaultAnalyser(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 {
-		MonolithicFileDocument document = new MonolithicFileDocument(new File(
-				"src/test/resources/elements/test.LICENSE"));
-		IDocumentAnalyser analyser = new DefaultAnalyser(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, 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);
+    }
 }

Modified: creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportTest.java?rev=1549163&r1=1549162&r2=1549163&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportTest.java
(original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/report/xml/XmlReportTest.java
Sun Dec  8 19:50:07 2013
@@ -29,11 +29,10 @@ import java.util.regex.Pattern;
 import org.apache.rat.analysis.DefaultAnalyser;
 import org.apache.rat.analysis.IHeaderMatcher;
 import org.apache.rat.api.Document;
-import org.apache.rat.document.IDocumentAnalyser;
 import org.apache.rat.report.AbstractReport;
 import org.apache.rat.report.RatReport;
 import org.apache.rat.report.claim.impl.xml.SimpleXmlClaimReporter;
-import org.apache.rat.report.claim.util.ClaimReporterMultiplexer;
+import org.apache.rat.report.claim.util.Pipeline;
 import org.apache.rat.report.xml.writer.IXmlWriter;
 import org.apache.rat.report.xml.writer.impl.base.XmlWriter;
 import org.apache.rat.test.utils.Resources;
@@ -64,10 +63,10 @@ public class XmlReportTest {
             public void reset() {
             }
         };
-        final IDocumentAnalyser analyser = new DefaultAnalyser(matcher);
+        final DefaultAnalyser analyser = new DefaultAnalyser(matcher);
         final List<AbstractReport> reporters = new ArrayList<AbstractReport>();
         reporters.add(reporter);
-        this.report = new ClaimReporterMultiplexer(analyser, reporters);
+        this.report = new Pipeline(analyser, null, reporters);
     }
 
     private void report(final DirectoryWalker directory) throws Exception {



Mime
View raw message