PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/plugin-module-codegen-maven-client/src/test/java/com/atlassian/maven/plugins/amps/codegen/prompter/AbstractPrompterTest.java

https://bitbucket.org/mmeinhold/amps
Java | 68 lines | 54 code | 11 blank | 3 comment | 0 complexity | 30ad026d92aecf2f86db7fd088b0320b MD5 | raw file
 1package com.atlassian.maven.plugins.amps.codegen.prompter;
 2
 3import java.io.File;
 4import java.io.IOException;
 5import java.io.InputStream;
 6import java.util.UUID;
 7
 8import com.atlassian.plugins.codegen.modules.PluginModuleLocation;
 9
10import org.apache.commons.io.FileUtils;
11import org.apache.commons.io.IOUtils;
12import org.codehaus.plexus.components.interactivity.Prompter;
13import org.junit.After;
14import org.junit.Before;
15
16import static org.mockito.Mockito.mock;
17
18/**
19 * @since 3.6
20 */
21public abstract class AbstractPrompterTest
22{
23    protected File tempDir;
24    protected File srcDir;
25    protected File testDir;
26    protected File resourcesDir;
27    protected File templateDir;
28    protected File pluginXml;
29    protected PluginModuleLocation moduleLocation;
30    protected Prompter prompter;
31
32    @Before
33    public void setupDirs() throws Exception
34    {
35
36        final File sysTempDir = new File("target");
37        String dirName = UUID.randomUUID()
38                .toString();
39        tempDir = new File(sysTempDir, dirName);
40        srcDir = new File(tempDir, "src");
41        testDir = new File(tempDir, "test-src");
42        resourcesDir = new File(tempDir, "resources");
43        templateDir = new File(resourcesDir, "templates");
44        pluginXml = new File(resourcesDir, "atlassian-plugin.xml");
45
46        tempDir.mkdirs();
47        srcDir.mkdirs();
48        resourcesDir.mkdirs();
49        templateDir.mkdirs();
50
51        InputStream is = this.getClass()
52                .getResourceAsStream("/empty-plugin.xml");
53        IOUtils.copy(is, FileUtils.openOutputStream(pluginXml));
54
55        moduleLocation = new PluginModuleLocation.Builder(srcDir)
56                .resourcesDirectory(resourcesDir)
57                .testDirectory(testDir)
58                .templateDirectory(templateDir)
59                .build();
60        prompter = mock(Prompter.class);
61    }
62
63    @After
64    public void removeTempDir() throws IOException
65    {
66        FileUtils.deleteQuietly(tempDir);
67    }
68}