Exemplo n.º 1
0
  void setUpMocksAndAttributes(GroovyCompile compile, final boolean groovyClasspathEmpty) {
    super.setUpMocksAndAttributes(compile);

    final FileCollection groovyClasspathCollection = context.mock(FileCollection.class);
    context.checking(
        new Expectations() {
          {
            allowing(groovyClasspathCollection).isEmpty();
            will(returnValue(groovyClasspathEmpty));
          }
        });

    compile.setGroovyClasspath(groovyClasspathCollection);
    compile.source(srcDir);
  }
Exemplo n.º 2
0
  @Before
  public void setUp() {
    testObj = createTask(GroovyCompile.class);
    groovyCompilerMock = context.mock(Compiler.class);
    testObj.setCompiler(groovyCompilerMock);

    GFileUtils.touch(new File(srcDir, "incl/file.groovy"));
  }
Exemplo n.º 3
0
 @Test
 public void testMoansIfGroovyClasspathIsEmpty() {
   setUpMocksAndAttributes(testObj, true);
   try {
     testObj.compile();
     fail();
   } catch (InvalidUserDataException e) {
     assertThat(e.getMessage(), containsString("'testTask.groovyClasspath' must not be empty."));
   }
 }
Exemplo n.º 4
0
  public void testExecute(final int numFilesCompiled) {
    setUpMocksAndAttributes(testObj, false);
    context.checking(
        new Expectations() {
          {
            WorkResult result = context.mock(WorkResult.class);

            one(groovyCompilerMock)
                .execute((GroovyJavaJointCompileSpec) with(IsNull.notNullValue()));
            will(returnValue(result));
            allowing(result).getDidWork();
            will(returnValue(numFilesCompiled > 0));
          }
        });

    testObj.compile();
  }
Exemplo n.º 5
0
 @Test
 public void testExecuteNotDoingWork() {
   testExecute(0);
   assertFalse(testObj.getDidWork());
 }
Exemplo n.º 6
0
 @Test
 public void testExecuteDoingWork() {
   testExecute(7);
   assertTrue(testObj.getDidWork());
 }