<commit_before>
package org.osgi.test.cases.enocean;

import org.osgi.framework.ServiceReference;
import org.osgi.service.enocean.EnOceanDevice;
import org.osgi.test.cases.enocean.messages.MessageExample1;
import org.osgi.test.cases.enocean.serial.EspRadioPacket;
import org.osgi.test.cases.enocean.utils.Fixtures;
import org.osgi.test.cases.enocean.utils.Logger;

/**
 * This class contains:
 * 
 * - testAutoDeviceRegistration, tests initial, and automatic device
 * registration from a raw Radio teach-in packet that is triggered through the
 * step service.
 * 
 * @author $Id$
 */
public class RegistrationTestCase extends AbstractEnOceanTestCase {

	/**
	 * Tests initial device registration from a raw Radio teach-in packet.
	 * 
	 * @throws Exception
	 */
	public void testAutoDeviceRegistration() throws Exception {

		/* Insert a device */
		MessageExample1 teachIn = MessageExample1.generateTeachInMsg(Fixtures.HOST_ID, Fixtures.MANUFACTURER);
		EspRadioPacket pkt = new EspRadioPacket(teachIn);
		// Push everything in the command...
		String[] params = {new String(pkt.serialize())};
		testStepService.execute("MessageExample1", params);

		// Device added
		String lastServiceEvent = devices.waitForService();
		Logger.d("Device added, lastServiceEvent: " + lastServiceEvent);
		assertNotNull("Timeout reached.", lastServiceEvent);
		assertNotNull("Timeout reached.", lastServiceEvent);
		// Device modified (profile)
		lastServiceEvent = devices.waitForService();
		Logger.d("Device modified (profile), lastServiceEvent: " + lastServiceEvent);
		assertNotNull("Timeout reached.", lastServiceEvent);

		/*
		 * NOTE: The service should have been modified AFTER insertion,
		 * nevertheless it seems that when registration and modification happen
		 * almost in the same time, OSGi only generates a single SERVICE_ADDED
		 * event.
		 */
		ServiceReference ref = devices.getServiceReference();

		/*
		 * Verify that the device has been registered with the correct service
		 * properties
		 */
		assertEquals("category mismatch", EnOceanDevice.DEVICE_CATEGORY, ref.getProperty(org.osgi.service.device.Constants.DEVICE_CATEGORY));
		assertEquals("CHIP_ID mismatch", Fixtures.STR_HOST_ID, ref.getProperty(EnOceanDevice.CHIP_ID));
		assertEquals("RORG mismatch", Fixtures.STR_RORG, ref.getProperty(EnOceanDevice.RORG));
		assertEquals("FUNC mismatch", Fixtures.STR_FUNC, ref.getProperty(EnOceanDevice.FUNC));
		assertEquals("TYPE mismatch", Fixtures.STR_TYPE_1, ref.getProperty(EnOceanDevice.TYPE));
		assertEquals("MANUFACTURER mismatch", Fixtures.STR_MANUFACTURER, ref.getProperty(EnOceanDevice.MANUFACTURER));

		getContext().ungetService(ref);
	}
}
<commit_msg>RFC199: Remove a duplicated assert.<commit_after>
package org.osgi.test.cases.enocean;

import org.osgi.framework.ServiceReference;
import org.osgi.service.enocean.EnOceanDevice;
import org.osgi.test.cases.enocean.messages.MessageExample1;
import org.osgi.test.cases.enocean.serial.EspRadioPacket;
import org.osgi.test.cases.enocean.utils.Fixtures;
import org.osgi.test.cases.enocean.utils.Logger;

/**
 * This class contains:
 * 
 * - testAutoDeviceRegistration, tests initial, and automatic device
 * registration from a raw Radio teach-in packet that is triggered through the
 * step service.
 * 
 * @author $Id$
 */
public class RegistrationTestCase extends AbstractEnOceanTestCase {

	/**
	 * Tests initial device registration from a raw Radio teach-in packet.
	 * 
	 * @throws Exception
	 */
	public void testAutoDeviceRegistration() throws Exception {

		/* Insert a device */
		MessageExample1 teachIn = MessageExample1.generateTeachInMsg(Fixtures.HOST_ID, Fixtures.MANUFACTURER);
		EspRadioPacket pkt = new EspRadioPacket(teachIn);
		// Push everything in the command...
		String[] params = {new String(pkt.serialize())};
		testStepService.execute("MessageExample1", params);

		// Device added
		String lastServiceEvent = devices.waitForService();
		Logger.d("Device added, lastServiceEvent: " + lastServiceEvent);
		assertNotNull("Timeout reached.", lastServiceEvent);

		// Device modified (profile)
		lastServiceEvent = devices.waitForService();
		Logger.d("Device modified (profile), lastServiceEvent: " + lastServiceEvent);
		assertNotNull("Timeout reached.", lastServiceEvent);

		/*
		 * NOTE: The service should have been modified AFTER insertion,
		 * nevertheless it seems that when registration and modification happen
		 * almost in the same time, OSGi only generates a single SERVICE_ADDED
		 * event.
		 */
		ServiceReference ref = devices.getServiceReference();

		/*
		 * Verify that the device has been registered with the correct service
		 * properties
		 */
		assertEquals("category mismatch", EnOceanDevice.DEVICE_CATEGORY, ref.getProperty(org.osgi.service.device.Constants.DEVICE_CATEGORY));
		assertEquals("CHIP_ID mismatch", Fixtures.STR_HOST_ID, ref.getProperty(EnOceanDevice.CHIP_ID));
		assertEquals("RORG mismatch", Fixtures.STR_RORG, ref.getProperty(EnOceanDevice.RORG));
		assertEquals("FUNC mismatch", Fixtures.STR_FUNC, ref.getProperty(EnOceanDevice.FUNC));
		assertEquals("TYPE mismatch", Fixtures.STR_TYPE_1, ref.getProperty(EnOceanDevice.TYPE));
		assertEquals("MANUFACTURER mismatch", Fixtures.STR_MANUFACTURER, ref.getProperty(EnOceanDevice.MANUFACTURER));

		getContext().ungetService(ref);
	}
}

{'fraction_non_alphanumeric': 0.10582706766917294, 'fraction_numerical': 0.002443609022556391, 'mean_word_length': 5.237983587338804, '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': '1093365', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1511, 'n_words': 365}