📄 clientconnect_t.java
字号:
/* $Id: ClientConnect_T.java,v 1.4 2004/02/05 23:28:59 giuli Exp $*/
/*
* The contents of this file are subject to the OAA Community Research
* License Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License
* at http://www.ai.sri.com/~oaa/. Software distributed under the License
* is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific language governing
* rights and limitations under the License. Portions of the software are
* Copyright (c) SRI International, 1999. All rights reserved.
* "OAA" is a registered trademark, and "Open Agent Architecture" is a
* trademark, of SRI International, a California nonprofit public benefit
* corporation.
*/
package com.sri.oaa2.test.client;
import com.sri.oaa2.test.agent.OaaTest_T;
import com.sri.oaa2.test.agent.TestAgent;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
*
*/
public class ClientConnect_T extends TestCase {
OaaTest_T oaaAgent = new OaaTest_T() {
public String getAgentName() {
return "oaa2_unitTest_agent_client";
}
};
public ClientConnect_T(String name) {
super(name);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
public static Test suite() {
return new TestSuite(ClientConnect_T.class);
}
public void testConnect0() throws Exception {
oaaAgent.facilitatorConnect(new String[]{});
assertTrue("# connections = " + oaaAgent.getLibOaa().getComLib().getAllValidConnections().size(),
oaaAgent.getLibOaa().getComLib().getAllValidConnections().size() == 1);
oaaAgent.facilitatorDisconnect();
Thread.sleep(500L);
}
public void testConnect1() throws Exception {
oaaAgent.facilitatorConnect(new String[]{});
oaaAgent.facilitatorDisconnect();
oaaAgent.facilitatorConnect(new String[]{});
oaaAgent.facilitatorDisconnect();
}
public void testConnect2() throws Exception {
TestAgent agent = new TestAgent("add_test");
agent.facilitatorConnect(new String[]{});
agent.facilitatorDisconnect();
}
public void testConnectListen0() throws Exception {
oaaAgent.facilitatorConnect(new String[]{"-oaa_listen", "tcp('localhost',4016)"});
assertTrue("# connections = " + oaaAgent.getLibOaa().getComLib().getAllValidConnections().size(),
oaaAgent.getLibOaa().getComLib().getAllValidConnections().size() == 2);
oaaAgent.facilitatorDisconnect();
}
public void testConnectListen1() throws Exception {
// Execute testConnectListen0 again to make sure the port is open
// again.
testConnectListen0();
}
public void testConnectListen2() throws Exception {
System.setProperty("OAA_LISTEN", "tcp('localhost',4016)");
oaaAgent.facilitatorConnect(new String[]{});
assertTrue("# connections = " + oaaAgent.getLibOaa().getComLib().getAllValidConnections().size(),
oaaAgent.getLibOaa().getComLib().getAllValidConnections().size() == 2);
System.setProperty("OAA_LISTEN", "");
oaaAgent.facilitatorDisconnect();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -