You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by jo...@apache.org on 2008/05/12 22:12:49 UTC
svn commit: r655625 [7/8] - in /incubator/rat/main/trunk/rat: ./
rat-anttasks/ rat-anttasks/src/ rat-anttasks/src/main/
rat-anttasks/src/main/java/ rat-anttasks/src/main/java/org/
rat-anttasks/src/main/java/org/apache/ rat-anttasks/src/main/java/org/ap...
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/analyser/ReadableArchiveAnalyserTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/analyser/ReadableArchiveAnalyserTest.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/analyser/ReadableArchiveAnalyserTest.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/analyser/ReadableArchiveAnalyserTest.java Mon May 12 13:12:44 2008
@@ -0,0 +1,53 @@
+/*
+ * 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.rat.report.analyser;
+
+import org.apache.rat.document.MockArchiveDocument;
+import org.apache.rat.document.MockDocument;
+import org.apache.rat.document.MockDocumentCollection;
+import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
+import junit.framework.TestCase;
+
+public class ReadableArchiveAnalyserTest extends TestCase {
+
+ MockClaimReporter reporter;
+ ReadableArchiveAnalyser analyser;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ reporter = new MockClaimReporter();
+ analyser = new ReadableArchiveAnalyser(reporter);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testUnreadableArchiveToObject() throws Exception {
+ MockDocument document = new MockDocument();
+ assertEquals("Document is unreadable", ReadableArchiveAnalyser.UNREADABLE_ARCHIVE_VALUE,
+ analyser.toObject(document));
+ }
+
+ public void testReadableArchiveToObject() throws Exception {
+ MockArchiveDocument document = new MockArchiveDocument("whatever", new MockDocumentCollection());
+ assertEquals("Document is readable", ReadableArchiveAnalyser.READABLE_ARCHIVE_VALUE,
+ analyser.toObject(document));
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/MockClaimReporter.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/MockClaimReporter.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/MockClaimReporter.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/MockClaimReporter.java Mon May 12 13:12:44 2008
@@ -0,0 +1,66 @@
+/*
+ * 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.rat.report.claim.impl.xml;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.rat.report.RatReportFailedException;
+import org.apache.rat.report.claim.IClaimReporter;
+
+public class MockClaimReporter implements IClaimReporter {
+
+ public List claims = new ArrayList();
+
+ public void claim(CharSequence subject, CharSequence predicate,
+ CharSequence object, boolean isLiteral)
+ throws RatReportFailedException {
+ claims.add(new Claim(subject, predicate, object, isLiteral));
+ }
+
+ public Claim getClaim(int index) {
+ return (Claim) claims.get(index);
+ }
+
+ public static class Claim {
+ public final CharSequence subject;
+ public final CharSequence predicate;
+ public final CharSequence object;
+ public final boolean isLiteral;
+ public Claim(final CharSequence subject, final CharSequence predicate, final CharSequence object, final boolean isLiteral) {
+ super();
+ this.subject = subject;
+ this.predicate = predicate;
+ this.object = object;
+ this.isLiteral = isLiteral;
+ }
+
+ public boolean equals(Object obj) {
+ boolean result = false;
+ if (obj instanceof Claim) {
+ Claim claim = (Claim) obj;
+ result = subject.equals(claim.subject) && predicate.equals(claim.predicate)
+ && object.equals(claim.object) && isLiteral == claim.isLiteral;
+ }
+ return result;
+ }
+
+
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporterTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporterTest.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporterTest.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/impl/xml/SimpleXmlClaimReporterTest.java Mon May 12 13:12:44 2008
@@ -0,0 +1,93 @@
+/*
+ * 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.rat.report.claim.impl.xml;
+
+import junit.framework.TestCase;
+import org.apache.rat.report.xml.MockXmlWriter;
+
+public class SimpleXmlClaimReporterTest extends TestCase {
+
+ MockXmlWriter mockWriter;
+ SimpleXmlClaimReporter reporter;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ mockWriter = new MockXmlWriter();
+ reporter = new SimpleXmlClaimReporter(mockWriter);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testClaimsAboutOneResource() throws Exception {
+ final String subject = "subject";
+ final String predicate = "predicate";
+ final String object = "object";
+ reporter.claim(subject, predicate, object, false);
+ assertEquals("Five calls made", 5, mockWriter.calls.size());
+ assertTrue("First call is open element 'resource'", mockWriter.isOpenElement("resource", 0));
+ assertTrue("Second call is name attribute", mockWriter.isAttribute("name", subject, 1));
+ assertTrue("Third call is predicate element", mockWriter.isOpenElement(predicate, 2));
+ assertTrue("Forth call is object attribute", mockWriter.isAttribute("name", object, 3));
+ assertTrue("Fifth call is close element", mockWriter.isCloseElement(4));
+ final String predicateTwo = "another-predicate";
+ final String objectTwo = "another-object";
+ reporter.claim(subject, predicateTwo, objectTwo, false);
+ assertEquals("Another three calls made", 8, mockWriter.calls.size());
+ assertTrue("Sixth call is predicate element", mockWriter.isOpenElement(predicateTwo, 5));
+ assertTrue("Seventh call is object attribute", mockWriter.isAttribute("name", objectTwo, 6));
+ assertTrue("Eighth call is close element", mockWriter.isCloseElement(7));
+ }
+
+ public void testClaimsAboutTwoResource() throws Exception {
+ final String subject = "subject";
+ final String predicate = "predicate";
+ final String object = "object";
+ reporter.claim(subject, predicate, object, false);
+ assertEquals("Five calls made", 5, mockWriter.calls.size());
+ assertTrue("First call is open element 'resource'", mockWriter.isOpenElement("resource", 0));
+ assertTrue("Second call is name attribute", mockWriter.isAttribute("name", subject, 1));
+ assertTrue("Third call is predicate element", mockWriter.isOpenElement(predicate, 2));
+ assertTrue("Forth call is object attribute", mockWriter.isAttribute("name", object, 3));
+ assertTrue("Fifth call is close element", mockWriter.isCloseElement(4));
+ final String subjectTwo = "another-subject";
+ reporter.claim(subjectTwo, predicate, object, false);
+ assertEquals("Another found calls made", 11, mockWriter.calls.size());
+ assertTrue("Sixth call is close element", mockWriter.isCloseElement(5));
+ assertTrue("Seventh call is open element 'resource'", mockWriter.isOpenElement("resource", 6));
+ assertTrue("Eighth call is name attribute", mockWriter.isAttribute("name", subjectTwo, 7));
+ assertTrue("Nineth call is predicate element", mockWriter.isOpenElement(predicate, 8));
+ assertTrue("Tenth call is object attribute", mockWriter.isAttribute("name", object, 9));
+ assertTrue("Eleventh call is close element", mockWriter.isCloseElement(10));
+ }
+
+ public void testLiteralClaim() throws Exception {
+ final String subject = "subject";
+ final String predicate = "predicate";
+ final String object = "object";
+ reporter.claim(subject, predicate, object, true);
+ assertEquals("Five calls made", 5, mockWriter.calls.size());
+ assertTrue("First call is open element 'resource'", mockWriter.isOpenElement("resource", 0));
+ assertTrue("Second call is name attribute", mockWriter.isAttribute("name", subject, 1));
+ assertTrue("Third call is predicate element", mockWriter.isOpenElement(predicate, 2));
+ assertTrue("Forth call is object content", mockWriter.isContent(object, 3));
+ assertTrue("Fifth call is close element", mockWriter.isCloseElement(4));
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexerTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexerTest.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexerTest.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/claim/util/ClaimReporterMultiplexerTest.java Mon May 12 13:12:44 2008
@@ -0,0 +1,65 @@
+/*
+ * 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.rat.report.claim.util;
+
+import org.apache.rat.report.claim.IClaimReporter;
+import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
+import junit.framework.TestCase;
+
+public class ClaimReporterMultiplexerTest extends TestCase {
+
+ MockClaimReporter reporterOne;
+ MockClaimReporter reporterTwo;
+ MockClaimReporter reporterThree;
+ ClaimReporterMultiplexer multiplexer;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ reporterOne = new MockClaimReporter();
+ reporterTwo = new MockClaimReporter();
+ reporterThree = new MockClaimReporter();
+ IClaimReporter[] reporters = {reporterOne, reporterTwo, reporterThree};
+ multiplexer = new ClaimReporterMultiplexer(reporters);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testClaim() throws Exception {
+ multiplexer.claim("subject", "predicate", "object", true);
+ MockClaimReporter.Claim claimOne = new MockClaimReporter.Claim("subject", "predicate", "object", true);
+ assertEquals("Claim reported", 1 , reporterOne.claims.size());
+ assertEquals("Claim reported", claimOne, reporterOne.claims.get(0));
+ assertEquals("Claim reported", 1 , reporterTwo.claims.size());
+ assertEquals("Claim reported", claimOne, reporterTwo.claims.get(0));
+ assertEquals("Claim reported", 1 , reporterThree.claims.size());
+ assertEquals("Claim reported", claimOne, reporterThree.claims.get(0));
+ multiplexer.claim("another subject", "another predicate", "another object", false);
+ MockClaimReporter.Claim claimTwo = new MockClaimReporter.Claim("another subject", "another predicate", "another object", false);
+ assertEquals("Claim reported", 2, reporterOne.claims.size());
+ assertEquals("Claim reported", claimTwo, reporterOne.claims.get(1));
+ assertEquals("Claim reported", 2, reporterTwo.claims.size());
+ assertEquals("Claim reported", claimTwo, reporterTwo.claims.get(1));
+ assertEquals("Claim reported", 2, reporterThree.claims.size());
+ assertEquals("Claim reported", claimTwo, reporterThree.claims.get(1));
+
+ }
+
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/MockXmlWriter.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/MockXmlWriter.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/MockXmlWriter.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/MockXmlWriter.java Mon May 12 13:12:44 2008
@@ -0,0 +1,126 @@
+/*
+ * 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.rat.report.xml;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.rat.report.xml.writer.IXmlWriter;
+
+public class MockXmlWriter implements IXmlWriter {
+
+ public final List calls;
+
+ public MockXmlWriter() {
+ calls = new ArrayList();
+ }
+
+ public IXmlWriter attribute(CharSequence name, CharSequence value)
+ throws IOException {
+ calls.add(new Attribute(name, value));
+ return this;
+ }
+
+ public IXmlWriter closeDocument() throws IOException {
+ calls.add(new CloseDocument());
+ return this;
+ }
+
+ public IXmlWriter closeElement() throws IOException {
+ calls.add(new CloseElement());
+ return this;
+ }
+
+ public IXmlWriter content(CharSequence content) throws IOException {
+ calls.add(new Content(content));
+ return this;
+ }
+
+ public IXmlWriter openElement(CharSequence elementName) throws IOException {
+ calls.add(new OpenElement(elementName));
+ return this;
+ }
+
+ public IXmlWriter startDocument() throws IOException {
+ calls.add(new StartDocument());
+ return this;
+ }
+
+ public boolean isCloseElement(int index) {
+ boolean result = false;
+ final Object call = calls.get(index);
+ result = call instanceof CloseElement;
+ return result;
+ }
+
+ public boolean isContent(String content, int index) {
+ boolean result = false;
+ final Object call = calls.get(index);
+ if (call instanceof Content) {
+ Content contentCall = (Content) call;
+ result = content.equals(contentCall.content);
+ }
+ return result;
+ }
+
+ public boolean isOpenElement(String name, int index) {
+ boolean result = false;
+ final Object call = calls.get(index);
+ if (call instanceof OpenElement) {
+ OpenElement openElement = (OpenElement) call;
+ result = name.equals(openElement.elementName);
+ }
+ return result;
+ }
+
+ public boolean isAttribute(String name, String value, int index) {
+ boolean result = false;
+ final Object call = calls.get(index);
+ if (call instanceof Attribute) {
+ Attribute attribute = (Attribute) call;
+ result = name.equals(attribute.name) && value.equals(attribute.value);
+ }
+ return result;
+ }
+
+ public class StartDocument {}
+ public class CloseDocument {}
+ public class CloseElement {}
+ public class OpenElement {
+ public final CharSequence elementName;
+ private OpenElement(CharSequence elementName) {
+ this.elementName = elementName;
+ }
+ }
+ public class Content {
+ public final CharSequence content;
+ private Content(CharSequence content) {
+ this.content = content;
+ }
+ }
+ public class Attribute {
+ public final CharSequence name;
+ public final CharSequence value;
+ private Attribute(CharSequence name, CharSequence value) {
+ this.name = name;
+ this.value = value;
+ }
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlReportFactoryTest.java Mon May 12 13:12:44 2008
@@ -0,0 +1,83 @@
+/*
+ * 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.rat.report.xml;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.apache.rat.DirectoryWalker;
+import org.apache.rat.analysis.MockLicenseMatcher;
+import org.apache.rat.report.RatReport;
+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;
+
+public class XmlReportFactoryTest extends TestCase {
+
+ private static final Pattern IGNORE_EMPTY = Pattern.compile(".svn|Empty.txt");
+
+ StringWriter out;
+ IXmlWriter writer;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ out = new StringWriter();
+ writer = new XmlWriter(out);
+ writer.startDocument();
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+ private void report(DirectoryWalker directory, RatReport report) throws Exception {
+ directory.run(report);
+ }
+
+ public void testStandardReport() throws Exception {
+ final String elementsPath = Resources.getResourceDirectory("elements/Source.java");
+ final MockLicenseMatcher mockLicenseMatcher = new MockLicenseMatcher();
+ DirectoryWalker directory = new DirectoryWalker(new File(elementsPath), IGNORE_EMPTY);
+ RatReport report = XmlReportFactory.createStandardReport(writer, mockLicenseMatcher);
+ report.startReport();
+ report(directory, report);
+ report.endReport();
+ writer.closeDocument();
+ final String output = out.toString();
+ assertEquals(
+ "<?xml version='1.0'?>" +
+ "<rat-report>" +
+ "<resource name='" + elementsPath + "/Image.png'><type name='binary'/></resource>" +
+ "<resource name='" + elementsPath + "/LICENSE'><type name='notice'/></resource>" +
+ "<resource name='" + elementsPath + "/NOTICE'><type name='notice'/></resource>" +
+ "<resource name='" + elementsPath + "/Source.java'><type name='standard'/>" +
+ "</resource>" +
+ "<resource name='" + elementsPath + "/Text.txt'><type name='standard'/>" +
+ "</resource>" +
+ "<resource name='" + elementsPath + "/Xml.xml'><type name='standard'/>" +
+ "</resource>" +
+ "<resource name='" + elementsPath + "/dummy.jar'><type name='archive'/><archive-type name='readable'/></resource>" +
+ "</rat-report>", output);
+ assertTrue("Is well formed", XmlUtils.isWellFormedXml(output));
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlReportTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlReportTest.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlReportTest.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlReportTest.java Mon May 12 13:12:44 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.rat.report.xml;
+
+import java.io.File;
+import java.io.StringWriter;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.apache.rat.DirectoryWalker;
+import org.apache.rat.document.IDocumentAnalyser;
+import org.apache.rat.report.analyser.DefaultAnalyserFactory;
+import org.apache.rat.report.claim.impl.xml.SimpleXmlClaimReporter;
+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;
+
+public class XmlReportTest extends TestCase {
+
+ private static final Pattern IGNORE = Pattern.compile(".svn");
+ StringWriter out;
+ IXmlWriter writer;
+ XmlReport report;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ out = new StringWriter();
+ writer = new XmlWriter(out);
+ writer.startDocument();
+ final SimpleXmlClaimReporter reporter = new SimpleXmlClaimReporter(writer);
+ IDocumentAnalyser archiveAnalyser = DefaultAnalyserFactory.createArchiveTypeAnalyser(reporter);
+ IDocumentAnalyser binaryAnalyser = DefaultAnalyserFactory.createBinaryTypeAnalyser(reporter);
+ IDocumentAnalyser noticeAnalyser = DefaultAnalyserFactory.createNoticeTypeAnalyser(reporter);
+ IDocumentAnalyser standardAnalyser = DefaultAnalyserFactory.createStandardTypeAnalyser(reporter);
+ IDocumentAnalyser analyser =DefaultAnalyserFactory.createDefaultAnalyser(binaryAnalyser, archiveAnalyser, noticeAnalyser, standardAnalyser);
+ report = new XmlReport(writer, analyser);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ private void report(DirectoryWalker directory) throws Exception {
+ directory.run(report);
+ }
+
+ public void testBaseReport() throws Exception {
+ final String elementsPath = Resources.getResourceDirectory("elements/Source.java");
+ DirectoryWalker directory = new DirectoryWalker(new File(elementsPath), IGNORE);
+ report.startReport();
+ report(directory);
+ report.endReport();
+ writer.closeDocument();
+ final String output = out.toString();;
+ assertEquals(
+ "<?xml version='1.0'?>" +
+ "<rat-report>" +
+ "<resource name='" + elementsPath + "/Image.png'><type name='binary'/></resource>" +
+ "<resource name='" + elementsPath + "/LICENSE'><type name='notice'/></resource>" +
+ "<resource name='" + elementsPath + "/NOTICE'><type name='notice'/></resource>" +
+ "<resource name='" + elementsPath + "/Source.java'><type name='standard'/></resource>" +
+ "<resource name='" + elementsPath + "/Text.txt'><type name='standard'/></resource>" +
+ "<resource name='" + elementsPath + "/Xml.xml'><type name='standard'/></resource>" +
+ "<resource name='" + elementsPath + "/dummy.jar'><type name='archive'/></resource>" +
+ "<resource name='" + elementsPath + "/sub/Empty.txt'><type name='standard'/></resource>" +
+ "</rat-report>", output);
+ assertTrue("Is well formed", XmlUtils.isWellFormedXml(output));
+ }
+
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlUtils.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlUtils.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlUtils.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/XmlUtils.java Mon May 12 13:12:44 2008
@@ -0,0 +1,75 @@
+/*
+ * 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.rat.report.xml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.lang.reflect.UndeclaredThrowableException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.w3c.dom.Document;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+
+public final class XmlUtils {
+
+ public static final boolean isWellFormedXml(final String string) throws Exception {
+ return isWellFormedXml(new InputSource(new StringReader(string)));
+ }
+
+ public static final XMLReader newXMLReader() throws SAXException, ParserConfigurationException {
+ final SAXParserFactory spf = SAXParserFactory.newInstance();
+ spf.setValidating(false);
+ spf.setNamespaceAware(true);
+ return spf.newSAXParser().getXMLReader();
+ }
+
+ public static final boolean isWellFormedXml(final InputSource isource) {
+ try {
+ newXMLReader().parse(isource);
+ return true;
+ } catch (SAXException e) {
+ System.out.println(e);
+ e.printStackTrace();
+ return false;
+ } catch (IOException e) {
+ throw new UndeclaredThrowableException(e);
+ } catch (ParserConfigurationException e) {
+ throw new UndeclaredThrowableException(e);
+ }
+ }
+
+ public static final boolean isWellFormedXml(final InputStream in) throws Exception {
+ return isWellFormedXml(new InputSource(in));
+ }
+
+ public static final Document toDom(final InputStream in) throws SAXException, IOException, ParserConfigurationException, FactoryConfigurationError {
+ final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document result;
+ result = builder.parse(in);
+ return result;
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/writer/XmlWriterUtilsTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/writer/XmlWriterUtilsTest.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/writer/XmlWriterUtilsTest.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/writer/XmlWriterUtilsTest.java Mon May 12 13:12:44 2008
@@ -0,0 +1,51 @@
+/*
+ * 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.rat.report.xml.writer;
+
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+import org.apache.rat.report.xml.writer.impl.base.XmlWriter;
+
+public class XmlWriterUtilsTest extends TestCase {
+
+ StringWriter out;
+ IXmlWriter writer;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ out = new StringWriter();
+ writer = new XmlWriter(out);
+ writer.openElement("alpha");
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testWriteTrue() throws Exception {
+ XmlWriterUtils.writeAttribute(writer, "name", true);
+ assertEquals("Attribute written as True", "<alpha name='true'", out.toString());
+ }
+
+ public void testWriteFalse() throws Exception {
+ XmlWriterUtils.writeAttribute(writer, "name", false);
+ assertEquals("Attribute written as False", "<alpha name='false'", out.toString());
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/writer/impl/base/XmlWriterTest.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/writer/impl/base/XmlWriterTest.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/writer/impl/base/XmlWriterTest.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/report/xml/writer/impl/base/XmlWriterTest.java Mon May 12 13:12:44 2008
@@ -0,0 +1,456 @@
+/*
+ * 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.rat.report.xml.writer.impl.base;
+
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+import org.apache.rat.report.xml.writer.InvalidXmlException;
+import org.apache.rat.report.xml.writer.OperationNotAllowedException;
+
+public class XmlWriterTest extends TestCase {
+
+ private static final char[] ZERO_CHAR = {(char)0};
+
+ XmlWriter writer;
+ StringWriter out;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ out = new StringWriter();
+ writer = new XmlWriter(out);
+ }
+
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testReturnValues() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("beta", "b"));
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.content("gamma"));
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ }
+
+ public void testOpenElement() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("beta"));
+ assertEquals("Alpha element tag closed and beta started", "<alpha><beta", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Beta tag ended", "<alpha><beta/>", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("gamma"));
+ assertEquals("Gamma tag started", "<alpha><beta/><gamma", out.toString());
+ }
+
+ public void testInvalidElementName() throws Exception {
+ assertTrue("All strings ok", isValidElementName("alpha"));
+ assertTrue("Strings and digits ok", isValidElementName("alpha77"));
+ assertFalse("Must no start with digit", isValidElementName("5alpha77"));
+ assertFalse("Greater than not ok", isValidElementName("alph<a77"));
+ assertFalse("Less than not ok", isValidElementName("alph<a77"));
+ assertFalse("Quote not ok", isValidElementName("alph'a77"));
+ assertTrue("Dash ok", isValidElementName("alph-a77"));
+ assertTrue("Underscore ok", isValidElementName("alph_a77"));
+ assertTrue("Dot ok", isValidElementName("alph.a77"));
+ assertTrue("Colon ok", isValidElementName("alpha:77"));
+ assertFalse("Start with dash not ok", isValidElementName("-a77"));
+ assertTrue("Start with underscore ok", isValidElementName("_a77"));
+ assertFalse("Start with dot not ok", isValidElementName(".a77"));
+ assertTrue("Start with colon ok", isValidElementName(":a77"));
+ }
+
+ private boolean isValidElementName(String elementName) throws Exception {
+ boolean result = true;
+ try {
+ writer.openElement(elementName);
+ } catch (InvalidXmlException e) {
+ result = false;
+ }
+ return result;
+ }
+
+ public void testCallOpenElementAfterLastElementClosed() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element alpha is closed", "<alpha/>", out.toString());
+ try {
+ writer.openElement("delta");
+ fail("Cannot open new elements once the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements once the first element has been closed
+ }
+ }
+
+ public void testCallCloseElementAfterLastElementClosed() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element alpha is closed", "<alpha/>", out.toString());
+ try {
+ writer.closeElement();
+ fail("Cannot close elements once the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements once the first element has been closed
+ }
+ }
+
+
+ public void testCloseFirstElement() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element alpha is closed", "<alpha/>", out.toString());
+ }
+
+ public void testCloseElementWithContent() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("beta"));
+ assertEquals("Beta element started", "<alpha><beta", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element beta is closed", "<alpha><beta/>", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element beta is closed", "<alpha><beta/></alpha>", out.toString());
+ try {
+ writer.closeElement();
+ fail("Cannot close elements once the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements once the first element has been closed
+ }
+ }
+
+ public void testCloseElementBeforeFirstElement() throws Exception {
+ try {
+ writer.closeElement();
+ fail("Cannot close elements before the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements before the first element has been closed
+ }
+ }
+
+ public void testContentAfterElement() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.content("foo bar"));
+ assertEquals("Alpha tag closed. Content written", "<alpha>foo bar", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.content(" and more foo bar"));
+ assertEquals("Alpha tag closed. Content written", "<alpha>foo bar and more foo bar", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("beta"));
+ assertEquals("Beta element started", "<alpha>foo bar and more foo bar<beta", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element beta is closed", "<alpha>foo bar and more foo bar<beta/>", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element beta is closed", "<alpha>foo bar and more foo bar<beta/></alpha>", out.toString());
+ try {
+ writer.content("A Sentence Too far");
+ fail("Cannot write content once the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements once the first element has been closed
+ }
+ }
+
+
+ public void testContentAfterLastElement() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element beta is closed", "<alpha/>", out.toString());
+ try {
+ writer.content("A Sentence Too far");
+ fail("Cannot write content once the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements once the first element has been closed
+ }
+ }
+
+ public void testWriteContentBeforeFirstElement() throws Exception {
+ try {
+ writer.content("Too early");
+ fail("Cannot close elements before the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements before the first element has been closed
+ }
+ }
+
+ public void testContentEscaping() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.content("this&that"));
+ assertEquals("Amphersands must be escaped", "<alpha>this&that", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.content("small<large"));
+ assertEquals("Left angle brackets must be escaped", "<alpha>this&thatsmall<large", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.content("12>1"));
+ assertEquals("Choose to escape right angle brackets", "<alpha>this&thatsmall<large12>1", out.toString());
+
+ }
+
+ public void testAttributeAfterLastElement() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Element beta is closed", "<alpha/>", out.toString());
+ try {
+ writer.attribute("foo", "bar");
+ fail("Cannot write content once the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements once the first element has been closed
+ }
+ }
+
+ public void testAttributeContentBeforeFirstElement() throws Exception {
+ try {
+ writer.attribute("foo", "bar");
+ fail("Cannot close elements before the first element has been closed");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements before the first element has been closed
+ }
+ }
+
+ public void testInvalidAttributeName() throws Exception {
+ writer.openElement("alpha");
+ assertTrue("All strings ok", isValidAttributeName("alpha"));
+ assertTrue("Strings and digits ok", isValidAttributeName("alpha77"));
+ assertFalse("Must not start with digit", isValidAttributeName("5alpha77"));
+ assertTrue("Colon ok", isValidAttributeName("alpha:77"));
+ assertFalse("Greater than not ok", isValidAttributeName("alph<a77"));
+ assertFalse("Less than not ok", isValidAttributeName("alph<a77"));
+ assertFalse("Quote not ok", isValidAttributeName("alph'a77"));
+ }
+
+ private boolean isValidAttributeName(String name) throws Exception {
+ boolean result = true;
+ try {
+ writer.attribute(name, "");
+ } catch (InvalidXmlException e) {
+ result = false;
+ }
+ return result;
+ }
+
+ public void testEscapeAttributeContent() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("one", "this&that"));
+ assertEquals("Amphersands must be escaped", "<alpha one='this&that'", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("two", "small<large"));
+ assertEquals("Left angle brackets must be escaped", "<alpha one='this&that' two='small<large'", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("three", "12>1"));
+ assertEquals("Choose to escape right angle brackets", "<alpha one='this&that' two='small<large' three='12>1'", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("four", "'quote'"));
+ assertEquals("Apostrophes must be escape", "<alpha one='this&that' two='small<large' three='12>1' four=''quote''", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("five", "\"quote\""));
+ assertEquals("Double quotes must be escape", "<alpha one='this&that' two='small<large' three='12>1' four=''quote'' five='"quote"'", out.toString());
+
+ }
+
+ public void testAttributeInContent() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.content("foo bar"));
+ try {
+ writer.attribute("name", "value");
+ fail("attributes after body content are not allowed");
+ } catch (InvalidXmlException e) {
+ // attributes after body content are not allowed
+ }
+ }
+
+ public void testOutOfRangeCharacter() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.content(new String(ZERO_CHAR)));
+ String out = this.out.toString();
+ assertEquals("Replace illegal characters with question marks", "<alpha>?", out);
+ }
+
+ public void testAttributeAfterElementClosed() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("beta"));
+ assertEquals("Beta element started", "<alpha><beta", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Beta element closed", "<alpha><beta/>", out.toString());
+ try {
+ writer.attribute("name", "value");
+ fail("attributes after closed element are not allowed");
+ } catch (InvalidXmlException e) {
+ // attributes after body content are not allowed
+ }
+ }
+
+ public void testCloseDocumentBeforeOpen() throws Exception {
+ try {
+ writer.closeDocument();
+ fail("Cannot close document before the first element has been opened");
+ } catch (OperationNotAllowedException e) {
+ // Cannot open new elements before the first element has been opened
+ }
+ }
+
+ public void testCloseDocumentAfterRootElementClosed() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Beta element started", "<alpha/>", out.toString());
+ try {
+ writer.closeDocument();
+ } catch (OperationNotAllowedException e) {
+ fail("No exception should be thrown when called after the root element is closed.");
+ }
+ }
+
+ public void testCloseSimpleDocument() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("beta"));
+ assertEquals("Beta element started", "<alpha><beta", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeDocument());
+ assertEquals("Beta element started", "<alpha><beta/></alpha>", out.toString());
+ }
+
+ public void testCloseComplexDocument() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("beta"));
+ assertEquals("Beta element started", "<alpha><beta", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("name", "value"));
+ assertEquals("Beta element started", "<alpha><beta name='value'", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeElement());
+ assertEquals("Beta element started", "<alpha><beta name='value'/>", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("beta"));
+ assertEquals("Beta element started", "<alpha><beta name='value'/><beta", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("name", "value"));
+ assertEquals("Beta element started", "<alpha><beta name='value'/><beta name='value'", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("gamma"));
+ assertEquals("Beta element started", "<alpha><beta name='value'/><beta name='value'><gamma", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.closeDocument());
+ assertEquals("Beta element started", "<alpha><beta name='value'/><beta name='value'><gamma/></beta></alpha>", out.toString());
+ }
+
+ public void testWriteProlog() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.startDocument());
+ assertEquals("Prolog written", "<?xml version='1.0'?>", out.toString());
+ }
+
+ public void testWriteAfterElement() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ try {
+ writer.startDocument();
+ fail("Operation not allowed once an element has been written");
+ } catch (OperationNotAllowedException e) {
+ // Operation not allowed once an element has been written
+ }
+ }
+
+ public void testWritePrologTwo() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.startDocument());
+ assertEquals("Prolog written", "<?xml version='1.0'?>", out.toString());
+ try {
+ writer.startDocument();
+ fail("Operation not allow once a prolog has been written");
+ } catch (OperationNotAllowedException e) {
+ // Operation not allowed once an prolog has been written
+ }
+ }
+
+ public void testDuplicateAttributes() throws Exception {
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("alpha"));
+ assertEquals("Alpha element started", "<alpha", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("one", "1"));
+ assertEquals("Attribute written", "<alpha one='1'", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.openElement("beta"));
+ assertEquals("Beta element started", "<alpha one='1'><beta", out.toString());
+ assertEquals("XmlWriters should always return themselves",
+ writer, writer.attribute("one", "1"));
+ assertEquals("Beta element started", "<alpha one='1'><beta one='1'", out.toString());
+ try {
+ writer.attribute("one", "2");
+ fail("Each attribute may only be written once");
+ } catch (InvalidXmlException e) {
+ // Each attribute may only be written once
+ }
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/test/utils/RATCase.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/test/utils/RATCase.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/test/utils/RATCase.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/test/utils/RATCase.java Mon May 12 13:12:44 2008
@@ -0,0 +1,101 @@
+/*
+ * 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.rat.test.utils;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.IteratorUtils;
+
+import org.apache.rat.document.DocumentUtils;
+import org.apache.rat.document.IDocument;
+import org.apache.rat.document.IDocumentCollection;
+
+public abstract class RATCase extends TestCase {
+
+ protected void checkDummyJar(IDocumentCollection collection) {
+ assertNotNull(collection);
+ Collection documents = IteratorUtils.toList(collection.documentIterator());
+ CollectionUtils.transform(documents, DocumentUtils.toNameTransformer());
+ assertEquals("Six documents in the jar", 6, documents.size());
+ assertTrue("Document names", documents.contains("Image.png"));
+ assertTrue("Document names", documents.contains("LICENSE"));
+ assertTrue("Document names", documents.contains("NOTICE"));
+ assertTrue("Document names", documents.contains("Source.java"));
+ assertTrue("Document names", documents.contains("Text.txt"));
+ assertTrue("Document names", documents.contains("Xml.xml"));
+ Iterator iterator = collection.subcollectionIterator();
+ assertTrue("Two subdirectories", iterator.hasNext());
+ Object subdirectory = iterator.next();
+ assertNotNull("Collection contains document collections", subdirectory);
+ assertTrue("Collection contains document collections", subdirectory instanceof IDocumentCollection);
+ IDocumentCollection subcollection = (IDocumentCollection) subdirectory;
+ checkSubDirectory(collection, subcollection);
+ assertTrue("Two subdirectories", iterator.hasNext());
+ subdirectory = iterator.next();
+ assertNotNull("Collection contains document collections", subdirectory);
+ assertTrue("Collection contains document collections", subdirectory instanceof IDocumentCollection);
+ subcollection = (IDocumentCollection) subdirectory;
+ checkSubDirectory(collection, subcollection);
+ assertFalse("Two subdirectories", iterator.hasNext());
+ }
+
+ private void checkSubDirectory(IDocumentCollection collection, IDocumentCollection subcollection) {
+ final String name = subcollection.getName();
+ if ("sub".equals(name)) {
+ checkSub(subcollection);
+ } else if ("META-INF".equals(name)) {
+ checkMetaInf(subcollection);
+ } else {
+ fail("Unexception subdirectory named " + name);
+ }
+ }
+
+ private void checkMetaInf(IDocumentCollection subcollection) {
+ Iterator documentIterator = subcollection.documentIterator();
+ assertNotNull("Document iterator has one element", documentIterator);
+ assertTrue("Document iterator has one element", documentIterator.hasNext());
+ Object next = documentIterator.next();
+ assertNotNull("Document iterator has one element", next);
+ assertTrue("Document iterator has one element", next instanceof IDocument);
+ IDocument document = (IDocument) next;
+ assertEquals("Document named", "MANIFEST.MF", document.getName());
+ Iterator subsubcollectionIterator = subcollection.subcollectionIterator();
+ assertNotNull("No sub collections", subsubcollectionIterator);
+ assertFalse("No sub collections", subsubcollectionIterator.hasNext());
+ }
+
+ private void checkSub(IDocumentCollection subcollection) {
+ Iterator documentIterator = subcollection.documentIterator();
+ assertNotNull("Document iterator has one element", documentIterator);
+ assertTrue("Document iterator has one element", documentIterator.hasNext());
+ Object next = documentIterator.next();
+ assertNotNull("Document iterator has one element", next);
+ assertTrue("Document iterator has one element", next instanceof IDocument);
+ IDocument document = (IDocument) next;
+ assertEquals("Document named", "Empty.txt", document.getName());
+ Iterator subsubcollectionIterator = subcollection.subcollectionIterator();
+ assertNotNull("No sub collections", subsubcollectionIterator);
+ assertFalse("No sub collections", subsubcollectionIterator.hasNext());
+ }
+
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/test/utils/Resources.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/test/utils/Resources.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/test/utils/Resources.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/java/org/apache/rat/test/utils/Resources.java Mon May 12 13:12:44 2008
@@ -0,0 +1,86 @@
+/*
+ * 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.rat.test.utils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.apache.rat.document.impl.DocumentImplUtils;
+
+
+/**
+ * Utility class, which provides static methods for creating
+ * test cases.
+ */
+public class Resources {
+ /**
+ * Private constructor, to prevent accidental instantiation.
+ */
+ private Resources() {
+ // Does nothing
+ }
+
+ /**
+ * Locates a resource file in the class path.
+ */
+ public static File getResourceFile(String pResource) throws IOException {
+ final File f = new File("src/test/resources", pResource);
+ if (!f.isFile()) {
+ throw new FileNotFoundException("Unable to locate resource file: " + pResource);
+ }
+ return f;
+ }
+
+ /**
+ * Locates a resource file in the class path and returns an {@link InputStream}.
+ */
+ public static InputStream getResourceStream(String pResource) throws IOException {
+ return new FileInputStream(getResourceFile(pResource));
+ }
+
+ /**
+ * Locates a resource file in the class path and returns a {@link Reader}.
+ */
+ public static Reader getResourceReader(String pResource) throws IOException {
+ return new InputStreamReader(getResourceStream(pResource), "UTF-8");
+ }
+
+ /**
+ * Locates a resource file in the class path and returns a {@link BufferedReader}.
+ */
+ public static BufferedReader getBufferedResourceReader(String pResource) throws IOException {
+ return new BufferedReader(getResourceReader(pResource));
+ }
+
+ /**
+ * Locates the name of a directory, which contains the given
+ * resource file.
+ */
+ public static String getResourceDirectory(String pResource) throws IOException {
+ final File resource = getResourceFile(pResource);
+ final File dir = resource.getParentFile();
+ return DocumentImplUtils.toName(dir);
+ }
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/artifacts/dummy.tar.gz
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/artifacts/dummy.tar.gz?rev=655625&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/rat/main/trunk/rat/rat-core/src/test/resources/artifacts/dummy.tar.gz
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/binaries/Image-png.not
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/binaries/Image-png.not?rev=655625&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/rat/main/trunk/rat/rat-core/src/test/resources/binaries/Image-png.not
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Image.png
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Image.png?rev=655625&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Image.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/LICENSE
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/LICENSE?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/LICENSE (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/LICENSE Mon May 12 13:12:44 2008
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
\ No newline at end of file
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/NOTICE
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/NOTICE?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/NOTICE (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/NOTICE Mon May 12 13:12:44 2008
@@ -0,0 +1,7 @@
+=========================================================================
+== NOTICE file corresponding to section 4(d) of the Apache License, ==
+== Version 2.0. ==
+=========================================================================
+
+This product includes software developed by
+The Apache Software Foundation (http://www.apache.org/).
\ No newline at end of file
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Source.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Source.java?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Source.java (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Source.java Mon May 12 13:12:44 2008
@@ -0,0 +1,5 @@
+package elements;
+
+public class Source {
+
+}
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Text.txt
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Text.txt?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Text.txt (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Text.txt Mon May 12 13:12:44 2008
@@ -0,0 +1,15 @@
+/*
+ * Copyright 2006 Robert Burrell Donkin
+ *
+ * Licensed 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.
+ */
\ No newline at end of file
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Xml.xml
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Xml.xml?rev=655625&view=auto
==============================================================================
--- incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Xml.xml (added)
+++ incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/Xml.xml Mon May 12 13:12:44 2008
@@ -0,0 +1,20 @@
+<?xml version='1.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. *
+-->
+<document/>
\ No newline at end of file
Added: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/dummy.jar
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/dummy.jar?rev=655625&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/rat/main/trunk/rat/rat-core/src/test/resources/elements/dummy.jar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream