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

jadex.base.test.impl.ComponentTest Maven / Gradle / Ivy

Go to download

Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.

There is a newer version: 4.0.267
Show newest version
package jadex.base.test.impl;


import java.io.File;

import jadex.base.IPlatformConfiguration;
import jadex.base.Starter;
import jadex.base.test.IAbortableTestSuite;
import jadex.base.test.Testcase;
import jadex.bridge.IExternalAccess;
import jadex.bridge.IResourceIdentifier;
import jadex.bridge.modelinfo.IModelInfo;
import jadex.bridge.service.search.ServiceQuery;
import jadex.bridge.service.types.library.ILibraryService;

/**
 *  Test a component.
 */
public class ComponentTest extends ComponentTestBase
{
	//-------- attributes --------
	
	/** Additional config args. */
	protected String[]	args;
	
	/** The dirs for rids (e.g. classes and resources dirs). */
	protected File[][]	dirs;
	
	/** The component full name. */
	protected String	fullname;
	
	/** The component (kernel) type. */
	protected String	type;
	
	//-------- constructors --------
	
	/**
	 *  Create a new ComponentTest.
	 */
	public ComponentTest() 
	{
		//Logger.getLogger("ComponentTest").log(Level.SEVERE, "Empty ComponentTest Constructor called");
	}
	
	/**
	 *  Create a component test.
	 *  Run on existing test suite platform.
	 *  @param cms	The CMS of the test suite platform.
	 */
	public ComponentTest(IExternalAccess platform, IModelInfo comp, IAbortableTestSuite suite)
	{
		super(comp.getFullName(), suite);
		this.platform = platform;
		this.filename	= comp.getFilename();
		this.rid	= comp.getResourceIdentifier();
		this.fullname	= comp.getFullName();
		this.type	= comp.getType();
		Object	to	= comp.getProperty(Testcase.PROPERTY_TEST_TIMEOUT, getClass().getClassLoader());
		if(to!=null)
		{
			this.timeout	= ((Number)to).longValue();
		}
		else
		{
			this.timeout	= Starter.getScaledDefaultTimeout(platform.getId(), 2);
		}
	}
	
	/**
	 *  Create a component test.
	 *  Run on separate platform.
	 *  @param conf	The config for the new platform.
	 */
	public ComponentTest(IPlatformConfiguration conf, String[] args,  File[][] dirs, IExternalAccess platform, IModelInfo comp, IAbortableTestSuite suite)
	{
		this(platform, comp, suite);
		this.platform	= null; // Don't store suite cms -> use for own cms later.
		this.conf	= conf;
		this.args	= args;
		this.dirs	= dirs;
	}
	
	//-------- methods --------
	
	/**
	 *  Create a new platform (only if conf is given and thus platform per test is enabled)
	 */
	protected IExternalAccess	createPlatform()
	{
		IExternalAccess	platform = Starter.createPlatform(conf, args).get(timeout, true);
		ILibraryService	libsrv	= platform.searchService( new ServiceQuery<>(ILibraryService.class)).get(timeout, true);
		
		for(int projectIndex=0; projectIndex < dirs.length; projectIndex++) 
		{
			File[] project = dirs[projectIndex];
			IResourceIdentifier	parentRid	= null;
			for(int rootIndex=0; rootIndex




© 2015 - 2024 Weber Informatics LLC | Privacy Policy