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

com.lordofthejars.nosqlunit.infinispan.EmbeddedInfinispan Maven / Gradle / Ivy

There is a newer version: 1.0.0
Show newest version
package com.lordofthejars.nosqlunit.infinispan;

import org.junit.rules.ExternalResource;

public class EmbeddedInfinispan extends ExternalResource {

	private EmbeddedInfinispan() {
		super();
	}
	
	protected EmbeddedInfinispanLifecycleManager embeddedInfinispanLifecycleManager;
	
	public static class EmbeddedInfinispanRuleBuilder {
		
		private EmbeddedInfinispanLifecycleManager embeddedInfinispanLifecycleManager;
		
		private EmbeddedInfinispanRuleBuilder() {
			this.embeddedInfinispanLifecycleManager = new EmbeddedInfinispanLifecycleManager();
		}
		
		public static EmbeddedInfinispanRuleBuilder newEmbeddedInfinispanRule() {
			return new EmbeddedInfinispanRuleBuilder();
		}
		
		public EmbeddedInfinispanRuleBuilder targetPath(String targetPath) {
			this.embeddedInfinispanLifecycleManager.setTargetPath(targetPath);
			return this;
		}
		
		public EmbeddedInfinispanRuleBuilder configurationFile(String configurationFile) {
			this.embeddedInfinispanLifecycleManager.setConfigurationFile(configurationFile);
			return this;
		}
		
		public EmbeddedInfinispan build() {
			
			if(this.embeddedInfinispanLifecycleManager.getTargetPath() == null) {
				throw new IllegalArgumentException("No Path to Embedded Infinispan is provided.");
			}
			
			EmbeddedInfinispan embeddedInfinispan = new EmbeddedInfinispan();
			embeddedInfinispan.embeddedInfinispanLifecycleManager = this.embeddedInfinispanLifecycleManager;
			
			return embeddedInfinispan;
			
		}
		
	}
	
	@Override
	protected void before() throws Throwable {
		this.embeddedInfinispanLifecycleManager.startEngine();
	}

	@Override
	protected void after() {
		this.embeddedInfinispanLifecycleManager.stopEngine();
	}
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy