// Path: src/info/xuluan/podcast/fetcher/Response.java
// public class Response {
// 	private final Log log = Log.getLog(getClass());
// 
// 	public final byte[] content;
// 
// 	public Response(byte[] content) {
// 		this.content = content;
// 	}
// 	
// 	public String getCharset(){
// 		if(content==null)
// 			return "ISO-8859-1";
// 		
// 		Pattern p = Pattern.compile("\\<\\?xml.*?encoding\\=\"(.*?)\"\\s*\\?\\>"
// 				,Pattern.CASE_INSENSITIVE + Pattern.MULTILINE);
// 		int length = content.length>100?100:content.length;
// 		String line = new String(content, 0, length);		
// 		Matcher m = p.matcher(line);
// 		
// 		if (m.find()){
// 			log.debug("Charset = " + m.group(1));
// 			return m.group(1);
// 		}
// 		return "ISO-8859-1";
// 	}
// 	
// 	public String getContentAsString() throws UnsupportedEncodingException {
// 		
// 		//String enc = charset == null ? "ISO-8859-1" : charset;
// 		String charset = getCharset();
// 		String text;
// 
// 		try {
// 			text = new String(content, charset);
// 		}catch (Exception e) {
// 			text = new String(content, "UTF-8");
// 		} 
// 
// 		return text;
// 	}
// 
// }


import info.xuluan.podcast.fetcher.Response;
import junit.framework.TestCase;
/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * 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 info.xuluan.podcast.tests;




public class ResponseTest extends TestCase {

    public void testGetCharset_ISO_8859_1() throws Exception {
    	String s = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
// Path: src/info/xuluan/podcast/fetcher/Response.java
// public class Response {
// 	private final Log log = Log.getLog(getClass());
// 
// 	public final byte[] content;
// 
// 	public Response(byte[] content) {
// 		this.content = content;
// 	}
// 	
// 	public String getCharset(){
// 		if(content==null)
// 			return "ISO-8859-1";
// 		
// 		Pattern p = Pattern.compile("\\<\\?xml.*?encoding\\=\"(.*?)\"\\s*\\?\\>"
// 				,Pattern.CASE_INSENSITIVE + Pattern.MULTILINE);
// 		int length = content.length>100?100:content.length;
// 		String line = new String(content, 0, length);		
// 		Matcher m = p.matcher(line);
// 		
// 		if (m.find()){
// 			log.debug("Charset = " + m.group(1));
// 			return m.group(1);
// 		}
// 		return "ISO-8859-1";
// 	}
// 	
// 	public String getContentAsString() throws UnsupportedEncodingException {
// 		
// 		//String enc = charset == null ? "ISO-8859-1" : charset;
// 		String charset = getCharset();
// 		String text;
// 
// 		try {
// 			text = new String(content, charset);
// 		}catch (Exception e) {
// 			text = new String(content, "UTF-8");
// 		} 
// 
// 		return text;
// 	}
// 
// }


// Path: src/info/xuluan/podcast/tests/ResponseTest.java
import info.xuluan.podcast.fetcher.Response;
import junit.framework.TestCase;

/*
 * Copyright (C) 2008 The Android Open Source Project
 *
 * 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 info.xuluan.podcast.tests;




public class ResponseTest extends TestCase {

    public void testGetCharset_ISO_8859_1() throws Exception {
    	String s = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
    	Response res = new Response(s.getBytes());