You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by dj...@apache.org on 2016/05/14 20:13:42 UTC
svn commit: r1743855 - in /felix/trunk/scr/src:
main/java/org/apache/felix/scr/impl/ScrCommand.java
test/java/org/apache/felix/scr/impl/SCRCommandlTest.java
Author: djencks
Date: Sat May 14 20:13:42 2016
New Revision: 1743855
URL: http://svn.apache.org/viewvc?rev=1743855&view=rev
Log:
FELIX-5257 Improve formatting of command list output
Modified:
felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/SCRCommandlTest.java
Modified: felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java?rev=1743855&r1=1743854&r2=1743855&view=diff
==============================================================================
--- felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java (original)
+++ felix/trunk/scr/src/main/java/org/apache/felix/scr/impl/ScrCommand.java Sat May 14 20:13:42 2016
@@ -351,12 +351,12 @@ public class ScrCommand implements ScrIn
}
String[] services = component.serviceInterfaces;
- if ( services != null )
+ if ( services != null && services.length > 0 )
{
out.println( " Services: " );
for ( String service: services )
{
- out.print( " " );
+ out.print( " " );
out.println( service );
}
out.print( " Service Scope: " );
@@ -390,7 +390,7 @@ public class ScrCommand implements ScrIn
}
Map<String, Object> props = component.properties;
- propertyInfo(props, out, "");
+ propertyInfo(props, out, " ", "Component Description");
if ( result.configuration != null )
{
info(result.configuration, out);
@@ -416,12 +416,13 @@ public class ScrCommand implements ScrIn
out.flush();
}
- void propertyInfo(Map<String, Object> props, PrintWriter out, String prefix)
+ void propertyInfo(Map<String, Object> props, PrintWriter out, String prefix, String label)
{
if ( props != null )
{
out.print( prefix );
- out.println( " Properties:" );
+ out.print( label );
+ out.println( " Properties:" );
TreeMap<String, Object> keys = new TreeMap<String, Object>( props );
for ( Entry<String, Object> entry: keys.entrySet() )
{
@@ -474,7 +475,7 @@ public class ScrCommand implements ScrIn
{
out.print( " " );
out.println( sr.id );
- propertyInfo(sr.properties, out, " ");
+ propertyInfo(sr.properties, out, " ", "Reference" );
}
}
else
@@ -505,7 +506,7 @@ public class ScrCommand implements ScrIn
}
}
- propertyInfo( cc.properties, out, " ");
+ propertyInfo( cc.properties, out, " ", "Component Configuration" );
}
void change(final String componentIdentifier, final PrintWriter out, final boolean enable)
Modified: felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/SCRCommandlTest.java
URL: http://svn.apache.org/viewvc/felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/SCRCommandlTest.java?rev=1743855&r1=1743854&r2=1743855&view=diff
==============================================================================
--- felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/SCRCommandlTest.java (original)
+++ felix/trunk/scr/src/test/java/org/apache/felix/scr/impl/SCRCommandlTest.java Sat May 14 20:13:42 2016
@@ -37,18 +37,18 @@ public class SCRCommandlTest extends Tes
public void testPropertyInfo()
{
ScrCommand scr = new ScrCommand(null, null, null);
- check(scr, String.format(" Properties:%n key = [1, 2]%n"), new int[] {1, 2});
- check(scr, String.format(" Properties:%n key = [1, 2]%n"), new String[] {"1", "2"});
- check(scr, String.format(" Properties:%n key = [true, false]%n"), new Boolean[] {true, false});
- check(scr, String.format(" Properties:%n key = foo%n"), "foo");
- check(scr, String.format(" Properties:%n key = true%n"), true);
+ check(scr, String.format("x Properties:%n key = [1, 2]%n"), new int[] {1, 2});
+ check(scr, String.format("x Properties:%n key = [1, 2]%n"), new String[] {"1", "2"});
+ check(scr, String.format("x Properties:%n key = [true, false]%n"), new Boolean[] {true, false});
+ check(scr, String.format("x Properties:%n key = foo%n"), "foo");
+ check(scr, String.format("x Properties:%n key = true%n"), true);
}
private PrintWriter check(ScrCommand scr, String expected, Object o)
{
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
- scr.propertyInfo(Collections.<String, Object>singletonMap("key", o), pw, "");
+ scr.propertyInfo(Collections.<String, Object>singletonMap("key", o), pw, "", "x");
assertEquals(expected, sw.toString());
return pw;
}