Repository: syncope Updated Branches: refs/heads/master 07451e4cc -> 538761562
Fixed SYNCOPE-727 Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/53876156 Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/53876156 Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/53876156 Branch: refs/heads/master Commit: 538761562e922794bcb674028c2a01ff19469d5a Parents: 6b2e6f3 Author: massi <massimiliano.perr...@tirasa.net> Authored: Mon Nov 23 15:27:19 2015 +0100 Committer: massi <massimiliano.perr...@tirasa.net> Committed: Mon Nov 23 15:27:33 2015 +0100 ---------------------------------------------------------------------- .../install/InstallConfigFileTemplate.java | 6 +- .../client/cli/util/FileSystemUtils.java | 4 - .../syncope/fit/core/reference/CLIITCase.java | 98 ++++++++++++++++++-- .../src/test/resources/log4j2.xml | 33 +++++++ 4 files changed, 124 insertions(+), 17 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/53876156/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallConfigFileTemplate.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallConfigFileTemplate.java b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallConfigFileTemplate.java index 6da4e8e..2bf0ded 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallConfigFileTemplate.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/commands/install/InstallConfigFileTemplate.java @@ -19,7 +19,7 @@ package org.apache.syncope.client.cli.commands.install; import java.util.ResourceBundle; -import org.apache.syncope.client.cli.util.FileSystemUtils; +import org.apache.commons.lang3.SystemUtils; public final class InstallConfigFileTemplate { @@ -49,7 +49,7 @@ public final class InstallConfigFileTemplate { } public static String dirPath() { - if (FileSystemUtils.isWindows()) { + if (SystemUtils.IS_OS_WINDOWS) { return CONF.getString("cli.installation.directory.windows"); } else { return CONF.getString("cli.installation.directory.linux"); @@ -61,7 +61,7 @@ public final class InstallConfigFileTemplate { } private static String scriptFileName() { - if (FileSystemUtils.isWindows()) { + if (SystemUtils.IS_OS_WINDOWS) { return CONF.getString("script.file.name.windows"); } else { return CONF.getString("script.file.name.linux"); http://git-wip-us.apache.org/repos/asf/syncope/blob/53876156/client/cli/src/main/java/org/apache/syncope/client/cli/util/FileSystemUtils.java ---------------------------------------------------------------------- diff --git a/client/cli/src/main/java/org/apache/syncope/client/cli/util/FileSystemUtils.java b/client/cli/src/main/java/org/apache/syncope/client/cli/util/FileSystemUtils.java index 6ed7a9b..5c8eb68 100644 --- a/client/cli/src/main/java/org/apache/syncope/client/cli/util/FileSystemUtils.java +++ b/client/cli/src/main/java/org/apache/syncope/client/cli/util/FileSystemUtils.java @@ -42,10 +42,6 @@ public final class FileSystemUtils { return installationDirectory.exists(); } - public static boolean isWindows() { - return (System.getProperty("os.name").toLowerCase().contains("win")); - } - private FileSystemUtils() { } http://git-wip-us.apache.org/repos/asf/syncope/blob/53876156/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 f2cbf11..9fcd018 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 @@ -32,6 +32,7 @@ import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.Predicate; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.SystemUtils; +import org.apache.syncope.common.rest.api.beans.AnyListQuery; import org.junit.BeforeClass; import org.junit.FixMethodOrder; import org.junit.Test; @@ -111,12 +112,14 @@ public class CLIITCase extends AbstractITCase { int entitlements = CollectionUtils.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(); } catch (IOException e) { fail(e.getMessage()); } @@ -131,12 +134,87 @@ public class CLIITCase extends AbstractITCase { int bundles = CollectionUtils.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(); + } catch (IOException e) { + fail(e.getMessage()); + } + } + + @Test + public void userRead() { + final long userId = 1; + try { + PROCESS_BUILDER.command(getCommand("user", "--read", String.valueOf(userId))); + final Process process = PROCESS_BUILDER.start(); + final String result = IOUtils.toString(process.getInputStream()); + assertTrue(result.contains("username: " + userService.read(userId).getUsername())); + process.destroy(); + + PROCESS_BUILDER.command(getCommand("user", "--read", String.valueOf("1"), String.valueOf("2"), + String.valueOf("3"), String.valueOf("4"), String.valueOf("5"))); + final Process process2 = PROCESS_BUILDER.start(); + int users = CollectionUtils.countMatches(IOUtils.readLines(process2.getInputStream()), + new Predicate<String>() { + + @Override + public boolean evaluate(final String line) { + return line.startsWith(" > USER ID:"); + } + }); + assertEquals(userService.list(new AnyListQuery()).getResult().size(), users); + + process2.destroy(); + } catch (IOException e) { + fail(e.getMessage()); + } + } + + @Test + public void roleRead() { + final String roleId = "Search for realm evenTwo"; + try { + PROCESS_BUILDER.command(getCommand("role", "--read", roleId)); + final Process process = PROCESS_BUILDER.start(); + final String result = IOUtils.toString(process.getInputStream()); + assertTrue(result.contains(roleService.read(roleId).getEntitlements().iterator().next())); + + process.destroy(); + } catch (IOException e) { + fail(e.getMessage()); + } + } + + @Test + public void reportNotExists() { + try { + PROCESS_BUILDER.command(getCommand("report", "--read", "2")); + final Process process = PROCESS_BUILDER.start(); + final String result = IOUtils.toString(process.getInputStream()); + assertTrue(result.contains("- Report 2 doesn't exist")); + + process.destroy(); + } catch (IOException e) { + fail(e.getMessage()); + } + } + + @Test + public void policyError() { + try { + PROCESS_BUILDER.command(getCommand("policy", "--read", "wrong")); + final Process process = PROCESS_BUILDER.start(); + final String result = IOUtils.toString(process.getInputStream()); + assertTrue(result.contains( + "- Error reading wrong. It isn't a valid policy value because it isn't a boolean value")); + + process.destroy(); } catch (IOException e) { fail(e.getMessage()); } http://git-wip-us.apache.org/repos/asf/syncope/blob/53876156/fit/core-reference/src/test/resources/log4j2.xml ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/log4j2.xml b/fit/core-reference/src/test/resources/log4j2.xml new file mode 100644 index 0000000..61b388d --- /dev/null +++ b/fit/core-reference/src/test/resources/log4j2.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +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. +--> +<configuration status="WARN" shutdownHook="disable"> + <appenders> + <console name="Console" target="SYSTEM_OUT"> + <PatternLayout> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern> + </PatternLayout> + </console> + </appenders> + <loggers> + <root level="debug"> + <appenderRef ref="Console" /> + </root> + </loggers> +</configuration> \ No newline at end of file