Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
This file is part of Port@l Port@l 3.0 - Portal Engine and Management System Copyright (C) 2010 Isotrol, SA. http://www.isotrol.com Port@l is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Port@l 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 General Public License for more details. You should have received a copy of the GNU General Public License along with Port@l. If not, see <http://www.gnu.org/licenses/>.
 
 
 package com.isotrol.impe3.test;
 
 
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 
A module tester.

Parameters:
<T> specific module
Author(s):
Andres Rodriguez
 
 public final class ModuleTester<T extends Module> {
 	private final ModuleDefinition<T> module;
 	private final TestModel model;
 	private StartedModule<T> started = null;
 	private ModuleStarter<T> starter = null;

Default Constructor.
 
 	ModuleTester(final Class<T> modulefinal TestModel model) {
 		this. = ModuleDefinition.of(module);
 		this. = model;
 	}
 
 	private void off() {
 		Preconditions.checkState( == null);
 	}
 
 	private void starting() {
 		off();
 		if ( == null) {
 			final ModuleStarter<T> mstarter = .starter();
 			mstarter.set(EngineMode.class.);
 			mstarter.set(ContentTypes.class.getContentTypes());
 			mstarter.set(Categories.class.getCategories());
 			mstarter.set(FileLoader.class.getFileLoader());
 				mstarter.set(URIGenerator.class.getURIGenerator());
 				mstarter.set(ContentLoader.class.getContentLoader());
 			}
 			this. = mstarter;
 		}
 	}

Returns the module definition.

Returns:
The module definition.
 
 		return ;
 	}

Supplies a dependency to the module.

Parameters:
name Dependency name.
value Dependency value.
Returns:
This object for method chaining.
Throws:
java.lang.NullPointerException if any of the arguments is null.
java.lang.IllegalArgumentException if the dependency has incorrect name or value.
java.lang.IllegalArgumentException if the dependency is an internal dependency.
java.lang.IllegalStateException if the module is already on.
	public ModuleTester<T> put(String nameObject value) {
		.put(namevalue);
		return this;
	}

Starts the module.

Returns:
The started module.
	public T start() {
		if ( == null) {
		}
		return .getModule();
	}

Loads and starts a module with one dependency.

Parameters:
name1 First dependency name.
value1 First dependency value.
Returns:
The started module.
	public T start(String name1Object value1) {
		return put(name1value1).start();
	}

Loads and starts a module with two dependencies.

Parameters:
name1 First dependency name.
value1 First dependency value.
name2 Second dependency name.
value2 Second dependency value.
Returns:
The started module.
	public T start(String name1Object value1String name2Object value2) {
		return put(name1value1).put(name2value2).start();
	}

Loads and starts a module with three dependencies.

Parameters:
name1 First dependency name.
value1 First dependency value.
name2 Second dependency name.
value2 Second dependency value.
Returns:
The started module.
	public T start(String name1Object value1String name2Object value2String name3Object value3) {
		return put(name1value1).put(name2value2).put(name3value3).start();
	}

Loads and starts a module with fake dependencies.

Returns:
The started module.
	public T fakeStart() {
			if (d.isRequired() && !d.isInternal()) {
				put(d.getBeanName(), Proxies.alwaysNull(d.getType()));
			}
		}
		return start();
	}
	private Provision getComponentProvision(final String name) {
		Preconditions.checkNotNull(name);
		final Provision p = .getProvisions().get(name);
		Preconditions.checkArgument(p != null);
		return p;
	}
	private <C extends ComponentComponentTester<C> getComponent(Class<C> typeProvision p) {
		Preconditions.checkNotNull(type);
		Preconditions.checkArgument(p != null);
		Preconditions.checkArgument(type.equals(p.getType()));
		final Object component = .getProvision(p.getBeanName());
		return ComponentTester.of(typetype.cast(component), );
	}

get a component by name of class type

Parameters:
<C> component class type
type class type (must be not null
name component name
Returns:
the component
	public <C extends ComponentComponentTester<C> getComponent(Class<C> typefinal String name) {
		Preconditions.checkNotNull(type);
		final Provision p = getComponentProvision(name);
		return getComponent(typep);
	}

get a component by name as generic subclass of component

Parameters:
name component name
Returns:
the component
	public ComponentTester<?> getComponent(final String name) {
		final Provision p = getComponentProvision(name);
		return getComponent(p.getType().asSubclass(Component.class), p);
	}

Returns an action bean.

Parameters:
name Action name.
Returns:
The requested action.
	public Object getAction(String name) {
		checkState( != null);
		return .getAction(RequestContexts.action(crcnamecrc.getComponentId(), crc.getRoute()));
	}

Returns an action bean.

Parameters:
actionType Action type.
name Action name.
Returns:
The requested action.
	public <A> A getAction(Class<A> actionTypeString name) {
		return actionType.cast(getAction(name));
	}

Returns a connector by name.

Parameters:
name Connector name
Returns:
The requested connector.
	public Object getConnector(final String name) {
		Preconditions.checkState( != null);
		Preconditions.checkNotNull(name);
		return .getProvision(name);
	}

Returns a connector by name and type.

Parameters:
type Connector type.
name Connector name.
Returns:
The requested connector.
	public <C> C getConnector(Class<C> typefinal String name) {
		Preconditions.checkNotNull(type);
		return type.cast(getConnector(name));
	}
New to GrepCode? Check out our FAQ X