incubator-s4-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject git commit: S4-127 fix parsing issue in Status tool
Date Fri, 08 Mar 2013 19:49:56 GMT
Updated Branches:
  refs/heads/S4-127 [created] a5aacb19f


S4-127 fix parsing issue in Status tool


Project: http://git-wip-us.apache.org/repos/asf/incubator-s4/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-s4/commit/a5aacb19
Tree: http://git-wip-us.apache.org/repos/asf/incubator-s4/tree/a5aacb19
Diff: http://git-wip-us.apache.org/repos/asf/incubator-s4/diff/a5aacb19

Branch: refs/heads/S4-127
Commit: a5aacb19ff7000391f65b6c44248c218e8c13f64
Parents: eb20b95
Author: Matthieu Morel <mmorel@apache.org>
Authored: Fri Mar 8 20:49:06 2013 +0100
Committer: Matthieu Morel <mmorel@apache.org>
Committed: Fri Mar 8 20:49:06 2013 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/s4/tools/Status.java  |    4 +-
 .../test/java/org/apache/s4/tools/TestStatus.java  |   19 +++++++++++++++
 2 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/a5aacb19/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Status.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Status.java b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Status.java
index 11fe2cd..63fd077 100644
--- a/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Status.java
+++ b/subprojects/s4-tools/src/main/java/org/apache/s4/tools/Status.java
@@ -204,12 +204,12 @@ public class Status extends S4ArgsBase {
 
     }
 
-    private static String inMiddle(String content, int width) {
+    static String inMiddle(String content, int width) {
         if (content == null) {
             content = "UNDEFINED";
         }
         int i = (width - content.length()) / 2;
-        return String.format("%" + i + "s%s", " ", content);
+        return String.format("%" + (i == 0 ? "" : (i + "s")) + "%s", " ", content);
     }
 
     private static String generateEdge(int length) {

http://git-wip-us.apache.org/repos/asf/incubator-s4/blob/a5aacb19/subprojects/s4-tools/src/test/java/org/apache/s4/tools/TestStatus.java
----------------------------------------------------------------------
diff --git a/subprojects/s4-tools/src/test/java/org/apache/s4/tools/TestStatus.java b/subprojects/s4-tools/src/test/java/org/apache/s4/tools/TestStatus.java
new file mode 100644
index 0000000..7c7bae9
--- /dev/null
+++ b/subprojects/s4-tools/src/test/java/org/apache/s4/tools/TestStatus.java
@@ -0,0 +1,19 @@
+package org.apache.s4.tools;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+
+import com.google.common.base.Strings;
+
+public class TestStatus {
+
+    @Test
+    public void testStringFormatting() {
+
+        Status.inMiddle(Strings.repeat("A", 20), 20);
+        Assert.assertTrue("Failed to parse correctly", true);
+
+    }
+
+}


Mime
View raw message