You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by rd...@apache.org on 2012/10/28 19:53:20 UTC
svn commit: r1403072 - in /creadur/whisker/trunk/apache-whisker-model/src:
main/java/org/apache/creadur/whisker/model/
test/java/org/apache/creadur/whisker/model/
Author: rdonkin
Date: Sun Oct 28 18:53:19 2012
New Revision: 1403072
URL: http://svn.apache.org/viewvc?rev=1403072&view=rev
Log:
WHISKER-6 Introduce visitor to search for copyright notices
Added:
creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/NoCopyrightNoticeVerifier.java (with props)
creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestNoCopyrightNoticeVerifier.java (with props)
Modified:
creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/WithLicenseBuilderForTesting.java
Added: creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/NoCopyrightNoticeVerifier.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/NoCopyrightNoticeVerifier.java?rev=1403072&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/NoCopyrightNoticeVerifier.java (added)
+++ creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/NoCopyrightNoticeVerifier.java Sun Oct 28 18:53:19 2012
@@ -0,0 +1,54 @@
+/**
+ * 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.creadur.whisker.model;
+
+/**
+ * Verifies that no copyright notices are present.
+ */
+public class NoCopyrightNoticeVerifier extends Visitor {
+ /**
+ * Set to true when a {@link WithLicense} with
+ * a copyright notice set is visited.
+ */
+ private boolean isCopyrightNoticePresent = false;
+
+ /**
+ * Visits a license to determine whether a copyright notice
+ * has been set.
+ * @param license not null
+ */
+ @Override
+ public void visit(WithLicense license) {
+ super.visit(license);
+ if (license.hasCopyrightNotice()) {
+ isCopyrightNoticePresent = true;
+ }
+ }
+
+ /**
+ * Has any {@link WithLicense} been visited
+ * with a copyright notice set?
+ * @return true when this verifier has visited a {@link WithLicense}
+ * with a copyright notice set,
+ * false otherwise
+ */
+ public boolean isCopyrightNoticePresent() {
+ return isCopyrightNoticePresent;
+ }
+}
Propchange: creadur/whisker/trunk/apache-whisker-model/src/main/java/org/apache/creadur/whisker/model/NoCopyrightNoticeVerifier.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestNoCopyrightNoticeVerifier.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestNoCopyrightNoticeVerifier.java?rev=1403072&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestNoCopyrightNoticeVerifier.java (added)
+++ creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestNoCopyrightNoticeVerifier.java Sun Oct 28 18:53:19 2012
@@ -0,0 +1,40 @@
+/**
+ * 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.creadur.whisker.model;
+
+import junit.framework.TestCase;
+
+public class TestNoCopyrightNoticeVerifier extends TestCase {
+
+ NoCopyrightNoticeVerifier subject;
+
+ public void setUp() throws Exception {
+ subject = new NoCopyrightNoticeVerifier();
+ }
+
+ public void testWithLicenseNoCopyrightNotice() throws Exception {
+ new WithLicenseBuilderForTesting().withNoCopyrightNotice().build().accept(subject);
+ assertFalse(subject.isCopyrightNoticePresent());
+ }
+
+ public void testWithLicenseWithCopyrightNotice() throws Exception {
+ new WithLicenseBuilderForTesting().withCopyrightNotice().build().accept(subject);
+ assertTrue(subject.isCopyrightNoticePresent());
+ }
+}
Propchange: creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/TestNoCopyrightNoticeVerifier.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/WithLicenseBuilderForTesting.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/WithLicenseBuilderForTesting.java?rev=1403072&r1=1403071&r2=1403072&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/WithLicenseBuilderForTesting.java (original)
+++ creadur/whisker/trunk/apache-whisker-model/src/test/java/org/apache/creadur/whisker/model/WithLicenseBuilderForTesting.java Sun Oct 28 18:53:19 2012
@@ -24,6 +24,8 @@ import java.util.Map;
public class WithLicenseBuilderForTesting {
+ public static final String A_COPYRIGHT_NOTICE = "copyright (c) 2525 someone";
+
License license = new LicenseBuilderForTesting().build();
@SuppressWarnings("unchecked")
Collection<ByOrganisation> organisations = Collections.EMPTY_LIST;
@@ -39,4 +41,12 @@ public class WithLicenseBuilderForTestin
public WithLicense build() {
return new WithLicense(license, copyrightNotice, parameters, organisations);
}
+
+ public WithLicenseBuilderForTesting withCopyrightNotice() {
+ return withCopyrightNotice(A_COPYRIGHT_NOTICE);
+ }
+
+ public WithLicenseBuilderForTesting withNoCopyrightNotice() {
+ return withCopyrightNotice(null);
+ }
}