/*
 * Copyright (C) 2004-2005  exedio GmbH (www.exedio.com)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package com.exedio.cope;

import java.io.IOException;
import java.io.InputStream;

public class AttributeDataTest extends AttributeTest
{
	public void testSomeData() throws IOException
	{
		assertEquals(item.TYPE, item.someData.getType());
		assertEquals("someData", item.someData.getName());
		assertEquals(null, item.someData.getFixedMimeMajor());
		assertEquals(null, item.someData.getFixedMimeMinor());

		// TODO: test with not null data
		assertEquals(item.TYPE, item.someData.getType());
		assertEquals(null, item.getSomeDataURL());
		assertEquals(null, item.getSomeDataData());
		assertEquals(null, item.getSomeDataMimeMajor());
		assertEquals(null, item.getSomeDataMimeMinor());

		final byte[] bytes = new byte[]{3,7,1,4};
		item.setSomeData(stream(bytes),"someMimeMajor", "someMimeMinor");

		final String prefix =
			model.getProperties().getMediaRootUrl() + "AttributeItem/someData/";
		final String pkString = pkString(item);
		final String expectedURL =
			prefix + pkString + ".someMimeMajor.someMimeMinor";
		//System.out.println(expectedURL);
		//System.out.println(item.getSomeDataURL());
		assertEquals(expectedURL, item.getSomeDataURL());
		assertData(bytes, item.getSomeDataData());
		assertEquals("someMimeMajor", item.getSomeDataMimeMajor());
		assertEquals("someMimeMinor", item.getSomeDataMimeMinor());

		restartTransaction();
		assertEquals(expectedURL, item.getSomeDataURL());
		assertData(bytes, item.getSomeDataData());
		assertEquals("someMimeMajor", item.getSomeDataMimeMajor());
		assertEquals("someMimeMinor", item.getSomeDataMimeMinor());

		assertDataMime(item, "image", "jpeg", bytes, "jpg");
		assertDataMime(item, "image", "pjpeg", bytes, "jpg");
		assertDataMime(item, "image", "gif", bytes, "gif");
		assertDataMime(item, "image", "png", bytes, "png");
		assertDataMime(item, "image", "someMinor", bytes, "image.someMinor");

		final byte[] manyBytes = new byte[49467];
		for(int i = 0; i<manyBytes.length; i++)
		{
			manyBytes[i] = (byte)((121*i)%253);
			//System.out.print(manyBytes[i]+", ");
		}
		item.setSomeData(stream(manyBytes),"someMimeMajor", "someMimeMinor");
		assertData(manyBytes, item.getSomeDataData());

		item.setSomeData((InputStream)null, null, null);
		assertEquals(null, item.getSomeDataURL());
		assertEquals(null, item.getSomeDataData());
		assertEquals(null, item.getSomeDataMimeMajor());
		assertEquals(null, item.getSomeDataMimeMinor());
	}


}

@@ -796,16 +796,17 @@
 USA%0A */%0A
+%0A
 package 

add blank line after copyright comment