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 #define LOG4CXX_TEST 1
19 #include <log4cxx/private/log4cxx_private.h>
20
21
22 #include <log4cxx/logmanager.h>
23 #include <log4cxx/logger.h>
24 #include <log4cxx/helpers/pool.h>
25 #include <apr_file_io.h>
26 #include "../insertwide.h"
27 #include "../logunit.h"
28
29 using namespace log4cxx;
30
LOGUNIT_CLASS(TestCase2)31 LOGUNIT_CLASS(TestCase2)
32 {
33 LOGUNIT_TEST_SUITE(TestCase2);
34 LOGUNIT_TEST(xmlTest);
35 LOGUNIT_TEST_SUITE_END();
36
37 public:
38 void setUp()
39 {
40 helpers::Pool p;
41 apr_file_copy("input/xml/defaultInit.xml", "log4cxx.xml", APR_FPROT_UREAD | APR_FPROT_UWRITE, p.getAPRPool());
42 }
43
44 void tearDown()
45 {
46 helpers::Pool p;
47 apr_file_remove("log4cxx.xml", p.getAPRPool());
48 LogManager::shutdown();
49 }
50
51 void xmlTest()
52 {
53 LoggerPtr root = Logger::getRootLogger();
54 LOG4CXX_DEBUG(root, "Hello, world");
55 bool rootIsConfigured = !root->getAllAppenders().empty();
56 LOGUNIT_ASSERT(rootIsConfigured);
57
58 AppenderList list = root->getAllAppenders();
59 AppenderPtr appender = list.front();
60 LOGUNIT_ASSERT_EQUAL((LogString) LOG4CXX_STR("D1"), appender->getName());
61 }
62
63 };
64
65 LOGUNIT_TEST_SUITE_REGISTRATION(TestCase2)
66
67
68