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

net.stickycode.mockwire.junit4.MockwireContainerLifecycleStatement Maven / Gradle / Ivy

There is a newer version: 2.5
Show newest version
package net.stickycode.mockwire.junit4;

import org.junit.runners.model.Statement;

import net.stickycode.mockwire.MockwireContainer;

final class MockwireContainerLifecycleStatement
    extends Statement {

  private final MockwireContainer container;

  private final Statement wrappedStatement;

  MockwireContainerLifecycleStatement(MockwireContainer container, Statement block) {
    this.container = container;
    this.wrappedStatement = block;
  }

  @Override
  public void evaluate()
      throws Throwable {
    startup();
    try {
      wrappedStatement.evaluate();
    }
    finally {
      shutdown();
    }
  }

  private void shutdown()
      throws AssertionError {
    try {
      container.shutdown();
    }
    catch (Throwable t) {
      throw new AssertionError(t);
    }
  }

  private void startup()
      throws AssertionError {
    try {
      container.startup();
    }
    catch (Throwable t) {
      throw new AssertionError(t);
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy