// Path: cdiqi-core/src/main/java/cz/symbiont_it/cdiqi/api/AsyncEvent.java
// public final class AsyncEvent {
// 
// 	private final Object targetEvent;
// 
// 	private final Annotation[] qualifiers;
// 
// 	public AsyncEvent(Object targetEvent, Annotation... qualifiers) {
// 		super();
// 		
// 		if(targetEvent == null)
// 			throw new IllegalArgumentException("Target event must not be null");
// 		
// 		this.targetEvent = targetEvent;
// 		this.qualifiers = qualifiers;
// 	}
// 
// 	public Object getTargetEvent() {
// 		return targetEvent;
// 	}
// 
// 	public Annotation[] getQualifiers() {
// 		return qualifiers;
// 	}
// 	
// }
// 
// Path: cdiqi-core/src/main/java/cz/symbiont_it/cdiqi/api/QuartzSchedulerManager.java
// public interface QuartzSchedulerManager {
// 
// 	public static final String QUARTZ_PROPERTY_FILE_NAME = "cdiqi-quartz.properties";
// 	
// 	/**
// 	 * Perform init.
// 	 * 
// 	 * @throws SchedulerException
// 	 */
// 	public void init() throws SchedulerException;
// 
// 	/**
// 	 * @return <code>true</code> if initialized, <code>false</code> otherwise
// 	 */
// 	public boolean isInitialized();
// 
// 	/**
// 	 * Start underlying quartz scheduler. If not initialized perform init first.
// 	 * 
// 	 * @throws SchedulerException
// 	 */
// 	public void start() throws SchedulerException;
// 
// 	/**
// 	 * Pause underlying quartz scheduler.
// 	 * 
// 	 * @throws SchedulerException
// 	 */
// 	public void standby() throws SchedulerException;
// 
// 	/**
// 	 * Deletes all scheduling data.
// 	 * 
// 	 * @throws SchedulerException
// 	 */
// 	public void clear() throws SchedulerException;
// 
// 	/**
// 	 * Schedule new job.
// 	 * 
// 	 * @param jobDetail
// 	 * @param trigger
// 	 * @throws SchedulerException
// 	 */
// 	public void schedule(JobDetail jobDetail, Trigger trigger)
// 			throws SchedulerException;
// 
// }
// 
// Path: cdiqi-weld/src/test/java/cz/symbiont_it/cdiqi/tests/CdiqiTestUtil.java
// public final class CdiqiTestUtil {
// 
// 	private CdiqiTestUtil() {
// 	}
// 
// 	/**
// 	 * @return default test archive
// 	 */
// 	public static WebArchive createTestArchive() {
// 
// 		WebArchive archive = ShrinkWrap.create(WebArchive.class, "test.war");
// 
// 		// API
// 		archive.addPackage(QuartzSchedulerManager.class.getPackage());
// 		// SPI
// 		archive.addPackage(BoundRequestJobListener.class.getPackage());
// 		// Core impl
// 		archive.addPackage(QuartzSchedulerManagerImpl.class.getPackage());
// 		// Weld impl
// 		archive.addPackage(WeldBoundRequestJobListener.class.getPackage());
// 		
// 		archive.addClass(ResultStore.class);
// 		archive.addAsLibraries(DependencyResolvers
// 				.use(MavenDependencyResolver.class)
// 				.artifact("org.quartz-scheduler:quartz:2.0.2")
// 				.artifact("org.slf4j:slf4j-log4j12:1.6.1")
// 				.resolveAs(GenericArchive.class));
// 		archive.addAsResource(new File(
// 				"src/test/resources/cdiqi-quartz.properties"));
// 		archive.addAsResource(new File("src/test/resources/log4j.properties"));
// 		archive.setWebXML(new File("src/test/webapp/WEB-INF/web.xml"));
// 		archive.addAsWebInfResource(new File("src/test/resources/beans.xml"));
// 		// archive.addAsWebInfResource(EmptyAsset.INSTANCE,
// 		// ArchivePaths.create("beans.xml"));
// 		// ARQ will replace in the end
// 		// archive.setManifest(new
// 		// File("src/test/webapp/META-INF/MANIFEST.MF"));
// 		return archive;
// 	}
// 
// }


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import javax.enterprise.event.Event;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.quartz.SchedulerException;
import cz.symbiont_it.cdiqi.api.AsyncEvent;
import cz.symbiont_it.cdiqi.api.QuartzSchedulerManager;
import cz.symbiont_it.cdiqi.tests.CdiqiTestUtil;
	 * 
	 * @throws SchedulerException
	 * @throws InterruptedException
	 */
	@SuppressWarnings("serial")
	@Test
	public void testAsyncEvents() throws SchedulerException,
			InterruptedException {

		quartzManager.start();

		event.fire(new AsyncEvent(new ComputationStart(),
				new AnnotationLiteral<Normal>() {
				}));
		event.fire(new AsyncEvent(new ComputationStart(),
				new AnnotationLiteral<Pseudo>() {
				}));

		String id = "" + Thread.currentThread().getId();
		Thread.sleep(2000l);

		// Check number of results
		assertEquals(1l,
				resultStore.getResultsCount(DependentComputationService.class
						.getName()));
		assertEquals(1l,
				resultStore.getResultsCount(RequestScopedComputationService.class
						.getName()));
		assertEquals(1l,
				resultStore.getResultsCount(ApplicationScopedComputationService.class
// Path: cdiqi-core/src/main/java/cz/symbiont_it/cdiqi/api/AsyncEvent.java
// public final class AsyncEvent {
// 
// 	private final Object targetEvent;
// 
// 	private final Annotation[] qualifiers;
// 
// 	public AsyncEvent(Object targetEvent, Annotation... qualifiers) {
// 		super();
// 		
// 		if(targetEvent == null)
// 			throw new IllegalArgumentException("Target event must not be null");
// 		
// 		this.targetEvent = targetEvent;
// 		this.qualifiers = qualifiers;
// 	}
// 
// 	public Object getTargetEvent() {
// 		return targetEvent;
// 	}
// 
// 	public Annotation[] getQualifiers() {
// 		return qualifiers;
// 	}
// 	
// }
// 
// Path: cdiqi-core/src/main/java/cz/symbiont_it/cdiqi/api/QuartzSchedulerManager.java
// public interface QuartzSchedulerManager {
// 
// 	public static final String QUARTZ_PROPERTY_FILE_NAME = "cdiqi-quartz.properties";
// 	
// 	/**
// 	 * Perform init.
// 	 * 
// 	 * @throws SchedulerException
// 	 */
// 	public void init() throws SchedulerException;
// 
// 	/**
// 	 * @return <code>true</code> if initialized, <code>false</code> otherwise
// 	 */
// 	public boolean isInitialized();
// 
// 	/**
// 	 * Start underlying quartz scheduler. If not initialized perform init first.
// 	 * 
// 	 * @throws SchedulerException
// 	 */
// 	public void start() throws SchedulerException;
// 
// 	/**
// 	 * Pause underlying quartz scheduler.
// 	 * 
// 	 * @throws SchedulerException
// 	 */
// 	public void standby() throws SchedulerException;
// 
// 	/**
// 	 * Deletes all scheduling data.
// 	 * 
// 	 * @throws SchedulerException
// 	 */
// 	public void clear() throws SchedulerException;
// 
// 	/**
// 	 * Schedule new job.
// 	 * 
// 	 * @param jobDetail
// 	 * @param trigger
// 	 * @throws SchedulerException
// 	 */
// 	public void schedule(JobDetail jobDetail, Trigger trigger)
// 			throws SchedulerException;
// 
// }
// 
// Path: cdiqi-weld/src/test/java/cz/symbiont_it/cdiqi/tests/CdiqiTestUtil.java
// public final class CdiqiTestUtil {
// 
// 	private CdiqiTestUtil() {
// 	}
// 
// 	/**
// 	 * @return default test archive
// 	 */
// 	public static WebArchive createTestArchive() {
// 
// 		WebArchive archive = ShrinkWrap.create(WebArchive.class, "test.war");
// 
// 		// API
// 		archive.addPackage(QuartzSchedulerManager.class.getPackage());
// 		// SPI
// 		archive.addPackage(BoundRequestJobListener.class.getPackage());
// 		// Core impl
// 		archive.addPackage(QuartzSchedulerManagerImpl.class.getPackage());
// 		// Weld impl
// 		archive.addPackage(WeldBoundRequestJobListener.class.getPackage());
// 		
// 		archive.addClass(ResultStore.class);
// 		archive.addAsLibraries(DependencyResolvers
// 				.use(MavenDependencyResolver.class)
// 				.artifact("org.quartz-scheduler:quartz:2.0.2")
// 				.artifact("org.slf4j:slf4j-log4j12:1.6.1")
// 				.resolveAs(GenericArchive.class));
// 		archive.addAsResource(new File(
// 				"src/test/resources/cdiqi-quartz.properties"));
// 		archive.addAsResource(new File("src/test/resources/log4j.properties"));
// 		archive.setWebXML(new File("src/test/webapp/WEB-INF/web.xml"));
// 		archive.addAsWebInfResource(new File("src/test/resources/beans.xml"));
// 		// archive.addAsWebInfResource(EmptyAsset.INSTANCE,
// 		// ArchivePaths.create("beans.xml"));
// 		// ARQ will replace in the end
// 		// archive.setManifest(new
// 		// File("src/test/webapp/META-INF/MANIFEST.MF"));
// 		return archive;
// 	}
// 
// }


// Path: cdiqi-weld/src/test/java/cz/symbiont_it/cdiqi/tests/async/AsyncTest.java
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import javax.enterprise.event.Event;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.quartz.SchedulerException;
import cz.symbiont_it.cdiqi.api.AsyncEvent;
import cz.symbiont_it.cdiqi.api.QuartzSchedulerManager;
import cz.symbiont_it.cdiqi.tests.CdiqiTestUtil;

	 * 
	 * @throws SchedulerException
	 * @throws InterruptedException
	 */
	@SuppressWarnings("serial")
	@Test
	public void testAsyncEvents() throws SchedulerException,
			InterruptedException {

		quartzManager.start();

		event.fire(new AsyncEvent(new ComputationStart(),
				new AnnotationLiteral<Normal>() {
				}));
		event.fire(new AsyncEvent(new ComputationStart(),
				new AnnotationLiteral<Pseudo>() {
				}));

		String id = "" + Thread.currentThread().getId();
		Thread.sleep(2000l);

		// Check number of results
		assertEquals(1l,
				resultStore.getResultsCount(DependentComputationService.class
						.getName()));
		assertEquals(1l,
				resultStore.getResultsCount(RequestScopedComputationService.class
						.getName()));
		assertEquals(1l,
				resultStore.getResultsCount(ApplicationScopedComputationService.class
						.getName()));