Repository: syncope
Updated Branches:
  refs/heads/master 24e414446 -> 9b033aa1b


Integration test, SYNCOPE-727


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

Branch: refs/heads/master
Commit: 9b033aa1be51f0d7b37d46434803b1f12f942c72
Parents: 7326955
Author: massi <[email protected]>
Authored: Thu Nov 19 18:06:13 2015 +0100
Committer: massi <[email protected]>
Committed: Thu Nov 19 18:06:33 2015 +0100

----------------------------------------------------------------------
 fit/core-reference/pom.xml                      |  21 +++
 .../syncope/fit/core/reference/CLIITCase.java   | 127 ++++++++++++++++++
 .../src/test/resources/log4j2.xml               | 133 +++++++++++++++++++
 3 files changed, 281 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/syncope/blob/9b033aa1/fit/core-reference/pom.xml
----------------------------------------------------------------------
diff --git a/fit/core-reference/pom.xml b/fit/core-reference/pom.xml
index 3d8af35..fb98efe 100644
--- a/fit/core-reference/pom.xml
+++ b/fit/core-reference/pom.xml
@@ -38,6 +38,7 @@ under the License.
     <jdbcdriver.artifactId>h2</jdbcdriver.artifactId>
     
     <rootpom.basedir>${basedir}/../..</rootpom.basedir>
+    <work.dir>${project.build.directory}/cli-test</work.dir>
   </properties>
 
   <dependencies>
@@ -152,6 +153,26 @@ under the License.
     <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-antrun-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>cli-test</id>
+            <goals>
+              <goal>run</goal>
+            </goals>
+            <phase>pre-integration-test</phase>
+            <configuration>
+              <target>
+                <mkdir dir="${work.dir}" />
+                <unzip 
src="../../client/cli/target/syncope-client-cli-${project.version}.zip" 
dest="${work.dir}"/>
+              </target>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-war-plugin</artifactId>
         <inherited>true</inherited>
         <configuration>

http://git-wip-us.apache.org/repos/asf/syncope/blob/9b033aa1/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
new file mode 100644
index 0000000..1f9c752
--- /dev/null
+++ 
b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/CLIITCase.java
@@ -0,0 +1,127 @@
+/*
+ * 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.syncope.fit.core.reference;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import org.junit.BeforeClass;
+import org.junit.FixMethodOrder;
+import org.junit.Test;
+import org.junit.runners.MethodSorters;
+
+@FixMethodOrder(MethodSorters.JVM)
+public class CLIITCase extends AbstractITCase {
+
+    private static final String LINUX_SCRIPT_DIR = 
"/target/cli-test/syncope-client-cli-2.0.0-SNAPSHOT";
+
+    private static final String LINUX_SCRIPT_FILENAME = "syncopeadm.sh";
+
+    private static ProcessBuilder processBuilder;
+
+    @BeforeClass
+    public static void install() {
+        try {
+            final File f = new File(".");
+            final File buildDirectory = new File(f.getCanonicalPath() + 
LINUX_SCRIPT_DIR);
+            processBuilder = new ProcessBuilder();
+            processBuilder.directory(buildDirectory);
+            final String[] command = {"/bin/bash", LINUX_SCRIPT_FILENAME, 
"install", "--setup-debug"};
+            processBuilder.command(command);
+            final Process process = processBuilder.start();
+            process.waitFor();
+            final File cliPropertiesFile = new File(buildDirectory + 
"/cli.properties");
+            assertTrue(cliPropertiesFile.exists());
+        } catch (final IOException | InterruptedException ex) {
+            fail(ex.getMessage());
+        }
+    }
+
+    @Test
+    public void runScriptWithoutOptions() {
+        try {
+            final String[] command = {"/bin/bash", LINUX_SCRIPT_FILENAME};
+            processBuilder.command(command);
+            final Process process = processBuilder.start();
+            final String result = readScriptOutput(process.getInputStream());
+            assertTrue(result.startsWith("\nUsage: Main [options]"));
+            assertTrue(result.contains("entitlement --help"));
+            assertTrue(result.contains("group --help"));
+            process.destroy();
+        } catch (IOException ex) {
+            fail(ex.getMessage());
+        }
+    }
+
+    @Test
+    public void entitlementCount() {
+        try {
+            final String[] command = {"/bin/bash", LINUX_SCRIPT_FILENAME, 
"entitlement", "--list"};
+            processBuilder.command(command);
+            final Process process = processBuilder.start();
+            final BufferedReader br = new BufferedReader(new 
InputStreamReader(process.getInputStream()));
+            int entitlementsNumber = 0;
+            String line;
+            while ((line = br.readLine()) != null) {
+                if (line.startsWith("-")) {
+                    entitlementsNumber++;
+                }
+            }
+            assertEquals(112, entitlementsNumber);
+        } catch (IOException ex) {
+            fail(ex.getMessage());
+        }
+    }
+
+    @Test
+    public void connectorCount() {
+        try {
+            final String[] command = {"/bin/bash", LINUX_SCRIPT_FILENAME, 
"connector", "--list-bundles"};
+            processBuilder.command(command);
+            final Process process = processBuilder.start();
+            final BufferedReader br = new BufferedReader(new 
InputStreamReader(process.getInputStream()));
+            int bundlesNumber = 0;
+            String line;
+            while ((line = br.readLine()) != null) {
+                if (line.startsWith(" > BUNDLE NAME:")) {
+                    bundlesNumber++;
+                }
+            }
+            assertEquals(8, bundlesNumber);
+        } catch (IOException ex) {
+            fail(ex.getMessage());
+        }
+    }
+
+    private static String readScriptOutput(final InputStream inputStream) 
throws IOException {
+        final BufferedReader br = new BufferedReader(new 
InputStreamReader(inputStream));
+        final StringBuilder resultBuilder = new StringBuilder();
+        String line;
+        while ((line = br.readLine()) != null) {
+            resultBuilder.append(line).append("\n");
+        }
+        return resultBuilder.toString();
+    }
+}

http://git-wip-us.apache.org/repos/asf/syncope/blob/9b033aa1/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..4811c94
--- /dev/null
+++ b/fit/core-reference/src/test/resources/log4j2.xml
@@ -0,0 +1,133 @@
+<?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>
+    
+    <RollingRandomAccessFile name="main" fileName="${log.directory}/core.log"
+                             
filePattern="${log.directory}/core-%d{yyyy-MM-dd}.log.gz"
+                             immediateFlush="false" append="true">
+      <PatternLayout>
+        <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+      </PatternLayout>
+      <Policies>
+        <TimeBasedTriggeringPolicy/>
+        <SizeBasedTriggeringPolicy size="250 MB"/>
+      </Policies>
+    </RollingRandomAccessFile>
+
+    <RollingRandomAccessFile name="persistence" 
fileName="${log.directory}/core-persistence.log"
+                             
filePattern="${log.directory}/core-persistence-%d{yyyy-MM-dd}.log.gz"
+                             immediateFlush="false" append="true">
+      <PatternLayout>
+        <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+      </PatternLayout>
+      <Policies>
+        <TimeBasedTriggeringPolicy/>
+        <SizeBasedTriggeringPolicy size="250 MB"/>
+      </Policies>
+    </RollingRandomAccessFile>
+
+    <RollingRandomAccessFile name="rest" 
fileName="${log.directory}/core-rest.log"
+                             
filePattern="${log.directory}/core-rest-%d{yyyy-MM-dd}.log.gz"
+                             immediateFlush="false" append="true">
+      <PatternLayout>
+        <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern>
+      </PatternLayout>
+      <Policies>
+        <TimeBasedTriggeringPolicy/>
+        <SizeBasedTriggeringPolicy size="250 MB"/>
+      </Policies>
+    </RollingRandomAccessFile>
+
+    <RollingRandomAccessFile name="connid" 
fileName="${log.directory}/core-connid.log"
+                             
filePattern="${log.directory}/core-connid-%d{yyyy-MM-dd}.log.gz"
+                             immediateFlush="false" append="true">
+      <PatternLayout>
+        <pattern>%d{HH:mm:ss.SSS} %-5level %msg%n</pattern>
+      </PatternLayout>
+      <Policies>
+        <TimeBasedTriggeringPolicy/>
+        <SizeBasedTriggeringPolicy size="250 MB"/>
+      </Policies>
+    </RollingRandomAccessFile>
+    
+  </appenders>
+  
+  <loggers>
+    
+    <asyncLogger name="org.apache.syncope.core.persistence" additivity="false" 
level="INFO">
+      <appender-ref ref="persistence"/>
+    </asyncLogger>
+    <asyncLogger name="org.springframework.orm" additivity="false" 
level="INFO">
+      <appender-ref ref="persistence"/>
+    </asyncLogger>
+    
+    <asyncLogger name="org.apache.syncope.core.rest" additivity="false" 
level="INFO">
+      <appender-ref ref="rest"/>
+    </asyncLogger>
+    <asyncLogger name="org.springframework.web" additivity="false" 
level="INFO">
+      <appender-ref ref="rest"/>
+    </asyncLogger>
+    <asyncLogger name="org.apache.http" additivity="false" level="INFO">
+      <appender-ref ref="rest"/>
+    </asyncLogger>
+    <asyncLogger name="org.apache.cxf" additivity="false" level="ERROR">
+      <appender-ref ref="rest"/>
+    </asyncLogger>
+    
+    <asyncLogger name="org.identityconnectors" additivity="false" 
level="DEBUG">
+      <appender-ref ref="connid"/>
+    </asyncLogger>
+    <asyncLogger name="net.tirasa.connid" additivity="false" level="DEBUG">
+      <appender-ref ref="connid"/>
+    </asyncLogger>
+    <asyncLogger 
name="org.apache.syncope.core.provisioning.api.ConnIdBundleManager" 
additivity="false" level="INFO">
+      <appender-ref ref="connid"/>
+    </asyncLogger>
+    
+    <asyncLogger name="org.apache.syncope" additivity="false" level="INFO">
+      <appender-ref ref="main"/>
+    </asyncLogger>
+    <asyncLogger name="org.apache.syncope.core.provisioning" 
additivity="false" level="INFO">
+      <appender-ref ref="main"/>
+    </asyncLogger>
+    <asyncLogger name="org.apache.syncope.core.logic" additivity="false" 
level="INFO">
+      <appender-ref ref="main"/>
+    </asyncLogger>
+    <asyncLogger name="org.springframework" additivity="false" level="INFO">
+      <appender-ref ref="main"/>
+    </asyncLogger>
+    <asyncLogger name="org.quartz" additivity="false" level="INFO">
+      <appender-ref ref="main"/>
+    </asyncLogger>
+    <asyncLogger name="org.activiti" additivity="false" level="ERROR">
+      <appender-ref ref="main"/>
+    </asyncLogger>
+    <asyncLogger name="org.apache.camel" additivity="false" level="ERROR">
+      <appender-ref ref="main"/>
+    </asyncLogger>
+    
+    <root level="INFO">
+      <appender-ref ref="main"/>
+    </root>
+    
+  </loggers>
+</configuration>

Reply via email to