You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by je...@apache.org on 2013/08/20 22:58:05 UTC

svn commit: r1515969 [2/2] - in /chemistry/opencmis/trunk: chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/java/org/apache/chemistry/opencmis/inmemory/query/ chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/main/ja...

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java?rev=1515969&r1=1515968&r2=1515969&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/fractal/FractalGenerator.java Tue Aug 20 20:58:05 2013
@@ -75,19 +75,18 @@ public class FractalGenerator {
     private final String[] colorSchemes = { COLORS_BLACK_AND_WHITE, COLORS_BLUE_ICE, COLORS_FUNKY, COLORS_PASTEL,
             COLORS_PSYCHEDELIC, COLORS_PURPLE_HAZE, COLORS_RADICAL, COLORS_RAINBOW, COLORS_RAINBOWS,
             COLORS_SCINTILLATION, COLORS_WARPED, COLORS_WILD, COLORS_ZEBRA };
-    private final int imageHeight = 512; // default
-    private final int imageWidth = 512; // default
-    private final int numColors = 512; // colors per colormap
+    private static final int IMAGE_HEIGHT = 512; // default
+    private static final int IMAGE_WIDTH = 512; // default
+    private static final int NUM_COLORS = 512; // colors per colormap
     private FractalCalculator calculator;
     private int previousIterations = 1;
     private int maxIterations;
-    String color;
-    int counter = 0;
-    int newRowTile, newColTile;
-    int parts = 16;
+    private String color;
+    private int newRowTile, newColTile;
+    private int parts = 16;
     private int stepInBatch = 0;
-    ComplexRectangle rect;
-    ComplexPoint juliaPoint;
+    private ComplexRectangle rect;
+    private ComplexPoint juliaPoint;
 
     public FractalGenerator() {
         reset();
@@ -166,16 +165,12 @@ public class FractalGenerator {
         LOG.debug("using " + maxIterations + " iterations.");
         detectDeepZoom(rect);
 
-        calculator = new FractalCalculator(rect, maxIterations, imageWidth, imageHeight, getCurrentColorMap(),
+        calculator = new FractalCalculator(rect, maxIterations, IMAGE_WIDTH, IMAGE_HEIGHT, getCurrentColorMap(),
                 juliaPoint);
         int[][] iterations = calculator.calcFractal();
         BufferedImage image = calculator.mapItersToColors(iterations);
         findNewRect(image, iterations);
 
-        // fast method to write to a file with default options
-        // ImageIO.write((BufferedImage)(image), "jpg", new File("fractal-" +
-        // counter++ + ".jpg"));
-
         // create image in memory
         ByteArrayOutputStream bos = new ByteArrayOutputStream(200 * 1024);
         ImageOutputStream ios = ImageIO.createImageOutputStream(bos);
@@ -190,13 +185,6 @@ public class FractalGenerator {
         imageWriter.write(null, new IIOImage(image, null, null), params);
         ios.close();
 
-        // write memory block to a file
-        // String fileName = String.format(pattern, counter++);
-        // FileOutputStream outputStream = new FileOutputStream (fileName);
-        // bos.writeTo(outputStream);
-        // bos.close();
-        // outputStream.close();
-
         return bos;
     }
 
@@ -220,10 +208,8 @@ public class FractalGenerator {
         double complexWidth = rMax - rMin;
         double complexHeight = iMax - iMin;
 
-        if ((imageWidth > 0) && (imageHeight > 0)) {
-            imageWHRatio = ((double) imageWidth / (double) imageHeight);
-        } else {
-            return;
+        if ((IMAGE_WIDTH > 0) && (IMAGE_HEIGHT > 0)) {
+            imageWHRatio = ((double) IMAGE_WIDTH / (double) IMAGE_HEIGHT);
         }
 
         if ((complexWidth > 0) && (complexHeight > 0)) {
@@ -286,7 +272,7 @@ public class FractalGenerator {
         // double
         // runs out of resolution. The use of BigDecimal is required to fix
         // this.
-        double deltaDiv2 = cr.getWidth() / ((imageWidth) * 2.0);
+        double deltaDiv2 = cr.getWidth() / ((IMAGE_WIDTH) * 2.0);
         String min = "" + (cr.getRMin());
         String minPlus = "" + (cr.getRMin() + deltaDiv2);
 
@@ -309,48 +295,48 @@ public class FractalGenerator {
         float brightness = (float) 1.0;
 
         // COLORS_BLACK_AND_WHITE:
-        int[] colorMap = new int[numColors];
-        for (int colorNum = numColors - 1; colorNum >= 0; colorNum--) {
+        int[] colorMap = new int[NUM_COLORS];
+        for (int colorNum = NUM_COLORS - 1; colorNum >= 0; colorNum--) {
             colorMap[colorNum] = Color.white.getRGB();
         }
         colorTable.put(COLORS_BLACK_AND_WHITE, colorMap);
 
         // COLORS_BLUE_ICE:
         blue = 255;
-        colorMap = new int[numColors];
-        for (int colorNum = numColors - 1; colorNum >= 0; colorNum--) {
-            red = (int) ((255 * (float) colorNum / numColors)) % 255;
-            green = (int) ((255 * (float) colorNum / numColors)) % 255;
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = NUM_COLORS - 1; colorNum >= 0; colorNum--) {
+            red = (int) ((255 * (float) colorNum / NUM_COLORS)) % 255;
+            green = (int) ((255 * (float) colorNum / NUM_COLORS)) % 255;
             colorMap[colorNum] = new Color(red, green, blue).getRGB();
         }
         colorTable.put(COLORS_BLUE_ICE, colorMap);
 
         // COLORS_FUNKY:
-        colorMap = new int[numColors];
-        for (int colorNum = numColors - 1; colorNum >= 0; colorNum--) {
-            red = (int) ((1024 * (float) colorNum / numColors)) % 255;
-            green = (int) ((512 * (float) colorNum / numColors)) % 255;
-            blue = (int) ((256 * (float) colorNum / numColors)) % 255;
-            colorMap[numColors - colorNum - 1] = new Color(red, green, blue).getRGB();
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = NUM_COLORS - 1; colorNum >= 0; colorNum--) {
+            red = (int) ((1024 * (float) colorNum / NUM_COLORS)) % 255;
+            green = (int) ((512 * (float) colorNum / NUM_COLORS)) % 255;
+            blue = (int) ((256 * (float) colorNum / NUM_COLORS)) % 255;
+            colorMap[NUM_COLORS - colorNum - 1] = new Color(red, green, blue).getRGB();
         }
         colorTable.put(COLORS_FUNKY, colorMap);
 
         // COLORS_PASTEL
         brightness = (float) 1.0;
-        colorMap = new int[numColors];
-        for (int colorNum = 0; colorNum < numColors; colorNum++) {
-            hue = ((float) (colorNum * 4) / (float) numColors) % numColors;
-            saturation = ((float) (colorNum * 2) / (float) numColors) % numColors;
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = 0; colorNum < NUM_COLORS; colorNum++) {
+            hue = ((float) (colorNum * 4) / (float) NUM_COLORS) % NUM_COLORS;
+            saturation = ((float) (colorNum * 2) / (float) NUM_COLORS) % NUM_COLORS;
             colorMap[colorNum] = Color.HSBtoRGB(hue, saturation, brightness);
         }
         colorTable.put(COLORS_PASTEL, colorMap);
 
         // COLORS_PSYCHEDELIC:
         saturation = (float) 1.0;
-        colorMap = new int[numColors];
-        for (int colorNum = 0; colorNum < numColors; colorNum++) {
-            hue = ((float) (colorNum * 5) / (float) numColors) % numColors;
-            brightness = ((float) (colorNum * 20) / (float) numColors) % numColors;
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = 0; colorNum < NUM_COLORS; colorNum++) {
+            hue = ((float) (colorNum * 5) / (float) NUM_COLORS) % NUM_COLORS;
+            brightness = ((float) (colorNum * 20) / (float) NUM_COLORS) % NUM_COLORS;
             colorMap[colorNum] = Color.HSBtoRGB(hue, saturation, brightness);
         }
         colorTable.put(COLORS_PSYCHEDELIC, colorMap);
@@ -358,19 +344,19 @@ public class FractalGenerator {
         // COLORS_PURPLE_HAZE:
         red = 255;
         blue = 255;
-        colorMap = new int[numColors];
-        for (int colorNum = numColors - 1; colorNum >= 0; colorNum--) {
-            green = (int) ((255 * (float) colorNum / numColors)) % 255;
-            colorMap[numColors - colorNum - 1] = new Color(red, green, blue).getRGB();
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = NUM_COLORS - 1; colorNum >= 0; colorNum--) {
+            green = (int) ((255 * (float) colorNum / NUM_COLORS)) % 255;
+            colorMap[NUM_COLORS - colorNum - 1] = new Color(red, green, blue).getRGB();
         }
         colorTable.put(COLORS_PURPLE_HAZE, colorMap);
 
         // COLORS_RADICAL:
         saturation = (float) 1.0;
-        colorMap = new int[numColors];
-        for (int colorNum = 0; colorNum < numColors; colorNum++) {
-            hue = ((float) (colorNum * 7) / (float) numColors) % numColors;
-            brightness = ((float) (colorNum * 49) / (float) numColors) % numColors;
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = 0; colorNum < NUM_COLORS; colorNum++) {
+            hue = ((float) (colorNum * 7) / (float) NUM_COLORS) % NUM_COLORS;
+            brightness = ((float) (colorNum * 49) / (float) NUM_COLORS) % NUM_COLORS;
             colorMap[colorNum] = Color.HSBtoRGB(hue, saturation, brightness);
         }
         colorTable.put(COLORS_RADICAL, colorMap);
@@ -378,9 +364,9 @@ public class FractalGenerator {
         // COLORS_RAINBOW:
         saturation = (float) 1.0;
         brightness = (float) 1.0;
-        colorMap = new int[numColors];
-        for (int colorNum = 0; colorNum < numColors; colorNum++) {
-            hue = (float) colorNum / (float) numColors;
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = 0; colorNum < NUM_COLORS; colorNum++) {
+            hue = (float) colorNum / (float) NUM_COLORS;
             colorMap[colorNum] = Color.HSBtoRGB(hue, saturation, brightness);
         }
         colorTable.put(COLORS_RAINBOW, colorMap);
@@ -388,9 +374,9 @@ public class FractalGenerator {
         // COLORS_RAINBOWS:
         saturation = (float) 1.0;
         brightness = (float) 1.0;
-        colorMap = new int[numColors];
-        for (int colorNum = 0; colorNum < numColors; colorNum++) {
-            hue = ((float) (colorNum * 5) / (float) numColors) % numColors;
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = 0; colorNum < NUM_COLORS; colorNum++) {
+            hue = ((float) (colorNum * 5) / (float) NUM_COLORS) % NUM_COLORS;
             colorMap[colorNum] = Color.HSBtoRGB(hue, saturation, brightness);
         }
         colorTable.put(COLORS_RAINBOWS, colorMap);
@@ -398,37 +384,37 @@ public class FractalGenerator {
         // COLORS_SCINTILLATION
         brightness = (float) 1.0;
         saturation = (float) 1.0;
-        colorMap = new int[numColors];
-        for (int colorNum = 0; colorNum < numColors; colorNum++) {
-            hue = ((float) (colorNum * 2) / (float) numColors) % numColors;
-            brightness = ((float) (colorNum * 5) / (float) numColors) % numColors;
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = 0; colorNum < NUM_COLORS; colorNum++) {
+            hue = ((float) (colorNum * 2) / (float) NUM_COLORS) % NUM_COLORS;
+            brightness = ((float) (colorNum * 5) / (float) NUM_COLORS) % NUM_COLORS;
             colorMap[colorNum] = Color.HSBtoRGB(hue, saturation, brightness);
         }
         colorTable.put(COLORS_SCINTILLATION, colorMap);
 
         // COLORS_WARPED:
-        colorMap = new int[numColors];
-        for (int colorNum = numColors - 1; colorNum >= 0; colorNum--) {
-            red = (int) ((1024 * (float) colorNum / numColors)) % 255;
-            green = (int) ((256 * (float) colorNum / numColors)) % 255;
-            blue = (int) ((512 * (float) colorNum / numColors)) % 255;
-            colorMap[numColors - colorNum - 1] = new Color(red, green, blue).getRGB();
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = NUM_COLORS - 1; colorNum >= 0; colorNum--) {
+            red = (int) ((1024 * (float) colorNum / NUM_COLORS)) % 255;
+            green = (int) ((256 * (float) colorNum / NUM_COLORS)) % 255;
+            blue = (int) ((512 * (float) colorNum / NUM_COLORS)) % 255;
+            colorMap[NUM_COLORS - colorNum - 1] = new Color(red, green, blue).getRGB();
         }
         colorTable.put(COLORS_WARPED, colorMap);
 
         // COLORS_WILD:
-        colorMap = new int[numColors];
-        for (int colorNum = 0; colorNum < numColors; colorNum++) {
-            hue = ((float) (colorNum * 1) / (float) numColors) % numColors;
-            saturation = ((float) (colorNum * 2) / (float) numColors) % numColors;
-            brightness = ((float) (colorNum * 4) / (float) numColors) % numColors;
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = 0; colorNum < NUM_COLORS; colorNum++) {
+            hue = ((float) (colorNum * 1) / (float) NUM_COLORS) % NUM_COLORS;
+            saturation = ((float) (colorNum * 2) / (float) NUM_COLORS) % NUM_COLORS;
+            brightness = ((float) (colorNum * 4) / (float) NUM_COLORS) % NUM_COLORS;
             colorMap[colorNum] = Color.HSBtoRGB(hue, saturation, brightness);
         }
         colorTable.put(COLORS_WILD, colorMap);
 
         // COLORS_ZEBRA:
-        colorMap = new int[numColors];
-        for (int colorNum = 0; colorNum < numColors; colorNum++) {
+        colorMap = new int[NUM_COLORS];
+        for (int colorNum = 0; colorNum < NUM_COLORS; colorNum++) {
             if (colorNum % 2 == 0) {
                 colorMap[colorNum] = Color.white.getRGB();
             } else {
@@ -450,7 +436,7 @@ public class FractalGenerator {
                                                                                        // aware
                                                                                        // of
                                                                                        // rounding
-                                                                                       // errors!;
+                                                                                       // errors!
         double[] stdDev = new double[noTiles];
 
         for (int y = 0; y + newHeight <= image.getHeight(); y += newHeight) {
@@ -492,7 +478,7 @@ public class FractalGenerator {
         double mean = 0.0;
 
         mean = (double) sum / count;
-        return Math.sqrt(sumSquare / count - (mean * mean));
+        return Math.sqrt(sumSquare / (count - (mean * mean)));
     }
 
 }

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java?rev=1515969&r1=1515968&r2=1515969&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsum.java Tue Aug 20 20:58:05 2013
@@ -46,6 +46,7 @@ public class LoremIpsum {
             this.len2 = len2;
         }
 
+        @Override
         public String toString() {
             return "WordLengthPair: len1: " + len1 + ", len2: " + len2;
         }
@@ -358,8 +359,9 @@ public class LoremIpsum {
 
         result.replace(0, 1, result.substring(0, 1).toUpperCase());
         int strLen = result.length() - 1;
-        if (wordDelimiter.length() > 0 && wordDelimiter.charAt(0) == result.charAt(strLen))
+        if (wordDelimiter.length() > 0 && wordDelimiter.charAt(0) == result.charAt(strLen)) {
             result.deleteCharAt(strLen);
+        }
         result.append(".");
         return result.toString();
     }
@@ -398,8 +400,9 @@ public class LoremIpsum {
         while (text.length() < quantity) {
             para = generateParagraph(false);
             text.append(para);
-            if (text.length() < quantity)
+            if (text.length() < quantity) {
                 text.append(between);
+            }
         }
 
         text.append(end);
@@ -575,8 +578,9 @@ public class LoremIpsum {
             }
         }
 
-        if (words.size() == 0)
+        if (words.size() == 0) {
             throw new RuntimeException("Invalid dictionary.");
+        }
     }
 
     /**
@@ -730,7 +734,7 @@ public class LoremIpsum {
     }
 
     public static double mean(double[] values) {
-        return sum(values) / ((double) (Math.max(values.length, 1)));
+        return sum(values) / ((Math.max(values.length, 1)));
     }
 
     public static double variance(double[] values) {
@@ -746,7 +750,7 @@ public class LoremIpsum {
     public static double sigma(int[] values) {
         double[] d = new double[values.length];
         for (int i = 0; i < values.length; i++) {
-            d[i] = (double) values[i];
+            d[i] = values[i];
         }
 
         return sigma(d);
@@ -773,10 +777,11 @@ public class LoremIpsum {
     }
 
     public static boolean contains(String[] array, String val) {
-        for (String s : array)
+        for (String s : array) {
             if (s.equals(val)) {
                 return true;
             }
+        }
         return false;
     }
 

Modified: 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/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java?rev=1515969&r1=1515968&r2=1515969&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/MultiThreadedObjectGenerator.java Tue Aug 20 20:58:05 2013
@@ -25,7 +25,7 @@ import org.apache.chemistry.opencmis.com
 import org.apache.chemistry.opencmis.commons.spi.NavigationService;
 import org.apache.chemistry.opencmis.commons.spi.ObjectService;
 import org.apache.chemistry.opencmis.commons.spi.RepositoryService;
-import org.apache.chemistry.opencmis.util.repository.ObjectGenerator.CONTENT_KIND;
+import org.apache.chemistry.opencmis.util.repository.ObjectGenerator.ContentKind;
 
 public class MultiThreadedObjectGenerator {
 
@@ -87,7 +87,7 @@ public class MultiThreadedObjectGenerato
 
     private static ObjectGenerator createObjectGenerator(CmisBinding binding, String repoId, int docsPerFolder,
             int foldersPerFolders, int depth, String documentType, String folderType, int contentSizeInKB,
-            String rootFolderId, CONTENT_KIND contentKind, boolean doCleanup) {
+            String rootFolderId, ContentKind contentKind, boolean doCleanup) {
 
         BindingsObjectFactory objectFactory = binding.getObjectFactory();
         NavigationService navSvc = binding.getNavigationService();
@@ -121,7 +121,7 @@ public class MultiThreadedObjectGenerato
 
     public static ObjectGeneratorRunner prepareForCreateTree(CmisBinding binding, String repoId, int docsPerFolder,
             int foldersPerFolders, int depth, String documentType, String folderType, int contentSizeInKB,
-            String rootFolderId, CONTENT_KIND contentKind, boolean doCleanup) {
+            String rootFolderId, ContentKind contentKind, boolean doCleanup) {
 
         ObjectGenerator objGen = createObjectGenerator(binding, repoId, docsPerFolder, foldersPerFolders, depth,
                 documentType, folderType, contentSizeInKB, rootFolderId, contentKind, doCleanup);
@@ -135,7 +135,7 @@ public class MultiThreadedObjectGenerato
 
     public static ObjectGeneratorRunner[] prepareForCreateTreeMT(CmisBinding provider, String repoId,
             int docsPerFolder, int foldersPerFolders, int depth, String documentType, String folderType,
-            int contentSizeInKB, String[] rootFolderIds, CONTENT_KIND contentKind, boolean doCleanup) {
+            int contentSizeInKB, String[] rootFolderIds, ContentKind contentKind, boolean doCleanup) {
 
         ObjectGeneratorRunner[] runners = new ObjectGeneratorRunner[rootFolderIds.length];
         for (int i = 0; i < rootFolderIds.length; i++) {
@@ -154,7 +154,7 @@ public class MultiThreadedObjectGenerato
 
     public static ObjectGeneratorRunner prepareForCreateDocument(CmisBinding provider, String repoId,
             String documentType, int contentSizeInKB, String rootFolderId, int noDocuments, 
-            CONTENT_KIND contentKind, boolean doCleanup) {
+            ContentKind contentKind, boolean doCleanup) {
 
         ObjectGenerator objGen = createObjectGenerator(provider, repoId, 0, 0, 0, documentType, null, contentSizeInKB,
                 rootFolderId, contentKind, doCleanup);
@@ -167,7 +167,7 @@ public class MultiThreadedObjectGenerato
 
     public static ObjectGeneratorRunner[] prepareForCreateDocumentMT(int threadCount, CmisBinding binding,
             String repoId, String documentType, int contentSizeInKB, String rootFolderId, int noDocuments,
-            CONTENT_KIND contentKind, boolean doCleanup) {
+            ContentKind contentKind, boolean doCleanup) {
 
         ObjectGeneratorRunner[] runners = new ObjectGeneratorRunner[threadCount];
         for (int i = 0; i < threadCount; i++) {

Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java?rev=1515969&r1=1515968&r2=1515969&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/main/java/org/apache/chemistry/opencmis/util/repository/ObjectGenerator.java Tue Aug 20 20:58:05 2013
@@ -21,6 +21,7 @@ package org.apache.chemistry.opencmis.ut
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -63,6 +64,7 @@ import org.slf4j.LoggerFactory;
  */
 public class ObjectGenerator {
 
+    private static final int KILO = 1024;
     private static final Logger LOG = LoggerFactory.getLogger(ObjectGenerator.class);
     private final BindingsObjectFactory fFactory;
     NavigationService fNavSvc;
@@ -81,7 +83,7 @@ public class ObjectGenerator {
      * supported kinds of content
      *
      */
-    public enum CONTENT_KIND {StaticText, LoremIpsumText, LoremIpsumHtml, ImageFractalJpeg};
+    public enum ContentKind {STATIC_TEXT, LOREM_IPSUM_TEXT, LOREM_IPSUM_HTML, IMAGE_FRACTAL_JPEG};
 
     /**
      * Indicates if / how many documents are created in each folder
@@ -130,7 +132,7 @@ public class ObjectGenerator {
     /**
      * Kind of content to create
      */
-    private CONTENT_KIND fContentKind;
+    private ContentKind fContentKind;
     
 
     private static final String NAMEPROPVALPREFIXDOC = "My_Document-";
@@ -150,7 +152,7 @@ public class ObjectGenerator {
     private FractalGenerator fractalGenerator = null;
 
     public ObjectGenerator(BindingsObjectFactory factory, NavigationService navSvc, ObjectService objSvc,
-            RepositoryService repSvc, String repositoryId, CONTENT_KIND contentKind) {
+            RepositoryService repSvc, String repositoryId, ContentKind contentKind) {
         super();
         fFactory = factory;
         fNavSvc = navSvc;
@@ -197,11 +199,11 @@ public class ObjectGenerator {
         fContentSizeInK = sizeInK;
     }
     
-    public CONTENT_KIND getContentKind() {
+    public ContentKind getContentKind() {
         return fContentKind;
     }
     
-    public void setLoreIpsumGenerator(CONTENT_KIND contentKind) {
+    public void setLoreIpsumGenerator(ContentKind contentKind) {
         fContentKind = contentKind;
     }
 
@@ -373,7 +375,8 @@ public class ObjectGenerator {
     }
 
     public void resetCounters() {
-        fDocumentsInTotalCount = fFoldersInTotalCount = 0;
+        fDocumentsInTotalCount = 0;
+        fFoldersInTotalCount = 0;
     }
 
     public void printTimings() {
@@ -453,16 +456,16 @@ public class ObjectGenerator {
         
         if (fContentSizeInK > 0) {
             switch (fContentKind) {
-            case StaticText:
+            case STATIC_TEXT:
                 contentStream = createContentStaticText();
                 break;
-            case LoremIpsumText:
+            case LOREM_IPSUM_TEXT:
                 contentStream = createContentLoremIpsumText();
                 break;
-            case LoremIpsumHtml:
+            case LOREM_IPSUM_HTML:
                 contentStream = createContentLoremIpsumHtml();
                 break;
-            case ImageFractalJpeg:
+            case IMAGE_FRACTAL_JPEG:
                 contentStream = createContentFractalimageJpeg();
                 break;
             }
@@ -477,7 +480,7 @@ public class ObjectGenerator {
         }
 
         if (null == id) {
-            throw new RuntimeException("createDocument failed.");
+            LOG.error("createDocument failed.");
         }
         ++fDocumentsInTotalCount;
         return id;
@@ -514,11 +517,15 @@ public class ObjectGenerator {
         ContentStreamImpl content = new ContentStreamImpl();
         content.setFileName("data.html");
         content.setMimeType("text/html");
-        int len = fContentSizeInK * 1024; // size of document in K
+        int len = fContentSizeInK * KILO; // size of document in K
         
         LoremIpsum ipsum = new LoremIpsum();
         String text = ipsum.generateParagraphsFullHtml(len, true);
-        content.setStream(new ByteArrayInputStream(text.getBytes()));
+        try {
+            content.setStream(new ByteArrayInputStream(text.getBytes("UTF-8")));
+        } catch (UnsupportedEncodingException e) {
+            LOG.error("Unsupported Encoding Exception", e);
+        }
         return content;
     }
 
@@ -558,8 +565,9 @@ public class ObjectGenerator {
     }
 
     public ContentStream createContentFractalimageJpeg() {
-        if (null == fractalGenerator)
+        if (null == fractalGenerator) {
             fractalGenerator = new FractalGenerator();
+        }
 
         ContentStreamImpl content = null;