*/\r
package org.tizen.ncli.ide.test;\r
\r
+import java.io.File;\r
import java.io.IOException;\r
import java.io.InputStream;\r
import java.util.Properties;\r
protected static Logger log = LoggerFactory.getLogger(CommonCLISubCommandTest.class);\r
protected static Properties testGlobalProp = new Properties();\r
protected static Properties testLocalProp = new Properties();\r
+ protected static File testLocalConf = null;\r
\r
@BeforeClass\r
public static void prepare_once() {\r
protected static InputStream loadTestLocalConfig() {\r
final ClassLoader classLoader = CommonCLISubCommandTest.class.getClassLoader();\r
final String testFilePath = CommonCLISubCommandTest.class.getPackage().getName().replace(".", "/")+"/tizen-cli-config-local";\r
+ testLocalConf = new File(classLoader.getResource(testFilePath).getFile());\r
InputStream configStream = null;\r
configStream = classLoader.getResourceAsStream(testFilePath);\r
return configStream;\r
\r
import static org.junit.Assert.*;\r
import static org.powermock.api.mockito.PowerMockito.doAnswer;\r
+import static org.powermock.api.mockito.PowerMockito.mockStatic;\r
import static org.powermock.api.mockito.PowerMockito.spy;\r
+import static org.powermock.api.mockito.PowerMockito.when;\r
\r
import java.io.InputStream;\r
import java.util.Collection;\r
import org.tizen.common.config.Preference;\r
import org.tizen.common.config.provider.EnvironmentProvider;\r
import org.tizen.common.config.provider.SystemPropertiesProvider;\r
+import org.tizen.ncli.ide.CLIConstant;\r
import org.tizen.ncli.ide.config.CLIConfig;\r
+import org.tizen.ncli.ide.core.config.NCLIConfigLoader;\r
import org.tizen.ncli.ide.core.config.TizenCLIConfigProvider;\r
import org.tizen.ncli.ide.subcommands.ConfigCLICommand;\r
\r
\r
}\r
\r
+ @PrepareForTest(NCLIConfigLoader.class )\r
@Test\r
public void test_setLocalConfig() throws Exception {\r
- final TizenCLIConfigProvider globalProvider = new TizenCLIConfigProvider(testGlobalProp);\r
- final TizenCLIConfigProvider localProvider = new TizenCLIConfigProvider(testLocalProp);\r
-\r
- ConfigCLICommand configCmd = spy(new ConfigCLICommand());\r
+ \r
+ mockStatic(NCLIConfigLoader.class);\r
+ \r
+ when(NCLIConfigLoader.getLocalConfigFile()).thenReturn(testLocalConf);\r
+ when(NCLIConfigLoader.loadLocalConf()).thenReturn(testLocalProp);\r
+\r
+ final TizenCLIConfigProvider globalProvider = new TizenCLIConfigProvider(testGlobalProp);\r
+ final TizenCLIConfigProvider localProvider = new TizenCLIConfigProvider(NCLIConfigLoader.loadLocalConf());\r
+ \r
+ \r
+ ConfigCLICommand configCmd = spy(new ConfigCLICommand());\r
\r
doAnswer(new Answer<Object>() {\r
\r
Preference.register("OS", new EnvironmentProvider());\r
Preference.register("JVM", new SystemPropertiesProvider());\r
Preference.register("TIZEN.CLI.GLOBAL", globalProvider);\r
- Preference.register("TIZEN.CLI.LOCAL", localProvider);\r
+ Preference.register(CLIConstant.TIZEN_CLI_LOCAL_KEY, localProvider);\r
return "run command called";\r
}\r
\r