これは私の前の質問へのフォローアップの質問です。
ServiceLocator クラスのテスト ケースを作成しようとしていますが、次のエラーが表示されます。
com/iplanet/ias/admin/common/ASException
java.lang.NoClassDefFoundError: com/iplanet/ias/admin/common/ASException
at java.lang.ClassLoader.defineClass1(Native Method)
私のテストケース:
public void testServiceLocator () throws UivException, NamingException
{
DataSource ds = ServiceLocator.getInstance().getDataSource("jdbc/RSRC/my/mydb");
//I have not put any assert statements because i know above line is failing
}
上記のコードは、getInstance()
次のようなメソッドで失敗します。
static public ServiceLocator getInstance() throws UivException {
try {
if (me == null) {
synchronized(ServiceLocator.class) {
me = new ServiceLocator();
}
}
return me;
}
catch (UivException e) {
throw new UivException(ErrorCode.SERVICE_LOCATOR_ERROR,
ErrorCode.SERVICE_LOCATOR_LOOKUP_ERROR,
e.getMessage());
}
}
ServiceLocator
フロントエンドからアプリケーションをテストしても問題がないため、これがうまく機能することはわかっています。このテスト ケースを書いている唯一の理由は、DAOをテストしたいからです。そして、私が DAO をテストするには、 ServiceLocator
( JUnitから) 動作する必要があります。
エラーメッセージの意味がわかりません。誰かが私が試してうまくいくことを提案したいですか?
編集: ServiceLocator コンストラクター
private ServiceLocator() throws UivException {
try {
ic = new InitialContext();
// System.out.println("Created the Initial Context");
cache = Collections.synchronizedMap(new HashMap());
}
catch (NamingException ne) {
throw new UivException(ErrorCode.SERVICE_LOCATOR_ERROR,
0, ne.getMessage());
}
catch (NullPointerException e) {
throw new UivException(ErrorCode.SERVICE_LOCATOR_ERROR,
0, e.getMessage());
}
}