[exo-jcr-commits] exo-jcr SVN: r3030 - in core/branches/2.3.x/exo.core.component.document: src/main/java/org/exoplatform/services/document/impl and 3 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Tue Aug 31 10:21:31 EDT 2010


Author: nzamosenchuk
Date: 2010-08-31 10:21:30 -0400 (Tue, 31 Aug 2010)
New Revision: 3030

Added:
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java
Modified:
   core/branches/2.3.x/exo.core.component.document/pom.xml
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSExcelDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSOutlookDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSWordDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PDFDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PPTDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/main/resources/conf/portal/configuration.xml
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestHtmlDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSOutlookDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSWordDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestOpenOfficeDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPDFDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPPTDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestTextPlainDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java
   core/branches/2.3.x/exo.core.component.document/src/test/resources/test.doc
   core/branches/2.3.x/exo.core.component.document/src/test/resources/test.docx
   core/branches/2.3.x/exo.core.component.document/src/test/resources/test.odt
   core/branches/2.3.x/exo.core.component.document/src/test/resources/test.ppt
   core/branches/2.3.x/exo.core.component.document/src/test/resources/test.pptx
   core/branches/2.3.x/exo.core.component.document/src/test/resources/test.xls
   core/branches/2.3.x/exo.core.component.document/src/test/resources/test.xlsx
Log:
EXOJCR-886: updating tests and DocumentReaders according to remarks. Implementing property extraction from OOXML (MS 2007) formats.

Modified: core/branches/2.3.x/exo.core.component.document/pom.xml
===================================================================
--- core/branches/2.3.x/exo.core.component.document/pom.xml	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/pom.xml	2010-08-31 14:21:30 UTC (rev 3030)
@@ -1,24 +1,16 @@
-<!--
 
-    Copyright (C) 2009 eXo Platform SAS.
+   <!--
 
-    This is free software; you can redistribute it and/or modify it
-    under the terms of the GNU Lesser General Public License as
-    published by the Free Software Foundation; either version 2.1 of
-    the License, or (at your option) any later version.
-
-    This software is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this software; if not, write to the Free
-    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-    02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+      Copyright (C) 2009 eXo Platform SAS. This is free software; you can redistribute it and/or modify it under the
+      terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of
+      the License, or (at your option) any later version. This software is distributed in the hope that it will be
+      useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+      PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU
+      Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51
+      Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
       <groupId>org.exoplatform.core</groupId>
@@ -116,5 +108,16 @@
             </includes>
          </testResource>
       </testResources>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+               <includes>
+                  <include>org/exoplatform/services/document/**/Test*.java</include>
+               </includes>
+            </configuration>
+         </plugin>
+      </plugins>
    </build>
 </project>

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/HTMLDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,7 +18,6 @@
  */
 package org.exoplatform.services.document.impl;
 
-import org.exoplatform.container.xml.InitParams;
 import org.exoplatform.services.document.DocumentReadException;
 import org.htmlparser.Parser;
 import org.htmlparser.beans.StringBean;
@@ -43,7 +42,7 @@
     * 
     * @param params the container parameters.
     */
-   public HTMLDocumentReader(InitParams params)
+   public HTMLDocumentReader()
    {
    }
 
@@ -54,7 +53,7 @@
     */
    public String[] getMimeTypes()
    {
-      return new String[]{"text/html","application/x-groovy+html"};
+      return new String[]{"text/html", "application/x-groovy+html"};
    }
 
    /**
@@ -77,7 +76,9 @@
          int len;
          ByteArrayOutputStream bos = new ByteArrayOutputStream();
          while ((len = is.read(buffer)) > 0)
+         {
             bos.write(buffer, 0, len);
+         }
          bos.close();
 
          String html = new String(bos.toByteArray());

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSExcelDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSExcelDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSExcelDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -42,8 +42,8 @@
 public class MSExcelDocumentReader extends BaseDocumentReader
 {
 
-   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
-
+   private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSSZ";
+   
    /**
     * Get the application/excel mime type.
     * 
@@ -68,9 +68,16 @@
       }
 
       StringBuilder builder = new StringBuilder("");
+      
+      SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
 
       try
       {
+         if (is.available() == 0)
+         {
+            return "";
+         }
+         
          HSSFWorkbook wb;
          try
          {
@@ -78,7 +85,7 @@
          }
          catch (IOException e)
          {
-            return builder.toString();
+            throw new DocumentReadException("Can't open spreadsheet.", e);
          }
          for (int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++)
          {
@@ -104,7 +111,7 @@
                                  if (isCellDateFormatted(cell))
                                  {
                                     Date date = HSSFDateUtil.getJavaDate(d);
-                                    String cellText = this.DATE_FORMAT.format(date);
+                                    String cellText = dateFormat.format(date);
                                     builder.append(cellText).append(" ");
                                  }
                                  else

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSOutlookDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSOutlookDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSOutlookDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -61,6 +61,11 @@
       }
       try
       {
+         if (is.available() == 0)
+         {
+            return "";
+         }
+         
          MAPIMessage message;
          try
          {
@@ -68,12 +73,12 @@
          }
          catch (IOException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open message.", e);
          }
-         StringBuffer buffer = new StringBuffer();
+         StringBuilder builder = new StringBuilder();
          try
          {
-            buffer.append(message.getDisplayFrom()).append('\n');
+            builder.append(message.getDisplayFrom()).append('\n');
          }
          catch (ChunkNotFoundException e)
          {
@@ -81,7 +86,7 @@
          }
          try
          {
-            buffer.append(message.getDisplayTo()).append('\n');
+            builder.append(message.getDisplayTo()).append('\n');
          }
          catch (ChunkNotFoundException e)
          {
@@ -89,7 +94,7 @@
          }
          try
          {
-            buffer.append(message.getSubject()).append('\n');
+            builder.append(message.getSubject()).append('\n');
          }
          catch (ChunkNotFoundException e)
          {
@@ -97,13 +102,13 @@
          }
          try
          {
-            buffer.append(message.getTextBody());
+            builder.append(message.getTextBody());
          }
          catch (ChunkNotFoundException e)
          {
             // "textBody" is empty
          }
-         return buffer.toString();
+         return builder.toString();
 
       }
       finally

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSWordDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSWordDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSWordDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -61,6 +61,11 @@
       String text = "";
       try
       {
+         if (is.available() == 0)
+         {
+            return "";
+         }
+         
          HWPFDocument doc;
          try
          {
@@ -68,7 +73,7 @@
          }
          catch (IOException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open document.", e);
          }
 
          Range range = doc.getRange();
@@ -77,6 +82,7 @@
       finally
       {
          if (is != null)
+         {
             try
             {
                is.close();
@@ -84,6 +90,7 @@
             catch (IOException e)
             {
             }
+         }
       }
       return text.trim();
    }

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXExcelDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,8 +18,11 @@
  */
 package org.exoplatform.services.document.impl;
 
+import org.apache.poi.POIXMLDocument;
+import org.apache.poi.POIXMLPropertiesTextExtractor;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
+import org.apache.poi.openxml4j.opc.OPCPackage;
 import org.apache.poi.xssf.usermodel.XSSFCell;
 import org.apache.poi.xssf.usermodel.XSSFCellStyle;
 import org.apache.poi.xssf.usermodel.XSSFRow;
@@ -44,9 +47,8 @@
  */
 public class MSXExcelDocumentReader extends BaseDocumentReader
 {
+   private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSSZ";
 
-   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
-
    /**
     * @see org.exoplatform.services.document.DocumentReader#getMimeTypes()
     */
@@ -69,17 +71,25 @@
       }
 
       StringBuilder builder = new StringBuilder("");
+      SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
 
       try
       {
+         if (is.available() == 0)
+         {
+            return "";
+         }
+
          XSSFWorkbook wb;
          try
          {
             wb = new XSSFWorkbook(is);
+            OPCPackage pkg;
+
          }
          catch (IOException e)
          {
-            return builder.toString();
+            throw new DocumentReadException("Can't open spreadsheet.", e);
          }
          catch (OpenXML4JRuntimeException e)
          {
@@ -109,7 +119,7 @@
                                  if (isCellDateFormatted(cell))
                                  {
                                     Date date = HSSFDateUtil.getJavaDate(d);
-                                    String cellText = this.DATE_FORMAT.format(date);
+                                    String cellText = dateFormat.format(date);
                                     builder.append(cellText).append(" ");
                                  }
                                  else
@@ -171,7 +181,7 @@
    public Properties getProperties(InputStream is) throws IOException, DocumentReadException
    {
       POIPropertiesReader reader = new POIPropertiesReader();
-      reader.readDCProperties(is);
+      reader.readDCProperties(new XSSFWorkbook(is));
       return reader.getProperties();
    }
 

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXPPTDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,9 +18,11 @@
  */
 package org.exoplatform.services.document.impl;
 
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
 import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException;
 import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.xslf.XSLFSlideShow;
 import org.apache.poi.xslf.extractor.XSLFPowerPointExtractor;
 import org.apache.xmlbeans.XmlException;
 import org.exoplatform.services.document.DocumentReadException;
@@ -62,6 +64,11 @@
       }
       try
       {
+         if (is.available() == 0)
+         {
+            return "";
+         }
+         
          XSLFPowerPointExtractor ppe;
          try
          {
@@ -69,19 +76,19 @@
          }
          catch (IOException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open presentation.", e);
          }
          catch (OpenXML4JRuntimeException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open presentation.", e);
          }
          catch (OpenXML4JException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open presentation.", e);
          }
          catch (XmlException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open presentation.", e);
          }
          return ppe.getText(true, true);
       }
@@ -115,7 +122,22 @@
    public Properties getProperties(InputStream is) throws IOException, DocumentReadException
    {
       POIPropertiesReader reader = new POIPropertiesReader();
-      reader.readDCProperties(is);
+      try
+      {
+         reader.readDCProperties(new XSLFSlideShow(OPCPackage.open(is)));
+      }
+      catch (InvalidFormatException e)
+      {
+         throw new DocumentReadException("Can't read properties from OOXML document", e);
+      }
+      catch (OpenXML4JException e)
+      {
+         throw new DocumentReadException("Can't read properties from OOXML document", e);
+      }
+      catch (XmlException e)
+      {
+         throw new DocumentReadException("Can't read properties from OOXML document", e);
+      }
       return reader.getProperties();
    }
 

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/MSXWordDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -62,6 +62,11 @@
       String text = "";
       try
       {
+         if (is.available() == 0)
+         {
+            return "";
+         }
+         
          XWPFDocument doc;
          try
          {
@@ -69,11 +74,11 @@
          }
          catch (IOException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open message.", e);
          }
          catch (OpenXML4JRuntimeException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open message.", e);
          }
 
          XWPFWordExtractor extractor = new XWPFWordExtractor(doc);
@@ -110,7 +115,7 @@
    public Properties getProperties(InputStream is) throws IOException, DocumentReadException
    {
       POIPropertiesReader reader = new POIPropertiesReader();
-      reader.readDCProperties(is);
+      reader.readDCProperties(new XWPFDocument(is));
       return reader.getProperties();
    }
 

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PDFDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PDFDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PDFDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -21,13 +21,13 @@
 import com.lowagie.text.pdf.PdfDate;
 import com.lowagie.text.pdf.PdfReader;
 
+import org.apache.pdfbox.pdmodel.PDDocument;
+import org.apache.pdfbox.util.PDFTextStripper;
 import org.exoplatform.commons.utils.ISO8601;
 import org.exoplatform.services.document.DCMetaData;
 import org.exoplatform.services.document.DocumentReadException;
 import org.exoplatform.services.log.ExoLogger;
 import org.exoplatform.services.log.Log;
-import org.apache.pdfbox.pdmodel.PDDocument;
-import org.apache.pdfbox.util.PDFTextStripper;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -37,6 +37,9 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
 import java.text.ParseException;
 import java.util.Calendar;
 import java.util.HashMap;
@@ -74,53 +77,81 @@
     * @param is an input stream with .pdf file content.
     * @return The string only with text from file content.
     */
-   public String getContentAsText(InputStream is) throws IOException, DocumentReadException
+   public String getContentAsText(final InputStream is) throws IOException, DocumentReadException
    {
-      if (is == null)
+
+      try
       {
-         throw new NullPointerException("InputStream is null.");
+         return (String)AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
+         {
+            public Object run() throws Exception
+            {
+               if (is == null)
+               {
+                  throw new NullPointerException("InputStream is null.");
+               }
+               PDDocument pdDocument = null;
+               StringWriter sw = new StringWriter();
+               try
+               {
+                  if (is.available() == 0)
+                     return "";
+
+                  try
+                  {
+                     pdDocument = PDDocument.load(is);
+                  }
+                  catch (IOException e)
+                  {
+                     throw new DocumentReadException("Can not load PDF document.", e);
+                  }
+
+                  PDFTextStripper stripper = new PDFTextStripper();
+                  stripper.setStartPage(1);
+                  stripper.setEndPage(Integer.MAX_VALUE);
+                  stripper.writeText(pdDocument, sw);
+               }
+               finally
+               {
+                  if (pdDocument != null)
+                     try
+                     {
+                        pdDocument.close();
+                     }
+                     catch (IOException e)
+                     {
+                     }
+                  if (is != null)
+                     try
+                     {
+                        is.close();
+                     }
+                     catch (IOException e)
+                     {
+                     }
+               }
+               return sw.toString();
+            }
+         });
+
       }
-      PDDocument pdDocument = null;
-      StringWriter sw = new StringWriter();
-      try
+      catch (PrivilegedActionException pae)
       {
-         if (is.available() == 0)
-            return "";
-         
-         try
+         Throwable cause = pae.getCause();
+         if (cause instanceof IOException)
          {
-            pdDocument = PDDocument.load(is);
+            throw (IOException)cause;
          }
-         catch (IOException e)
+         else if (cause instanceof RuntimeException)
          {
-            throw new DocumentReadException("Can not load PDF document.", e);
+            throw (RuntimeException)cause;
          }
+         else
+         {
+            throw new RuntimeException(cause);
+         }
+      }
 
-         PDFTextStripper stripper = new PDFTextStripper();
-         stripper.setStartPage(1);
-         stripper.setEndPage(Integer.MAX_VALUE);
-         stripper.writeText(pdDocument, sw);
-      }
-      finally
-      {
-         if (pdDocument != null)
-            try
-            {
-               pdDocument.close();
-            }
-            catch (IOException e)
-            {
-            }
-         if (is != null)
-            try
-            {
-               is.close();
-            }
-            catch (IOException e)
-            {
-            }
-      }
-      return sw.toString();
    }
 
    public String getContentAsText(InputStream is, String encoding) throws IOException, DocumentReadException

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/POIPropertiesReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,11 +18,17 @@
  */
 package org.exoplatform.services.document.impl;
 
+import org.apache.poi.POIXMLDocument;
+import org.apache.poi.POIXMLPropertiesTextExtractor;
+import org.apache.poi.POIXMLProperties.CoreProperties;
+import org.apache.poi.POIXMLProperties.CustomProperties;
+import org.apache.poi.POIXMLProperties.ExtendedProperties;
 import org.apache.poi.hpsf.MarkUnsupportedException;
 import org.apache.poi.hpsf.NoPropertySetStreamException;
 import org.apache.poi.hpsf.PropertySet;
 import org.apache.poi.hpsf.PropertySetFactory;
 import org.apache.poi.hpsf.SummaryInformation;
+import org.apache.poi.openxml4j.util.Nullable;
 import org.apache.poi.poifs.eventfilesystem.POIFSReader;
 import org.apache.poi.poifs.eventfilesystem.POIFSReaderEvent;
 import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
@@ -51,6 +57,14 @@
       return props;
    }
 
+   /**
+    * Metadata extraction from OLE2 documents (legacy MS office file formats)
+    * 
+    * @param is
+    * @return
+    * @throws IOException
+    * @throws DocumentReadException
+    */
    public Properties readDCProperties(InputStream is) throws IOException, DocumentReadException
    {
       if (is == null)
@@ -89,23 +103,39 @@
                   SummaryInformation si = (SummaryInformation)ps;
 
                   if (si.getLastAuthor() != null && si.getLastAuthor().length() > 0)
+                  {
                      props.put(DCMetaData.CONTRIBUTOR, si.getLastAuthor());
+                  }
                   if (si.getComments() != null && si.getComments().length() > 0)
+                  {
                      props.put(DCMetaData.DESCRIPTION, si.getComments());
+                  }
                   if (si.getCreateDateTime() != null)
+                  {
                      props.put(DCMetaData.DATE, si.getCreateDateTime());
+                  }
                   if (si.getAuthor() != null && si.getAuthor().length() > 0)
+                  {
                      props.put(DCMetaData.CREATOR, si.getAuthor());
+                  }
                   if (si.getKeywords() != null && si.getKeywords().length() > 0)
+                  {
                      props.put(DCMetaData.SUBJECT, si.getKeywords());
+                  }
                   if (si.getLastSaveDateTime() != null)
+                  {
                      props.put(DCMetaData.DATE, si.getLastSaveDateTime());
+                  }
                   // if(docInfo.getProducer() != null)
                   // props.put(DCMetaData.PUBLISHER, docInfo.getProducer());
                   if (si.getSubject() != null && si.getSubject().length() > 0)
+                  {
                      props.put(DCMetaData.SUBJECT, si.getSubject());
+                  }
                   if (si.getTitle() != null && si.getTitle().length() > 0)
+                  {
                      props.put(DCMetaData.TITLE, si.getTitle());
+                  }
 
                }
             }
@@ -163,4 +193,56 @@
       return props;
    }
 
+   /**
+    * Metadata extraction from ooxml documents (MS 2007 office file formats)
+    * 
+    * @param document
+    * @return
+    * @throws IOException
+    * @throws DocumentReadException
+    */
+   public Properties readDCProperties(POIXMLDocument document) throws IOException, DocumentReadException
+   {
+
+      POIXMLPropertiesTextExtractor extractor = new POIXMLPropertiesTextExtractor(document);
+
+      CoreProperties coreProperties = extractor.getCoreProperties();
+
+      Nullable<String> lastModifiedBy = coreProperties.getUnderlyingProperties().getLastModifiedByProperty();
+      if (lastModifiedBy != null && lastModifiedBy.getValue() != null && lastModifiedBy.getValue().length() > 0)
+      {
+         props.put(DCMetaData.CONTRIBUTOR, lastModifiedBy.getValue());
+      }
+      if (coreProperties.getDescription() != null && coreProperties.getDescription().length() > 0)
+      {
+         props.put(DCMetaData.DESCRIPTION, coreProperties.getDescription());
+      }
+      if (coreProperties.getCreated() != null)
+      {
+         props.put(DCMetaData.DATE, coreProperties.getCreated());
+      }
+      if (coreProperties.getCreator() != null && coreProperties.getCreator().length() > 0)
+      {
+         props.put(DCMetaData.CREATOR, coreProperties.getCreator());
+      }
+      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
+      {
+         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
+      }
+      if (coreProperties.getModified() != null)
+      {
+         props.put(DCMetaData.DATE, coreProperties.getModified());
+      }
+      if (coreProperties.getSubject() != null && coreProperties.getSubject().length() > 0)
+      {
+         props.put(DCMetaData.SUBJECT, coreProperties.getSubject());
+      }
+      if (coreProperties.getTitle() != null && coreProperties.getTitle().length() > 0)
+      {
+         props.put(DCMetaData.TITLE, coreProperties.getTitle());
+      }
+
+      return props;
+   }
+
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PPTDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PPTDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/java/org/exoplatform/services/document/impl/PPTDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -60,6 +60,12 @@
       }
       try
       {
+         
+         if (is.available() == 0)
+         {
+            return "";
+         }
+         
          PowerPointExtractor ppe;
          try
          {
@@ -67,13 +73,14 @@
          }
          catch (IOException e)
          {
-            return "";
+            throw new DocumentReadException("Can't open presentation.", e);
          }
          return ppe.getText(true, true);
       }
       finally
       {
          if (is != null)
+         {
             try
             {
                is.close();
@@ -81,6 +88,7 @@
             catch (IOException e)
             {
             }
+         }
       }
    }
 

Modified: core/branches/2.3.x/exo.core.component.document/src/main/resources/conf/portal/configuration.xml
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/main/resources/conf/portal/configuration.xml	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/main/resources/conf/portal/configuration.xml	2010-08-31 14:21:30 UTC (rev 3030)
@@ -1,25 +1,16 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
+   <!--
 
-    Copyright (C) 2009 eXo Platform SAS.
-
-    This is free software; you can redistribute it and/or modify it
-    under the terms of the GNU Lesser General Public License as
-    published by the Free Software Foundation; either version 2.1 of
-    the License, or (at your option) any later version.
-
-    This software is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this software; if not, write to the Free
-    Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-    02110-1301 USA, or see the FSF site: http://www.fsf.org.
-
--->
-<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
+      Copyright (C) 2009 eXo Platform SAS. This is free software; you can redistribute it and/or modify it under the
+      terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of
+      the License, or (at your option) any later version. This software is distributed in the hope that it will be
+      useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+      PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU
+      Lesser General Public License along with this software; if not, write to the Free Software Foundation, Inc., 51
+      Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+   -->
+<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd http://www.exoplaform.org/xml/ns/kernel_1_0.xsd"
    xmlns="http://www.exoplaform.org/xml/ns/kernel_1_0.xsd">
 
    <component>
@@ -31,13 +22,6 @@
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.PDFDocumentReader</type>
             <description>to read the pdf inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.types</name>
-                  <description>description</description>
-                  <value>application/pdf</value>
-               </values-param>
-            </init-params>
          </component-plugin>
 
          <component-plugin>
@@ -45,13 +29,6 @@
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.MSWordDocumentReader</type>
             <description>to read the ms word inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesMSWord</name>
-                  <description>description</description>
-                  <value>application/msword</value>
-               </values-param>
-            </init-params>
          </component-plugin>
 
          <component-plugin>
@@ -59,41 +36,20 @@
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.MSXWordDocumentReader</type>
             <description>to read the ms word inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesMSXWord</name>
-                  <description>description</description>
-                  <value>application/msword</value>
-               </values-param>
-            </init-params>
-         </component-plugin>
+         </component-plugin>
 
          <component-plugin>
             <name>document.readerMSExcel</name>
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.MSExcelDocumentReader</type>
             <description>to read the ms excel inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesMSExcel</name>
-                  <description>description</description>
-                  <value>application/excel</value>
-               </values-param>
-            </init-params>
-         </component-plugin>
+         </component-plugin>
 
          <component-plugin>
             <name>document.readerMSXExcel</name>
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.MSXExcelDocumentReader</type>
             <description>to read the ms excel inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesMSXExcel</name>
-                  <description>description</description>
-                  <value>application/excel</value>
-               </values-param>
-            </init-params>
          </component-plugin>
 
          <component-plugin>
@@ -101,13 +57,6 @@
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.MSOutlookDocumentReader</type>
             <description>to read the ms outlook inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesMSOutlook</name>
-                  <description>description</description>
-                  <value>application/vnd.ms-outlook</value>
-               </values-param>
-            </init-params>
          </component-plugin>
 
          <component-plugin>
@@ -115,27 +64,13 @@
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.PPTDocumentReader</type>
             <description>to read the ms ppt inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesPPT</name>
-                  <description>description</description>
-                  <value>application/ppt</value>
-               </values-param>
-            </init-params>
-         </component-plugin>
+         </component-plugin>
 
          <component-plugin>
             <name>MSXPPTdocument.reader</name>
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.MSXPPTDocumentReader</type>
             <description>to read the ms pptx inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesPPTX</name>
-                  <description>description</description>
-                  <value>application/ppt</value>
-               </values-param>
-            </init-params>
          </component-plugin>
 
          <component-plugin>
@@ -143,13 +78,6 @@
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.HTMLDocumentReader</type>
             <description>to read the html inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesHTML</name>
-                  <description>description</description>
-                  <value>text/html</value>
-               </values-param>
-            </init-params>
          </component-plugin>
 
          <component-plugin>
@@ -157,13 +85,6 @@
             <set-method>addDocumentReader</set-method>
             <type>org.exoplatform.services.document.impl.XMLDocumentReader</type>
             <description>to read the xml inputstream</description>
-            <init-params>
-               <values-param>
-                  <name>document.known.typesXML</name>
-                  <description>description</description>
-                  <value>text/xml</value>
-               </values-param>
-            </init-params>
          </component-plugin>
 
          <component-plugin>
@@ -172,16 +93,10 @@
             <type>org.exoplatform.services.document.impl.TextPlainDocumentReader</type>
             <description>to read the plain text inputstream</description>
             <init-params>
-               <values-param>
-                  <name>document.known.typesTextPlain</name>
-                  <description>description</description>
-                  <value>text/plain</value>
-               </values-param>
-               <!-- values-param>
-                  <name>defaultEncoding</name>
-                  <description>description</description>
-                  <value>UTF-8</value>
-               </values-param -->
+               <!--
+                  values-param> <name>defaultEncoding</name> <description>description</description> <value>UTF-8</value>
+                  </values-param
+               -->
             </init-params>
          </component-plugin>
 

Added: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java	                        (rev 0)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2003-2010 eXo Platform SAS.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see<http://www.gnu.org/licenses/>.
+ */
+package org.exoplatform.services.document.test;
+
+import org.exoplatform.commons.utils.MimeTypeResolver;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.test.BasicTestCase;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Created by The eXo Platform SAS.
+ * 
+ * <br/>Date: 
+ *
+ * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a> 
+ * @version $Id: BaseStandaloneTest.java 111 2008-11-11 11:11:11Z serg $
+ */
+public class BaseStandaloneTest extends BasicTestCase
+{
+
+   public PortalContainer pcontainer;
+
+   protected MimeTypeResolver mimetypeResolver = new MimeTypeResolver();
+
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      pcontainer = PortalContainer.getInstance();
+   }
+
+   public Object getComponentInstanceOfType(Class componentType)
+   {
+      return pcontainer.getComponentInstanceOfType(componentType);
+   }
+
+   /**
+    * Its a wrapper to cheat security.
+    */
+   public File createTempFile(String prefix, String suffix) throws IOException
+   {
+      return File.createTempFile(prefix, suffix);
+   }
+
+   /**
+    * Its a wrapper to cheat security.
+    */
+   public boolean createNewFile(File f) throws IOException
+   {
+      return f.createNewFile();
+   }
+
+   /**
+    * Its a wrapper to cheat security.
+    */
+   public InputStream getInputStream(File f) throws IOException
+   {
+      return new FileInputStream(f);
+   }
+
+   /**
+    * Its a wrapper to cheat security.
+    */
+   public boolean deleteFile(File f) throws IOException
+   {
+      return f.delete();
+   }
+
+   public String normalizeWhitespaces(String str)
+   {
+      str = str.trim();
+      str = str.replaceAll("\\s+", " ");
+      return str;
+   }
+
+}


Property changes on: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/BaseStandaloneTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestDocumentReadersIncomVals.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -32,10 +32,8 @@
 import org.exoplatform.services.document.impl.PPTDocumentReader;
 import org.exoplatform.services.document.impl.TextPlainDocumentReader;
 import org.exoplatform.services.document.impl.XMLDocumentReader;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.File;
-import java.io.FileInputStream;
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
@@ -48,15 +46,14 @@
  * @author <a href="karpenko.sergiy at gmail.com">Karpenko Sergiy</a> 
  * @version $Id: TestDocumentReadersIncomVals.java 111 2008-11-11 11:11:11Z serg $
  */
-public class TestDocumentReadersIncomVals extends BasicTestCase
+public class TestDocumentReadersIncomVals extends BaseStandaloneTest
 {
-
    List<DocumentReader> serviceList;
 
    public TestDocumentReadersIncomVals()
    {
       serviceList = new ArrayList<DocumentReader>();
-      serviceList.add(new HTMLDocumentReader(null));
+      serviceList.add(new HTMLDocumentReader());
       serviceList.add(new MSExcelDocumentReader());
       serviceList.add(new MSXExcelDocumentReader());
       serviceList.add(new MSOutlookDocumentReader());
@@ -105,13 +102,13 @@
    {
       StringBuilder sb = new StringBuilder();
 
-      File f = File.createTempFile("dfd", "suf");
-      f.createNewFile();
+      File f = createTempFile("dfd", "suf");
+      createNewFile(f);
       InputStream in;
 
       for (int i = 0; i < serviceList.size(); i++)
       {
-         in = new FileInputStream(f);
+         in = getInputStream(f);
          try
          {
             assertEquals("", serviceList.get(i).getContentAsText(in));
@@ -130,6 +127,6 @@
          System.out.println(sb.toString());
       }
 
-      f.delete();
+      deleteFile(f);
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestHtmlDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestHtmlDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestHtmlDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,11 +18,8 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.commons.utils.MimeTypeResolver;
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReader;
 import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.InputStream;
 
@@ -33,24 +30,30 @@
  * @version $Id: $
  */
 
-public class TestHtmlDocumentReader extends BasicTestCase
+public class TestHtmlDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
+   DocumentReaderService service;
 
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestHtmlDocumentReader.class.getResourceAsStream("/test.html");
-      MimeTypeResolver mimetypeResolver = new MimeTypeResolver();
-      String mimeType = mimetypeResolver.getMimeType("test.html");
+      try
+      {
+         String mimeType = mimetypeResolver.getMimeType("test.html");
 
-      DocumentReader dr = service_.getDocumentReader(mimeType);
-      String text = dr.getContentAsText(is);
-      // TODO text is too huge, need small test file
+         DocumentReader dr = service.getDocumentReader(mimeType);
+         String text = dr.getContentAsText(is);
+         assertTrue(text.contains("This is the third maintenance release of the redesigned 2.0"));
+      }
+      finally
+      {
+         is.close();
+      }
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSExcelDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,11 +18,11 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 
 /**
  * Created by The eXo Platform SAS Author : Sergey Karpenko
@@ -31,48 +31,92 @@
  * @version $Id: $
  */
 
-public class TestMSExcelDocumentReader extends BasicTestCase
+public class TestMSExcelDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
-
+   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
+   
+   DocumentReaderService service;
+   
+   @Override
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestMSExcelDocumentReader.class.getResourceAsStream("/test.xls");
-      String text = service_.getDocumentReader("application/excel").getContentAsText(is);
-      System.out.println(" text [" + text + "]");
-      /*
-       * String etalon =
-       * "Ronaldo Eric Cantona Kaka Ronaldonho ID Group Functionality Executor Begin End Tested "
-       * +
-       * "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
-       * +"XNNL XNNL XNNL_76 NamPH TRUE 1984-12-10 00:00:00.000+0200 No "
-       * +"XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
-       * +
-       * "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
-       * +"XNNL XNNL LASUCO_PROJECT NamPH Tested "+
-       * "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
-       * +
-       * "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
-       * ; System.out.println(" etalon ["+etalon+"]");
-       * assertEquals("String length is incorect",etalon.length(),text.length());
-       * assertEquals("Wrong string returned",etalon ,text );
-       */
+      try
+      {
+         String text = service.getDocumentReader("application/excel").getContentAsText(is);
+         String expected =
+            "Ronaldo Eric Cantona Kaka Ronaldonho " + "ID Group Functionality Executor Begin End Tested "
+               + "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH "
+               + getDate(2005, 2, 2)
+               + " "
+               + getDate(2005, 10, 2)
+               + " Tested "
+               + "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 "
+               + getDate(2005, 10, 1)
+               + " Tested "
+               + "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH "
+               + getDate(2005, 10, 12)
+               + " "
+               + getDate(2005, 10, 2)
+               + " Tested "
+               + "XNNL XNNL XNNL_76 NamPH TRUE() "
+               + getDate(1984, 12, 10)
+               + " No "
+               + "XNNL XNNL XNNL_CREATE_REAP NamPH none "
+               + getDate(2005, 10, 3)
+               + " No "
+               + "XNNL XNNL XNNL_SCALE NamPH "
+               + getDate(1984, 12, 10)
+               + " "
+               + getDate(2005, 10, 5)
+               + " Tested "
+               + "XNNL XNNL LASUCO_PROJECT NamPH "
+               + getDate(2005, 10, 5)
+               + " "
+               + getDate(2005, 10, 6)
+               + " No "
+               + "XNNL XNNL LASUCO_PROJECT NamPH Tested "
+               + "XNNL XNNL XNNL_BRANCH NamPH "
+               + getDate(2005, 12, 12)
+               + " "
+               + getDate(2005, 6, 10)
+               + " Tested "
+               + "XNNL XNNL XNNL_SUGAR_RACE NamPH "
+               + getDate(2005, 5, 9)
+               + " "
+               + getDate(2005, 6, 10)
+               + " No "
+               + "XNNL XNNL F_XNNL_DISTRI NamPH "
+               + getDate(2005, 5, 9)
+               + " "
+               + getDate(2005, 6, 10)
+               + " Tested "
+               + "XNNL XNNL XNNL_LASUCO_USER NamPH "
+               + getDate(2005, 9, 9)
+               + " "
+               + getDate(2005, 6, 10) + " No";
 
+         assertEquals("Wrong string returned", normalizeWhitespaces(expected), normalizeWhitespaces(text));
+      }
+      finally
+      {
+         is.close();
+      }
+
    }
+
+   public String getDate(int year, int month, int day)
+   {
+      Calendar date = Calendar.getInstance();
+      date.setTimeInMillis(0);
+      date.set(year, month - 1, day, 0, 0, 0);
+
+      return (DATE_FORMAT.format(date.getTime()));
+   }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSOutlookDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSOutlookDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSOutlookDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,7 +18,6 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReaderService;
 import org.exoplatform.test.BasicTestCase;
 
@@ -31,14 +30,14 @@
  * @version $Id: $
  */
 
-public class TestMSOutlookDocumentReader extends BasicTestCase
+public class TestMSOutlookDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
+   DocumentReaderService service;
 
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
@@ -46,9 +45,15 @@
       String name = "/test.msg";
       InputStream is = BasicTestCase.class.getResourceAsStream(name);
       assertNotNull(is);
-
-      String text = service_.getDocumentReader("application/vnd.ms-outlook").getContentAsText(is);
-      String etalon = "Goooogle\n" + "theme\n" + "Hello, this is the test outlook message.\r\n";
-      assertEquals("Wrong string returned", etalon, text);
+      try
+      {
+         String text = service.getDocumentReader("application/vnd.ms-outlook").getContentAsText(is);
+         String etalon = "Goooogle\n" + "theme\n" + "Hello, this is the test outlook message.\r\n";
+         assertEquals("Wrong string returned", etalon, text);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSWordDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSWordDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSWordDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,9 +18,7 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.InputStream;
 
@@ -31,40 +29,44 @@
  * @version $Id: $
  */
 
-public class TestMSWordDocumentReader extends BasicTestCase
+public class TestMSWordDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
+   DocumentReaderService service;
 
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsStringTemplate() throws Exception
    {
       InputStream is = TestMSWordDocumentReader.class.getResourceAsStream("/test.dot");
-      String text = service_.getDocumentReader("application/msworddot").getContentAsText(is);
-      System.out.println("text [" + text + "]");
-      String etalon = "exotest";
-      System.out.println("etalon [" + etalon + "]");
-
-      System.out.println("[" + text.length() + "] [" + etalon.length() + "]");
-      assertEquals("Wrong string returned", etalon, text);
+      try
+      {
+         String text = service.getDocumentReader("application/msworddot").getContentAsText(is);
+         String etalon = "exotest";
+         assertEquals("Wrong string returned", etalon, text);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
    public void testGetContentAsStringDoc() throws Exception
    {
       InputStream is = TestMSWordDocumentReader.class.getResourceAsStream("/test.doc");
-      String text = service_.getDocumentReader("application/msword").getContentAsText(is);
-      System.out.println("text [" + text + "]");
+      try
+      {
+         String text = service.getDocumentReader("application/msword").getContentAsText(is);
+         assertTrue(text
+            .contains("Before the test starts there is a directions section, which takes a few minutes to read"));
 
-      /*
-       * String etalon = "Hello.\n" +"This is the test document 12345\n"
-       * +"Table\n" +"Title One Two\n" +"Hello_Title Hello_One Hello_Two\n";
-       * System.out.println("etalon ["+etalon+"]");
-       * System.out.println("["+text.length()+"] ["+etalon.length()+"]");
-       * assertEquals("Wrong string returned",etalon ,text );
-       */
+      }
+      finally
+      {
+         is.close();
+      }
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXExcelDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -17,12 +17,12 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.document.test;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
+import org.exoplatform.services.document.DocumentReaderService;
+
 import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
 
 /**
  * Created by The eXo Platform SAS Author : Sergey Karpenko
@@ -31,49 +31,96 @@
  * @version $Id: $
  */
 
-public class TestMSXExcelDocumentReader extends BasicTestCase
+public class TestMSXExcelDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
 
+   private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
+
+   DocumentReaderService service;
+
    @Override
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestMSXExcelDocumentReader.class.getResourceAsStream("/test.xlsx");
-      String text = service_.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet").getContentAsText(is);
-      System.out.println(" text [" + text + "]");
-      /*
-       * String etalon =
-       * "Ronaldo Eric Cantona Kaka Ronaldonho ID Group Functionality Executor Begin End Tested "
-       * +
-       * "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH 2005-02-02 00:00:00.000+0200 2005-10-02 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 2005-10-01 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH 2005-10-12 00:00:00.000+0300 2005-10-02 00:00:00.000+0300 Tested "
-       * +"XNNL XNNL XNNL_76 NamPH TRUE 1984-12-10 00:00:00.000+0200 No "
-       * +"XNNL XNNL XNNL_CREATE_REAP NamPH none 2005-10-03 00:00:00.000+0300 No "
-       * +
-       * "XNNL XNNL XNNL_SCALE NamPH 1984-12-10 00:00:00.000+0200 2005-10-05 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL LASUCO_PROJECT NamPH 2005-10-05 00:00:00.000+0300 2005-10-06 00:00:00.000+0300 No "
-       * +"XNNL XNNL LASUCO_PROJECT NamPH Tested "+
-       * "XNNL XNNL XNNL_BRANCH NamPH 2005-12-12 00:00:00.000+0200 2005-06-10 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL XNNL_SUGAR_RACE NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
-       * +
-       * "XNNL XNNL F_XNNL_DISTRI NamPH 2005-05-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 Tested "
-       * +
-       * "XNNL XNNL XNNL_LASUCO_USER NamPH 2005-09-09 00:00:00.000+0300 2005-06-10 00:00:00.000+0300 No "
-       * ; System.out.println(" etalon ["+etalon+"]");
-       * assertEquals("String length is incorect",etalon.length(),text.length());
-       * assertEquals("Wrong string returned",etalon ,text );
-       */
+      try
+      {
+         String text =
+            service.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+               .getContentAsText(is);
 
+         String expected =
+            "Ronaldo Eric Cantona Kaka Ronaldonho " + "ID Group Functionality Executor Begin End Tested "
+               + "XNNL XNNL Xay dung vung quan li nguyen lieu NamPH "
+               + getDate(2005, 2, 2)
+               + " "
+               + getDate(2005, 10, 2)
+               + " Tested "
+               + "XNNL XNNL XNNL_HAVEST NamPH 1223554.0 "
+               + getDate(2005, 10, 1)
+               + " Tested "
+               + "XNNL XNNL XNNL_PIECE_OF_GROUND NamPH "
+               + getDate(2005, 10, 12)
+               + " "
+               + getDate(2005, 10, 2)
+               + " Tested "
+               + "XNNL XNNL XNNL_76 NamPH TRUE() "
+               + getDate(1984, 12, 10)
+               + " No "
+               + "XNNL XNNL XNNL_CREATE_REAP NamPH none "
+               + getDate(2005, 10, 3)
+               + " No "
+               + "XNNL XNNL XNNL_SCALE NamPH "
+               + getDate(1984, 12, 10)
+               + " "
+               + getDate(2005, 10, 5)
+               + " Tested "
+               + "XNNL XNNL LASUCO_PROJECT NamPH "
+               + getDate(2005, 10, 5)
+               + " "
+               + getDate(2005, 10, 6)
+               + " No "
+               + "XNNL XNNL LASUCO_PROJECT NamPH Tested "
+               + "XNNL XNNL XNNL_BRANCH NamPH "
+               + getDate(2005, 12, 12)
+               + " "
+               + getDate(2005, 6, 10)
+               + " Tested "
+               + "XNNL XNNL XNNL_SUGAR_RACE NamPH "
+               + getDate(2005, 5, 9)
+               + " "
+               + getDate(2005, 6, 10)
+               + " No "
+               + "XNNL XNNL F_XNNL_DISTRI NamPH "
+               + getDate(2005, 5, 9)
+               + " "
+               + getDate(2005, 6, 10)
+               + " Tested "
+               + "XNNL XNNL XNNL_LASUCO_USER NamPH "
+               + getDate(2005, 9, 9)
+               + " "
+               + getDate(2005, 6, 10) + " No";
+
+         assertEquals("Wrong string returned", normalizeWhitespaces(expected), normalizeWhitespaces(text));
+      }
+      finally
+      {
+         is.close();
+      }
    }
+
+   public String getDate(int year, int month, int day)
+   {
+      Calendar date = Calendar.getInstance();
+      date.setTimeInMillis(0);
+      date.set(year, month - 1, day, 0, 0, 0);
+
+      return (DATE_FORMAT.format(date.getTime()));
+   }
+
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXPPTDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -17,11 +17,9 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.document.test;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
+import org.exoplatform.services.document.DocumentReaderService;
+
 import java.io.InputStream;
 
 /**
@@ -31,27 +29,34 @@
  * @version $Id: $
  */
 
-public class TestMSXPPTDocumentReader extends BasicTestCase
+public class TestMSXPPTDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
+   DocumentReaderService service;
 
    @Override
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestMSXPPTDocumentReader.class.getResourceAsStream("/test.pptx");
-      String text =
-         service_.getDocumentReader("application/vnd.openxmlformats-officedocument.presentationml.presentation")
-            .getContentAsText(is);
-      String etalon =
-         "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
-            + "Ronaldo\n" + "The natural scients universitys\n";
+      try
+      {
+         String text =
+            service.getDocumentReader("application/vnd.openxmlformats-officedocument.presentationml.presentation")
+               .getContentAsText(is);
+         String etalon =
+            "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
+               + "Ronaldo\n" + "The natural scients universitys\n";
 
-      assertEquals("Wrong string returned", etalon, text);
+         assertEquals("Wrong string returned", etalon, text);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestMSXWordDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -17,11 +17,9 @@
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.exoplatform.services.document.test;
-
-import org.exoplatform.container.PortalContainer;
-import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
+import org.exoplatform.services.document.DocumentReaderService;
+
 import java.io.InputStream;
 
 /**
@@ -29,29 +27,31 @@
  * @version $Id: TestMSXWordDocumentReader.java 34360 2009-07-22 23:58:59Z nzamosenchuk $
  *
  */
-public class TestMSXWordDocumentReader extends BasicTestCase
+public class TestMSXWordDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
+   DocumentReaderService service;
 
    @Override
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsStringDoc() throws Exception
    {
       InputStream is = TestMSXWordDocumentReader.class.getResourceAsStream("/test.docx");
-      String text = service_.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document").getContentAsText(is);
-      System.out.println("text [" + text + "]");
-
-      /*
-       * String etalon = "Hello.\n" +"This is the test document 12345\n"
-       * +"Table\n" +"Title One Two\n" +"Hello_Title Hello_One Hello_Two\n";
-       * System.out.println("etalon ["+etalon+"]");
-       * System.out.println("["+text.length()+"] ["+etalon.length()+"]");
-       * assertEquals("Wrong string returned",etalon ,text );
-       */
+      try
+      {
+         String text =
+            service.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
+               .getContentAsText(is);
+         assertTrue(text
+            .contains("Before the test starts there is a directions section, which takes a few minutes to read"));
+      }
+      finally
+      {
+         is.close();
+      }
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestOpenOfficeDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestOpenOfficeDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestOpenOfficeDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,9 +18,7 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.InputStream;
 
@@ -31,55 +29,32 @@
  * @version $Id: $
  */
 
-public class TestOpenOfficeDocumentReader extends BasicTestCase
+public class TestOpenOfficeDocumentReader extends BaseStandaloneTest
 {
+   DocumentReaderService service;
 
-   DocumentReaderService service_;
-
+   @Override
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestOpenOfficeDocumentReader.class.getResourceAsStream("/test.odt");
-      String text = service_.getDocumentReader("application/vnd.oasis.opendocument.text").getContentAsText(is);
-      System.out.println("[" + text + "]");
-      /*
-       * String etalon = "Subscription:" +
-       * "\tEULA with add on warranties and non GPL viral effect (all Customer's development free of GPL license limitations). This agreement continues to be valid even if customers do not renew their subscription.\n"
-       * +
-       * "\tProduct documentation including user and admin guides to eXo platform portal, ECM, JCR, and Portlet Container. (currently we have all the docs accessible for free but it will not)\n"
-       * +
-       * "\tAccess to all Flash tutorial gives a visual guide to eXo platform and demonstrates a comprehensive tutorial that enhance the understanding of eXo products. (only part of Flash tutorials are accessible for free)\n"
-       * +
-       * "\tAdvanced Installer is an application that makes it quick and easy to install eXo platform products with simple clicks and allows better configuration to integrate existing database and directories (LDAP) in a multi platform environment.\n"
-       * +
-       * "\tUnlimited access to online premium forum (customer request tracking?) support, you will get answer from eXo platform company technical specialist employees. (TODO) \n"
-       * +
-       * "\tUnlimited email support within 48 hours response time for limited contact names per CPU.(i think we may join it with prev item using term customer request tracking with email notification)\n"
-       * +
-       * "\tUpdate alert will send out email periodically to subscribers all the latest change in eXo documentations, flash tutorials, and product services. (TODO)\n"
-       * +
-       * "\tTechnical code improvement alert will send out email periodically to subscribers to inform of all the latest code patches, latest version, latest code improvement download. (TODO)\n"
-       * +
-       * "\tKnowledge Base subscribers can access to all of eXo platform wiki knowledge bases. (TODO, i do not think we may put it into agreement yet)\n"
-       * +
-       * "\tFeature Request Priority As customers you have priorities to request the latest features improvement for any of eXo products next version. (what does it mean?)\n"
-       * + "\n" +
-       * "Subscription is annual and per CPU because it is the unit of load increase and so more support demand. Subscription advantages are:\n"
-       * + "\tEULA � it is obligatory to be Subscriber to get EULA\n" +
-       * "\tAdditional documentations (Guides, Flash tutorials)\n" +
-       * "\tAdditional software (Installer)\n" +
-       * "\tAdditional product/documentation changes notifications\n" +
-       * "\tProfessional support: limited contact name (3 customer contact with 1 eXo contact per CPU), 48 hours to answer via email\n"
-       * + "\tFeature request priority (also depending on CPU number)\n" + "\n";
-       * System.out.println("["+etalon+"]");
-       * System.out.println("TEXT size ["+text.
-       * length()+"]  ETALON LEN ["+etalon.length()+"]");
-       * assertEquals("Wrong string returned", etalon, text);
-       */
+      try
+      {
+         String text = service.getDocumentReader("application/vnd.oasis.opendocument.text").getContentAsText(is);
+
+         assertTrue(
+            "Wrong string returned",
+            text
+               .contains("Product documentation including user and admin guides to eXo platform portal, ECM, JCR, and Portlet Container. (currently we have all the docs accessible for free but it will not)"));
+      }
+      finally
+      {
+         is.close();
+      }
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPDFDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPDFDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPDFDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,9 +18,7 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.InputStream;
 
@@ -31,23 +29,29 @@
  * @version $Id: $
  */
 
-public class TestPDFDocumentReader extends BasicTestCase
+public class TestPDFDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
+   DocumentReaderService service;
 
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestPDFDocumentReader.class.getResourceAsStream("/test.pdf");
-      String text = service_.getDocumentReader("application/pdf").getContentAsText(is);
-      String etalon = "Hello\nThis is my first Cocoon page!\npage 1 \n";
+      try
+      {
+         String text = service.getDocumentReader("application/pdf").getContentAsText(is);
+         String expected = "Hello This is my first Cocoon page! page 1";
 
-      System.out.println("[" + text + "]");
-      // assertEquals("Wrong string returned",etalon ,text );
+         assertEquals("Wrong string returned", normalizeWhitespaces(expected), normalizeWhitespaces(text));
+      }
+      finally
+      {
+         is.close();
+      }
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPPTDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPPTDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPPTDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,9 +18,7 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.InputStream;
 
@@ -31,24 +29,30 @@
  * @version $Id: $
  */
 
-public class TestPPTDocumentReader extends BasicTestCase
+public class TestPPTDocumentReader extends BaseStandaloneTest
 {
+   DocumentReaderService service;
 
-   DocumentReaderService service_;
-
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestPPTDocumentReader.class.getResourceAsStream("/test.ppt");
-      String text = service_.getDocumentReader("application/powerpoint").getContentAsText(is);
-      String etalon =
-         "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
-            + "Ronaldo\n" + "The natural scients universitys\n\n";
-      assertEquals("Wrong string returned", etalon, text);
+      try
+      {
+         String text = service.getDocumentReader("application/powerpoint").getContentAsText(is);
+         String etalon =
+            "TEST POWERPOINT\n" + "Manchester United \n" + "AC Milan\n" + "SLIDE 2 \n" + "Eric Cantona\n" + "Kaka\n"
+               + "Ronaldo\n" + "The natural scients universitys\n\n";
+         assertEquals("Wrong string returned", etalon, text);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestPropertiesExtracting.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,10 +18,7 @@
  */
 package org.exoplatform.services.document.test;
 
-import junit.framework.TestCase;
-
 import org.exoplatform.commons.utils.ISO8601;
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DCMetaData;
 import org.exoplatform.services.document.DocumentReader;
 import org.exoplatform.services.document.DocumentReaderService;
@@ -32,87 +29,224 @@
 import java.util.Map;
 import java.util.Properties;
 
-public class TestPropertiesExtracting extends TestCase
+public class TestPropertiesExtracting extends BaseStandaloneTest
 {
+   DocumentReaderService service;
 
-   DocumentReaderService service_;
-
-   public TestPropertiesExtracting(String name)
-   {
-      super(name);
-   }
-
+   @Override
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
-   public void testPDFDocumentReaderService() throws Exception
-   {
-      InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.pdf");
-      DocumentReader rdr = service_.getDocumentReader("application/pdf");
-      Properties props = rdr.getProperties(is);
-      printProps(props);
-   }
-
    public void testPDFDocumentReaderServiceXMPMetadata() throws Exception
    {
       InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/MyTest.pdf");
-      DocumentReader rdr = service_.getDocumentReader("application/pdf");
-
-      Properties testprops = rdr.getProperties(is);
-      printProps(testprops);
-
-      Properties etalon = new Properties();
-      etalon.put(DCMetaData.TITLE, "Test de convertion de fichier tif");
-      etalon.put(DCMetaData.CREATOR, "Christian Klaus");
-      etalon.put(DCMetaData.SUBJECT, "20080901 TEST Christian Etat OK");
-      Calendar c = ISO8601.parseEx("2008-09-01T08:01:10+00:00");;
-      etalon.put(DCMetaData.DATE, c);
-
-      evalProps(etalon, testprops);
+      try
+      {
+         DocumentReader rdr = service.getDocumentReader("application/pdf");
+         Properties testprops = rdr.getProperties(is);
+         Properties etalon = new Properties();
+         etalon.put(DCMetaData.TITLE, "Test de convertion de fichier tif");
+         etalon.put(DCMetaData.CREATOR, "Christian Klaus");
+         etalon.put(DCMetaData.SUBJECT, "20080901 TEST Christian Etat OK");
+         Calendar c = ISO8601.parseEx("2008-09-01T08:01:10+00:00");
+         etalon.put(DCMetaData.DATE, c);
+         evalProps(etalon, testprops);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
    public void testWordDocumentReaderService() throws Exception
    {
       InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.doc");
-      Properties props = service_.getDocumentReader("application/msword").getProperties(is);
-      printProps(props);
+      try
+      {
+         Properties props = service.getDocumentReader("application/msword").getProperties(is);
+         Properties etalon = new Properties();
+         Calendar date = Calendar.getInstance();
+         date.setTimeInMillis(0);
+         date.set(2010, 7, 31, 12, 31, 0);
+
+         etalon.put(DCMetaData.TITLE, "test-Title");
+         etalon.put(DCMetaData.DATE, date.getTime());
+         etalon.put(DCMetaData.SUBJECT, "test-Subject");
+         etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
+         etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+         etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+         evalProps(etalon, props);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
    public void testPPTDocumentReaderService() throws Exception
    {
       InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.ppt");
-      Properties props = service_.getDocumentReader("application/powerpoint").getProperties(is);
-      printProps(props);
+      try
+      {
+         Properties props = service.getDocumentReader("application/powerpoint").getProperties(is);
+         Properties etalon = new Properties();
+         Calendar date = Calendar.getInstance();
+         date.setTimeInMillis(41);
+         date.set(2010, 7, 31, 12, 34, 15);
+         etalon.put(DCMetaData.TITLE, "test-Title");
+         etalon.put(DCMetaData.DATE, date.getTime());
+         etalon.put(DCMetaData.SUBJECT, "test-Subject");
+         etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
+         etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+         etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+         evalProps(etalon, props);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
    public void testExcelDocumentReaderService() throws Exception
    {
       InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.xls");
-      Properties props = service_.getDocumentReader("application/excel").getProperties(is);
-      printProps(props);
+      try
+      {
+         Properties props = service.getDocumentReader("application/excel").getProperties(is);
+         Properties etalon = new Properties();
+         Calendar date = Calendar.getInstance();
+         date.setTimeInMillis(0);
+         date.set(2010, 7, 31, 12, 34, 53);
+
+         etalon.put(DCMetaData.TITLE, "test-Title");
+         etalon.put(DCMetaData.DATE, date.getTime());
+         etalon.put(DCMetaData.SUBJECT, "test-Subject");
+         etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
+         etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+         etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+         evalProps(etalon, props);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
-   public void testOODocumentReaderService() throws Exception
+   public void testXWordDocumentReaderService() throws Exception
    {
-      InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.odt");
-      Properties props = service_.getDocumentReader("application/vnd.oasis.opendocument.text").getProperties(is);
-      printProps(props);
+      InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.docx");
+      try
+      {
+         Properties props =
+            service.getDocumentReader("application/vnd.openxmlformats-officedocument.wordprocessingml.document")
+               .getProperties(is);
+         Properties etalon = new Properties();
+         Calendar date = Calendar.getInstance();
+         date.setTimeInMillis(0);
+         date.set(2010, 7, 31, 7, 53, 0);
+
+         etalon.put(DCMetaData.TITLE, "test-Title");
+         etalon.put(DCMetaData.DATE, date.getTime());
+         etalon.put(DCMetaData.SUBJECT, "Subject");
+         etalon.put(DCMetaData.CREATOR, "nikolaz");
+         etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+         etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+         evalProps(etalon, props);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
-   private void printProps(Properties props)
+   public void testXPPTDocumentReaderService() throws Exception
    {
-      Iterator it = props.entrySet().iterator();
-      props.toString();
-      while (it.hasNext())
+      InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.pptx");
+      try
       {
-         Map.Entry entry = (Map.Entry)it.next();
-         System.out.println(" " + entry.getKey() + " -> [" + entry.getValue() + "]");
+         Properties props =
+            service.getDocumentReader("application/vnd.openxmlformats-officedocument.presentationml.presentation")
+               .getProperties(is);
+         Properties etalon = new Properties();
+         Calendar date = Calendar.getInstance();
+         date.setTimeInMillis(0);
+         date.set(2010, 7, 31, 7, 59, 37);
+
+         etalon.put(DCMetaData.TITLE, "test-Title");
+         etalon.put(DCMetaData.DATE, date.getTime());
+         etalon.put(DCMetaData.SUBJECT, "test-Subject");
+         etalon.put(DCMetaData.CREATOR, "Max Yakimenko");
+         etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+         etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+         evalProps(etalon, props);
       }
+      finally
+      {
+         is.close();
+      }
    }
 
+   public void testXExcelDocumentReaderService() throws Exception
+   {
+      InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.xlsx");
+      try
+      {
+         Properties props =
+            service.getDocumentReader("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
+               .getProperties(is);
+         Properties etalon = new Properties();
+         Calendar date = Calendar.getInstance();
+         date.setTimeInMillis(0);
+         date.set(2010, 7, 31, 8, 7, 25);
+
+         etalon.put(DCMetaData.TITLE, "test-Title");
+         etalon.put(DCMetaData.DATE, date.getTime());
+         etalon.put(DCMetaData.SUBJECT, "test-Subject");
+         etalon.put(DCMetaData.CREATOR, "KHANH NGUYEN GIA");
+         etalon.put(DCMetaData.CONTRIBUTOR, "Max Yakimenko");
+         etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+         evalProps(etalon, props);
+      }
+      finally
+      {
+         is.close();
+      }
+   }
+
+   public void testOODocumentReaderService() throws Exception
+   {
+      InputStream is = TestPropertiesExtracting.class.getResourceAsStream("/test.odt");
+      try
+      {
+         Properties props = service.getDocumentReader("application/vnd.oasis.opendocument.text").getProperties(is);
+         Properties etalon = new Properties();
+         Calendar date = Calendar.getInstance();
+         date.setTimeInMillis(0);
+         date.set(2010, 7, 31, 14, 13, 23);
+
+         etalon.put(DCMetaData.TITLE, "test-Title");
+         etalon.put(DCMetaData.LANGUAGE, "ru-RU");
+         etalon.put(DCMetaData.DATE, "2010-08-31T14:13:23");
+         etalon.put(DCMetaData.SUBJECT, "test-Subject");
+         etalon.put(DCMetaData.CREATOR, "nikolaz ");
+         etalon.put(DCMetaData.DESCRIPTION, "test-Comments");
+
+         evalProps(etalon, props);
+      }
+      finally
+      {
+         is.close();
+      }
+   }
+
    private void evalProps(Properties etalon, Properties testedProps)
    {
       Iterator it = etalon.entrySet().iterator();

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestTextPlainDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestTextPlainDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestTextPlainDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,9 +18,7 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.InputStream;
 
@@ -31,31 +29,44 @@
  * @version $Id: $
  */
 
-public class TestTextPlainDocumentReader extends BasicTestCase
+public class TestTextPlainDocumentReader extends BaseStandaloneTest
 {
+   DocumentReaderService service;
 
-   DocumentReaderService service_;
-
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestTextPlainDocumentReader.class.getResourceAsStream("/test.txt");
-      String text = service_.getDocumentReader("text/plain").getContentAsText(is);
-      assertEquals("Wrong string returned", "This is a test text\n", text);
+      try
+      {
+         String text = service.getDocumentReader("text/plain").getContentAsText(is);
+         assertEquals("Wrong string returned", "This is a test text\n", text);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
    public void testGetContentAsStringWithEncoding() throws Exception
    {
       InputStream is = TestTextPlainDocumentReader.class.getResourceAsStream("/testUTF8.txt");
-      String text = service_.getDocumentReader("text/plain").getContentAsText(is, "UTF-8");
-      String etalon =
-         "\ufeff\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442. \u042d\u0442\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.";
-      assertEquals("Wrong string returned", etalon, text);
+      try
+      {
+         String text = service.getDocumentReader("text/plain").getContentAsText(is, "UTF-8");
+         String expected =
+            "\ufeff\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442. \u042d\u0442\u043e \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0442\u0435\u043a\u0441\u0442.";
+         assertEquals("Wrong string returned", expected, text);
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java
===================================================================
--- core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java	2010-08-31 11:49:25 UTC (rev 3029)
+++ core/branches/2.3.x/exo.core.component.document/src/test/java/org/exoplatform/services/document/test/TestXMLDocumentReader.java	2010-08-31 14:21:30 UTC (rev 3030)
@@ -18,9 +18,7 @@
  */
 package org.exoplatform.services.document.test;
 
-import org.exoplatform.container.PortalContainer;
 import org.exoplatform.services.document.DocumentReaderService;
-import org.exoplatform.test.BasicTestCase;
 
 import java.io.InputStream;
 
@@ -31,40 +29,60 @@
  * @version $Id: $
  */
 
-public class TestXMLDocumentReader extends BasicTestCase
+public class TestXMLDocumentReader extends BaseStandaloneTest
 {
-   DocumentReaderService service_;
+   DocumentReaderService service;
 
    public void setUp() throws Exception
    {
-      PortalContainer pcontainer = PortalContainer.getInstance();
-      service_ = (DocumentReaderService)pcontainer.getComponentInstanceOfType(DocumentReaderService.class);
+      super.setUp();
+      service = (DocumentReaderService)getComponentInstanceOfType(DocumentReaderService.class);
    }
 
    public void testGetContentAsString() throws Exception
    {
       InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/test.xml");
-      String text = service_.getDocumentReader("text/xml").getContentAsText(is);
-      String expected = "John\n" + "  Alice\n" + "  Reminder\n" + "  Don't forget it this weekend!";
-      assertEquals("Wrong string returned", expected, text.trim());
+      try
+      {
+         String text = service.getDocumentReader("text/xml").getContentAsText(is);
+         String expected = "John\n" + "  Alice\n" + "  Reminder\n" + "  Don't forget it this weekend!";
+         assertEquals("Wrong string returned", expected, text.trim());
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
    public void testCDATAGetContentAsString() throws Exception
    {
       InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/testCDATA.xml");
-      String text = service_.getDocumentReader("text/xml").getContentAsText(is);
-      String expected = "This is a text inside CDATA.";
-      assertEquals("Wrong string returned", expected, text.trim());
+      try
+      {
+         String text = service.getDocumentReader("text/xml").getContentAsText(is);
+         String expected = "This is a text inside CDATA.";
+         assertEquals("Wrong string returned", expected, text.trim());
+      }
+      finally
+      {
+         is.close();
+      }
    }
 
    public void testI18ngetContentAsString() throws Exception
    {
       InputStream is = TestXMLDocumentReader.class.getResourceAsStream("/testUTF8.xml");
-      String text = service_.getDocumentReader("text/xml").getContentAsText(is);
-      final String expected =
-         "\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442.\n"
-            + "Archim\u00E8de et Lius \u00E0 Ch\u00E2teauneuf testing chars en \u00E9t\u00E9";
-      assertEquals("Wrong string returned", expected, text.trim());
+      try
+      {
+         String text = service.getDocumentReader("text/xml").getContentAsText(is);
+         final String expected =
+            "\u0426\u0435 \u0442\u0435\u0441\u0442\u043e\u0432\u0438\u0439 \u0442\u0435\u043a\u0441\u0442.\n"
+               + "Archim\u00E8de et Lius \u00E0 Ch\u00E2teauneuf testing chars en \u00E9t\u00E9";
+         assertEquals("Wrong string returned", expected, text.trim());
+      }
+      finally
+      {
+         is.close();
+      }
    }
-
 }

Modified: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.doc
===================================================================
(Binary files differ)

Modified: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.docx
===================================================================
(Binary files differ)

Modified: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.odt
===================================================================
(Binary files differ)

Modified: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.ppt
===================================================================
(Binary files differ)

Modified: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.pptx
===================================================================
(Binary files differ)

Modified: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.xls
===================================================================
(Binary files differ)

Modified: core/branches/2.3.x/exo.core.component.document/src/test/resources/test.xlsx
===================================================================
(Binary files differ)



More information about the exo-jcr-commits mailing list