You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fg...@apache.org on 2010/07/29 19:18:22 UTC

svn commit: r980514 [3/4] - in /incubator/chemistry/opencmis/trunk/chemistry-opencmis-test: chemistry-opencmis-test-fit/src/main/webapp/WEB-INF/ chemistry-opencmis-test-fit/src/main/webapp/WEB-INF/classes/ chemistry-opencmis-test-fit/src/test/java/org/...

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runcmd.bat
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runcmd.bat?rev=980514&r1=980513&r2=980514&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runcmd.bat (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runcmd.bat Thu Jul 29 17:18:20 2010
@@ -1,51 +1,51 @@
-rem
-rem
-rem Licensed to the Apache Software Foundation (ASF) under one
-rem or more contributor license agreements.  See the NOTICE file
-rem distributed with this work for additional information
-rem regarding copyright ownership.  The ASF licenses this file
-rem to you under the Apache License, Version 2.0 (the
-rem "License"); you may not use this file except in compliance
-rem with the License.  You may obtain a copy of the License at
-rem
-rem   http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing,
-rem software distributed under the License is distributed on an
-rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-rem KIND, either express or implied.  See the License for the
-rem specific language governing permissions and limitations
-rem under the License.
-rem
-rem
-set M2_REPO=c:\java\maven-repository
-set JAVA_HOME=C:\Java\jdk.1.6.0_14
-set PATH=%JAVA_HOME%\bin
-
-java -Dopencmis.test.atompub.url=http://localhost:8080/opencmis/atom -cp ^
-./target/classes;^
-%M2_REPO%/javax/activation/activation/1.1/activation-1.1.jar;^
-%M2_REPO%/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar;^
-%M2_REPO%/javax/xml/ws/jaxws-api/2.1/jaxws-api-2.1.jar;^
-%M2_REPO%/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.jar;^
-%M2_REPO%/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar;^
-%M2_REPO%/javax/xml/soap/saaj-api/1.3/saaj-api-1.3.jar;^
-%M2_REPO%/javax/xml/stream/stax-api/1.0/stax-api-1.0.jar;^
-%M2_REPO%/commons-codec/commons-codec/1.4/commons-codec-1.4.jar;^
-%M2_REPO%/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar;^
-%M2_REPO%/com/sun/xml/bind/jaxb-impl/2.1.11/jaxb-impl-2.1.11.jar;^
-%M2_REPO%/com/sun/xml/ws/jaxws-rt/2.1.7/jaxws-rt-2.1.7.jar;^
-%M2_REPO%/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2.jar;^
-%M2_REPO%/junit/junit/4.8.1/junit-4.8.1.jar;^
-%M2_REPO%/org/jvnet/mimepull/1.3/mimepull-1.3.jar;^
-%M2_REPO%/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar;^
-%M2_REPO%/com/sun/xml/messaging/saaj/saaj-impl/1.3.3/saaj-impl-1.3.3.jar;^
-%M2_REPO%/stax/stax-api/1.0.1/stax-api-1.0.1.jar;^
-%M2_REPO%/org/jvnet/staxex/stax-ex/1.2/stax-ex-1.2.jar;^
-%M2_REPO%/com/sun/xml/stream/buffer/streambuffer/0.9/streambuffer-0.9.jar;^
-%M2_REPO%/org/codehaus/woodstox/wstx-asl/3.2.3/wstx-asl-3.2.3.jar;^
-%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-client-bindings/0.1-incubating-SNAPSHOT/chemistry-opencmis-client-bindings-0.1-incubating-SNAPSHOT.jar;^
-%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-commons-impl/0.1-incubating-SNAPSHOT/chemistry-opencmis-commons-impl-0.1-incubating-SNAPSHOT.jar;^
-%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-commons-api/0.1-incubating-SNAPSHOT/chemistry-opencmis-commons-api-0.1-incubating-SNAPSHOT.jar;^
-%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-test-util/0.1-incubating-SNAPSHOT/chemistry-opencmis-test-util-0.1-incubating-SNAPSHOT.jar ^
-org.apache.chemistry.opencmis.util.repository.ObjGenApp %*
+rem
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements.  See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership.  The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with the License.  You may obtain a copy of the License at
+rem
+rem   http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing,
+rem software distributed under the License is distributed on an
+rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem KIND, either express or implied.  See the License for the
+rem specific language governing permissions and limitations
+rem under the License.
+rem
+rem
+set M2_REPO=c:\java\maven-repository
+set JAVA_HOME=C:\Java\jdk.1.6.0_14
+set PATH=%JAVA_HOME%\bin
+
+java -Dopencmis.test.atompub.url=http://localhost:8080/opencmis/atom -cp ^
+./target/classes;^
+%M2_REPO%/javax/activation/activation/1.1/activation-1.1.jar;^
+%M2_REPO%/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar;^
+%M2_REPO%/javax/xml/ws/jaxws-api/2.1/jaxws-api-2.1.jar;^
+%M2_REPO%/javax/jws/jsr181-api/1.0-MR1/jsr181-api-1.0-MR1.jar;^
+%M2_REPO%/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar;^
+%M2_REPO%/javax/xml/soap/saaj-api/1.3/saaj-api-1.3.jar;^
+%M2_REPO%/javax/xml/stream/stax-api/1.0/stax-api-1.0.jar;^
+%M2_REPO%/commons-codec/commons-codec/1.4/commons-codec-1.4.jar;^
+%M2_REPO%/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar;^
+%M2_REPO%/com/sun/xml/bind/jaxb-impl/2.1.11/jaxb-impl-2.1.11.jar;^
+%M2_REPO%/com/sun/xml/ws/jaxws-rt/2.1.7/jaxws-rt-2.1.7.jar;^
+%M2_REPO%/net/sf/jopt-simple/jopt-simple/3.2/jopt-simple-3.2.jar;^
+%M2_REPO%/junit/junit/4.8.1/junit-4.8.1.jar;^
+%M2_REPO%/org/jvnet/mimepull/1.3/mimepull-1.3.jar;^
+%M2_REPO%/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar;^
+%M2_REPO%/com/sun/xml/messaging/saaj/saaj-impl/1.3.3/saaj-impl-1.3.3.jar;^
+%M2_REPO%/stax/stax-api/1.0.1/stax-api-1.0.1.jar;^
+%M2_REPO%/org/jvnet/staxex/stax-ex/1.2/stax-ex-1.2.jar;^
+%M2_REPO%/com/sun/xml/stream/buffer/streambuffer/0.9/streambuffer-0.9.jar;^
+%M2_REPO%/org/codehaus/woodstox/wstx-asl/3.2.3/wstx-asl-3.2.3.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-client-bindings/0.1-incubating-SNAPSHOT/chemistry-opencmis-client-bindings-0.1-incubating-SNAPSHOT.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-commons-impl/0.1-incubating-SNAPSHOT/chemistry-opencmis-commons-impl-0.1-incubating-SNAPSHOT.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-commons-api/0.1-incubating-SNAPSHOT/chemistry-opencmis-commons-api-0.1-incubating-SNAPSHOT.jar;^
+%M2_REPO%/org/apache/chemistry/opencmis/chemistry-opencmis-test-util/0.1-incubating-SNAPSHOT/chemistry-opencmis-test-util-0.1-incubating-SNAPSHOT.jar ^
+org.apache.chemistry.opencmis.util.repository.ObjGenApp %*

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runcmd.bat
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runfill.bat
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runfill.bat?rev=980514&r1=980513&r2=980514&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runfill.bat (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runfill.bat Thu Jul 29 17:18:20 2010
@@ -1,22 +1,22 @@
-rem
-rem
-rem Licensed to the Apache Software Foundation (ASF) under one
-rem or more contributor license agreements.  See the NOTICE file
-rem distributed with this work for additional information
-rem regarding copyright ownership.  The ASF licenses this file
-rem to you under the Apache License, Version 2.0 (the
-rem "License"); you may not use this file except in compliance
-rem with the License.  You may obtain a copy of the License at
-rem
-rem   http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing,
-rem software distributed under the License is distributed on an
-rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-rem KIND, either express or implied.  See the License for the
-rem specific language governing permissions and limitations
-rem under the License.
-rem
-rem
-call runcmd.bat --Command=FillRepository --RepositoryId=A1 --Depth=1 --DocsPerFolder=1 ^
---FoldersPerFolder=0  --ContentSizeInKB=25
+rem
+rem
+rem Licensed to the Apache Software Foundation (ASF) under one
+rem or more contributor license agreements.  See the NOTICE file
+rem distributed with this work for additional information
+rem regarding copyright ownership.  The ASF licenses this file
+rem to you under the Apache License, Version 2.0 (the
+rem "License"); you may not use this file except in compliance
+rem with the License.  You may obtain a copy of the License at
+rem
+rem   http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing,
+rem software distributed under the License is distributed on an
+rem "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+rem KIND, either express or implied.  See the License for the
+rem specific language governing permissions and limitations
+rem under the License.
+rem
+rem
+call runcmd.bat --Command=FillRepository --RepositoryId=A1 --Depth=1 --DocsPerFolder=1 ^
+--FoldersPerFolder=0  --ContentSizeInKB=25

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/runfill.bat
------------------------------------------------------------------------------
    svn:eol-style = CRLF

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java?rev=980514&r1=980513&r2=980514&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java Thu Jul 29 17:18:20 2010
@@ -1,230 +1,230 @@
-/*
- * 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.chemistry.opencmis.util.repository;
-
-import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
-import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-import org.apache.chemistry.opencmis.commons.spi.NavigationService;
-import org.apache.chemistry.opencmis.commons.spi.ObjectService;
-import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
-
-public class MultiThreadedObjectGenerator {
-
-    static public enum Action {
-        CreateDocument, CreateTree, CreateFolders
-    };
-
-    static class ObjectGeneratorRunner implements Runnable {
-        private Action fAction;
-        ObjectGenerator fObjGen;
-        private String fRootFolderId;
-        private int fFoldersPerFolders;
-        private int fDepth;
-        private int fCount;
-
-        public ObjectGeneratorRunner(ObjectGenerator objGen, Action action) {
-            fObjGen = objGen;
-            fAction = action;
-        }
-
-        public void run() {
-            if (fAction == Action.CreateDocument) {
-                doCreateDocument();
-            } else if (fAction == Action.CreateTree) {
-                doCreateTree();
-            } else if (fAction == Action.CreateFolders) {
-                doCreateFolder();
-            }
-        }
-
-        public String[] doCreateDocument() {
-            String ids[] = fObjGen.createDocuments(fRootFolderId, fCount);
-            return ids;
-        }
-
-        public void doCreateTree() {
-            fObjGen.createFolderHierachy(fDepth, fFoldersPerFolders, fRootFolderId);
-        }
-
-        public String[] doCreateFolder() {
-            return fObjGen.createFolders(fRootFolderId, fCount);
-        }
-
-        public ObjectGenerator getObjectGenerator() {
-            return fObjGen;
-        }
-
-    } // ObjectCreatorRunner
-
-    static private ObjectGenerator createObjectGenerator(CmisBinding binding, String repoId, int docsPerFolder,
-            int foldersPerFolders, int depth, String documentType, String folderType, int contentSizeInKB,
-            String rootFolderId, boolean doCleanup) {
-
-        BindingsObjectFactory objectFactory = binding.getObjectFactory();
-        NavigationService navSvc = binding.getNavigationService();
-        ObjectService objSvc = binding.getObjectService();
-
-        ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repoId);
-        gen.setUseUuidsForNames(true);
-        gen.setNumberOfDocumentsToCreatePerFolder(docsPerFolder);
-        // Set the type id for all created documents:
-        gen.setDocumentTypeId(documentType);
-        // Set the type id for all created folders:
-        gen.setFolderTypeId(folderType);
-        // Set contentSize
-        gen.setContentSizeInKB(contentSizeInKB);
-        gen.setCleanUpAfterCreate(doCleanup);
-
-        return gen;
-    }
-
-    static private String getRootFolderId(CmisBinding binding, String repositoryId, String rootFolderId) {
-        RepositoryService repSvc = binding.getRepositoryService();
-
-        RepositoryInfo rep = repSvc.getRepositoryInfo(repositoryId, null);
-        if (null == rootFolderId || rootFolderId.length() == 0)
-            rootFolderId = rep.getRootFolderId();
-
-        return rootFolderId;
-    }
-
-    public static ObjectGeneratorRunner prepareForCreateTree(CmisBinding binding, String repoId, int docsPerFolder,
-            int foldersPerFolders, int depth, String documentType, String folderType, int contentSizeInKB,
-            String rootFolderId, boolean doCleanup) {
-
-        ObjectGenerator objGen = createObjectGenerator(binding, repoId, docsPerFolder, foldersPerFolders, depth,
-                documentType, folderType, contentSizeInKB, rootFolderId, doCleanup);
-
-        ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateTree);
-        gen.fFoldersPerFolders = foldersPerFolders;
-        gen.fDepth = depth;
-        gen.fRootFolderId = getRootFolderId(binding, repoId, rootFolderId);
-        return gen;
-    }
-
-    public static ObjectGeneratorRunner[] prepareForCreateTreeMT(CmisBinding provider, String repoId,
-            int docsPerFolder, int foldersPerFolders, int depth, String documentType, String folderType,
-            int contentSizeInKB, String[] rootFolderIds, boolean doCleanup) {
-
-        ObjectGeneratorRunner[] runners = new ObjectGeneratorRunner[rootFolderIds.length];
-        for (int i = 0; i < rootFolderIds.length; i++) {
-            ObjectGenerator objGen = createObjectGenerator(provider, repoId, docsPerFolder, foldersPerFolders, depth,
-                    documentType, folderType, contentSizeInKB, rootFolderIds[i], doCleanup);
-
-            ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateTree);
-            gen.fFoldersPerFolders = foldersPerFolders;
-            gen.fDepth = depth;
-            gen.fRootFolderId = rootFolderIds[i];
-            runners[i] = gen;
-        }
-        return runners;
-    }
-
-    public static ObjectGeneratorRunner prepareForCreateDocument(CmisBinding provider, String repoId,
-            String documentType, int contentSizeInKB, String rootFolderId, int noDocuments, boolean doCleanup) {
-
-        ObjectGenerator objGen = createObjectGenerator(provider, repoId, 0, 0, 0, documentType, null, contentSizeInKB,
-                rootFolderId, doCleanup);
-
-        ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateDocument);
-        gen.fRootFolderId = getRootFolderId(provider, repoId, rootFolderId);
-        gen.fCount = noDocuments;
-        return gen;
-    }
-
-    public static ObjectGeneratorRunner[] prepareForCreateDocumentMT(int threadCount, CmisBinding binding,
-            String repoId, String documentType, int contentSizeInKB, String rootFolderId, int noDocuments,
-            boolean doCleanup) {
-
-        ObjectGeneratorRunner[] runners = new ObjectGeneratorRunner[threadCount];
-        for (int i = 0; i < threadCount; i++) {
-            ObjectGenerator objGen = createObjectGenerator(binding, repoId, 0, 0, 0, documentType, null,
-                    contentSizeInKB, rootFolderId, doCleanup);
-
-            ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateDocument);
-            gen.fRootFolderId = getRootFolderId(binding, repoId, rootFolderId);
-            gen.fCount = noDocuments;
-            runners[i] = gen;
-        }
-        return runners;
-    }
-
-    public static ObjectGeneratorRunner prepareForCreateFolder(CmisBinding provider, String repoId, String folderType,
-            String rootFolderId, int noFolders, boolean doCleanup) {
-
-        ObjectGenerator objGen = createObjectGenerator(provider, repoId, 0, 0, 0, null, folderType, 0, rootFolderId,
-                doCleanup);
-
-        ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateFolders);
-        gen.fRootFolderId = getRootFolderId(provider, repoId, rootFolderId);
-        gen.fCount = noFolders;
-        return gen;
-    }
-
-    public static ObjectGeneratorRunner[] prepareForCreateFolderMT(int threadCount, CmisBinding binding, String repoId,
-            String folderType, String rootFolderId, int noFolders, boolean doCleanup) {
-
-        ObjectGeneratorRunner[] runners = new ObjectGeneratorRunner[threadCount];
-        for (int i = 0; i < threadCount; i++) {
-            ObjectGenerator objGen = createObjectGenerator(binding, repoId, 0, 0, 0, null, folderType, 0, rootFolderId,
-                    doCleanup);
-
-            ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateFolders);
-            gen.fRootFolderId = getRootFolderId(binding, repoId, rootFolderId);
-            gen.fCount = noFolders;
-            runners[i] = gen;
-        }
-        return runners;
-    }
-
-    public static void runMultiThreaded(ObjectGeneratorRunner[] runner) {
-        int threadCount = runner.length;
-        Thread threads[] = new Thread[threadCount];
-        for (int i = 0; i < threadCount; i++) {
-            Thread thread = new Thread(runner[i], "ObjectGeneratorThread-" + i);
-            threads[i] = thread;
-            thread.start();
-        }
-
-        try {
-            for (Thread thread : threads) {
-                thread.join();
-            }
-            // Print all timings to System.out
-            System.out.println();
-            System.out.println("Result:");
-            TimeLogger[] loggersCreateDoc = new TimeLogger[threadCount];
-            TimeLogger[] loggersCreateFolder = new TimeLogger[threadCount];
-            TimeLogger[] loggersDelete = new TimeLogger[threadCount];
-            for (int i = 0; i < threadCount; i++) {
-                loggersCreateDoc[i] = runner[i].fObjGen.getCreateDocumentTimeLogger();
-                loggersCreateFolder[i] = runner[i].fObjGen.getCreateFolderTimeLogger();
-                loggersDelete[i] = runner[i].fObjGen.getDeleteTimeLogger();
-            }
-            TimeLogger.printTimes(loggersCreateDoc);
-            TimeLogger.printTimes(loggersCreateFolder);
-            TimeLogger.printTimes(loggersDelete);
-
-        } catch (InterruptedException e) {
-            System.out.println("Failed to wait for termination of threads: " + e);
-        }
-    }
-
-}
+/*
+ * 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.chemistry.opencmis.util.repository;
+
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
+import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
+import org.apache.chemistry.opencmis.commons.spi.NavigationService;
+import org.apache.chemistry.opencmis.commons.spi.ObjectService;
+import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
+
+public class MultiThreadedObjectGenerator {
+
+    static public enum Action {
+        CreateDocument, CreateTree, CreateFolders
+    };
+
+    static class ObjectGeneratorRunner implements Runnable {
+        private Action fAction;
+        ObjectGenerator fObjGen;
+        private String fRootFolderId;
+        private int fFoldersPerFolders;
+        private int fDepth;
+        private int fCount;
+
+        public ObjectGeneratorRunner(ObjectGenerator objGen, Action action) {
+            fObjGen = objGen;
+            fAction = action;
+        }
+
+        public void run() {
+            if (fAction == Action.CreateDocument) {
+                doCreateDocument();
+            } else if (fAction == Action.CreateTree) {
+                doCreateTree();
+            } else if (fAction == Action.CreateFolders) {
+                doCreateFolder();
+            }
+        }
+
+        public String[] doCreateDocument() {
+            String ids[] = fObjGen.createDocuments(fRootFolderId, fCount);
+            return ids;
+        }
+
+        public void doCreateTree() {
+            fObjGen.createFolderHierachy(fDepth, fFoldersPerFolders, fRootFolderId);
+        }
+
+        public String[] doCreateFolder() {
+            return fObjGen.createFolders(fRootFolderId, fCount);
+        }
+
+        public ObjectGenerator getObjectGenerator() {
+            return fObjGen;
+        }
+
+    } // ObjectCreatorRunner
+
+    static private ObjectGenerator createObjectGenerator(CmisBinding binding, String repoId, int docsPerFolder,
+            int foldersPerFolders, int depth, String documentType, String folderType, int contentSizeInKB,
+            String rootFolderId, boolean doCleanup) {
+
+        BindingsObjectFactory objectFactory = binding.getObjectFactory();
+        NavigationService navSvc = binding.getNavigationService();
+        ObjectService objSvc = binding.getObjectService();
+
+        ObjectGenerator gen = new ObjectGenerator(objectFactory, navSvc, objSvc, repoId);
+        gen.setUseUuidsForNames(true);
+        gen.setNumberOfDocumentsToCreatePerFolder(docsPerFolder);
+        // Set the type id for all created documents:
+        gen.setDocumentTypeId(documentType);
+        // Set the type id for all created folders:
+        gen.setFolderTypeId(folderType);
+        // Set contentSize
+        gen.setContentSizeInKB(contentSizeInKB);
+        gen.setCleanUpAfterCreate(doCleanup);
+
+        return gen;
+    }
+
+    static private String getRootFolderId(CmisBinding binding, String repositoryId, String rootFolderId) {
+        RepositoryService repSvc = binding.getRepositoryService();
+
+        RepositoryInfo rep = repSvc.getRepositoryInfo(repositoryId, null);
+        if (null == rootFolderId || rootFolderId.length() == 0)
+            rootFolderId = rep.getRootFolderId();
+
+        return rootFolderId;
+    }
+
+    public static ObjectGeneratorRunner prepareForCreateTree(CmisBinding binding, String repoId, int docsPerFolder,
+            int foldersPerFolders, int depth, String documentType, String folderType, int contentSizeInKB,
+            String rootFolderId, boolean doCleanup) {
+
+        ObjectGenerator objGen = createObjectGenerator(binding, repoId, docsPerFolder, foldersPerFolders, depth,
+                documentType, folderType, contentSizeInKB, rootFolderId, doCleanup);
+
+        ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateTree);
+        gen.fFoldersPerFolders = foldersPerFolders;
+        gen.fDepth = depth;
+        gen.fRootFolderId = getRootFolderId(binding, repoId, rootFolderId);
+        return gen;
+    }
+
+    public static ObjectGeneratorRunner[] prepareForCreateTreeMT(CmisBinding provider, String repoId,
+            int docsPerFolder, int foldersPerFolders, int depth, String documentType, String folderType,
+            int contentSizeInKB, String[] rootFolderIds, boolean doCleanup) {
+
+        ObjectGeneratorRunner[] runners = new ObjectGeneratorRunner[rootFolderIds.length];
+        for (int i = 0; i < rootFolderIds.length; i++) {
+            ObjectGenerator objGen = createObjectGenerator(provider, repoId, docsPerFolder, foldersPerFolders, depth,
+                    documentType, folderType, contentSizeInKB, rootFolderIds[i], doCleanup);
+
+            ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateTree);
+            gen.fFoldersPerFolders = foldersPerFolders;
+            gen.fDepth = depth;
+            gen.fRootFolderId = rootFolderIds[i];
+            runners[i] = gen;
+        }
+        return runners;
+    }
+
+    public static ObjectGeneratorRunner prepareForCreateDocument(CmisBinding provider, String repoId,
+            String documentType, int contentSizeInKB, String rootFolderId, int noDocuments, boolean doCleanup) {
+
+        ObjectGenerator objGen = createObjectGenerator(provider, repoId, 0, 0, 0, documentType, null, contentSizeInKB,
+                rootFolderId, doCleanup);
+
+        ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateDocument);
+        gen.fRootFolderId = getRootFolderId(provider, repoId, rootFolderId);
+        gen.fCount = noDocuments;
+        return gen;
+    }
+
+    public static ObjectGeneratorRunner[] prepareForCreateDocumentMT(int threadCount, CmisBinding binding,
+            String repoId, String documentType, int contentSizeInKB, String rootFolderId, int noDocuments,
+            boolean doCleanup) {
+
+        ObjectGeneratorRunner[] runners = new ObjectGeneratorRunner[threadCount];
+        for (int i = 0; i < threadCount; i++) {
+            ObjectGenerator objGen = createObjectGenerator(binding, repoId, 0, 0, 0, documentType, null,
+                    contentSizeInKB, rootFolderId, doCleanup);
+
+            ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateDocument);
+            gen.fRootFolderId = getRootFolderId(binding, repoId, rootFolderId);
+            gen.fCount = noDocuments;
+            runners[i] = gen;
+        }
+        return runners;
+    }
+
+    public static ObjectGeneratorRunner prepareForCreateFolder(CmisBinding provider, String repoId, String folderType,
+            String rootFolderId, int noFolders, boolean doCleanup) {
+
+        ObjectGenerator objGen = createObjectGenerator(provider, repoId, 0, 0, 0, null, folderType, 0, rootFolderId,
+                doCleanup);
+
+        ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateFolders);
+        gen.fRootFolderId = getRootFolderId(provider, repoId, rootFolderId);
+        gen.fCount = noFolders;
+        return gen;
+    }
+
+    public static ObjectGeneratorRunner[] prepareForCreateFolderMT(int threadCount, CmisBinding binding, String repoId,
+            String folderType, String rootFolderId, int noFolders, boolean doCleanup) {
+
+        ObjectGeneratorRunner[] runners = new ObjectGeneratorRunner[threadCount];
+        for (int i = 0; i < threadCount; i++) {
+            ObjectGenerator objGen = createObjectGenerator(binding, repoId, 0, 0, 0, null, folderType, 0, rootFolderId,
+                    doCleanup);
+
+            ObjectGeneratorRunner gen = new ObjectGeneratorRunner(objGen, Action.CreateFolders);
+            gen.fRootFolderId = getRootFolderId(binding, repoId, rootFolderId);
+            gen.fCount = noFolders;
+            runners[i] = gen;
+        }
+        return runners;
+    }
+
+    public static void runMultiThreaded(ObjectGeneratorRunner[] runner) {
+        int threadCount = runner.length;
+        Thread threads[] = new Thread[threadCount];
+        for (int i = 0; i < threadCount; i++) {
+            Thread thread = new Thread(runner[i], "ObjectGeneratorThread-" + i);
+            threads[i] = thread;
+            thread.start();
+        }
+
+        try {
+            for (Thread thread : threads) {
+                thread.join();
+            }
+            // Print all timings to System.out
+            System.out.println();
+            System.out.println("Result:");
+            TimeLogger[] loggersCreateDoc = new TimeLogger[threadCount];
+            TimeLogger[] loggersCreateFolder = new TimeLogger[threadCount];
+            TimeLogger[] loggersDelete = new TimeLogger[threadCount];
+            for (int i = 0; i < threadCount; i++) {
+                loggersCreateDoc[i] = runner[i].fObjGen.getCreateDocumentTimeLogger();
+                loggersCreateFolder[i] = runner[i].fObjGen.getCreateFolderTimeLogger();
+                loggersDelete[i] = runner[i].fObjGen.getDeleteTimeLogger();
+            }
+            TimeLogger.printTimes(loggersCreateDoc);
+            TimeLogger.printTimes(loggersCreateFolder);
+            TimeLogger.printTimes(loggersDelete);
+
+        } catch (InterruptedException e) {
+            System.out.println("Failed to wait for termination of threads: " + e);
+        }
+    }
+
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java?rev=980514&r1=980513&r2=980514&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java (original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java Thu Jul 29 17:18:20 2010
@@ -1,496 +1,496 @@
-/*
- * 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.chemistry.opencmis.util.repository;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import joptsimple.OptionParser;
-import joptsimple.OptionSet;
-import joptsimple.OptionSpec;
-
-import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
-import org.apache.chemistry.opencmis.commons.SessionParameter;
-import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
-import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
-import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
-import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
-
-public class ObjGenApp {
-    public static final String DEFAULT_USER = "";
-    public static final String DEFAULT_PWD = "";
-    public static final String PROP_ATOMPUB_URL = "opencmis.test.atompub.url";
-    public static final String PROP_URL = "url";
-    public static final String PROP_WS_URL = "opencmis.test.webservices.url";
-    public static final String DEFAULT_ATOMPUB_URL = "http://localhost:8080/opencmis/atom";
-    public static final String DEFAULT_WS_URL = "http://localhost:8080/cmis/services/";
-
-    private final static String CMD = "Command";
-    private final static String REPOSITORY_ID = "RepositoryId";
-    private final static String FILLER_DOCUMENT_TYPE_ID = "DocumentTypeId";
-    private final static String FILLER_FOLDER_TYPE_ID = "FolderTypeId";
-    private final static String FILLER_DOCS_PER_FOLDER = "DocsPerFolder";
-    private final static String FILLER_FOLDERS_PER_FOLDER = "FoldersPerFolder";
-    private final static String FILLER_DEPTH = "Depth";
-    private final static String FILLER_CONTENT_SIZE = "ContentSizeInKB";
-    private final static String COUNT = "Count";
-    private final static String BINDING = "Binding";
-    private final static String CLEANUP = "Cleanup";
-    private final static String ROOTFOLDER = "RootFolder";
-    private final static String THREADS = "Threads";
-
-    private final static String BINDING_ATOM = "AtomPub";
-    private final static String BINDING_WS = "WebService";
-
-    private CmisBinding binding;
-    private boolean fUsingAtom;
-    private String fUrlStr;
-
-    OptionSpec<String> fCmd;
-    OptionSpec<Integer> fDepth;
-    OptionSpec<Integer> fContentSize;
-    OptionSpec<Integer> fFolderPerFolder;
-    OptionSpec<Integer> fDocsPerFolder;
-    OptionSpec<String> fFolderType;
-    OptionSpec<String> fDocType;
-    OptionSpec<String> fRepoId;
-    OptionSpec<Integer> fCount;
-    OptionSpec<String> fBinding;
-    OptionSpec<Boolean> fCleanup;
-    OptionSpec<String> fRootFolder;
-    OptionSpec<Integer> fThreads;
-
-    public static void main(String[] args) {
-
-        ObjGenApp app = new ObjGenApp();
-        try {
-            app.processCmdLine(args);
-        } catch (CmisBaseException ce) {
-            System.out.println("Error: Could not process command. " + ce);
-            System.out.println("Extended error: " + ce.getErrorContent());
-            ce.printStackTrace();
-        } catch (Exception e) {
-            System.out.println("Could not fill repository " + e);
-            e.printStackTrace();
-        }
-    }
-
-    private void processCmdLine(String[] args) {
-
-        OptionParser parser = new OptionParser();
-        fCmd = parser.accepts(CMD).withRequiredArg().describedAs("Command to perform (see below)");
-        fRepoId = parser.accepts(REPOSITORY_ID).withOptionalArg().describedAs("Repository used");
-        fDocType = parser.accepts(FILLER_DOCUMENT_TYPE_ID).withOptionalArg().defaultsTo(
-                BaseTypeId.CMIS_DOCUMENT.value()).describedAs("Document type created");
-        fFolderType = parser.accepts(FILLER_FOLDER_TYPE_ID).withOptionalArg()
-                .defaultsTo(BaseTypeId.CMIS_FOLDER.value()).describedAs("Folder type created");
-        fDocsPerFolder = parser.accepts(FILLER_DOCS_PER_FOLDER).withOptionalArg().ofType(Integer.class).describedAs(
-                "Documents on each level").defaultsTo(1);
-        fFolderPerFolder = parser.accepts(FILLER_FOLDERS_PER_FOLDER).withOptionalArg().ofType(Integer.class)
-                .describedAs(" Folders on each level").defaultsTo(0);
-        fDepth = parser.accepts(FILLER_DEPTH).withOptionalArg().ofType(Integer.class).describedAs("Levels of folders")
-                .defaultsTo(1);
-        fContentSize = parser.accepts(FILLER_CONTENT_SIZE).withOptionalArg().ofType(Integer.class).describedAs(
-                "Content size of each doc").defaultsTo(0);
-        fCount = parser.accepts(COUNT).withOptionalArg().ofType(Integer.class).defaultsTo(1).describedAs(
-                "Repeat a command n times (partially implemented)");
-        fBinding = parser.accepts(BINDING).withOptionalArg().ofType(String.class).defaultsTo(BINDING_ATOM).describedAs(
-                "Protocol Binding: " + BINDING_ATOM + " or " + BINDING_WS);
-        fCleanup = parser.accepts(CLEANUP).withOptionalArg().ofType(Boolean.class).defaultsTo(false).describedAs(
-                "Clean all created objects at the end");
-        fRootFolder = parser.accepts(ROOTFOLDER).withOptionalArg().ofType(String.class).describedAs(
-                "folder id used as root to create objects (default repository root folder)");
-        fThreads = parser.accepts(THREADS).withOptionalArg().ofType(Integer.class).defaultsTo(1).describedAs(
-                "Number of threads to start in parallel");
-
-        OptionSet options = parser.parse(args);
-
-        if (options.valueOf(fCmd) == null || options.has("?"))
-            usage(parser);
-
-        if (options.valueOf(fBinding).equals(BINDING_WS)) {
-            fUsingAtom = false;
-        } else if (options.valueOf(fBinding).equals(BINDING_ATOM)) {
-            fUsingAtom = true;
-        } else {
-            System.out.println("Unknown option <Binding>: " + options.valueOf(fBinding) + " allowed values: "
-                    + BINDING_WS + " or " + BINDING_ATOM);
-            return;
-        }
-
-        if (options.valueOf(fCmd).equals("FillRepository")) {
-            fillRepository(options);
-        } else if (options.valueOf(fCmd).equals("CreateDocument")) {
-            createSingleDocument(options);
-        } else if (options.valueOf(fCmd).equals("CreateFolder")) {
-            createFolders(options);
-        } else if (options.valueOf(fCmd).equals("RepositoryInfo")) {
-            repositoryInfo(options);
-        } else if (options.valueOf(fCmd).equals("GetUrl")) {
-            getUrl(getConfiguredUrl());
-        } else {
-            System.out.println("Unknown cmd: " + options.valueOf(fCmd));
-            usage(parser);
-        }
-    }
-
-    // private void preInitExpensiveTasks() {
-    // // JAXB initialization is very expensive, count this separate:
-    // TimeLogger logger = new TimeLogger("Initialization");
-    // logger.start();
-    // try {
-    // JaxBHelper.createMarshaller();
-    // }
-    // catch (JAXBException e) {
-    // System.out.print("Failuer in JAXB init: " + e);
-    // e.printStackTrace();
-    // } // dummy call just to get initialized
-    // logger.stop();
-    // logger.printTimes();
-    // }
-
-    private void usage(OptionParser parser) {
-        try {
-            System.out.println();
-            System.out.println("ObjGenApp is a command line tool for testing a CMIS repository.");
-            System.out.println("Usage:");
-            parser.printHelpOn(System.out);
-            System.out.println();
-            System.out.println("Command is one of [CreateDocument, CreateFolder, FillRepository, RepositoryInfo]");
-            System.out.println("JVM system properties: " + PROP_ATOMPUB_URL + ", " + PROP_WS_URL);
-            System.out.println();
-            System.out.println("Example: ");
-            System.out
-                    .println("java -D"
-                            + PROP_ATOMPUB_URL
-                            + "=http://localhost:8080/opencmis/atom -cp ... "
-                            + "org.apache.chemistry.opencmis.util.repository.ObjGenApp --Binding=AtomPub --Command=CreateDocument "
-                            + "--RepositoryId=A1 --ContentSizeInKB=25");
-            return;
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-    private void fillRepository(String repoId, int docsPerFolder, int foldersPerFolders, int depth,
-            String documentType, String folderType, int contentSizeInKB, String rootFolderId, boolean doCleanup) {
-
-        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator.prepareForCreateTree(
-                getBinding(), repoId, docsPerFolder, foldersPerFolders, depth, documentType, folderType,
-                contentSizeInKB, rootFolderId, doCleanup);
-        ObjectGenerator gen = runner.getObjectGenerator();
-        runner.doCreateTree();
-
-        System.out.println();
-        System.out.println("Result:");
-        System.out.println("Filling repository succeeded.");
-        System.out.println("Folder used as root for creation (null=rootFolderId): " + rootFolderId);
-        System.out.println("Number of documents created: " + gen.getDocumentsInTotal());
-        System.out.println("Number of folders created: " + gen.getFoldersInTotal());
-        gen.printTimings();
-    }
-
-    private void fillRepositoryMT(int noThreads, String repoId, int docsPerFolder, int foldersPerFolders, int depth,
-            String documentType, String folderType, int contentSizeInKB, String rootFolderId, boolean doCleanup) {
-
-        // Step 1: create a root folder for each thread
-        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
-                .prepareForCreateFolder(getBinding(), repoId, folderType, rootFolderId, noThreads, doCleanup);
-        String[] folderIds = runner.doCreateFolder();
-
-        // Step 2: fill each root folder with an object tree
-        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
-                .prepareForCreateTreeMT(getBinding(), repoId, docsPerFolder, foldersPerFolders, depth, documentType,
-                        folderType, contentSizeInKB, folderIds, doCleanup);
-
-        MultiThreadedObjectGenerator.runMultiThreaded(runners);
-        System.out.println("Filling repository succeeded.");
-    }
-
-    private void printParameters(OptionSet options) {
-        if (fUsingAtom)
-            System.out.println("Using AtomPub, connecting to  " + getAtomPubUrl());
-        else
-            System.out.println("Using WebService, connecting to  " + getWsUrl());
-
-        System.out.println("Repository id is: " + options.valueOf(fRepoId));
-        System.out.println("Content size: " + options.valueOf(fContentSize));
-        System.out.println("Document Type: " + options.valueOf(fDocType));
-        System.out.println("Folder id used as root: " + options.valueOf(fRootFolder));
-        System.out.println("Delete all objects after creation: " + options.valueOf(fCleanup));
-        System.out.println("Number of actions to perform: " + options.valueOf(fCount));
-        System.out.println("Number of threads to start: " + options.valueOf(fThreads));
-    }
-
-    private void createSingleDocument(OptionSet options) {
-        System.out.println();
-        System.out.println("Creating document with parameters:");
-        printParameters(options);
-        int noThreads = options.valueOf(fThreads);
-        if (noThreads <= 1)
-            createSingleDocument(options.valueOf(fRepoId), options.valueOf(fDocType), options.valueOf(fContentSize),
-                    options.valueOf(fRootFolder), options.valueOf(fCount), options.valueOf(fCleanup));
-        else
-            createSingleDocumentMT(noThreads, options.valueOf(fRepoId), options.valueOf(fDocType), options
-                    .valueOf(fContentSize), options.valueOf(fRootFolder), options.valueOf(fCount), options
-                    .valueOf(fCleanup));
-    }
-
-    private void fillRepository(OptionSet options) {
-        System.out.println();
-        printParameters(options);
-        System.out.println("Creating object tree with folowing parameters: ");
-        System.out.println("Documents per folder: " + options.valueOf(fDocsPerFolder));
-        System.out.println("Folder per folder: " + options.valueOf(fFolderPerFolder));
-        System.out.println("Depth: " + options.valueOf(fDepth));
-        System.out.println("Folder Type: " + options.valueOf(fFolderType));
-
-        int noThreads = options.valueOf(fThreads);
-        if (noThreads <= 1)
-            fillRepository(options.valueOf(fRepoId), options.valueOf(fDocsPerFolder),
-                    options.valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType), options
-                            .valueOf(fFolderType), options.valueOf(fContentSize), options.valueOf(fRootFolder), options
-                            .valueOf(fCleanup));
-        else
-            fillRepositoryMT(noThreads, options.valueOf(fRepoId), options.valueOf(fDocsPerFolder), options
-                    .valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType), options
-                    .valueOf(fFolderType), options.valueOf(fContentSize), options.valueOf(fRootFolder), options
-                    .valueOf(fCleanup));
-
-    }
-
-    private void createFolders(OptionSet options) {
-        System.out.println();
-        System.out.println("Creating folder with parameters:");
-        printParameters(options);
-        System.out.println("Folder Type: " + options.valueOf(fFolderType));
-        int noThreads = options.valueOf(fThreads);
-        if (noThreads <= 1)
-            createFolders(options.valueOf(fRepoId), options.valueOf(fFolderType), options.valueOf(fRootFolder), options
-                    .valueOf(fCount), options.valueOf(fCleanup));
-        else
-            createFoldersMT(noThreads, options.valueOf(fRepoId), options.valueOf(fFolderType), options
-                    .valueOf(fRootFolder), options.valueOf(fCount), options.valueOf(fCleanup));
-    }
-
-    private void createSingleDocument(String repoId, String documentType, int contentSizeInKB, String rootFolderId,
-            int docCount, boolean doCleanup) {
-
-        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
-                .prepareForCreateDocument(getBinding(), repoId, documentType, contentSizeInKB, rootFolderId, docCount,
-                        doCleanup);
-        ObjectGenerator gen = runner.getObjectGenerator();
-        String[] ids = runner.doCreateDocument();
-        System.out.println();
-        System.out.println("Result:");
-        System.out.println("Document creation succeeded.");
-        System.out.println("Folder used as root for creation: " + rootFolderId);
-        System.out.println("Ids of created documents: ");
-        if (null == ids)
-            System.out.println("<none>");
-        else
-            for (int i = 0; i < ids.length; i++)
-                System.out.println(ids[i]);
-        gen.printTimings();
-        gen.resetCounters();
-    }
-
-    private void createSingleDocumentMT(int noThreads, String repoId, String documentType, int contentSizeInKB,
-            String rootFolderId, int docCount, boolean doCleanup) {
-
-        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
-                .prepareForCreateDocumentMT(noThreads, getBinding(), repoId, documentType, contentSizeInKB,
-                        rootFolderId, docCount, doCleanup);
-
-        MultiThreadedObjectGenerator.runMultiThreaded(runners);
-        System.out.println("Document creation succeeded. All threads terminated.");
-    }
-
-    private void createFolders(String repoId, String folderType, String rootFolderId, int noFolders, boolean doCleanup) {
-
-        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
-                .prepareForCreateFolder(getBinding(), repoId, folderType, rootFolderId, noFolders, doCleanup);
-        ObjectGenerator gen = runner.getObjectGenerator();
-        String[] ids = runner.doCreateFolder();
-        System.out.println();
-        System.out.println("Result:");
-        System.out.println("Folder creation succeeded.");
-        System.out.println("Ids of created folders: ");
-        if (null == ids)
-            System.out.println("<none>");
-        else
-            for (int i = 0; i < ids.length; i++)
-                System.out.println(ids[i]);
-        gen.printTimings();
-        gen.resetCounters();
-    }
-
-    private void createFoldersMT(int noThreads, String repoId, String folderType, String rootFolderId, int noFolders,
-            boolean doCleanup) {
-
-        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
-                .prepareForCreateFolderMT(noThreads, getBinding(), repoId, folderType, rootFolderId, noFolders,
-                        doCleanup);
-        MultiThreadedObjectGenerator.runMultiThreaded(runners);
-        System.out.println("Folder creation succeeded.");
-    }
-
-    private void callRepoInfo(String repositoryId, int count) {
-        RepositoryService repSvc = getBinding().getRepositoryService();
-        TimeLogger timeLogger = new TimeLogger("RepoInfoTest");
-        RepositoryInfo repoInfo = null;
-        for (int i = 0; i < count; i++) {
-            binding.clearRepositoryCache(repositoryId);
-            timeLogger.start();
-            repoInfo = repSvc.getRepositoryInfo(repositoryId, null);
-            timeLogger.stop();
-        }
-        System.out.println("Root Folder id is: " + (repoInfo == null ? "<unknown>" : repoInfo.getRootFolderId()));
-        timeLogger.printTimes();
-    }
-
-    private void repositoryInfo(OptionSet options) {
-        callRepoInfo(options.valueOf(fRepoId), options.valueOf(fCount));
-    }
-
-    private CmisBinding getBinding() {
-        if (binding == null) {
-            if (fUsingAtom)
-                binding = createAtomBinding(getAtomPubUrl(), DEFAULT_USER, DEFAULT_PWD);
-            else
-                binding = createWsBinding(getWsUrl(), DEFAULT_USER, DEFAULT_PWD);
-        }
-        return binding;
-    }
-
-    private static void filLoginParams(Map<String, String> parameters, String user, String password) {
-        if (user != null && user.length() > 0)
-            parameters.put(SessionParameter.USER, user);
-        if (user != null && user.length() > 0)
-            parameters.put(SessionParameter.PASSWORD, password);
-    }
-
-    private static CmisBinding createAtomBinding(String url, String user, String password) {
-
-        // gather parameters
-        Map<String, String> parameters = new HashMap<String, String>();
-        filLoginParams(parameters, user, password);
-
-        // get factory and create binding
-        CmisBindingFactory factory = CmisBindingFactory.newInstance();
-        parameters.put(SessionParameter.ATOMPUB_URL, url);
-        CmisBinding binding = factory.createCmisAtomPubBinding(parameters);
-        return binding;
-    }
-
-    private static CmisBinding createWsBinding(String url, String username, String password) {
-        boolean isPrefix = true;
-        String urlLower = url.toLowerCase();
-
-        if (urlLower.endsWith("?wsdl")) {
-            isPrefix = false;
-        } else if (urlLower.endsWith(".wsdl")) {
-            isPrefix = false;
-        } else if (urlLower.endsWith(".xml")) {
-            isPrefix = false;
-        }
-
-        return createBinding(url, isPrefix, username, password);
-    }
-
-    public static CmisBinding createBinding(String url, boolean isPrefix, String username, String password) {
-        // gather parameters
-        Map<String, String> parameters = new HashMap<String, String>();
-        parameters.put(SessionParameter.USER, username);
-        parameters.put(SessionParameter.PASSWORD, password);
-
-        if (!isPrefix) {
-            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
-            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
-            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
-            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
-            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
-            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url);
-            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url);
-            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
-            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
-        } else {
-            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "RepositoryService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "NavigationService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "ObjectService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "VersioningService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "DiscoveryService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "RelationshipService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "MultiFilingService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "PolicyService?wsdl");
-            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "ACLService?wsdl");
-        }
-
-        // get factory and create provider
-        CmisBindingFactory factory = CmisBindingFactory.newInstance();
-        CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
-
-        return binding;
-    }
-
-    private String getAtomPubUrl() {
-        return System.getProperty(PROP_ATOMPUB_URL, DEFAULT_ATOMPUB_URL);
-    }
-
-    private String getWsUrl() {
-        return System.getProperty(PROP_WS_URL, DEFAULT_WS_URL);
-    }
-
-    private String getConfiguredUrl() {
-        return System.getProperty(PROP_URL, fUrlStr);
-    }
-
-    private void getUrl(String urlStr) {
-        URL url;
-        InputStream is;
-        InputStreamReader isr;
-        BufferedReader r;
-        String str;
-
-        try {
-            System.out.println("Reading URL: " + urlStr);
-            url = new URL(urlStr);
-            is = url.openStream();
-            isr = new InputStreamReader(is);
-            r = new BufferedReader(isr);
-            do {
-                str = r.readLine();
-                if (str != null)
-                    System.out.println(str);
-            } while (str != null);
-        } catch (MalformedURLException e) {
-            System.out.println("Must enter a valid URL" + e);
-        } catch (IOException e) {
-            System.out.println("Can not connect" + e);
-        }
-    }
-
-}
+/*
+ * 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.chemistry.opencmis.util.repository;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import joptsimple.OptionParser;
+import joptsimple.OptionSet;
+import joptsimple.OptionSpec;
+
+import org.apache.chemistry.opencmis.client.bindings.CmisBindingFactory;
+import org.apache.chemistry.opencmis.commons.SessionParameter;
+import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
+import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisBaseException;
+import org.apache.chemistry.opencmis.commons.spi.CmisBinding;
+import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
+
+public class ObjGenApp {
+    public static final String DEFAULT_USER = "";
+    public static final String DEFAULT_PWD = "";
+    public static final String PROP_ATOMPUB_URL = "opencmis.test.atompub.url";
+    public static final String PROP_URL = "url";
+    public static final String PROP_WS_URL = "opencmis.test.webservices.url";
+    public static final String DEFAULT_ATOMPUB_URL = "http://localhost:8080/opencmis/atom";
+    public static final String DEFAULT_WS_URL = "http://localhost:8080/cmis/services/";
+
+    private final static String CMD = "Command";
+    private final static String REPOSITORY_ID = "RepositoryId";
+    private final static String FILLER_DOCUMENT_TYPE_ID = "DocumentTypeId";
+    private final static String FILLER_FOLDER_TYPE_ID = "FolderTypeId";
+    private final static String FILLER_DOCS_PER_FOLDER = "DocsPerFolder";
+    private final static String FILLER_FOLDERS_PER_FOLDER = "FoldersPerFolder";
+    private final static String FILLER_DEPTH = "Depth";
+    private final static String FILLER_CONTENT_SIZE = "ContentSizeInKB";
+    private final static String COUNT = "Count";
+    private final static String BINDING = "Binding";
+    private final static String CLEANUP = "Cleanup";
+    private final static String ROOTFOLDER = "RootFolder";
+    private final static String THREADS = "Threads";
+
+    private final static String BINDING_ATOM = "AtomPub";
+    private final static String BINDING_WS = "WebService";
+
+    private CmisBinding binding;
+    private boolean fUsingAtom;
+    private String fUrlStr;
+
+    OptionSpec<String> fCmd;
+    OptionSpec<Integer> fDepth;
+    OptionSpec<Integer> fContentSize;
+    OptionSpec<Integer> fFolderPerFolder;
+    OptionSpec<Integer> fDocsPerFolder;
+    OptionSpec<String> fFolderType;
+    OptionSpec<String> fDocType;
+    OptionSpec<String> fRepoId;
+    OptionSpec<Integer> fCount;
+    OptionSpec<String> fBinding;
+    OptionSpec<Boolean> fCleanup;
+    OptionSpec<String> fRootFolder;
+    OptionSpec<Integer> fThreads;
+
+    public static void main(String[] args) {
+
+        ObjGenApp app = new ObjGenApp();
+        try {
+            app.processCmdLine(args);
+        } catch (CmisBaseException ce) {
+            System.out.println("Error: Could not process command. " + ce);
+            System.out.println("Extended error: " + ce.getErrorContent());
+            ce.printStackTrace();
+        } catch (Exception e) {
+            System.out.println("Could not fill repository " + e);
+            e.printStackTrace();
+        }
+    }
+
+    private void processCmdLine(String[] args) {
+
+        OptionParser parser = new OptionParser();
+        fCmd = parser.accepts(CMD).withRequiredArg().describedAs("Command to perform (see below)");
+        fRepoId = parser.accepts(REPOSITORY_ID).withOptionalArg().describedAs("Repository used");
+        fDocType = parser.accepts(FILLER_DOCUMENT_TYPE_ID).withOptionalArg().defaultsTo(
+                BaseTypeId.CMIS_DOCUMENT.value()).describedAs("Document type created");
+        fFolderType = parser.accepts(FILLER_FOLDER_TYPE_ID).withOptionalArg()
+                .defaultsTo(BaseTypeId.CMIS_FOLDER.value()).describedAs("Folder type created");
+        fDocsPerFolder = parser.accepts(FILLER_DOCS_PER_FOLDER).withOptionalArg().ofType(Integer.class).describedAs(
+                "Documents on each level").defaultsTo(1);
+        fFolderPerFolder = parser.accepts(FILLER_FOLDERS_PER_FOLDER).withOptionalArg().ofType(Integer.class)
+                .describedAs(" Folders on each level").defaultsTo(0);
+        fDepth = parser.accepts(FILLER_DEPTH).withOptionalArg().ofType(Integer.class).describedAs("Levels of folders")
+                .defaultsTo(1);
+        fContentSize = parser.accepts(FILLER_CONTENT_SIZE).withOptionalArg().ofType(Integer.class).describedAs(
+                "Content size of each doc").defaultsTo(0);
+        fCount = parser.accepts(COUNT).withOptionalArg().ofType(Integer.class).defaultsTo(1).describedAs(
+                "Repeat a command n times (partially implemented)");
+        fBinding = parser.accepts(BINDING).withOptionalArg().ofType(String.class).defaultsTo(BINDING_ATOM).describedAs(
+                "Protocol Binding: " + BINDING_ATOM + " or " + BINDING_WS);
+        fCleanup = parser.accepts(CLEANUP).withOptionalArg().ofType(Boolean.class).defaultsTo(false).describedAs(
+                "Clean all created objects at the end");
+        fRootFolder = parser.accepts(ROOTFOLDER).withOptionalArg().ofType(String.class).describedAs(
+                "folder id used as root to create objects (default repository root folder)");
+        fThreads = parser.accepts(THREADS).withOptionalArg().ofType(Integer.class).defaultsTo(1).describedAs(
+                "Number of threads to start in parallel");
+
+        OptionSet options = parser.parse(args);
+
+        if (options.valueOf(fCmd) == null || options.has("?"))
+            usage(parser);
+
+        if (options.valueOf(fBinding).equals(BINDING_WS)) {
+            fUsingAtom = false;
+        } else if (options.valueOf(fBinding).equals(BINDING_ATOM)) {
+            fUsingAtom = true;
+        } else {
+            System.out.println("Unknown option <Binding>: " + options.valueOf(fBinding) + " allowed values: "
+                    + BINDING_WS + " or " + BINDING_ATOM);
+            return;
+        }
+
+        if (options.valueOf(fCmd).equals("FillRepository")) {
+            fillRepository(options);
+        } else if (options.valueOf(fCmd).equals("CreateDocument")) {
+            createSingleDocument(options);
+        } else if (options.valueOf(fCmd).equals("CreateFolder")) {
+            createFolders(options);
+        } else if (options.valueOf(fCmd).equals("RepositoryInfo")) {
+            repositoryInfo(options);
+        } else if (options.valueOf(fCmd).equals("GetUrl")) {
+            getUrl(getConfiguredUrl());
+        } else {
+            System.out.println("Unknown cmd: " + options.valueOf(fCmd));
+            usage(parser);
+        }
+    }
+
+    // private void preInitExpensiveTasks() {
+    // // JAXB initialization is very expensive, count this separate:
+    // TimeLogger logger = new TimeLogger("Initialization");
+    // logger.start();
+    // try {
+    // JaxBHelper.createMarshaller();
+    // }
+    // catch (JAXBException e) {
+    // System.out.print("Failuer in JAXB init: " + e);
+    // e.printStackTrace();
+    // } // dummy call just to get initialized
+    // logger.stop();
+    // logger.printTimes();
+    // }
+
+    private void usage(OptionParser parser) {
+        try {
+            System.out.println();
+            System.out.println("ObjGenApp is a command line tool for testing a CMIS repository.");
+            System.out.println("Usage:");
+            parser.printHelpOn(System.out);
+            System.out.println();
+            System.out.println("Command is one of [CreateDocument, CreateFolder, FillRepository, RepositoryInfo]");
+            System.out.println("JVM system properties: " + PROP_ATOMPUB_URL + ", " + PROP_WS_URL);
+            System.out.println();
+            System.out.println("Example: ");
+            System.out
+                    .println("java -D"
+                            + PROP_ATOMPUB_URL
+                            + "=http://localhost:8080/opencmis/atom -cp ... "
+                            + "org.apache.chemistry.opencmis.util.repository.ObjGenApp --Binding=AtomPub --Command=CreateDocument "
+                            + "--RepositoryId=A1 --ContentSizeInKB=25");
+            return;
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    private void fillRepository(String repoId, int docsPerFolder, int foldersPerFolders, int depth,
+            String documentType, String folderType, int contentSizeInKB, String rootFolderId, boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator.prepareForCreateTree(
+                getBinding(), repoId, docsPerFolder, foldersPerFolders, depth, documentType, folderType,
+                contentSizeInKB, rootFolderId, doCleanup);
+        ObjectGenerator gen = runner.getObjectGenerator();
+        runner.doCreateTree();
+
+        System.out.println();
+        System.out.println("Result:");
+        System.out.println("Filling repository succeeded.");
+        System.out.println("Folder used as root for creation (null=rootFolderId): " + rootFolderId);
+        System.out.println("Number of documents created: " + gen.getDocumentsInTotal());
+        System.out.println("Number of folders created: " + gen.getFoldersInTotal());
+        gen.printTimings();
+    }
+
+    private void fillRepositoryMT(int noThreads, String repoId, int docsPerFolder, int foldersPerFolders, int depth,
+            String documentType, String folderType, int contentSizeInKB, String rootFolderId, boolean doCleanup) {
+
+        // Step 1: create a root folder for each thread
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+                .prepareForCreateFolder(getBinding(), repoId, folderType, rootFolderId, noThreads, doCleanup);
+        String[] folderIds = runner.doCreateFolder();
+
+        // Step 2: fill each root folder with an object tree
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+                .prepareForCreateTreeMT(getBinding(), repoId, docsPerFolder, foldersPerFolders, depth, documentType,
+                        folderType, contentSizeInKB, folderIds, doCleanup);
+
+        MultiThreadedObjectGenerator.runMultiThreaded(runners);
+        System.out.println("Filling repository succeeded.");
+    }
+
+    private void printParameters(OptionSet options) {
+        if (fUsingAtom)
+            System.out.println("Using AtomPub, connecting to  " + getAtomPubUrl());
+        else
+            System.out.println("Using WebService, connecting to  " + getWsUrl());
+
+        System.out.println("Repository id is: " + options.valueOf(fRepoId));
+        System.out.println("Content size: " + options.valueOf(fContentSize));
+        System.out.println("Document Type: " + options.valueOf(fDocType));
+        System.out.println("Folder id used as root: " + options.valueOf(fRootFolder));
+        System.out.println("Delete all objects after creation: " + options.valueOf(fCleanup));
+        System.out.println("Number of actions to perform: " + options.valueOf(fCount));
+        System.out.println("Number of threads to start: " + options.valueOf(fThreads));
+    }
+
+    private void createSingleDocument(OptionSet options) {
+        System.out.println();
+        System.out.println("Creating document with parameters:");
+        printParameters(options);
+        int noThreads = options.valueOf(fThreads);
+        if (noThreads <= 1)
+            createSingleDocument(options.valueOf(fRepoId), options.valueOf(fDocType), options.valueOf(fContentSize),
+                    options.valueOf(fRootFolder), options.valueOf(fCount), options.valueOf(fCleanup));
+        else
+            createSingleDocumentMT(noThreads, options.valueOf(fRepoId), options.valueOf(fDocType), options
+                    .valueOf(fContentSize), options.valueOf(fRootFolder), options.valueOf(fCount), options
+                    .valueOf(fCleanup));
+    }
+
+    private void fillRepository(OptionSet options) {
+        System.out.println();
+        printParameters(options);
+        System.out.println("Creating object tree with folowing parameters: ");
+        System.out.println("Documents per folder: " + options.valueOf(fDocsPerFolder));
+        System.out.println("Folder per folder: " + options.valueOf(fFolderPerFolder));
+        System.out.println("Depth: " + options.valueOf(fDepth));
+        System.out.println("Folder Type: " + options.valueOf(fFolderType));
+
+        int noThreads = options.valueOf(fThreads);
+        if (noThreads <= 1)
+            fillRepository(options.valueOf(fRepoId), options.valueOf(fDocsPerFolder),
+                    options.valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType), options
+                            .valueOf(fFolderType), options.valueOf(fContentSize), options.valueOf(fRootFolder), options
+                            .valueOf(fCleanup));
+        else
+            fillRepositoryMT(noThreads, options.valueOf(fRepoId), options.valueOf(fDocsPerFolder), options
+                    .valueOf(fFolderPerFolder), options.valueOf(fDepth), options.valueOf(fDocType), options
+                    .valueOf(fFolderType), options.valueOf(fContentSize), options.valueOf(fRootFolder), options
+                    .valueOf(fCleanup));
+
+    }
+
+    private void createFolders(OptionSet options) {
+        System.out.println();
+        System.out.println("Creating folder with parameters:");
+        printParameters(options);
+        System.out.println("Folder Type: " + options.valueOf(fFolderType));
+        int noThreads = options.valueOf(fThreads);
+        if (noThreads <= 1)
+            createFolders(options.valueOf(fRepoId), options.valueOf(fFolderType), options.valueOf(fRootFolder), options
+                    .valueOf(fCount), options.valueOf(fCleanup));
+        else
+            createFoldersMT(noThreads, options.valueOf(fRepoId), options.valueOf(fFolderType), options
+                    .valueOf(fRootFolder), options.valueOf(fCount), options.valueOf(fCleanup));
+    }
+
+    private void createSingleDocument(String repoId, String documentType, int contentSizeInKB, String rootFolderId,
+            int docCount, boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+                .prepareForCreateDocument(getBinding(), repoId, documentType, contentSizeInKB, rootFolderId, docCount,
+                        doCleanup);
+        ObjectGenerator gen = runner.getObjectGenerator();
+        String[] ids = runner.doCreateDocument();
+        System.out.println();
+        System.out.println("Result:");
+        System.out.println("Document creation succeeded.");
+        System.out.println("Folder used as root for creation: " + rootFolderId);
+        System.out.println("Ids of created documents: ");
+        if (null == ids)
+            System.out.println("<none>");
+        else
+            for (int i = 0; i < ids.length; i++)
+                System.out.println(ids[i]);
+        gen.printTimings();
+        gen.resetCounters();
+    }
+
+    private void createSingleDocumentMT(int noThreads, String repoId, String documentType, int contentSizeInKB,
+            String rootFolderId, int docCount, boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+                .prepareForCreateDocumentMT(noThreads, getBinding(), repoId, documentType, contentSizeInKB,
+                        rootFolderId, docCount, doCleanup);
+
+        MultiThreadedObjectGenerator.runMultiThreaded(runners);
+        System.out.println("Document creation succeeded. All threads terminated.");
+    }
+
+    private void createFolders(String repoId, String folderType, String rootFolderId, int noFolders, boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner runner = MultiThreadedObjectGenerator
+                .prepareForCreateFolder(getBinding(), repoId, folderType, rootFolderId, noFolders, doCleanup);
+        ObjectGenerator gen = runner.getObjectGenerator();
+        String[] ids = runner.doCreateFolder();
+        System.out.println();
+        System.out.println("Result:");
+        System.out.println("Folder creation succeeded.");
+        System.out.println("Ids of created folders: ");
+        if (null == ids)
+            System.out.println("<none>");
+        else
+            for (int i = 0; i < ids.length; i++)
+                System.out.println(ids[i]);
+        gen.printTimings();
+        gen.resetCounters();
+    }
+
+    private void createFoldersMT(int noThreads, String repoId, String folderType, String rootFolderId, int noFolders,
+            boolean doCleanup) {
+
+        MultiThreadedObjectGenerator.ObjectGeneratorRunner[] runners = MultiThreadedObjectGenerator
+                .prepareForCreateFolderMT(noThreads, getBinding(), repoId, folderType, rootFolderId, noFolders,
+                        doCleanup);
+        MultiThreadedObjectGenerator.runMultiThreaded(runners);
+        System.out.println("Folder creation succeeded.");
+    }
+
+    private void callRepoInfo(String repositoryId, int count) {
+        RepositoryService repSvc = getBinding().getRepositoryService();
+        TimeLogger timeLogger = new TimeLogger("RepoInfoTest");
+        RepositoryInfo repoInfo = null;
+        for (int i = 0; i < count; i++) {
+            binding.clearRepositoryCache(repositoryId);
+            timeLogger.start();
+            repoInfo = repSvc.getRepositoryInfo(repositoryId, null);
+            timeLogger.stop();
+        }
+        System.out.println("Root Folder id is: " + (repoInfo == null ? "<unknown>" : repoInfo.getRootFolderId()));
+        timeLogger.printTimes();
+    }
+
+    private void repositoryInfo(OptionSet options) {
+        callRepoInfo(options.valueOf(fRepoId), options.valueOf(fCount));
+    }
+
+    private CmisBinding getBinding() {
+        if (binding == null) {
+            if (fUsingAtom)
+                binding = createAtomBinding(getAtomPubUrl(), DEFAULT_USER, DEFAULT_PWD);
+            else
+                binding = createWsBinding(getWsUrl(), DEFAULT_USER, DEFAULT_PWD);
+        }
+        return binding;
+    }
+
+    private static void filLoginParams(Map<String, String> parameters, String user, String password) {
+        if (user != null && user.length() > 0)
+            parameters.put(SessionParameter.USER, user);
+        if (user != null && user.length() > 0)
+            parameters.put(SessionParameter.PASSWORD, password);
+    }
+
+    private static CmisBinding createAtomBinding(String url, String user, String password) {
+
+        // gather parameters
+        Map<String, String> parameters = new HashMap<String, String>();
+        filLoginParams(parameters, user, password);
+
+        // get factory and create binding
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        parameters.put(SessionParameter.ATOMPUB_URL, url);
+        CmisBinding binding = factory.createCmisAtomPubBinding(parameters);
+        return binding;
+    }
+
+    private static CmisBinding createWsBinding(String url, String username, String password) {
+        boolean isPrefix = true;
+        String urlLower = url.toLowerCase();
+
+        if (urlLower.endsWith("?wsdl")) {
+            isPrefix = false;
+        } else if (urlLower.endsWith(".wsdl")) {
+            isPrefix = false;
+        } else if (urlLower.endsWith(".xml")) {
+            isPrefix = false;
+        }
+
+        return createBinding(url, isPrefix, username, password);
+    }
+
+    public static CmisBinding createBinding(String url, boolean isPrefix, String username, String password) {
+        // gather parameters
+        Map<String, String> parameters = new HashMap<String, String>();
+        parameters.put(SessionParameter.USER, username);
+        parameters.put(SessionParameter.PASSWORD, password);
+
+        if (!isPrefix) {
+            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url);
+            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url);
+        } else {
+            parameters.put(SessionParameter.WEBSERVICES_REPOSITORY_SERVICE, url + "RepositoryService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_NAVIGATION_SERVICE, url + "NavigationService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_OBJECT_SERVICE, url + "ObjectService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_VERSIONING_SERVICE, url + "VersioningService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_DISCOVERY_SERVICE, url + "DiscoveryService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_RELATIONSHIP_SERVICE, url + "RelationshipService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_MULTIFILING_SERVICE, url + "MultiFilingService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_POLICY_SERVICE, url + "PolicyService?wsdl");
+            parameters.put(SessionParameter.WEBSERVICES_ACL_SERVICE, url + "ACLService?wsdl");
+        }
+
+        // get factory and create provider
+        CmisBindingFactory factory = CmisBindingFactory.newInstance();
+        CmisBinding binding = factory.createCmisWebServicesBinding(parameters);
+
+        return binding;
+    }
+
+    private String getAtomPubUrl() {
+        return System.getProperty(PROP_ATOMPUB_URL, DEFAULT_ATOMPUB_URL);
+    }
+
+    private String getWsUrl() {
+        return System.getProperty(PROP_WS_URL, DEFAULT_WS_URL);
+    }
+
+    private String getConfiguredUrl() {
+        return System.getProperty(PROP_URL, fUrlStr);
+    }
+
+    private void getUrl(String urlStr) {
+        URL url;
+        InputStream is;
+        InputStreamReader isr;
+        BufferedReader r;
+        String str;
+
+        try {
+            System.out.println("Reading URL: " + urlStr);
+            url = new URL(urlStr);
+            is = url.openStream();
+            isr = new InputStreamReader(is);
+            r = new BufferedReader(isr);
+            do {
+                str = r.readLine();
+                if (str != null)
+                    System.out.println(str);
+            } while (str != null);
+        } catch (MalformedURLException e) {
+            System.out.println("Must enter a valid URL" + e);
+        } catch (IOException e) {
+            System.out.println("Can not connect" + e);
+        }
+    }
+
+}

Propchange: incubator/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjGenApp.java
------------------------------------------------------------------------------
    svn:eol-style = native