/*
 * Copyright @ 2015 Atlassian Pty Ltd
 *
 * 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.
 */
package org.jitsi.meet.test.base;

import java.io.*;
import java.util.*;

/**
 * Loads custom settings.properties an populates them in system properties.
 *
 * @author Damian Minkov
 */
public class TestSettings
{
    /**
     * The settings file we will use to load properties needed for tests.
     */
    private static final String SETTINGS_PROPERTIES_LOCATION
        = "settings.properties";

    /**
     * Initialize the settings by loading the properties file and use all
     * its values as system properties.
     *
     * @return a properties set containing all the stuff from
     * {@link #SETTINGS_PROPERTIES_LOCATION} file merged with the
     * {@link System#getProperties()} set.
     */
    public static Properties initSettings()
    {
        // will load properties from settings.properties files
        try (
            InputStream is
                = TestSettings.class.getClassLoader()
                    .getResourceAsStream(SETTINGS_PROPERTIES_LOCATION))
        {
            // settings.properties file is missing
            if (is == null)
            {
                throw new RuntimeException("Missing settings.properties file.");
            }

            // take current system properties as we will set merged props
            // to system
            Properties p = new Properties(System.getProperties());
            p.load(is);

            // setting system properties
            System.setProperties(p);

            initFolders();

            return p;
        }
        catch (IOException e)
        {
            throw new RuntimeException(e);
        }
    }

    /**
     * Init folders. Like creating custom screen shot folders if they are not
     * created.
     */
    private static void initFolders()
    {
        // FIXME Remove. This directory is created on lazy access to screenshots
        // output dir.
        String shotsDirStr = System.getProperty("appium.screenshots.dir");
        if (shotsDirStr != null)
        {
            File shotsDir = new File(shotsDirStr);
            shotsDir.mkdirs();
        }
    }
}

@@ -2056,36 +2056,8 @@
 );%0A%0A
-            initFolders();%0A%0A
     
@@ -2186,482 +2186,7 @@
    %7D
-%0A%0A    /**%0A     * Init folders. Like creating custom screen shot folders if they are not%0A     * created.%0A     */%0A    private static void initFolders()%0A    %7B%0A        // FIXME Remove. This directory is created on lazy access to screenshots%0A        // output dir.%0A        String shotsDirStr = System.getProperty(%22appium.screenshots.dir%22);%0A        if (shotsDirStr != null)%0A        %7B%0A            File shotsDir = new File(shotsDirStr);%0A            shotsDir.mkdirs();%0A        %7D%0A    %7D
 %0A%7D%0A

remove initFolders()