All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.micro.testcases.PojoInjectionAgent Maven / Gradle / Ivy

Go to download

The Jadex micro applications package contains several example applications, benchmarks and testcases using micro agents.

There is a newer version: 4.0.267
Show newest version
package jadex.micro.testcases;

import jadex.base.test.TestReport;
import jadex.base.test.Testcase;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IArgumentsResultsFeature;
import jadex.bridge.service.annotation.Service;
import jadex.bridge.service.annotation.ServiceComponent;
import jadex.commons.future.IFuture;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.AgentBody;
import jadex.micro.annotation.Description;
import jadex.micro.annotation.ProvidedService;
import jadex.micro.annotation.ProvidedServices;
import jadex.micro.annotation.Result;
import jadex.micro.annotation.Results;

/**
 *  Test if a pojo can be injected into a service.
 */
@Agent
@ProvidedServices(@ProvidedService(type=IAService.class))
@Service
@Description("Test if a pojo agent can be injected into a service as servicecomponent.")
@Results(@Result(name="testresults", clazz=Testcase.class))
public class PojoInjectionAgent implements IAService
{
	/** The agent. */
	@Agent
	protected IInternalAccess agent;

	/** The service component. */
	@ServiceComponent
	protected PojoInjectionAgent pojo;
	
	@AgentBody
	public IFuture body()
	{
//		System.out.println("pojo is: "+pojo);
		TestReport	tr	= new TestReport("#1", "Test if a pojo agent can be injected into a service as servicecomponent.");
		if(pojo!=null)
		{
			tr.setSucceeded(true);
		}
		else
		{
			tr.setFailed("Service component not set: "+pojo);
		}
		agent.getComponentFeature(IArgumentsResultsFeature.class).getResults().put("testresults", new Testcase(1, new TestReport[]{tr}));
		
		return IFuture.DONE;
	}
	
	/**
	 *  Dummy test method.
	 */
	public IFuture test()
	{
		return IFuture.DONE;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy