syncope-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject syncope git commit: Improved IT, SYNCOPE-158
Date Tue, 01 Dec 2015 10:33:43 GMT
Repository: syncope
Updated Branches:
  refs/heads/master 234819b6e -> d433501b9


Improved IT, SYNCOPE-158


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

Branch: refs/heads/master
Commit: d433501b978ea120436de48c7dbcaf08f8d8e249
Parents: 234819b
Author: massi <massimiliano.perrone@tirasa.net>
Authored: Tue Dec 1 11:27:54 2015 +0100
Committer: massi <massimiliano.perrone@tirasa.net>
Committed: Tue Dec 1 11:27:54 2015 +0100

----------------------------------------------------------------------
 client/cli/pom.xml                              |  4 +-
 .../commands/connector/ConnectorCommand.java    |  2 +-
 .../entitlement/EntitlementCommand.java         |  2 +-
 .../client/cli/commands/group/GroupCommand.java |  2 +-
 .../cli/commands/install/InstallCommand.java    |  2 +-
 .../cli/commands/policy/PolicyCommand.java      | 16 ++--
 .../cli/commands/report/ReportCommand.java      | 16 ++--
 .../client/cli/commands/role/RoleCommand.java   |  2 +-
 .../client/cli/commands/user/UserCommand.java   |  2 +-
 fit/core-reference/pom.xml                      |  6 ++
 .../syncope/fit/core/reference/CLIITCase.java   | 90 ++++++++++++++------
 11 files changed, 93 insertions(+), 51 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/pom.xml
----------------------------------------------------------------------
diff --git a/client/cli/pom.xml b/client/cli/pom.xml
index 61282ce..b1b1e08 100644
--- a/client/cli/pom.xml
+++ b/client/cli/pom.xml
@@ -30,8 +30,8 @@ under the License.
 
   <name>Apache Syncope Client CLI</name>
   <description>Apache Syncope Client CLI</description>
-
-  <groupId>org.apache.syncope</groupId>
+  
+  <groupId>org.apache.syncope.client</groupId>
   <artifactId>syncope-client-cli</artifactId>
   <packaging>jar</packaging>
 

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
index b08ecd5..aeec15c 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/connector/ConnectorCommand.java
@@ -71,7 +71,7 @@ public class ConnectorCommand extends AbstractCommand {
         return connectorResultManager.commandHelpMessage(getClass());
     }
 
-    private enum ConnectorOptions {
+    public enum ConnectorOptions {
 
         HELP("--help"),
         LIST("--list"),

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementCommand.java
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementCommand.java
index de35fc3..42949a7 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/entitlement/EntitlementCommand.java
@@ -65,7 +65,7 @@ public class EntitlementCommand extends AbstractCommand {
         return entitlementResultManager.commandHelpMessage(getClass());
     }
 
-    private enum EntitlementOptions {
+    public enum EntitlementOptions {
 
         HELP("--help"),
         LIST("--list"),

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupCommand.java
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupCommand.java
index e5d4e39..fee8252 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/group/GroupCommand.java
@@ -67,7 +67,7 @@ public class GroupCommand extends AbstractCommand {
         return groupResultManager.commandHelpMessage(getClass());
     }
 
-    private enum GroupOptions {
+    public enum GroupOptions {
 
         HELP("--help"),
         DETAILS("--details"),

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallCommand.java
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallCommand.java
index 21a5b40..172e261 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallCommand.java
@@ -77,7 +77,7 @@ public class InstallCommand extends AbstractCommand {
         return HELP_MESSAGE;
     }
 
-    private enum Options {
+    public enum Options {
 
         HELP("--help"),
         SETUP("--setup"),

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyCommand.java
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyCommand.java
index bceb0d6..f334888 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/policy/PolicyCommand.java
@@ -33,10 +33,10 @@ public class PolicyCommand extends AbstractCommand {
     @Override
     public void execute(final Input input) {
         if (StringUtils.isBlank(input.getOption())) {
-            input.setOption(Options.HELP.getOptionName());
+            input.setOption(PolicyOptions.HELP.getOptionName());
         }
 
-        switch (Options.fromName(input.getOption())) {
+        switch (PolicyOptions.fromName(input.getOption())) {
             case DETAILS:
                 new PolicyDetails(input).details();
                 break;
@@ -62,7 +62,7 @@ public class PolicyCommand extends AbstractCommand {
         return policyResultManager.commandHelpMessage(getClass());
     }
 
-    private enum Options {
+    public enum PolicyOptions {
 
         HELP("--help"),
         DETAILS("--details"),
@@ -72,7 +72,7 @@ public class PolicyCommand extends AbstractCommand {
 
         private final String optionName;
 
-        Options(final String optionName) {
+        PolicyOptions(final String optionName) {
             this.optionName = optionName;
         }
 
@@ -84,9 +84,9 @@ public class PolicyCommand extends AbstractCommand {
             return (otherName == null) ? false : optionName.equals(otherName);
         }
 
-        public static Options fromName(final String name) {
-            Options optionToReturn = HELP;
-            for (final Options option : Options.values()) {
+        public static PolicyOptions fromName(final String name) {
+            PolicyOptions optionToReturn = HELP;
+            for (final PolicyOptions option : PolicyOptions.values()) {
                 if (option.equalsOptionName(name)) {
                     optionToReturn = option;
                 }
@@ -96,7 +96,7 @@ public class PolicyCommand extends AbstractCommand {
 
         public static List<String> toList() {
             final List<String> options = new ArrayList<>();
-            for (final Options value : values()) {
+            for (final PolicyOptions value : values()) {
                 options.add(value.getOptionName());
             }
             return options;

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportCommand.java
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportCommand.java
index fcbf1ae..ff7860a 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/report/ReportCommand.java
@@ -33,10 +33,10 @@ public class ReportCommand extends AbstractCommand {
     @Override
     public void execute(final Input input) {
         if (StringUtils.isBlank(input.getOption())) {
-            input.setOption(Options.HELP.getOptionName());
+            input.setOption(ReportOptions.HELP.getOptionName());
         }
 
-        switch (Options.fromName(input.getOption())) {
+        switch (ReportOptions.fromName(input.getOption())) {
             case LIST:
                 new ReportList(input).list();
                 break;
@@ -77,7 +77,7 @@ public class ReportCommand extends AbstractCommand {
         return reportResultManager.commandHelpMessage(getClass());
     }
 
-    private enum Options {
+    public enum ReportOptions {
 
         HELP("--help"),
         DETAILS("--details"),
@@ -92,7 +92,7 @@ public class ReportCommand extends AbstractCommand {
 
         private final String optionName;
 
-        Options(final String optionName) {
+        ReportOptions(final String optionName) {
             this.optionName = optionName;
         }
 
@@ -104,9 +104,9 @@ public class ReportCommand extends AbstractCommand {
             return (otherName == null) ? false : optionName.equals(otherName);
         }
 
-        public static Options fromName(final String name) {
-            Options optionToReturn = HELP;
-            for (final Options option : Options.values()) {
+        public static ReportOptions fromName(final String name) {
+            ReportOptions optionToReturn = HELP;
+            for (final ReportOptions option : ReportOptions.values()) {
                 if (option.equalsOptionName(name)) {
                     optionToReturn = option;
                 }
@@ -116,7 +116,7 @@ public class ReportCommand extends AbstractCommand {
 
         public static List<String> toList() {
             final List<String> options = new ArrayList<>();
-            for (final Options value : values()) {
+            for (final ReportOptions value : values()) {
                 options.add(value.getOptionName());
             }
             return options;

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleCommand.java
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleCommand.java
index 818d707..52974ac 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/role/RoleCommand.java
@@ -62,7 +62,7 @@ public class RoleCommand extends AbstractCommand {
         return roleResultManager.commandHelpMessage(getClass());
     }
 
-    private enum RoleOptions {
+    public enum RoleOptions {
 
         HELP("--help"),
         DETAILS("--details"),

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserCommand.java
----------------------------------------------------------------------
diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserCommand.java
b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserCommand.java
index e74eb95..ec0aff4 100644
--- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserCommand.java
+++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/user/UserCommand.java
@@ -86,7 +86,7 @@ public class UserCommand extends AbstractCommand {
         return userResultManager.commandHelpMessage(getClass());
     }
 
-    private enum UserOptions {
+    public enum UserOptions {
 
         HELP("--help"),
         DETAILS("--details"),

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/fit/core-reference/pom.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index 223c611..e686bdc 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -138,6 +138,12 @@ under the License.
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.syncope.client</groupId>
+      <artifactId>syncope-client-cli</artifactId>
+      <version>${project.version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-test</artifactId>
       <scope>test</scope>

http://git-wip-us.apache.org/repos/asf/syncope/blob/d433501b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
----------------------------------------------------------------------
diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
index 26f23d4..746459f 100644
--- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
+++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
@@ -33,6 +33,15 @@ import org.apache.commons.collections4.IterableUtils;
 import org.apache.commons.collections4.Predicate;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.SystemUtils;
+import org.apache.syncope.client.cli.Command;
+import org.apache.syncope.client.cli.commands.connector.ConnectorCommand;
+import org.apache.syncope.client.cli.commands.entitlement.EntitlementCommand;
+import org.apache.syncope.client.cli.commands.group.GroupCommand;
+import org.apache.syncope.client.cli.commands.install.InstallCommand;
+import org.apache.syncope.client.cli.commands.policy.PolicyCommand;
+import org.apache.syncope.client.cli.commands.report.ReportCommand;
+import org.apache.syncope.client.cli.commands.role.RoleCommand;
+import org.apache.syncope.client.cli.commands.user.UserCommand;
 import org.junit.BeforeClass;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
@@ -57,7 +66,9 @@ public class CLIITCase extends AbstractITCase {
             PROCESS_BUILDER = new ProcessBuilder();
             PROCESS_BUILDER.directory(workDir);
 
-            PROCESS_BUILDER.command(getCommand("install", "--setup-debug"));
+            PROCESS_BUILDER.command(getCommand(
+                    new InstallCommand().getClass().getAnnotation(Command.class).name(),
+                    InstallCommand.Options.SETUP_DEBUG.getOptionName()));
             Process process = PROCESS_BUILDER.start();
             process.waitFor();
 
@@ -94,9 +105,14 @@ public class CLIITCase extends AbstractITCase {
 
             String result = IOUtils.toString(process.getInputStream());
             assertTrue(result.startsWith("\nUsage: Main [options]"));
-            assertTrue(result.contains("entitlement --help"));
-            assertTrue(result.contains("group --help"));
-
+            assertTrue(result.contains(
+                    new EntitlementCommand().getClass().getAnnotation(Command.class).name()
+                    + " "
+                    + EntitlementCommand.EntitlementOptions.HELP.getOptionName()));
+            assertTrue(result.contains(
+                    new GroupCommand().getClass().getAnnotation(Command.class).name()
+                    + " "
+                    + GroupCommand.GroupOptions.HELP.getOptionName()));
             process.destroy();
         } catch (IOException e) {
             fail(e.getMessage());
@@ -106,17 +122,19 @@ public class CLIITCase extends AbstractITCase {
     @Test
     public void entitlementCount() {
         try {
-            PROCESS_BUILDER.command(getCommand("entitlement", "--list"));
+            PROCESS_BUILDER.command(getCommand(
+                    new EntitlementCommand().getClass().getAnnotation(Command.class).name(),
+                    EntitlementCommand.EntitlementOptions.LIST.getOptionName()));
             Process process = PROCESS_BUILDER.start();
 
             long entitlements = IterableUtils.countMatches(IOUtils.readLines(process.getInputStream()),
                     new Predicate<String>() {
 
-                @Override
-                public boolean evaluate(final String line) {
-                    return line.startsWith("-");
-                }
-            });
+                        @Override
+                        public boolean evaluate(final String line) {
+                            return line.startsWith("-");
+                        }
+                    });
             assertEquals(syncopeService.info().getEntitlements().size(), entitlements);
 
             process.destroy();
@@ -128,17 +146,19 @@ public class CLIITCase extends AbstractITCase {
     @Test
     public void connectorCount() {
         try {
-            PROCESS_BUILDER.command(getCommand("connector", "--list-bundles"));
+            PROCESS_BUILDER.command(getCommand(
+                    new ConnectorCommand().getClass().getAnnotation(Command.class).name(),
+                    ConnectorCommand.ConnectorOptions.LIST_BUNDLES.getOptionName()));
             Process process = PROCESS_BUILDER.start();
 
             long bundles = IterableUtils.countMatches(IOUtils.readLines(process.getInputStream()),
                     new Predicate<String>() {
 
-                @Override
-                public boolean evaluate(final String line) {
-                    return line.startsWith(" > BUNDLE NAME:");
-                }
-            });
+                        @Override
+                        public boolean evaluate(final String line) {
+                            return line.startsWith(" > BUNDLE NAME:");
+                        }
+                    });
             assertEquals(connectorService.getBundles(null).size(), bundles);
 
             process.destroy();
@@ -155,30 +175,37 @@ public class CLIITCase extends AbstractITCase {
         final long userId4 = 4;
         final long userId5 = 5;
         try {
-            PROCESS_BUILDER.command(getCommand("user", "--read-by-userid", String.valueOf(userId1)));
+            PROCESS_BUILDER.command(getCommand(
+                    new UserCommand().getClass().getAnnotation(Command.class).name(),
+                    UserCommand.UserOptions.READ_BY_ID.getOptionName(),
+                    String.valueOf(userId1)));
             Process process = PROCESS_BUILDER.start();
             String result = IOUtils.toString(process.getInputStream());
             assertTrue(result.contains("username: " + userService.read(userId1).getUsername()));
             process.destroy();
 
             PROCESS_BUILDER.command(getCommand(
-                    "user", "--read-by-userid", String.valueOf(userId1), String.valueOf(userId2),
+                    new UserCommand().getClass().getAnnotation(Command.class).name(),
+                    UserCommand.UserOptions.READ_BY_ID.getOptionName(),
+                    String.valueOf(userId1), String.valueOf(userId2),
                     String.valueOf(userId3), String.valueOf(userId4), String.valueOf(userId5)));
             Process process2 = PROCESS_BUILDER.start();
             long users = IterableUtils.countMatches(IOUtils.readLines(process2.getInputStream()),
                     new Predicate<String>() {
 
-                @Override
-                public boolean evaluate(final String line) {
-                    return line.startsWith(" > USER ID:");
-                }
-            });
+                        @Override
+                        public boolean evaluate(final String line) {
+                            return line.startsWith(" > USER ID:");
+                        }
+                    });
             assertEquals(5, users);
 
             process2.destroy();
 
             PROCESS_BUILDER.command(getCommand(
-                    "user", "--read-by-userid", String.valueOf(userId1), String.valueOf(userId2),
+                    new UserCommand().getClass().getAnnotation(Command.class).name(),
+                    UserCommand.UserOptions.READ_BY_ID.getOptionName(),
+                    String.valueOf(userId1), String.valueOf(userId2),
                     String.valueOf(userId3), String.valueOf(userId4), String.valueOf(userId5)));
             Process process3 = PROCESS_BUILDER.start();
             String result3 = IOUtils.toString(process3.getInputStream());
@@ -198,7 +225,10 @@ public class CLIITCase extends AbstractITCase {
     public void roleRead() {
         final String roleId = "Search for realm evenTwo";
         try {
-            PROCESS_BUILDER.command(getCommand("role", "--read", roleId));
+            PROCESS_BUILDER.command(getCommand(
+                    new RoleCommand().getClass().getAnnotation(Command.class).name(),
+                    RoleCommand.RoleOptions.READ.getOptionName(),
+                    roleId));
             final Process process = PROCESS_BUILDER.start();
             final String result = IOUtils.toString(process.getInputStream());
             assertTrue(result.contains(roleService.read(roleId).getEntitlements().iterator().next()));
@@ -212,7 +242,10 @@ public class CLIITCase extends AbstractITCase {
     @Test
     public void reportNotExists() {
         try {
-            PROCESS_BUILDER.command(getCommand("report", "--read", "2"));
+            PROCESS_BUILDER.command(getCommand(
+                    new ReportCommand().getClass().getAnnotation(Command.class).name(),
+                    ReportCommand.ReportOptions.READ.getOptionName(),
+                    "2"));
             final Process process = PROCESS_BUILDER.start();
             final String result = IOUtils.toString(process.getInputStream());
             assertTrue(result.contains("- Report 2 doesn't exist"));
@@ -226,7 +259,10 @@ public class CLIITCase extends AbstractITCase {
     @Test
     public void policyError() {
         try {
-            PROCESS_BUILDER.command(getCommand("policy", "--read", "wrong"));
+            PROCESS_BUILDER.command(getCommand(
+                    new PolicyCommand().getClass().getAnnotation(Command.class).name(),
+                    PolicyCommand.PolicyOptions.READ.getOptionName(),
+                    "wrong"));
             final Process process = PROCESS_BUILDER.start();
             final String result = IOUtils.toString(process.getInputStream());
             assertTrue(result.contains(


Mime
View raw message