/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements. See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You 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.apache.logging.log4j.core.config.builder;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LifeCycle;
import org.apache.logging.log4j.core.LoggerContext;
import org.apache.logging.log4j.core.config.Configuration;

import org.apache.logging.log4j.core.config.ConfigurationFactory;
import org.apache.logging.log4j.core.config.LoggerConfig;
import org.apache.logging.log4j.core.filter.ThresholdFilter;
import org.junit.Test;

import java.util.Map;

import static org.junit.Assert.*;

/**
 *
 */
public class ConfigurationAssemblerTest {

    @Test
    public void doConfigure() throws Exception {
        System.setProperty(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY, "org.apache.logging.log4j.core.config.builder.CustomConfigurationFactory");
        Configuration config = ((LoggerContext)LogManager.getContext(false)).getConfiguration();
        assertNotNull("No configuration created", config);
        assertEquals("Incorrect State: " + config.getState(), config.getState(), LifeCycle.State.STARTED);
        Map<String, Appender> appenders = config.getAppenders();
        assertNotNull(appenders);
        assertTrue("Incorrect number of Appenders: " + appenders.size(), appenders.size() == 1);
        Map<String, LoggerConfig> loggers = config.getLoggers();
        assertNotNull(loggers);
        assertTrue("Incorrect number of LoggerConfigs: " + loggers.size(), loggers.size() == 2);
        Filter filter = config.getFilter();
        assertNotNull("No Filter", filter);
        assertTrue("Not a Threshold Filter", filter instanceof ThresholdFilter);
        Logger logger = LogManager.getLogger(getClass());
        logger.info("Welcome to Log4j!");
    }
}

@@ -849,16 +849,174 @@
 ilder;%0A%0A
+import static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.Map;%0A%0A
 import o
@@ -1047,24 +1047,24 @@
 LogManager;%0A
-
 import org.a
@@ -1342,17 +1342,16 @@
 ration;%0A
-%0A
 import o
@@ -1555,66 +1555,8 @@
 t;%0A%0A
-import java.util.Map;%0A%0Aimport static org.junit.Assert.*;%0A%0A
 /**%0A
@@ -1664,16 +1664,34 @@
 ption %7B%0A
+        try %7B%0A    
         
@@ -1761,16 +1761,36 @@
 ROPERTY,
+%0A                   
  %22org.ap
@@ -1854,24 +1854,28 @@
 nFactory%22);%0A
+    
         Conf
@@ -1909,16 +1909,17 @@
 Context)
+ 
 LogManag
@@ -1956,24 +1956,28 @@
 guration();%0A
+    
         asse
@@ -2027,24 +2027,28 @@
 g);%0A        
+  
+  
 assertEquals
@@ -2134,32 +2134,36 @@
 ARTED);%0A        
+    
 Map%3CString, Appe
@@ -2203,32 +2203,36 @@
 ders();%0A        
+ 
+   
 assertNotNull(ap
@@ -2237,24 +2237,28 @@
 appenders);%0A
+    
         asse
@@ -2342,32 +2342,36 @@
  == 1);%0A        
+    
 Map%3CString, Logg
@@ -2411,32 +2411,36 @@
 gers();%0A        
+   
+ 
 assertNotNull(lo
@@ -2443,24 +2443,28 @@
 l(loggers);%0A
+    
         asse
@@ -2556,16 +2556,20 @@
         
+  
+  
 Filter f
@@ -2592,24 +2592,28 @@
 etFilter();%0A
+    
         asse
@@ -2644,32 +2644,36 @@
 ilter);%0A        
+ 
+   
 assertTrue(%22Not 
@@ -2721,32 +2721,36 @@
 resholdFilter);%0A
+    
         Logger l
@@ -2799,16 +2799,20 @@
         
+    
 logger.i
@@ -2833,20 +2833,146 @@
 o Log4j!%22);%0A
+        %7D finally %7B%0A            System.getProperties().remove(ConfigurationFactory.CONFIGURATION_FACTORY_PROPERTY);%0A        %7D%0A
     %7D%0A%7D%0A

Reset sys prop at the end of the test. Use specific static imports instead of *.