import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import junit.framework.TestCase; /** * * @author pzajac */ public class UpdateFeatureDepsTest extends TestCase { public UpdateFeatureDepsTest(String testName) { super(testName); } public void testupdateProjectXml() throws IOException { File projectFile = copyFileToTmp("project.xml"); File nbmFile = copyFileToTmp("test.nbm"); UpdateFeatureDeps task = new UpdateFeatureDeps(); task.setProjectXml(projectFile); task.setNbmFolder(getTmpFolder()); task.execute(); } private File getTmpFolder() { File dir = new File("/tmp/UpdateFeatureDepsTest"); dir.mkdirs(); return dir; } File copyFileToTmp(String name) throws IOException { InputStream is = getClass().getResourceAsStream(name); File file = new File(getTmpFolder(),name); FileOutputStream fos = new FileOutputStream(file); try { byte buffer[] = new byte[10000]; while (true) { int size = is.read(buffer); if (size < 1) { break; } fos.write(buffer, 0, size); } } finally { fos.close(); is.close(); } return file; } // TODO add test methods here. The name must begin with 'test'. For example: // public void testHello() {} }