/*
 * Copyright 2012-2014 MarkLogic Corporation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.marklogic.client.test;

import static org.junit.Assert.assertEquals;

import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.net.URISyntaxException;
import java.net.URL;

import org.junit.Test;

import com.marklogic.client.impl.HandleAccessor;
import com.marklogic.client.io.BytesHandle;
import com.marklogic.client.io.FileHandle;
import com.marklogic.client.io.InputStreamHandle;
import com.marklogic.client.io.ReaderHandle;
import com.marklogic.client.io.StringHandle;
public class HandleAccessorTest {
	@Test
    public void testContentAsString() throws URISyntaxException, IOException {
        // I'm purposely using a string with a non-ascii character to test 
        // charset issues
        String hola = "¡Hola!";
        assertEquals("String content mismatch", hola, 
            HandleAccessor.contentAsString(new StringHandle(hola)));
        assertEquals("byte[] content mismatch", hola, 
            HandleAccessor.contentAsString(new BytesHandle(hola.getBytes())));
        URL filePath = this.getClass().getClassLoader().getResource("hola.txt");
        assertEquals("Reader content mismatch", hola, 
            HandleAccessor.contentAsString(new ReaderHandle(new StringReader(hola))));
        assertEquals("File content mismatch", hola, 
            HandleAccessor.contentAsString(new FileHandle(new File(filePath.toURI()))));
        assertEquals("InputStream content mismatch", hola, 
            HandleAccessor.contentAsString(new InputStreamHandle(filePath.openStream())));
    }
}

@@ -818,16 +818,49 @@
 net.URL;
+%0Aimport java.nio.charset.Charset;
 %0A%0Aimport
@@ -1407,16 +1407,97 @@
 Hola!%22;%0A
+        System.out.println(%22Default Java Charset: %22 + Charset.defaultCharset());%0A
         
@@ -1740,16 +1740,23 @@
 etBytes(
+%22UTF-8%22
 ))));%0A  

fix #202--test was failing with maven (though not with eclipse). The problem is the test needed to be explicit about charset.