package fi.csc.microarray.databeans;

import java.io.File;
import java.io.IOException;

import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import fi.csc.microarray.config.DirectoryLayout;
import fi.csc.microarray.config.ConfigurationLoader.IllegalConfigurationException;
import fi.csc.microarray.module.ModuleManager;

public class DataManagerTest {

	private DataManager manager; 
	
	@BeforeClass(alwaysRun = true)
	public void init() throws IOException, IllegalConfigurationException, InstantiationException, IllegalAccessException, ClassNotFoundException {
		DirectoryLayout.initialiseSimpleLayout().getConfiguration();			
		this.manager = new DataManager();
		new ModuleManager("fi.csc.microarray.module.chipster.MicroarrayModule").plugAll(this.manager, null);
	}
	
	@Test(groups = {"unit"} )
	public void testDataTypes() throws IOException {
		File file = File.createTempFile("test", ".png");
		Assert.assertEquals(manager.guessContentType(file).getType(), "image/png");
	}
	
}

@@ -217,29 +217,252 @@
 ay.c
-onfig.DirectoryLayout
+lient.Session;%0Aimport fi.csc.microarray.client.operation.Operation;%0Aimport fi.csc.microarray.client.operation.OperationDefinition;%0Aimport fi.csc.microarray.client.operation.OperationRecord;%0Aimport fi.csc.microarray.client.operation.ToolCategory
 ;%0Aim
@@ -538,24 +538,73 @@
 nException;%0A
+import fi.csc.microarray.config.DirectoryLayout;%0A
 import fi.cs
@@ -984,16 +984,46 @@
 er();%0A%09%09
+ModuleManager moduleManager = 
 new Modu
@@ -1085,16 +1085,33 @@
 Module%22)
+;%0A%09%09moduleManager
 .plugAll
@@ -1132,16 +1132,72 @@
  null);%0A
+%09%09Session.getSession().setModuleManager(moduleManager);%0A
 %09%7D%0A%09%0A%09@T
@@ -1402,12 +1402,798 @@
 g%22);%0A%09%7D%0A
-%09
+%0A%09%0A%09@Test(groups = %7B%22unit%22%7D )%0A%09public void testRemoteSessions() throws Exception %7B%0A%09%09%0A%09%09// populate with crap%0A%09%09File content = File.createTempFile(%22content%22, %22.tsv%22);%0A%09%09DataBean data = manager.createDataBean(%22test-content%22, content);%0A%09%09OperationRecord operationRecord = new OperationRecord(new Operation(new OperationDefinition(%22%22, %22%22, new ToolCategory(%22%22), %22%22, false), new DataBean%5B%5D %7B data %7D ));%0A%09%09data.setOperationRecord(operationRecord);%0A%09%09operationRecord.setModule(%22%22);%0A%09%09manager.getRootFolder().addChild(data);%0A%09%09%0A%09%09// save%0A%09%09File session = File.createTempFile(%22test-remote-session%22, %22.zip%22);%0A%09%09manager.saveLightweightSession(session);%0A%0A%09%09// clear%0A%09%09manager.deleteAllDataItems();%0A%0A%09%09// load%0A%09%09manager.loadSession(session, true);%0A%09%09%0A%09%09// clean up%0A%09%09manager.deleteAllDataItems();%0A%09%7D%0A
 %0A%7D%0A

work with unit testing