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/11/11 19:41:45 UTC

svn commit: r1408078 - in /creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity: DescriptorBuilderForTesting.java TestLicenseGeneration.java

Author: rdonkin
Date: Sun Nov 11 18:41:45 2012
New Revision: 1408078

URL: http://svn.apache.org/viewvc?rev=1408078&view=rev
Log:
Improve test coverage

Modified:
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/DescriptorBuilderForTesting.java
    creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestLicenseGeneration.java

Modified: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/DescriptorBuilderForTesting.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/DescriptorBuilderForTesting.java?rev=1408078&r1=1408077&r2=1408078&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/DescriptorBuilderForTesting.java (original)
+++ creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/DescriptorBuilderForTesting.java Sun Nov 11 18:41:45 2012
@@ -38,6 +38,8 @@ public class DescriptorBuilderForTesting
     String primaryLicenseText = "This is the primary license text";
     Organisation thirdPartyOrg = new Organisation("third-party", "thirdparty.org", "http://thirdparty.org");
     License primaryLicense = new License(false, primaryLicenseText, Collections.<String> emptyList(), "example.org", "http://example.org", "Example License");
+    License secondaryLicense = new License(false, "This is the secondary license text", Collections.<String> emptyList(), "example.org:secondary", "http://example.org/secondary", "Example Secondary License");
+
     String primaryOrgName = "example.org";
     String primaryNotice = "The primary notice.";
     Collection<WithinDirectory> contents = new ArrayList<WithinDirectory>();
@@ -140,4 +142,10 @@ public class DescriptorBuilderForTesting
         return this;
     }
 
+    public DescriptorBuilderForTesting withSecondaryLicensePrimaryOrganisationInDirectory(
+            String directoryName) {
+        addDirectory(secondaryLicense, primaryOrganisation(), directoryName);
+        return this;
+    }
+
 }

Modified: creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestLicenseGeneration.java
URL: http://svn.apache.org/viewvc/creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestLicenseGeneration.java?rev=1408078&r1=1408077&r2=1408078&view=diff
==============================================================================
--- creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestLicenseGeneration.java (original)
+++ creadur/whisker/trunk/apache-whisker-velocity/src/test/java/org/apache/creadur/whisker/out/velocity/TestLicenseGeneration.java Sun Nov 11 18:41:45 2012
@@ -18,23 +18,11 @@
  */
 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 junit.framework.TestCase;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.creadur.whisker.app.Result;
-import org.apache.creadur.whisker.model.ByOrganisation;
 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.WithLicense;
-import org.apache.creadur.whisker.model.WithinDirectory;
-
-import junit.framework.TestCase;
 
 public class TestLicenseGeneration extends TestCase {
 
@@ -90,10 +78,22 @@ public class TestLicenseGeneration exten
         assertTrue("Expect secondary copyright to be presented: " + writerFactory.firstOutputFor(Result.LICENSE),
                 StringUtils.contains(writerFactory.firstOutputFor(Result.LICENSE),
                         builder.getSecondaryCopyright()));
+        verifyThatResourceNameIsWritten();
+
+    }
+
+    private void verifyThatResourceNameIsWritten() {
         assertTrue("Expect resource to be indicated: " + writerFactory.firstOutputFor(Result.LICENSE),
                 StringUtils.contains(writerFactory.firstOutputFor(Result.LICENSE),
                         builder.getResourceName()));
+    }
 
+    public void testPrimaryOrganisationSecondaryLicense() throws Exception {
+        subject.generate(
+                builder.withSecondaryLicensePrimaryOrganisationInDirectory("lib").build(),
+                writerFactory);
+        assertEquals("Only one request for LICENSE writer", 1, writerFactory.requestsFor(Result.LICENSE));
+        verifyThatResourceNameIsWritten();
     }
 
 }