summaryrefslogtreecommitdiff
path: root/CIAO/connectors/dds4ccm/tests/NonChangeableAttribute/Component/NonChangeable_Component_exec.cpp
blob: 9519d15b3f621942525392bf65803bda85770814 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// -*- C++ -*-
// $Id$

#include "NonChangeable_Component_exec.h"

#include "dds4ccm/impl/Utils.h"

#define DOMAIN_ID_IN_DP 56
#define TOPIC_NAME_IN_DP "NonChangeable"

#define DW_MAX_BLOCKING_TIME_SEC 11
#define DW_MAX_BLOCKING_TIME_NSEC 200

namespace CIAO_NonChangeable_NonChangeableComponent_Impl
{
  //============================================================
  // Component_exec_i
  //============================================================
  Component_exec_i::Component_exec_i (void)
  {
  }

  Component_exec_i::~Component_exec_i (void)
  {
  }

  bool
  Component_exec_i::test_topic_name (
    ::NonChangeable::NonChangeableTestConnector::CCM_DDS_Event_ptr conn)
  {
    try
      {
        conn->topic_name ("nonchangeable_test");
        ACE_DEBUG ((LM_DEBUG, "NonChangeable_Connector_exec_impl_i::test_topic_name - "
                              "Able to reset topic name without an exception.\n"));
        return true;
      }
    catch (const ::CCM_DDS::NonChangeable &)
      {
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_topic_name - "
                              "ERROR: Unable to reset topic name.\n"));
      }
    catch (...)
      {
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_topic_name - "
                              "ERROR: Caught unexpected exception.\n"));
      }
    return false;
  }

  bool
  Component_exec_i::test_key_fields (
    ::NonChangeable::NonChangeableTestConnector::CCM_DDS_Event_ptr conn)
  {
    try
      {
        ::DDS::StringSeq fields;
        fields.length (2);
        fields[0] = CORBA::string_dup ("field_0");
        fields[1] = CORBA::string_dup ("field_1");
        conn->key_fields (fields);
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_domain_id - "
                              "ERROR: Able to set key fields without "
                              "an exception.\n"));
      }
    catch (const ::CCM_DDS::NonChangeable &)
      {
        ACE_DEBUG ((LM_DEBUG, "NonChangeable_Connector_exec_impl_i::test_key_fields - "
                              "Caught expected exception.\n"));
        return true;
      }
    catch (...)
      {
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_key_fields - "
                              "ERROR: Caught unexpected exception.\n"));
        return false;
      }
    return false;
  }

  bool
  Component_exec_i::test_domain_id (
    ::NonChangeable::NonChangeableTestConnector::CCM_DDS_Event_ptr conn)
  {
    try
      {
        conn->domain_id (64);
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_domain_id - "
                              "ERROR: Able to set domain ID without "
                              "an exception.\n"));
      }
    catch (const ::CCM_DDS::NonChangeable &)
      {
        ACE_DEBUG ((LM_DEBUG, "NonChangeable_Connector_exec_impl_i::test_domain_id - "
                              "Caught expected exception.\n"));
        return true;
      }
    catch (...)
      {
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_domain_id - "
                              "ERROR: Caught unexpected exception.\n"));
        return false;
      }
    return false;
  }

  bool
  Component_exec_i::test_qos_profile (
    ::NonChangeable::NonChangeableTestConnector::CCM_DDS_Event_ptr conn)
  {
    try
      {
        conn->qos_profile ("nonchangeable_profile");
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_qos_profile - "
                              "ERROR: Able to set QoS profile without "
                              "an exception.\n"));
      }
    catch (const ::CCM_DDS::NonChangeable &)
      {
        ACE_DEBUG ((LM_DEBUG, "NonChangeable_Connector_exec_impl_i::test_qos_profile - "
                              "Caught expected exception.\n"));
        return true;
      }
    catch (...)
      {
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_qos_profile - "
                              "ERROR: Caught unexpected exception.\n"));
        return false;
      }
    return false;
  }

  bool
  Component_exec_i::test_filter (
    ::NonChangeable::NonChangeableTestConnector::CCM_DDS_Event_ptr conn)
  {
    try
      {
        ::CCM_DDS::QueryFilter filter;
        filter.expression = ::CORBA::string_dup ("na");
        conn->pull_consumer_filter (filter);
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_filter - "
                              "ERROR: Able to set filter without "
                              "an exception.\n"));
      }
    catch (const ::CCM_DDS::NonChangeable &)
      {
        ACE_DEBUG ((LM_DEBUG, "NonChangeable_Connector_exec_impl_i::test_filter - "
                              "Caught expected exception.\n"));
        return true;
      }
    catch (...)
      {
        ACE_ERROR ((LM_ERROR, "NonChangeable_Connector_exec_impl_i::test_filter - "
                              "ERROR: Caught unexpected exception.\n"));
        return false;
      }
    return false;
  }

  // Operations from Components::SessionComponent.
  CCM_DDS::CCM_PortStatusListener_ptr
  Component_exec_i::get_info_get_status (void)
  {
    return CCM_DDS::CCM_PortStatusListener::_nil ();
  }

  void
  Component_exec_i::set_session_context (
    ::Components::SessionContext_ptr ctx)
  {
    this->context_ =
      ::NonChangeable::CCM_NonChangeableComponent_Context::_narrow (ctx);
    if ( ::CORBA::is_nil (this->context_.in ()))
      {
        throw ::CORBA::INTERNAL ();
      }
  }

  void
  Component_exec_i::configuration_complete (void)
  {
  }

  void
  Component_exec_i::ccm_activate (void)
  {
    ::NonChangeable::NonChangeableTestConnector::Reader_var reader =
      this->context_->get_connection_info_get_data ();
    if (::CORBA::is_nil (reader.in ()))
      {
        ACE_ERROR ((LM_ERROR, "ERROR: Component_exec_i::ccm_activate - "
                              "Unable to get reader interface\n"));
        throw ::CORBA::INTERNAL ();
      }
    ::CORBA::Object_var cmp = reader->_get_component ();
    if (::CORBA::is_nil (cmp.in ()))
      {
        ACE_ERROR ((LM_ERROR, "ERROR: Component_exec_i::ccm_activate - "
                              "Unable to get component interface\n"));
        throw ::CORBA::INTERNAL ();
      }
    ::NonChangeable::NonChangeableTestConnector::CCM_DDS_Event_var conn =
      ::NonChangeable::NonChangeableTestConnector::CCM_DDS_Event::_narrow (cmp.in ());
    if (::CORBA::is_nil (conn.in ()))
      {
        ACE_ERROR ((LM_ERROR, "ERROR: Component_exec_i::ccm_activate - "
                              "Unable to narrow connector interface\n"));
        throw ::CORBA::INTERNAL ();
      }

    if (this->test_topic_name (conn.in ()))
      {
        ACE_DEBUG ((LM_DEBUG, "Set topic_name test passed.\n"));
      }
    if (this->test_key_fields (conn.in ()))
      {
        ACE_DEBUG ((LM_DEBUG, "Set key_fields test passed.\n"));
      }
    if (this->test_domain_id (conn.in ()))
      {
        ACE_DEBUG ((LM_DEBUG, "Set domain_id test passed.\n"));
      }
    if (this->test_qos_profile (conn.in ()))
      {
        ACE_DEBUG ((LM_DEBUG, "Set qos_profile test passed.\n"));
      }
    if (this->test_filter (conn.in ()))
      {
        ACE_DEBUG ((LM_DEBUG, "Set qos_profile test passed.\n"));
      }
  }

  void
  Component_exec_i::ccm_passivate (void)
  {
  }

  void
  Component_exec_i::ccm_remove (void)
  {
  }

  extern "C" COMPONENT_EXEC_Export ::Components::EnterpriseComponent_ptr
  create_NonChangeable_Component_Impl (void)
  {
    ::Components::EnterpriseComponent_ptr retval =
      ::Components::EnterpriseComponent::_nil ();

    ACE_NEW_NORETURN (
      retval,
      Component_exec_i);

    return retval;
  }
}