org.junitpioneer.jupiter.resource.ResourceFactory Maven / Gradle / Ivy
/*
* Copyright 2016-2022 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at
*
* http://www.eclipse.org/legal/epl-v20.html
*/
package org.junitpioneer.jupiter.resource;
import java.util.List;
import org.junit.jupiter.api.extension.ExtensionContext;
/**
* {@code ResourceFactory} is the common interface for "resource factories", which are responsible
* for creating {@link Resource}s.
*
* It is part of the "resources" JUnit Jupiter extension, which pertains to anything that needs
* to be injected into tests and which may need to be started up or torn down. Temporary
* directories are a common example.
*
*
This class is intended for implementors of new kinds of resources.
*
* For more details and examples, see
* the documentation on resources.
*
* @param the type of the resources created by the resource factory
* @since 1.9.0
* @see Resource
*/
public interface ResourceFactory extends ExtensionContext.Store.CloseableResource {
/**
* Returns a new resource.
*
* @param arguments a list of strings to be used to populate or configure the resource
* @throws Exception if creating the resource failed
*/
Resource create(List arguments) throws Exception;
/**
* Closes the resource factory.
*
* @throws Exception if closing the resource factory failed
*/
@Override
default void close() throws Exception {
// no op by default
}
}