package org.jerrymouse.cc.site.bean;

import static org.junit.Assert.*;

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

public class ResourceTest extends BaseTest {
	@Autowired
	UserDao userDao;
	private Storage storage;

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

	@Override
	protected void onSetUp() throws Exception {
		super.onSetUp();
		storage = userDao.getUserByName("yankai").getStorage();
	}

	@Test
	public void testGetOrgFileBytes() {
		Resource resource = storage.getResourceByName("a");
		// log.debug(resource.getName());
		// log.debug(resource.getOrgFileName());
		// log.debug(new String(resource.getOrgFileBytes()));
	}

	@Test
	public void testSetOrgFileBytes() {
	}

	@Test
	public void testConvertImage() throws Exception {
		Resource resource = storage.getResourceByName("Cloud_computing");
		resource.setFormat(new Format(new Type("jpg")));
		log.debug(resource.getBytes());
	}

	@Test
	public void testConvertVideo() throws Exception {
		Resource resource = storage.getResourceByName("open_3d");
		resource.setFormat(new Format((new Type("3gp"))));
		resource.setUser(userDao.getUserByName("yankai"));
		log.debug(resource.getBytes());
	}
}
