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

jadex.micro.testcases.AAgent 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 java.util.ArrayList;
import java.util.List;

import jadex.base.test.TestReport;
import jadex.bridge.IInternalAccess;
import jadex.bridge.component.IArgumentsResultsFeature;
import jadex.bridge.component.IExecutionFeature;
import jadex.bridge.service.annotation.Service;
import jadex.commons.future.IFuture;
import jadex.micro.annotation.Agent;
import jadex.micro.annotation.AgentCreated;
import jadex.micro.annotation.Implementation;
import jadex.micro.annotation.ProvidedService;
import jadex.micro.annotation.ProvidedServices;
import jadex.micro.annotation.Result;
import jadex.micro.annotation.Results;

/**
 *  Simple test agent with one service.
 */
@ProvidedServices(@ProvidedService(type=IAService.class, implementation=@Implementation(expression="$pojoagent")))
@Results(@Result(name="testcases", clazz=List.class))
@Service(IAService.class)
@Agent
public class AAgent implements IAService 
{
	@Agent
	protected IInternalAccess agent; 
	
	/**
	 *  Init service method.
	 */
	@AgentCreated
	public IFuture test()
	{
		boolean ext = !agent.getComponentFeature(IExecutionFeature.class).isComponentThread();
		String reason = ext? "Wrong thread: "+Thread.currentThread(): null;
		List tests = new ArrayList();
		tests.add(new TestReport("#A1", "Test if service is called on component thread.", !ext, reason));
		agent.getComponentFeature(IArgumentsResultsFeature.class).getResults().put("testcases", tests);
		
//		System.out.println("called service");
		return IFuture.DONE;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy