maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r1129981 - in /maven/sandbox/trunk/mae/mae-prompter-cli/src: main/java/org/apache/maven/mae/prompt/ test/ test/java/ test/java/org/ test/java/org/apache/ test/java/org/apache/maven/ test/java/org/apache/maven/mae/ test/java/org/apache/maven...
Date Wed, 01 Jun 2011 00:53:39 GMT
Author: jdcasey
Date: Wed Jun  1 00:53:38 2011
New Revision: 1129981

URL: http://svn.apache.org/viewvc?rev=1129981&view=rev
Log:
Adding test for prompter, and adjusting getSelection(..) methods of MAEPrompt.

Added:
    maven/sandbox/trunk/mae/mae-prompter-cli/src/test/
    maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/
    maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/
    maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/
    maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/
    maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/mae/
    maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/mae/prompt/
    maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/mae/prompt/MAEPromptTest.java
  (with props)
Modified:
    maven/sandbox/trunk/mae/mae-prompter-cli/src/main/java/org/apache/maven/mae/prompt/MAEPrompt.java

Modified: maven/sandbox/trunk/mae/mae-prompter-cli/src/main/java/org/apache/maven/mae/prompt/MAEPrompt.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-prompter-cli/src/main/java/org/apache/maven/mae/prompt/MAEPrompt.java?rev=1129981&r1=1129980&r2=1129981&view=diff
==============================================================================
--- maven/sandbox/trunk/mae/mae-prompter-cli/src/main/java/org/apache/maven/mae/prompt/MAEPrompt.java
(original)
+++ maven/sandbox/trunk/mae/mae-prompter-cli/src/main/java/org/apache/maven/mae/prompt/MAEPrompt.java
Wed Jun  1 00:53:38 2011
@@ -235,7 +235,7 @@ public class MAEPrompt
 
         if ( defaultReply > -1 )
         {
-            formatted.append( ' ' ).append( defaultReply ).append( ": " );
+            formatted.append( " [" ).append( defaultReply + 1 ).append( "]: " );
         }
 
         return formatted.toString();
@@ -244,7 +244,7 @@ public class MAEPrompt
     private void writePrompt( final String message )
         throws IOException
     {
-        config.getStandardOut().print( message + ": " );
+        config.getStandardOut().print( message );
     }
 
 }

Added: maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/mae/prompt/MAEPromptTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/mae/prompt/MAEPromptTest.java?rev=1129981&view=auto
==============================================================================
--- maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/mae/prompt/MAEPromptTest.java
(added)
+++ maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/mae/prompt/MAEPromptTest.java
Wed Jun  1 00:53:38 2011
@@ -0,0 +1,58 @@
+/*
+ * 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.maven.mae.prompt;
+
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
+
+import org.apache.maven.mae.conf.MAEConfiguration;
+import org.junit.Test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MAEPromptTest
+{
+    
+    @Test
+    public void getSelectionWithDefaultReturnsDefaultWhenInputIsBlank()
+        throws PromptException
+    {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ByteArrayInputStream bais = new ByteArrayInputStream( "\n".getBytes() );
+        
+        MAEConfiguration config =
+            new MAEConfiguration().withStandardIn( bais ).withStandardOut( new PrintStream(
baos ) );
+        
+        List<String> selections = new ArrayList<String>();
+        selections.add( "One" );
+        selections.add( "Two" );
+        
+        int selection = new MAEPrompt( config ).getSelection( "Choose", selections, 1 );
+        
+        System.out.println( new String( baos.toByteArray() ) );
+        
+        assertThat( selection, equalTo( 1 ) );
+    }
+
+}

Propchange: maven/sandbox/trunk/mae/mae-prompter-cli/src/test/java/org/apache/maven/mae/prompt/MAEPromptTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message