/** * Gets a list from a comma separated property with support for overrides, defaulting to Append behavior * * @param property the property * @return the list */ public List<String> getConfigList( String property ) { return getConfigList( property, ListOverrideType.APPEND ); }
@Test public void testGetConfigListReplaceWithNoRootConfig() { List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); assertEquals( new ArrayList<String>(), shimProperties.getConfigList( "propName", ListOverrideType.REPLACE ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( shimConfig, shimProperties.getConfigList( "propName", ListOverrideType.REPLACE ) ); }
@Test public void testGetConfigListAppendWithNoShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); assertEquals( rootConfig, shimProperties.getConfigList( "propName", ListOverrideType.APPEND ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( rootConfig, shimProperties.getConfigList( "propName", ListOverrideType.APPEND ) ); }
@Test public void testGetConfigListPrependWithNoRootConfig() { List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); assertEquals( new ArrayList<String>(), shimProperties.getConfigList( "propName", ListOverrideType.PREPEND ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( shimConfig, shimProperties.getConfigList( "propName", ListOverrideType.PREPEND ) ); }
@Test public void testGetConfigListAppendWithNoRootConfig() { List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); assertEquals( new ArrayList<String>(), shimProperties.getConfigList( "propName", ListOverrideType.APPEND ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( shimConfig, shimProperties.getConfigList( "propName", ListOverrideType.APPEND ) ); }
@Test public void testGetConfigListReplaceWithNoShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); assertEquals( rootConfig, shimProperties.getConfigList( "propName", ListOverrideType.REPLACE ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( rootConfig, shimProperties.getConfigList( "propName", ListOverrideType.REPLACE ) ); }
@Test public void testGetConfigListPrependWithNoShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); assertEquals( rootConfig, shimProperties.getConfigList( "propName", ListOverrideType.PREPEND ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( rootConfig, shimProperties.getConfigList( "propName", ListOverrideType.PREPEND ) ); }
@Test public void testGetConfigListAppendWithShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); List<String> combinedList = new ArrayList<String>( rootConfig ); combinedList.addAll( shimConfig ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( combinedList, shimProperties.getConfigList( "propName", ListOverrideType.APPEND ) ); }
@Test public void testGetConfigListDefaultsToAppend() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); List<String> combinedList = new ArrayList<String>( rootConfig ); combinedList.addAll( shimConfig ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( combinedList, shimProperties.getConfigList( "propName" ) ); }
@Test public void testGetConfigListPrependWithShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); List<String> combinedList = new ArrayList<String>( shimConfig ); combinedList.addAll( rootConfig ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( combinedList, shimProperties.getConfigList( "propName", ListOverrideType.PREPEND ) ); }
@Test public void testGetConfigListAppendWith2ShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); List<String> shimConfig2 = new ArrayList<String>( Arrays.asList( "3", "cee", "p", "o" ) ); List<String> combinedList = new ArrayList<String>( rootConfig ); combinedList.addAll( shimConfig ); combinedList.addAll( shimConfig2 ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); shimProperties.setProperty( "hbase.propName", join( ",", shimConfig2 ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1,hbase" ); assertEquals( combinedList, shimProperties.getConfigList( "propName", ListOverrideType.APPEND ) ); }
@Test public void testGetConfigListPrependWith2ShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); List<String> shimConfig2 = new ArrayList<String>( Arrays.asList( "3", "cee", "p", "o" ) ); List<String> combinedList = new ArrayList<String>( shimConfig2 ); combinedList.addAll( shimConfig ); combinedList.addAll( rootConfig ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); shimProperties.setProperty( "hbase.propName", join( ",", shimConfig2 ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1,hbase" ); assertEquals( combinedList, shimProperties.getConfigList( "propName", ListOverrideType.PREPEND ) ); }
@Test public void testGetConfigListReplaceWith2ShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); List<String> shimConfig2 = new ArrayList<String>( Arrays.asList( "3", "cee", "p", "o" ) ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); shimProperties.setProperty( "hbase.propName", join( ",", shimConfig2 ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1,hbase" ); assertEquals( shimConfig2, shimProperties.getConfigList( "propName", ListOverrideType.REPLACE ) ); }
@Test public void testGetConfigListReplaceWithShimConfig() { List<String> rootConfig = new ArrayList<String>( Arrays.asList( "one", "b", "iii" ) ); List<String> shimConfig = new ArrayList<String>( Arrays.asList( "1", "two", "tres" ) ); shimProperties.setProperty( "propName", join( ",", rootConfig ) ); shimProperties.setProperty( "mr1.propName", join( ",", shimConfig ) ); shimProperties.setProperty( ShimProperties.SHIM_CP_CONFIG, "mr1" ); assertEquals( shimConfig, shimProperties.getConfigList( "propName", ListOverrideType.REPLACE ) ); }