⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 icldataqtransferclient.java

📁 SRI international 发布的OAA框架软件
💻 JAVA
字号:
package com.sri.oaa2.test.client;

import com.sri.oaa2.agentlib.AgentException;
import com.sri.oaa2.icl.IclList;
import com.sri.oaa2.icl.IclTerm;
import com.sri.oaa2.test.agent.OaaTest_T;
import junit.framework.Assert;
import junit.framework.TestCase;

/**
 * Author: Chris Brigham (cbrigham)
 * Date: Jul 9, 2004
 * Time: 1:54:01 PM
 * Description: Tests IclDataQ through the facilitator and with direct_connect.
 * Requires testAgent connected to the same facilitator to pass all tests.
 */
public class IclDataQTransferClient extends TestCase {

    OaaTest_T oaaTest;

    public IclDataQTransferClient(String test) {
        super(test);
    }

    public void setUp() {
        oaaTest = new OaaTest_T() {
            public String getAgentName() {
                return "IclDataQTransferClient";
            }

        };
    }

    public void testIclDataQDirectConnect() {
        copyData(true);
    }

    public void testIclDataQFacilitator() {
        copyData(false);
    }

    private void copyData(boolean dc) {
        int[] data = {
            10,
            100,
            1000,
            10000,
            65535,
            100000,
            261121,
            500000,
            1000000,
        };

        //System.out.println("..done building test Strings");

        IclList answers;
        String random;

        try {
            oaaTest.facilitatorConnect(new String[]{});

            for (int i = 0; i < data.length; i++) {

                random = makeString(data[i]);
                answers = oaaTest.solve("copyData(icldataq(\"" + random + "\"), DataCopy)", dc ? "[direct_connect(true)]" : "[]");
                try {
                    Assert.assertEquals("IclDataQ of size " + data[i] + " failed through " + (dc ? "direct_connect" : "fac"), IclTerm.fromString("icldataq(\"" + random + "\")"), answers.getTerm(0).getTerm(1));
                } catch (Exception e) {
                    e.printStackTrace();
                }

            }

        } catch (AgentException e) {
            e.printStackTrace();
            Assert.assertTrue(false);
        }
    }

    private String makeString(int size) {
        StringBuffer s = new StringBuffer();

        for (int indx = 0; indx < size; indx++) {
            char c = (char) ('a' + Math.round(Math.random() * ('z' - 'a')));
            s.append(c);
        }

        return s.toString();
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -