| 129 | } |
| 130 | |
| 131 | int run_test_next_instance(DDS::DomainParticipant_ptr dp) |
| 132 | { |
| 133 | using namespace DDS; |
| 134 | using namespace OpenDDS::DCPS; |
| 135 | using namespace Messenger; |
| 136 | WaitSet_var ws = new WaitSet; |
| 137 | MessageTypeSupport_var ts = new MessageTypeSupportImpl; |
| 138 | ts->register_type(dp, ""); |
| 139 | CORBA::String_var type_name = ts->get_type_name(); |
| 140 | Topic_var topic = dp->create_topic("MyTopic", type_name, |
| 141 | TOPIC_QOS_DEFAULT, 0, ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 142 | |
| 143 | Publisher_var pub = dp->create_publisher(PUBLISHER_QOS_DEFAULT, 0, |
| 144 | ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 145 | DataWriter_var dw = pub->create_datawriter(topic, DATAWRITER_QOS_DEFAULT, 0, |
| 146 | ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 147 | |
| 148 | Subscriber_var sub = dp->create_subscriber(SUBSCRIBER_QOS_DEFAULT, 0, |
| 149 | ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 150 | DataReader_var dr = sub->create_datareader(topic, DATAREADER_QOS_DEFAULT, 0, |
| 151 | ::OpenDDS::DCPS::DEFAULT_STATUS_MASK); |
| 152 | |
| 153 | StatusCondition_var dw_sc = dw->get_statuscondition(); |
| 154 | dw_sc->set_enabled_statuses(PUBLICATION_MATCHED_STATUS); |
| 155 | ws->attach_condition(dw_sc); |
| 156 | Duration_t infinite = {DURATION_INFINITE_SEC, DURATION_INFINITE_NSEC}; |
| 157 | ConditionSeq active; |
| 158 | |
| 159 | ReturnCode_t ret = ws->wait(active, infinite); |
| 160 | if (ret != RETCODE_OK) return ret; |
| 161 | |
| 162 | ret = ws->detach_condition(dw_sc); |
| 163 | if (ret != RETCODE_OK) return ret; |
| 164 | |
| 165 | MessageDataWriter_var mdw = MessageDataWriter::_narrow(dw); |
| 166 | Message msg = {0}; |
| 167 | for (int i(0); i < 12; ++i) { |
| 168 | ++msg.subject_id; |
| 169 | ret = mdw->write(msg, HANDLE_NIL); |
| 170 | if (ret != RETCODE_OK) return ret; |
| 171 | } |
| 172 | |
| 173 | ReadCondition_var dr_rc = dr->create_readcondition(NOT_READ_SAMPLE_STATE, |
| 174 | NEW_VIEW_STATE, ALIVE_INSTANCE_STATE); |
| 175 | ReadCondition_var dr_rc2 = dr->create_readcondition(ANY_SAMPLE_STATE, |
| 176 | ANY_VIEW_STATE, NOT_ALIVE_DISPOSED_INSTANCE_STATE); |
| 177 | ws->attach_condition(dr_rc); |
| 178 | ws->attach_condition(dr_rc2); |
| 179 | MessageDataReader_var mdr = MessageDataReader::_narrow(dr); |
| 180 | bool passed = true, done = false; |
| 181 | ret = sub->delete_datareader(dr); |
| 182 | if (ret != DDS::RETCODE_PRECONDITION_NOT_MET) { |
| 183 | cerr << "ERROR: expected delete_datareader to return RETCODE_PRECONDITION_NOT_MET, " |
| 184 | "but it returned " << retcode_to_string(ret) << endl; |
| 185 | passed = false; |
| 186 | done = true; |
| 187 | } |
| 188 | while (!done) { |
no test coverage detected