1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements.  See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License.  You may obtain a copy of the License at
8  *
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #include <log4cxx/logmanager.h>
19 #include <log4cxx/logger.h>
20 #include <log4cxx/helpers/pool.h>
21 #include <apr_file_io.h>
22 #include "../insertwide.h"
23 #include "../logunit.h"
24 
25 using namespace log4cxx;
26 
LOGUNIT_CLASS(TestCase3)27 LOGUNIT_CLASS(TestCase3)
28 {
29 	LOGUNIT_TEST_SUITE(TestCase3);
30 	LOGUNIT_TEST(testProperties);
31 	LOGUNIT_TEST_SUITE_END();
32 
33 public:
34 	void setUp()
35 	{
36 		helpers::Pool p;
37 		apr_file_copy("input/defaultInit3.properties", "log4cxx.properties", APR_FPROT_UREAD | APR_FPROT_UWRITE, p.getAPRPool());
38 	}
39 
40 	void tearDown()
41 	{
42 		helpers::Pool p;
43 		apr_file_remove("log4cxx.properties", p.getAPRPool());
44 		LogManager::shutdown();
45 	}
46 
47 	void testProperties()
48 	{
49 		LoggerPtr root = Logger::getRootLogger();
50 		LOG4CXX_DEBUG(root, "Hello, world");
51 		bool rootIsConfigured = !root->getAllAppenders().empty();
52 		LOGUNIT_ASSERT(rootIsConfigured);
53 
54 		AppenderList list = root->getAllAppenders();
55 		AppenderPtr appender = list.front();
56 		LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("D3"), appender->getName());
57 	}
58 
59 };
60 
61 LOGUNIT_TEST_SUITE_REGISTRATION(TestCase3)
62