summaryrefslogtreecommitdiff
path: root/src/main/JUTests/conf
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/JUTests/conf')
-rw-r--r--src/main/JUTests/conf/SSSyncConfParserTest.java69
-rw-r--r--src/main/JUTests/conf/testConn.yaml19
-rw-r--r--src/main/JUTests/conf/testExpectedConn.yaml22
-rw-r--r--src/main/JUTests/conf/testExpectedMain.yaml70
-rw-r--r--src/main/JUTests/conf/testMain.yaml54
5 files changed, 234 insertions, 0 deletions
diff --git a/src/main/JUTests/conf/SSSyncConfParserTest.java b/src/main/JUTests/conf/SSSyncConfParserTest.java
new file mode 100644
index 0000000..100df16
--- /dev/null
+++ b/src/main/JUTests/conf/SSSyncConfParserTest.java
@@ -0,0 +1,69 @@
+package conf;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.net.URL;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+public class SSSyncConfParserTest {
+
+ private File currentFolder;
+
+ @Before
+ public void setup() {
+ URL main = SSSyncConfParserTest.class.getResource("SSSyncConfParserTest.class");
+ if (!"file".equalsIgnoreCase(main.getProtocol()))
+ throw new IllegalStateException("This class is not stored in a file");
+ currentFolder = new File(main.getPath()).getParentFile();
+ }
+
+ @Test
+ public void loadConfigTest() throws Exception {
+
+ String expectedMain = readEntireFile(new File(currentFolder, "testExpectedMain.yaml"));
+ String expectedConn = readEntireFile(new File(currentFolder, "testExpectedConn.yaml"));
+ String mainConfigFile = new File(currentFolder, "testMain.yaml").getAbsolutePath();
+ String connConfigFile = new File(currentFolder, "testConn.yaml").getAbsolutePath();
+
+ // Loading (config => beans)
+ ConfigRootBean confMain = SSSyncConfParser.loadMainConfig(mainConfigFile);
+ ConfigConnectionsBean confConn = SSSyncConfParser.loadConnConfig(connConfigFile);
+
+
+ System.out.println(confMain);
+ System.out.println(confConn);
+
+ // Dumping (beans => config)
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ Yaml yamlDump = new Yaml(options);
+ String dumpMain = yamlDump.dump(confMain);
+ String dumpConn = yamlDump.dump(confConn);
+
+ // Checking that everything is kept
+ assertEquals(expectedMain, dumpMain);
+ assertEquals(expectedConn, dumpConn);
+ }
+
+ private static String readEntireFile(File file) throws IOException {
+ FileReader in = new FileReader(file);
+ StringBuilder contents = new StringBuilder((int) file.length());
+ char[] buffer = new char[4096];
+ int read = 0;
+ do {
+ contents.append(buffer, 0, read);
+ read = in.read(buffer);
+ } while (read >= 0);
+ in.close();
+
+ return contents.toString();
+ }
+
+}
diff --git a/src/main/JUTests/conf/testConn.yaml b/src/main/JUTests/conf/testConn.yaml
new file mode 100644
index 0000000..c41063c
--- /dev/null
+++ b/src/main/JUTests/conf/testConn.yaml
@@ -0,0 +1,19 @@
+# This file contains credentials (should be readable only by SSSync)
+connections:
+ - id : ora_1
+ type: jdbc
+ dbms: oracle
+ ress: gest
+ host: ora.univ-jfc.fr
+ port: 1521
+ user: GRHUM
+ pass: secret
+ db : GHRUM
+
+ - id : ldap_1
+ type: ldap
+ host: localhost
+ port: 389
+ bind: uid=ldapadmin,ou=specialUsers,dc=univ-jfc,dc=fr
+ pass: secret
+
diff --git a/src/main/JUTests/conf/testExpectedConn.yaml b/src/main/JUTests/conf/testExpectedConn.yaml
new file mode 100644
index 0000000..4cb3421
--- /dev/null
+++ b/src/main/JUTests/conf/testExpectedConn.yaml
@@ -0,0 +1,22 @@
+!!conf.ConfigConnectionsBean
+connections:
+- bind: null
+ db: GHRUM
+ dbms: oracle
+ host: ora.univ-jfc.fr
+ id: ora_1
+ pass: secret
+ port: 1521
+ ress: gest
+ type: jdbc
+ user: GRHUM
+- bind: uid=ldapadmin,ou=specialUsers,dc=univ-jfc,dc=fr
+ db: null
+ dbms: null
+ host: localhost
+ id: ldap_1
+ pass: secret
+ port: 389
+ ress: null
+ type: ldap
+ user: null
diff --git a/src/main/JUTests/conf/testExpectedMain.yaml b/src/main/JUTests/conf/testExpectedMain.yaml
new file mode 100644
index 0000000..dd00aef
--- /dev/null
+++ b/src/main/JUTests/conf/testExpectedMain.yaml
@@ -0,0 +1,70 @@
+!!conf.ConfigRootBean
+globals:
+ maxExecTime: 3
+tasks:
+- destination:
+ attr: uid
+ base: ou=people,dc=univ-jfc,dc=fr
+ conn: ldap_1
+ kind: ldap
+ mode: null
+ name: LDAP de test, ou=people
+ path: null
+ query: null
+ name: People sync
+ opLimits:
+ delete: 10
+ insert: 100
+ update: 10
+ skipEntryDelete: false
+ skipReadErrors: false
+ sources:
+ - attr: null
+ base: null
+ conn: ora_1
+ kind: sql
+ mode: PRIMARY_SOURCE
+ name: GHRUM, comptes et personnes
+ path: null
+ query: people.sql
+ - attr: null
+ base: null
+ conn: null
+ kind: csv
+ mode: MERGE_APPEND
+ name: CSV personnes additionnelles
+ path: people_append.csv
+ query: null
+ - attr: null
+ base: null
+ conn: null
+ kind: sorted_csv
+ mode: MERGE_REPLACE
+ name: CSV correctifs personnes
+ path: people_replace.csv
+ query: null
+- destination:
+ attr: supannEntiteAffectation
+ base: ou=structures,dc=univ-jfc,dc=fr
+ conn: ldap_1
+ kind: ldap
+ mode: null
+ name: LDAP de test, ou=structures
+ path: null
+ query: null
+ name: Structure sync
+ opLimits:
+ delete: 10
+ insert: 10
+ update: 10
+ skipEntryDelete: true
+ skipReadErrors: true
+ sources:
+ - attr: null
+ base: null
+ conn: ora_1
+ kind: sql
+ mode: PRIMARY_SOURCE
+ name: GHRUM, structures
+ path: null
+ query: structures.sql
diff --git a/src/main/JUTests/conf/testMain.yaml b/src/main/JUTests/conf/testMain.yaml
new file mode 100644
index 0000000..39350b2
--- /dev/null
+++ b/src/main/JUTests/conf/testMain.yaml
@@ -0,0 +1,54 @@
+# This YAML file describe all synchronization tasks, with their readers and writers
+
+globals:
+ maxExecTime: 3
+
+tasks:
+ - name: People sync
+ opLimits:
+ insert: 100
+ update: 10
+ delete: 10
+ sources:
+ - name: GHRUM, comptes et personnes
+ kind: sql
+ conn: ora_1
+ mode: PRIMARY_SOURCE
+ query: people.sql
+
+ - name: CSV personnes additionnelles
+ kind: csv
+ mode: MERGE_APPEND
+ path: people_append.csv
+
+ - name: CSV correctifs personnes
+ kind: sorted_csv
+ mode: MERGE_REPLACE
+ path: people_replace.csv
+
+ destination:
+ name: LDAP de test, ou=people
+ kind: ldap
+ conn: ldap_1
+ attr: uid
+ base: ou=people,dc=univ-jfc,dc=fr
+
+ - name: Structure sync
+ sources:
+ - name: GHRUM, structures
+ kind: sql
+ conn: ora_1
+ mode: PRIMARY_SOURCE
+ query: structures.sql
+ destination:
+ name: LDAP de test, ou=structures
+ kind: ldap
+ conn: ldap_1
+ attr: supannEntiteAffectation
+ base: ou=structures,dc=univ-jfc,dc=fr
+ skipEntryDelete: true
+ skipReadErrors: true
+ opLimits:
+ insert: 10
+ update: 10
+ delete: 10 \ No newline at end of file