/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

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