woolpack.test
クラス TestConcurrent

java.lang.Object
  上位を拡張 woolpack.test.TestConcurrent

public class TestConcurrent
extends java.lang.Object

並列性制御(セマフォとロック)をテストするための、execute()内で実行状況を記録するクラス。

作成者:
nakamura

コンストラクタの概要
TestConcurrent(java.lang.String label, java.lang.Object lock, int minConcurrent, int maxConcurrent, int threadCount, int threshold)
          コンストラクタ。
TestConcurrent(java.lang.String label, java.lang.Object lock, int minConcurrent, int maxConcurrent, int threadCount, int threshold, double failOdds)
          コンストラクタ。
 
メソッドの概要
 boolean assertValid()
          execute()の実行状況を検証する。
 void execute()
          並行性制御を実装しているクラスから呼び出される(called)。
 int getCount()
          execute()が実行された回数を返す。
 void print()
          execute()の実行状況を標準出力する。
 void setThreadId(int i)
          記録するスレッドの識別子(ゼロ開始)を設定する。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

コンストラクタの詳細

TestConcurrent

public TestConcurrent(java.lang.String label,
                      java.lang.Object lock,
                      int minConcurrent,
                      int maxConcurrent,
                      int threadCount,
                      int threshold)
コンストラクタ。

パラメータ:
label - 実行状況を標準出力する際の先頭の文字列。
lock - 実行状況を記録する際のロックオブジェクト。
minConcurrent - 期待される同時実行可能な最小のスレッド数。
maxConcurrent - 期待される同時実行可能な最大のスレッド数。
threadCount - テストにおいて並行して実行するスレッド数。
threshold - 実行状況を検証するための許容範囲(単位は件)。

TestConcurrent

public TestConcurrent(java.lang.String label,
                      java.lang.Object lock,
                      int minConcurrent,
                      int maxConcurrent,
                      int threadCount,
                      int threshold,
                      double failOdds)
コンストラクタ。

パラメータ:
label - 実行状況を標準出力する際の先頭の文字列。
lock - 実行状況を記録する際のロックオブジェクト。
minConcurrent - 期待される同時実行可能な最小のスレッド数。
maxConcurrent - 期待される同時実行可能な最大のスレッド数。
threadCount - テストにおいて並行して実行するスレッド数。
threshold - 実行状況を検証するための許容範囲(単位は件)。
failOdds - 実行状況を記録した後にRuntimeExceptionを発生させる確率。
メソッドの詳細

getCount

public int getCount()
execute()が実行された回数を返す。

戻り値:
execute()が実行された回数。

setThreadId

public void setThreadId(int i)
記録するスレッドの識別子(ゼロ開始)を設定する。

パラメータ:
i - 記録するスレッドの識別子(ゼロ開始)。

execute

public void execute()
並行性制御を実装しているクラスから呼び出される(called)。 呼び出された回数、スレッド識別子、並行実行数を記録し、 内容がコンストラクタ引数と合致しているか検証する。 最後に確率的ににRuntimeExceptionを発生させる。


print

public void print()
execute()の実行状況を標準出力する。


assertValid

public boolean assertValid()
execute()の実行状況を検証する。 検証結果が偽の場合は実行状況を標準出力する。

戻り値:
execute()の実行状況を検証した結果。


Copyright (C) 2006 Takahiro Nakamura. All rights reserved.