creadur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rdon...@apache.org
Subject svn commit: r1361570 - in /creadur/whisker/trunk: ./ apache-whisker-velocity/ apache-whisker-velocity/src/main/resources/org/apache/creadur/whisker/template/velocity/ apache-whisker-velocity/src/test/java/org/ apache-whisker-velocity/src/test/java/org/...
Date Sat, 14 Jul 2012 17:51:24 GMT
Author: rdonkin
Date: Sat Jul 14 17:51:23 2012
New Revision: 1361570

URL: http://svn.apache.org/viewvc?rev=1361570&view=rev
Log:
Started testing output from template

Added:
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/EmptyLog.java
  (with props)
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/StringResultWriterFactory.java
  (with props)
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java
  (with props)
Modified:
    creadur/whisker/trunk/apache-whisker-velocity/pom.xml
    creadur/whisker/trunk/apache-whisker-velocity/src/main/resources/org/apache/creadur/whisker/template/velocity/notice.vm
    creadur/whisker/trunk/pom.xml

Modified: creadur/whisker/trunk/apache-whisker-velocity/pom.xml
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/pom.xml?rev=1361570&r1=1361569&r2=1361570&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/pom.xml (original)
+++ creadur/whisker/trunk/apache-whisker-velocity/pom.xml Sat Jul 14 17:51:23 2012
@@ -62,6 +62,12 @@
     </dependency>
     
     <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock-junit3</artifactId>
+      <scope>test</scope>
+    </dependency>
+    
+    <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>apache-whisker-scan</artifactId>
       <version>${project.version}</version>

Modified: creadur/whisker/trunk/apache-whisker-velocity/src/main/resources/org/apache/creadur/whisker/template/velocity/notice.vm
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/src/main/resources/org/apache/creadur/whisker/template/velocity/notice.vm?rev=1361570&r1=1361569&r2=1361570&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/src/main/resources/org/apache/creadur/whisker/template/velocity/notice.vm
(original)
+++ creadur/whisker/trunk/apache-whisker-velocity/src/main/resources/org/apache/creadur/whisker/template/velocity/notice.vm
Sat Jul 14 17:51:23 2012
@@ -23,7 +23,7 @@ $indent.indent(2, $work.PrimaryNotice)
 
 
 #if ( ! $work.ResourcesRequiringSourceLinks.isEmpty() )
-  Download the source for:
+  ##Download the source for:
 #foreach ( $resource in $work.ResourcesRequiringSourceLinks )
     $resource.Name from $resource.Source
 #end

Added: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/EmptyLog.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/EmptyLog.java?rev=1361570&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/EmptyLog.java
(added)
+++ creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/EmptyLog.java
Sat Jul 14 17:51:23 2012
@@ -0,0 +1,85 @@
+/**
+ * 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.out.velocity;
+
+import org.apache.commons.logging.Log;
+
+public class EmptyLog implements Log {
+
+    public void debug(Object arg0, Throwable arg1) {
+    }
+
+    public void debug(Object arg0) {        
+    }
+
+    public void error(Object arg0, Throwable arg1) {
+    }
+
+    public void error(Object arg0) {
+    }
+
+    public void fatal(Object arg0, Throwable arg1) {
+    }
+
+    public void fatal(Object arg0) {
+    }
+
+    public void info(Object arg0, Throwable arg1) {
+    }
+
+    public void info(Object arg0) {
+    }
+
+    public boolean isDebugEnabled() {
+        return false;
+    }
+
+    public boolean isErrorEnabled() {
+        return false;
+    }
+
+    public boolean isFatalEnabled() {
+        return false;
+    }
+
+    public boolean isInfoEnabled() {
+        return false;
+    }
+
+    public boolean isTraceEnabled() {
+        return false;
+    }
+
+    public boolean isWarnEnabled() {
+        return false;
+    }
+
+    public void trace(Object arg0, Throwable arg1) {
+    }
+
+    public void trace(Object arg0) {
+    }
+
+    public void warn(Object arg0, Throwable arg1) {
+    }
+
+    public void warn(Object arg0) {
+    }
+
+}

Propchange: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/EmptyLog.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/StringResultWriterFactory.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/StringResultWriterFactory.java?rev=1361570&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/StringResultWriterFactory.java
(added)
+++ creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/StringResultWriterFactory.java
Sat Jul 14 17:51:23 2012
@@ -0,0 +1,55 @@
+/**
+ * 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.out.velocity;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.creadur.whisker.app.Result;
+import org.apache.creadur.whisker.app.ResultWriterFactory;
+
+public class StringResultWriterFactory implements ResultWriterFactory {
+    
+    Map<Result, List<StringWriter>> results = new HashMap<Result, List<StringWriter>>();
+    
+    public StringResultWriterFactory() {
+        for (Result result: Result.values()) {
+            results.put(result, new ArrayList<StringWriter>());
+        }
+    }
+
+    public Writer writerFor(Result result) throws IOException {
+        final StringWriter writer = new StringWriter();
+        results.get(result).add(writer);
+        return writer;
+    }
+    
+    public int requestsFor(Result result) {
+        return results.get(result).size();
+    }
+    
+    public String firstOutputFor(Result result) {
+        return results.get(result).get(0).toString();
+    }
+}

Propchange: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/StringResultWriterFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java?rev=1361570&view=auto
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java
(added)
+++ creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java
Sat Jul 14 17:51:23 2012
@@ -0,0 +1,70 @@
+/**
+ * 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.out.velocity;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.creadur.whisker.app.Result;
+import org.apache.creadur.whisker.model.Descriptor;
+import org.apache.creadur.whisker.model.License;
+import org.apache.creadur.whisker.model.Organisation;
+import org.apache.creadur.whisker.model.Resource;
+import org.apache.creadur.whisker.model.WithinDirectory;
+
+import junit.framework.TestCase;
+
+public class TestNoticeGeneration extends TestCase {
+    
+    StringResultWriterFactory writerFactory;
+    VelocityEngine subject;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        writerFactory = new StringResultWriterFactory();
+        subject = new VelocityEngine(new EmptyLog());
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+    
+    public void testThatWhenThereAreNoThirdPartyNoticesHeaderIsNotShown() throws Exception
{
+        License primaryLicense = new License(false, "This is the license text", Collections.<String>
emptyList(), "example.org", "http://example.org", "Example License");
+        String primaryOrg = "example.org";
+        String primaryNotice = "The primary notice.";
+        Collection<WithinDirectory> contents = new ArrayList<WithinDirectory>();
+        Map<String, License> licenses = new HashMap<String, License>();
+        primaryLicense.storeIn(licenses);
+        Map<String, String> notices = new HashMap<String, String>();
+        Map<String, Organisation> organisations = new HashMap<String, Organisation>();
+        Descriptor work = 
+                new Descriptor(primaryLicense, primaryOrg,  primaryNotice, 
+                        licenses, notices, organisations, contents);
+        subject.generate(work, writerFactory);
+        
+        assertEquals("Only one request for NOTICE writer", 1, writerFactory.requestsFor(Result.NOTICE));
+        assertEquals("When no third party notices, expect that only the primary notice is
output", primaryNotice, writerFactory.firstOutputFor(Result.NOTICE).trim());
+    }
+}

Propchange: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestNoticeGeneration.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: creadur/whisker/trunk/pom.xml
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/pom.xml?rev=1361570&r1=1361569&r2=1361570&view=diff
==============================================================================
--- creadur/whisker/trunk/pom.xml (original)
+++ creadur/whisker/trunk/pom.xml Sat Jul 14 17:51:23 2012
@@ -76,6 +76,12 @@
         <version>${junit.version}</version>
         <scope>test</scope>
       </dependency>
+      <dependency>
+        <groupId>org.jmock</groupId>
+        <artifactId>jmock-junit3</artifactId>
+        <version>2.5.1</version>
+        <scope>test</scope>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 



Mime
View raw message