1 /*******************************************************************************
2 * ============LICENSE_START==================================================
4 * * ===========================================================================
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * * ===========================================================================
7 * * Licensed under the Apache License, Version 2.0 (the "License");
8 * * you may not use this file except in compliance with the License.
9 * * You may obtain a copy of the License at
11 * * http://www.apache.org/licenses/LICENSE-2.0
13 * * Unless required by applicable law or agreed to in writing, software
14 * * distributed under the License is distributed on an "AS IS" BASIS,
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * * See the License for the specific language governing permissions and
17 * * limitations under the License.
18 * * ============LICENSE_END====================================================
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 ******************************************************************************/
23 package org.onap.dmaap.datarouter.provisioning;
25 import ch.qos.logback.classic.Logger;
26 import ch.qos.logback.classic.spi.ILoggingEvent;
27 import ch.qos.logback.core.read.ListAppender;
28 import org.apache.commons.lang3.reflect.FieldUtils;
29 import org.jetbrains.annotations.NotNull;
30 import org.json.JSONObject;
32 import org.junit.runner.RunWith;
33 import org.mockito.Mock;
34 import org.onap.dmaap.datarouter.authz.AuthorizationResponse;
35 import org.onap.dmaap.datarouter.authz.Authorizer;
36 import org.onap.dmaap.datarouter.provisioning.beans.Deleteable;
37 import org.onap.dmaap.datarouter.provisioning.beans.SubDelivery;
38 import org.onap.dmaap.datarouter.provisioning.beans.Subscription;
39 import org.onap.dmaap.datarouter.provisioning.beans.Updateable;
40 import org.onap.dmaap.datarouter.provisioning.utils.DB;
41 import org.powermock.modules.junit4.PowerMockRunner;
42 import org.slf4j.LoggerFactory;
44 import javax.persistence.EntityManager;
45 import javax.persistence.EntityManagerFactory;
46 import javax.persistence.Persistence;
47 import javax.servlet.ServletInputStream;
48 import javax.servlet.ServletOutputStream;
49 import javax.servlet.http.HttpServletRequest;
50 import javax.servlet.http.HttpServletResponse;
52 import java.io.FileNotFoundException;
53 import java.io.PrintWriter;
54 import java.sql.SQLException;
55 import java.util.HashSet;
58 import static org.hamcrest.Matchers.notNullValue;
59 import static org.junit.Assert.assertEquals;
60 import static org.mockito.Mockito.*;
61 import static org.onap.dmaap.datarouter.provisioning.BaseServlet.BEHALF_HEADER;
64 @RunWith(PowerMockRunner.class)
65 public class SubscriptionServletTest extends DrServletTestBase {
66 private static EntityManagerFactory emf;
67 private static EntityManager em;
68 private SubscriptionServlet subscriptionServlet;
70 private final String URL= "https://172.100.0.5";
71 private final String USER = "user1";
72 private final String PASSWORD="password1";
76 private HttpServletRequest request;
78 private HttpServletResponse response;
80 ListAppender<ILoggingEvent> listAppender;
83 public static void init() {
84 emf = Persistence.createEntityManagerFactory("dr-unit-tests");
85 em = emf.createEntityManager();
87 "org.onap.dmaap.datarouter.provserver.properties",
88 "src/test/resources/h2Database.properties");
92 public static void tearDownClass() throws FileNotFoundException {
99 public void setUp() throws Exception {
100 listAppender = setTestLogger(SubscriptionServlet.class);
101 subscriptionServlet = new SubscriptionServlet();
103 setAuthoriserToReturnRequestIsAuthorized();
104 setPokerToNotCreateTimersWhenDeleteSubscriptionIsCalled();
105 setupValidAuthorisedRequest();
106 setUpValidSecurityOnHttpRequest();
110 public void Given_Request_Is_HTTP_DELETE_SC_Forbidden_Response_Is_Generated() throws Exception {
111 when(request.isSecure()).thenReturn(false);
112 subscriptionServlet.doDelete(request, response);
113 verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
114 verifyEnteringExitCalled(listAppender);
118 public void Given_Request_Is_HTTP_DELETE_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated() throws Exception {
119 setBehalfHeader(null);
120 subscriptionServlet.doDelete(request, response);
121 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
125 public void Given_Request_Is_HTTP_DELETE_And_Path_Header_Is_Not_Set_In_Request_With_Valid_Path_Then_Bad_Request_Response_Is_Generated() throws Exception {
126 when(request.getPathInfo()).thenReturn(null);
127 subscriptionServlet.doDelete(request, response);
128 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
132 public void Given_Request_Is_HTTP_DELETE_And_Subscription_Id_Is_Invalid_Then_Not_Found_Response_Is_Generated() throws Exception {
133 when(request.getPathInfo()).thenReturn("/3");
134 subscriptionServlet.doDelete(request, response);
135 verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
139 public void Given_Request_Is_HTTP_DELETE_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated() throws Exception {
140 setAuthoriserToReturnRequestNotAuthorized();
141 subscriptionServlet.doDelete(request, response);
142 verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
146 public void Given_Request_Is_HTTP_DELETE_And_Delete_On_Database_Fails_An_Internal_Server_Error_Is_Reported() throws Exception {
147 SubscriptionServlet subscriptionServlet = new SubscriptionServlet(){
148 public boolean doDelete(Deleteable deletable){
152 subscriptionServlet.doDelete(request, response);
153 verify(response).sendError(eq(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), argThat(notNullValue(String.class)));
157 public void Given_Request_Is_HTTP_DELETE_And_Delete_On_Database_Succeeds_A_NO_CONTENT_Response_Is_Generated() throws Exception {
158 subscriptionServlet.doDelete(request, response);
159 verify(response).setStatus(eq(HttpServletResponse.SC_NO_CONTENT));
160 verifyEnteringExitCalled(listAppender);
161 insertSubscriptionIntoDb();
165 public void Given_Request_Is_HTTP_GET_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
166 when(request.isSecure()).thenReturn(false);
167 subscriptionServlet.doGet(request, response);
168 verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
169 verifyEnteringExitCalled(listAppender);
173 public void Given_Request_Is_HTTP_GET_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated() throws Exception {
174 setBehalfHeader(null);
175 subscriptionServlet.doGet(request, response);
176 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
180 public void Given_Request_Is_HTTP_GET_And_Path_Header_Is_Not_Set_In_Request_With_Valid_Path_Then_Bad_Request_Response_Is_Generated() throws Exception {
181 when(request.getPathInfo()).thenReturn(null);
182 subscriptionServlet.doGet(request, response);
183 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
187 public void Given_Request_Is_HTTP_GET_And_Subscription_Id_Is_Invalid_Then_Not_Found_Response_Is_Generated() throws Exception {
188 when(request.getPathInfo()).thenReturn("/3");
189 subscriptionServlet.doGet(request, response);
190 verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
194 public void Given_Request_Is_HTTP_GET_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated() throws Exception {
195 setAuthoriserToReturnRequestNotAuthorized();
196 subscriptionServlet.doGet(request, response);
197 verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
201 public void Given_Request_Is_HTTP_GET_And_Request_Succeeds() throws Exception {
202 ServletOutputStream outStream = mock(ServletOutputStream.class);
203 when(response.getOutputStream()).thenReturn(outStream);
204 subscriptionServlet.doGet(request, response);
205 verify(response).setStatus(eq(HttpServletResponse.SC_OK));
206 verifyEnteringExitCalled(listAppender);
210 public void Given_Request_Is_HTTP_PUT_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
211 when(request.isSecure()).thenReturn(false);
212 subscriptionServlet.doPut(request, response);
213 verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
214 verifyEnteringExitCalled(listAppender);
218 public void Given_Request_Is_HTTP_PUT_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated() throws Exception {
219 setBehalfHeader(null);
220 subscriptionServlet.doPut(request, response);
221 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
225 public void Given_Request_Is_HTTP_PUT_And_Path_Header_Is_Not_Set_In_Request_With_Valid_Path_Then_Bad_Request_Response_Is_Generated() throws Exception {
226 when(request.getPathInfo()).thenReturn(null);
227 subscriptionServlet.doPut(request, response);
228 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
232 public void Given_Request_Is_HTTP_PUT_And_Subscription_Id_Is_Invalid_Then_Not_Found_Response_Is_Generated() throws Exception {
233 when(request.getPathInfo()).thenReturn("/3");
234 subscriptionServlet.doPut(request, response);
235 verify(response).sendError(eq(HttpServletResponse.SC_NOT_FOUND), argThat(notNullValue(String.class)));
239 public void Given_Request_Is_HTTP_PUT_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated() throws Exception {
240 setAuthoriserToReturnRequestNotAuthorized();
241 subscriptionServlet.doPut(request, response);
242 verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
246 public void Given_Request_Is_HTTP_PUT_And_Content_Header_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated() throws Exception {
247 when(request.getContentType()).thenReturn("stub_ContentType");
248 subscriptionServlet.doPut(request, response);
249 verify(response).sendError(eq(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE), argThat(notNullValue(String.class)));
253 public void Given_Request_Is_HTTP_PUT_And_Request_Contains_Badly_Formed_JSON_Then_Bad_Request_Response_Is_Generated() throws Exception {
254 when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.subscription; version=1.0");
255 ServletInputStream inStream = mock(ServletInputStream.class);
256 when(request.getInputStream()).thenReturn(inStream);
257 subscriptionServlet.doPut(request, response);
258 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
262 public void Given_Request_Is_HTTP_PUT_And_Subscription_Object_Is_Invalid_Bad_Request_Response_Is_Generated() throws Exception {
263 when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.subscription; version=1.0");
264 SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
265 protected JSONObject getJSONfromInput(HttpServletRequest req) {
266 JSONObject jo = new JSONObject();
270 subscriptionServlet.doPut(request, response);
271 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
275 public void Given_Request_Is_HTTP_PUT_And_Subscriber_Modified_By_Different_Creator_Then_Bad_Request_Is_Generated() throws Exception {
276 when(request.getHeader("X-ATT-DR-ON-BEHALF-OF-GROUP")).thenReturn(null);
277 when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.subscription; version=1.0");
278 JSONObject JSObject = buildRequestJsonObject();
279 SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
280 protected JSONObject getJSONfromInput(HttpServletRequest req) {
281 JSONObject jo = new JSONObject();
282 jo.put("name", "stub_name");
283 jo.put("version", "2.0");
284 jo.put("metadataOnly", true);
285 jo.put("suspend", true);
286 jo.put("delivery", JSObject);
287 jo.put("subscriber", "differentSubscriber");
288 jo.put("sync", true);
292 subscriptionServlet.doPut(request, response);
293 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
297 public void Given_Request_Is_HTTP_PUT_And_Update_Fails() throws Exception {
298 when(request.getHeader("X-ATT-DR-ON-BEHALF-OF-GROUP")).thenReturn("stub_subjectGroup");
299 when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.subscription; version=1.0");
300 JSONObject JSObject = buildRequestJsonObject();
301 SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
302 protected JSONObject getJSONfromInput(HttpServletRequest req) {
303 JSONObject jo = new JSONObject();
304 jo.put("name", "stub_name");
305 jo.put("version", "2.0");
306 jo.put("metadataOnly", true);
307 jo.put("suspend", true);
308 jo.put("delivery", JSObject);
309 jo.put("sync", true);
314 protected boolean doUpdate(Updateable bean) {
318 subscriptionServlet.doPut(request, response);
319 verify(response).sendError(eq(HttpServletResponse.SC_INTERNAL_SERVER_ERROR), argThat(notNullValue(String.class)));
323 public void Given_Request_Is_HTTP_PUT_And_Update_Succeeds() throws Exception {
324 ServletOutputStream outStream = mock(ServletOutputStream.class);
325 when(response.getOutputStream()).thenReturn(outStream);
326 when(request.getHeader("X-ATT-DR-ON-BEHALF-OF-GROUP")).thenReturn("stub_subjectGroup");
327 when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.subscription; version=1.0");
328 JSONObject JSObject = buildRequestJsonObject();
329 SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
330 protected JSONObject getJSONfromInput(HttpServletRequest req) {
331 JSONObject jo = new JSONObject();
332 jo.put("name", "stub_name");
333 jo.put("version", "2.0");
334 jo.put("metadataOnly", true);
335 jo.put("suspend", true);
336 jo.put("delivery", JSObject);
337 jo.put("sync", true);
338 jo.put("changeowner", true);
342 subscriptionServlet.doPut(request, response);
343 verify(response).setStatus(eq(HttpServletResponse.SC_OK));
344 changeSubscriptionBackToNormal();
345 verifyEnteringExitCalled(listAppender);
349 public void Given_Request_Is_HTTP_POST_And_Is_Not_Secure_When_HTTPS_Is_Required_Then_Forbidden_Response_Is_Generated() throws Exception {
350 when(request.isSecure()).thenReturn(false);
351 subscriptionServlet.doPost(request, response);
352 verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
353 verifyEnteringExitCalled(listAppender);
357 public void Given_Request_Is_HTTP_POST_And_BEHALF_HEADER_Is_Not_Set_In_Request_Then_Bad_Request_Response_Is_Generated() throws Exception {
358 setBehalfHeader(null);
359 subscriptionServlet.doPost(request, response);
360 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
364 public void Given_Request_Is_HTTP_POST_And_Path_Header_Is_Not_Set_In_Request_With_Valid_Path_Then_Bad_Request_Response_Is_Generated() throws Exception {
365 when(request.getPathInfo()).thenReturn(null);
366 subscriptionServlet.doPost(request, response);
367 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
371 public void Given_Request_Is_HTTP_POST_And_Subscription_Id_Is_Invalid_Then_Not_Found_Response_Is_Generated() throws Exception {
372 when(request.getPathInfo()).thenReturn("/3");
373 subscriptionServlet.doPost(request, response);
374 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
378 public void Given_Request_Is_HTTP_POST_And_Content_Header_Is_Not_Supported_Type_Then_Unsupported_Media_Type_Response_Is_Generated() throws Exception {
379 when(request.getContentType()).thenReturn("stub_ContentType");
380 subscriptionServlet.doPost(request, response);
381 verify(response).sendError(eq(HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE), argThat(notNullValue(String.class)));
385 public void Given_Request_Is_HTTP_POST_And_Request_Is_Not_Authorized_Then_Forbidden_Response_Is_Generated() throws Exception {
386 when(request.getHeader(anyString())).thenReturn("application/vnd.att-dr.subscription-control");
387 setAuthoriserToReturnRequestNotAuthorized();
388 subscriptionServlet.doPost(request, response);
389 verify(response).sendError(eq(HttpServletResponse.SC_FORBIDDEN), argThat(notNullValue(String.class)));
393 public void Given_Request_Is_HTTP_POST_And_Request_Contains_Badly_Formed_JSON_Then_Bad_Request_Response_Is_Generated() throws Exception {
394 when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.subscription-control; version=1.0");
395 ServletInputStream inStream = mock(ServletInputStream.class);
396 when(request.getInputStream()).thenReturn(inStream);
397 subscriptionServlet.doPost(request, response);
398 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
402 public void Given_Request_Is_HTTP_POST_And_Post_Fails() throws Exception {
403 when(request.getHeader("X-ATT-DR-ON-BEHALF-OF-GROUP")).thenReturn("stub_subjectGroup");
404 when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.subscription-control; version=1.0");
405 JSONObject JSObject = buildRequestJsonObject();
406 SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
407 protected JSONObject getJSONfromInput(HttpServletRequest req) {
408 JSONObject jo = new JSONObject();
409 jo.put("name", "stub_name");
410 jo.put("version", "2.0");
411 jo.put("metadataOnly", true);
412 jo.put("suspend", true);
413 jo.put("delivery", JSObject);
417 subscriptionServlet.doPost(request, response);
418 verify(response).sendError(eq(HttpServletResponse.SC_BAD_REQUEST), argThat(notNullValue(String.class)));
422 public void Given_Request_Is_HTTP_POST_And_Post_Succeeds() throws Exception {
423 ServletOutputStream outStream = mock(ServletOutputStream.class);
424 when(response.getOutputStream()).thenReturn(outStream);
425 when(request.getHeader("X-ATT-DR-ON-BEHALF-OF-GROUP")).thenReturn("stub_subjectGroup");
426 when(request.getHeader("Content-Type")).thenReturn("application/vnd.att-dr.subscription-control; version=1.0");
427 JSONObject JSObject = buildRequestJsonObject();
428 SubscriptionServlet subscriptionServlet = new SubscriptionServlet() {
429 protected JSONObject getJSONfromInput(HttpServletRequest req) {
430 JSONObject jo = new JSONObject();
431 jo.put("name", "stub_name");
432 jo.put("version", "2.0");
433 jo.put("metadataOnly", true);
434 jo.put("suspend", true);
435 jo.put("delivery", JSObject);
436 jo.put("failed", false);
440 subscriptionServlet.doPost(request, response);
441 verify(response).setStatus(eq(HttpServletResponse.SC_ACCEPTED));
442 verifyEnteringExitCalled(listAppender);
446 private JSONObject buildRequestJsonObject() {
447 JSONObject JSObject = new JSONObject();
448 JSObject.put("url", "https://stub_address");
449 JSObject.put("use100", "true");
450 JSObject.put("password", "stub_password");
451 JSObject.put("user", "stub_user");
455 private void setUpValidSecurityOnHttpRequest() throws Exception {
456 when(request.isSecure()).thenReturn(true);
457 Set<String> authAddressesAndNetworks = new HashSet<String>();
458 authAddressesAndNetworks.add(("127.0.0.1"));
459 FieldUtils.writeDeclaredStaticField(BaseServlet.class, "authorizedAddressesAndNetworks", authAddressesAndNetworks, true);
460 FieldUtils.writeDeclaredStaticField(BaseServlet.class, "requireCert", false, true);
463 private void setBehalfHeader(String headerValue) {
464 when(request.getHeader(BEHALF_HEADER)).thenReturn(headerValue);
467 private void setValidPathInfoInHttpHeader() {
468 when(request.getPathInfo()).thenReturn("/1");
471 private void setAuthoriserToReturnRequestNotAuthorized() throws IllegalAccessException {
472 AuthorizationResponse authResponse = mock(AuthorizationResponse.class);
473 Authorizer authorizer = mock(Authorizer.class);
474 FieldUtils.writeDeclaredStaticField(BaseServlet.class, "authz", authorizer, true);
475 when(authorizer.decide(request)).thenReturn(authResponse);
476 when(authResponse.isAuthorized()).thenReturn(false);
479 private void setAuthoriserToReturnRequestIsAuthorized() throws IllegalAccessException {
480 AuthorizationResponse authResponse = mock(AuthorizationResponse.class);
481 Authorizer authorizer = mock(Authorizer.class);
482 FieldUtils.writeDeclaredStaticField(BaseServlet.class, "authz", authorizer, true);
483 when(authorizer.decide(request)).thenReturn(authResponse);
484 when(authResponse.isAuthorized()).thenReturn(true);
487 private void setPokerToNotCreateTimersWhenDeleteSubscriptionIsCalled() throws Exception {
488 Poker poker = mock(Poker.class);
489 FieldUtils.writeDeclaredStaticField(Poker.class, "poker", poker, true);
492 private void setupValidAuthorisedRequest() throws Exception {
493 setUpValidSecurityOnHttpRequest();
494 setBehalfHeader("Stub_Value");
495 setValidPathInfoInHttpHeader();
498 private void insertSubscriptionIntoDb() throws SQLException {
499 Subscription subscription = new Subscription(URL, USER, PASSWORD);
500 subscription.setSubid(1);
501 subscription.setSubscriber("user1");
502 subscription.setFeedid(1);
503 SubDelivery subDelivery = new SubDelivery(URL, USER, PASSWORD, true);
504 subscription.setDelivery(subDelivery);
505 subscription.setGroupid(1);
506 subscription.setMetadataOnly(false);
507 subscription.setSuspended(false);
508 subscription.doInsert(db.getConnection());
511 private void changeSubscriptionBackToNormal() throws SQLException {
512 Subscription subscription = new Subscription("https://172.100.0.5", "user1", "password1");
513 subscription.setSubid(1);
514 subscription.setSubscriber("user1");
515 subscription.setFeedid(1);
516 SubDelivery subDelivery = new SubDelivery(URL, USER, PASSWORD, true);
517 subscription.setDelivery(subDelivery);
518 subscription.setGroupid(1);
519 subscription.setMetadataOnly(false);
520 subscription.setSuspended(false);
521 subscription.changeOwnerShip();
522 subscription.doUpdate(db.getConnection());