Thrift { public int compile() throws CommandLineException { for (File thriftFile : thriftFiles) { Commandline cl = new Commandline(); cl.setExecutable(executable); cl.addArguments(buildThriftCommand(thriftFile).toArray(new String[]{})); final int result = CommandLineUtils.executeCommandLine(cl, null, output, error); if (result != 0) { return result; } } return 0; } private  Thrift(String executable, String generator, ImmutableSet<File> thriftPath,
                   ImmutableSet<File> thriftFiles, File javaOutputDirectory); int compile(); String getOutput(); String getError();  }
@Test public void testThriftMultipleFileCompile() throws Exception { final File sharedThrift = new File(idlDir, "shared.thrift"); final File tutorialThrift = new File(idlDir, "tutorial.thrift"); builder.addThriftFile(sharedThrift); builder.addThriftFile(tutorialThrift); final Thrift thrift = builder.build(); assertTrue("File not found: shared.thrift", sharedThrift.exists()); assertFalse("gen-java directory should not exist", genJavaDir.exists()); final int result = thrift.compile(); assertEquals(0, result); assertFalse("gen-java directory was not removed", genJavaDir.exists()); assertTrue("generated java code doesn't exist", new File(testRootDir, "shared/SharedService.java").exists()); assertTrue("generated java code doesn't exist", new File(testRootDir, "tutorial/InvalidOperation.java").exists()); }
@Test public void testBadCompile() throws Exception { final File thriftFile = new File(testRootDir, "missing.thrift"); builder.addThriftPathElement(testRootDir); assertTrue(thriftFile.createNewFile()); builder.addThriftFile(thriftFile); assertTrue(thriftFile.delete()); final Thrift thrift = builder.build(); assertTrue(!thriftFile.exists()); assertFalse("gen-java directory should not exist", genJavaDir.exists()); final int result = thrift.compile(); assertEquals(1, result); }