Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.Opens in a new tab

For information on migrating to InterSystems IRISOpens in a new tab, see Why Migrate to InterSystems IRIS?

テスト・クラスの作成

Jalapeño の動作を確認するために、テスト・クラスを作成します。以下の Test というクラスは、次の操作を行う main メソッドを含みます。

  1. DBService のインスタンスを作成します。

  2. 2 つの Contact インスタンスを作成します。

  3. DBService を使用して、Contact インスタンスを Caché に保存します。

  4. DBService を使用して、Contact インスタンスを Caché から取得します。

Test の完全なコードは以下のとおりです。


package basic;
import java.util.Iterator;
public class Test {
    private static DBService service;
    public static void main (String[] args) throws Exception
    {
        service = new DBService();
       
        //Create and save two contacts
        Contact contact = new Contact();
        contact.name = "Smith,John";
        contact.contactType = "Business";
        service.saveContact(contact);
        contact = new Contact();
        contact.name="Smith,Jane";
        contact.contactType="Business";
        service.saveContact(contact);
        
        //retrieve and display contacts
        for (Iterator iter = service.allContacts(); iter.hasNext();)
        {
           Contact con = (Contact)iter.next();
           System.out.printf("Name: %s Type: %s\n", con.name, con.contactType);
        }        
    }      
} 

Note:

これらの例に示したコードが実行されると、アプリケーションのクラスパスに ASM ライブラリがないことに関する警告が system.err に送信されることがあります。この詳細は、付録の "アクセス設定" を参照してください。

FeedbackOpens in a new tab