/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * 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.
 */

package org.arquillian.liferay.test;

import com.liferay.portal.model.Release;
import com.liferay.portal.service.ReleaseLocalService;

import java.io.File;

import org.arquillian.container.liferay.remote.enricher.Inject;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.osgi.api.BndProjectBuilder;

import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;

/**
 * @author Cristina González
 */
@RunWith(Arquillian.class)
public class TestInjections {

	@Deployment
	public static JavaArchive create() {
		BndProjectBuilder bndProjectBuilder = ShrinkWrap.create(
			BndProjectBuilder.class);

		bndProjectBuilder.setBndFile(new File("bnd-basic-portlet-test.bnd"));

		bndProjectBuilder.generateManifest(true);

		return bndProjectBuilder.as(JavaArchive.class);
	}

	@Test
	public void shouldInjectBundle() {
		Assert.assertNotNull(_bundle);
		Assert.assertEquals(
			"org.arquillian.liferay.sample", _bundle.getSymbolicName());
	}

	@Test
	public void shouldInjectBundleCOntext() {
		Assert.assertNotNull(_bundleContext);
		Assert.assertEquals(_bundle, _bundleContext.getBundle());
	}

	@Test
	public void shouldInjectReleaseLocalService() {
		Assert.assertNotNull(_releaseLocalService);

		Release releasePortal = _releaseLocalService.fetchRelease("portal");

		Assert.assertEquals(7000, releasePortal.getBuildNumber());
	}

	@ArquillianResource
	private Bundle _bundle;

	@ArquillianResource
	private BundleContext _bundleContext;

	@Inject
	private ReleaseLocalService _releaseLocalService;

}
@@ -806,16 +806,227 @@
 .Inject;
+%0Aimport org.arquillian.liferay.sample.service4injection.Service;%0Aimport org.arquillian.liferay.sample.service4injection.ServiceFirstImpl;%0Aimport org.arquillian.liferay.sample.service4injection.ServiceSecondImpl;
 %0A%0Aimport
@@ -1361,33 +1361,8 @@
 rt;%0A
-import org.junit.Ignore;%0A
 impo
@@ -2458,16 +2458,330 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void shouldInjectServiceInOrden() %7B%0A%09%09Assert.assertNotNull(_service);%0A%0A%09%09Assert.assertTrue(_service instanceof ServiceFirstImpl);%0A%09%7D%0A%0A%09@Test%0A%09public void shouldInjectServiceWithFilter() %7B%0A%09%09Assert.assertNotNull(_secondService);%0A%0A%09%09Assert.assertTrue(_secondService instanceof ServiceSecondImpl);%0A%09%7D%0A%0A
 %09@Arquil
@@ -2941,9 +2941,113 @@
 rvice;%0A%0A
+%09@Inject(%22(name=ServiceSecond)%22)%0A%09private Service _secondService;%0A%0A%09@Inject%0A%09private Service _service;%0A%0A
 %7D

Test the Inject behaviour