Author: degenaro
Date: Mon Oct 27 20:54:22 2014
New Revision: 1634683

URL: http://svn.apache.org/r1634683
Log:
UIMA-4068 Redesign of JD toward the main goal of classpath separation for user 
code.

Initial code drop.

Added:
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/QuotedOptions.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/UimaUtils.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/Utils.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CasManager.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CollectionReaderManager.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/IJdUserErrorHandlerDirective.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserCollectionReader.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserErrorHandlerDirective.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserException.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserMetaCas.java
   (with props)
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java
   (with props)
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/helper/
    
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/helper/CR100.java
   (with props)
    uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/CR100.xml   
(with props)

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/QuotedOptions.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/QuotedOptions.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/QuotedOptions.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/QuotedOptions.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,164 @@
+/*
+ * 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.uima.ducc.user.common;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class QuotedOptions {
+       /**
+        * Create an array of parameters from a whitespace-delimited list (e.g. 
JVM
+        * args or environment assignments.) Values containing whitespace must 
be
+        * single- or double-quoted: TERM=xterm DISPLAY=:1.0
+        * LD_LIBRARY_PATH="/my/path/with blanks/" EMPTY= -Dxyz="a b c" 
-Dabc='x y
+        * z' Quotes may be stripped or preserved. Values containing both types 
of
+        * quotes are NOT supported.
+        * 
+        * @param options
+        *            - string of blank-delimited options
+        * @param stripQuotes
+        *            - true if balanced quotes are to be removed
+        * @return - array of options
+        */
+       public static ArrayList<String> tokenizeList(String options,
+                       boolean stripQuotes) {
+
+               ArrayList<String> tokens = new ArrayList<String>();
+               if (options == null) {
+                       return tokens;
+               }
+
+               // Pattern matches a non-quoted region or a double-quoted 
region or a
+               // single-quoted region
+               // 1st part matches one or more non-whitespace characters but 
not " or '
+               // 2nd part matches a "quoted" region containing any character 
except "
+               // 3rd part matches a 'quoted' region containing any character 
except '
+               // See:
+               // 
http://stackoverflow.com/questions/3366281/tokenizing-a-string-but-ignoring-delimiters-within-quotes
+
+               String noSpaceRegex = "[^\\s\"']+";
+               String doubleQuoteRegex = "\"([^\"]*)\"";
+               String singleQuoteRegex = "'([^']*)'";
+               final String regex = noSpaceRegex + "|" + doubleQuoteRegex + "|"
+                               + singleQuoteRegex;
+               Pattern patn = Pattern.compile(regex);
+               Matcher matcher = patn.matcher(options);
+               StringBuilder sb = new StringBuilder();
+
+               // If stripping quotes extract the capturing group (without the 
quotes)
+               // When preserving quotes extract the full region
+               // Combine the pieces of a token until the match ends with 
whitespace
+               if (stripQuotes) {
+                       while (matcher.find()) {
+                               if (matcher.group(1) != null) {
+                                       sb.append(matcher.group(1));
+                               } else if (matcher.group(2) != null) {
+                                       sb.append(matcher.group(2));
+                               } else {
+                                       sb.append(matcher.group());
+                               }
+                               if (matcher.end() >= options.length()
+                                               || Character
+                                                               
.isWhitespace(options.charAt(matcher.end()))) {
+                                       tokens.add(sb.toString());
+                                       sb.setLength(0);
+                               }
+                       }
+               } else {
+                       while (matcher.find()) {
+                               sb.append(matcher.group());
+                               if (matcher.end() >= options.length()
+                                               || Character
+                                                               
.isWhitespace(options.charAt(matcher.end()))) {
+                                       tokens.add(sb.toString());
+                                       sb.setLength(0);
+                               }
+                       }
+               }
+               return tokens;
+       }
+
+       /*
+        * Create a map from an array of environment variable assignments 
produced
+        * by tokenizeList Quotes may have been stripped by tokenizeList The 
value
+        * is optional but the key is NOT, e.g. accept assignments of the form
+        * foo=abc & foo= & foo reject =foo & =
+        * 
+        * @param assignments - list of environment or JVM arg assignments
+        * 
+        * @param jvmArgs - true if tokens are JVM args -- process only the
+        * -Dprop=value entries
+        * 
+        * @return - map of key/value pairs null if syntax is illegal
+        */
+       public static Map<String, String> parseAssignments(
+                       List<String> assignments, boolean jvmArgs)
+                       throws IllegalArgumentException {
+
+               HashMap<String, String> map = new HashMap<String, String>();
+               if (assignments == null || assignments.size() == 0) {
+                       return map;
+               }
+               for (String assignment : assignments) {
+                       String[] parts = assignment.split("=", 2); // Split on 
first '='
+                       String key = parts[0];
+                       if (key.length() == 0) {
+                               throw new IllegalArgumentException(
+                                               "Missing key in assignment: " + 
assignment);
+                       }
+                       if (jvmArgs) {
+                               if (!key.startsWith("-D")) {
+                                       continue;
+                               }
+                               key = key.substring(2);
+                       }
+                       map.put(key, parts.length > 1 ? parts[1] : "");
+               }
+               return map;
+       }
+
+       // 
====================================================================================================
+
+       /*
+        * Test the quote handling and optional stripping
+        */
+       public static void main(String[] args) {
+               String[] lists = {
+                               "SINGLE_QUOTED='single 
quoted'\tDOUBLE_QUOTED=\"double quoted\"     SINGLE_QUOTE=\"'\" \r 
DOUBLE_QUOTE='\"'",
+                               "", "            ", null };
+
+               for (String list : lists) {
+                       System.out.println("List: " + list);
+                       ArrayList<String> tokens = tokenizeList(list, false);
+                       System.out.println("\n  quotes preserved on " + 
tokens.size());
+                       for (String token : tokens) {
+                               System.out.println("~" + token + "~");
+                       }
+                       tokens = tokenizeList(list, true);
+                       System.out.println("\n  quotes stripped from " + 
tokens.size());
+                       for (String token : tokens) {
+                               System.out.println("~" + token + "~");
+                       }
+               }
+       }
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/QuotedOptions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/UimaUtils.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/UimaUtils.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/UimaUtils.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/UimaUtils.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,126 @@
+/*
+ * 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.uima.ducc.user.common;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.resource.RelativePathResolver;
+import org.apache.uima.resource.ResourceConfigurationException;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.resource.impl.RelativePathResolver_impl;
+import org.apache.uima.resource.metadata.ConfigurationParameter;
+import org.apache.uima.resource.metadata.ConfigurationParameterDeclarations;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.XMLInputSource;
+
+public class UimaUtils {
+
+       public static RelativePathResolver resolver = new 
RelativePathResolver_impl();
+
+       public static URL getRelativePathWithProtocol(String aRelativePath)
+                       throws MalformedURLException {
+               URL relativeUrl;
+               try {
+                       relativeUrl = new URL(aRelativePath);
+               } catch (MalformedURLException e) {
+                       relativeUrl = new URL("file", "", aRelativePath);
+               }
+               return relativeUrl;
+       }
+
+       public static ResourceSpecifier getResourceSpecifier(String 
resourceFile)
+                       throws Exception {
+               return UIMAFramework.getXMLParser().parseResourceSpecifier(
+                               getXMLInputSource(resourceFile));
+       }
+
+       public static XMLInputSource getXMLInputSource(String resourceFile)
+                       throws InvalidXMLException {
+               //
+               // If the resourceFile ends in .xml then we look in the 
filesystem, end
+               // of story.
+               //
+               // If not, then we turn it into a path by replacing . with / and
+               // appending .xml.
+               // We then have two places we need to look:
+               // a) in the user's classpath directly as a file (not inside a 
jar), or
+               // b) in the jar files in the user's classpath
+               //
+
+               try {
+                       resourceFile = 
Utils.resolvePlaceholderIfExists(resourceFile,
+                                       System.getProperties());
+                       XMLInputSource in = null;
+                       if (resourceFile.endsWith(".xml")) {
+                               in = new XMLInputSource(resourceFile);
+                       } else {
+                               resourceFile = resourceFile.replace('.', '/') + 
".xml";
+                               URL relativeURL = resolver
+                                               
.resolveRelativePath(getRelativePathWithProtocol(resourceFile));
+                               in = new XMLInputSource(relativeURL);
+                       }
+                       return in;
+               } catch (NullPointerException npe) {
+                       throw new InvalidXMLException(
+                                       
InvalidXMLException.IMPORT_BY_NAME_TARGET_NOT_FOUND,
+                                       new String[] { resourceFile });
+               } catch (IOException e) {
+                       throw new InvalidXMLException(
+                                       
InvalidXMLException.IMPORT_FAILED_COULD_NOT_READ_FROM_URL,
+                                       new String[] { resourceFile });
+               }
+
+       }
+
+       public static ConfigurationParameter findConfigurationParameter(
+                       ConfigurationParameterDeclarations 
configurationParameterDeclarations,
+                       String name) {
+               ConfigurationParameter retVal = null;
+               for (ConfigurationParameter parameter : 
configurationParameterDeclarations
+                               .getConfigurationParameters()) {
+                       if (name.equals(parameter.getName())) {
+                               retVal = parameter;
+                               break;
+                       }
+               }
+               return retVal;
+       }
+
+       public static Object getOverrideValueObject(
+                       ConfigurationParameter configurationParameter, String 
value)
+                       throws ResourceConfigurationException {
+               Object retVal = value;
+               try {
+                       if (configurationParameter.getType().equals("Integer")) 
{
+                               retVal = Integer.parseInt(value);
+                       } else if 
(configurationParameter.getType().equals("Boolean")) {
+                               retVal = Boolean.parseBoolean(value);
+                       } else if 
(configurationParameter.getType().equals("Float")) {
+                               retVal = Float.parseFloat(value);
+                       }
+               } catch (Throwable t) {
+                       throw new ResourceConfigurationException(t);
+               }
+               return retVal;
+       }
+
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/UimaUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/Utils.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/Utils.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/Utils.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/Utils.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,99 @@
+/*
+ * 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.uima.ducc.user.common;
+
+import java.util.Properties;
+import java.util.regex.Pattern;
+
+public class Utils {
+
+       /**
+        * Resolves placeholders in provided contents using java's Matcher. 
Finds
+        * all occurances of ${<placeholder>} and resolves each using System
+        * properties which holds <placeholder>=<value> pairs.
+        * 
+        * @param contents
+        *            - target text containing placeholder(s)
+        * @param props
+        *            - Properties object holding key/value pairs
+        * @return - text with resolved placeholders
+        * 
+        * @throws Exception
+        */
+       public static String resolvePlaceholders(String contents) {
+               return resolvePlaceholders(contents, System.getProperties());
+       }
+
+       /**
+        * Resolves placeholders in provided contents using java's Matcher. 
Finds
+        * all occurances of ${<placeholder>} and resolves each using provided
+        * Properties object which holds <placeholder>=<value> pairs. If the
+        * placeholder not found then tries the System properties.
+        * 
+        * @param contents
+        *            - target text containing placeholder(s)
+        * @param props
+        *            - Properties object holding key/value pairs
+        * @return - text with resolved placeholders
+        * 
+        * @throws Exception
+        */
+       public static String resolvePlaceholders(String contents, Properties 
props) {
+               // Placeholders syntax ${<placeholder>}
+               Pattern placeHolderPattern = Pattern.compile("\\$\\{(.*?)\\}");
+
+               java.util.regex.Matcher matcher = 
placeHolderPattern.matcher(contents);
+
+               StringBuffer sb = new StringBuffer();
+               while (matcher.find()) {
+                       // extract placeholder
+                       final String key = matcher.group(1);
+                       // Find value for extracted placeholder.
+                       String placeholderValue = props.getProperty(key);
+                       if (placeholderValue == null) {
+                               placeholderValue = System.getProperty(key);
+                               if (placeholderValue == null) {
+                                       throw new IllegalArgumentException(
+                                                       "Missing value for 
placeholder: " + key);
+                               }
+                       }
+                       matcher.appendReplacement(sb, placeholderValue);
+               }
+               matcher.appendTail(sb);
+               return sb.toString();
+       }
+
+       /**
+        * Resolves placeholder using Spring Framework utility class
+        * 
+        * 
+        * @param value
+        * @param props
+        * @return
+        */
+       public static String resolvePlaceholderIfExists(String value,
+                       Properties props) {
+               String retVal = value;
+               if (value != null && value.contains("${")) {
+                       retVal = resolvePlaceholders(value, props);
+               }
+               return retVal;
+       }
+
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/common/Utils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CasManager.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CasManager.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CasManager.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CasManager.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,119 @@
+/*
+ * 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.uima.ducc.user.jd;
+
+import java.util.Properties;
+import java.util.concurrent.ConcurrentLinkedQueue;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.collection.CollectionReader;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.metadata.FsIndexDescription;
+import org.apache.uima.resource.metadata.TypePriorities;
+import org.apache.uima.resource.metadata.TypeSystemDescription;
+import org.apache.uima.util.CasCreationUtils;
+
+public class CasManager {
+
+       private String CAS_INITIAL_HEAP_SIZE = "1000";
+       
+       private ConcurrentLinkedQueue<CAS> recycledCasList = new 
ConcurrentLinkedQueue<CAS>();
+       
+       private ConcurrentLinkedQueue<String> casIds = new 
ConcurrentLinkedQueue<String>();
+       
+       private TypeSystemDescription tsd = null;
+       private TypePriorities tp = null;
+       private FsIndexDescription[] fid;
+       private Properties crProperties = new Properties();
+       
+       public CasManager(CollectionReader cr) {
+               
setTypeSystemDescription(cr.getProcessingResourceMetaData().getTypeSystem());
+               
setTypePriorities(cr.getProcessingResourceMetaData().getTypePriorities());
+               
setFsIndexDescription(cr.getProcessingResourceMetaData().getFsIndexes());
+               initCrProperties();
+       }
+       
+       public CAS getEmptyCas() throws ResourceInitializationException {
+               CAS cas = getRecycledCas();
+               while(cas == null) {
+                       synchronized(CasCreationUtils.class) {
+                               cas = CasCreationUtils.createCas(tsd, tp, fid, 
crProperties);
+                       }
+                       String casId = ""+cas.hashCode();
+                       if(!casIds.contains(casId)) {
+                               casIds.add(casId);
+                       }
+                       else {
+                               cas = getRecycledCas();
+                       }
+               }
+               return cas;
+       }
+       
+       public void recycle(CAS cas) {
+               cas.reset();
+               putRecycledCas(cas);
+       }
+       
+       private CAS getRecycledCas() {
+               CAS cas = null;
+               if(!recycledCasList.isEmpty()) {
+                       cas = recycledCasList.poll();
+               }
+               return cas;
+       }
+       
+       private void putRecycledCas(CAS cas) {
+               recycledCasList.add(cas);
+       }
+       
+       private void setTypeSystemDescription(TypeSystemDescription value) {
+               tsd = value;
+       }
+
+       public TypeSystemDescription getTypeSystemDescription() {
+               return tsd;
+       }
+       
+       private void setTypePriorities(TypePriorities value) {
+               tp = value;
+       }
+
+       public TypePriorities getTypePriorities() {
+               return tp;
+       }
+       
+       private void setFsIndexDescription(FsIndexDescription[] value) {
+               fid = value;
+       }
+
+       public FsIndexDescription[] getFsIndexDescription() {
+               return fid;
+       }
+       
+       private void initCrProperties() {
+               // Change the heap size to reduce CAS size. The size here 
depends on
+               // what we intend to
+               // put into the CAS. If its just a pointer to data (like 
question id),
+               // the size of the
+               // heap can be reduced even more
+               crProperties.setProperty(UIMAFramework.CAS_INITIAL_HEAP_SIZE, 
CAS_INITIAL_HEAP_SIZE);
+       }
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CasManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CollectionReaderManager.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CollectionReaderManager.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CollectionReaderManager.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CollectionReaderManager.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,210 @@
+/*
+ * 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.uima.ducc.user.jd;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.aae.UimaSerializer;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.impl.XmiSerializationSharedData;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.collection.CollectionReader;
+import org.apache.uima.ducc.user.common.QuotedOptions;
+import org.apache.uima.ducc.user.common.UimaUtils;
+import org.apache.uima.ducc.user.jd.iface.JdUserException;
+import org.apache.uima.ducc.user.jd.iface.JdUserMetaCas;
+import org.apache.uima.resource.ResourceConfigurationException;
+import org.apache.uima.resource.ResourceCreationSpecifier;
+import org.apache.uima.resource.ResourceInitializationException;
+import org.apache.uima.resource.ResourceSpecifier;
+import org.apache.uima.resource.metadata.ConfigurationParameter;
+import org.apache.uima.resource.metadata.ConfigurationParameterDeclarations;
+import org.apache.uima.resource.metadata.ConfigurationParameterSettings;
+import org.apache.uima.util.InvalidXMLException;
+import org.apache.uima.util.Progress;
+import org.apache.uima.util.XMLInputSource;
+import org.apache.uima.util.XMLParser;
+
+public class CollectionReaderManager {
+
+       private static UimaSerializer uimaSerializer = new UimaSerializer();
+       private static XmiSerializationSharedData xmiSerializationSharedData = 
new XmiSerializationSharedData();
+       
+       private String crXml = null;
+       private String crCfg = null;
+
+       private CasManager cm = null;
+       private CollectionReader cr = null;
+
+       private HashMap<String, String> overrides = new HashMap<String, 
String>();
+
+       private int total = -1;
+       
+       private AtomicInteger seqNo = new AtomicInteger(0);
+       
+       public CollectionReaderManager(String crXml, String crCfg) throws 
JdUserException {
+               initialize(crXml, crCfg);
+       }
+
+       public void initialize(String crXml, String crCfg) throws 
JdUserException {
+               try {
+                       _initialize(crXml, crCfg);
+               }
+               catch(Exception e) {
+                       JdUserException jdUserException = new 
JdUserException(e.toString());
+                       throw jdUserException;
+               }
+       }
+       
+       private void _initialize(String crXml, String crCfg) throws 
InvalidXMLException, ResourceConfigurationException, 
ResourceInitializationException {
+               setCrXml(crXml);
+               setCrCfg(crCfg);
+               //
+               // Read and parse the collection reader
+               //
+               XMLParser xmlParser = UIMAFramework.getXMLParser();
+               XMLInputSource in = null;
+               String crDescriptor = crXml;
+               in = UimaUtils.getXMLInputSource(crDescriptor);
+               ResourceSpecifier crrs = 
xmlParser.parseCollectionReaderDescription(in);
+               // CR overrides
+               ResourceCreationSpecifier specifier = 
(ResourceCreationSpecifier) crrs;
+               ConfigurationParameterDeclarations 
configurationParameterDeclarations = specifier
+                               
.getMetaData().getConfigurationParameterDeclarations();
+               ConfigurationParameterSettings cps = specifier.getMetaData()
+                               .getConfigurationParameterSettings();
+               if (crCfg != null) {
+                       // Tokenize override assignments on whitespace, 
honoring but
+                       // stripping quotes
+                       // Then create a map from all of them
+                       ArrayList<String> toks = 
QuotedOptions.tokenizeList(crCfg, true);
+                       Map<String, String> map = 
QuotedOptions.parseAssignments(toks,
+                                       false);
+                       for (Entry<String, String> ent : map.entrySet()) {
+                               String name = ent.getKey();
+                               String value = ent.getValue();
+                               overrides.put(name, value);
+                               ConfigurationParameter configurationParameter = 
UimaUtils
+                                               .findConfigurationParameter(
+                                                               
configurationParameterDeclarations, name);
+                               if (configurationParameter == null) {
+                                       throw new 
ResourceConfigurationException(
+                                                       
ResourceConfigurationException.NONEXISTENT_PARAMETER,
+                                                       new Object[] { name, 
"CollectionReader" });
+                               }
+                               Object object = 
UimaUtils.getOverrideValueObject(
+                                               configurationParameter, value);
+                               cps.setParameterValue(name, object);
+                       }
+               }
+               // CollectionReader
+               setCr(UIMAFramework.produceCollectionReader(crrs));
+               initTotal();
+               // CasManager
+               cm = new CasManager(cr);
+       }
+
+       public int getTotal() {
+               return total;
+       }
+       
+       public JdUserMetaCas getJdUserMetaCas() throws JdUserException {
+               try {
+                       return _getJdUserMetaCas();
+               }
+               catch(Exception e) {
+                       JdUserException jdUserException = new 
JdUserException(e.toString());
+                       throw jdUserException;
+               }
+       }
+       
+       private JdUserMetaCas _getJdUserMetaCas() throws CollectionException, 
IOException, Exception {
+               JdUserMetaCas retVal = null;
+               cm.getEmptyCas();
+               synchronized(cr) {
+                       if(cr.hasNext()) {
+                               CAS cas = cm.getEmptyCas();
+                               cr.getNext(cas);
+                               String serializedCas = 
uimaSerializer.serializeCasToXmi(cas, xmiSerializationSharedData);
+                               String documentText = cas.getDocumentText();
+                               retVal = new 
JdUserMetaCas(seqNo.incrementAndGet(), serializedCas, documentText);
+                               cm.recycle(cas);
+                       }
+               }
+               return retVal;
+       }
+       
+       private void setCrXml(String value) {
+               crXml = value;
+       }
+
+       public String getCrXml() {
+               return crXml;
+       }
+       
+       private void setCrCfg(String value) {
+               crCfg = value;
+       }
+
+       public String getCrCfg() {
+               return crCfg;
+       }
+       
+       private void setCr(CollectionReader value) {
+               cr = value;
+       }
+
+       public CollectionReader getCr() {
+               return cr;
+       }
+
+
+       public Progress[] getProgressArray() {
+               synchronized (cr) {
+                       return cr.getProgress();
+               }
+       }
+
+       public Progress getProgress() {
+               Progress progress = null;
+               Progress[] progressArray = getProgressArray();
+               if (progressArray != null) {
+                       progress = progressArray[0];
+               }
+               return progress;
+       }
+
+       private void initTotal() {
+               Progress progress = getProgress();
+               if (progress != null) {
+                       setTotal((int) progress.getTotal());
+               }
+       }
+
+       private void setTotal(int value) {
+               total = value;
+       }
+
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/CollectionReaderManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/IJdUserErrorHandlerDirective.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/IJdUserErrorHandlerDirective.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/IJdUserErrorHandlerDirective.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/IJdUserErrorHandlerDirective.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,16 @@
+package org.apache.uima.ducc.user.jd.iface;
+
+import java.util.Properties;
+
+public interface IJdUserErrorHandlerDirective {
+
+       public boolean isTerminateJob();
+       public boolean isTerminateProcess();
+       public boolean isRetryCas();
+       
+       public String getReasonTerminateJob();
+       public String getReasonTerminateProcess();
+       public String getReasonRetryCas();
+       
+       public void config(Properties properties);
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/IJdUserErrorHandlerDirective.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserCollectionReader.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserCollectionReader.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserCollectionReader.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserCollectionReader.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,44 @@
+/*
+ * 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.uima.ducc.user.jd.iface;
+
+import org.apache.uima.ducc.user.jd.CollectionReaderManager;
+
+public class JdUserCollectionReader {
+       
+       CollectionReaderManager crm = null;
+       
+       public JdUserCollectionReader() throws JdUserException {
+       }
+       
+       public JdUserCollectionReader(String crXml, String crCfg) throws 
JdUserException {
+               crm = new CollectionReaderManager(crXml, crCfg);
+       }
+       
+       public JdUserMetaCas getJdUserMetaCas() throws JdUserException {
+               JdUserMetaCas retVal = crm.getJdUserMetaCas();
+               return retVal;
+       }
+       
+       public int getTotal() {
+               int retVal = crm.getTotal();
+               return retVal;
+       }
+       
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserCollectionReader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserErrorHandlerDirective.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserErrorHandlerDirective.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserErrorHandlerDirective.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserErrorHandlerDirective.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,55 @@
+package org.apache.uima.ducc.user.jd.iface;
+
+import java.util.Properties;
+
+public class JdUserErrorHandlerDirective implements 
IJdUserErrorHandlerDirective {
+
+       private boolean terminateJob = false;
+       private boolean terminateProcess = false;
+       private boolean retryCas = false;
+       
+       private String reasonTerminateJob = null;
+       private String reasonTerminateProcess = null;
+       private String reasonRetryCas = null;
+       
+       
+       @Override
+       public boolean isTerminateJob() {
+               return terminateJob;
+       }
+
+       @Override
+       public boolean isTerminateProcess() {
+               return terminateProcess;
+       }
+
+       @Override
+       public boolean isRetryCas() {
+               return retryCas;
+       }
+
+       @Override
+       public String getReasonTerminateJob() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public String getReasonTerminateProcess() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public String getReasonRetryCas() {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+       @Override
+       public void config(Properties properties) {
+               // TODO Auto-generated method stub
+               
+       }
+
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserErrorHandlerDirective.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserException.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserException.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserException.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserException.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,28 @@
+/*
+ * 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.uima.ducc.user.jd.iface;
+
+public class JdUserException extends Exception {
+
+       private static final long serialVersionUID = 1L;
+
+       public JdUserException(String message) {
+               super(message);
+       }
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserMetaCas.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserMetaCas.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserMetaCas.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserMetaCas.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,60 @@
+/*
+ * 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.uima.ducc.user.jd.iface;
+
+public class JdUserMetaCas {
+
+       private int seqNo = -1;
+       private String serializedCas = null;
+       private String documentText = null;
+       
+       public JdUserMetaCas(int seqNo, String serializedCas, String 
documentText) {
+               setSeqNo(seqNo);
+               setSerializedCas(serializedCas);
+               setDocumentText(documentText);
+       }
+       
+       private void setSeqNo(int value) {
+               seqNo = value;
+       }
+       
+       public int getSeqNo() {
+               return seqNo;
+       }
+       
+       private void setSerializedCas(String value) {
+               serializedCas = value;
+       }
+       
+       public String getSerializedCas() {
+               return serializedCas;
+       }
+       
+       private void setDocumentText(String value) {
+               documentText = value;
+       }
+       
+       public String getDocumentText() {
+               return documentText;
+       }
+       
+       public void printMe() {
+               System.out.println("seq:"+getSeqNo()+" 
"+"id:"+getDocumentText()+" "+"cas:"+getSerializedCas());
+       }
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/main/java/org/apache/uima/ducc/user/jd/iface/JdUserMetaCas.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,173 @@
+/*
+ * 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.uima.ducc.user.jd.test;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.net.URL;
+
+import org.apache.uima.ducc.user.jd.iface.JdUserCollectionReader;
+import org.apache.uima.ducc.user.jd.iface.JdUserException;
+import org.apache.uima.ducc.user.jd.iface.JdUserMetaCas;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class TestSuite {
+
+       @BeforeClass
+       public static void setUpBeforeClass() throws Exception {
+       }
+
+       @AfterClass
+       public static void tearDownAfterClass() throws Exception {
+       }
+
+       @Before
+       public void setUp() throws Exception {
+       }
+
+       @After
+       public void tearDown() throws Exception {
+       }
+       
+       private boolean debug = true;
+       
+       private void out_println(String message) {
+               System.out.println(message);
+       }
+       
+       private void debug(String message) {
+               if(debug) {
+                       out_println(message);
+               }
+       }
+       
+       @Test
+       public void test01() {
+               try {
+                       int seqNo = 1;
+                       String serializedCas = "ABC";
+                       String documentText = "123";
+                       JdUserMetaCas jdUserMetaCas = new JdUserMetaCas(seqNo, 
serializedCas, documentText);
+                       assertTrue(seqNo == jdUserMetaCas.getSeqNo());
+                       
assertTrue(serializedCas.equals(jdUserMetaCas.getSerializedCas()));
+                       
assertTrue(documentText.equals(jdUserMetaCas.getDocumentText()));
+               }
+               catch(Exception e) {
+                       e.printStackTrace();
+                       fail("Exception");
+               }
+       }
+       
+       @Test
+       public void test02() {
+               try {
+                       String message = "XYZ";
+                       JdUserException jdUserException = new 
JdUserException(message);
+                       
assertTrue(message.equals(jdUserException.getMessage()));
+               }
+               catch(Exception e) {
+                       e.printStackTrace();
+                       fail("Exception");
+               }
+       }
+       
+       @Test
+       public void test03() {
+               try {
+                       URL url = this.getClass().getResource("/CR100.xml");
+                       File file = new File(url.getFile());
+                       String crXml = file.getAbsolutePath();
+                       debug(crXml);
+                       String crCfg = null;
+                       JdUserCollectionReader jdUserCollectionReader = new 
JdUserCollectionReader(crXml, crCfg);
+                       int total = jdUserCollectionReader.getTotal();
+                       assertTrue(total == 100);
+               }
+               catch(Exception e) {
+                       e.printStackTrace();
+                       fail("Exception");
+               }
+       }
+       
+       @Test
+       public void test04() {
+               try {
+                       URL url = this.getClass().getResource("/CR100.xml");
+                       File file = new File(url.getFile());
+                       String crXml = file.getAbsolutePath();
+                       debug(crXml);
+                       String crCfg = null;
+                       JdUserCollectionReader jdUserCollectionReader = new 
JdUserCollectionReader(crXml, crCfg);
+                       int total = jdUserCollectionReader.getTotal();
+                       assertTrue(total == 100);
+                       int counter = 0;
+                       JdUserMetaCas jdUserMetaCas = 
jdUserCollectionReader.getJdUserMetaCas();
+                       while(jdUserMetaCas != null) {
+                               jdUserMetaCas.printMe();
+                               counter++;
+                               if(counter > 100) {
+                                       fail("Too many CASes: "+counter);
+                               }
+                               jdUserMetaCas = 
jdUserCollectionReader.getJdUserMetaCas();
+                       }
+                       if(counter < 100) {
+                               fail("Not enough CASes: "+counter);
+                       }
+               }
+               catch(Exception e) {
+                       e.printStackTrace();
+                       fail("Exception");
+               }
+       }
+       
+       @Test
+       public void test05() {
+               try {
+                       URL url = this.getClass().getResource("/CR100.xml");
+                       File file = new File(url.getFile());
+                       String crXml = file.getAbsolutePath();
+                       debug(crXml);
+                       String crCfg = null;
+                       JdUserCollectionReader jdUserCollectionReader = new 
JdUserCollectionReader(crXml, crCfg);
+                       int total = jdUserCollectionReader.getTotal();
+                       assertTrue(total == 100);
+                       JdUserMetaCas jdUserMetaCas = null;
+                       int counter = 0;
+                       for(int i=0; i<total; i++) {
+                               jdUserMetaCas = 
jdUserCollectionReader.getJdUserMetaCas();
+                               assertTrue(jdUserMetaCas != null);
+                               counter++;
+                       }
+                       jdUserMetaCas = 
jdUserCollectionReader.getJdUserMetaCas();
+                       assertTrue(jdUserMetaCas == null);
+                       assertTrue(counter == 100);
+               }
+               catch(Exception e) {
+                       e.printStackTrace();
+                       fail("Exception");
+               }
+       }
+       
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/TestSuite.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/helper/CR100.java
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/helper/CR100.java?rev=1634683&view=auto
==============================================================================
--- 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/helper/CR100.java
 (added)
+++ 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/helper/CR100.java
 Mon Oct 27 20:54:22 2014
@@ -0,0 +1,46 @@
+package org.apache.uima.ducc.user.jd.test.helper;
+
+import java.io.IOException;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.uima.cas.CAS;
+import org.apache.uima.collection.CollectionException;
+import org.apache.uima.collection.CollectionReader_ImplBase;
+import org.apache.uima.util.Progress;
+import org.apache.uima.util.ProgressImpl;
+
+public class CR100 extends CollectionReader_ImplBase {
+
+       private int casLimit = 100;
+       private AtomicInteger casCounter = new AtomicInteger(0);
+       
+       @Override
+       public void getNext(CAS aCAS) throws IOException, CollectionException {
+               aCAS.reset();
+               int item = casCounter.incrementAndGet();
+               if(item <= casLimit) {
+                       aCAS.setSofaDataString(""+item, "text");
+               }
+       }
+
+       @Override
+       public boolean hasNext() throws IOException, CollectionException {
+               boolean retVal = false;
+               if(casCounter.get() < casLimit) {
+                       retVal = true;
+               }
+               return retVal;
+       }
+
+       @Override
+       public Progress[] getProgress() {
+               ProgressImpl[] retVal = new ProgressImpl[1];
+               retVal[0] = new ProgressImpl(casCounter.get(), casLimit, 
"CASes");
+               return retVal;
+       }
+
+       @Override
+       public void close() throws IOException {
+       }
+
+}

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/java/org/apache/uima/ducc/user/jd/test/helper/CR100.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/CR100.xml
URL: 
http://svn.apache.org/viewvc/uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/CR100.xml?rev=1634683&view=auto
==============================================================================
--- uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/CR100.xml 
(added)
+++ uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/CR100.xml 
Mon Oct 27 20:54:22 2014
@@ -0,0 +1,111 @@
+<?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.
+        ***************************************************************
+   -->
+   
+<!-- A simple collection reader that reads text files from a directory in the
+     filesystem.  The Java class for this collection reader is in 
uima_core.jar. -->
+
+<collectionReaderDescription  xmlns="http://uima.apache.org/resourceSpecifier";>
+    <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+    
<implementationName>org.apache.uima.ducc.user.jd.test.helper.CR100</implementationName>
+    <processingResourceMetaData>
+        <name>Driver Collection Reader</name>
+        <description>Generates CASes comprising indices.</description>
+        <version>1.0</version>
+        <vendor>The Apache Software Foundation</vendor>
+        
+        <configurationParameters>
+
+               <configurationParameter>
+                       <name>compression</name>
+                       <description>Compression</description>
+                       <type>String</type>
+                       <multiValued>false</multiValued>
+                       <mandatory>false</mandatory>
+               </configurationParameter>
+
+               <configurationParameter>
+                       <name>jobfile</name>
+                       <description>JobFile</description>
+                       <type>String</type>
+                       <multiValued>false</multiValued>
+                       <mandatory>false</mandatory>
+               </configurationParameter>
+
+               <configurationParameter>
+                       <name>error_rate</name>
+                       <description>ErrorRate</description>
+                       <type>String</type>
+                       <multiValued>false</multiValued>
+                       <mandatory>false</mandatory>
+               </configurationParameter>
+
+       </configurationParameters>
+
+               <configurationParameterSettings>
+
+                 <nameValuePair>
+                   <name>compression</name>
+                   <value>
+                     <string>10</string>
+                   </value>
+                 </nameValuePair>
+
+                 <nameValuePair>
+                   <name>error_rate</name>
+                   <value>
+                     <string>0</string>
+                   </value>
+                 </nameValuePair>
+
+                 <nameValuePair>
+                   <name>jobfile</name>
+                   <value>
+                     <string>../ducc_test/jobs/1.job</string>
+                   </value>
+                 </nameValuePair>
+
+       </configurationParameterSettings>
+       
+        <!-- Type System of CASes returned by this Collection Reader -->
+
+        <typeSystemDescription>
+          <imports>
+            <import name="org.apache.uima.examples.SourceDocumentInformation"/>
+          </imports>
+        </typeSystemDescription>
+
+        <capabilities>
+               <capability>
+                       <inputs/>
+                       <outputs>
+                               <type 
allAnnotatorFeatures="true">org.apache.uima.examples.SourceDocumentInformation</type>
+                       </outputs>
+               </capability>
+        </capabilities>
+               <operationalProperties>
+                       <modifiesCas>false</modifiesCas>
+                       
<multipleDeploymentAllowed>false</multipleDeploymentAllowed>
+                       <outputsNewCASes>true</outputsNewCASes>
+               </operationalProperties>                
+    </processingResourceMetaData>
+</collectionReaderDescription>

Propchange: 
uima/sandbox/uima-ducc/trunk/uima-ducc-user/src/test/resources/CR100.xml
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to