/** Check if the getSubBuilders properly predicts the output. */ public static void testSubBuilders() throws Exception { Workspace ws = Workspace.getWorkspace(new File("test/ws")); Project project = ws.getProject("p4-sub"); Collection<? extends Builder> bs = project.getSubBuilders(); assertNotNull(bs); assertEquals(3, bs.size()); Set<String> names = new HashSet<String>(); for (Builder b : bs) { names.add(b.getBsn()); } assertTrue(names.contains("p4-sub.a")); assertTrue(names.contains("p4-sub.b")); assertTrue(names.contains("p4-sub.c")); File[] files = project.build(); assertTrue(project.check()); System.err.println(Processor.join(project.getErrors(), "\n")); System.err.println(Processor.join(project.getWarnings(), "\n")); assertEquals(0, project.getErrors().size()); assertEquals(0, project.getWarnings().size()); assertNotNull(files); assertEquals(3, files.length); for (File file : files) { Jar jar = new Jar(file); Manifest m = jar.getManifest(); assertTrue(names.contains(m.getMainAttributes().getValue("Bundle-SymbolicName"))); } }
/** * Tests the handling of the -sub facility * * @throws Exception */ public static void testSub() throws Exception { Workspace ws = Workspace.getWorkspace(new File("test/ws")); Project project = ws.getProject("p4-sub"); File[] files = project.build(); Arrays.sort(files); System.err.println(Processor.join(project.getErrors(), "\n")); System.err.println(Processor.join(project.getWarnings(), "\n")); assertEquals(0, project.getErrors().size()); assertEquals(0, project.getWarnings().size()); assertNotNull(files); assertEquals(3, files.length); Jar a = new Jar(files[0]); Jar b = new Jar(files[1]); Manifest ma = a.getManifest(); Manifest mb = b.getManifest(); assertEquals("base", ma.getMainAttributes().getValue("Base-Header")); assertEquals("base", mb.getMainAttributes().getValue("Base-Header")); assertEquals("a", ma.getMainAttributes().getValue("Sub-Header")); assertEquals("b", mb.getMainAttributes().getValue("Sub-Header")); }
public static void testOutofDate() throws Exception { Workspace ws = Workspace.getWorkspace(new File("test/ws")); Project project = ws.getProject("p3"); File bnd = new File("test/ws/p3/bnd.bnd"); assertTrue(bnd.exists()); project.clean(); File pt = project.getTarget(); if (!pt.exists() && !pt.mkdirs()) { throw new IOException("Could not create directory " + pt); } try { // Now we build it. File[] files = project.build(); System.err.println(project.getErrors()); System.err.println(project.getWarnings()); assertTrue(project.isOk()); assertNotNull(files); assertEquals(1, files.length); // Now we should not rebuild it long lastTime = files[0].lastModified(); files = project.build(); assertEquals(1, files.length); assertTrue(files[0].lastModified() == lastTime); Thread.sleep(2000); project.updateModified(System.currentTimeMillis(), "Testing"); files = project.build(); assertEquals(1, files.length); assertTrue("Must have newer files now", files[0].lastModified() > lastTime); } finally { project.clean(); } }