vmassol     2002/11/23 04:25:56

  Modified:    framework/src/java/share/org/apache/cactus/util IoUtil.java
               framework/src/java/share/org/apache/cactus/server
                        AbstractWebTestCaller.java
               framework/src/java/share/org/apache/cactus/client
                        DefaultHttpClient.java
  Log:
  Added support for internationalisation (double byte characters) for sending back 
test results. This allows Cactus to be used with any character set.
  
  Revision  Changes    Path
  1.3       +24 -5     
jakarta-cactus/framework/src/java/share/org/apache/cactus/util/IoUtil.java
  
  Index: IoUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/IoUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IoUtil.java       28 Aug 2002 19:57:15 -0000      1.2
  +++ IoUtil.java       23 Nov 2002 12:25:56 -0000      1.3
  @@ -71,19 +71,38 @@
   public class IoUtil
   {
       /**
  -     * Read all data in an Inpout stream and return them as a
  +     * @see #getText(InputStream, String)
  +     */
  +    public static String getText(InputStream theStream) throws IOException
  +    {
  +        return getText(theStream, null);
  +    }
  +
  +    /**
  +     * Read all data in an Input stream and return them as a 
        * <code>String</code> object.
        *
        * @param theStream the input stream from which to read the data
  +     * @param theCharsetName the charset name with which to read the data
        * @return the string representation of the data
        * @throws IOException if an error occurs during the read of data
        */
  -    public static String getText(InputStream theStream) throws IOException
  +    public static String getText(InputStream theStream, String theCharsetName) 
  +        throws IOException
       {
           StringBuffer sb = new StringBuffer();
   
  -        BufferedReader input = new BufferedReader(
  -            new InputStreamReader(theStream));
  +        BufferedReader input;
  +        if (theCharsetName == null)
  +        {
  +            input = new BufferedReader(new InputStreamReader(theStream));
  +        }
  +        else
  +        {
  +            input = new BufferedReader(
  +               new InputStreamReader(theStream, theCharsetName));
  +        }
  +        
           char[] buffer = new char[2048];
           int nb;
   
  
  
  
  1.10      +8 -3      
jakarta-cactus/framework/src/java/share/org/apache/cactus/server/AbstractWebTestCaller.java
  
  Index: AbstractWebTestCaller.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/server/AbstractWebTestCaller.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractWebTestCaller.java        26 Sep 2002 21:27:49 -0000      1.9
  +++ AbstractWebTestCaller.java        23 Nov 2002 12:25:56 -0000      1.10
  @@ -182,16 +182,21 @@
           // One could think there is a potential risk that the client side of
           // Cactus will request the result before it has been written to the
           // context scope as the HTTP request will not block in some containers.
  -        // However this will not happend because on the client side, once the
  +        // However this will not happen because on the client side, once the
           // first request is done to execute the test, all the result is read
           // by the AutoReadHttpURLConnection class, thus ensuring that the
  -        // request is fully finished and the resukt has been committed ...
  +        // request is fully finished and the result has been committed ...
           WebTestResult result = (WebTestResult) (this.webImplicitObjects
               .getServletContext().getAttribute(TEST_RESULTS));
   
           LOGGER.debug("Test Result = [" + result + "]");
   
           // Write back the results to the outgoing stream as an XML string.
  +
  +        // Use UTF-8 to transfer the result back
  +        webImplicitObjects.getHttpServletResponse().setContentType(
  +            "text/xml; charset=UTF-8");
  +
           try
           {
               Writer writer = getResponseWriter();
  
  
  
  1.2       +6 -3      
jakarta-cactus/framework/src/java/share/org/apache/cactus/client/DefaultHttpClient.java
  
  Index: DefaultHttpClient.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/DefaultHttpClient.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultHttpClient.java    26 Oct 2002 18:10:47 -0000      1.1
  +++ DefaultHttpClient.java    23 Nov 2002 12:25:56 -0000      1.2
  @@ -81,12 +81,15 @@
   public class DefaultHttpClient
   {
       /**
  -     * Cactus configuration.
     */
  +     * Cactus configuration.
  +     */
       protected WebConfiguration configuration;
       
       /**
        * Initialize the Http client.
  -     * 
     * @param theConfiguration the Cactus configuration
     */
  +     * 
  +     * @param theConfiguration the Cactus configuration
  +     */
       public DefaultHttpClient(WebConfiguration theConfiguration)
       {
           this.configuration = theConfiguration;
  @@ -237,7 +240,7 @@
           // Read the test result
           WebTestResultParser parser = new WebTestResultParser();
           WebTestResult result = parser.parse(
  -            IoUtil.getText(resultConnection.getInputStream()));
  +            IoUtil.getText(resultConnection.getInputStream(), "UTF-8"));
   
           return result;
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to