package com.wizzardo.http.framework;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.util.Map;

public class ConfigTest extends WebApplicationTest {

    @Before
    public void setUp() throws NoSuchMethodException, ClassNotFoundException, NoSuchFieldException {
        System.out.println("setUp " + this.getClass().getSimpleName() + "." + name.getMethodName());
        server = new WebApplication();
        server.setHost(null);
        server.setPort(port);
        server.setContext(context);
        server.setWorkersCount(workers);
        server.setIoThreadsCount(1);
    }

    @Test
    public void test() throws IOException {
        server.setEnvironment(Environment.TEST);
        server.start();

        Assert.assertEquals("value", server.getConfig().get("key"));
        Assert.assertEquals("c", ((Map) server.getConfig().get("a")).get("b"));
        Assert.assertEquals(1, ((Map) server.getConfig().get("a")).get("c"));

        Assert.assertTrue(((Map) server.getConfig().get("environments")).isEmpty());
    }

    @Test
    public void test_environments_test() throws IOException {
        server.setEnvironment(Environment.TEST);
        server.start();

        Assert.assertEquals("test", server.getConfig().get("env"));
        Assert.assertEquals("test", server.getConfig().get("environment"));
    }

    @Test
    public void test_environments_dev() throws IOException {
        server.setEnvironment(Environment.DEVELOPMENT);
        server.start();

        Assert.assertEquals("dev", server.getConfig().get("env"));
        Assert.assertEquals("development", server.getConfig().get("environment"));
    }

    @Test
    public void test_environments_prod() throws IOException {
        server.setEnvironment(Environment.PRODUCTION);
        server.start();

        Assert.assertEquals("prod", server.getConfig().get("env"));
        Assert.assertEquals("production", server.getConfig().get("environment"));
    }
}

@@ -31,16 +31,139 @@
 ework;%0A%0A
+import com.wizzardo.http.framework.template.ResourceTools;%0Aimport com.wizzardo.http.framework.template.TestResourcesTools;%0A
 import o
@@ -584,16 +584,172 @@
 cation()
+%7B%0A            @Override%0A            protected ResourceTools createResourceTools() %7B%0A                return new TestResourcesTools();%0A            %7D%0A        %7D
 ;%0A      

fix tests