From 39499cf63c05cb4409ab9ea93195836943c4679a Mon Sep 17 00:00:00 2001 From: "Bonyong.Lee" Date: Thu, 20 Sep 2012 19:59:35 +0900 Subject: [PATCH] Revert "[Title] Add common configuration management [Type] Enhancement [Module] Sub [Priority] Minor [CQ#] // CQ Issue Number [Redmine#] // Redmine Isuue Number [Problem] // Problem Description [Cause] // Cause Description [Solution] //" This reverts commit 4a7b6e9ae4a96f5df42b76bf76b4373f2eb28e6a --- .../org/tizen/common/config/ExpressionParser.java | 166 -------- .../src/org/tizen/common/config/Loader.java | 49 --- .../src/org/tizen/common/config/Namespace.java | 143 ------- .../src/org/tizen/common/config/Preference.java | 441 --------------------- .../src/org/tizen/common/config/Rule.java | 229 ----------- .../tizen/common/config/loader/AbstractLoader.java | 72 ---- .../common/config/loader/PropertiesLoader.java | 98 ----- .../tizen/common/config/loader/ResourceSource.java | 81 ---- .../src/org/tizen/common/config/loader/Source.java | 42 -- .../config/loader/StructuredResourceLoader.java | 310 --------------- .../org/tizen/common/config/loader/URLSource.java | 71 ---- .../src/org/tizen/common/util/CollectionMap.java | 25 +- .../org/tizen/common/util/url/vf/Connection.java | 5 +- .../src/org/tizen/common/AppIdGeneratorTest.java | 1 + .../src/org/tizen/common/CommonPluginTest.java | 2 +- .../src/org/tizen/common/config/.svn/all-wcprops | 17 - .../test/src/org/tizen/common/config/.svn/entries | 99 ----- .../prop-base/ExpressionParserTest.java.svn-base | 5 - .../.svn/prop-base/PreferenceTest.java.svn-base | 5 - .../text-base/ExpressionParserTest.java.svn-base | 78 ---- .../.svn/text-base/PreferenceTest.java.svn-base | 115 ------ .../tizen/common/config/ExpressionParserTest.java | 115 ------ .../org/tizen/common/config/PreferenceTest.java | 154 ------- .../tizen/common/config/loader/.svn/all-wcprops | 11 - .../org/tizen/common/config/loader/.svn/entries | 62 --- .../StructuredResourceReaderTest.java.svn-base | 5 - .../StructuredResourceReaderTest.java.svn-base | 40 -- .../loader/StructuredResourceLoaderTest.java | 80 ---- .../org/tizen/common/util/FilterIteratorTest.java | 46 +-- 29 files changed, 28 insertions(+), 2539 deletions(-) delete mode 100755 org.tizen.common/src/org/tizen/common/config/ExpressionParser.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/Loader.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/Namespace.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/Preference.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/Rule.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/loader/AbstractLoader.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/loader/PropertiesLoader.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/loader/ResourceSource.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/loader/Source.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/loader/StructuredResourceLoader.java delete mode 100755 org.tizen.common/src/org/tizen/common/config/loader/URLSource.java mode change 100755 => 100644 org.tizen.common/src/org/tizen/common/util/CollectionMap.java mode change 100755 => 100644 org.tizen.common/src/org/tizen/common/util/url/vf/Connection.java mode change 100755 => 100644 org.tizen.common/test/src/org/tizen/common/AppIdGeneratorTest.java mode change 100755 => 100644 org.tizen.common/test/src/org/tizen/common/CommonPluginTest.java delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/.svn/all-wcprops delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/.svn/entries delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/.svn/prop-base/ExpressionParserTest.java.svn-base delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/.svn/prop-base/PreferenceTest.java.svn-base delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/.svn/text-base/ExpressionParserTest.java.svn-base delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/.svn/text-base/PreferenceTest.java.svn-base delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/ExpressionParserTest.java delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/PreferenceTest.java delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/loader/.svn/all-wcprops delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/loader/.svn/entries delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/loader/.svn/prop-base/StructuredResourceReaderTest.java.svn-base delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/loader/.svn/text-base/StructuredResourceReaderTest.java.svn-base delete mode 100755 org.tizen.common/test/src/org/tizen/common/config/loader/StructuredResourceLoaderTest.java mode change 100755 => 100644 org.tizen.common/test/src/org/tizen/common/util/FilterIteratorTest.java diff --git a/org.tizen.common/src/org/tizen/common/config/ExpressionParser.java b/org.tizen.common/src/org/tizen/common/config/ExpressionParser.java deleted file mode 100755 index 2e45198..0000000 --- a/org.tizen.common/src/org/tizen/common/config/ExpressionParser.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config; - -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.HashMap; - -/** - * ExpressionParser. - * - * Object to parse preference declaration expression - * - * Variable notation is like ${blahblah} - * - * @author BonYong Lee{@literal } (S-Core) - * - */ -public class -ExpressionParser -{ - /** - * Parser status in parsing - */ - protected static enum Status{ ST_EXP, ST_ESCAPE, ST_VAR }; - - /** - * Variable start token - */ - protected static final char CH_VAR = '$'; - /** - * Variable open token - */ - protected static final char CH_VAR_OPEN = '{'; - /** - * Variable close token - */ - protected static final char CH_VAR_CLOSE = '}'; - /** - * Escaper character - */ - protected static final char CH_ESCAPE = '^'; - - /** - * Parse exp and return its value - * - * @param exp Config definition to parse - * - * @return Config value to be parsed - */ - protected static - String - parse( - final String exp - ) - { - Status status = Status.ST_EXP; - if ( null == exp ) - { - return null; - } - - final StringReader reader = new StringReader( exp ); - final StringWriter writer = new StringWriter(); - int ch = 0; - - StringWriter variableWriter = new StringWriter(); - try - { - final HashMap var2val = new HashMap(); - while ( 0 <= ( ch = reader.read() ) ) - { - switch ( status ) { - case ST_EXP: - if ( CH_VAR == ch ) - { - ch = reader.read(); - if ( CH_VAR_OPEN == ch ) - { - status = Status.ST_VAR; - variableWriter = new StringWriter(); - break; - } - else - { - writer.write( CH_VAR ); - } - } - else if ( CH_ESCAPE == ch ) - { - status = Status.ST_ESCAPE; - break; - } - - case ST_ESCAPE: - writer.write( (char) ch ); - status = Status.ST_EXP; - break; - - case ST_VAR: - if ( CH_VAR_CLOSE == ch ) - { - final String variable = variableWriter.toString(); - final String cached = var2val.get( variable ); - final String subVal = - ( null == cached )?Preference.getValue( variable, null ):cached; - - if ( null == subVal ) - { - writer.write( CH_VAR ); - writer.write( CH_VAR_OPEN ); - writer.write( variable ); - writer.write( CH_VAR_CLOSE ); - } - else - { - var2val.put( variable, subVal ); - writer.write( subVal ); - } - status = Status.ST_EXP; - break; - } - variableWriter.write( (char) ch ); - } - } - - if ( Status.ST_VAR == status ) - { - writer.write( CH_VAR ); - writer.write( CH_VAR_OPEN ); - writer.write( variableWriter.toString() ); - } - } - catch ( final IOException e ) - { - throw new IllegalStateException( "StringReader#read throw IOException", e ); - } - - - return writer.toString(); - } - -} diff --git a/org.tizen.common/src/org/tizen/common/config/Loader.java b/org.tizen.common/src/org/tizen/common/config/Loader.java deleted file mode 100755 index 3c9db57..0000000 --- a/org.tizen.common/src/org/tizen/common/config/Loader.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config; - -import java.io.IOException; - -/** - * Loader. - * - * Object to load preference from media resource - * - * @author BonYong Lee{@literal } (S-Core) - * - */ -public interface -Loader -{ - /** - * Load and register preference with namespace ns - * - * @param ns Namespace name - * - * @throws IOException If preference can't be loaded - */ - void load( final String ns ) throws IOException; - -} diff --git a/org.tizen.common/src/org/tizen/common/config/Namespace.java b/org.tizen.common/src/org/tizen/common/config/Namespace.java deleted file mode 100755 index 8ff4d40..0000000 --- a/org.tizen.common/src/org/tizen/common/config/Namespace.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config; - -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Namespace. - * - * Object to indicate preference inner region to be separated - * - * @author BonYong Lee{@literal } (S-Core) - * - */ -public class -Namespace -{ - - /** - * regsion name - */ - protected final String name; - - // Prefernece ( key/definition ) - protected final Map key2value = - new LinkedHashMap(); - - /** - * Consructor with name - * - * @param name namespace name - */ - public Namespace( - final String name - ) - { - this.name = name; - } - - /** - * Remove all preference in this namespace - */ - public - void - clear() - { - key2value.clear(); - } - - /** - * Register prefernece in this namespace - * - * @param key key of preference - * @param definition definition of preference - */ - public - void - put( - final String key, - final String definition - ) - { - key2value.put( key, definition ); - } - - /** - * Return value having key as key - * - * @param key Key of preference - * - * @return preference definition - */ - public - String - get( - final String key - ) - { - return key2value.get( key ); - } - - /** - * Remove preference having key as key - * - * @param key Key of preference - * - * @return preference definition - */ - public - String - remove( - final String key - ) - { - return key2value.remove( key ); - } - - /** - * Return if no preference exists - * - * @return flag if no prefernece exists - */ - public - boolean - isEmpty() - { - return key2value.isEmpty(); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public - String - toString() - { - return "Namespace[" + ((null == name)?"DEFAULT":name) + "]"; - } - -} diff --git a/org.tizen.common/src/org/tizen/common/config/Preference.java b/org.tizen.common/src/org/tizen/common/config/Preference.java deleted file mode 100755 index f57f1f7..0000000 --- a/org.tizen.common/src/org/tizen/common/config/Preference.java +++ /dev/null @@ -1,441 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config; - -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.TreeMap; - -import org.tizen.common.config.loader.PropertiesLoader; -import org.tizen.common.util.ArrayUtil; -import org.tizen.common.util.ParsingUtil; -import org.tizen.common.util.StringUtil; - -/** - * Preference. - * - * Object to manage preferences - * - * @author BonYong Lee{@literal } (S-Core) - * - */ -public class -Preference -{ - /** - * Default namespace that non-specified preference have - */ - protected static Namespace DEFAULT_NAMESPACE = new Namespace( null ); - - /** - * name-namespace map - */ - protected static final TreeMap name2ns = - new TreeMap(); - - /** - * {@link Rule}s to apply - */ - protected static final LinkedHashSet rules = - new LinkedHashSet(); - - static { - init(); - } - - protected Preference() {} - - /** - * Initialize preference from os environment and jvm properties - */ - public static - void - init() - { - // From OS environment variables - new PropertiesLoader( System.getenv() ).load( null ); - - // From JVM properties. Overwrite if preference is duplicated - new PropertiesLoader( System.getProperties() ).load( null ); - } - - /** - * Remove all preference - */ - public static - void - clear() - { - DEFAULT_NAMESPACE.clear(); - name2ns.clear(); - } - - /** - * Check name is valid - * - * Key must contain only alphabet, unicode, '_', and '.' - * - * @param name string to check - * - * @return Flag if name is valid - */ - protected static - final - boolean - checkName( - final String name - ) - { - final char[] chars = name.toCharArray(); - for ( int i=0, n=chars.length ; iname - * - * Ignore if invalid preference - * - * @param name namespace name - * @param key prefernece key - * @param exp prefernece expression - */ - public static - void - register( - final String name, - final String key, - final String exp - ) - { - // check namespace - if ( null != name && !checkName( name ) ) - { - return ; - } - - // check key - if ( !checkName( key ) ) - { - return ; - } - if ( StringUtil.isEmpty( key ) ) - { - return ; - } - - // specify namespace - Namespace namespace = - ( null==name )?DEFAULT_NAMESPACE:name2ns.get( name ); - if ( null == namespace ) - { - // create new namespace - namespace = new Namespace( name ); - name2ns.put( name, namespace ); - } - - if ( null == exp ) - { - // remove preference - namespace.remove( key ); - } - else - { - // add preference - namespace.put( key, exp ); - } - - if ( null != name && namespace.isEmpty() ) - { - // remove namespace if it is empty - name2ns.remove( name ); - } - - } - - /** - * Clear namespace naming name - * @param name - */ - public static - void - clear( - final String name - ) - { - // check namespace - if ( null != name && !checkName( name ) ) - { - return ; - } - - if ( null == name ) - { - DEFAULT_NAMESPACE.clear(); - } - else - { - name2ns.remove( name ); - } - } - - /** - * - * Add namespace rule - * - * @param rule {@link Rule} to add - * - * @see Rule - */ - public static - void - addRule( - final Rule rule - ) - { - rules.add( rule ); - } - - /** - * Remove namespace rule - * - * @param rule {@link Rule} to remove - */ - public static - void - removeRule( - final Rule rule - ) - { - rules.remove( rule ); - } - - /** - * Remove all rules - */ - public static - void - clearRule() - { - rules.clear(); - } - - /** - * Return preference expression - * - * @param name namespace name - * @param key preference key - * - * @return preference expression - */ - public static - String - get( - final String name, - final String key - ) - { - final Namespace ns = - (null==name)?DEFAULT_NAMESPACE:name2ns.get( name ); - if ( null == ns ) return null; - - return ns.get( key ); - } - /** - * Find preference expression for key - * - * Return null if it is not found - * - * @param key preference key - * - * @return preference expression - */ - protected static - String - find( - final String key - ) - { - // callstack - final StackTraceElement[] stacks = - Thread.currentThread().getStackTrace(); - - // iterate callstack - for ( int i=0, n=ArrayUtil.size( stacks ) ; i - getNamespaces() - { - final HashSet namespaces = new HashSet(); - - namespaces.add( DEFAULT_NAMESPACE ); - namespaces.addAll( name2ns.values() ); - - return namespaces; - } - /** - * Return preference keys in namespace name - * - * @param name namespace name - * - * @return preference keys - */ - public static - Collection - list( - final String name - ) - { - final Namespace ns = - ( null == name ) ? DEFAULT_NAMESPACE : name2ns.get( name ); - - if ( null == ns ) - { - return Collections.emptySet(); - } - - return Collections.unmodifiableCollection( ns.key2value.keySet() ); - - } - /* Value */ - /** - * Return value for key - * - * @param key preference key - * @param defaultValue default value if value doesn't exist - * - * @return calculated value - */ - public static - String - getValue( - final String key, - final String defaultValue - ) - { - // get definition - final String exp = find( key ); - if ( null == exp ) - { - // return default value if definition doesn't exist - if ( null == defaultValue ) - { - return null; - } - return ExpressionParser.parse( defaultValue ); - } - return ExpressionParser.parse( exp ); - } - - - /** - * Return value for key as int - * - * @param key preference key - * @param defaultValue default value if value doesn't exist - * - * @return calculated value - */ - public static - int - getInteger( - final String key, - final int defaultValue - ) - { - // get value - final String value = getValue( key, null ); - - // convert to integer - return ParsingUtil.parseInt( value, defaultValue ); - } - - /** - * Return value for key as boolean - * - * @param key preference key - * @param defaultValue default value if value doesn't exist - * - * @return calculated value - */ - public static - boolean - getBoolean( - final String key, - final boolean defaultValue - ) - { - // get value - final String value = getValue( key, null ); - - // convert to boolean - return ParsingUtil.parseBoolean( value, defaultValue ); - - } - -} diff --git a/org.tizen.common/src/org/tizen/common/config/Rule.java b/org.tizen.common/src/org/tizen/common/config/Rule.java deleted file mode 100755 index 6354c7a..0000000 --- a/org.tizen.common/src/org/tizen/common/config/Rule.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config; - -import org.tizen.common.util.Assert; - -/** - * Rule. - * - * Object to justify that target is valid - * - * @author BonYong Lee{@literal } (S-Core) - * - */ -public interface -Rule -{ - /** - * Return namespace name for arg - * - * Return null if rule is invalid for arg - * - * @param arg target name - * - * @return namespace name - */ - String accept( final Object arg ); - - /** - * {@link Rule} using pattern and call stack - */ - public static class - PatternRule - implements Rule - { - /** - * Separator between class name and method name - */ - protected static final String SEP_METHOD = "#"; - - /** - * Wildcard matching any character - */ - protected static final String ANY = "*"; - - /** - * Class qualified name pattern to apply - */ - protected final String qnPattern; - - /** - * Method name pattern to apply - */ - protected final String methodNamePattern; - - /** - * Namespace name - */ - protected final String name; - - /** - * Constructor with pattern and namespace name - * - * Example is following. - *
    - *
  • {QualifiedNamePattern}
  • - *
  • {QualifiedNamePattern}#{MethodNamePattern} - *
- * - * @param pattern pattern string to apply - * @param name namespace name to return if rule is valid - */ - public - PatternRule( - final String pattern, - final String name - ) - { - final int index = pattern.indexOf( SEP_METHOD ); - if ( index < 0 ) - { - // qualified name if no separator exists - qnPattern = pattern; - methodNamePattern = "*"; - } - else - { - // qualfied name and method name if separator exists - qnPattern = pattern.substring( 0, index ); - methodNamePattern = pattern.substring( index + 1 ); - } - - this.name = name; - } - - /** - * Check str is matching with pattern p - * - * @param p pattern to check - * @param str string to check - * - * @return Flag if str is matching with p - */ - protected - boolean - check( - final String p, - final String str - ) - { - if ( ANY.equals( p ) ) { - // Any string is ok - return true; - } else if ( !p.contains( ANY ) ) { - // Pattern contains no wildcard;exact matching - return p.equals( str ); - } else { - final boolean bStart = p.startsWith( ANY ); - final boolean bEnd = p.endsWith( ANY ); - - final String keyword = - p.substring( 0, p.length() - (bEnd?1:0) ). - substring( bStart?1:0 ); - - if ( !bStart && !bEnd ) { - // in case that strings exist leading and trailing - int index = keyword.indexOf( ANY ); - - // Dose NOT permit more than one wildcard - Assert.isFalse( - 0 <= keyword.indexOf( ANY, index ), - "Invalid Pattern[" + p + "]" - ); - - return ( - str.startsWith( keyword.substring( 0, index ) ) && - str.endsWith( keyword.substring( index + 1 ) ) - ); - } - - Assert.isFalse( - keyword.contains( ANY ), - "Invalid Pattern[" + p + "]" - ); - if ( bStart && bEnd ) - { - // In case that target pattern exists in middle of string - return str.contains( keyword ); - } - else if ( bStart ) - { - // In case of suffix - return str.endsWith( keyword ); - } - else if ( bEnd ) - { - // In case of prefix - return str.startsWith( keyword ); - } - throw new IllegalStateException(); - } - } // END of method 'check' - - - /* (non-Javadoc) - * @see com.parthenon.config.Rule#accept(java.lang.Object) - */ - public - String - accept( - final Object arg - ) - { - if ( arg instanceof StackTraceElement ) - { - final StackTraceElement e = (StackTraceElement) arg; - - // Check classname in call stack - if ( !check( qnPattern, e.getClassName() ) ) - { - return null; - } - - // Check method in call stack - if ( !check( methodNamePattern, e.getMethodName() ) ) - { - return null; - } - - return name; - } - return null; - } // END of method 'accept' - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - public - String - toString() - { - return "Rule[" + qnPattern + "->" + name + "]"; - } - - } // END of class 'PatternRule' - -} diff --git a/org.tizen.common/src/org/tizen/common/config/loader/AbstractLoader.java b/org.tizen.common/src/org/tizen/common/config/loader/AbstractLoader.java deleted file mode 100755 index c7f4c80..0000000 --- a/org.tizen.common/src/org/tizen/common/config/loader/AbstractLoader.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config.loader; - -import org.tizen.common.config.Loader; - -/** - * AbstractLoader. - * - * Abstract class to load preference - * - * @author BonYong Lee{@literal } (S-Core) - */ -abstract public class -AbstractLoader -implements Loader -{ - /** - * {@link Source} for preference - */ - protected final Source src; - - /** - * Constructor with preference source - * - * @param src {@link Source} for preference - */ - public - AbstractLoader( - final Source src - ) - { - this.src = src; - if ( null == src ) - { - throw new NullPointerException(); - } - } - - /** - * @return {@link Source} to load preference - */ - protected - Source - getSource() - { - return src; - } - -} diff --git a/org.tizen.common/src/org/tizen/common/config/loader/PropertiesLoader.java b/org.tizen.common/src/org/tizen/common/config/loader/PropertiesLoader.java deleted file mode 100755 index 6a2160f..0000000 --- a/org.tizen.common/src/org/tizen/common/config/loader/PropertiesLoader.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config.loader; - -import java.util.Map; -import java.util.Properties; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.tizen.common.config.Preference; - -/** - * PropertiesLoader. - * - * Object to load preference from *.properties file - * - * @author BonYong Lee{@literal } (S-Core) - */ -public class -PropertiesLoader -{ - protected final Logger logger = LoggerFactory.getLogger( getClass() ); - - protected final Map props; - - /** - * Constructor with {@link Properties} - * - * @param props {@link Properties} to clone from - */ - @SuppressWarnings("unchecked") - public - PropertiesLoader( - final Properties props - ) - { - this( (Map) (Object) props ); - } - - /** - * Constructor with {@link Map} - * - * @param props {@link Map} to clone from - */ - public - PropertiesLoader( - final Map props - ) - { - this.props = props; - } - - /* (non-Javadoc) - * @see com.parthenon.config.Loader#load(java.lang.String) - */ - public - void - load( - final String name - ) - { - // 읽어들일 key/definition을 설정에 등록한다. - for( final String key : props.keySet() ) - { - try - { - Preference.register( name, key, props.get( key ) ); - } - catch ( final IllegalArgumentException e ) - { - logger.error( "Error occurred in loading.", e ); - } - } - } - -} diff --git a/org.tizen.common/src/org/tizen/common/config/loader/ResourceSource.java b/org.tizen.common/src/org/tizen/common/config/loader/ResourceSource.java deleted file mode 100755 index 2a25c62..0000000 --- a/org.tizen.common/src/org/tizen/common/config/loader/ResourceSource.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config.loader; - -import java.io.IOException; -import java.net.URL; -import java.util.Collections; -import java.util.Enumeration; -import java.util.Iterator; - -import org.apache.commons.collections.iterators.EnumerationIterator; - -/** - * ResourceSource. - * - * {@link Source} to provide resource from classpath - * - * @author BonYong Lee{@literal } (S-Core) - */ -public class -ResourceSource -implements Source -{ - - protected final String resourceName; - - /** - * Constructor with resource name - * - * @param resourceName name of resource - */ - public - ResourceSource( - final String resourceName - ) - { - this.resourceName = resourceName; - } - - /* (non-Javadoc) - * @see java.lang.Iterable#iterator() - */ - @SuppressWarnings("unchecked") - public - Iterator - iterator() - { - try { - final ClassLoader cl = Thread.currentThread().getContextClassLoader(); - final Enumeration urls = cl.getResources( resourceName ); - return new EnumerationIterator( urls ); - } catch ( final IOException e ) { - e.printStackTrace(); - } - - return Collections.emptySet().iterator(); - } - -} diff --git a/org.tizen.common/src/org/tizen/common/config/loader/Source.java b/org.tizen.common/src/org/tizen/common/config/loader/Source.java deleted file mode 100755 index 8a0b03c..0000000 --- a/org.tizen.common/src/org/tizen/common/config/loader/Source.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config.loader; - -import java.net.URL; - -/** - * Source. - * - * Object to provide {@link URL}s of resource - * - * @author BonYong Lee{@literal } (S-Core) - * - * @see Iterable - */ -public interface -Source -extends Iterable -{ -} diff --git a/org.tizen.common/src/org/tizen/common/config/loader/StructuredResourceLoader.java b/org.tizen.common/src/org/tizen/common/config/loader/StructuredResourceLoader.java deleted file mode 100755 index 4729fee..0000000 --- a/org.tizen.common/src/org/tizen/common/config/loader/StructuredResourceLoader.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config.loader; - -import static org.tizen.common.util.IOUtil.tryClose; -import static org.tizen.common.util.StringUtil.EMPTY_STRING; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.StringReader; -import java.net.URL; -import java.text.ParseException; -import java.util.Iterator; -import java.util.Stack; - -import org.apache.log4j.lf5.util.StreamUtils; -import org.tizen.common.config.Preference; -import org.tizen.common.util.CollectionUtil; -import org.tizen.common.util.StringUtil; - -/** - * StructuredResourceLoader. - * - * Object to load preference from *.ini file - * - * @author BonYong Lee{@literal } (S-Core) - */ -public class -StructuredResourceLoader -extends AbstractLoader -{ - - - /** - * Section start token - */ - protected static final String SEC_OPEN ="["; - - /** - * Section end token - */ - protected static final String SEC_CLOSE = "]"; - - /** - * Line comment token - */ - protected static final String PREFIX_COMMENT = "#"; - - /** - * Separator of preference - */ - protected static final char CH_ATTR_VAL = '='; - /** - * Escaper - */ - protected static final char CH_ESCAPE = '\\'; - - /** - * Status of parser in syntax - */ - protected enum Status{ ST_INDENT, ST_ATTR, ST_VAL }; - - /** - * current name space - */ - protected String ns = EMPTY_STRING; - - /** - * current title in parsing - */ - protected String title = null; - - /** - * Constructor with source - * - * @param src {@link Source} - */ - public - StructuredResourceLoader( - final Source src - ) - { - super( src ); - } - - /* (non-Javadoc) - * @see org.tizen.common.config.Loader#load(java.lang.String) - */ - public - void - load( - final String ns - ) throws IOException { - final Iterator iter = src.iterator(); - this.ns = StringUtil.nvl( ns ); - while ( iter.hasNext() ) - { - - final URL url = iter.next(); - final InputStream in = url.openStream(); - try - { - ByteArrayInputStream byteIn = new ByteArrayInputStream( StreamUtils.getBytes( in ) ); - read( byteIn ); - } - finally - { - tryClose( in ); - } - } - } - - - /** - * Composite sentence from in line-by-line - * - * @param in {@link InputStream} to read preference from - * - * @throws IOException If prefernece can't be read - */ - protected - void - read( - final InputStream in - ) throws IOException { - final BufferedReader reader = - new BufferedReader( new InputStreamReader( in ) ); - - String line = null; - String meaning = ""; - - final Stack names = new Stack(); - - try - { - while ( null != ( line = reader.readLine() ) ) - { - meaning += line; - meaning = processLine( meaning, names ); - } - } - catch ( final ParseException e ) - { - throw new IOException( e ); - } - - } - - /** - * Process preference sentence - * - * @param line preference sentence - * @param names name stack - * - * @throws ParseException If line is invalid - */ - protected - String - processLine( - final String line, - final Stack names - ) - throws ParseException - { - // Ignore line comment - if ( line.startsWith( PREFIX_COMMENT ) ) return EMPTY_STRING; - - // If next line exists - int cnt = 0; - for ( int i=line.length()-1 ; 0<=i ; --i ) - { - if ( CH_ESCAPE == line.charAt( i ) ) - { - ++cnt; - } - } - - if ( 1 == ( cnt % 2 ) ) - { - return line.substring( 0, line.length() - 1 ); - } - - // Process meaningful sentence - if ( line.startsWith( SEC_OPEN ) && line.endsWith( SEC_CLOSE ) ) - { - // In case of title - title = ns + line.substring( 1, line.length() - 1 ).trim(); - return EMPTY_STRING; - } - - // Process preference - try { - final StringReader reader = new StringReader( line ); - - // character index - int ch = 0; - - // parsing state - Status status = Status.ST_INDENT; - - // the number of indent - int nTab = 0; - - // buffer for name - final StringBuilder nameBuffer = new StringBuilder(); - - // buffer for value - final StringBuilder valBuffer = new StringBuilder(); - - // flat that previous character is escape - boolean bEscape = false; - - int nRead = 0; - while ( 0 <= ( ch = reader.read() ) ) - { - ++nRead; - switch ( status ) - { - case ST_INDENT: - if ( '\t' == ch ) - { - ++nTab; - continue; - } - - while ( nTab < names.size() ) - { - names.pop(); - } - status = Status.ST_ATTR; - case ST_ATTR: - if ( '.' == ch ) - { - throw new ParseException( "It containers '.' which is NOT permitted in " + line, nRead ); - } - else if ( bEscape ) - { - nameBuffer.append( (char) ch ); - bEscape = false; - } - else if ( CH_ESCAPE == ch ) - { - bEscape = true; - } - else if ( '=' == ch ) - { - status = Status.ST_VAL; - } - else - { - nameBuffer.append( (char) ch ); - } - break; - case ST_VAL: - valBuffer.append( (char) ch ); - break; - } - } - - if ( status == Status.ST_INDENT ) - { - return EMPTY_STRING; - } - - // Create qualified name - final StringBuilder qn = new StringBuilder(); - for ( int i=0, n=CollectionUtil.size( names ) ; i - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config.loader; - -import java.net.URL; -import java.util.Iterator; - -/** - * URLSource. - * - * Object to provide {@link URL}s of resource using {@link URL} - * - * @author BonYong Lee{@literal } (S-Core) - * - * @see Source - */ -public class -URLSource -implements Source -{ - /** - * {@link URL} for resource - */ - protected final URL url; - - /** - * Constructor with url - * - * @param url {@link URL} for resource - */ - public - URLSource( - final URL url - ) - { - this.url = url; - } - - /* (non-Javadoc) - * @see java.lang.Iterable#iterator() - */ - public - Iterator - iterator() - { - return null; - } - -} diff --git a/org.tizen.common/src/org/tizen/common/util/CollectionMap.java b/org.tizen.common/src/org/tizen/common/util/CollectionMap.java old mode 100755 new mode 100644 index a3ff716..9037579 --- a/org.tizen.common/src/org/tizen/common/util/CollectionMap.java +++ b/org.tizen.common/src/org/tizen/common/util/CollectionMap.java @@ -26,8 +26,8 @@ package org.tizen.common.util; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.LinkedHashMap; -import java.util.Map; /** @@ -53,28 +53,7 @@ CollectionMap /** * Map to manage key-values */ - protected final Map> map; - - /** - * Default constructor - */ - public - CollectionMap() { - this( new LinkedHashMap>() ); - } - - /** - * Constructor with map - * - * @param map key-value container - */ - public - CollectionMap( - final Map> map - ) - { - this.map = map; - } + protected final HashMap> map = new LinkedHashMap>(); /** diff --git a/org.tizen.common/src/org/tizen/common/util/url/vf/Connection.java b/org.tizen.common/src/org/tizen/common/util/url/vf/Connection.java old mode 100755 new mode 100644 index 8e933ff..e32f42d --- a/org.tizen.common/src/org/tizen/common/util/url/vf/Connection.java +++ b/org.tizen.common/src/org/tizen/common/util/url/vf/Connection.java @@ -28,9 +28,6 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; -import java.net.URLDecoder; - -import javax.xml.crypto.URIDereferencer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -123,6 +120,6 @@ extends URLConnection { final String path = url.getPath(); logger.trace( "Path :{}", path ); - return vfHandler.read( URLDecoder.decode( path ) ); + return vfHandler.read( path ); } } diff --git a/org.tizen.common/test/src/org/tizen/common/AppIdGeneratorTest.java b/org.tizen.common/test/src/org/tizen/common/AppIdGeneratorTest.java old mode 100755 new mode 100644 index 5f04ce6..3481b7e --- a/org.tizen.common/test/src/org/tizen/common/AppIdGeneratorTest.java +++ b/org.tizen.common/test/src/org/tizen/common/AppIdGeneratorTest.java @@ -24,6 +24,7 @@ */ package org.tizen.common; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; diff --git a/org.tizen.common/test/src/org/tizen/common/CommonPluginTest.java b/org.tizen.common/test/src/org/tizen/common/CommonPluginTest.java old mode 100755 new mode 100644 index ec80700..4082bfa --- a/org.tizen.common/test/src/org/tizen/common/CommonPluginTest.java +++ b/org.tizen.common/test/src/org/tizen/common/CommonPluginTest.java @@ -74,7 +74,7 @@ CommonPluginTest (String) doNotCare() ); } - verify( preferenceStore ).setDefault( TizenBasePreferencePage.KEY_SDKUPDATE, false ); + verify( preferenceStore ).setDefault( TizenBasePreferencePage.KEY_SDKUPDATE, true ); } } diff --git a/org.tizen.common/test/src/org/tizen/common/config/.svn/all-wcprops b/org.tizen.common/test/src/org/tizen/common/config/.svn/all-wcprops deleted file mode 100755 index 54a531c..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/.svn/all-wcprops +++ /dev/null @@ -1,17 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 68 -/svn/!svn/ver/3135/product/common/escode.util/test/src/escode/config -END -PreferenceTest.java -K 25 -svn:wc:ra_dav:version-url -V 88 -/svn/!svn/ver/3123/product/common/escode.util/test/src/escode/config/PreferenceTest.java -END -ExpressionParserTest.java -K 25 -svn:wc:ra_dav:version-url -V 94 -/svn/!svn/ver/1885/product/common/escode.util/test/src/escode/config/ExpressionParserTest.java -END diff --git a/org.tizen.common/test/src/org/tizen/common/config/.svn/entries b/org.tizen.common/test/src/org/tizen/common/config/.svn/entries deleted file mode 100755 index 5167074..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/.svn/entries +++ /dev/null @@ -1,99 +0,0 @@ -10 - -dir -3304 -http://bravo/svn/product/common/escode.util/test/src/escode/config -http://bravo/svn - - - -2012-02-07T00:29:23.967704Z -3135 -bylee - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -deffe9a1-5acb-4285-bb96-7fb302350b82 - -ExpressionParserTest.java -file - - - - -2012-07-22T09:20:35.000000Z -405bee8a1d862887cd44cd4b77ca02d0 -2011-09-15T23:44:14.853268Z -1885 -bylee -has-props - - - - - - - - - - - - - - - - - - - - -1611 - -PreferenceTest.java -file - - - - -2012-07-22T09:20:35.000000Z -2fda4d6c8d0b3ac0b89256dc275319e9 -2012-02-03T06:01:04.868665Z -3123 -bylee -has-props - - - - - - - - - - - - - - - - - - - - -2560 - -loader -dir - diff --git a/org.tizen.common/test/src/org/tizen/common/config/.svn/prop-base/ExpressionParserTest.java.svn-base b/org.tizen.common/test/src/org/tizen/common/config/.svn/prop-base/ExpressionParserTest.java.svn-base deleted file mode 100755 index 138f983..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/.svn/prop-base/ExpressionParserTest.java.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 13 -svn:mime-type -V 10 -text/plain -END diff --git a/org.tizen.common/test/src/org/tizen/common/config/.svn/prop-base/PreferenceTest.java.svn-base b/org.tizen.common/test/src/org/tizen/common/config/.svn/prop-base/PreferenceTest.java.svn-base deleted file mode 100755 index 138f983..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/.svn/prop-base/PreferenceTest.java.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 13 -svn:mime-type -V 10 -text/plain -END diff --git a/org.tizen.common/test/src/org/tizen/common/config/.svn/text-base/ExpressionParserTest.java.svn-base b/org.tizen.common/test/src/org/tizen/common/config/.svn/text-base/ExpressionParserTest.java.svn-base deleted file mode 100755 index 060dc8f..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/.svn/text-base/ExpressionParserTest.java.svn-base +++ /dev/null @@ -1,78 +0,0 @@ -package escode.config; - -import escode.config.ExpressionParser; -import escode.config.Preference; -import escode.util.AbstractTestCase; - - - -public class -ExpressionParserTest -extends AbstractTestCase { - /* 테스트 환경 초기화 */ - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected - void - setUp() - throws Exception { - final String[][] CONFIGS = new String[][] { - new String[] { "msg1", "hello" }, - new String[] { "msg2", "${msg3}, ${msg4}!!" }, - new String[] { "msg5", "${msg6}, ${msg7}!!" }, - new String[] { "msg6", "hello" }, - new String[] { "msg7", "world" }, - new String[] { "msg8", "${msg9" }, - new String[] { "msg9", "$abcd" }, - new String[] { "msg10", "^${abc}" } - }; - - for ( final String[] CONFIG : CONFIGS ) - { - final String key = CONFIG[0]; - final String exp = CONFIG[1]; - - Preference.register( null, key, exp ); - } - } - - protected - void - tearDown() - throws Exception { - Preference.clear(); - - super.tearDown(); - } - - /** - * @throws Exception - * - * @see {@link ExpressionParser#parse(String)} - */ - public - void - test_parse() - throws Exception { - final String[][] TEST_CASES = new String[][] { - new String[] { "msg1", "hello" }, - new String[] { "msg2", "${msg3}, ${msg4}!!" }, - new String[] { "msg5", "hello, world!!" }, - new String[] { "msg8", "${msg9" }, - new String[] { "msg9", "$abcd" }, - new String[] { "msg10", "${abc}" } - }; - - - for ( final String[] TEST_CASE : TEST_CASES ) - { - final String key = TEST_CASE[0]; - final String value = TEST_CASE[1]; - - assertEquals( value, Preference.getValue( key, null ) ); - } - } - - -} diff --git a/org.tizen.common/test/src/org/tizen/common/config/.svn/text-base/PreferenceTest.java.svn-base b/org.tizen.common/test/src/org/tizen/common/config/.svn/text-base/PreferenceTest.java.svn-base deleted file mode 100755 index e6e8d42..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/.svn/text-base/PreferenceTest.java.svn-base +++ /dev/null @@ -1,115 +0,0 @@ -package escode.config; - -import java.io.InputStream; -import java.util.Properties; - -import escode.config.Preference; -import escode.config.Rule; -import escode.config.loader.PropertiesLoader; -import escode.util.AbstractTestCase; -import escode.util.StreamUtils; - - - - -public class -PreferenceTest -extends AbstractTestCase -{ - /** - * @throws Exception - * - * @see Preference#checkName(String) - */ - public void - test_checkName() - throws Exception { - assertTrue( Preference.checkName( "ajfdkfj" ) ); - assertTrue( Preference.checkName( "344223" ) ); - assertTrue( Preference.checkName( "한글" ) ); - - assertFalse( Preference.checkName( "344 223" ) ); - } - - /** - * @throws Exception - * - * @see {@link Preference#find(String)} - */ - public void - test_find() - throws Exception { - final ClassLoader cl = - Thread.currentThread().getContextClassLoader(); - - final InputStream in = - cl.getResourceAsStream( "test.properties" ); - - try - { - final Properties props = new Properties(); - props.load( in ); - - final PropertiesLoader loader = new PropertiesLoader( props ); - loader.load( "test" ); - - assertEquals( null, Preference.getValue( "hello", null ) ); - - Preference.addRule( new Rule.PatternRule( "*Test", "test" ) ); - - assertEquals( "world", Preference.find( "hello" ) ); - assertEquals( "${b}", Preference.find( "a" ) ); - assertEquals( null, Preference.find( "hello1" ) ); - - - } - finally - { - StreamUtils.tryClose( in ); - Preference.clear(); - Preference.clearRule(); - } - } - - /** - * @throws Exception - * - * @see {@link Preference#find(String)} - */ - public - void - test_getValue() - throws Exception - { - final ClassLoader cl = - Thread.currentThread().getContextClassLoader(); - - final InputStream in = - cl.getResourceAsStream( "test.properties" ); - - try - { - final Properties props = new Properties(); - props.load( in ); - - final PropertiesLoader loader = new PropertiesLoader( props ); - loader.load( "test" ); - - assertEquals( null, Preference.getValue( "hello", null ) ); - - Preference.addRule( new Rule.PatternRule( "*Test", "test" ) ); - - assertEquals( "world", Preference.getValue( "hello", null ) ); - assertEquals( "c", Preference.getValue( "a", null ) ); - assertEquals( null, Preference.getValue( "hello1", null ) ); - assertEquals( "e", Preference.getValue( "hello1", "${d}" ) ); - } - finally - { - StreamUtils.tryClose( in ); - Preference.clear(); - Preference.clearRule(); - } - } - -} diff --git a/org.tizen.common/test/src/org/tizen/common/config/ExpressionParserTest.java b/org.tizen.common/test/src/org/tizen/common/config/ExpressionParserTest.java deleted file mode 100755 index 396f83c..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/ExpressionParserTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * ExpressionParserTest - * - * Test case for {@link ExpressionParser} - * - * @author BonYong Lee{@literal } (S-Core) - * - * @see ExpressionParser - */ -public class -ExpressionParserTest -{ - /** - * Prepare test - * - * @throws Exception in case of failure in preparation - */ - @Before - protected - void - setUp() - throws Exception { - final String[][] CONFIGS = new String[][] { - new String[] { "msg1", "hello" }, - new String[] { "msg2", "${msg3}, ${msg4}!!" }, - new String[] { "msg5", "${msg6}, ${msg7}!!" }, - new String[] { "msg6", "hello" }, - new String[] { "msg7", "world" }, - new String[] { "msg8", "${msg9" }, - new String[] { "msg9", "$abcd" }, - new String[] { "msg10", "^${abc}" } - }; - - for ( final String[] CONFIG : CONFIGS ) - { - final String key = CONFIG[0]; - final String exp = CONFIG[1]; - - Preference.register( null, key, exp ); - } - } - - @After - protected - void - tearDown() - throws Exception { - Preference.clear(); - } - - /** - * Test {@link ExpressionParser#parse(String)} - * - * @throws Exception in case of failure in test - * - * @see {@link ExpressionParser#parse(String)} - */ - @Test - public - void - test_parse() - throws Exception { - final String[][] TEST_CASES = new String[][] { - new String[] { "msg1", "hello" }, - new String[] { "msg2", "${msg3}, ${msg4}!!" }, - new String[] { "msg5", "hello, world!!" }, - new String[] { "msg8", "${msg9" }, - new String[] { "msg9", "$abcd" }, - new String[] { "msg10", "${abc}" } - }; - - - for ( final String[] TEST_CASE : TEST_CASES ) - { - final String key = TEST_CASE[0]; - final String value = TEST_CASE[1]; - - assertEquals( value, Preference.getValue( key, null ) ); - } - } - - -} diff --git a/org.tizen.common/test/src/org/tizen/common/config/PreferenceTest.java b/org.tizen.common/test/src/org/tizen/common/config/PreferenceTest.java deleted file mode 100755 index 3b164d9..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/PreferenceTest.java +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.tizen.common.util.IOUtil.tryClose; - -import java.io.InputStream; -import java.util.Properties; - -import org.junit.Test; -import org.tizen.common.config.loader.PropertiesLoader; - - -/** - * PreferenceTest - * - * Test case for {@link Preference} - * - * @author BonYong Lee{@literal } (S-Core) - * - * @see Preference - */ -public class -PreferenceTest -{ - /** - * Test {@link Preference#checkName(String)} - * - * @throws Exception in case of failure in test - * - * @see {@link Preference#checkName(String)} - */ - public void - test_checkName() - throws Exception { - assertTrue( Preference.checkName( "ajfdkfj" ) ); - assertTrue( Preference.checkName( "344223" ) ); - assertTrue( Preference.checkName( "한글" ) ); - - assertFalse( Preference.checkName( "344 223" ) ); - } - - /** - * Test {@link Preference#find(String)} - * - * @throws Exception in case of failure in test - * - * @see {@link Preference#find(String)} - */ - public void - test_find() - throws Exception { - final ClassLoader cl = - Thread.currentThread().getContextClassLoader(); - - final InputStream in = - cl.getResourceAsStream( "test.properties" ); - - try - { - final Properties props = new Properties(); - props.load( in ); - - final PropertiesLoader loader = new PropertiesLoader( props ); - loader.load( "test" ); - - assertEquals( null, Preference.getValue( "hello", null ) ); - - Preference.addRule( new Rule.PatternRule( "*Test", "test" ) ); - - assertEquals( "world", Preference.find( "hello" ) ); - assertEquals( "${b}", Preference.find( "a" ) ); - assertEquals( null, Preference.find( "hello1" ) ); - - - } - finally - { - tryClose( in ); - Preference.clear(); - Preference.clearRule(); - } - } - - /** - * Test {@link Preference#getValue(String, String)} - * - * @throws Exception in case of failure in test - * - * @see {@link Preference#getValue(String, String)} - */ - @Test - public - void - test_getValue() - throws Exception - { - final ClassLoader cl = - Thread.currentThread().getContextClassLoader(); - - final InputStream in = - cl.getResourceAsStream( "test.properties" ); - - try - { - final Properties props = new Properties(); - props.load( in ); - - final PropertiesLoader loader = new PropertiesLoader( props ); - loader.load( "test" ); - - assertEquals( null, Preference.getValue( "hello", null ) ); - - Preference.addRule( new Rule.PatternRule( "*Test", "test" ) ); - - assertEquals( "world", Preference.getValue( "hello", null ) ); - assertEquals( "c", Preference.getValue( "a", null ) ); - assertEquals( null, Preference.getValue( "hello1", null ) ); - assertEquals( "e", Preference.getValue( "hello1", "${d}" ) ); - } - finally - { - tryClose( in ); - Preference.clear(); - Preference.clearRule(); - } - } - -} diff --git a/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/all-wcprops b/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/all-wcprops deleted file mode 100755 index f8bf58a..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/all-wcprops +++ /dev/null @@ -1,11 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 75 -/svn/!svn/ver/3135/product/common/escode.util/test/src/escode/config/loader -END -StructuredResourceReaderTest.java -K 25 -svn:wc:ra_dav:version-url -V 109 -/svn/!svn/ver/3135/product/common/escode.util/test/src/escode/config/loader/StructuredResourceReaderTest.java -END diff --git a/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/entries b/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/entries deleted file mode 100755 index 1d66628..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/entries +++ /dev/null @@ -1,62 +0,0 @@ -10 - -dir -3304 -http://bravo/svn/product/common/escode.util/test/src/escode/config/loader -http://bravo/svn - - - -2012-02-07T00:29:23.967704Z -3135 -bylee - - -svn:special svn:externals svn:needs-lock - - - - - - - - - - - -deffe9a1-5acb-4285-bb96-7fb302350b82 - -StructuredResourceReaderTest.java -file - - - - -2012-07-22T09:20:35.000000Z -ec0fc2c324dfb74801d1f833df7287cb -2012-02-07T00:29:23.967704Z -3135 -bylee -has-props - - - - - - - - - - - - - - - - - - - - -824 - diff --git a/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/prop-base/StructuredResourceReaderTest.java.svn-base b/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/prop-base/StructuredResourceReaderTest.java.svn-base deleted file mode 100755 index 138f983..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/prop-base/StructuredResourceReaderTest.java.svn-base +++ /dev/null @@ -1,5 +0,0 @@ -K 13 -svn:mime-type -V 10 -text/plain -END diff --git a/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/text-base/StructuredResourceReaderTest.java.svn-base b/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/text-base/StructuredResourceReaderTest.java.svn-base deleted file mode 100755 index 54af2da..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/loader/.svn/text-base/StructuredResourceReaderTest.java.svn-base +++ /dev/null @@ -1,40 +0,0 @@ -package escode.config.loader; - -import escode.config.Loader; -import escode.config.Preference; -import escode.util.AbstractTestCase; - - - - -public class -StructuredResourceReaderTest -extends AbstractTestCase -{ - public - void - test_load() - throws Exception { - final Source src = new ResourceSource( "logging.ini" ); - final Loader reader = new StructuredResourceReader( src ); - try - { - - reader.load( "escode.logging." ); - - assertNotNull( Preference.getNamespaces() ); - - assertEquals( 4, Preference.getNamespaces().size() ); - - assertEquals( 3, Preference.list( "escode.logging.layout" ).size() ); - assertEquals( 6, Preference.list( "escode.logging.appender" ).size() ); - assertEquals( 8, Preference.list( "escode.logging.logger" ).size() ); - } - finally - { - Preference.clear(); - Preference.clearRule(); - } - } - -} diff --git a/org.tizen.common/test/src/org/tizen/common/config/loader/StructuredResourceLoaderTest.java b/org.tizen.common/test/src/org/tizen/common/config/loader/StructuredResourceLoaderTest.java deleted file mode 100755 index 08f745c..0000000 --- a/org.tizen.common/test/src/org/tizen/common/config/loader/StructuredResourceLoaderTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ -package org.tizen.common.config.loader; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import org.junit.Test; -import org.tizen.common.config.Loader; -import org.tizen.common.config.Preference; - -/** - * StructuredResourceLoaderTest - * - * Test case for {@link StructuredResourceLoader} - * - * @author BonYong Lee{@literal } (S-Core) - * - * @see StructuredResourceLoader - */ -public class -StructuredResourceLoaderTest -{ - /** - * Test {@link StructuredResourceLoader#load(String)} - * - * @throws Exception in case of failure in test - * - * @see {@link StructuredResourceLoader#load(String)} - */ - @Test - public - void - test_load() - throws Exception { - final Source src = new ResourceSource( "logging.ini" ); - final Loader reader = new StructuredResourceLoader( src ); - try - { - - reader.load( "escode.logging." ); - - assertNotNull( Preference.getNamespaces() ); - - assertEquals( 4, Preference.getNamespaces().size() ); - - assertEquals( 3, Preference.list( "escode.logging.layout" ).size() ); - assertEquals( 6, Preference.list( "escode.logging.appender" ).size() ); - assertEquals( 8, Preference.list( "escode.logging.logger" ).size() ); - } - finally - { - Preference.clear(); - Preference.clearRule(); - } - } - -} diff --git a/org.tizen.common/test/src/org/tizen/common/util/FilterIteratorTest.java b/org.tizen.common/test/src/org/tizen/common/util/FilterIteratorTest.java old mode 100755 new mode 100644 index 1aa2390..931e4d6 --- a/org.tizen.common/test/src/org/tizen/common/util/FilterIteratorTest.java +++ b/org.tizen.common/test/src/org/tizen/common/util/FilterIteratorTest.java @@ -1,27 +1,27 @@ /* - * Common - * - * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. - * - * Contact: - * BonYong Lee - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Contributors: - * - S-Core Co., Ltd - * - */ +* Common +* +* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. +* +* Contact: +* BonYong Lee +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +* +* Contributors: +* - S-Core Co., Ltd +* +*/ package org.tizen.common.util; import static org.junit.Assert.assertEquals; -- 2.7.4