<commit_before>package test;

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

import aQute.bnd.header.*;
import aQute.bnd.osgi.*;
import aQute.bnd.osgi.Descriptors.PackageRef;
import aQute.bnd.test.*;
import aQute.lib.collections.*;

class T0 {}

abstract class T1 extends T0 {}

class T2 extends T1 {}

class T3 extends T2 {}

public class AnalyzerTest extends BndTestCase {
	
	
	/**
	 * Check if bnd detects references to private packages and 
	 * gives a warning.
	 */

	public void testExportReferencesToPrivatePackages2() throws Exception {
		Builder b = new Builder();
		b.addClasspath(new File("../biz.aQute.bndlib/bin"));
		b.setExportPackage("aQute.bnd.signing"); // refers to Event Admin
		b.setConditionalPackage("aQute.lib*");
		Jar jar = b.build();
		assertTrue(b.check());//"((, )?(org.osgi.service.event|org.osgi.service.component|org.osgi.service.http|org.osgi.service.log|org.osgi.service.condpermadmin|org.osgi.service.wireadmin|org.osgi.service.device)){7,7}"));
	}
	/**
	 * Check if bnd detects references to private packages and 
	 * gives a warning.
	 */

	public void testExportReferencesToPrivatePackages() throws Exception {
		Builder b = new Builder();
		b.addClasspath(new File("jar/osgi.jar"));
		b.addClasspath(new File("bin"));
		b.setExportPackage("test.referApi"); // refers to Event Admin
		b.setConditionalPackage("org.osgi.service.*");
		Jar jar = b.build();
		assertTrue(b.check("((, )?(org.osgi.service.event|org.osgi.service.component|org.osgi.service.http|org.osgi.service.log|org.osgi.service.condpermadmin|org.osgi.service.wireadmin|org.osgi.service.device)){7,7}"));
	}


	/**<commit_msg>Show that you can use -removeheaders to create a whitelist<commit_after>package test;

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

import aQute.bnd.header.*;
import aQute.bnd.osgi.*;
import aQute.bnd.osgi.Descriptors.PackageRef;
import aQute.bnd.test.*;
import aQute.lib.collections.*;

class T0 {}

abstract class T1 extends T0 {}

class T2 extends T1 {}

class T3 extends T2 {}

public class AnalyzerTest extends BndTestCase {

	/**
	 * The -removeheaders header can be used as a whitelist.
	 */

	public void testRemoveheadersAsWhiteList() throws Exception {
		Builder b = new Builder();
		b.addClasspath(new File("jar/asm.jar"));
		b.setExportPackage("*");
		b.setImportPackage("something");
		b.set("Foo", "Foo");
		b.set("Bar", "Bar");
		b.set(Constants.REMOVEHEADERS, "!Bundle-*,!*-Package,!Service-Component,*");
		b.build();
		assertTrue(b.check());
		Manifest m = b.getJar().getManifest();

		assertNotNull(m.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION));
		assertNotNull(m.getMainAttributes().getValue(Constants.BUNDLE_NAME));
		assertNotNull(m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME));
		assertNotNull(m.getMainAttributes().getValue(Constants.IMPORT_PACKAGE));
		assertNotNull(m.getMainAttributes().getValue(Constants.EXPORT_PACKAGE));
		assertNull(m.getMainAttributes().getValue("Foo"));
		assertNull(m.getMainAttributes().getValue("Bar"));
	}

	/**
	 * Check if bnd detects references to private packages and gives a warning.
	 */

	public void testExportReferencesToPrivatePackages2() throws Exception {
		Builder b = new Builder();
		b.addClasspath(new File("../biz.aQute.bndlib/bin"));
		b.setExportPackage("aQute.bnd.signing"); // refers to Event Admin
		b.setConditionalPackage("aQute.lib*");
		Jar jar = b.build();
		assertTrue(b.check());// "((, )?(org.osgi.service.event|org.osgi.service.component|org.osgi.service.http|org.osgi.service.log|org.osgi.service.condpermadmin|org.osgi.service.wireadmin|org.osgi.service.device)){7,7}"));
	}

	/**
	 * Check if bnd detects references to private packages and gives a warning.
	 */

	public void testExportReferencesToPrivatePackages() throws Exception {
		Builder b = new Builder();
		b.addClasspath(new File("jar/osgi.jar"));
		b.addClasspath(new File("bin"));
		b.setExportPackage("test.referApi"); // refers to Event Admin
		b.setConditionalPackage("org.osgi.service.*");
		Jar jar = b.build();
		assertTrue(b
				.check("((, )?(org.osgi.service.event|org.osgi.service.component|org.osgi.service.http|org.osgi.service.log|org.osgi.service.condpermadmin|org.osgi.service.wireadmin|org.osgi.service.device)){7,7}"));
	}

	/**
{'fraction_non_alphanumeric': 0.16068933395435492, 'fraction_numerical': 0.0055891942244993015, 'mean_word_length': 4.883561643835616, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5621953', 'n_tokens_mistral': 1518, 'n_tokens_neox': 1443, 'n_words': 266}