package org.jerrymouse.cc.site.web;

import javax.ws.rs.core.Response;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jerrymouse.cc.site.test.BaseTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

public class ResourceWebTest extends BaseTest {
	@Autowired
	ResourceWeb resourceAction;

	private static Log log = LogFactory.getLog(ResourceWeb.class);

	@Test
	public void testGetResourceA() {
		Response response = resourceAction.getResource("yankai", "a", null,
				null, null, null);
		log.debug(response.getMetadata());
	}

	@Test
	public void testGetResourceB() {
		Response response = resourceAction.getResource("yankai", "ººÎÄ", null,
				null, null, null);
		log.debug(response.getMetadata());
	}

	@Test
	public void testGetResourceC() {
		Response response = resourceAction.getResource("yankai",
				"Cloud_computing", null, null, null, null);
		log.debug(response.getMetadata());
	}

	// @Test
	// public void testGetResourceDevice() {
	// Response response = resourceAction.getResource("yankai", "open_3d",
	// null, null, "mobile-nokia-n82", null);
	// File file = new File("open_3d.3gp");
	// byte[] output = (byte[]) response.getEntity();
	// try {
	// IOUtils.write(output, new FileOutputStream(file));
	// } catch (FileNotFoundException e) {
	// e.printStackTrace();
	// } catch (IOException e) {
	// e.printStackTrace();
	// }
	// log.debug(response.getMetadata());
	// }

	// @Test
	// public void testGetFromWeb() throws Exception {
	// String url =
	// "http://www.tudou.com/playlist/playindex.do?lid=7328348&iid=39516812&cid=24";
	// Response response = resourceAction.getResource("yankai", "tudou", null,
	// null, null, url);
	// log.debug(response.getMetadata());
	// }

	@Test
	public void testView() throws Exception {
		Response response = resourceAction.viewResource("yankai", "open_3d",
				null, null);
		log.debug(response.getMetadata());
	}
	// @Test
	// public void testPutResourceFromWeb() {
	// String url =
	// "http://www.tudou.com/playlist/playindex.do?lid=7328348&iid=39516812&cid=24";
	// Response response = resourceAction.putResource("yankai", "tudou", url);
	// log.debug(response.getMetadata());
	// }
}
