// Path: micro-genie-application/src/main/java/io/microgenie/application/blob/FileStoreFactory.java
// public abstract class FileStoreFactory implements Closeable {
// 
// 	public FileStoreFactory(){}
// 	public abstract FileContent read(final FilePath path) throws IOException;
// 	public abstract FileContentStream readStream(final FilePath path);
// 	public abstract FilePath delete(final FilePath path);
// 	public abstract FilePath save(final FileContent file); 
// 	public abstract String getDefaultDrive();
// }
// 
// Path: micro-genie-application/src/main/java/io/microgenie/application/database/DatabaseFactory.java
// public abstract class DatabaseFactory implements Closeable {
// 
// 	
// 	private final Map<Class<?>, EntityRepository<?>> repositories = Maps.newHashMap();
// 	
// 	public DatabaseFactory(){}
// 
// 	
// 	@SuppressWarnings("unchecked")
// 	public <T,R extends EntityRepository<T>> R repos(Class<T> clazz) {
// 		final EntityRepository<?> repo =  repositories.get(clazz);
// 		if(repo!=null){
// 			return (R) repo;	
// 		}
// 		return null;
// 	}
// 	
// 	
// 	
// 	
// 	/***
// 	 *  Register a repository class
// 	 * @param clazz
// 	 * @param repo
// 	 */
// 	public <T> EntityRepository<T> registerRepo(Class<T> clazz, EntityRepository<T> repo){
// 		this.repositories.put(clazz, repo);
// 		return repo;
// 	}
// }
// 
// Path: micro-genie-application/src/main/java/io/microgenie/application/events/EventFactory.java
// public abstract class EventFactory implements Closeable {
// 
// 
// 	/***
// 	 * Constructor
// 	 */
// 	public EventFactory(){}
// 	
// 
// 	public abstract void publish(final Event event);
// 	public abstract void publish(final List<Event> events);
// 	
// 	public abstract void publish(final String clientId, final Event event);
// 	public abstract void publish(final String clientId, final List<Event> events);
// 
// 	public abstract Publisher createPublisher(final String clientId);
// 	public abstract Subscriber createSubscriber(final String clientId, final String topic);
// 	
// 	public abstract StateChangePublisher createChangePublisher(final String clientId, final StateChangeConfiguration stateChangeConfig);
// 	
// 	
// 	/***
// 	 * Subscribe to the given topic, providing an event handler that will process all
// 	 * consumed events for this Subscriber
// 	 * 
// 	 * @param topic
// 	 * @param clientId
// 	 * @param handler
// 	 */
// 	public abstract void subcribe(final String clientId, final String topic, final EventHandler handler);
// 	
// 
// 	
// 	/**
// 	 * Creates a publisher
// 	 * @param clientId - The clientId of the publisher to get
// 	 * @return publisher
// 	 */
// 	public synchronized Publisher getPublisher(final String clientId) {
// 		return this.createPublisher(clientId);
// 	}
// }
// 
// Path: micro-genie-application/src/main/java/io/microgenie/application/queue/QueueFactory.java
// public abstract class QueueFactory implements Closeable {
// 
// 	/***
// 	 * Creates the default ThreadGroupFactory
// 	 */
// 	public QueueFactory(){}
// 	
// 	
// 	public abstract Producer getProducer();
// 	public abstract Consumer getConsumer(final String queue);
// 	
// 	public abstract void produce(final Message message);
// 	public abstract void produceBatch(final List<Message> messages);
// 	
// 	public abstract void consume(String queue, int threadCount, MessageHandler handler);
// 
// }
// 
// Path: micro-genie-application/src/main/java/io/microgenie/application/util/CloseableUtil.java
// public class CloseableUtil {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(CloseableUtil.class); 
// 	
// 	/** The Guava version throws an IOException even if swallow exception is set to true, based on guava version **/
// 	public static void closeQuietly(Closeable closeable){
// 		try{
// 			Closeables.close(closeable, true);
// 		}catch(Exception ex){
// 			LOGGER.debug(ex.getMessage(),ex);
// 		}
// 	}
// }


import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import io.microgenie.application.blob.FileStoreFactory;
import io.microgenie.application.database.DatabaseFactory;
import io.microgenie.application.events.EventFactory;
import io.microgenie.application.queue.QueueFactory;
import io.microgenie.application.util.CloseableUtil;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;
		appFactory.close();
		verify(databases, times(1)).close();
		verify(queues, times(1)).close();
		verify(files, times(1)).close();
		verify(events, times(1)).close();
	}
	
	
	
	/***
	 * Mock Application Factory for unit testing
	 * @author shawn
	 */
	static class MockApplicationFactory extends ApplicationFactory {
		
		@Override
		public QueueFactory queues() {
			return queues;
		}		
		@Override
		public EventFactory events() {
			return events;
		}
		
		@SuppressWarnings("unchecked")
		@Override
		public DatabaseFactory database() {
			return databases;
		}
		@Override
// Path: micro-genie-application/src/main/java/io/microgenie/application/blob/FileStoreFactory.java
// public abstract class FileStoreFactory implements Closeable {
// 
// 	public FileStoreFactory(){}
// 	public abstract FileContent read(final FilePath path) throws IOException;
// 	public abstract FileContentStream readStream(final FilePath path);
// 	public abstract FilePath delete(final FilePath path);
// 	public abstract FilePath save(final FileContent file); 
// 	public abstract String getDefaultDrive();
// }
// 
// Path: micro-genie-application/src/main/java/io/microgenie/application/database/DatabaseFactory.java
// public abstract class DatabaseFactory implements Closeable {
// 
// 	
// 	private final Map<Class<?>, EntityRepository<?>> repositories = Maps.newHashMap();
// 	
// 	public DatabaseFactory(){}
// 
// 	
// 	@SuppressWarnings("unchecked")
// 	public <T,R extends EntityRepository<T>> R repos(Class<T> clazz) {
// 		final EntityRepository<?> repo =  repositories.get(clazz);
// 		if(repo!=null){
// 			return (R) repo;	
// 		}
// 		return null;
// 	}
// 	
// 	
// 	
// 	
// 	/***
// 	 *  Register a repository class
// 	 * @param clazz
// 	 * @param repo
// 	 */
// 	public <T> EntityRepository<T> registerRepo(Class<T> clazz, EntityRepository<T> repo){
// 		this.repositories.put(clazz, repo);
// 		return repo;
// 	}
// }
// 
// Path: micro-genie-application/src/main/java/io/microgenie/application/events/EventFactory.java
// public abstract class EventFactory implements Closeable {
// 
// 
// 	/***
// 	 * Constructor
// 	 */
// 	public EventFactory(){}
// 	
// 
// 	public abstract void publish(final Event event);
// 	public abstract void publish(final List<Event> events);
// 	
// 	public abstract void publish(final String clientId, final Event event);
// 	public abstract void publish(final String clientId, final List<Event> events);
// 
// 	public abstract Publisher createPublisher(final String clientId);
// 	public abstract Subscriber createSubscriber(final String clientId, final String topic);
// 	
// 	public abstract StateChangePublisher createChangePublisher(final String clientId, final StateChangeConfiguration stateChangeConfig);
// 	
// 	
// 	/***
// 	 * Subscribe to the given topic, providing an event handler that will process all
// 	 * consumed events for this Subscriber
// 	 * 
// 	 * @param topic
// 	 * @param clientId
// 	 * @param handler
// 	 */
// 	public abstract void subcribe(final String clientId, final String topic, final EventHandler handler);
// 	
// 
// 	
// 	/**
// 	 * Creates a publisher
// 	 * @param clientId - The clientId of the publisher to get
// 	 * @return publisher
// 	 */
// 	public synchronized Publisher getPublisher(final String clientId) {
// 		return this.createPublisher(clientId);
// 	}
// }
// 
// Path: micro-genie-application/src/main/java/io/microgenie/application/queue/QueueFactory.java
// public abstract class QueueFactory implements Closeable {
// 
// 	/***
// 	 * Creates the default ThreadGroupFactory
// 	 */
// 	public QueueFactory(){}
// 	
// 	
// 	public abstract Producer getProducer();
// 	public abstract Consumer getConsumer(final String queue);
// 	
// 	public abstract void produce(final Message message);
// 	public abstract void produceBatch(final List<Message> messages);
// 	
// 	public abstract void consume(String queue, int threadCount, MessageHandler handler);
// 
// }
// 
// Path: micro-genie-application/src/main/java/io/microgenie/application/util/CloseableUtil.java
// public class CloseableUtil {
// 
// 	private static final Logger LOGGER = LoggerFactory.getLogger(CloseableUtil.class); 
// 	
// 	/** The Guava version throws an IOException even if swallow exception is set to true, based on guava version **/
// 	public static void closeQuietly(Closeable closeable){
// 		try{
// 			Closeables.close(closeable, true);
// 		}catch(Exception ex){
// 			LOGGER.debug(ex.getMessage(),ex);
// 		}
// 	}
// }


// Path: micro-genie-application/src/test/java/io/microgenie/application/ApplicationFactoryTest.java
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import io.microgenie.application.blob.FileStoreFactory;
import io.microgenie.application.database.DatabaseFactory;
import io.microgenie.application.events.EventFactory;
import io.microgenie.application.queue.QueueFactory;
import io.microgenie.application.util.CloseableUtil;
import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

		appFactory.close();
		verify(databases, times(1)).close();
		verify(queues, times(1)).close();
		verify(files, times(1)).close();
		verify(events, times(1)).close();
	}
	
	
	
	/***
	 * Mock Application Factory for unit testing
	 * @author shawn
	 */
	static class MockApplicationFactory extends ApplicationFactory {
		
		@Override
		public QueueFactory queues() {
			return queues;
		}		
		@Override
		public EventFactory events() {
			return events;
		}
		
		@SuppressWarnings("unchecked")
		@Override
		public DatabaseFactory database() {
			return databases;
		}
		@Override
		public FileStoreFactory blobs() {