[openrtm-commit:00411] r563 - in trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC: . port
openrtm @ openrtm.org
openrtm @ openrtm.org
2011年 9月 20日 (火) 13:12:59 JST
Author: fsi-katami
Date: 2011-09-20 13:12:59 +0900 (Tue, 20 Sep 2011)
New Revision: 563
Modified:
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ConfigAdminTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ManagerServantTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ModuleManagerTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataInOutPortTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataInPortTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataOutPortTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortBaseTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortCorbaConsumerTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortCorbaProviderTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortProviderImplTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortProviderTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortPushConnectorTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortBaseTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaCdrProviderTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaConsumerTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaProviderTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortProviderImplTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortProviderTest.java
trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortPushConnectorTest.java
Log:
Programs for the test have been updated.
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ConfigAdminTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ConfigAdminTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ConfigAdminTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -6,6 +6,9 @@
import java.util.List;
import java.util.Vector;
+import jp.go.aist.rtm.RTC.ConfigurationSetNameListener;
+import jp.go.aist.rtm.RTC.ConfigurationParamListener;
+import jp.go.aist.rtm.RTC.ConfigurationSetListener;
import jp.go.aist.rtm.RTC.util.ByteHolder;
import jp.go.aist.rtm.RTC.util.DoubleHolder;
import jp.go.aist.rtm.RTC.util.FloatHolder;
@@ -30,7 +33,8 @@
private ConfigAdmin admin;
// OnUpdateCallback Mock
- public class OnUpdateCallbackMock implements OnUpdateCallbackFunc {
+ //public class OnUpdateCallbackMock implements OnUpdateCallbackFunc {
+ public class OnUpdateCallbackMock extends ConfigurationSetNameListener {
public void operator(String config_set) {
m_config_set = config_set;
}
@@ -38,7 +42,8 @@
}
// OnUpdateParamCallback Mock
- public class OnUpdateParamCallbackMock implements OnUpdateParamCallbackFunc {
+ //public class OnUpdateParamCallbackMock implements OnUpdateParamCallbackFunc {
+ public class OnUpdateParamCallbackMock extends ConfigurationParamListener {
public void operator(String config_set, String config_param) {
m_config_set = config_set;
m_config_param = config_param;
@@ -48,7 +53,8 @@
}
// OnSetConfigurationSetCallback Mock
- public class OnSetConfigurationSetCallbackMock implements OnSetConfigurationSetCallbackFunc {
+ //public class OnSetConfigurationSetCallbackMock implements OnSetConfigurationSetCallbackFunc {
+ public class OnSetConfigurationSetCallbackMock extends ConfigurationSetListener {
public void operator(Properties config_set) {
m_config_set = new Properties(config_set);
}
@@ -56,7 +62,8 @@
}
// OnAddConfigurationAddCallback Mock
- public class OnAddConfigurationAddCallbackMock implements OnAddConfigurationAddCallbackFunc {
+ //public class OnAddConfigurationAddCallbackMock implements OnAddConfigurationAddCallbackFunc {
+ public class OnAddConfigurationAddCallbackMock extends ConfigurationSetListener {
public void operator(Properties config_set) {
m_config_set = new Properties(config_set);
}
@@ -64,7 +71,8 @@
}
// OnRemoveConfigurationSetCallback Mock
- public class OnRemoveConfigurationSetCallbackMock implements OnRemoveConfigurationSetCallbackFunc {
+ //public class OnRemoveConfigurationSetCallbackMock implements OnRemoveConfigurationSetCallbackFunc {
+ public class OnRemoveConfigurationSetCallbackMock extends ConfigurationSetNameListener{
public void operator(String config_set) {
m_config_set = config_set;
}
@@ -72,7 +80,8 @@
}
// OnActivateSetCallback Mock
- public class OnActivateSetCallbackMock implements OnActivateSetCallbackFunc {
+ //public class OnActivateSetCallbackMock implements OnActivateSetCallbackFunc {
+ public class OnActivateSetCallbackMock extends ConfigurationSetNameListener {
public void operator(String config_set) {
m_config_set = config_set;
}
@@ -84,7 +93,7 @@
super.setUp();
jp.go.aist.rtm.RTC.util.Properties props = new jp.go.aist.rtm.RTC.util.Properties("rtc");
- props.setProperty("rtc.openrtm.version", "1.0.0");
+ props.setProperty("rtc.openrtm.version", "1.1.0");
props.setProperty("rtc.openrtm.release", "aist");
props.setProperty("rtc.openrtm.vendor", "AIST");
props.setProperty("rtc.openrtm.author", "Noriaki Ando");
@@ -1033,7 +1042,7 @@
ConfigAdmin configAdmin = new ConfigAdmin(configSet);
OnUpdateCallbackMock mock = new OnUpdateCallbackMock();
- configAdmin.setOnUpdate(mock);
+ configAdmin.setOnUpdate((ConfigurationSetNameListener)mock);
String str = new String("setNewString");
configAdmin.onUpdate(str);
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ManagerServantTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ManagerServantTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ManagerServantTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -749,6 +749,7 @@
* </ul>
* </p>
*/
+/*
public void test_get_owner() {
ManagerServant pman = new ManagerServant();
RTM.Manager obj;
@@ -756,7 +757,7 @@
assertNull(obj);
}
-
+*/
/**
* <p>shutdown()メソッドのテスト
* <ul>
@@ -830,6 +831,7 @@
* </ul>
* </p>
*/
+/*
public void test_set_owner() {
ManagerServant pman = new ManagerServant();
@@ -837,13 +839,14 @@
assertNull(pman.set_owner(m_objref));
}
-
+*/
/**
* <p>set_child()メソッドのテスト
* <ul>
* </ul>
* </p>
*/
+/*
public void test_set_child() {
ManagerServant pman = new ManagerServant();
@@ -851,20 +854,21 @@
assertNull(pman.set_child(m_objref));
}
-
+*/
/**
* <p>get_child()メソッドのテスト
* <ul>
* </ul>
* </p>
*/
+/*
public void test_get_child() {
ManagerServant pman = new ManagerServant();
assertNull(pman.get_child());
}
-
+*/
/**
* <p>fork()メソッドのテスト
* <ul>
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ModuleManagerTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ModuleManagerTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/ModuleManagerTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -24,6 +24,13 @@
}
return false;
}
+ private boolean isFound2(final Vector<Properties> list, final String target) {
+ for( int index=0;index<list.size();index++ ) {
+ Vector<String> vstr = list.get(index).propertyNames();
+ isFound(vstr, target);
+ }
+ return false;
+ }
protected void setUp() throws Exception {
super.setUp();
@@ -107,7 +114,7 @@
// モジュールのロードに成功するはず
String modName = m_pModMgr.load("loadSample");
- assertTrue(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName));
+ assertTrue(isFound2(m_pModMgr.getLoadedModules(), modName));
}
/**
* <p>unload()メソッドのテスト
@@ -123,18 +130,18 @@
public void test_unload() throws Exception {
// モジュールをロードしておく
String modName1 = m_pModMgr.load("jp.go.aist.rtm.RTC.sample.loadSample");
- assertTrue(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName1));
+ assertTrue(isFound2(m_pModMgr.getLoadedModules(), modName1));
String modName2 = m_pModMgr.load("jp.go.aist.rtm.RTC.sample.loadSample2");
- assertTrue(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName2));
+ assertTrue(isFound2(m_pModMgr.getLoadedModules(), modName2));
// Success case
// ロードしておいたモジュールを正しくアンロードできるか?
m_pModMgr.unload(modName1);
- assertFalse(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName1));
+ assertFalse(isFound2(m_pModMgr.getLoadedModules(), modName1));
// アンロードしていないモジュールは、なおアンロードされずに残っているか?
- assertTrue(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName2));
+ assertTrue(isFound2(m_pModMgr.getLoadedModules(), modName2));
// Failure case
// 絶対パスを指定せず、ファイル名だけ指定した場合に、意図どおりにアンロード失敗するか?
@@ -166,15 +173,15 @@
public void test_unloadAll() throws Exception {
// モジュールをロードしておく
String modName1 = m_pModMgr.load("jp.go.aist.rtm.RTC.sample.loadSample");
- assertTrue(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName1));
+ assertTrue(isFound2(m_pModMgr.getLoadedModules(), modName1));
String modName2 = m_pModMgr.load("jp.go.aist.rtm.RTC.sample.loadSample2");
- assertTrue(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName2));
+ assertTrue(isFound2(m_pModMgr.getLoadedModules(), modName2));
// unloadAll()によって、ロード済みのモジュールがすべてアンロードされるか?
m_pModMgr.unloadAll();
- assertFalse(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName1));
- assertFalse(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName2));
+ assertFalse(isFound2(m_pModMgr.getLoadedModules(), modName1));
+ assertFalse(isFound2(m_pModMgr.getLoadedModules(), modName2));
}
/**
* <p>symbol()メソッドのテスト
@@ -187,9 +194,23 @@
public void test_symbol() throws Exception {
// モジュールをロードしておく
String modName1 = m_pModMgr.load("jp.go.aist.rtm.RTC.sample.loadSample");
- assertTrue(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName1));
+ assertTrue(isFound2(m_pModMgr.getLoadedModules(), modName1));
//
- Class target = m_pModMgr.getLoadedModules().get("jp.go.aist.rtm.RTC.sample.loadSample");
+ Vector<Properties>vprop = m_pModMgr.getLoadedModules();
+ String str = "jp.go.aist.rtm.RTC.sample.loadSample";
+ String str_target = "Comp";
+ for( int ic=0;ic<vprop.size();++ic ) {
+ Vector<String> vstr = vprop.get(ic).propertyNames();
+ for( int index=0;index<vstr.size();index++ ) {
+ String fstr = vstr.get(index);
+ if(fstr.equals(str)){
+ str_target = vprop.get(ic).getProperty(fstr);
+ }
+
+ }
+ }
+ //Class target = m_pModMgr.getLoadedModules().get("jp.go.aist.rtm.RTC.sample.loadSample");
+ Class target = Class.forName(str_target);
Method method = null;
try {
method = m_pModMgr.symbol("jp.go.aist.rtm.RTC.sample.loadSample", "SampleMethod2");
@@ -279,7 +300,7 @@
// 絶対パス指定を許可した状態で、絶対パス指定でモジュールロードできるか?
m_pModMgr.allowAbsolutePath();
String modName = m_pModMgr.load("jp.go.aist.rtm.RTC.sample.loadSample");
- assertTrue(isFound(new Vector<String>(m_pModMgr.getLoadedModules().keySet()), modName));
+ assertTrue(isFound2(m_pModMgr.getLoadedModules(), modName));
// 絶対パス指定を禁止した状態で、絶対パス指定でモジュールロードを試みて、意図どおり失敗するか?
m_pModMgr.unloadAll(); // いったんアンロードしておく
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataInOutPortTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataInOutPortTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataInOutPortTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -13,8 +13,8 @@
import RTC.TimedFloat;
import jp.go.aist.rtm.RTC.buffer.RingBuffer;
-import jp.go.aist.rtm.RTC.port.DataInPort;
-import jp.go.aist.rtm.RTC.port.DataOutPort;
+//import jp.go.aist.rtm.RTC.port.DataInPort;
+//import jp.go.aist.rtm.RTC.port.DataOutPort;
import jp.go.aist.rtm.RTC.port.InPort;
import jp.go.aist.rtm.RTC.port.OutPort;
import jp.go.aist.rtm.RTC.util.CORBA_SeqUtil;
@@ -72,22 +72,22 @@
private OutPort<TimedFloat> m_outPortNonBlock;
private DataRef<TimedFloat> m_outFloatNonBlock;
- private DataOutPort<TimedFloat> m_dataOutPortNonBlock;
+// private DataOutPort<TimedFloat> m_dataOutPortNonBlock;
// private Port m_outPortRefNonBlock;
private OutPort<TimedFloat> m_outPortBlock;
private DataRef<TimedFloat> m_outFloatBlock;
- private DataOutPort<TimedFloat> m_dataOutPortBlock;
+// private DataOutPort<TimedFloat> m_dataOutPortBlock;
// private Port m_outPortRefBlock;
private InPort<TimedFloat> m_inPortNonBlock;
private DataRef<TimedFloat> m_inFloatNonBlock;
- private DataInPort<TimedFloat> m_dataInPortNonBlock;
+// private DataInPort<TimedFloat> m_dataInPortNonBlock;
// private Port m_inPortRefNonBlock;
private InPort<TimedFloat> m_inPortBlock;
private DataRef<TimedFloat> m_inFloatBlock;
- private DataInPort<TimedFloat> m_dataInPortBlock;
+// private DataInPort<TimedFloat> m_dataInPortBlock;
// private Port m_inPortRefBlock;
private OrbRunner m_orbRunner;
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataInPortTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataInPortTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataInPortTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -16,9 +16,13 @@
import RTC.ConnectorProfile;
import RTC.ConnectorProfileHolder;
-import RTC.InPortAny;
-import RTC.InPortAnyHelper;
-import RTC.OutPortAnyPOA;
+//import RTC.InPort;
+//import RTC.InPortCdrHelper;
+import OpenRTM.InPortCdrHelper;
+import OpenRTM.OutPortCdrPOA;
+//import RTC.InPortAny;
+//import RTC.InPortAnyHelper;
+//import RTC.OutPortAnyPOA;
//import RTC.Port;
import RTC.PortProfile;
import RTC.ReturnCode_t;
@@ -30,9 +34,12 @@
*/
public class DataInPortTest extends TestCase {
- class DataInPortMock extends DataInPort {
+
+/*
+ //class DataInPortMock extends DataInPort {
+ class DataInPortMock extends InPort {
public DataInPortMock(String name, InPort<TimedFloat> inport, Properties prop) throws Exception {
- super(TimedFloat.class, name, inport, prop);
+ super(TimedFloat.class, name, inport, prop);
}
// public override for test
@@ -40,7 +47,6 @@
ConnectorProfileHolder holder = new ConnectorProfileHolder(connector_profile);
return super.publishInterfaces(holder);
}
-
// public override for test
public ReturnCode_t subscribeInterfaces_public(ConnectorProfile connector_profile) {
ConnectorProfileHolder holder = new ConnectorProfileHolder(connector_profile);
@@ -53,8 +59,10 @@
}
};
+*/
- public class OutPortAnyMock extends OutPortAnyPOA {
+ //public class OutPortAnyMock extends OutPortAnyPOA {
+ public class OutPortAnyMock extends OutPortCdrPOA {
public OutPortAnyMock(Any data) {
m_data = data;
m_calledCount = 0;
@@ -70,6 +78,10 @@
private int m_calledCount;
private Any m_data;
+ public OpenRTM.PortStatus get(OpenRTM.CdrDataHolder data) {
+
+ return OpenRTM.PortStatus.from_int(0);
+ }
}
private ORB m_pORB;
@@ -117,16 +129,17 @@
InPort<TimedFloat> pInPort = new InPort<TimedFloat>("name of InPort", inPortBindValue); // will be deleted automatically
Properties dataInPortProps = new Properties();
- DataInPort pDataInPort = null;
- try {
- pDataInPort = new DataInPort(TimedFloat.class, "name of DataInPort", pInPort, dataInPortProps);
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- } // will be deleted automatically
+// DataInPort pDataInPort = null;
+// try {
+// pDataInPort = new DataInPort(TimedFloat.class, "name of DataInPort", pInPort, dataInPortProps);
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail();
+// } // will be deleted automatically
// PortProfileを取得する
- PortProfile pPortProfile = pDataInPort.get_port_profile();
+ //PortProfile pPortProfile = pDataInPort.get_port_profile();
+ PortProfile pPortProfile = pInPort.get_port_profile();
// - PortProfileの名称が正しく取得されるか?
assertEquals("name of DataInPort", pPortProfile.name);
@@ -159,13 +172,13 @@
InPort<TimedFloat> pInPort = new InPort<TimedFloat>("name of InPort", inPortBindValue); // will be deleted automatically
Properties dataInPortProps = new Properties();
- DataInPortMock pDataInPort = null;
- try {
- pDataInPort = new DataInPortMock("name of DataInPort", pInPort, dataInPortProps);
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- } // will be deleted automatically
+// DataInPortMock pDataInPort = null;
+// try {
+// pDataInPort = new DataInPortMock("name of DataInPort", pInPort, dataInPortProps);
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail();
+// } // will be deleted automatically
// CORBA_Any, Push, Newの組合せを指定してpublishInterfaces()を呼出す
ConnectorProfile connProf = new ConnectorProfile();
@@ -179,8 +192,12 @@
CORBA_SeqUtil.push_back(properties,
NVUtil.newNV("dataport.subscription_type", "Any"));
connProf.properties = properties.value;
+// assertEquals(ReturnCode_t.RTC_OK,
+// pDataInPort.publishInterfaces_public(connProf));
+ ConnectorProfileHolder holder = new ConnectorProfileHolder(connProf);
assertEquals(ReturnCode_t.RTC_OK,
- pDataInPort.publishInterfaces_public(connProf));
+ pInPort.publishInterfaces(holder));
+
// "dataport.corba_any.inport_ref"プロパティを取得できるか?
Any inPortAnyRef = null;
@@ -207,13 +224,14 @@
InPort<TimedFloat> pInPort = new InPort<TimedFloat>("name of InPort", inPortBindValue); // will be deleted automatically
Properties dataInPortProps = new Properties();
- DataInPortMock pDataInPort = null;
- try {
- pDataInPort = new DataInPortMock("name of DataInPort", pInPort, dataInPortProps);
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- } // will be deleted automatically
+
+// DataInPortMock pDataInPort = null;
+// try {
+// pDataInPort = new DataInPortMock("name of DataInPort", pInPort, dataInPortProps);
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail();
+// } // will be deleted automatically
// TCP_Any, Pull, Periodicの組合せを指定してpublishInterfaces()を呼出す
ConnectorProfile connProf = new ConnectorProfile();
@@ -224,8 +242,11 @@
CORBA_SeqUtil.push_back(properties, NVUtil.newNV("dataport.dataflow_type", "Push"));
CORBA_SeqUtil.push_back(properties, NVUtil.newNV("dataport.subscription_type", "Any"));
connProf.properties = properties.value;
+// assertEquals(ReturnCode_t.RTC_OK,
+// pDataInPort.publishInterfaces_public(connProf));
+ ConnectorProfileHolder holder = new ConnectorProfileHolder(connProf);
assertEquals(ReturnCode_t.RTC_OK,
- pDataInPort.publishInterfaces_public(connProf));
+ pInPort.publishInterfaces(holder));
// "dataport.tcp_any.inport_addr"プロパティを取得できるか?
int index = NVUtil.find_index(new NVListHolder(connProf.properties), "dataport.tcp_any.inport_addr");
@@ -241,13 +262,14 @@
InPort<TimedFloat> pInPort = new InPort<TimedFloat>("name of InPort", inPortBindValue); // will be deleted automatically
Properties dataInPortProps = new Properties();
- DataInPortMock pDataInPort = null;
- try {
- pDataInPort = new DataInPortMock("name of DataInPort", pInPort, dataInPortProps);
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- } // will be deleted automatically
+
+// DataInPortMock pDataInPort = null;
+// try {
+// pDataInPort = new DataInPortMock("name of DataInPort", pInPort, dataInPortProps);
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail();
+// } // will be deleted automatically
// ConnectorProfileに、接続に必要となるプロパティをセットする
ConnectorProfile connProf = new ConnectorProfile();
@@ -277,8 +299,11 @@
// subscribeInterfaces()メソッドを呼び出す
// (これによりDataInPortがOutPortAnyへの参照を取得して、接続が完了する)
+ //assertEquals(ReturnCode_t.RTC_OK,
+ // pDataInPort.subscribeInterfaces_public(connProf));
+ ConnectorProfileHolder holder = new ConnectorProfileHolder(connProf);
assertEquals(ReturnCode_t.RTC_OK,
- pDataInPort.subscribeInterfaces_public(connProf));
+ pInPort.subscribeInterfaces(holder));
}
/**
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataOutPortTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataOutPortTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/DataOutPortTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -14,7 +14,8 @@
import RTC.ConnectorProfile;
import RTC.ConnectorProfileHolder;
-import RTC.InPortAnyPOA;
+import OpenRTM.InPortCdrPOA;
+//import RTC.InPortAnyPOA;
import RTC.PortInterfacePolarity;
import RTC.PortProfile;
import RTC.ReturnCode_t;
@@ -25,7 +26,7 @@
* <p>DataOutPortクラスのためのテストケースです。</p>
*/
public class DataOutPortTest extends TestCase {
-
+/*
public class DataOutPortMock extends DataOutPort<TimedFloat> {
public DataOutPortMock(String name, OutPort<TimedFloat> outport, Properties prop) throws Exception {
@@ -55,13 +56,15 @@
public String type_name = "DataOutPortMock_type_name";
public PortInterfacePolarity pol = PortInterfacePolarity.REQUIRED;
}
+*/
private OutPort<TimedFloat> m_outport;
private DataRef<TimedFloat> m_tfloat = new DataRef<TimedFloat>(new TimedFloat());
private ORB m_pORB;
private POA m_pPOA;
- public class InPortAnyMock extends InPortAnyPOA {
+ //public class InPortAnyMock extends InPortAnyPOA {
+ public class InPortAnyMock extends InPortCdrPOA {
public InPortAnyMock() {
m_calledCount = 0;
}
@@ -69,6 +72,12 @@
public final int getCalledCount() { return m_calledCount; }
private int m_calledCount;
+ public OpenRTM.PortStatus put(byte[] data)
+ {
+
+
+ return OpenRTM.PortStatus.from_int(OpenRTM.PortStatus._PORT_OK);
+ }
}
protected void setUp() throws Exception {
@@ -128,10 +137,11 @@
OutPort<TimedFloat> pOutPort = new OutPort<TimedFloat>("name of OutPort", valholder); // will be deleted automatically
Properties dataOutPortProps = new Properties();
- DataOutPort pDataOutPort = new DataOutPort(TimedFloat.class, "name of DataOutPort", pOutPort, dataOutPortProps); // will be deleted automatically
+// DataOutPort pDataOutPort = new DataOutPort(TimedFloat.class, "name of DataOutPort", pOutPort, dataOutPortProps); // will be deleted automatically
// PortProfileを取得する
- PortProfile prof = pDataOutPort.get_port_profile();
+// PortProfile prof = pDataOutPort.get_port_profile();
+ PortProfile prof = pOutPort.get_port_profile();
// - PortProfileの名称が正しく取得されるか?
assertEquals("name of DataOutPort", prof.name);
@@ -161,13 +171,13 @@
DataRef<TimedFloat> outPortBindValue = new DataRef<TimedFloat>(TimedFloatFactory.create());
OutPort<TimedFloat> pOutPort = new OutPort<TimedFloat>("name of InPort", outPortBindValue); // will be deleted automatically
- DataOutPortMock pDataOutPort = null;
- try {
- pDataOutPort = new DataOutPortMock("name of DataInPort", pOutPort, new Properties());
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- } // will be deleted automatically
+// DataOutPortMock pDataOutPort = null;
+// try {
+// pDataOutPort = new DataOutPortMock("name of DataInPort", pOutPort, new Properties());
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail();
+// } // will be deleted automatically
// CORBA_Any, Push, Newの組合せを指定してpublisherInterfaces()を呼出す
ConnectorProfile connProf = new ConnectorProfile();
@@ -178,9 +188,10 @@
CORBA_SeqUtil.push_back(properties, NVUtil.newNV("dataport.dataflow_type", "Push"));
CORBA_SeqUtil.push_back(properties, NVUtil.newNV("dataport.subscription_type", "New"));
connProf.properties = properties.value;
- assertEquals(ReturnCode_t.RTC_OK, pDataOutPort.publishInterfaces_public(connProf));
+// assertEquals(ReturnCode_t.RTC_OK, pDataOutPort.publishInterfaces_public(connProf));
+ ConnectorProfileHolder holder = new ConnectorProfileHolder(connProf);
+ assertEquals(ReturnCode_t.RTC_OK, pOutPort.publishInterfaces(holder));
- ConnectorProfileHolder holder = new ConnectorProfileHolder(connProf);
// "dataport.corba_any.outport_ref"プロパティを取得できるか?
Any outPortAnyRef = null;
try {
@@ -205,13 +216,13 @@
DataRef<TimedFloat> outPortBindValue = new DataRef<TimedFloat>(TimedFloatFactory.create());
OutPort<TimedFloat> pOutPort = new OutPort<TimedFloat>("name of InPort", outPortBindValue); // will be deleted automatically
- DataOutPortMock pDataOutPort = null;
- try {
- pDataOutPort = new DataOutPortMock("name of DataInPort", pOutPort, new Properties());
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- } // will be deleted automatically
+// DataOutPortMock pDataOutPort = null;
+// try {
+// pDataOutPort = new DataOutPortMock("name of DataInPort", pOutPort, new Properties());
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail();
+// } // will be deleted automatically
// TCP_Any, Pull, Periodicの組合せを指定してpublisherInterfaces()を呼出す
ConnectorProfile connProf = new ConnectorProfile();
@@ -222,8 +233,10 @@
CORBA_SeqUtil.push_back(properties, NVUtil.newNV("dataport.dataflow_type", "Pull"));
CORBA_SeqUtil.push_back(properties, NVUtil.newNV("dataport.subscription_type", "Periodic"));
connProf.properties = properties.value;
- assertEquals(ReturnCode_t.RTC_OK, pDataOutPort.publishInterfaces_public(connProf));
+ //assertEquals(ReturnCode_t.RTC_OK, pDataOutPort.publishInterfaces_public(connProf));
+ ConnectorProfileHolder holder = new ConnectorProfileHolder(connProf);
+ assertEquals(ReturnCode_t.RTC_OK, pOutPort.publishInterfaces(holder));
}
/**
@@ -240,13 +253,13 @@
OutPort<TimedFloat> pOutPort = new OutPort<TimedFloat>("name of OutPort", outPortBindValue); // will be deleted automatically
//
Properties dataOutPortProps = new Properties();
- DataOutPortMock pDataOutPort = null;
- try {
- pDataOutPort = new DataOutPortMock("name of DataInPort", pOutPort, dataOutPortProps);
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- } // will be deleted automatically
+// DataOutPortMock pDataOutPort = null;
+// try {
+// pDataOutPort = new DataOutPortMock("name of DataInPort", pOutPort, dataOutPortProps);
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail();
+// } // will be deleted automatically
// ConnectorProfileに、接続に必要となるプロパティをセットする
ConnectorProfile connProf = new ConnectorProfile();
@@ -265,8 +278,11 @@
// subscribeInterfaces()メソッドを呼び出す
// (これによりDataOutPortがInPortAnyへの参照を取得して、接続が完了する)
+// assertEquals(ReturnCode_t.RTC_OK,
+// pDataOutPort.subscribeInterfaces_public(connProf));
+ ConnectorProfileHolder holder = new ConnectorProfileHolder(connProf);
assertEquals(ReturnCode_t.RTC_OK,
- pDataOutPort.subscribeInterfaces_public(connProf));
+ pOutPort.subscribeInterfaces(holder));
// データ送信を行い、InPortAnyMock::put()側に到達したことをチェックすることで、接続の成功を確認する
TimedFloat sending = new TimedFloat();
@@ -293,13 +309,13 @@
DataRef<TimedFloat> outPortBindValue = new DataRef<TimedFloat>(base);
OutPort<TimedFloat> pOutPort = new OutPort<TimedFloat>("name of InPort", outPortBindValue); // will be deleted automatically
//
- DataOutPortMock pDataOutPort = null;
- try {
- pDataOutPort = new DataOutPortMock("name of DataInPort", pOutPort, new Properties());
- } catch (Exception e) {
- e.printStackTrace();
- fail();
- } // will be deleted automatically
+// DataOutPortMock pDataOutPort = null;
+// try {
+// pDataOutPort = new DataOutPortMock("name of DataInPort", pOutPort, new Properties());
+// } catch (Exception e) {
+// e.printStackTrace();
+// fail();
+// } // will be deleted automatically
// ConnectorProfileに、接続に必要となるプロパティをセットする
ConnectorProfile connProf = new ConnectorProfile();
@@ -318,8 +334,11 @@
// subscribeInterfaces()メソッドを呼び出す
// (これによりDataOutPortがInPortAnyへの参照を取得して、接続が完了する)
+// assertEquals(ReturnCode_t.RTC_OK,
+// pDataOutPort.subscribeInterfaces_public(connProf));
+ ConnectorProfileHolder holder = new ConnectorProfileHolder(connProf);
assertEquals(ReturnCode_t.RTC_OK,
- pDataOutPort.subscribeInterfaces_public(connProf));
+ pOutPort.subscribeInterfaces(holder));
// データ送信を行い、InPortAnyMock::put()側に到達したことをチェックすることで、接続の成功を確認する
TimedFloat sending = new TimedFloat();
@@ -332,7 +351,8 @@
assertEquals(1, pInPortAny.getCalledCount());
// (接続が成功した後で、)unsubscribeInterfacesを呼出す
- pDataOutPort.unsubscribeInterfaces_public(connProf);
+// pDataOutPort.unsubscribeInterfaces_public(connProf);
+ pOutPort.unsubscribeInterfaces(connProf);
// 再度データ送信を行うが、InPortAnyMock::put()側に到達しないことをチェックすることで、切断の成功を確認する
sending.data = 2.0F;
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortBaseTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortBaseTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortBaseTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -235,7 +235,10 @@
public void setLogger(Logger logger) {
m_logger = logger;
}
- private Logger m_logger;
+ private Logger m_logger;
+ public void setListener(ConnectorBase.ConnectorInfo info,
+ ConnectorListeners listeners) {
+ }
};
/**
*
@@ -347,11 +350,14 @@
*
*/
/*
- coil.Properties get_m_properties()
- {
+ coil.Properties get_m_properties()
+ {
return m_properties;
- }
+ }
*/
+ public boolean read() {
+ return true;
+ }
};
public static Logger m_mock_logger = null;
private ORB m_orb;
@@ -507,7 +513,8 @@
// RingBufferMock.m_mock_logger.countLog("RingBufferMock.Constructor"));
m_mock_logger.countLog("RingBufferMock.Constructor"));
- inport.init();
+ //inport.init();
+ inport.init(prop);
//
assertTrue("7:",null!=inport.getThebuffer());
@@ -597,7 +604,8 @@
m_mock_logger.countLog("RingBufferMock.Constructor"));
inport.setMultibuffer();
- inport.init();
+ //inport.init();
+ inport.init(prop);
assertTrue(null==inport.getThebuffer());
assertEquals("8:",0,
@@ -685,7 +693,8 @@
// RingBufferMock.m_mock_logger.countLog("RingBufferMock.Constructor"));
m_mock_logger.countLog("RingBufferMock.Constructor"));
- inport.init();
+ //inport.init();
+ inport.init(prop);
//
assertTrue("7:",null==inport.getThebuffer());
@@ -1018,7 +1027,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1092,7 +1103,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1173,7 +1186,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1251,7 +1266,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1324,7 +1341,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1391,7 +1410,9 @@
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1458,7 +1479,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1535,7 +1558,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1606,7 +1631,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1673,7 +1700,9 @@
CdrRingBufferMockInit();
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(inport);
@@ -1739,7 +1768,9 @@
}
InPortBaseMock inport = new InPortBaseMock("InPortBaseTest", "TimedFloat");
- inport.init();
+ //inport.init();
+ Properties prop = new Properties();
+ inport.init(prop);
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
RTC.ConnectorProfile prof = new RTC.ConnectorProfile();
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortCorbaConsumerTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortCorbaConsumerTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortCorbaConsumerTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -13,7 +13,8 @@
import org.omg.CORBA.Object;
import org.omg.PortableServer.POA;
-import RTC.InPortAnyPOA;
+//import RTC.InPortAnyPOA;
+import OpenRTM.InPortCdrPOA;
import _SDOPackage.NVListHolder;
/**
@@ -21,7 +22,8 @@
*/
public class InPortCorbaConsumerTest extends TestCase {
- class InPortAnyMock extends InPortAnyPOA {
+ //class InPortAnyMock extends InPortAnyPOA {
+ class InPortAnyMock extends InPortCdrPOA {
private Any m_data;
public void put(Any data) {
@@ -30,6 +32,10 @@
public Any getData() {
return m_data;
}
+ public OpenRTM.PortStatus put(byte[] data)
+ {
+ return OpenRTM.PortStatus.PORT_OK;
+ }
}
/*!
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortCorbaProviderTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortCorbaProviderTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortCorbaProviderTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -5,14 +5,19 @@
import jp.go.aist.rtm.RTC.util.NVListHolderFactory;
import jp.go.aist.rtm.RTC.util.NVUtil;
import jp.go.aist.rtm.RTC.util.TypeCast;
+import jp.go.aist.rtm.RTC.util.ORBUtil;
import junit.framework.TestCase;
import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.OutputStream;
import RTC.Time;
import RTC.TimedFloat;
+import RTC.TimedFloatHolder;
import _SDOPackage.NVListHolder;
+import com.sun.corba.se.impl.encoding.EncapsOutputStream;
/**
* <p>InPortProviderクラスのためのテストケースです。</p>
*/
@@ -38,7 +43,8 @@
*/
public void test_publishInterfaceProfile() throws Exception {
RingBuffer<TimedFloat> buffer = new RingBuffer<TimedFloat>(100);
- InPortCorbaProvider<TimedFloat> provider = new InPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+// InPortCorbaProvider<TimedFloat> provider = new InPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ InPortCorbaCdrProvider provider = new InPortCorbaCdrProvider(); // will be deleted automatically
NVListHolder profile = NVListHolderFactory.create();
provider.publishInterfaceProfile(profile);
@@ -64,7 +70,8 @@
*/
public void test_publishInterface_matched_interfaceType() throws Exception {
RingBuffer<TimedFloat> buffer = new RingBuffer<TimedFloat>(100);
- InPortCorbaProvider<TimedFloat> provider = new InPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ //InPortCorbaProvider<TimedFloat> provider = new InPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ InPortCorbaCdrProvider provider = new InPortCorbaCdrProvider(); // will be deleted automatically
// インタフェース・タイプが適合するように設定したうえで、インタフェース情報を取得する
NVListHolder properties = NVListHolderFactory.create();
@@ -84,7 +91,8 @@
*/
public void test_publishInterface_unmatched_interfaceType() throws Exception {
RingBuffer<TimedFloat> buffer = new RingBuffer<TimedFloat>(100);
- InPortCorbaProvider<TimedFloat> provider = new InPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ //InPortCorbaProvider<TimedFloat> provider = new InPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ InPortCorbaCdrProvider provider = new InPortCorbaCdrProvider(); // will be deleted automatically
// インタフェース・タイプが適合するように設定したうえで、インタフェース情報を取得する
NVListHolder properties = NVListHolderFactory.create();
@@ -108,14 +116,23 @@
*/
public void test_put() throws Exception {
RingBuffer<TimedFloat> buffer = new RingBuffer<TimedFloat>(100);
- InPortCorbaProvider<TimedFloat> provider = new InPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ //InPortCorbaProvider<TimedFloat> provider = new InPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ InPortCorbaCdrProvider provider = new InPortCorbaCdrProvider(); // will be deleted automatically
// 値をInPortCorbaProviderを通して書き込む
TimedFloat putValue = new TimedFloat();
putValue.data = 3.14159f;
putValue.tm = new Time();
- Any putValueAny = new TypeCast<TimedFloat>(TimedFloat.class).castAny(putValue);
- provider.put(putValueAny);
+ TimedFloatHolder holder = new TimedFloatHolder(putValue);
+ ORB m_orb = ORBUtil.getOrb();
+ org.omg.CORBA.Any any = m_orb.create_any();
+ OutputStream out = any.create_output_stream();
+ holder._write(out);
+ //Any putValueAny = new TypeCast<TimedFloat>(TimedFloat.class).castAny(putValue);
+ //provider.put(putValueAny);
+ EncapsOutputStream cdr;
+ cdr = (EncapsOutputStream)out;
+ provider.put(cdr.toByteArray());
// バッファから値を取り出して、正しく書き込まれたことを確認する
TimedFloat readValue = new TimedFloat();
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortProviderImplTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortProviderImplTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortProviderImplTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -1,7 +1,7 @@
package jp.go.aist.rtm.RTC.port;
import _SDOPackage.NVListHolder;
-import jp.go.aist.rtm.RTC.port.InPortProviderImpl;
+//import jp.go.aist.rtm.RTC.port.InPortProviderImpl;
import jp.go.aist.rtm.RTC.util.NVListHolderFactory;
import jp.go.aist.rtm.RTC.util.NVUtil;
import junit.framework.TestCase;
@@ -11,7 +11,8 @@
*/
public class InPortProviderImplTest extends TestCase {
- private class InPortProviderImplMock extends InPortProviderImpl {
+ //private class InPortProviderImplMock extends InPortProviderImpl {
+ private class InPortProviderImplMock extends InPortCorbaCdrProvider {
public InPortProviderImplMock(
String dataType, String interfaceType,
@@ -49,7 +50,7 @@
*/
public void test_publishInterfaceProfile() throws Exception {
- InPortProviderImpl provider = new InPortProviderImplMock(
+ InPortProvider provider = new InPortProviderImplMock(
"DATA_TYPE", "INTERFACE_TYPE",
"DATA_FLOW_TYPE", "SUBSCRIPTION_TYPE");
@@ -79,7 +80,7 @@
*/
public void testPublishInterface() {
- InPortProviderImpl provider = new InPortProviderImplMock(
+ InPortProvider provider = new InPortProviderImplMock(
"DATA_TYPE", "INTERFACE_TYPE",
"DATA_FLOW_TYPE", "SUBSCRIPTION_TYPE");
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortProviderTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortProviderTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortProviderTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -14,7 +14,8 @@
*/
public class InPortProviderTest extends TestCase {
- class InPortProviderMock extends InPortProviderImpl {
+ //class InPortProviderMock extends InPortProviderImpl {
+ class InPortProviderMock extends InPortCorbaCdrProvider {
public int g_argc;
public String g_argv;
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortPushConnectorTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortPushConnectorTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortPushConnectorTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -250,7 +250,8 @@
InPortCorbaCdrProviderMock provider = new InPortCorbaCdrProviderMock();
Logger logger = new Logger();
provider.setLogger(logger);
- ConnectorBase.Profile profile_new = new ConnectorBase.Profile(
+ //ConnectorBase.Profile profile_new = new ConnectorBase.Profile(
+ ConnectorBase.ConnectorInfo profile_new = new ConnectorBase.ConnectorInfo(
prof.name,
prof.connector_id,
CORBA_SeqUtil.refToVstring(prof.ports),
@@ -261,7 +262,8 @@
int constructor_counter = RingBufferMock.m_mock_logger.countLog("RingBufferMock.Constructor");
try {
BufferBase<OutputStream> buffer = null;
- connector = new InPortPushConnector(profile_new, provider,buffer);
+ ConnectorListeners listeners = new ConnectorListeners();
+ connector = new InPortPushConnector(profile_new,provider,listeners,buffer);
assertEquals("1:",init_counter+1,
logger.countLog("InPortCorbaCdrProviderMock.init"));
assertEquals("2:",setBuffer_counter+1,
@@ -291,13 +293,15 @@
NVUtil.copyToProperties(conn_prop, holder);
prop.merge(conn_prop.getNode("dataport"));
}
- ConnectorBase.Profile profile_err = new ConnectorBase.Profile(
+ //ConnectorBase.Profile profile_err = new ConnectorBase.Profile(
+ ConnectorBase.ConnectorInfo profile_err = new ConnectorBase.ConnectorInfo(
prof_err.name,
prof_err.connector_id,
CORBA_SeqUtil.refToVstring(prof_err.ports),
prop);
BufferBase<OutputStream> buffer = null;
- connector_err = new InPortPushConnector(profile_err, null, buffer);
+ ConnectorListeners ls = new ConnectorListeners();
+ connector_err = new InPortPushConnector(profile_err, null, ls, buffer);
fail("The exception was not thrown. ");
}
catch(Exception e) {
@@ -331,13 +335,16 @@
InPortCorbaCdrProviderMock provider = new InPortCorbaCdrProviderMock();
Logger logger = new Logger();
provider.setLogger(logger);
- ConnectorBase.Profile profile_new = new ConnectorBase.Profile (
+ //ConnectorBase.Profile profile_new = new ConnectorBase.Profile (
+ ConnectorBase.ConnectorInfo profile_new = new ConnectorBase.ConnectorInfo (
prof.name,
prof.connector_id,
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
InPortConnector connector= null;
- connector = new InPortPushConnector(profile_new, provider, pbuffer);
+ ConnectorListeners listeners = new ConnectorListeners();
+ //connector = new InPortPushConnector(profile_new, provider, pbuffer);
+ connector = new InPortPushConnector(profile_new, provider, listeners, pbuffer);
InputStream cdr = null;
DataRef<InputStream> cdrref = new DataRef<InputStream>(cdr);
@@ -391,14 +398,16 @@
InPortCorbaCdrProviderMock provider = new InPortCorbaCdrProviderMock();
Logger logger = new Logger();
provider.setLogger(logger);
- ConnectorBase.Profile profile_new = new ConnectorBase.Profile (
+ //ConnectorBase.Profile profile_new = new ConnectorBase.Profile (
+ ConnectorBase.ConnectorInfo profile_new = new ConnectorBase.ConnectorInfo (
prof.name,
prof.connector_id,
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
InPortConnector connector=null;
BufferBase<OutputStream> buffer = null;
- connector = new InPortPushConnector(profile_new, provider,buffer);
+ ConnectorListeners listeners = new ConnectorListeners();
+ connector = new InPortPushConnector(profile_new, provider, listeners, buffer);
connector.disconnect();
InputStream cdr = null;
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/InPortTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -73,7 +73,8 @@
// assertEquals(ReturnCode.PORT_OK,this.m_pInport.write(writeValue));
// write()で書き込んだ値が、read()で正しく読み出されるか?
- double readValue = this.m_pInport.read();
+ //double readValue = this.m_pInport.read();
+ double readValue = this.m_pInport.extract();
assertEquals(writeValue, readValue);
}
}
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortBaseTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortBaseTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortBaseTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -46,7 +46,8 @@
public class OutPortBaseTest extends TestCase {
class OutPortPushConnector extends OutPortConnector {
- public OutPortPushConnector(Profile profile,
+ //public OutPortPushConnector(Profile profile,
+ public OutPortPushConnector(ConnectorBase.ConnectorInfo profile,
InPortConsumer consumer,
BufferBase<OutputStream> buffer) throws Exception {
super(profile);
@@ -58,7 +59,8 @@
}
}
- public OutPortPushConnector(Profile profile,
+ //public OutPortPushConnector(Profile profile,
+ public OutPortPushConnector(ConnectorBase.ConnectorInfo profile,
InPortConsumer consumer ) throws Exception {
super(profile);
BufferBase<OutputStream> buffer = null;
@@ -70,7 +72,8 @@
}
}
- private void _Constructor(Profile profile,
+ //private void _Constructor(Profile profile,
+ private void _Constructor(ConnectorBase.ConnectorInfo profile,
InPortConsumer consumer,
BufferBase<OutputStream> buffer) throws Exception {
@@ -93,10 +96,12 @@
public ReturnCode write(final OutputStream data_little,final OutputStream data_big){
return ReturnCode.PORT_OK;
}
- protected PublisherBase createPublisher(Profile profile) {
+ //protected PublisherBase createPublisher(Profile profile) {
+ protected PublisherBase createPublisher(ConnectorBase.ConnectorInfo profile) {
return new PublisherFlush();
}
- protected BufferBase<OutputStream> createBuffer(Profile profile) {
+ //protected BufferBase<OutputStream> createBuffer(Profile profile) {
+ protected BufferBase<OutputStream> createBuffer(ConnectorBase.ConnectorInfo profile) {
return new RingBufferMock();
}
public <DataType> ReturnCode write(final DataType data) {
@@ -108,7 +113,8 @@
}
class OutPortPullConnector extends OutPortConnector {
- public OutPortPullConnector(Profile profile,
+ //public OutPortPullConnector(Profile profile,
+ public OutPortPullConnector(ConnectorBase.ConnectorInfo profile,
OutPortProvider provider,
BufferBase<OutputStream> buffer) throws Exception {
super(profile);
@@ -116,7 +122,8 @@
throw new Exception("bad_alloc()");
}
}
- public OutPortPullConnector(Profile profile,
+ //public OutPortPullConnector(Profile profile,
+ public OutPortPullConnector(ConnectorBase.ConnectorInfo profile,
OutPortProvider provider ) throws Exception {
super(profile);
if(profile.properties.getProperty("OutPortBaseTests").equals("bad_alloc")) {
@@ -193,6 +200,9 @@
final ConnectorProfileHolder cprof) {
return subscribeInterfaces(cprof);
}
+ public boolean read() {
+ return true;
+ }
};
/**
* *
@@ -493,6 +503,9 @@
return m_connectors;
}
+ public boolean write() {
+ return true;
+ }
}
/**
@@ -701,6 +714,10 @@
public String getName(){
return "A";
}
+ public ReturnCode setListener(ConnectorBase.ConnectorInfo info,
+ ConnectorListeners listeners) {
+ return ReturnCode.PORT_OK;
+ }
}
class PublisherB extends PublisherBase {
@@ -740,6 +757,10 @@
public String getName(){
return "B";
}
+ public ReturnCode setListener(ConnectorBase.ConnectorInfo info,
+ ConnectorListeners listeners) {
+ return ReturnCode.PORT_OK;
+ }
}
class PublisherC extends PublisherBase {
@@ -779,6 +800,10 @@
public String getName(){
return "C";
}
+ public ReturnCode setListener(ConnectorBase.ConnectorInfo info,
+ ConnectorListeners listeners) {
+ return ReturnCode.PORT_OK;
+ }
}
class PublisherD extends PublisherBase {
@@ -818,6 +843,10 @@
public String getName(){
return "D";
}
+ public ReturnCode setListener(ConnectorBase.ConnectorInfo info,
+ ConnectorListeners listeners) {
+ return ReturnCode.PORT_OK;
+ }
}
/**
*
@@ -865,6 +894,9 @@
// super(name);
super(name,"dummy");
}
+ public boolean write() {
+ return true;
+ }
}
private PublisherA m_pubA;
private PublisherB m_pubB;
@@ -965,7 +997,9 @@
PortAdmin portAdmin = new PortAdmin(m_orb,m_poa);
portAdmin.registerPort(outPort);
- assertTrue(outPort.name().equals("Hello, World!") );
+ //assertTrue(outPort.name().equals("Hello, World!") );
+ assertTrue(outPort.m_profile.equals("Hello, World!") );
+
portAdmin.deletePort(outPort);
}
@@ -1530,7 +1564,9 @@
inprof.properties = holder.value;
inprof.connector_id = "id0";
inprof.name = "bar";
- inPort.init();
+ //inPort.init();
+ Properties pro = new Properties();
+ inPort.init(pro);
ConnectorProfileHolder profh = new ConnectorProfileHolder(inprof);
inPort.publishInterfaces_public(profh);
@@ -1598,7 +1634,8 @@
//
//getConnectorProfiles()
//
- Vector<ConnectorBase.Profile> list = outPort.getConnectorProfiles();
+ //Vector<ConnectorBase.Profile> list = outPort.getConnectorProfiles();
+ Vector<ConnectorBase.ConnectorInfo> list = outPort.getConnectorProfiles();
assertEquals(10, list.size());
for(int ic=0;ic<10;++ic)
{
@@ -1644,10 +1681,15 @@
Vector<String> vstr = new Vector<String>();
Properties prop = new Properties();
- ConnectorBase.Profile prof = new ConnectorBase.Profile("test","id",
+ //ConnectorBase.Profile prof = new ConnectorBase.Profile("test","id",
+ ConnectorBase.ConnectorInfo prof = new ConnectorBase.ConnectorInfo("test","id",
vstr,prop);
- ConnectorBase.ProfileHolder cbprofh
- = new ConnectorBase.ProfileHolder(prof);
+
+ //ConnectorBase.ProfileHolder cbprofh
+ // = new ConnectorBase.ProfileHolder(prof);
+ ConnectorBase.ConnectorInfoHolder cbprofh
+ = new ConnectorBase.ConnectorInfoHolder(prof);
+
boolean ret = outPort.getConnectorProfileById(vstrid[ic],cbprofh);
prof = cbprofh.value;
assertTrue("12:",ret);
@@ -1662,10 +1704,13 @@
Vector<String> vstr = new Vector<String>();
Properties prop = new Properties();
- ConnectorBase.Profile prof = new ConnectorBase.Profile ("test","id",
+ //ConnectorBase.Profile prof = new ConnectorBase.Profile ("test","id",
+ ConnectorBase.ConnectorInfo prof = new ConnectorBase.ConnectorInfo ("test","id",
vstr,prop);
- ConnectorBase.ProfileHolder cbprofh
- = new ConnectorBase.ProfileHolder(prof);
+ //ConnectorBase.ProfileHolder cbprofh
+ // = new ConnectorBase.ProfileHolder(prof);
+ ConnectorBase.ConnectorInfoHolder cbprofh
+ = new ConnectorBase.ConnectorInfoHolder(prof);
boolean ret = outPort.getConnectorProfileById("foo",cbprofh);
assertTrue("16:",!ret);
ret = outPort.getConnectorProfileById("bar",cbprofh);
@@ -1680,10 +1725,13 @@
Vector<String> vstr = new Vector<String>();
Properties prop = new Properties();
- ConnectorBase.Profile prof = new ConnectorBase.Profile("test","id",
+ //ConnectorBase.Profile prof = new ConnectorBase.Profile("test","id",
+ ConnectorBase.ConnectorInfo prof = new ConnectorBase.ConnectorInfo("test","id",
vstr,prop);
- ConnectorBase.ProfileHolder cbprofh
- = new ConnectorBase.ProfileHolder(prof);
+ //ConnectorBase.ProfileHolder cbprofh
+ // = new ConnectorBase.ProfileHolder(prof);
+ ConnectorBase.ConnectorInfoHolder cbprofh
+ = new ConnectorBase.ConnectorInfoHolder(prof);
boolean ret = outPort.getConnectorProfileByName(vstrname[ic],
cbprofh);
prof = cbprofh.value;
@@ -1699,10 +1747,13 @@
Vector<String> vstr = new Vector<String>();
Properties prop = new Properties();
- ConnectorBase.Profile prof = new ConnectorBase.Profile("test","id",
+ //ConnectorBase.Profile prof = new ConnectorBase.Profile("test","id",
+ ConnectorBase.ConnectorInfo prof = new ConnectorBase.ConnectorInfo("test","id",
vstr,prop);
- ConnectorBase.ProfileHolder cbprofh
- = new ConnectorBase.ProfileHolder(prof);
+ //ConnectorBase.ProfileHolder cbprofh
+ // = new ConnectorBase.ProfileHolder(prof);
+ ConnectorBase.ConnectorInfoHolder cbprofh
+ = new ConnectorBase.ConnectorInfoHolder(prof);
boolean ret = outPort.getConnectorProfileByName("foo",cbprofh);
prof = cbprofh.value;
assertTrue("22:",!ret);
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaCdrProviderTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaCdrProviderTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaCdrProviderTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -133,8 +133,10 @@
//provider.init();
- RingBuffer<InputStream> buffer;
- final BufferFactory<RingBuffer<InputStream>,String> factory
+ //RingBuffer<InputStream> buffer;
+ RingBuffer<OutputStream> buffer;
+ //final BufferFactory<RingBuffer<InputStream>,String> factory
+ final BufferFactory<RingBuffer<OutputStream>,String> factory
= BufferFactory.instance();
factory.addFactory("ring_buffer",
new CdrRingBuffer(),
@@ -158,7 +160,8 @@
byte testdata[] = { 4, 8, 15, 16, 23, 42, 49, 50};
OutputStream cdr = toStream(testdata, 0, 0);
- buffer.write(cdr.create_input_stream());
+ //buffer.write(cdr.create_input_stream());
+ buffer.write(cdr);
retcode = provider.get(cdr_data_ref);
assertEquals("5",OpenRTM.PortStatus.PORT_OK, retcode);
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaConsumerTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaConsumerTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaConsumerTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -7,22 +7,31 @@
import jp.go.aist.rtm.RTC.util.NVListHolderFactory;
import jp.go.aist.rtm.RTC.util.NVUtil;
import jp.go.aist.rtm.RTC.util.ORBUtil;
+import jp.go.aist.rtm.RTC.util.FloatHolder;
import junit.framework.TestCase;
import org.omg.CORBA.Any;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Object;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
import org.omg.PortableServer.POA;
-import RTC.OutPortAnyPOA;
+//import RTC.OutPortAnyPOA;
+import OpenRTM.OutPortCdrPOA;
+
import _SDOPackage.NVListHolder;
+import com.sun.corba.se.impl.encoding.EncapsOutputStream;
+
+
/**
* <p>OutPortCorbaConsumerクラスのためのテストケースです。</p>
*/
public class OutPortCorbaConsumerTest extends TestCase {
- class OutPortAnyMock extends OutPortAnyPOA {
+ //class OutPortAnyMock extends OutPortAnyPOA {
+ class OutPortAnyMock extends OutPortCdrPOA {
private Any m_data;
public void setData(Any data) {
@@ -31,6 +40,9 @@
public Any get() {
return m_data;
}
+ public OpenRTM.PortStatus get(OpenRTM.CdrDataHolder data) {
+ return OpenRTM.PortStatus.from_int(0);
+ }
}
private ORB m_orb;
@@ -66,7 +78,8 @@
byte[] oid = this.m_poa.activate_object(outPortAny);
RingBuffer<Float> buffer = new RingBuffer<Float>(100);
- OutPortCorbaConsumer<Float> consumer = new OutPortCorbaConsumer<Float>(Float.class, buffer);
+ //OutPortCorbaConsumer<Float> consumer = new OutPortCorbaConsumer<Float>(Float.class, buffer);
+ OutPortCorbaCdrConsumer consumer = new OutPortCorbaCdrConsumer();
consumer.setObject(m_poa.id_to_reference(oid));
// InPortConsumerのput()メソッドを呼び出す
@@ -76,8 +89,18 @@
outPortAny.setData(writeValueAny);
// OutPortCorbaConsumer::get()を用いて、データを読み取る
+ com.sun.corba.se.spi.orb.ORB orb
+ = (com.sun.corba.se.spi.orb.ORB)ORBUtil.getOrb();
+ EncapsOutputStream cdr = new EncapsOutputStream(orb, true);
+ consumer.get(cdr);
+ DataRef<OutputStream> dataref = new DataRef<OutputStream>(cdr);
+ InputStream data = dataref.v.create_input_stream();
+ FloatHolder holder = new FloatHolder();
+ holder._read(data);
DataRef<Float> readValue = new DataRef<Float>(0f);
- assertTrue(consumer.get(readValue));
+ readValue.v = holder.value;
+ //DataRef<Float> readValue = new DataRef<Float>(0f);
+ //assertTrue(consumer.get(readValue));
// テスト用に設定しておいたデータを読み取ったデータを比較し、正しく取得できたことを確認する
assertTrue( Math.abs(writeValue.doubleValue()-readValue.v) < 0.00001);
@@ -89,13 +112,15 @@
* </ul>
* </p>
*/
+/*
public void test_pull() throws Exception {
// 接続先となるProvider側のオブジェクトを生成し、設定する
OutPortAnyMock outPortAny = new OutPortAnyMock();
byte[] oid = this.m_poa.activate_object(outPortAny);
RingBuffer<Float> buffer = new RingBuffer<Float>(100);
- OutPortCorbaConsumer<Float> consumer = new OutPortCorbaConsumer<Float>(Float.class, buffer);
+ //OutPortCorbaConsumer<Float> consumer = new OutPortCorbaConsumer<Float>(Float.class, buffer);
+ OutPortCorbaCdrConsumer consumer = new OutPortCorbaCdrConsumer();
consumer.setObject(m_poa.id_to_reference(oid));
// Provider側にテスト用のデータを設定しておく
@@ -105,7 +130,11 @@
outPortAny.setData(writeValueAny);
// pull()メソッドを呼出して、OutPortAny側のデータをバッファへ読み込む
- consumer.pull();
+ //consumer.pull();
+ com.sun.corba.se.spi.orb.ORB orb
+ = (com.sun.corba.se.spi.orb.ORB)ORBUtil.getOrb();
+ EncapsOutputStream cdr = new EncapsOutputStream(orb, true);
+ consumer.get(cdr);
// バッファからデータを読み出して、テスト用に設定しておいたデータを読み取ったデータを比較し、正しく取得できたことを確認する
DataRef<Float> readValue = new DataRef<Float>(0f);
@@ -113,6 +142,7 @@
// assertTrue(buffer.read(readValue));
assertTrue( Math.abs(writeValue.doubleValue()-readValue.v) < 0.00001);
}
+*/
/**
* <p>subscribeInterface()メソッドのテスト
* <ul>
@@ -125,7 +155,8 @@
byte[] oid = this.m_poa.activate_object(outPortAny);
RingBuffer<Float> buffer = new RingBuffer<Float>(100);
- OutPortCorbaConsumer<Float> consumer = new OutPortCorbaConsumer<Float>(Float.class, buffer);
+ //OutPortCorbaConsumer<Float> consumer = new OutPortCorbaConsumer<Float>(Float.class, buffer);
+ OutPortCorbaCdrConsumer consumer = new OutPortCorbaCdrConsumer();
org.omg.CORBA.Object outPortAnyRef = m_poa.id_to_reference(oid);
// Any outPortAnyRefAny = ORBUtil.getOrb().create_any();
// outPortAnyRefAny.insert_Object(outPortAnyRef);
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaProviderTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaProviderTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortCorbaProviderTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -3,13 +3,22 @@
import jp.go.aist.rtm.RTC.buffer.RingBuffer;
import jp.go.aist.rtm.RTC.util.NVListHolderFactory;
import jp.go.aist.rtm.RTC.util.NVUtil;
+import jp.go.aist.rtm.RTC.util.FloatHolder;
+import jp.go.aist.rtm.RTC.util.DataRef;
+import jp.go.aist.rtm.RTC.util.ORBUtil;
import junit.framework.TestCase;
import org.omg.CORBA.Any;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.OutputStream;
import RTC.TimedFloat;
import _SDOPackage.NVListHolder;
+import com.sun.corba.se.impl.encoding.EncapsOutputStream;
+import com.sun.corba.se.impl.encoding.EncapsInputStream;
+
/**
* <p>OutPortProviderImplクラスのためのテストケースです。</p>
*/
@@ -35,7 +44,8 @@
*/
public void test_publishInterfaceProfile() throws Exception {
RingBuffer<TimedFloat> buffer = new RingBuffer<TimedFloat>(100);
- OutPortCorbaProvider<TimedFloat> provider = new OutPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ //OutPortCorbaProvider<TimedFloat> provider = new OutPortCorbaProvider<TimedFloat>(TimedFloat.class, buffer); // will be deleted automatically
+ OutPortCorbaCdrProvider provider = new OutPortCorbaCdrProvider(); // will be deleted automatically
NVListHolder profile = NVListHolderFactory.create();
provider.publishInterfaceProfile(profile);
@@ -61,16 +71,34 @@
*/
public void test_get() throws Exception {
RingBuffer<Float> buffer = new RingBuffer<Float>(100);
- OutPortCorbaProvider<Float> provider = new OutPortCorbaProvider<Float>(Float.class, buffer); // will be deleted automatically
+ //OutPortCorbaProvider<Float> provider = new OutPortCorbaProvider<Float>(Float.class, buffer); // will be deleted automatically
+ OutPortCorbaCdrProvider provider = new OutPortCorbaCdrProvider(); // will be deleted automatically
for( int i = 0; i < 10; ++i ) {
Float writeValue = new Float(3.14159 * i);
buffer.write(writeValue);
- // バッファに書き込まれた値を、get()メソッドで正しく読み出せるか?
- float readValue;
- Any any = provider.get();
- readValue = any.extract_float();
+ // バッファに書き込まれた値を、get()メソッドで正しく読み出せるか?
+
+ //float readValue;
+ OpenRTM.CdrDataHolder cdr_data = new OpenRTM.CdrDataHolder();
+ ORB m_orb = ORBUtil.getOrb();
+ org.omg.CORBA.Any any = m_orb.create_any();
+ OutputStream data = any.create_output_stream();
+ provider.get(cdr_data);
+ data.write_octet_array(cdr_data.value, 0,
+ cdr_data.value.length);
+ EncapsOutputStream outcdr;
+ outcdr = (EncapsOutputStream)data;
+ DataRef<InputStream> dataref
+ = new DataRef<InputStream>(outcdr.create_input_stream());
+ FloatHolder holder = new FloatHolder();
+ holder._read(dataref.v);
+ Float readValue = holder.value;
+
+ //float readValue;
+ //Any any = provider.get();
+ //readValue = any.extract_float();
assertEquals(writeValue.floatValue(), readValue);
}
}
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortProviderImplTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortProviderImplTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortProviderImplTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -1,7 +1,7 @@
package jp.go.aist.rtm.RTC.port;
import _SDOPackage.NVListHolder;
-import jp.go.aist.rtm.RTC.port.OutPortProviderImpl;
+//import jp.go.aist.rtm.RTC.port.OutPortProviderImpl;
import jp.go.aist.rtm.RTC.util.NVListHolderFactory;
import jp.go.aist.rtm.RTC.util.NVUtil;
import junit.framework.TestCase;
@@ -11,7 +11,8 @@
*/
public class OutPortProviderImplTest extends TestCase {
- private class OutPortProviderImplMock extends OutPortProviderImpl {
+ //private class OutPortProviderImplMock extends OutPortProviderImpl {
+ private class OutPortProviderImplMock extends OutPortCorbaCdrProvider {
public OutPortProviderImplMock(
String portType, String dataType,
@@ -50,7 +51,8 @@
*/
public void test_publishInterfaceProfile() throws Exception {
- OutPortProviderImpl provider = new OutPortProviderImplMock(
+ //OutPortProviderImpl provider = new OutPortProviderImplMock(
+ OutPortCorbaCdrProvider provider = new OutPortProviderImplMock(
"PORT_TYPE", "DATA_TYPE", "INTERFACE_TYPE",
"DATA_FLOW_TYPE", "SUBSCRIPTION_TYPE");
@@ -80,7 +82,8 @@
*/
public void test_publishInterface() {
- OutPortProviderImpl provider = new OutPortProviderImplMock(
+ //OutPortProviderImpl provider = new OutPortProviderImplMock(
+ OutPortCorbaCdrProvider provider = new OutPortProviderImplMock(
"PORT_TYPE", "DATA_TYPE", "INTERFACE_TYPE",
"DATA_FLOW_TYPE", "SUBSCRIPTION_TYPE");
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortProviderTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortProviderTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortProviderTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -15,7 +15,8 @@
*/
public class OutPortProviderTest extends TestCase {
- class OutPortProviderMock extends OutPortProviderImpl {
+ //class OutPortProviderMock extends OutPortProviderImpl {
+ class OutPortProviderMock extends OutPortCorbaCdrProvider {
public int g_argc;
public String g_argv;
Modified: trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortPushConnectorTest.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortPushConnectorTest.java 2011-09-12 07:05:47 UTC (rev 562)
+++ trunk/jp.go.aist.rtm.RTC/tests/src/jp/go/aist/rtm/RTC/port/OutPortPushConnectorTest.java 2011-09-20 04:12:59 UTC (rev 563)
@@ -240,6 +240,11 @@
public String getName(){
return "flush";
}
+ public ReturnCode setListener(ConnectorBase.ConnectorInfo info,
+ ConnectorListeners listeners) {
+
+ return ReturnCode.PORT_OK;
+ }
}
/**
*
@@ -367,6 +372,11 @@
public String getName(){
return "new";
}
+ public ReturnCode setListener(ConnectorBase.ConnectorInfo info,
+ ConnectorListeners listeners) {
+
+ return ReturnCode.PORT_OK;
+ }
};
public static Logger m_mock_logger = null;
@@ -473,19 +483,23 @@
InPortCorbaCdrConsumerMock consumer = new InPortCorbaCdrConsumerMock();
Logger logger = new Logger();
consumer.setLogger(logger);
- ConnectorBase.Profile profile_new = new ConnectorBase.Profile(
+ //ConnectorBase.Profile profile_new = new ConnectorBase.Profile(
+ ConnectorBase.ConnectorInfo profile_new = new ConnectorBase.ConnectorInfo(
+
prof.name,
prof.connector_id,
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
OutPortConnector connector = null;
+ ConnectorListeners listeners = null;
int init_counter = logger.countLog("InPortCorbaCdrConsumerMock.init");
int setBuffer_counter = m_mock_logger.countLog("PublisherNewMock.setBuffer");
int buffOk_counter = m_mock_logger.countLog("buffer OK");
int buffNg_counter = m_mock_logger.countLog("buffer NG");
int setConsumer_counter = m_mock_logger.countLog("PublisherNewMock.setConsumer");
try {
- connector = new OutPortPushConnector(profile_new, consumer);
+ //connector = new OutPortPushConnector(profile_new, consumer);
+ connector = new OutPortPushConnector(profile_new, listeners, consumer);
assertEquals("1:",init_counter+1,
logger.countLog("InPortCorbaCdrConsumerMock.init"));
assertEquals("2:",setBuffer_counter+1,
@@ -515,7 +529,8 @@
NVUtil.copyToProperties(conn_prop, holder);
prop.merge(conn_prop.getNode("dataport"));
}
- ConnectorBase.Profile profile_flush = new ConnectorBase.Profile(
+ //ConnectorBase.Profile profile_flush = new ConnectorBase.Profile(
+ ConnectorBase.ConnectorInfo profile_flush = new ConnectorBase.ConnectorInfo(
prof.name,
prof.connector_id,
CORBA_SeqUtil.refToVstring(prof.ports),
@@ -526,7 +541,8 @@
buffNg_counter = m_mock_logger.countLog("buffer NG");
setConsumer_counter = m_mock_logger.countLog("PublisherFlushMock.setConsumer");
try{
- connector = new OutPortPushConnector(profile_flush, consumer);
+ //connector = new OutPortPushConnector(profile_flush, consumer);
+ connector = new OutPortPushConnector(profile_flush, listeners, consumer);
assertEquals("6:",init_counter+1,
logger.countLog("InPortCorbaCdrConsumerMock.init"));
assertEquals("7:",setBuffer_counter+1,
@@ -559,12 +575,14 @@
NVUtil.copyToProperties(conn_prop, holder);
prop.merge(conn_prop.getNode("dataport"));
}
- ConnectorBase.Profile profile_err = new ConnectorBase.Profile(
+ //ConnectorBase.Profile profile_err = new ConnectorBase.Profile(
+ ConnectorBase.ConnectorInfo profile_err = new ConnectorBase.ConnectorInfo(
prof_err.name,
prof_err.connector_id,
CORBA_SeqUtil.refToVstring(prof_err.ports),
prop);
- connector_err = new OutPortPushConnector(profile_err, null);
+ //connector_err = new OutPortPushConnector(profile_err, null);
+ connector_err = new OutPortPushConnector(profile_err, listeners, null);
fail("The exception was not thrown. ");
}
catch(Exception e) {
@@ -606,14 +624,17 @@
InPortCorbaCdrConsumerMock consumer = new InPortCorbaCdrConsumerMock();
Logger logger = new Logger();
consumer.setLogger(logger);
- ConnectorBase.Profile profile_new = new ConnectorBase.Profile (
+ //ConnectorBase.Profile profile_new = new ConnectorBase.Profile (
+ ConnectorBase.ConnectorInfo profile_new = new ConnectorBase.ConnectorInfo(
prof.name,
prof.connector_id,
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
OutPortConnector connector = null;
+ ConnectorListeners listeners = null;
try {
- connector = new OutPortPushConnector(profile_new, consumer);
+ //connector = new OutPortPushConnector(profile_new, consumer);
+ connector = new OutPortPushConnector(profile_new, listeners, consumer);
int write_counter = m_mock_logger.countLog("PublisherNewMock.write");
int num_counter = m_mock_logger.countLog("12345");
OutputStream cdr = toStream(12345,0,0);
@@ -667,14 +688,17 @@
InPortCorbaCdrConsumerMock consumer = new InPortCorbaCdrConsumerMock();
Logger logger = new Logger();
consumer.setLogger(logger);
- ConnectorBase.Profile profile_new = new ConnectorBase.Profile(
+ //ConnectorBase.Profile profile_new = new ConnectorBase.Profile(
+ ConnectorBase.ConnectorInfo profile_new = new ConnectorBase.ConnectorInfo(
prof.name,
prof.connector_id,
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
OutPortConnector connector=null;
+ ConnectorListeners listeners = null;
try {
- connector = new OutPortPushConnector(profile_new, consumer);
+ //connector = new OutPortPushConnector(profile_new, consumer);
+ connector = new OutPortPushConnector(profile_new, listeners, consumer);
BufferBase<OutputStream> buffer = connector.getBuffer();
assertTrue("1",buffer!=null);
connector.disconnect();
@@ -717,14 +741,17 @@
InPortCorbaCdrConsumerMock consumer = new InPortCorbaCdrConsumerMock();
Logger logger = new Logger();
consumer.setLogger(logger);
- ConnectorBase.Profile profile_new = new ConnectorBase.Profile(
+ //ConnectorBase.Profile profile_new = new ConnectorBase.Profile(
+ ConnectorBase.ConnectorInfo profile_new = new ConnectorBase.ConnectorInfo(
prof.name,
prof.connector_id,
CORBA_SeqUtil.refToVstring(prof.ports),
prop);
OutPortConnector connector = null;
+ ConnectorListeners listeners = null;
try {
- connector = new OutPortPushConnector(profile_new, consumer);
+ //connector = new OutPortPushConnector(profile_new, consumer);
+ connector = new OutPortPushConnector(profile_new, listeners, consumer);
assertEquals(0,
m_mock_logger.countLog("PublisherNewMock.activate"));
connector.activate();
@@ -736,7 +763,8 @@
fail("The exception not intended was thrown .");
}
try{
- connector = new OutPortPushConnector(profile_new, consumer);
+ //connector = new OutPortPushConnector(profile_new, consumer);
+ connector = new OutPortPushConnector(profile_new, listeners, consumer);
assertEquals(0,
m_mock_logger.countLog("PublisherNewMock.deactivate"));
connector.deactivate();
openrtm-commit メーリングリストの案内