indexing description: "test switches from async to sync and vice-versa. " library: "elogger" copyright: "Copyright (c) 2006, AXA Rosenberg, and others (see copyright.txt)" author: "Ulrich Weiss, and others" license: "Eiffel Forum License v2 (see forum.txt)" date: "$Date: $" revision: "$Revision: $" archive: "$Archive: $" deferred class TEST_ELOG_ASYNC_APPENDER inherit TS_TEST_CASE undefine name_of_id, execute_i_th end ELOG_SHARED_HIERARCHY feature -- Basic operations test_async_basic is -- test basic asynchronous logging. local h: ELOG_HIERARCHY a: ELOG_BUFFER_APPENDER e: ELOG_EVENT i: INTEGER do create h.make (Warning_severity) create a.make ("bufferappender", False) -- this appender is asynchronous by default h.root.add_appender (a) from i := 1 until i > 4 loop h.root.log_warning (create {ELOG_SIMPLE_EVENT}.make ("message "+i.out)) i := i+1 end a.wait (False) e := a.buffer.remove assert_strings_equal ("buffer1", "message 1", e.message) e := a.buffer.remove assert_strings_equal ("buffer2", "message 2", e.message) e := a.buffer.remove assert_strings_equal ("buffer3", "message 3", e.message) e := a.buffer.remove assert_strings_equal ("buffer4", "message 4", e.message) e := a.buffer.remove assert ("buffer5", e = Void) end test_async_switches is -- test switches from async to sync and vice-versa. local h: ELOG_HIERARCHY a: ELOG_BUFFER_APPENDER e: ELOG_EVENT i, j, max: INTEGER do create h.make (Warning_severity) create a.make ("bufferappender", False) -- this appender is asynchronous by default h.root.add_appender (a) max := 1000 from i := 1 until i > max loop h.root.log_warning (create {ELOG_SIMPLE_EVENT}.make ("m"+i.out)) if i = 100 then a.set_synchronous_wait from j := 1 until j > 100 loop e := a.buffer.remove assert_strings_equal ("buffer"+j.out, "m"+j.out, e.message) j := j + 1 end assert ("buffer size", a.buffer.is_empty) elseif i > 100 and i < 201 then -- we are synchronous here e := a.buffer.remove assert_strings_equal ("buffer"+i.out, "m"+i.out, e.message) assert ("buffer size", a.buffer.is_empty) elseif i = 201 then -- set back to asynchronous a.set_asynchronous elseif i = max then -- wait until all the events are put in the queue a.wait (False) -- print_buffer (a.buffer) from j := 201 until j > max loop e := a.buffer.remove assert_strings_equal ("buffer"+j.out, "m"+j.out, e.message) j := j + 1 end assert ("buffer size", a.buffer.is_empty) end i := i + 1 end a.close end end