Return-Path: X-Original-To: apmail-incubator-rat-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-rat-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4B055968B for ; Sun, 15 Apr 2012 10:17:12 +0000 (UTC) Received: (qmail 6457 invoked by uid 500); 15 Apr 2012 10:17:12 -0000 Delivered-To: apmail-incubator-rat-commits-archive@incubator.apache.org Received: (qmail 6433 invoked by uid 500); 15 Apr 2012 10:17:12 -0000 Mailing-List: contact rat-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: rat-dev@incubator.apache.org Delivered-To: mailing list rat-commits@incubator.apache.org Received: (qmail 6426 invoked by uid 99); 15 Apr 2012 10:17:12 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Apr 2012 10:17:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 15 Apr 2012 10:17:07 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 310352388BEF; Sun, 15 Apr 2012 10:16:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1326295 [7/8] - in /incubator/rat/site/trunk/content/rat/whisker: apache-whisker-cli/apidocs/org/apache/creadur/ apache-whisker-cli/apidocs/org/apache/creadur/whisker/ apache-whisker-cli/apidocs/org/apache/creadur/whisker/cli/ apache-whisk... Date: Sun, 15 Apr 2012 10:16:20 -0000 To: rat-commits@incubator.apache.org From: rdonkin@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120415101623.310352388BEF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-summary.html URL: http://svn.apache.org/viewvc/incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-summary.html?rev=1326295&view=auto ============================================================================== --- incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-summary.html (added) +++ incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-summary.html Sun Apr 15 10:16:18 2012 @@ -0,0 +1,158 @@ + + + + + + + +org.apache.creadur.whisker.cli (Apache Whisker 0.1-SNAPSHOT Test API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package org.apache.creadur.whisker.cli +

+ + + + + + + + + +
+Class Summary
TestCommandParsing 
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2011-2012 Apache Software Foundation. All Rights Reserved. + + Propchange: incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-summary.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-tree.html URL: http://svn.apache.org/viewvc/incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-tree.html?rev=1326295&view=auto ============================================================================== --- incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-tree.html (added) +++ incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-tree.html Sun Apr 15 10:16:18 2012 @@ -0,0 +1,159 @@ + + + + + + + +org.apache.creadur.whisker.cli Class Hierarchy (Apache Whisker 0.1-SNAPSHOT Test API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package org.apache.creadur.whisker.cli +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+
    +
  • java.lang.Object
      +
    • junit.framework.Assert
        +
      • junit.framework.TestCase (implements junit.framework.Test) + +
      +
    +
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2011-2012 Apache Software Foundation. All Rights Reserved. + + Propchange: incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-tree.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-use.html URL: http://svn.apache.org/viewvc/incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-use.html?rev=1326295&view=auto ============================================================================== --- incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-use.html (added) +++ incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-use.html Sun Apr 15 10:16:18 2012 @@ -0,0 +1,145 @@ + + + + + + + +Uses of Package org.apache.creadur.whisker.cli (Apache Whisker 0.1-SNAPSHOT Test API) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Uses of Package
org.apache.creadur.whisker.cli

+
+No usage of org.apache.creadur.whisker.cli +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+Copyright © 2011-2012 Apache Software Foundation. All Rights Reserved. + + Propchange: incubator/rat/site/trunk/content/rat/whisker/testapidocs/org/apache/creadur/whisker/cli/package-use.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/TestCommandParsing.html URL: http://svn.apache.org/viewvc/incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/TestCommandParsing.html?rev=1326295&view=auto ============================================================================== --- incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/TestCommandParsing.html (added) +++ incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/TestCommandParsing.html Sun Apr 15 10:16:18 2012 @@ -0,0 +1,198 @@ + + + + +TestCommandParsing xref + + + +
+
+1   /**
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    *  to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    *  with the License.  You may obtain a copy of the License at
+9    *
+10   *   http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License. 
+18   */
+19  package org.apache.creadur.whisker.cli;
+20  
+21  import junit.framework.TestCase;
+22  
+23  import org.apache.commons.cli.AlreadySelectedException;
+24  import org.apache.commons.cli.ParseException;
+25  import org.apache.rat.whisker.app.Act;
+26  import org.apache.rat.whisker.app.Whisker;
+27  import org.apache.rat.whisker.app.load.StreamableClassPathResource;
+28  
+29  /**
+30   *
+31   */
+32  public class TestCommandParsing extends TestCase {
+33      
+34      /**
+35       * 
+36       */
+37      private static final String LONG_OPT = "--";
+38      /**
+39       * 
+40       */
+41      private static final String SHORT_OPT = "-";
+42      private Main subject;
+43  
+44      @Override
+45      protected void setUp() throws Exception {
+46          subject = new Main(new Whisker());
+47      }
+48  
+49      public void testGenerateAndAuditAreMutuallyExclusive() throws Exception {
+50          try {
+51              subject.configure(
+52                  args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH", 
+53                          longOpt(CommandLineOption.ACT_TO_AUDIT.getLongName()),
+54                          longOpt(CommandLineOption.ACT_TO_GENERATE.getLongName())));
+55              
+56              fail("Expected audit and generate to together to throw exception");
+57          } catch (AlreadySelectedException e) {
+58              // expected
+59          }
+60      }
+61      
+62      public void testSetGenerateAct() throws Exception {
+63          checkSetActForOption(Act.GENERATE, CommandLineOption.ACT_TO_GENERATE);
+64      }
+65      
+66      public void testSetAuditAct() throws Exception {
+67          checkSetActForOption(Act.AUDIT, CommandLineOption.ACT_TO_AUDIT);
+68      }
+69  
+70      /**
+71       * @param act
+72       * @param option
+73       * @throws ParseException
+74       */
+75      private void checkSetActForOption(Act act, CommandLineOption option)
+76              throws ParseException {
+77          assertEquals(act + " arg should set property on Whisker", act, subject.configure(
+78                  args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH", 
+79                          shortOpt(CommandLineOption.SOURCE.getShortName()), "path", longOpt(option.getLongName()))).getAct());
+80          assertEquals(act + "Audit arg should set property on Whisker", act, subject.configure(
+81                  args(longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()), "PATH", 
+82                          shortOpt(CommandLineOption.SOURCE.getShortName()), "path", shortOpt(option.getShortName()))).getAct());
+83      }
+84  
+85      public void testSetSourceByCli() throws Exception {
+86          checkSourceWithPath("/some/path");
+87          checkSourceWithPath("/");
+88          checkSourceWithPath("relative");
+89      }
+90      
+91      public void testAuditRequiresSource() throws Exception {
+92          try {
+93              subject.configure(args( 
+94                      longOpt(CommandLineOption.ACT_TO_AUDIT.getLongName()),
+95                      shortOpt(CommandLineOption.LICENSE_DESCRIPTION.getShortName()), "some/path"));
+96              fail("Audit requires source");
+97          } catch (ParseException e) {
+98              // Expected
+99          }
+100     }
+101     
+102     /**
+103      * @param aPath
+104      */
+105     private void checkSourceWithPath(String aPath) throws Exception {
+106         checkSource(aPath, shortOpt(CommandLineOption.SOURCE.getShortName()));
+107         checkSource(aPath, longOpt(CommandLineOption.SOURCE.getLongName()));
+108     }
+109 
+110     
+111     private void checkSource(String aPath, String arg) throws ParseException {
+112         assertEquals("Source arg should set property on Whisker", aPath, 
+113                 subject.configure(args(arg, aPath, 
+114                         longOpt(CommandLineOption.ACT_TO_AUDIT.getLongName()),
+115                         shortOpt(CommandLineOption.LICENSE_DESCRIPTION.getShortName()), "Whatever/bin")).getSource());
+116     }
+117     
+118     
+119     public void testSetLicenseDescriptorShortByCLI() throws Exception {
+120         exerciseShortLicenseDescriptionWithPath("/some/path");
+121         exerciseShortLicenseDescriptionWithPath("another/path");
+122         exerciseShortLicenseDescriptionWithPath("short");
+123         exerciseShortLicenseDescriptionWithPath("");
+124         exerciseShortLicenseDescriptionWithPath("http://url.style/path");
+125     }
+126     
+127     public void testSetLicenseDescriptorLongByCLI() throws Exception {
+128         exerciseLongLicenseDescriptionWithPath("/some/path");
+129         exerciseLongLicenseDescriptionWithPath("another/path");
+130         exerciseLongLicenseDescriptionWithPath("short");
+131         exerciseLongLicenseDescriptionWithPath("");
+132         exerciseLongLicenseDescriptionWithPath("http://url.style/path");
+133     }
+134 
+135     /**
+136      * @param aPath
+137      */
+138     private void exerciseShortLicenseDescriptionWithPath(String aPath) throws Exception {
+139         exerciseLicenseDescriptor(aPath, shortOpt(CommandLineOption.LICENSE_DESCRIPTION.getShortName()));
+140     }
+141 
+142 
+143     /**
+144      * @param licenseDescriptorShortOpt
+145      * @return
+146      */
+147     private String shortOpt(char licenseDescriptorShortOpt) {
+148         return SHORT_OPT + licenseDescriptorShortOpt;
+149     }
+150     
+151     /**
+152      * @param aPath
+153      */
+154     private void exerciseLongLicenseDescriptionWithPath(String aPath) throws Exception {
+155         exerciseLicenseDescriptor(aPath, longOpt(CommandLineOption.LICENSE_DESCRIPTION.getLongName()));
+156     }
+157 
+158 
+159     /**
+160      * @param licenseDescriptorLongOpt
+161      * @return
+162      */
+163     private String longOpt(String licenseDescriptorLongOpt) {
+164         return LONG_OPT + licenseDescriptorLongOpt;
+165     }
+166 
+167 
+168     /**
+169      * @param aPath
+170      * @param arg
+171      * @throws ParseException
+172      */
+173     private void exerciseLicenseDescriptor(String aPath, String arg)
+174             throws ParseException {
+175         assertEquals("License descriptor arg should set property on Whisker", aPath, 
+176                 ((StreamableClassPathResource)subject.configure(
+177                         args(arg, aPath, longOpt(CommandLineOption.ACT_TO_GENERATE.getLongName())))
+178                             .getLicenseDescriptor()).getName());
+179     }
+180     
+181     private String[] args(String ...strings) {
+182         return strings;
+183     }
+184 }
+
+
+ + Propchange: incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/TestCommandParsing.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-frame.html URL: http://svn.apache.org/viewvc/incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-frame.html?rev=1326295&view=auto ============================================================================== --- incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-frame.html (added) +++ incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-frame.html Sun Apr 15 10:16:18 2012 @@ -0,0 +1,24 @@ + + + + + + Apache Whisker 0.1-SNAPSHOT Reference Package org.apache.creadur.whisker.cli + + + + +

+ org.apache.creadur.whisker.cli +

+ +

Classes

+ + + + + \ No newline at end of file Propchange: incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-frame.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-summary.html URL: http://svn.apache.org/viewvc/incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-summary.html?rev=1326295&view=auto ============================================================================== --- incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-summary.html (added) +++ incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-summary.html Sun Apr 15 10:16:18 2012 @@ -0,0 +1,67 @@ + + + + + + Apache Whisker 0.1-SNAPSHOT Reference Package org.apache.creadur.whisker.cli + + + +
+ +
+
+ +
+ +

Package org.apache.creadur.whisker.cli

+ + + + + + + + + + + + +
Class Summary
+ TestCommandParsing +
+ +
+ +
+
+ +
+
+ Copyright © 2011-2012 Apache Software Foundation. All Rights Reserved. + + \ No newline at end of file Propchange: incubator/rat/site/trunk/content/rat/whisker/xref-test/org/apache/creadur/whisker/cli/package-summary.html ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/rat/site/trunk/content/rat/whisker/xref/org/apache/creadur/whisker/cli/CommandLineOption.html URL: http://svn.apache.org/viewvc/incubator/rat/site/trunk/content/rat/whisker/xref/org/apache/creadur/whisker/cli/CommandLineOption.html?rev=1326295&view=auto ============================================================================== --- incubator/rat/site/trunk/content/rat/whisker/xref/org/apache/creadur/whisker/cli/CommandLineOption.html (added) +++ incubator/rat/site/trunk/content/rat/whisker/xref/org/apache/creadur/whisker/cli/CommandLineOption.html Sun Apr 15 10:16:18 2012 @@ -0,0 +1,170 @@ + + + + +CommandLineOption xref + + + +
+
+1   /**
+2    * Licensed to the Apache Software Foundation (ASF) under one
+3    * or more contributor license agreements.  See the NOTICE file
+4    * distributed with this work for additional information
+5    * regarding copyright ownership.  The ASF licenses this file
+6    *  to you under the Apache License, Version 2.0 (the
+7    * "License"); you may not use this file except in compliance
+8    *  with the License.  You may obtain a copy of the License at
+9    *
+10   *   http://www.apache.org/licenses/LICENSE-2.0
+11   *
+12   * Unless required by applicable law or agreed to in writing,
+13   * software distributed under the License is distributed on an
+14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+15   * KIND, either express or implied.  See the License for the
+16   * specific language governing permissions and limitations
+17   * under the License.
+18   */
+19  package org.apache.creadur.whisker.cli;
+20  
+21  import org.apache.commons.cli.CommandLine;
+22  import org.apache.commons.cli.Option;
+23  import org.apache.commons.cli.OptionBuilder;
+24  import org.apache.commons.cli.OptionGroup;
+25  import org.apache.commons.cli.Options;
+26  
+27  /**
+28   * Describes an option on the command line.
+29   */
+30  public enum CommandLineOption {
+31  
+32      /** License descriptor command line argument. */
+33      LICENSE_DESCRIPTION("license-descriptor", 'l', 
+34              "use given license descriptor", true, "file", false),
+35      /** Application source command line argument. */
+36      SOURCE("source", 's', "application source", false, "dir", false),
+37      /** Generation command line argument. */
+38      ACT_TO_GENERATE("generate", 'g', 
+39              "generate license and notice", false, null, true),
+40      /** Audit command line argument. */
+41      ACT_TO_AUDIT("audit", 'a', "report audit details", false, null, true);
+42  
+43      /**
+44       * Creates options for the command line.
+45       * @return not null
+46       */
+47      public static Options options() {
+48          final Options options = new Options();
+49          final OptionGroup acts = new OptionGroup();
+50          acts.setRequired(true);
+51          for (final CommandLineOption option : values()) {
+52              final Option cliOption = option.create();
+53              if (option.isAct) {
+54                  acts.addOption(cliOption);
+55              } else {
+56                  options.addOption(cliOption);
+57              }
+58          }
+59          options.addOptionGroup(acts);
+60          return options;
+61      }
+62  
+63      /** The long name used for this command line argument. */
+64      private final String longName;
+65      /** The character short for this command line argument.*/
+66      private final char shortName;
+67      /** A description of this command line argument suitable for user.*/
+68      private final String description;
+69      /** Is this a mandatory argument? */
+70      private final boolean required;
+71      /** The argument name. */
+72      private final String argument;
+73      /** Is this argument within the act group? */
+74      private final boolean isAct;
+75  
+76      /**
+77       * Describes one argument.
+78       * @param longName not null
+79       * @param shortName not null
+80       * @param description not null
+81       * @param required is this mandatory?
+82       * @param argument possibly null
+83       * @param isAct is this argument an act?
+84       */
+85      private CommandLineOption(final String longName,
+86              final char shortName,
+87              final String description,
+88              final boolean required,
+89              final String argument,
+90              final boolean isAct) {
+91          this.longName = longName;
+92          this.shortName = shortName;
+93          this.description = description;
+94          this.required = required;
+95          this.argument = argument;
+96          this.isAct = isAct;
+97      }
+98  
+99      /**
+100      * Gets the long name of this command line argument.
+101      * @return not null
+102      */
+103     public String getLongName() {
+104         return longName;
+105     }
+106 
+107     /**
+108      * Gets the short name of this command line argument.
+109      * @return the character short for this option
+110      */
+111     public char getShortName() {
+112         return shortName;
+113     }
+114 
+115     /**
+116      * Gets the description for this option.
+117      * @return not null
+118      */
+119     public String getDescription() {
+120         return description;
+121     }
+122 
+123     /**
+124      * Builds a representation.
+125      * @return not null
+126      */
+127     @SuppressWarnings("static-access")
+128     public Option create() {
+129         final OptionBuilder builder = OptionBuilder
+130             .isRequired(required)
+131             .withDescription(getDescription())
+132             .withLongOpt(getLongName());
+133         if (argument != null) {
+134             builder.hasArg().withArgName(argument);
+135         }
+136         return builder.create(getShortName());
+137     }
+138 
+139     /**
+140      * Gets an option value from the command line.
+141      * @param commandLine not null
+142      * @return not null
+143      */
+144     public String getOptionValue(final CommandLine commandLine) {
+145         return commandLine.getOptionValue(getShortName());
+146     }
+147 
+148     /**
+149      * Is the short name option set?
+150      * @param commandLine not null
+151      * @return true when the option is present, false otherwise
+152      */
+153     public boolean isSetOn(final CommandLine commandLine) {
+154         return commandLine.hasOption(getShortName());
+155     }
+156 }
+
+
+ + Propchange: incubator/rat/site/trunk/content/rat/whisker/xref/org/apache/creadur/whisker/cli/CommandLineOption.html ------------------------------------------------------------------------------ svn:eol-style = native