<commit_before>package org.springframework.osgi.test.referenceProxy;

import org.osgi.framework.Bundle;
import org.springframework.osgi.ServiceUnavailableException;
import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests;
import org.springframework.osgi.test.reference.proxy.ServiceReferer;
import org.springframework.osgi.test.simpleservice.MyService;

/**
 * @author <NAME> Date: Nov 25, 2006 Time: 12:42:30 PM
 */
public class ReferenceProxyTest extends AbstractConfigurableBundleCreatorTests {

	protected String getManifestLocation() {
		// return
		// "classpath:org/springframework/osgi/test/referenceProxy/ReferenceProxyTest.MF";
		return null;
	}

	protected String[] getBundles() {
		return new String[] {
				localMavenArtifact("org.springframework.osgi", "commons-collections.osgi", "3.2-SNAPSHOT"),
				localMavenArtifact("org.springframework.osgi", "org.springframework.osgi.test.simple.service",
					"1.0-SNAPSHOT"),
				localMavenArtifact("org.springframework.osgi", "org.springframework.osgi.test.reference.proxy",
					"1.0-SNAPSHOT") };
	}

	public void testReferenceProxyLifecycle() throws Exception {
		waitOnContextCreation("org.springframework.osgi.test.simpleservice");
		waitOnContextCreation("org.springframework.osgi.test.reference.proxy");
		MyService reference = ServiceReferer.serviceReference;
		assertNotNull(reference.stringValue());

		Bundle simpleServiceBundle = findBundleBySymbolicName("org.springframework.osgi.test.simpleservice");

		assertNotNull("Cannot find the simple service bundle", simpleServiceBundle);
		System.out.println("stopping bundle");
		simpleServiceBundle.stop();

		while (simpleServiceBundle.getState() == Bundle.STOPPING) {
			System.out.println("waiting for bundle to stop");
			Thread.sleep(10);
		}
		System.out.println("bundle stopped");

		// Service should be unavailable
		try {
			reference.stringValue();
			fail("ServiceUnavailableException should have been thrown!");
		}
		catch (ServiceUnavailableException e) {
			// Expected
		}<commit_msg>+ added a new assertion<commit_after>package org.springframework.osgi.test.referenceProxy;

import org.osgi.framework.Bundle;
import org.springframework.osgi.ServiceUnavailableException;
import org.springframework.osgi.test.AbstractConfigurableBundleCreatorTests;
import org.springframework.osgi.test.reference.proxy.ServiceReferer;
import org.springframework.osgi.test.simpleservice.MyService;

/**
 * @author <NAME> Date: Nov 25, 2006 Time: 12:42:30 PM
 */
public class ReferenceProxyTest extends AbstractConfigurableBundleCreatorTests {

	protected String getManifestLocation() {
		// return
		// "classpath:org/springframework/osgi/test/referenceProxy/ReferenceProxyTest.MF";
		return null;
	}

	protected String[] getBundles() {
		return new String[] {
				localMavenArtifact("org.springframework.osgi", "commons-collections.osgi", "3.2-SNAPSHOT"),
				localMavenArtifact("org.springframework.osgi", "org.springframework.osgi.test.simple.service",
					"1.0-SNAPSHOT"),
				localMavenArtifact("org.springframework.osgi", "org.springframework.osgi.test.reference.proxy",
					"1.0-SNAPSHOT") };
	}

	public void testReferenceProxyLifecycle() throws Exception {
		waitOnContextCreation("org.springframework.osgi.test.simpleservice");
		waitOnContextCreation("org.springframework.osgi.test.reference.proxy");
	
		MyService reference = ServiceReferer.serviceReference;
		
		assertNotNull("reference not initialized", reference);
		assertNotNull("no value specified in the reference", reference.stringValue());

		Bundle simpleServiceBundle = findBundleBySymbolicName("org.springframework.osgi.test.simpleservice");

		assertNotNull("Cannot find the simple service bundle", simpleServiceBundle);
		System.out.println("stopping bundle");
		simpleServiceBundle.stop();

		while (simpleServiceBundle.getState() == Bundle.STOPPING) {
			System.out.println("waiting for bundle to stop");
			Thread.sleep(10);
		}
		System.out.println("bundle stopped");

		// Service should be unavailable
		try {
			reference.stringValue();
			fail("ServiceUnavailableException should have been thrown!");
		}
		catch (ServiceUnavailableException e) {
			// Expected
		}
{'fraction_non_alphanumeric': 0.11750656794841174, 'fraction_numerical': 0.009553379508000955, 'mean_word_length': 5.6265822784810124, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7255823', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1186, 'n_words': 210}