// Path: src/main/java/pl/domzal/junit/docker/rule/ex/InvalidVolumeFrom.java
// public class InvalidVolumeFrom extends IllegalStateException {
// 
//     public InvalidVolumeFrom(String message) {
//         super(message);
//     }
// 
// }


import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.DockerClient.LogsParam;
import com.spotify.docker.client.LogStream;
import pl.domzal.junit.docker.rule.ex.InvalidVolumeFrom;
        testFilename = testFile.getName();
        try (Writer out = new FileWriter(testFile)) {
            IOUtils.write(testFileContent, out);
        }
        testDir = tempFolder.getRoot();
        log.debug("testDir: {}", testDir.getAbsolutePath());
        testDirPath = DockerRuleMountBuilder.toUnixStylePath(testDir.getAbsolutePath());
        log.debug("testDirPath: {}", testDirPath);
    }

    private DockerRule testee;

    @After
    public void tearDown() {
        // make sure testee will bee cleaned up after test cases
        // commit tear down is more convienient than 'try {} finally in every test case'
        if (testee != null) {
            testee.after();
        }
    }

    @Test
    public void shouldFailWhenMountFromDoesNotExist() {
        try {
            File nonexistingHostDir = testDir.toPath().resolve("nonexisting").toFile();
            log.debug("mountFrom: "+nonexistingHostDir.getAbsolutePath());
            testee = DockerRule.builder()//
                    .imageName("busybox:1.25.1")//
                    .mountFrom(nonexistingHostDir).to("/somedir", "ro")//
                    .build();
// Path: src/main/java/pl/domzal/junit/docker/rule/ex/InvalidVolumeFrom.java
// public class InvalidVolumeFrom extends IllegalStateException {
// 
//     public InvalidVolumeFrom(String message) {
//         super(message);
//     }
// 
// }


// Path: src/test/java/pl/domzal/junit/docker/rule/DockerRuleVolumeMountTest.java
import static org.hamcrest.CoreMatchers.containsString;
import static org.junit.Assert.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.spotify.docker.client.DockerClient;
import com.spotify.docker.client.DockerClient.LogsParam;
import com.spotify.docker.client.LogStream;
import pl.domzal.junit.docker.rule.ex.InvalidVolumeFrom;

        testFilename = testFile.getName();
        try (Writer out = new FileWriter(testFile)) {
            IOUtils.write(testFileContent, out);
        }
        testDir = tempFolder.getRoot();
        log.debug("testDir: {}", testDir.getAbsolutePath());
        testDirPath = DockerRuleMountBuilder.toUnixStylePath(testDir.getAbsolutePath());
        log.debug("testDirPath: {}", testDirPath);
    }

    private DockerRule testee;

    @After
    public void tearDown() {
        // make sure testee will bee cleaned up after test cases
        // commit tear down is more convienient than 'try {} finally in every test case'
        if (testee != null) {
            testee.after();
        }
    }

    @Test
    public void shouldFailWhenMountFromDoesNotExist() {
        try {
            File nonexistingHostDir = testDir.toPath().resolve("nonexisting").toFile();
            log.debug("mountFrom: "+nonexistingHostDir.getAbsolutePath());
            testee = DockerRule.builder()//
                    .imageName("busybox:1.25.1")//
                    .mountFrom(nonexistingHostDir).to("/somedir", "ro")//
                    .build();
            fail("should fail with "+InvalidVolumeFrom.class.getSimpleName());