3 * WikiFetchThread is a background thread that fetches
4 * pages from the preload list until the suite is done.
7 package com
.piclab
.wikitest
;
8 import com
.meterware
.httpunit
.*;
10 public class WikiFetchThread
extends Thread
{
12 private WebConversation m_conv
;
13 private int m_totalfetches
;
14 private long m_totaltime
;
15 private volatile boolean m_running
;
18 public WikiFetchThread() {
19 m_conv
= new WebConversation();
24 public int getFetches() { return m_totalfetches
; }
25 public long getTime() { return m_totaltime
; }
26 public void requestStop() { m_running
= false; }
39 url
= WikiTest
.viewUrl( "" ); /* Main page */
40 } else if ( r
< 0.15 ) {
41 url
= WikiTest
.viewUrl( "Special:Recentchanges" );
43 if ( ++index
>= WikiSuite
.preloadedPages
.length
) { index
= 0; }
44 url
= WikiTest
.viewUrl( WikiSuite
.preloadedPages
[index
] );
47 start
= System
.currentTimeMillis();
49 WebResponse wr
= m_conv
.getResponse( url
);
50 } catch (Exception e
) {
51 WikiSuite
.warning( "Error (" + e
+ ") fetching \"" + url
+ "\"" );
53 end
= System
.currentTimeMillis();
55 WikiSuite
.finer( "Fetched \"" + url
+ "\"" );
57 m_totaltime
+= ( end
- start
);
61 } catch( InterruptedException e
) {
66 * The main suite tells us to stop, but we wait until the
67 * current fetch is done. So we have the suite wait for us
68 * to actually stop before continuing with its final report,
69 * and we wake it up here.
71 synchronized (this) { notify(); }