/**
 * Copyright (c) 2010-2015, openHAB.org and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 */
package org.openhab.binding.exec.internal;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;
import org.openhab.binding.exec.internal.ExecGenericBindingProvider.ExecBindingConfig;
import org.openhab.core.library.items.SwitchItem;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.StringType;
import org.openhab.model.item.binding.BindingConfigParseException;


/**
 * @author Thomas.Eichstaedt-Engelen
 * @since 0.6.0
 */
public class ExecGenericBindingProviderTest {
	
	private ExecGenericBindingProvider provider;
	
	@Before
	public void init() {
		provider = new ExecGenericBindingProvider();
	}

	@Test
	public void testParseBindingConfig() throws BindingConfigParseException {
		ExecBindingConfig config = new ExecGenericBindingProvider.ExecBindingConfig();
		String bindingConfig = "ON:some command to execute, OFF: 'other command with comma\\, and \\'quotes\\' and slashes \\\\ ', *:and a fallback";
		SwitchItem item = new SwitchItem("");
		
		provider.parseLegacyOutBindingConfig(item, bindingConfig, config);
		
		Assert.assertEquals(3, config.size());
		Assert.assertEquals("some command to execute", config.get(OnOffType.ON).commandLine);
		Assert.assertEquals("other command with comma, and 'quotes' and slashes \\ ", config.get(OnOffType.OFF).commandLine);
		Assert.assertEquals("and a fallback", config.get(StringType.valueOf("*")).commandLine);
	}

}

@@ -346,16 +346,39 @@
 ernal;%0A%0A
+import java.util.List;%0A
 import j
@@ -1758,10 +1758,771 @@
 e);%0A%09%7D%0A%0A
+%09@Test%0A%09public void testParseBindingConfigIn() throws BindingConfigParseException %7B%0A%09%09String     cmdLine = %22/usr/bin/uptime%22;%0A%09%09String     itemName = %22Switch%22;%0A%09%09SwitchItem item = new SwitchItem(itemName);%0A%09%09String     bindingConfig = %22%3C%5B%22 + cmdLine + %22:60000:%5D%22;%0A%0A%09%09provider.processBindingConfiguration(%22New%22, item, bindingConfig);%0A%0A%09%09Assert.assertTrue(provider.providesBinding());%0A%09%09Assert.assertTrue(provider.providesBindingFor(itemName));%0A%09%09Assert.assertEquals(cmdLine, provider.getCommandLine(itemName));%0A%0A%09%09Assert.assertEquals(60000, provider.getRefreshInterval(itemName));%0A%09%09Assert.assertEquals(%22%22, provider.getTransformation(itemName));%0A%0A%09%09List%3CString%3E itemNames = provider.getInBindingItemNames();%0A%09%09Assert.assertEquals(itemName, itemNames.get(0));%0A%09%7D%0A
 %7D%0A

Add a test for parsing exec binding IN config