Beispiel #1
0
 private void checkExecute() throws IOException {
   context.checking(
       new Expectations() {
         {
           one(wrapperScriptGeneratorMock)
               .generate(
                   targetWrapperJarPath + "/" + Wrapper.WRAPPER_JAR,
                   targetWrapperJarPath + "/" + Wrapper.WRAPPER_PROPERTIES,
                   new File(getProject().getProjectDir(), wrapper.getScriptDestinationPath()));
         }
       });
   wrapper.execute();
   TestFile unjarDir = tmpDir.createDir("unjar");
   expectedTargetWrapperJar.unzipTo(unjarDir);
   unjarDir.file(GradleWrapperMain.class.getName().replace(".", "/") + ".class").assertIsFile();
   Properties properties = GUtil.loadProperties(expectedTargetWrapperProperties);
   assertEquals(properties.getProperty(Wrapper.URL_ROOT_PROPERTY), wrapper.getUrlRoot());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_BASE_PROPERTY),
       wrapper.getDistributionBase().toString());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_PATH_PROPERTY), wrapper.getDistributionPath());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_NAME_PROPERTY), wrapper.getArchiveName());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_CLASSIFIER_PROPERTY),
       wrapper.getArchiveClassifier());
   assertEquals(
       properties.getProperty(Wrapper.DISTRIBUTION_VERSION_PROPERTY), wrapper.getGradleVersion());
   assertEquals(
       properties.getProperty(Wrapper.ZIP_STORE_BASE_PROPERTY),
       wrapper.getArchiveBase().toString());
   assertEquals(properties.getProperty(Wrapper.ZIP_STORE_PATH_PROPERTY), wrapper.getArchivePath());
 }
Beispiel #2
0
 @Test
 public void testWrapper() {
   wrapper = createTask(Wrapper.class);
   assertEquals("", wrapper.getJarPath());
   assertEquals("", wrapper.getScriptDestinationPath());
   assertEquals(Wrapper.DEFAULT_DISTRIBUTION_PARENT_NAME, wrapper.getDistributionPath());
   assertEquals(Wrapper.DEFAULT_ARCHIVE_NAME, wrapper.getArchiveName());
   assertEquals(Wrapper.DEFAULT_ARCHIVE_CLASSIFIER, wrapper.getArchiveClassifier());
   assertEquals(Wrapper.DEFAULT_DISTRIBUTION_PARENT_NAME, wrapper.getArchivePath());
   assertEquals(Wrapper.DEFAULT_URL_ROOT, wrapper.getUrlRoot());
   assertEquals(Wrapper.PathBase.GRADLE_USER_HOME, wrapper.getDistributionBase());
   assertEquals(Wrapper.PathBase.GRADLE_USER_HOME, wrapper.getArchiveBase());
 }
Beispiel #3
0
 @Before
 public void setUp() {
   super.setUp();
   context.setImposteriser(ClassImposteriser.INSTANCE);
   wrapper = createTask(Wrapper.class);
   wrapperScriptGeneratorMock = context.mock(WrapperScriptGenerator.class);
   wrapper.setScriptDestinationPath("scriptDestination");
   wrapper.setGradleVersion("1.0");
   targetWrapperJarPath = "jarPath";
   expectedTargetWrapperJar =
       new TestFile(
           getProject().getProjectDir(), targetWrapperJarPath + "/" + Wrapper.WRAPPER_JAR);
   expectedTargetWrapperProperties =
       new File(
           getProject().getProjectDir(), targetWrapperJarPath + "/" + Wrapper.WRAPPER_PROPERTIES);
   new File(getProject().getProjectDir(), targetWrapperJarPath).mkdirs();
   distributionPath = "somepath";
   wrapper.setJarPath(targetWrapperJarPath);
   wrapper.setDistributionPath(distributionPath);
   wrapper.setUnixWrapperScriptGenerator(wrapperScriptGeneratorMock);
 }
Beispiel #4
0
 @Test
 public void testCheckInputs() throws IOException {
   assertThat(
       wrapper.getInputs().getProperties().keySet(),
       equalTo(
           WrapUtil.toSet(
               "jarPath",
               "archiveClassifier",
               "distributionBase",
               "archiveBase",
               "distributionPath",
               "archiveName",
               "urlRoot",
               "scriptDestinationPath",
               "gradleVersion",
               "archivePath")));
 }