()
| 224 | } |
| 225 | |
| 226 | protected static void testElectionNews() throws Exception { |
| 227 | final AtomicInteger count = new AtomicInteger(); |
| 228 | |
| 229 | final Lock lock = new ReentrantLock(); |
| 230 | final Condition finished = lock.newCondition(); |
| 231 | |
| 232 | publisher.create_datawriter(union_topic, DATAWRITER_QOS_DEFAULT.get(), |
| 233 | new DDS._DataWriterListenerLocalBase() { |
| 234 | public void on_liveliness_lost(DataWriter dw, LivelinessLostStatus status) {} |
| 235 | |
| 236 | public void on_offered_deadline_missed(DataWriter dw, OfferedDeadlineMissedStatus status) {} |
| 237 | |
| 238 | public void on_offered_incompatible_qos(DataWriter dw, OfferedIncompatibleQosStatus status) {} |
| 239 | |
| 240 | public void on_publication_matched(DataWriter dw, PublicationMatchedStatus status) { |
| 241 | try { |
| 242 | if (status.current_count == 0) return; |
| 243 | // Don't run the rest of this method if the callback is |
| 244 | // due to the datareader going away. |
| 245 | |
| 246 | ElectionNews_tDataWriter writer = ElectionNews_tDataWriterHelper.narrow(dw); |
| 247 | |
| 248 | count.set(1); |
| 249 | |
| 250 | ElectionNews_t data = new ElectionNews_t(); |
| 251 | data.status(ElectionNewsType_t.ELECTION_STATUS, new Candidate_t("A Name", 10)); |
| 252 | |
| 253 | int result = writer.write(data, HANDLE_NIL.value); |
| 254 | assert (result != RETCODE_ERROR.value); |
| 255 | |
| 256 | } catch (Throwable t) { |
| 257 | t.printStackTrace(); |
| 258 | } |
| 259 | }; |
| 260 | }, DEFAULT_STATUS_MASK.value |
| 261 | ); |
| 262 | |
| 263 | lock.lock(); |
| 264 | try { |
| 265 | subscriber.create_datareader(union_topic, DATAREADER_QOS_DEFAULT.get(), |
| 266 | new DDS._DataReaderListenerLocalBase() { |
| 267 | public void on_liveliness_changed(DataReader dr, LivelinessChangedStatus status) {} |
| 268 | |
| 269 | public void on_requested_deadline_missed(DataReader dr, RequestedDeadlineMissedStatus status) {} |
| 270 | |
| 271 | public void on_requested_incompatible_qos(DataReader dr, RequestedIncompatibleQosStatus status) {} |
| 272 | |
| 273 | public void on_sample_lost(DataReader dr, SampleLostStatus status) {} |
| 274 | |
| 275 | public void on_sample_rejected(DataReader dr, SampleRejectedStatus status) {} |
| 276 | |
| 277 | public void on_subscription_matched(DataReader dr, SubscriptionMatchedStatus status) {} |
| 278 | |
| 279 | public void on_data_available(DataReader dr) { |
| 280 | try { |
| 281 | ElectionNews_tDataReader reader = ElectionNews_tDataReaderHelper.narrow(dr); |
| 282 | |
| 283 | ElectionNews_t en = new ElectionNews_t(); |
no test coverage detected