<commit_before>package test;

import java.io.*;
import java.util.*;
import java.util.jar.*;

import junit.framework.*;
import aQute.bnd.build.*;
import aQute.bnd.osgi.*;
import aQute.bnd.osgi.eclipse.*;
import aQute.bnd.service.*;
import aQute.bnd.version.*;
import aQute.lib.deployer.*;
import aQute.lib.io.*;

public class ProjectTest extends TestCase {
	<commit_msg>Added test case for checking last Bnd-Lastmodified<commit_after>package test;

import java.io.*;
import java.util.*;
import java.util.jar.*;

import junit.framework.*;
import aQute.bnd.build.*;
import aQute.bnd.osgi.*;
import aQute.bnd.osgi.eclipse.*;
import aQute.bnd.service.*;
import aQute.bnd.version.*;
import aQute.lib.deployer.*;
import aQute.lib.io.*;

public class ProjectTest extends TestCase {
	
	/**
	 * Two subsequent builds should not change the last modified if none of
	 * the source inputs have been modified. 
	 * 
	 * @throws Exception
	 */
	public static void testLastModified() 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();
			assertTrue(project.check());
			assertNotNull(files);
			assertEquals(1, files.length);

			Jar older = new Jar(files[0]);
			String lastmodified = older.getManifest().getMainAttributes().getValue(Constants.BND_LASTMODIFIED);
			older.close();
			
			Thread.sleep(3000); // Ensure system time granularity is < than wait

			files[0].delete();
			
			project.build();
			assertTrue(project.check());
			assertNotNull(files);
			assertEquals(1, files.length);
			
			Jar newer = new Jar(files[0]);
			String lastmodifiedn = newer.getManifest().getMainAttributes().getValue(Constants.BND_LASTMODIFIED);
			newer.close();
			
			assertEquals(lastmodified,lastmodifiedn);
		}
		finally {
			project.clean();
		}
	}
	
{'fraction_non_alphanumeric': 0.14523809523809525, 'fraction_numerical': 0.005238095238095238, 'mean_word_length': 3.966903073286052, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6073868', 'n_tokens_mistral': 751, 'n_tokens_neox': 672, 'n_words': 161}