remove tab characters from code 87/59687/8
authoreronkeo <ronan.keogh@ericsson.com>
Wed, 8 Aug 2018 15:22:25 +0000 (16:22 +0100)
committereronkeo <ronan.keogh@ericsson.com>
Wed, 8 Aug 2018 19:04:45 +0000 (20:04 +0100)
Change-Id: I5b1d041561056833f744270350b3d2c9cd4e1dcb
Issue-ID: DMAAP-570
Signed-off-by: eronkeo <ronan.keogh@ericsson.com>
34 files changed:
datarouter-node/src/main/resources/EelfMessages.properties
datarouter-node/src/main/resources/misc/node.properties
datarouter-node/src/main/resources/node.properties
datarouter-prov/src/main/resources/EelfMessages.properties
datarouter-prov/src/main/resources/docker-compose/node_data/node.properties
datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties
datarouter-prov/src/main/resources/provserver.properties
datarouter-prov/src/test/java/datarouter/provisioning/AllTests.java
datarouter-prov/src/test/java/datarouter/provisioning/FillDB.java
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestCleanup.java [moved from datarouter-prov/src/test/java/datarouter/provisioning/testCleanup.java with 50% similarity]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestDrFeedsDelete.java [moved from datarouter-prov/src/test/java/datarouter/provisioning/testDRFeedsDelete.java with 70% similarity]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestDrFeedsGet.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestDrFeedsPost.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestDrFeedsPut.java [moved from datarouter-prov/src/test/java/datarouter/provisioning/testDRFeedsPut.java with 70% similarity]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestFeedDelete.java [moved from datarouter-prov/src/test/java/datarouter/provisioning/testFeedDelete.java with 51% similarity]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestFeedPut.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalGet.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalMisc.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestLogGet.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestPublish.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestRleBitSet.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestRouteApi.java [moved from datarouter-prov/src/test/java/datarouter/provisioning/testRouteAPI.java with 92% similarity]
datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestSubscribePost.java [new file with mode: 0644]
datarouter-prov/src/test/java/datarouter/provisioning/testBase.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testDRFeedsGet.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testDRFeedsPost.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testFeedPut.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testInternalGet.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testInternalMisc.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testLogGet.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testPublish.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testRLEBitSet.java [deleted file]
datarouter-prov/src/test/java/datarouter/provisioning/testSubscribePost.java [deleted file]

index 8c17417..659748e 100644 (file)
@@ -7,9 +7,9 @@
 # * Licensed under the Apache License, Version 2.0 (the "License");\r
 # * you may not use this file except in compliance with the License.\r
 # * You may obtain a copy of the License at\r
-# * \r
+# *\r
 #  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
+# *\r
 #  * Unless required by applicable law or agreed to in writing, software\r
 # * distributed under the License is distributed on an "AS IS" BASIS,\r
 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 #\r
 ######\r
 #Error code classification category\r
-#100   Permission errors\r
-#200   Availability errors/Timeouts\r
-#300   Data errors\r
-#400   Schema Interface type/validation errors\r
-#500   Business process errors\r
-#900   Unknown errors\r
+#100    Permission errors\r
+#200    Availability errors/Timeouts\r
+#300    Data errors\r
+#400    Schema Interface type/validation errors\r
+#500    Business process errors\r
+#900    Unknown errors\r
 #\r
 ########################################################################\r
 \r
index fb97702..fc70741 100644 (file)
@@ -7,9 +7,9 @@
 # * Licensed under the Apache License, Version 2.0 (the "License");\r
 # * you may not use this file except in compliance with the License.\r
 # * You may obtain a copy of the License at\r
-# * \r
+# *\r
 #  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
+# *\r
 #  * Unless required by applicable law or agreed to in writing, software\r
 # * distributed under the License is distributed on an "AS IS" BASIS,\r
 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 # *\r
 #-------------------------------------------------------------------------------\r
 #\r
-#      Configuration parameters fixed at startup for the DataRouter node\r
+#    Configuration parameters fixed at startup for the DataRouter node\r
 #\r
-#      URL to retrieve dynamic configuration\r
+#    URL to retrieve dynamic configuration\r
 #\r
-#ProvisioningURL:      ${DRTR_PROV_INTURL}\r
+#ProvisioningURL:    ${DRTR_PROV_INTURL}\r
 ProvisioningURL=https://prov.datarouternew.com:8443/internal/prov\r
 \r
 #\r
-#      URL to upload PUB/DEL/EXP logs\r
+#    URL to upload PUB/DEL/EXP logs\r
 #\r
-#LogUploadURL: ${DRTR_LOG_URL}\r
+#LogUploadURL:    ${DRTR_LOG_URL}\r
 LogUploadURL=https://prov.datarouternew.com:8443/internal/logs\r
 \r
 #\r
-#      The port number for http as seen within the server\r
+#    The port number for http as seen within the server\r
 #\r
-#IntHttpPort:  ${DRTR_NODE_INTHTTPPORT:-8080}\r
+#IntHttpPort:    ${DRTR_NODE_INTHTTPPORT:-8080}\r
 IntHttpPort=8080\r
 #\r
-#      The port number for https as seen within the server\r
+#    The port number for https as seen within the server\r
 #\r
 IntHttpsPort=8443\r
 #\r
-#      The external port number for https taking port mapping into account\r
+#    The external port number for https taking port mapping into account\r
 #\r
 ExtHttpsPort=443\r
 #\r
-#      The minimum interval between fetches of the dynamic configuration\r
-#      from the provisioning server\r
+#    The minimum interval between fetches of the dynamic configuration\r
+#    from the provisioning server\r
 #\r
 MinProvFetchInterval=10000\r
 #\r
-#      The minimum interval between saves of the redirection data file\r
+#    The minimum interval between saves of the redirection data file\r
 #\r
 MinRedirSaveInterval=10000\r
 #\r
-#      The path to the directory where log files are stored\r
+#    The path to the directory where log files are stored\r
 #\r
 LogDir=/opt/app/datartr/logs\r
 #\r
-#      The retention interval (in days) for log files\r
+#    The retention interval (in days) for log files\r
 #\r
 LogRetention=30\r
 #\r
-#      The path to the directories where data and meta data files are stored\r
+#    The path to the directories where data and meta data files are stored\r
 #\r
 SpoolDir=/opt/app/datartr/spool\r
 #\r
-#      The path to the redirection data file\r
-#\r
-#RedirectionFile:      etc/redirections.dat\r
+#    The path to the redirection data file\r
 #\r
-#      The type of keystore for https\r
+#RedirectionFile:    etc/redirections.dat\r
 #\r
-KeyStoreType:  jks\r
+#    The type of keystore for https\r
+KeyStoreType:    jks\r
 #\r
-#      The path to the keystore for https\r
+#    The path to the keystore for https\r
 #\r
 KeyStoreFile:/opt/app/datartr/self_signed/keystore.jks\r
 #\r
-#      The password for the https keystore\r
+#    The password for the https keystore\r
 #\r
 KeyStorePassword=changeit\r
 #\r
-#      The password for the private key in the https keystore\r
+#    The password for the private key in the https keystore\r
 #\r
 KeyPassword=changeit\r
 #\r
-#      The type of truststore for https\r
+#    The type of truststore for https\r
 #\r
 TrustStoreType=jks\r
 #\r
-#      The path to the truststore for https\r
+#    The path to the truststore for https\r
 #\r
 #TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts\r
 TrustStoreFile=/opt/app/datartr/self_signed/cacerts.jks\r
 #\r
-#      The password for the https truststore\r
+#    The password for the https truststore\r
 #\r
 TrustStorePassword=changeit\r
 #\r
-#      The path to the file used to trigger an orderly shutdown\r
+#    The path to the file used to trigger an orderly shutdown\r
 #\r
 QuiesceFile=etc/SHUTDOWN\r
 #\r
-#      The key used to generate passwords for node to node transfers\r
+#    The key used to generate passwords for node to node transfers\r
 #\r
 NodeAuthKey=Node123!\r
 \r
index fb97702..411cc2b 100644 (file)
@@ -7,9 +7,9 @@
 # * Licensed under the Apache License, Version 2.0 (the "License");\r
 # * you may not use this file except in compliance with the License.\r
 # * You may obtain a copy of the License at\r
-# * \r
+# *\r
 #  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
+# *\r
 #  * Unless required by applicable law or agreed to in writing, software\r
 # * distributed under the License is distributed on an "AS IS" BASIS,\r
 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 # *\r
 #-------------------------------------------------------------------------------\r
 #\r
-#      Configuration parameters fixed at startup for the DataRouter node\r
+#    Configuration parameters fixed at startup for the DataRouter node\r
 #\r
-#      URL to retrieve dynamic configuration\r
+#    URL to retrieve dynamic configuration\r
 #\r
-#ProvisioningURL:      ${DRTR_PROV_INTURL}\r
+#ProvisioningURL:    ${DRTR_PROV_INTURL}\r
 ProvisioningURL=https://prov.datarouternew.com:8443/internal/prov\r
 \r
 #\r
-#      URL to upload PUB/DEL/EXP logs\r
+#    URL to upload PUB/DEL/EXP logs\r
 #\r
-#LogUploadURL: ${DRTR_LOG_URL}\r
+#LogUploadURL:    ${DRTR_LOG_URL}\r
 LogUploadURL=https://prov.datarouternew.com:8443/internal/logs\r
 \r
 #\r
-#      The port number for http as seen within the server\r
+#    The port number for http as seen within the server\r
 #\r
-#IntHttpPort:  ${DRTR_NODE_INTHTTPPORT:-8080}\r
+#IntHttpPort:    ${DRTR_NODE_INTHTTPPORT:-8080}\r
 IntHttpPort=8080\r
 #\r
-#      The port number for https as seen within the server\r
+#    The port number for https as seen within the server\r
 #\r
 IntHttpsPort=8443\r
 #\r
-#      The external port number for https taking port mapping into account\r
+#    The external port number for https taking port mapping into account\r
 #\r
 ExtHttpsPort=443\r
 #\r
-#      The minimum interval between fetches of the dynamic configuration\r
-#      from the provisioning server\r
+#    The minimum interval between fetches of the dynamic configuration\r
+#    from the provisioning server\r
 #\r
 MinProvFetchInterval=10000\r
 #\r
-#      The minimum interval between saves of the redirection data file\r
+#    The minimum interval between saves of the redirection data file\r
 #\r
 MinRedirSaveInterval=10000\r
 #\r
-#      The path to the directory where log files are stored\r
+#    The path to the directory where log files are stored\r
 #\r
 LogDir=/opt/app/datartr/logs\r
 #\r
-#      The retention interval (in days) for log files\r
+#    The retention interval (in days) for log files\r
 #\r
 LogRetention=30\r
 #\r
-#      The path to the directories where data and meta data files are stored\r
+#    The path to the directories where data and meta data files are stored\r
 #\r
 SpoolDir=/opt/app/datartr/spool\r
 #\r
-#      The path to the redirection data file\r
+#    The path to the redirection data file\r
 #\r
-#RedirectionFile:      etc/redirections.dat\r
+#RedirectionFile:    etc/redirections.dat\r
 #\r
-#      The type of keystore for https\r
+#    The type of keystore for https\r
 #\r
-KeyStoreType:  jks\r
+KeyStoreType:    jks\r
 #\r
-#      The path to the keystore for https\r
+#    The path to the keystore for https\r
 #\r
 KeyStoreFile:/opt/app/datartr/self_signed/keystore.jks\r
 #\r
-#      The password for the https keystore\r
+#    The password for the https keystore\r
 #\r
 KeyStorePassword=changeit\r
 #\r
-#      The password for the private key in the https keystore\r
+#    The password for the private key in the https keystore\r
 #\r
 KeyPassword=changeit\r
 #\r
-#      The type of truststore for https\r
+#    The type of truststore for https\r
 #\r
 TrustStoreType=jks\r
 #\r
-#      The path to the truststore for https\r
+#    The path to the truststore for https\r
 #\r
 #TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts\r
 TrustStoreFile=/opt/app/datartr/self_signed/cacerts.jks\r
 #\r
-#      The password for the https truststore\r
+#    The password for the https truststore\r
 #\r
 TrustStorePassword=changeit\r
 #\r
-#      The path to the file used to trigger an orderly shutdown\r
+#    The path to the file used to trigger an orderly shutdown\r
 #\r
 QuiesceFile=etc/SHUTDOWN\r
 #\r
-#      The key used to generate passwords for node to node transfers\r
+#    The key used to generate passwords for node to node transfers\r
 #\r
 NodeAuthKey=Node123!\r
 \r
index 5e8b179..b0afa48 100644 (file)
@@ -7,9 +7,9 @@
 # * Licensed under the Apache License, Version 2.0 (the "License");\r
 # * you may not use this file except in compliance with the License.\r
 # * You may obtain a copy of the License at\r
-# * \r
+# *\r
 #  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
+# *\r
 #  * Unless required by applicable law or agreed to in writing, software\r
 # * distributed under the License is distributed on an "AS IS" BASIS,\r
 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 #\r
 ######\r
 #Error code classification category\r
-#100   Permission errors\r
-#200   Availability errors/Timeouts\r
-#300   Data errors\r
-#400   Schema Interface type/validation errors\r
-#500   Business process errors\r
-#900   Unknown errors\r
+#100    Permission errors\r
+#200    Availability errors/Timeouts\r
+#300    Data errors\r
+#400    Schema Interface type/validation errors\r
+#500    Business process errors\r
+#900    Unknown errors\r
 #\r
 ########################################################################\r
 \r
index f57833c..4848502 100644 (file)
@@ -7,9 +7,9 @@
 # * Licensed under the Apache License, Version 2.0 (the "License");\r
 # * you may not use this file except in compliance with the License.\r
 # * You may obtain a copy of the License at\r
-# * \r
+# *\r
 #  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
+# *\r
 #  * Unless required by applicable law or agreed to in writing, software\r
 # * distributed under the License is distributed on an "AS IS" BASIS,\r
 # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
 # *\r
 #-------------------------------------------------------------------------------\r
 #\r
-#      Configuration parameters fixed at startup for the DataRouter node\r
+#    Configuration parameters fixed at startup for the DataRouter node\r
 #\r
-#      URL to retrieve dynamic configuration\r
+#    URL to retrieve dynamic configuration\r
 #\r
-#ProvisioningURL:      ${DRTR_PROV_INTURL:-https://feeds-drtr.web.att.com/internal/prov}\r
+#ProvisioningURL:    ${DRTR_PROV_INTURL:-https://feeds-drtr.web.att.com/internal/prov}\r
 ProvisioningURL=https://prov.datarouternew.com:8443/internal/prov\r
 \r
 #\r
-#      URL to upload PUB/DEL/EXP logs\r
+#    URL to upload PUB/DEL/EXP logs\r
 #\r
-#LogUploadURL: ${DRTR_LOG_URL:-https://feeds-drtr.web.att.com/internal/logs}\r
+#LogUploadURL:    ${DRTR_LOG_URL:-https://feeds-drtr.web.att.com/internal/logs}\r
 LogUploadURL=https://prov.datarouternew.com:8443/internal/logs\r
 \r
 #\r
-#      The port number for http as seen within the server\r
+#    The port number for http as seen within the server\r
 #\r
-#IntHttpPort:  ${DRTR_NODE_INTHTTPPORT:-8080}\r
+#IntHttpPort:    ${DRTR_NODE_INTHTTPPORT:-8080}\r
 IntHttpPort=8080\r
 #\r
-#      The port number for https as seen within the server\r
+#    The port number for https as seen within the server\r
 #\r
 IntHttpsPort=8443\r
 #\r
-#      The external port number for https taking port mapping into account\r
+#    The external port number for https taking port mapping into account\r
 #\r
 ExtHttpsPort=443\r
 #\r
-#      The minimum interval between fetches of the dynamic configuration\r
-#      from the provisioning server\r
+#    The minimum interval between fetches of the dynamic configuration\r
+#    from the provisioning server\r
 #\r
 MinProvFetchInterval=10000\r
 #\r
-#      The minimum interval between saves of the redirection data file\r
+#    The minimum interval between saves of the redirection data file\r
 #\r
 MinRedirSaveInterval=10000\r
 #\r
-#      The path to the directory where log files are stored\r
+#    The path to the directory where log files are stored\r
 #\r
 LogDir=/opt/app/datartr/logs\r
 #\r
-#      The retention interval (in days) for log files\r
+#    The retention interval (in days) for log files\r
 #\r
 LogRetention=30\r
 #\r
-#      The path to the directories where data and meta data files are stored\r
+#    The path to the directories where data and meta data files are stored\r
 #\r
 SpoolDir=/opt/app/datartr/spool\r
 #\r
-#      The path to the redirection data file\r
+#    The path to the redirection data file\r
 #\r
-#RedirectionFile:      etc/redirections.dat\r
+#RedirectionFile:    etc/redirections.dat\r
 #\r
-#      The type of keystore for https\r
+#    The type of keystore for https\r
 #\r
-KeyStoreType:  jks\r
+KeyStoreType:    jks\r
 #\r
-#      The path to the keystore for https\r
+#    The path to the keystore for https\r
 #\r
 KeyStoreFile:/opt/app/datartr/self_signed/keystore.jks\r
 #\r
-#      The password for the https keystore\r
+#    The password for the https keystore\r
 #\r
 KeyStorePassword=changeit\r
 #\r
-#      The password for the private key in the https keystore\r
+#    The password for the private key in the https keystore\r
 #\r
 KeyPassword=changeit\r
 #\r
-#      The type of truststore for https\r
+#    The type of truststore for https\r
 #\r
 TrustStoreType=jks\r
 #\r
-#      The path to the truststore for https\r
+#    The path to the truststore for https\r
 #\r
 #TrustStoreFile=/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts\r
 TrustStoreFile=/opt/app/datartr/self_signed/cacerts.jks\r
 #\r
-#      The password for the https truststore\r
+#    The password for the https truststore\r
 #\r
 TrustStorePassword=changeit\r
 #\r
-#      The path to the file used to trigger an orderly shutdown\r
+#    The path to the file used to trigger an orderly shutdown\r
 #\r
 QuiesceFile=etc/SHUTDOWN\r
 #\r
-#      The key used to generate passwords for node to node transfers\r
+#    The key used to generate passwords for node to node transfers\r
 #\r
 NodeAuthKey=Node123!\r
 \r
index f37330a..d733cc2 100644 (file)
@@ -1,48 +1,47 @@
-#-------------------------------------------------------------------------------\r
-# ============LICENSE_START==================================================\r
-# * org.onap.dmaap\r
-# * ===========================================================================\r
-# * Copyright � 2017 AT&T Intellectual Property. All rights reserved.\r
-# * ===========================================================================\r
-# * Licensed under the Apache License, Version 2.0 (the "License");\r
-# * you may not use this file except in compliance with the License.\r
-# * You may obtain a copy of the License at\r
-# * \r
-#  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
-#  * Unless required by applicable law or agreed to in writing, software\r
-# * distributed under the License is distributed on an "AS IS" BASIS,\r
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# * See the License for the specific language governing permissions and\r
-# * limitations under the License.\r
-# * ============LICENSE_END====================================================\r
-# *\r
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
-# *\r
-#-------------------------------------------------------------------------------\r
-\r
-\r
-#Jetty Server properties\r
-org.onap.dmaap.datarouter.provserver.http.port           = 8080\r
-org.onap.dmaap.datarouter.provserver.https.port          = 8443\r
-org.onap.dmaap.datarouter.provserver.https.relaxation     = false\r
-org.onap.dmaap.datarouter.provserver.keymanager.password = changeit\r
-org.onap.dmaap.datarouter.provserver.keystore.type       = jks\r
-org.onap.dmaap.datarouter.provserver.keystore.path       = /opt/app/datartr/self_signed/keystore.jks\r
-\r
-org.onap.dmaap.datarouter.provserver.keystore.password   = changeit\r
-#org.onap.dmaap.datarouter.provserver.truststore.path     = /home/eby/dr2/misc/cacerts+1\r
-#org.onap.dmaap.datarouter.provserver.truststore.path     = /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts\r
-org.onap.dmaap.datarouter.provserver.truststore.path     = /opt/app/datartr/self_signed/cacerts.jks\r
-\r
-org.onap.dmaap.datarouter.provserver.truststore.password = changeit\r
-org.onap.dmaap.datarouter.provserver.accesslog.dir       = /opt/app/datartr/logs\r
-org.onap.dmaap.datarouter.provserver.spooldir            = /opt/app/datartr/spool\r
-org.onap.dmaap.datarouter.provserver.dbscripts           = /opt/app/datartr/etc/misc\r
-org.onap.dmaap.datarouter.provserver.logretention        = 30\r
-\r
-# Database access\r
-org.onap.dmaap.datarouter.db.driver   = org.mariadb.jdbc.Driver\r
-org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://172.100.0.2:3306/datarouter\r
-org.onap.dmaap.datarouter.db.login    = datarouter\r
-org.onap.dmaap.datarouter.db.password = datarouter\r
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright � 2017 AT&T Intellectual Property. All rights reserved.
+# * ===========================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+#  *      http://www.apache.org/licenses/LICENSE-2.0
+# *
+#  * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# * ============LICENSE_END====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+
+#Jetty Server properties
+org.onap.dmaap.datarouter.provserver.http.port           = 8080
+org.onap.dmaap.datarouter.provserver.https.port          = 8443
+org.onap.dmaap.datarouter.provserver.https.relaxation       = false
+org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
+org.onap.dmaap.datarouter.provserver.keystore.type       = jks
+org.onap.dmaap.datarouter.provserver.keystore.path       = /opt/app/datartr/self_signed/keystore.jks
+
+org.onap.dmaap.datarouter.provserver.keystore.password   = changeit
+#org.onap.dmaap.datarouter.provserver.truststore.path     = /home/eby/dr2/misc/cacerts+1
+#org.onap.dmaap.datarouter.provserver.truststore.path     = /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
+org.onap.dmaap.datarouter.provserver.truststore.path     = /opt/app/datartr/self_signed/cacerts.jks
+
+org.onap.dmaap.datarouter.provserver.truststore.password = changeit
+org.onap.dmaap.datarouter.provserver.accesslog.dir       = /opt/app/datartr/logs
+org.onap.dmaap.datarouter.provserver.spooldir            = /opt/app/datartr/spool
+org.onap.dmaap.datarouter.provserver.dbscripts           = /opt/app/datartr/etc/misc
+org.onap.dmaap.datarouter.provserver.logretention        = 30
+
+# Database access
+org.onap.dmaap.datarouter.db.driver   = org.mariadb.jdbc.Driver
+org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://172.100.0.2:3306/datarouter
+org.onap.dmaap.datarouter.db.login    = datarouter
+org.onap.dmaap.datarouter.db.password = datarouter
index f37330a..28ffb98 100644 (file)
@@ -1,48 +1,47 @@
-#-------------------------------------------------------------------------------\r
-# ============LICENSE_START==================================================\r
-# * org.onap.dmaap\r
-# * ===========================================================================\r
-# * Copyright � 2017 AT&T Intellectual Property. All rights reserved.\r
-# * ===========================================================================\r
-# * Licensed under the Apache License, Version 2.0 (the "License");\r
-# * you may not use this file except in compliance with the License.\r
-# * You may obtain a copy of the License at\r
-# * \r
-#  *      http://www.apache.org/licenses/LICENSE-2.0\r
-# * \r
-#  * Unless required by applicable law or agreed to in writing, software\r
-# * distributed under the License is distributed on an "AS IS" BASIS,\r
-# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
-# * See the License for the specific language governing permissions and\r
-# * limitations under the License.\r
-# * ============LICENSE_END====================================================\r
-# *\r
-# * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
-# *\r
-#-------------------------------------------------------------------------------\r
-\r
-\r
-#Jetty Server properties\r
-org.onap.dmaap.datarouter.provserver.http.port           = 8080\r
-org.onap.dmaap.datarouter.provserver.https.port          = 8443\r
-org.onap.dmaap.datarouter.provserver.https.relaxation     = false\r
-org.onap.dmaap.datarouter.provserver.keymanager.password = changeit\r
-org.onap.dmaap.datarouter.provserver.keystore.type       = jks\r
-org.onap.dmaap.datarouter.provserver.keystore.path       = /opt/app/datartr/self_signed/keystore.jks\r
-\r
-org.onap.dmaap.datarouter.provserver.keystore.password   = changeit\r
-#org.onap.dmaap.datarouter.provserver.truststore.path     = /home/eby/dr2/misc/cacerts+1\r
-#org.onap.dmaap.datarouter.provserver.truststore.path     = /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts\r
-org.onap.dmaap.datarouter.provserver.truststore.path     = /opt/app/datartr/self_signed/cacerts.jks\r
-\r
-org.onap.dmaap.datarouter.provserver.truststore.password = changeit\r
-org.onap.dmaap.datarouter.provserver.accesslog.dir       = /opt/app/datartr/logs\r
-org.onap.dmaap.datarouter.provserver.spooldir            = /opt/app/datartr/spool\r
-org.onap.dmaap.datarouter.provserver.dbscripts           = /opt/app/datartr/etc/misc\r
-org.onap.dmaap.datarouter.provserver.logretention        = 30\r
-\r
-# Database access\r
-org.onap.dmaap.datarouter.db.driver   = org.mariadb.jdbc.Driver\r
-org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://172.100.0.2:3306/datarouter\r
-org.onap.dmaap.datarouter.db.login    = datarouter\r
-org.onap.dmaap.datarouter.db.password = datarouter\r
+#-------------------------------------------------------------------------------
+# ============LICENSE_START==================================================
+# * org.onap.dmaap
+# * ===========================================================================
+# * Copyright � 2017 AT&T Intellectual Property. All rights reserved.
+# * ===========================================================================
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+#  *      http://www.apache.org/licenses/LICENSE-2.0
+# *
+#  * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# * ============LICENSE_END====================================================
+# *
+# * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+# *
+#-------------------------------------------------------------------------------
+
+#Jetty Server properties
+org.onap.dmaap.datarouter.provserver.http.port           = 8080
+org.onap.dmaap.datarouter.provserver.https.port          = 8443
+org.onap.dmaap.datarouter.provserver.https.relaxation       = false
+org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
+org.onap.dmaap.datarouter.provserver.keystore.type       = jks
+org.onap.dmaap.datarouter.provserver.keystore.path       = /opt/app/datartr/self_signed/keystore.jks
+
+org.onap.dmaap.datarouter.provserver.keystore.password   = changeit
+#org.onap.dmaap.datarouter.provserver.truststore.path     = /home/eby/dr2/misc/cacerts+1
+#org.onap.dmaap.datarouter.provserver.truststore.path     = /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
+org.onap.dmaap.datarouter.provserver.truststore.path     = /opt/app/datartr/self_signed/cacerts.jks
+
+org.onap.dmaap.datarouter.provserver.truststore.password = changeit
+org.onap.dmaap.datarouter.provserver.accesslog.dir       = /opt/app/datartr/logs
+org.onap.dmaap.datarouter.provserver.spooldir            = /opt/app/datartr/spool
+org.onap.dmaap.datarouter.provserver.dbscripts          = /opt/app/datartr/etc/misc
+org.onap.dmaap.datarouter.provserver.logretention        = 30
+
+# Database access
+org.onap.dmaap.datarouter.db.driver   = org.mariadb.jdbc.Driver
+org.onap.dmaap.datarouter.db.url      = jdbc:mariadb://172.100.0.2:3306/datarouter
+org.onap.dmaap.datarouter.db.login    = datarouter
+org.onap.dmaap.datarouter.db.password = datarouter
index 9215955..34fb144 100644 (file)
@@ -7,9 +7,9 @@
  * * Licensed under the Apache License, Version 2.0 (the "License");
  * * you may not use this file except in compliance with the License.
  * * You may obtain a copy of the License at
- * * 
+ * *
  *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
+ * *
  *  * Unless required by applicable law or agreed to in writing, software
  * * distributed under the License is distributed on an "AS IS" BASIS,
  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,19 +30,20 @@ import org.junit.runners.Suite.SuiteClasses;
 
 @RunWith(Suite.class)
 @SuiteClasses({
-       testDRFeedsPost.class,
-       testDRFeedsGet.class,
-       testDRFeedsPut.class,
-       testDRFeedsDelete.class,
-       testFeedPut.class,
-       testSubscribePost.class,
-       testInternalGet.class,
-       testInternalMisc.class,
-       testPublish.class,
-       testLogGet.class,
-       testFeedDelete.class,
-       testCleanup.class,
-       testRLEBitSet.class
-})
+        IntegrationTestDrFeedsPost.class,
+        IntegrationTestDrFeedsGet.class,
+        IntegrationTestDrFeedsPut.class,
+        IntegrationTestDrFeedsDelete.class,
+        IntegrationTestFeedPut.class,
+        IntegrationTestSubscribePost.class,
+        IntegrationTestInternalGet.class,
+        IntegrationTestInternalMisc.class,
+        IntegrationTestPublish.class,
+        IntegrationTestLogGet.class,
+        IntegrationTestFeedDelete.class,
+        IntegrationTestCleanup.class,
+        IntegrationTestRleBitSet.class
+    })
+
 public class AllTests {
 }
index f83113e..fd682bb 100644 (file)
@@ -7,9 +7,9 @@
  * * Licensed under the Apache License, Version 2.0 (the "License");
  * * you may not use this file except in compliance with the License.
  * * You may obtain a copy of the License at
- * * 
+ * *
  *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
+ * *
  *  * Unless required by applicable law or agreed to in writing, software
  * * distributed under the License is distributed on an "AS IS" BASIS,
  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,6 +20,7 @@
  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  * *
  ******************************************************************************/
+
 package datarouter.provisioning;
 
 import java.io.File;
@@ -46,79 +47,102 @@ import org.json.JSONArray;
 import org.json.JSONObject;
 import org.onap.dmaap.datarouter.provisioning.FeedServlet;
 
+/**
+ * The FillDB class
+ *
+ * @version 1.0.1
+ */
 public class FillDB {
-       public static void main(String[] args)
-               throws KeyStoreException, FileNotFoundException, KeyManagementException, UnrecoverableKeyException, NoSuchAlgorithmException
-       {
-               AbstractHttpClient httpclient = new DefaultHttpClient();
-
-               String keystore = "/home/eby/dr2/misc/client.keystore";
-               String kspass   = "changeit";
-               KeyStore trustStore  = KeyStore.getInstance(KeyStore.getDefaultType());
-           FileInputStream instream = new FileInputStream(new File(keystore));
-           try {
-               trustStore.load(instream, kspass.toCharArray());
-           } catch (Exception x) {
-               System.err.println("READING KEYSTORE: "+x);
-           } finally {
-               try { instream.close(); } catch (Exception ignore) {}
-           }
-
-           SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore, "changeit", trustStore);
-           Scheme sch = new Scheme("https", 443, socketFactory);
-           httpclient.getConnectionManager().getSchemeRegistry().register(sch);
-
-           JSONObject jo = buildFeedRequest();
-               for (int i = 0; i < 10000; i++) {
-                       jo.put("version", ""+System.currentTimeMillis());
-                       int rv = -1;
-                       String url   = "https://conwy.proto.research.att.com:6443/";
-                       HttpPost httpPost = new HttpPost(url);
-                       try {
-                               httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-                               String t = jo.toString();
-                               HttpEntity body = new ByteArrayEntity(t.getBytes(), ContentType.create(FeedServlet.FEED_CONTENT_TYPE));
-                               httpPost.setEntity(body);
-
-                               HttpResponse response = httpclient.execute(httpPost);
-                               rv = response.getStatusLine().getStatusCode();
-                               HttpEntity entity = response.getEntity();
-                               EntityUtils.consume(entity);
-                       } catch (IOException e) {
-                               System.err.println(e);
-                       } finally {
-                               httpPost.releaseConnection();
-                       }
-                       System.out.println(i + " " + rv);
-               }
-       }
-       private static JSONObject buildFeedRequest() {
-               JSONObject jo = new JSONObject();
-               jo.put("name", "feed");
-               jo.put("version", ""+System.currentTimeMillis());
-               jo.put("description", "Sample feed used by JUnit to test");
-
-                       JSONObject jo2 = new JSONObject();
-                       jo2.put("classification", "unrestricted");
-
-                       JSONArray ja = new JSONArray();
-                               JSONObject jo3 = new JSONObject();
-                               jo3.put("id", "id001");
-                               jo3.put("password", "re1kwelj");
-                               JSONObject jo4 = new JSONObject();
-                               jo4.put("id", "id002");
-                               jo4.put("password", "o9eqlmbd");
-                               ja.put(jo3);
-                               ja.put(jo4);
-                       jo2.put("endpoint_ids", ja);
-
-                       ja = new JSONArray();
-                               ja.put("10.0.0.1");
-                               ja.put("192.168.0.1");
-                               ja.put("135.207.136.128/25");
-                       jo2.put("endpoint_addrs", ja);
-
-               jo.put("authorization", jo2);
-               return jo;
-       }
+    /**
+     * This is the main method of the FillDB class.
+     *
+     * @throws KeyStoreException KeyStore exception
+     * @throws FileNotFoundException Exeception thrown when error locating file
+     * @throws KeyManagementException KeyManagement exception
+     * @throws UnrecoverableKeyException Exception thrown when Key cannot be recovered
+     * @throws NoSuchAlgorithmException Exception thrown when algorithm does not exist
+     */
+    public static void main(String[] args)
+        throws KeyStoreException, FileNotFoundException, KeyManagementException, UnrecoverableKeyException,
+            NoSuchAlgorithmException {
+        AbstractHttpClient httpclient = new DefaultHttpClient();
+
+        String keystore = "/home/eby/dr2/misc/client.keystore";
+        String kspass   = "changeit";
+        KeyStore trustStore  = KeyStore.getInstance(KeyStore.getDefaultType());
+        FileInputStream instream = new FileInputStream(new File(keystore));
+        try {
+            trustStore.load(instream, kspass.toCharArray());
+        } catch (Exception x) {
+            System.err.println("READING KEYSTORE: " + x);
+        } finally {
+            try {
+                instream.close();
+            } catch (Exception ignore) {
+                // Ignore exception
+            }
+        }
+
+        SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore, "changeit", trustStore);
+        Scheme sch = new Scheme("https", 443, socketFactory);
+        httpclient.getConnectionManager().getSchemeRegistry().register(sch);
+
+        JSONObject jo = buildFeedRequest();
+        for (int i = 0; i < 10000; i++) {
+            jo.put("version", "" + System.currentTimeMillis());
+            int rv = -1;
+            String url   = "https://conwy.proto.research.att.com:6443/";
+            HttpPost httpPost = new HttpPost(url);
+            try {
+                httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+                String feedRequestString = jo.toString();
+                HttpEntity body = new ByteArrayEntity(feedRequestString.getBytes(),
+                        ContentType.create(FeedServlet.FEED_CONTENT_TYPE));
+                httpPost.setEntity(body);
+
+                HttpResponse response = httpclient.execute(httpPost);
+                rv = response.getStatusLine().getStatusCode();
+                HttpEntity entity = response.getEntity();
+                EntityUtils.consume(entity);
+            } catch (IOException e) {
+                System.err.println(e);
+            } finally {
+                httpPost.releaseConnection();
+            }
+            System.out.println(i + " " + rv);
+        }
+    }
+
+    private static JSONObject buildFeedRequest() {
+        JSONObject jo = new JSONObject();
+        jo.put("name", "feed");
+        jo.put("version", "" + System.currentTimeMillis());
+        jo.put("description", "Sample feed used by JUnit to test");
+
+        JSONObject jo2 = new JSONObject();
+        jo2.put("classification", "unrestricted");
+
+
+        JSONObject jo3 = new JSONObject();
+        jo3.put("id", "id001");
+        jo3.put("password", "re1kwelj");
+
+        JSONObject jo4 = new JSONObject();
+        jo4.put("id", "id002");
+        jo4.put("password", "o9eqlmbd");
+
+        JSONArray ja = new JSONArray();
+        ja.put(jo3);
+        ja.put(jo4);
+        jo2.put("endpoint_ids", ja);
+
+        ja = new JSONArray();
+        ja.put("10.0.0.1");
+        ja.put("192.168.0.1");
+        ja.put("135.207.136.128/25");
+        jo2.put("endpoint_addrs", ja);
+
+        jo.put("authorization", jo2);
+        return jo;
+    }
 }
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestBase.java
new file mode 100644 (file)
index 0000000..52e80a8
--- /dev/null
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.KeyStore;
+import java.util.Properties;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.StatusLine;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.conn.scheme.Scheme;
+import org.apache.http.conn.ssl.SSLSocketFactory;
+import org.apache.http.impl.client.AbstractHttpClient;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.junit.After;
+import org.junit.Before;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+
+public class IntegrationTestBase {
+    /** The properties file to read the DB properties from. */
+    public static final String CONFIG_FILE = "integration_test.properties";
+
+    public Properties props;
+    protected AbstractHttpClient httpclient;
+    protected String s33;
+    protected String s257;
+    protected static JSONObject db_state;
+
+    /**
+     * This is the setUp method.
+     */
+    @Before
+    public void setUp() throws Exception {
+        if (props == null) {
+            props = new Properties();
+            InputStream inStream = getClass().getClassLoader().getResourceAsStream(CONFIG_FILE);
+            try {
+                props.load(inStream);
+            } catch (Exception e) {
+                e.printStackTrace();
+            } finally {
+                inStream.close();
+            }
+        }
+
+        httpclient = new DefaultHttpClient();
+        String str = "0123456789ABCDEF";
+        s33 = str + str + "!";
+        str = str + str + str + str;
+        s257 = str + str + str + str + "!";
+
+        // keystore
+        String store = props.getProperty("test.keystore");
+        String pass  = props.getProperty("test.kspassword");
+        KeyStore keyStore  = KeyStore.getInstance(KeyStore.getDefaultType());
+        FileInputStream instream = new FileInputStream(new File(store));
+        try {
+            keyStore.load(instream, pass.toCharArray());
+        } catch (Exception x) {
+            System.err.println("READING KEYSTORE: " + x);
+        } finally {
+            try {
+                instream.close();
+            } catch (Exception ignore) {
+                // Ignore exception
+            }
+        }
+
+        store = props.getProperty("test.truststore");
+        pass  = props.getProperty("test.tspassword");
+        KeyStore trustStore  = KeyStore.getInstance(KeyStore.getDefaultType());
+        instream = new FileInputStream(new File(store));
+        try {
+            trustStore.load(instream, pass.toCharArray());
+        } catch (Exception x) {
+            System.err.println("READING TRUSTSTORE: " + x);
+        } finally {
+            try {
+                instream.close();
+            } catch (Exception ignore) {
+                // Ignore exception
+            }
+        }
+
+        SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore, "changeit", trustStore);
+        Scheme sch = new Scheme("https", 443, socketFactory);
+        httpclient.getConnectionManager().getSchemeRegistry().register(sch);
+    }
+
+    /**
+     * This is the getDBstate method.
+     */
+    public JSONObject getDBstate() {
+        // set db_state!
+        if (db_state == null) {
+            String url   = props.getProperty("test.host") + "/internal/prov";
+            HttpGet httpGet = new HttpGet(url);
+            try {
+                httpGet.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+                HttpResponse response = httpclient.execute(httpGet);
+                HttpEntity entity = response.getEntity();
+                String ctype = entity.getContentType().getValue().trim();
+                // save the response body as db_state
+                boolean ok  = ctype.equals(FeedServlet.PROVFULL_CONTENT_TYPE1);
+                ok |= ctype.equals(FeedServlet.PROVFULL_CONTENT_TYPE2);
+                if (ok) {
+                    db_state = null;
+                    try {
+                        db_state = new JSONObject(new JSONTokener(entity.getContent()));
+                    } catch (Exception e) {
+                        fail("Bad JSON: " + e.getMessage());
+                    }
+                } else {
+                    EntityUtils.consume(entity);
+                }
+            } catch (IOException e) {
+                fail(e.getMessage());
+            } finally {
+                httpGet.releaseConnection();
+            }
+        }
+        return db_state;
+    }
+
+    /**
+     * This is the tearDown method.
+     */
+    @After
+    public void tearDown() throws Exception {
+        // When HttpClient instance is no longer needed,
+        // shut down the connection manager to ensure
+        // immediate deallocation of all system resources
+        httpclient.getConnectionManager().shutdown();
+        FileUtils.deleteDirectory(new File("./unit-test-logs"));
+    }
+
+    protected void ckResponse(HttpResponse response, int expect) {
+        System.out.println(response.getStatusLine());
+        StatusLine sl = response.getStatusLine();
+        int code = sl.getStatusCode();
+        if (code != expect) {
+            fail("Unexpected response, expect " + expect + " got " + code + " " + sl.getReasonPhrase());
+        }
+    }
+}
@@ -7,9 +7,9 @@
  * * Licensed under the Apache License, Version 2.0 (the "License");
  * * you may not use this file except in compliance with the License.
  * * You may obtain a copy of the License at
- * * 
+ * *
  *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
+ * *
  *  * Unless required by applicable law or agreed to in writing, software
  * * distributed under the License is distributed on an "AS IS" BASIS,
  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -37,48 +37,49 @@ import org.junit.Before;
 import org.junit.Test;
 import org.onap.dmaap.datarouter.provisioning.FeedServlet;
 
-public class testCleanup extends testBase {
-       @Before
-       public void setUp() throws Exception {
-               super.setUp();
-               getDBstate();
-       }
+public class IntegrationTestCleanup extends IntegrationTestBase {
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        getDBstate();
+    }
+
+    @Test
+    public void testNormal() {
+        // Delete all feeds w/JUnit as publisher
+        JSONArray ja = db_state.getJSONArray("feeds");
+        for (int i = 0; i < ja.length(); i++) {
+            JSONObject feed = ja.getJSONObject(i);
+            if (feed != null && !feed.getBoolean("deleted")) {
+                if (feed.getString("publisher").equals("JUnit")) {
+                    int feedid = feed.getInt("feedid");
+                    delete("/feed/" + feedid);
+                }
+            }
+        }
+        // Delete all subscriptions w/JUnit as subscriber
+        ja = db_state.getJSONArray("subscriptions");
+        for (int i = 0; i < ja.length(); i++) {
+            JSONObject sub = ja.getJSONObject(i);
+            if (sub != null && sub.getString("subscriber").equals("JUnit")) {
+                int subid = sub.getInt("subid");
+                delete("/subs/" + subid);
+            }
+        }
+    }
 
-       @Test
-       public void testNormal() {
-               // Delete all feeds w/JUnit as publisher
-               JSONArray ja = db_state.getJSONArray("feeds");
-               for (int i = 0; i < ja.length(); i++) {
-                       JSONObject feed = ja.getJSONObject(i);
-                       if (feed != null && !feed.getBoolean("deleted")) {
-                               if (feed.getString("publisher").equals("JUnit")) {
-                                       int feedid = feed.getInt("feedid");
-                                       delete("/feed/"+feedid);
-                               }
-                       }
-               }
-               // Delete all subscriptions w/JUnit as subscriber
-               ja = db_state.getJSONArray("subscriptions");
-               for (int i = 0; i < ja.length(); i++) {
-                       JSONObject sub = ja.getJSONObject(i);
-                       if (sub != null && sub.getString("subscriber").equals("JUnit")) {
-                               int subid = sub.getInt("subid");
-                               delete("/subs/"+subid);
-                       }
-               }
-       }
-       private void delete(String uri) {
-               String url = props.getProperty("test.host") + uri;;
-               HttpDelete del = new HttpDelete(url);
-               try {
-                       del.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-                       HttpResponse response = httpclient.execute(del);
-                       HttpEntity entity = response.getEntity();
-                       EntityUtils.consume(entity);
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       del.releaseConnection();
-               }
-       }
+    private void delete(String uri) {
+        String url = props.getProperty("test.host") + uri;;
+        HttpDelete del = new HttpDelete(url);
+        try {
+            del.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+            HttpResponse response = httpclient.execute(del);
+            HttpEntity entity = response.getEntity();
+            EntityUtils.consume(entity);
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            del.releaseConnection();
+        }
+    }
 }
@@ -7,9 +7,9 @@
  * * Licensed under the Apache License, Version 2.0 (the "License");
  * * you may not use this file except in compliance with the License.
  * * You may obtain a copy of the License at
- * * 
+ * *
  *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
+ * *
  *  * Unless required by applicable law or agreed to in writing, software
  * * distributed under the License is distributed on an "AS IS" BASIS,
  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,23 +36,23 @@ import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.onap.dmaap.datarouter.provisioning.FeedServlet;
 
-public class testDRFeedsDelete extends testBase {
-       @Test
-       public void testNotAllowed() {
-               String url = props.getProperty("test.host") + "/";
-               HttpDelete del = new HttpDelete(url);
-               try {
-                       del.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-
-                       HttpResponse response = httpclient.execute(del);
-                   ckResponse(response, HttpServletResponse.SC_METHOD_NOT_ALLOWED);
-
-                       HttpEntity entity = response.getEntity();
-                       EntityUtils.consume(entity);
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       del.releaseConnection();
-               }
-       }
+public class IntegrationTestDrFeedsDelete extends IntegrationTestBase {
+    @Test
+    public void testNotAllowed() {
+        String url = props.getProperty("test.host") + "/";
+        HttpDelete del = new HttpDelete(url);
+        try {
+            del.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+
+            HttpResponse response = httpclient.execute(del);
+            ckResponse(response, HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+
+            HttpEntity entity = response.getEntity();
+            EntityUtils.consume(entity);
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            del.releaseConnection();
+        }
+    }
 }
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestDrFeedsGet.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestDrFeedsGet.java
new file mode 100644 (file)
index 0000000..70be1f2
--- /dev/null
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+
+public class IntegrationTestDrFeedsGet extends IntegrationTestBase {
+    private JSONArray returnedlist;
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        getDBstate();
+    }
+
+    @Test
+    public void testNormal() {
+        testCommon(HttpServletResponse.SC_OK);
+        int expect = 0;
+        JSONArray ja = db_state.getJSONArray("feeds");
+        for (int i = 0; i < ja.length(); i++) {
+            JSONObject jo = ja.getJSONObject(i);
+            if (!jo.getBoolean("deleted")) {
+                expect++;
+            }
+        }
+        if (returnedlist.length() != expect) {
+            fail("bad length, got " + returnedlist.length() + " expect " + expect);
+        }
+    }
+
+    @Test
+    public void testNormalGoodName() {
+        JSONArray ja = db_state.getJSONArray("feeds");
+        JSONObject feed0 = ja.getJSONObject(0);
+        String name = feed0.getString("name");
+        String query = "?name=" + name;
+        int expect = 0;
+        for (int n = 0; n < ja.length(); n++) {
+            JSONObject jo = ja.getJSONObject(n);
+            if (!jo.getBoolean("deleted") && jo.getString("name").equals(name)) {
+                expect++;
+            }
+        }
+        testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
+        if (returnedlist.length() != expect) {
+            fail("bad length, got " + returnedlist.length() + " expect " + expect);
+        }
+    }
+
+    @Test
+    public void testNormalBadName() {
+        String query = "?name=ZZTOP123456";
+        testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
+        if (returnedlist.length() != 0) {
+            fail("bad length, got " + returnedlist.length() + " expect 0");
+        }
+    }
+
+    @Test
+    public void testNormalBadPath() {
+        String query = "flarg/?publisher=JUnit";
+        testCommon(HttpServletResponse.SC_NOT_FOUND, query, "text/html;charset=ISO-8859-1", "JUnit");
+    }
+
+    @Test
+    public void testNormalGoodPublisher() {
+        JSONArray ja = db_state.getJSONArray("feeds");
+        JSONObject feed0 = ja.getJSONObject(0);
+        String query = "?publisher=" + feed0.getString("publisher");
+        testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
+        int expect = 0;
+        for (int i = 0; i < ja.length(); i++) {
+            JSONObject jo = ja.getJSONObject(i);
+            if (jo.getString("publisher").equals(feed0.getString("publisher")) && !jo.getBoolean("deleted")) {
+                expect++;
+            }
+        }
+        if (returnedlist.length() != expect) {
+            fail("bad length, got " + returnedlist.length() + " expected " + expect);
+        }
+    }
+
+    @Test
+    public void testNormalBadPublisher() {
+        String query = "?publisher=ZZTOP123456";
+        testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
+        if (returnedlist.length() != 0) {
+            fail("bad length");
+        }
+    }
+
+    @Test
+    public void testNormalGoodSubscriber() {
+        JSONArray ja = db_state.getJSONArray("subscriptions");
+        if (ja.length() > 0) {
+            JSONObject sub0 = ja.getJSONObject(0);
+            String query = "?subscriber=" + sub0.getString("subscriber");
+            testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
+// aarg! - this is complicated!
+//        int expect = 0;
+//        for (int i = 0; i < ja.length(); i++) {
+//            JSONObject jo = ja.getJSONObject(i);
+//            if (jo.getString("subscriber").equals(sub0.getString("subscriber")))
+//                expect++;
+//        }
+//        if (returnedlist.length() != 1)
+//            fail("bad length " + returnedlist.toString());
+        } else {
+            // There are no subscriptions yet, so use a made up name
+            testCommon(HttpServletResponse.SC_OK, "?subscriber=foo", FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
+        }
+    }
+
+    @Test
+    public void testNormalBadSubscriber() {
+        String query = "?subscriber=ZZTOP123456";
+        testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
+        if (returnedlist.length() != 0) {
+            fail("bad length");
+        }
+    }
+
+    private void testCommon(int expect) {
+        testCommon(expect, "", FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
+    }
+
+    private void testCommon(int expect, String query, String ectype, String bhdr) {
+        String url = props.getProperty("test.host") + "/" + query;
+        HttpGet httpGet = new HttpGet(url);
+        try {
+            if (bhdr != null) {
+                httpGet.addHeader(FeedServlet.BEHALF_HEADER, bhdr);
+            }
+
+            HttpResponse response = httpclient.execute(httpGet);
+            ckResponse(response, expect);
+
+            HttpEntity entity = response.getEntity();
+            String ctype = entity.getContentType().getValue().trim();
+            if (!ctype.equals(ectype)) {
+                fail("Got wrong content type: " + ctype);
+            }
+
+            // do something useful with the response body and ensure it is fully consumed
+            if (ctype.equals(FeedServlet.FEEDLIST_CONTENT_TYPE)) {
+                try {
+                    returnedlist = new JSONArray(new JSONTokener(entity.getContent()));
+                } catch (Exception e) {
+                    fail("Bad JSON: " + e.getMessage());
+                }
+            } else {
+                EntityUtils.consume(entity);
+            }
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            httpGet.releaseConnection();
+        }
+    }
+}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestDrFeedsPost.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestDrFeedsPost.java
new file mode 100644 (file)
index 0000000..ca328b1
--- /dev/null
@@ -0,0 +1,308 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+
+public class IntegrationTestDrFeedsPost extends IntegrationTestBase {
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    @Test
+    public void testNormal() {
+        JSONObject jo = buildFeedRequest();
+        testCommon(jo, HttpServletResponse.SC_CREATED);
+    }
+
+    @Test
+    public void testNormalNoCtVersion() {
+        JSONObject jo = buildFeedRequest();
+        testCommon(jo, HttpServletResponse.SC_CREATED, "application/vnd.att-dr.feed", "JUnit");
+    }
+
+    @Test
+    public void testBadContentType() {
+        JSONObject jo = buildFeedRequest();
+        testCommon(jo, HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "bad/bad", "Junit");
+    }
+
+    @Test
+    public void testNoBehalfHeader() {
+        JSONObject jo = buildFeedRequest();
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, FeedServlet.FEED_CONTENT_TYPE, null);
+    }
+
+    @Test
+    public void testMissingName() {
+        JSONObject jo = buildFeedRequest();
+        jo.remove("name");
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testTooLongName() {
+        JSONObject jo = buildFeedRequest();
+        jo.put("name", "123456789012345678901234567890");
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testMissingVersion() {
+        JSONObject jo = buildFeedRequest();
+        jo.remove("version");
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testTooLongVersion() {
+        JSONObject jo = buildFeedRequest();
+        jo.put("version", "123456789012345678901234567890");
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testTooLongDescription() {
+        // normal request
+        JSONObject jo = buildFeedRequest();
+        jo.put("description", s257);
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testMissingAuthorization() {
+        JSONObject jo = buildFeedRequest();
+        jo.remove("authorization");
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testMissingClassification() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        j2.remove("classification");
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testTooLongClassification() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        j2.put("classification", s33);
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testNoEndpointIds() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        j2.put("endpoint_ids", new JSONArray());
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testBadIpAddress1() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        JSONArray ja = j2.getJSONArray("endpoint_addrs");
+        ja.put("ZZZ^&#$%@#&^%$@#&^");
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testBadIpAddress2() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        JSONArray ja = j2.getJSONArray("endpoint_addrs");
+        ja.put("135.207.136.678");  // bad IPv4 addr
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testBadIpAddress3() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        JSONArray ja = j2.getJSONArray("endpoint_addrs");
+        ja.put("2001:1890:1110:d000:1a29::17567");  // bad IPv6 addr
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testBadNetMask() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        JSONArray ja = j2.getJSONArray("endpoint_addrs");
+        ja.put("10.10.10.10/64");
+        testCommon(jo, 400);
+    }
+
+    @Test
+    public void testGoodIpAddress1() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        JSONArray ja = j2.getJSONArray("endpoint_addrs");
+        ja.put("135.207.136.175"); // good IPv4 addr
+        testCommon(jo, 201);
+    }
+
+    @Test
+    public void testGoodIpAddress2() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        JSONArray ja = j2.getJSONArray("endpoint_addrs");
+        ja.put("2001:1890:1110:d000:1a29::175"); // good IPv6 addr
+        testCommon(jo, 201);
+    }
+
+    @Test
+    public void testGoodNetMask() {
+        JSONObject jo = buildFeedRequest();
+        JSONObject j2 = jo.getJSONObject("authorization");
+        JSONArray ja = j2.getJSONArray("endpoint_addrs");
+        ja.put("2001:1890:1110:d000:1a29::175/120");
+        testCommon(jo, 201);
+    }
+
+    private void testCommon(JSONObject jo, int expect) {
+        testCommon(jo, expect, FeedServlet.FEED_CONTENT_TYPE, "JUnit");
+    }
+
+    private void testCommon(JSONObject jo, int expect, String ctype, String bhdr) {
+        String url   = props.getProperty("test.host") + "/";
+        HttpPost httpPost = new HttpPost(url);
+        try {
+            if (bhdr != null) {
+                httpPost.addHeader(FeedServlet.BEHALF_HEADER, bhdr);
+            }
+            String strJo = jo.toString();
+            HttpEntity body = new ByteArrayEntity(strJo.getBytes(), ContentType.create(ctype));
+            httpPost.setEntity(body);
+
+            HttpResponse response = httpclient.execute(httpPost);
+            ckResponse(response, expect);
+
+            HttpEntity entity = response.getEntity();
+            ctype = entity.getContentType().getValue().trim();
+            int code = response.getStatusLine().getStatusCode();
+            if (code == HttpServletResponse.SC_CREATED && !ctype.equals(FeedServlet.FEEDFULL_CONTENT_TYPE)) {
+                fail("Got wrong content type: " + ctype);
+            }
+
+            if (code == HttpServletResponse.SC_CREATED) {
+                Header[] loc = response.getHeaders("Location");
+                if (loc == null) {
+                    fail("Missing Location header.");
+                }
+            }
+
+            // do something useful with the response body and ensure it is fully consumed
+            if (ctype.equals(FeedServlet.FEEDFULL_CONTENT_TYPE)) {
+                // ck Location header!
+                JSONObject jo2 = null;
+                try {
+                    jo2 = new JSONObject(new JSONTokener(entity.getContent()));
+                    System.err.println(jo2.toString());
+                } catch (Exception e) {
+                    fail("Bad JSON: " + e.getMessage());
+                }
+                try {
+                    jo2.getString("publisher");
+                    JSONObject jo3 = jo2.getJSONObject("links");
+                    jo3.getString("self");
+                    jo3.getString("publish");
+                    jo3.getString("subscribe");
+                    jo3.getString("log");
+                } catch (JSONException e) {
+                    fail("required field missing from result: " + e.getMessage());
+                }
+            } else {
+                EntityUtils.consume(entity);
+            }
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            httpPost.releaseConnection();
+        }
+    }
+
+    private JSONObject buildFeedRequest() {
+        JSONObject jo = new JSONObject();
+        jo.put("name", "JunitFeed");
+        jo.put("version", "" + System.currentTimeMillis());  // make version unique
+        jo.put("description", "Sample feed used by JUnit to test");
+
+        JSONObject jo2 = new JSONObject();
+        jo2.put("classification", "unrestricted");
+
+        JSONObject jo3 = new JSONObject();
+        jo3.put("id", "id001");
+        jo3.put("password", "re1kwelj");
+        JSONObject jo4 = new JSONObject();
+        jo4.put("id", "id002");
+        jo4.put("password", "o9eqlmbd");
+
+        JSONArray ja = new JSONArray();
+        ja.put(jo3);
+        ja.put(jo4);
+        jo2.put("endpoint_ids", ja);
+
+        ja = new JSONArray();
+        ja.put("10.0.0.1");
+        ja.put("192.168.0.1");
+        ja.put("135.207.136.128/25");
+        jo2.put("endpoint_addrs", ja);
+
+        jo.put("authorization", jo2);
+        return jo;
+    }
+}
+/*
+curl -v -X POST -H 'X-ATT-DR-ON-BEHALF-OF: tester' -H 'Content-type: application/vnd.att-dr.feed' \
+    --user publisher:tomcat \
+    --data "$data" http://127.0.0.1:8080/prov/feed/
+*/
@@ -7,9 +7,9 @@
  * * Licensed under the Apache License, Version 2.0 (the "License");
  * * you may not use this file except in compliance with the License.
  * * You may obtain a copy of the License at
- * * 
+ * *
  *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
+ * *
  *  * Unless required by applicable law or agreed to in writing, software
  * * distributed under the License is distributed on an "AS IS" BASIS,
  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -36,23 +36,23 @@ import org.apache.http.util.EntityUtils;
 import org.junit.Test;
 import org.onap.dmaap.datarouter.provisioning.FeedServlet;
 
-public class testDRFeedsPut extends testBase {
-       @Test
-       public void testNotAllowed() {
-               String url = props.getProperty("test.host") + "/";
-               HttpPut put = new HttpPut(url);
-               try {
-                       put.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-
-                       HttpResponse response = httpclient.execute(put);
-                   ckResponse(response, HttpServletResponse.SC_METHOD_NOT_ALLOWED);
-
-                       HttpEntity entity = response.getEntity();
-                       EntityUtils.consume(entity);
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       put.releaseConnection();
-               }
-       }
+public class IntegrationTestDrFeedsPut extends IntegrationTestBase {
+    @Test
+    public void testNotAllowed() {
+        String url = props.getProperty("test.host") + "/";
+        HttpPut put = new HttpPut(url);
+        try {
+            put.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+
+            HttpResponse response = httpclient.execute(put);
+            ckResponse(response, HttpServletResponse.SC_METHOD_NOT_ALLOWED);
+
+            HttpEntity entity = response.getEntity();
+            EntityUtils.consume(entity);
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            put.releaseConnection();
+        }
+    }
 }
@@ -7,9 +7,9 @@
  * * Licensed under the Apache License, Version 2.0 (the "License");
  * * you may not use this file except in compliance with the License.
  * * You may obtain a copy of the License at
- * * 
+ * *
  *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
+ * *
  *  * Unless required by applicable law or agreed to in writing, software
  * * distributed under the License is distributed on an "AS IS" BASIS,
  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -41,57 +41,60 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.onap.dmaap.datarouter.provisioning.FeedServlet;
 
-public class testFeedDelete extends testBase {
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-       }
+public class IntegrationTestFeedDelete extends IntegrationTestBase {
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        getDBstate();
+    }
+
+    @Test
+    public void testDeleteNormal() {
+        // Delete the first non-deleted feed in the DB
+        JSONArray ja = db_state.getJSONArray("feeds");
+        for (int i = ja.length() - 1; i >= 0; i--) {
+            JSONObject feed = ja.getJSONObject(i);
+            if (!feed.getBoolean("deleted")) {
+                int feedid = feed.getInt("feedid");
+                testCommon(HttpServletResponse.SC_NO_CONTENT, "/feed/" + feedid);
+                return;
+            }
+        }
+    }
 
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-       }
+    @Test
+    public void testDeleteNoFeedId() {
+        testCommon(HttpServletResponse.SC_BAD_REQUEST, "/feed/");
+    }
 
-       @Before
-       public void setUp() throws Exception {
-               super.setUp();
-               getDBstate();
-       }
+    @Test
+    public void testDeleteNoFeed() {
+        testCommon(HttpServletResponse.SC_NOT_FOUND, "/feed/999999");
+    }
 
-       @Test
-       public void testDeleteNormal() {
-               // Delete the first non-deleted feed in the DB
-               JSONArray ja = db_state.getJSONArray("feeds");
-               for (int i = ja.length()-1; i >= 0; i--) {
-                       JSONObject feed = ja.getJSONObject(i);
-                       if (!feed.getBoolean("deleted")) {
-                               int feedid = feed.getInt("feedid");
-                               testCommon(HttpServletResponse.SC_NO_CONTENT, "/feed/"+feedid);
-                               return;
-                       }
-               }
-       }
-       @Test
-       public void testDeleteNoFeedID() {
-               testCommon(HttpServletResponse.SC_BAD_REQUEST, "/feed/");
-       }
-       @Test
-       public void testDeleteNoFeed() {
-               testCommon(HttpServletResponse.SC_NOT_FOUND, "/feed/999999");
-       }
-       private void testCommon(int expect, String uri) {
-               String url = props.getProperty("test.host") + uri;
-               HttpDelete del = new HttpDelete(url);
-               try {
-                       del.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+    private void testCommon(int expect, String uri) {
+        String url = props.getProperty("test.host") + uri;
+        HttpDelete del = new HttpDelete(url);
+        try {
+            del.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
 
-                       HttpResponse response = httpclient.execute(del);
-                   ckResponse(response, expect);
+            HttpResponse response = httpclient.execute(del);
+            ckResponse(response, expect);
 
-                       HttpEntity entity = response.getEntity();
-                       EntityUtils.consume(entity);
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       del.releaseConnection();
-               }
-       }
+            HttpEntity entity = response.getEntity();
+            EntityUtils.consume(entity);
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            del.releaseConnection();
+        }
+    }
 }
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestFeedPut.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestFeedPut.java
new file mode 100644 (file)
index 0000000..7a02931
--- /dev/null
@@ -0,0 +1,214 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+
+public class IntegrationTestFeedPut extends IntegrationTestBase {
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        getDBstate();
+    }
+
+    @Test
+    public void testPutNoFeedId() {
+        JSONObject jo = buildFeedRequest();
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, "/feed/");
+    }
+
+    @Test
+    public void testPutNoFeed() {
+        JSONObject jo = buildFeedRequest();
+        testCommon(jo, HttpServletResponse.SC_NOT_FOUND, "/feed/999999");
+    }
+
+    @Test
+    public void testBadContentType() {
+        JSONObject jo = buildFeedRequest();
+        testCommon(jo, HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "bad/bad", "JUnit");
+    }
+
+    @Test
+    public void testChangeName() {
+        JSONObject jo = buildFeedRequest();
+        jo.put("name", "badname");
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, FeedServlet.FEED_CONTENT_TYPE, "JUnit");
+    }
+
+    @Test
+    public void testChangeVersion() {
+        JSONObject jo = buildFeedRequest();
+        jo.put("version", "badvers");
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, FeedServlet.FEED_CONTENT_TYPE, "JUnit");
+    }
+
+    @Test
+    public void testBadPublisher() {
+        JSONObject jo = buildFeedRequest();
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, FeedServlet.FEED_CONTENT_TYPE, "BadBadBad");
+    }
+
+    @Test
+    public void testChangeDescription() {
+        JSONObject jo = buildFeedRequest();
+        // change descr
+        jo.put("description", "This description HAS BEEN CHANGED!!!");
+        testCommon(jo, HttpServletResponse.SC_OK, FeedServlet.FEED_CONTENT_TYPE, "JUnit");
+    }
+
+    private void testCommon(JSONObject jo, int expect, String uri) {
+        testCommon(jo, expect, FeedServlet.FEED_CONTENT_TYPE, "Junit", uri);
+    }
+
+    private void testCommon(JSONObject jo, int expect, String ctype, String bhdr) {
+        JSONArray ja = db_state.getJSONArray("feeds");
+        for (int i = 0; i < ja.length(); i++) {
+            JSONObject feed0 = ja.getJSONObject(i);
+            if (!feed0.getBoolean("deleted") && feed0.getString("publisher").equals(bhdr)) {
+                int feedid = feed0.getInt("feedid");
+                testCommon(jo, expect, ctype, bhdr, "/feed/" + feedid);
+                return;
+            }
+        }
+    }
+
+    private void testCommon(JSONObject jo, int expect, String ctype, String bhdr, String uri) {
+        String url   = props.getProperty("test.host") + uri;
+        HttpPut put = new HttpPut(url);
+        try {
+            if (bhdr != null) {
+                put.addHeader(FeedServlet.BEHALF_HEADER, bhdr);
+            }
+            String strJo = jo.toString();
+            HttpEntity body = new ByteArrayEntity(strJo.getBytes(), ContentType.create(ctype));
+            put.setEntity(body);
+
+            HttpResponse response = httpclient.execute(put);
+            ckResponse(response, expect);
+
+            HttpEntity entity = response.getEntity();
+            ctype = entity.getContentType().getValue().trim();
+            int code = response.getStatusLine().getStatusCode();
+            if (code == HttpServletResponse.SC_CREATED && !ctype.equals(FeedServlet.FEEDFULL_CONTENT_TYPE)) {
+                fail("Got wrong content type: " + ctype);
+            }
+
+            if (code == HttpServletResponse.SC_CREATED) {
+                Header[] loc = response.getHeaders("Location");
+                if (loc == null) {
+                    fail("Missing Location header.");
+                }
+            }
+
+            // do something useful with the response body and ensure it is fully consumed
+            if (ctype.equals(FeedServlet.FEEDFULL_CONTENT_TYPE)) {
+                // ck Location header!
+                JSONObject jo2 = null;
+                try {
+                    jo2 = new JSONObject(new JSONTokener(entity.getContent()));
+                    System.err.println(jo2.toString());
+                } catch (Exception e) {
+                    fail("Bad JSON: " + e.getMessage());
+                }
+                try {
+                    jo2.getString("publisher");
+                    JSONObject jo3 = jo2.getJSONObject("links");
+                    jo3.getString("self");
+                    jo3.getString("publish");
+                    jo3.getString("subscribe");
+                    jo3.getString("log");
+                } catch (JSONException e) {
+                    fail("required field missing from result: " + e.getMessage());
+                }
+            } else {
+                EntityUtils.consume(entity);
+            }
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            put.releaseConnection();
+        }
+    }
+
+    private JSONObject buildFeedRequest() {
+        JSONObject jo = new JSONObject();
+        jo.put("name", "feed");
+        jo.put("version", "1.0.0");
+        jo.put("description", "Sample feed used by JUnit to test");
+
+        JSONObject jo2 = new JSONObject();
+        jo2.put("classification", "unrestricted");
+
+        JSONObject jo3 = new JSONObject();
+        jo3.put("id", "id001");
+        jo3.put("password", "re1kwelj");
+        JSONObject jo4 = new JSONObject();
+        jo4.put("id", "id002");
+        jo4.put("password", "o9eqlmbd");
+
+        JSONArray ja = new JSONArray();
+        ja.put(jo3);
+        ja.put(jo4);
+        jo2.put("endpoint_ids", ja);
+
+        ja = new JSONArray();
+        ja.put("20.0.0.1");
+        ja.put("195.68.12.15");
+        ja.put("135.207.136.128/25");
+        jo2.put("endpoint_addrs", ja);
+
+        jo.put("authorization", jo2);
+        return jo;
+    }
+}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalGet.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalGet.java
new file mode 100644 (file)
index 0000000..25397f7
--- /dev/null
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
+
+public class IntegrationTestInternalGet extends IntegrationTestBase {
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    @Test
+    public void testNormal() {
+        String url   = props.getProperty("test.host") + "/internal/prov";
+        HttpGet httpPost = new HttpGet(url);
+        try {
+            httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+
+            HttpResponse response = httpclient.execute(httpPost);
+            int code = response.getStatusLine().getStatusCode();
+            if (code != 200) {
+                fail("Unexpected response, expect " + 200 + " got " + code);
+            }
+
+            HttpEntity entity = response.getEntity();
+            String ctype = entity.getContentType().getValue().trim();
+            boolean ok  = ctype.equals(FeedServlet.PROVFULL_CONTENT_TYPE1);
+            ok |= ctype.equals(FeedServlet.PROVFULL_CONTENT_TYPE2);
+            if (!ok) {
+                fail("Got wrong content type: " + ctype);
+            }
+
+            // do something useful with the response body and ensure it is fully consumed
+            if (ok) {
+                JSONObject jo = null;
+                try {
+                    jo = new JSONObject(new JSONTokener(entity.getContent()));
+                } catch (Exception e) {
+                    fail("Bad JSON: " + e.getMessage());
+                }
+                try {
+                    jo.getJSONArray("feeds");
+                    jo.getJSONArray("subscriptions");
+                    JSONObject jo2 = jo.getJSONObject("parameters");
+                    jo2.getJSONArray(Parameters.NODES);
+                    jo2.getString(Parameters.ACTIVE_POD);
+                    jo2.getString(Parameters.STANDBY_POD);
+                    jo2.getInt(Parameters.LOGROLL_INTERVAL);
+                    jo2.getInt(Parameters.DELIVERY_INIT_RETRY_INTERVAL);
+                    jo2.getInt(Parameters.DELIVERY_MAX_RETRY_INTERVAL);
+                    jo2.getInt(Parameters.DELIVERY_RETRY_RATIO);
+                    jo2.getInt(Parameters.DELIVERY_MAX_AGE);
+                } catch (JSONException e) {
+                    fail("required field missing from result: " + e.getMessage());
+                }
+            } else {
+                EntityUtils.consume(entity);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            httpPost.releaseConnection();
+        }
+    }
+}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalMisc.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalMisc.java
new file mode 100644 (file)
index 0000000..fd00ea5
--- /dev/null
@@ -0,0 +1,155 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONArray;
+import org.json.JSONTokener;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+
+public class IntegrationTestInternalMisc extends IntegrationTestBase {
+    @Test
+    public void testInternalDrlogs() {
+        String url   = props.getProperty("test.host") + "/internal/drlogs";
+        HttpGet httpPost = new HttpGet(url);
+        try {
+            httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+            HttpResponse response = httpclient.execute(httpPost);
+            int code = response.getStatusLine().getStatusCode();
+            if (code != 200) {
+                fail("Unexpected response, expect " + HttpServletResponse.SC_NOT_FOUND + " got " + code);
+            }
+
+            HttpEntity entity = response.getEntity();
+            String ctype = entity.getContentType().getValue().trim();
+            boolean ok  = ctype.equals("text/plain");
+            if (!ok) {
+                fail("Got wrong content type: " + ctype);
+            }
+
+            EntityUtils.consume(entity);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            httpPost.releaseConnection();
+        }
+    }
+
+    @Test
+    public void testInternalHalt() {
+        String url   = props.getProperty("test.host") + "/internal/halt";
+        HttpGet httpPost = new HttpGet(url);
+        try {
+            httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+
+            HttpResponse response = httpclient.execute(httpPost);
+            int code = response.getStatusLine().getStatusCode();
+            if (code != HttpServletResponse.SC_NOT_FOUND) {
+                fail("Unexpected response, expect " + HttpServletResponse.SC_NOT_FOUND + " got " + code);
+            }
+
+            HttpEntity entity = response.getEntity();
+            EntityUtils.consume(entity);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            httpPost.releaseConnection();
+        }
+    }
+
+    @SuppressWarnings("unused")
+    @Test
+    public void testInternalLogs() {
+        String url   = props.getProperty("test.host") + "/internal/logs";
+        HttpGet httpPost = new HttpGet(url);
+        try {
+            httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+
+            HttpResponse response = httpclient.execute(httpPost);
+            int code = response.getStatusLine().getStatusCode();
+            if (code != 200) {
+                fail("Unexpected response, expect " + 200 + " got " + code);
+            }
+
+            HttpEntity entity = response.getEntity();
+            String ctype = entity.getContentType().getValue().trim();
+            boolean ok  = ctype.equals("application/json");
+            if (!ok) {
+                fail("Got wrong content type: " + ctype);
+            }
+
+            // do something useful with the response body and ensure it is fully consumed
+            if (ok) {
+                try {
+                    new JSONArray(new JSONTokener(entity.getContent()));
+                } catch (Exception e) {
+                    fail("Bad JSON: " + e.getMessage());
+                }
+            } else {
+                EntityUtils.consume(entity);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            httpPost.releaseConnection();
+        }
+    }
+
+    @Test
+    public void testInternalBadUrl() {
+        String url   = props.getProperty("test.host") + "/internal/badurl";
+        HttpGet httpPost = new HttpGet(url);
+        try {
+            httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+
+            HttpResponse response = httpclient.execute(httpPost);
+            int code = response.getStatusLine().getStatusCode();
+            if (code != HttpServletResponse.SC_NOT_FOUND) {
+                fail("Unexpected response, expect " + HttpServletResponse.SC_NOT_FOUND + " got " + code);
+            }
+
+            HttpEntity entity = response.getEntity();
+            EntityUtils.consume(entity);
+        } catch (IOException e) {
+            e.printStackTrace();
+            fail(e.getMessage());
+        } finally {
+            httpPost.releaseConnection();
+        }
+    }
+
+}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestLogGet.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestLogGet.java
new file mode 100644 (file)
index 0000000..ba28da1
--- /dev/null
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONArray;
+import org.json.JSONTokener;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+
+public class IntegrationTestLogGet extends IntegrationTestBase {
+    private JSONArray returnedlist;
+    private int feedid = 4;
+    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+        // need to seed the DB here
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+        // need to "unseed" the DB
+    }
+
+    /**
+     * This is the setUp method.
+     */
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        getDBstate();
+//        JSONArray ja = db_state.getJSONArray("feeds");
+//        for (int i = 0; i < ja.length(); i++) {
+//            JSONObject jo = ja.getJSONObject(i);
+//            if (!jo.getBoolean("deleted"))
+//                feedid = jo.getInt("feedid");
+//        }
+    }
+
+    @Test
+    public void testNormal() {
+        testCommon(HttpServletResponse.SC_OK);
+    }
+
+    @Test
+    public void testNormalPubOnly() {
+        testCommon(HttpServletResponse.SC_OK, "?type=pub");
+    }
+
+    @Test
+    public void testNormalDelOnly() {
+        testCommon(HttpServletResponse.SC_OK, "?type=del");
+    }
+
+    @Test
+    public void testNormalExpOnly() {
+        testCommon(HttpServletResponse.SC_OK, "?type=exp");
+    }
+
+    @Test
+    public void testNormalXxxOnly() {
+        testCommon(HttpServletResponse.SC_BAD_REQUEST, "?type=xxx");
+    }
+
+    @Test
+    public void testNormalStatusSuccess() {
+        testCommon(HttpServletResponse.SC_OK, "?statusCode=success");
+    }
+
+    @Test
+    public void testNormalStatusRedirect() {
+        testCommon(HttpServletResponse.SC_OK, "?statusCode=redirect");
+    }
+
+    @Test
+    public void testNormalStatusFailure() {
+        testCommon(HttpServletResponse.SC_OK, "?statusCode=failure");
+    }
+
+    @Test
+    public void testNormalStatus200() {
+        testCommon(HttpServletResponse.SC_OK, "?statusCode=200");
+    }
+
+    @Test
+    public void testNormalStatusXxx() {
+        testCommon(HttpServletResponse.SC_BAD_REQUEST, "?statusCode=xxx");
+    }
+
+    @Test
+    public void testNormalExpiryNotRetryable() {
+        testCommon(HttpServletResponse.SC_OK, "?expiryReason=notRetryable");
+    }
+
+    @Test
+    public void testNormalExpiryRetriesExhausted() {
+        testCommon(HttpServletResponse.SC_OK, "?expiryReason=retriesExhausted");
+    }
+
+    @Test
+    public void testNormalExpiryXxx() {
+        testCommon(HttpServletResponse.SC_BAD_REQUEST, "?expiryReason=xxx");
+    }
+
+    @Test
+    public void testNormalPublishId() {
+        testCommon(HttpServletResponse.SC_OK, "?publishId=1366985877801.mtdvnj00-drtr.proto.research.att.com");
+    }
+
+    @Test
+    public void testNormalStart() {
+        long nowMinus5Days = System.currentTimeMillis() - (5 * 24 * 60 * 60 * 1000L);    // 5 days
+        testCommon(HttpServletResponse.SC_OK, String.format("?start=%s", sdf.format(nowMinus5Days)));
+    }
+
+    @Test
+    public void testBadStart() {
+        testCommon(HttpServletResponse.SC_BAD_REQUEST, "?start=xxx");
+    }
+
+    @Test
+    public void testLongEnd() {
+        testCommon(HttpServletResponse.SC_OK, "?end=1364837896220");
+    }
+
+    @Test
+    public void testBadEnd() {
+        testCommon(HttpServletResponse.SC_BAD_REQUEST, "?end=2013-04-25T11:01:25Q");
+    }
+
+    private void testCommon(int expect) {
+        testCommon(expect, "");
+    }
+
+    private void testCommon(int expect, String query) {
+        String url = props.getProperty("test.host") + "/feedlog/" + feedid + query;
+        HttpGet httpGet = new HttpGet(url);
+        try {
+            HttpResponse response = httpclient.execute(httpGet);
+            ckResponse(response, expect);
+
+            HttpEntity entity = response.getEntity();
+            String ctype = entity.getContentType().getValue().trim();
+            if (expect == HttpServletResponse.SC_OK) {
+                if (!ctype.equals(FeedServlet.LOGLIST_CONTENT_TYPE)) {
+                    fail("Got wrong content type: " + ctype);
+                }
+            }
+
+            // do something useful with the response body and ensure it is fully consumed
+            if (ctype.equals(FeedServlet.LOGLIST_CONTENT_TYPE)) {
+                try {
+                    returnedlist = new JSONArray(new JSONTokener(entity.getContent()));
+                    int returnedListLength = returnedlist.length();
+                    if (returnedListLength != 0) {
+                        System.err.println(returnedListLength + " items");
+                    }
+                } catch (Exception e) {
+                    fail("Bad JSON: " + e.getMessage());
+                }
+            } else {
+                EntityUtils.consume(entity);
+            }
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            httpGet.releaseConnection();
+        }
+    }
+}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestPublish.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestPublish.java
new file mode 100644 (file)
index 0000000..833380a
--- /dev/null
@@ -0,0 +1,126 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.Header;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.RedirectStrategy;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.impl.client.DefaultRedirectStrategy;
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+
+public class IntegrationTestPublish extends IntegrationTestBase {
+    private String publishUrl;
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    /**
+     * This is the setUp method.
+     */
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        getDBstate();
+        // Get publish URL from first feed
+        JSONArray ja = db_state.getJSONArray("feeds");
+        for (int i = ja.length() - 1; i >= 0; i--) {
+            JSONObject feed = ja.getJSONObject(i);
+            if (!feed.getBoolean("deleted")) {
+                publishUrl = feed.getJSONObject("links").getString("publish");
+                publishUrl += "/" + System.currentTimeMillis();
+                return;
+            }
+        }
+    }
+
+    @Test
+    public void testDelete() {
+        HttpDelete httpDelete = new HttpDelete(publishUrl);
+        testCommon(httpDelete);
+    }
+
+    @Test
+    public void testGet() {
+        HttpGet httpGet = new HttpGet(publishUrl);
+        testCommon(httpGet);
+    }
+
+    @Test
+    public void testPut() {
+        HttpPut httpPut = new HttpPut(publishUrl);
+        testCommon(httpPut);
+    }
+
+    @Test
+    public void testPost() {
+        HttpPost httpPost = new HttpPost(publishUrl);
+        testCommon(httpPost);
+    }
+
+    private void testCommon(HttpRequestBase rb) {
+        try {
+            rb.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
+            RedirectStrategy strategy = new DefaultRedirectStrategy() {
+                protected boolean isRedirectable(String method) {
+                    return false;
+                }
+            };
+            httpclient.setRedirectStrategy(strategy);
+            HttpResponse response = httpclient.execute(rb);
+            ckResponse(response, HttpServletResponse.SC_MOVED_PERMANENTLY);
+
+            // Make sure there is a Location hdr
+            Header[] loc = response.getHeaders("Location");
+            if (loc == null || loc.length == 0) {
+                fail("No location header");
+            }
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            rb.releaseConnection();
+        }
+    }
+}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestRleBitSet.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestRleBitSet.java
new file mode 100644 (file)
index 0000000..133e7dc
--- /dev/null
@@ -0,0 +1,289 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.util.Iterator;
+
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
+
+public class IntegrationTestRleBitSet {
+    @Test
+    public void testBasicConstructor() {
+        RLEBitSet bs = new RLEBitSet();
+        if (!bs.isEmpty()) {
+            fail("bit set not empty");
+        }
+    }
+
+    @Test
+    public void testStringConstructor() {
+        RLEBitSet bs = new RLEBitSet("1-10");
+        if (bs.isEmpty()) {
+            fail("bit set is empty");
+        }
+        if (!bs.toString().equals("1-10")) {
+            fail("bad value");
+        }
+        bs = new RLEBitSet("69,70,71");
+        if (bs.isEmpty()) {
+            fail("bit set is empty");
+        }
+        if (!bs.toString().equals("69-71")) {
+            fail("bad value");
+        }
+        bs = new RLEBitSet("555 444    443  442");
+        if (!bs.toString().equals("442-444,555")) {
+            fail("bad value");
+        }
+    }
+
+    @Test
+    public void testLength() {
+        RLEBitSet bs = new RLEBitSet();
+        if (bs.length() != 0) {
+            fail("testLength fail " + bs + " " + bs.length());
+        }
+        bs = new RLEBitSet("1-10");
+        if (bs.length() != 11) {
+            fail("testLength fail " + bs + " " + bs.length());
+        }
+        bs = new RLEBitSet("1-20,100000000-100000005");
+        if (bs.length() != 100000006) {
+            fail("testLength fail " + bs + " " + bs.length());
+        }
+    }
+
+    @Test
+    public void testGet() {
+        RLEBitSet bs = new RLEBitSet("1-10");
+        if (!bs.get(5)) {
+            fail("get");
+        }
+        if (bs.get(69)) {
+            fail("get");
+        }
+    }
+
+    @Test
+    public void testSetOneBit() {
+        RLEBitSet bs = new RLEBitSet();
+        for (int i = 12; i < 200; i++) {
+            bs.set(i);
+        }
+        bs.set(690);
+        for (int i = 305; i < 309; i++) {
+            bs.set(i);
+        }
+        bs.set(304);
+        if (!bs.toString().equals("12-199,304-308,690")) {
+            fail("testSetOneBit fail " + bs);
+        }
+    }
+
+    @Test
+    public void testSetString() {
+        RLEBitSet bs = new RLEBitSet();
+        bs.set("1-100");
+        if (!bs.toString().equals("1-100")) {
+            fail("testSetString fail " + bs);
+        }
+    }
+
+    @Test
+    public void testSetRange() {
+        RLEBitSet bs = new RLEBitSet();
+        bs.set(50,60);
+        if (!bs.toString().equals("50-59")) {
+            fail("testSetRange fail " + bs);
+        }
+    }
+
+    @Test
+    public void testClearOneBit() {
+        RLEBitSet bs = new RLEBitSet("1-10");
+        bs.clear(5);
+        if (!bs.toString().equals("1-4,6-10")) {
+            fail("testClearOneBit fail");
+        }
+        bs = new RLEBitSet("1-10");
+        bs.clear(11);
+        if (!bs.toString().equals("1-10")) {
+            fail("testClearOneBit fail " + bs);
+        }
+    }
+
+    @Test
+    public void testClearRangeLeft() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        bs.clear(40,50);
+        if (!bs.toString().equals("100-200")) {
+            fail("testClearRangeLeft fail " + bs);
+        }
+    }
+
+    @Test
+    public void testClearRangeRight() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        bs.clear(400,500);
+        if (!bs.toString().equals("100-200")) {
+            fail("testClearRangeRight fail " + bs);
+        }
+    }
+
+    @Test
+    public void testClearRangeMiddle() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        bs.clear(120,130);
+        if (!bs.toString().equals("100-119,130-200")) {
+            fail("testClearRangeRight fail " + bs);
+        }
+    }
+
+    @Test
+    public void testClearRangeIntersect() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        bs.clear(100,200);
+        if (!bs.toString().equals("200")) {
+            fail("testClearRangeIntersect fail " + bs);
+        }
+    }
+
+    @Test
+    public void testClearOverlapLeft() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        bs.clear(50,150);
+        if (!bs.toString().equals("150-200")) {
+            fail("testClearOverlapLeft fail " + bs);
+        }
+    }
+
+    @Test
+    public void testClearOverlapRight() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        bs.clear(150,250);
+        if (!bs.toString().equals("100-149")) {
+            fail("testClearOverlapRight fail " + bs);
+        }
+    }
+
+    @Test
+    public void testClearOverlapAll() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        bs.clear(50,250);
+        if (!bs.toString().equals("")) {
+            fail("testClearOverlapAll fail " + bs);
+        }
+    }
+
+    @Test
+    public void testAnd() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        RLEBitSet b2 = new RLEBitSet("150-400");
+        bs.and(b2);
+        if (!bs.toString().equals("150-200")) {
+            fail("testAnd fail " + bs);
+        }
+        bs = new RLEBitSet("100-200");
+        b2 = new RLEBitSet("1500-4000");
+        bs.and(b2);
+        if (!bs.isEmpty()) {
+            fail("testAnd fail " + bs);
+        }
+    }
+
+    @Test
+    public void testAndNot() {
+        RLEBitSet bs = new RLEBitSet("100-200");
+        RLEBitSet b2 = new RLEBitSet("150-159");
+        bs.andNot(b2);
+        if (!bs.toString().equals("100-149,160-200")) {
+            fail("testAndNot fail " + bs);
+        }
+    }
+
+    @Test
+    public void testIsEmpty() {
+        RLEBitSet bs = new RLEBitSet("");
+        if (!bs.isEmpty()) {
+            fail("testIsEmpty fail " + bs);
+        }
+        bs.set(1);
+        if (bs.isEmpty()) {
+            fail("testIsEmpty fail " + bs);
+        }
+    }
+
+    @Test
+    public void testCardinality() {
+        RLEBitSet bs = new RLEBitSet("1-120,10000000-10000005");
+        if (bs.cardinality() != 126) {
+            fail("testCardinality fail 1");
+        }
+    }
+
+    @Test
+    public void testIterator() {
+        RLEBitSet rleBitSet = new RLEBitSet("1,5,10-12");
+        Iterator<Long[]> rleBitSetRangeIterator = rleBitSet.getRangeIterator();
+        if (!rleBitSetRangeIterator.hasNext()) {
+            fail("iterator fail 1");
+        }
+        Long[] ll = rleBitSetRangeIterator.next();
+        if (ll == null || ll[0] != 1 || ll[1] != 1) {
+            fail("iterator fail 2");
+        }
+
+        if (!rleBitSetRangeIterator.hasNext()) {
+            fail("iterator fail 3");
+        }
+        ll = rleBitSetRangeIterator.next();
+        if (ll == null || ll[0] != 5 || ll[1] != 5) {
+            fail("iterator fail 4");
+        }
+
+        if (!rleBitSetRangeIterator.hasNext()) {
+            fail("iterator fail 5");
+        }
+        ll = rleBitSetRangeIterator.next();
+        if (ll == null || ll[0] != 10 || ll[1] != 12) {
+            fail("iterator fail 6");
+        }
+
+        if (rleBitSetRangeIterator.hasNext()) {
+            fail("iterator fail 7");
+        }
+    }
+
+    @Test
+    public void testClone() {
+        RLEBitSet bs1 = new RLEBitSet("1,5,10-12");
+        RLEBitSet bs2 = (RLEBitSet) bs1.clone();
+        if (!bs1.toString().equals(bs2.toString())) {
+            fail("clone");
+        }
+    }
+}
@@ -7,9 +7,9 @@
  * * Licensed under the Apache License, Version 2.0 (the "License");
  * * you may not use this file except in compliance with the License.
  * * You may obtain a copy of the License at
- * * 
+ * *
  *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
+ * *
  *  * Unless required by applicable law or agreed to in writing, software
  * * distributed under the License is distributed on an "AS IS" BASIS,
  * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,8 +23,6 @@
 
 package datarouter.provisioning;
 
-import datarouter.provisioning.testBase;
-
-public class testRouteAPI extends testBase {
+public class IntegrationTestRouteApi extends IntegrationTestBase {
 
 }
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestSubscribePost.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestSubscribePost.java
new file mode 100644 (file)
index 0000000..1f21c1f
--- /dev/null
@@ -0,0 +1,192 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * * ===========================================================================
+ * * Licensed under the Apache License, Version 2.0 (the "License");
+ * * you may not use this file except in compliance with the License.
+ * * You may obtain a copy of the License at
+ * *
+ *  *      http://www.apache.org/licenses/LICENSE-2.0
+ * *
+ *  * Unless required by applicable law or agreed to in writing, software
+ * * distributed under the License is distributed on an "AS IS" BASIS,
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * * See the License for the specific language governing permissions and
+ * * limitations under the License.
+ * * ============LICENSE_END====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+
+package datarouter.provisioning;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.ByteArrayEntity;
+import org.apache.http.entity.ContentType;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.json.JSONTokener;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.FeedServlet;
+import org.onap.dmaap.datarouter.provisioning.SubscribeServlet;
+
+public class IntegrationTestSubscribePost extends IntegrationTestBase {
+    private int feednum = 0;
+
+    @BeforeClass
+    public static void setUpBeforeClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownAfterClass() throws Exception {
+    }
+
+    /**
+     * This is the setUp method.
+     */
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        getDBstate();
+        // use the first feed to subscribe to
+        JSONArray ja = db_state.getJSONArray("feeds");
+        for (int i = 0; i < ja.length(); i++) {
+            JSONObject feed0 = ja.getJSONObject(i);
+            if (feed0 != null && !feed0.getBoolean("deleted")) {
+                feednum = feed0.getInt("feedid");
+                return;
+            }
+        }
+    }
+
+    @Test
+    public void testNormal() {
+        JSONObject jo = buildSubRequest();
+        testCommon(jo, HttpServletResponse.SC_CREATED);
+    }
+
+    @Test
+    public void testMissingUrl() {
+        JSONObject jo = buildSubRequest();
+        jo.getJSONObject("delivery").remove("url");
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
+    }
+
+    @Test
+    public void testTooLongUrl() {
+        JSONObject jo = buildSubRequest();
+        jo.getJSONObject("delivery").put("url", "https://" + s257);
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
+    }
+
+    @Test
+    public void testMissingUser() {
+        JSONObject jo = buildSubRequest();
+        jo.getJSONObject("delivery").remove("user");
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
+    }
+
+    @Test
+    public void testTooLongUser() {
+        JSONObject jo = buildSubRequest();
+        jo.getJSONObject("delivery").put("user", s33);
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
+    }
+
+    @Test
+    public void testMissingPassword() {
+        JSONObject jo = buildSubRequest();
+        jo.getJSONObject("delivery").remove("password");
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
+    }
+
+    @Test
+    public void testTooLongPassword() {
+        JSONObject jo = buildSubRequest();
+        jo.getJSONObject("delivery").put("password", s33);
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
+    }
+
+    @Test
+    public void testNonBooleanMetadata() {
+        JSONObject jo = buildSubRequest();
+        jo.put("metadataOnly", s33);
+        testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
+    }
+
+    private void testCommon(JSONObject jo, int expect) {
+        String url   = props.getProperty("test.host") + "/subscribe/" + feednum;
+        HttpPost httpPost = new HttpPost(url);
+        try {
+            httpPost.addHeader(SubscribeServlet.BEHALF_HEADER, "JUnit");
+            String strJo = jo.toString();
+            HttpEntity body = new ByteArrayEntity(strJo.getBytes(),
+                    ContentType.create(SubscribeServlet.SUB_CONTENT_TYPE));
+            httpPost.setEntity(body);
+
+            HttpResponse response = httpclient.execute(httpPost);
+            ckResponse(response, expect);
+
+            HttpEntity entity = response.getEntity();
+            String ctype = entity.getContentType().getValue();
+            int code = response.getStatusLine().getStatusCode();
+            if (code == HttpServletResponse.SC_CREATED && !ctype.equals(SubscribeServlet.SUBFULL_CONTENT_TYPE)) {
+                fail("Got wrong content type: " + ctype);
+            }
+
+            // do something useful with the response body and ensure it is fully consumed
+            if (ctype.equals(FeedServlet.SUBFULL_CONTENT_TYPE)) {
+                JSONObject jo2 = null;
+                try {
+                    jo2 = new JSONObject(new JSONTokener(entity.getContent()));
+                } catch (Exception e) {
+                    fail("Bad JSON: " + e.getMessage());
+                }
+                try {
+                    jo2.getString("subscriber");
+                    JSONObject jo3 = jo2.getJSONObject("links");
+                    jo3.getString("self");
+                    jo3.getString("feed");
+                    jo3.getString("log");
+                } catch (JSONException e) {
+                    fail("required field missing from result: " + e.getMessage());
+                }
+            } else {
+                EntityUtils.consume(entity);
+            }
+        } catch (IOException e) {
+            fail(e.getMessage());
+        } finally {
+            httpPost.releaseConnection();
+        }
+    }
+
+    private JSONObject buildSubRequest() {
+        JSONObject jo2 = new JSONObject();
+        jo2.put("url", "https://www.att.com/");
+        jo2.put("user", "dmr");
+        jo2.put("password", "passw0rd");
+        jo2.put("use100", true);
+
+        JSONObject jo = new JSONObject();
+        jo.put("delivery", jo2);
+        jo.put("metadataOnly", Boolean.FALSE);
+        return jo;
+    }
+}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testBase.java b/datarouter-prov/src/test/java/datarouter/provisioning/testBase.java
deleted file mode 100644 (file)
index dd8e86c..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.KeyStore;
-import java.util.Properties;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.conn.scheme.Scheme;
-import org.apache.http.conn.ssl.SSLSocketFactory;
-import org.apache.http.impl.client.AbstractHttpClient;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.junit.After;
-import org.junit.Before;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-
-public class testBase {
-       /** The properties file to read the DB properties from */
-       public static final String CONFIG_FILE = "integration_test.properties";
-
-       public Properties props;
-       protected AbstractHttpClient httpclient;
-       protected String s_33;
-       protected String s_257;
-       protected static JSONObject db_state;
-
-       @Before
-       public void setUp() throws Exception {
-               if (props == null) {
-                       props = new Properties();
-                       InputStream inStream = getClass().getClassLoader().getResourceAsStream(CONFIG_FILE);
-                       try {
-                               props.load(inStream);
-                       } catch (Exception e) {
-                               e.printStackTrace();
-                       } finally {
-                               inStream.close();
-                       }
-               }
-
-               httpclient = new DefaultHttpClient();
-               String s = "0123456789ABCDEF";
-               s_33 = s + s + "!";
-               s = s + s + s + s;
-               s_257 = s + s + s + s + "!";
-
-               // keystore
-               String store = props.getProperty("test.keystore");
-               String pass  = props.getProperty("test.kspassword");
-               KeyStore keyStore  = KeyStore.getInstance(KeyStore.getDefaultType());
-           FileInputStream instream = new FileInputStream(new File(store));
-           try {
-               keyStore.load(instream, pass.toCharArray());
-           } catch (Exception x) {
-               System.err.println("READING KEYSTORE: "+x);
-           } finally {
-               try { instream.close(); } catch (Exception ignore) {}
-           }
-
-               store = props.getProperty("test.truststore");
-               pass  = props.getProperty("test.tspassword");
-               KeyStore trustStore  = KeyStore.getInstance(KeyStore.getDefaultType());
-           instream = new FileInputStream(new File(store));
-           try {
-               trustStore.load(instream, pass.toCharArray());
-           } catch (Exception x) {
-               System.err.println("READING TRUSTSTORE: "+x);
-           } finally {
-               try { instream.close(); } catch (Exception ignore) {}
-           }
-
-           SSLSocketFactory socketFactory = new SSLSocketFactory(keyStore, "changeit", trustStore);
-           Scheme sch = new Scheme("https", 443, socketFactory);
-           httpclient.getConnectionManager().getSchemeRegistry().register(sch);
-       }
-
-       public JSONObject getDBstate() {
-               // set db_state!
-               if (db_state == null) {
-                       String url   = props.getProperty("test.host") + "/internal/prov";
-                       HttpGet httpGet = new HttpGet(url);
-                       try {
-                               httpGet.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-                               HttpResponse response = httpclient.execute(httpGet);
-                               HttpEntity entity = response.getEntity();
-                               String ctype = entity.getContentType().getValue().trim();
-                               // save the response body as db_state
-                               boolean ok  = ctype.equals(FeedServlet.PROVFULL_CONTENT_TYPE1);
-                                       ok |= ctype.equals(FeedServlet.PROVFULL_CONTENT_TYPE2);
-                               if (ok) {
-                                       db_state = null;
-                                       try {
-                                               db_state = new JSONObject(new JSONTokener(entity.getContent()));
-                                       } catch (Exception e) {
-                                               fail("Bad JSON: "+e.getMessage());
-                                       }
-                               } else {
-                                       EntityUtils.consume(entity);
-                               }
-                       } catch (IOException e) {
-                               fail(e.getMessage());
-                       } finally {
-                               httpGet.releaseConnection();
-                       }
-               }
-               return db_state;
-       }
-
-       @After
-       public void tearDown() throws Exception {
-               // When HttpClient instance is no longer needed,
-               // shut down the connection manager to ensure
-               // immediate deallocation of all system resources
-               httpclient.getConnectionManager().shutdown();
-               FileUtils.deleteDirectory(new File("./unit-test-logs"));
-       }
-
-       protected void ckResponse(HttpResponse response, int expect) {
-               System.out.println(response.getStatusLine());
-               StatusLine sl = response.getStatusLine();
-               int code = sl.getStatusCode();
-               if (code != expect)
-                       fail("Unexpected response, expect "+expect+" got "+code+" "+sl.getReasonPhrase());
-       }
-}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testDRFeedsGet.java b/datarouter-prov/src/test/java/datarouter/provisioning/testDRFeedsGet.java
deleted file mode 100644 (file)
index 4ad9036..0000000
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-
-public class testDRFeedsGet extends testBase {
-       private JSONArray returnedlist;
-
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-       }
-
-       @Before
-       public void setUp() throws Exception {
-               super.setUp();
-               getDBstate();
-       }
-
-       @Test
-       public void testNormal() {
-               testCommon(HttpServletResponse.SC_OK);
-               int expect = 0;
-               JSONArray ja = db_state.getJSONArray("feeds");
-               for (int i = 0; i < ja.length(); i++) {
-                       JSONObject jo = ja.getJSONObject(i);
-                       if (!jo.getBoolean("deleted"))
-                               expect++;
-               }
-               if (returnedlist.length() != expect)
-                       fail("bad length, got "+ returnedlist.length() + " expect " + expect);
-       }
-       @Test
-       public void testNormalGoodName() {
-               JSONArray ja = db_state.getJSONArray("feeds");
-               JSONObject feed0 = ja.getJSONObject(0);
-               String name = feed0.getString("name");
-               String query = "?name=" + name;
-               int expect = 0;
-               for (int n = 0; n < ja.length(); n++) {
-                       JSONObject jo = ja.getJSONObject(n);
-                       if (!jo.getBoolean("deleted") && jo.getString("name").equals(name))
-                               expect++;
-               }
-               testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
-               if (returnedlist.length() != expect)
-                       fail("bad length, got "+ returnedlist.length() + " expect "+expect);
-       }
-       @Test
-       public void testNormalBadName() {
-               String query = "?name=ZZTOP123456";
-               testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
-               if (returnedlist.length() != 0)
-                       fail("bad length, got "+ returnedlist.length() + " expect 0");
-       }
-       @Test
-       public void testNormalBadPath() {
-               String query = "flarg/?publisher=JUnit";
-               testCommon(HttpServletResponse.SC_NOT_FOUND, query, "text/html;charset=ISO-8859-1", "JUnit");
-       }
-       @Test
-       public void testNormalGoodPublisher() {
-               JSONArray ja = db_state.getJSONArray("feeds");
-               JSONObject feed0 = ja.getJSONObject(0);
-               String query = "?publisher=" + feed0.getString("publisher");
-               testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
-               int expect = 0;
-               for (int i = 0; i < ja.length(); i++) {
-                       JSONObject jo = ja.getJSONObject(i);
-                       if (jo.getString("publisher").equals(feed0.getString("publisher")) && !jo.getBoolean("deleted"))
-                               expect++;
-               }
-               if (returnedlist.length() != expect)
-                       fail("bad length, got "+returnedlist.length()+" expected "+expect);
-       }
-       @Test
-       public void testNormalBadPublisher() {
-               String query = "?publisher=ZZTOP123456";
-               testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
-               if (returnedlist.length() != 0)
-                       fail("bad length");
-       }
-       @Test
-       public void testNormalGoodSubscriber() {
-               JSONArray ja = db_state.getJSONArray("subscriptions");
-               if (ja.length() > 0) {
-                       JSONObject sub0 = ja.getJSONObject(0);
-                       String query = "?subscriber=" + sub0.getString("subscriber");
-                       testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
-// aarg! - this is complicated!
-//             int expect = 0;
-//             for (int i = 0; i < ja.length(); i++) {
-//                     JSONObject jo = ja.getJSONObject(i);
-//                     if (jo.getString("subscriber").equals(sub0.getString("subscriber")))
-//                             expect++;
-//             }
-//             if (returnedlist.length() != 1)
-//                     fail("bad length "+returnedlist.toString());
-               } else {
-                       // There are no subscriptions yet, so use a made up name
-                       testCommon(HttpServletResponse.SC_OK, "?subscriber=foo", FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
-               }
-       }
-       @Test
-       public void testNormalBadSubscriber() {
-               String query = "?subscriber=ZZTOP123456";
-               testCommon(HttpServletResponse.SC_OK, query, FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
-               if (returnedlist.length() != 0)
-                       fail("bad length");
-       }
-       private void testCommon(int expect) {
-               testCommon(expect, "", FeedServlet.FEEDLIST_CONTENT_TYPE, "JUnit");
-       }
-       private void testCommon(int expect, String query, String ectype, String bhdr) {
-               String url = props.getProperty("test.host") + "/" + query;
-               HttpGet httpGet = new HttpGet(url);
-               try {
-                       if (bhdr != null)
-                               httpGet.addHeader(FeedServlet.BEHALF_HEADER, bhdr);
-
-                       HttpResponse response = httpclient.execute(httpGet);
-                   ckResponse(response, expect);
-
-                       HttpEntity entity = response.getEntity();
-                       String ctype = entity.getContentType().getValue().trim();
-                       if (!ctype.equals(ectype))
-                               fail("Got wrong content type: "+ctype);
-
-                       // do something useful with the response body and ensure it is fully consumed
-                       if (ctype.equals(FeedServlet.FEEDLIST_CONTENT_TYPE)) {
-                               try {
-                                       returnedlist = new JSONArray(new JSONTokener(entity.getContent()));
-                               } catch (Exception e) {
-                                       fail("Bad JSON: "+e.getMessage());
-                               }
-                       } else {
-                               EntityUtils.consume(entity);
-                       }
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       httpGet.releaseConnection();
-               }
-       }
-}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testDRFeedsPost.java b/datarouter-prov/src/test/java/datarouter/provisioning/testDRFeedsPost.java
deleted file mode 100644 (file)
index 5142423..0000000
+++ /dev/null
@@ -1,281 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.*;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-
-public class testDRFeedsPost extends testBase {
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-       }
-
-       @Test
-       public void testNormal() {
-               JSONObject jo = buildFeedRequest();
-               testCommon(jo, HttpServletResponse.SC_CREATED);
-       }
-       @Test
-       public void testNormalNoCTVersion() {
-               JSONObject jo = buildFeedRequest();
-               testCommon(jo, HttpServletResponse.SC_CREATED, "application/vnd.att-dr.feed", "JUnit");
-       }
-       @Test
-       public void testBadContentType() {
-               JSONObject jo = buildFeedRequest();
-               testCommon(jo, HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "bad/bad", "Junit");
-       }
-       @Test
-       public void testNoBehalfHeader() {
-               JSONObject jo = buildFeedRequest();
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, FeedServlet.FEED_CONTENT_TYPE, null);
-       }
-       @Test
-       public void testMissingName() {
-               JSONObject jo = buildFeedRequest();
-               jo.remove("name");
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testTooLongName() {
-               JSONObject jo = buildFeedRequest();
-               jo.put("name", "123456789012345678901234567890");
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testMissingVersion() {
-               JSONObject jo = buildFeedRequest();
-               jo.remove("version");
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testTooLongVersion() {
-               JSONObject jo = buildFeedRequest();
-               jo.put("version", "123456789012345678901234567890");
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testTooLongDescription() {
-               // normal request
-               JSONObject jo = buildFeedRequest();
-               jo.put("description", s_257);
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testMissingAuthorization() {
-               JSONObject jo = buildFeedRequest();
-               jo.remove("authorization");
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testMissingClassification() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               j2.remove("classification");
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testTooLongClassification() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               j2.put("classification", s_33);
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testNoEndpointIds() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               j2.put("endpoint_ids", new JSONArray());
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testBadIPAddress1() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               JSONArray ja = j2.getJSONArray("endpoint_addrs");
-               ja.put("ZZZ^&#$%@#&^%$@#&^");
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testBadIPAddress2() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               JSONArray ja = j2.getJSONArray("endpoint_addrs");
-               ja.put("135.207.136.678");      // bad IPv4 addr
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testBadIPAddress3() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               JSONArray ja = j2.getJSONArray("endpoint_addrs");
-               ja.put("2001:1890:1110:d000:1a29::17567"); // bad IPv6 addr
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testBadNetMask() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               JSONArray ja = j2.getJSONArray("endpoint_addrs");
-               ja.put("10.10.10.10/64");
-               testCommon(jo, 400);
-       }
-       @Test
-       public void testGoodIPAddress1() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               JSONArray ja = j2.getJSONArray("endpoint_addrs");
-               ja.put("135.207.136.175"); // good IPv4 addr
-               testCommon(jo, 201);
-       }
-       @Test
-       public void testGoodIPAddress2() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               JSONArray ja = j2.getJSONArray("endpoint_addrs");
-               ja.put("2001:1890:1110:d000:1a29::175"); // good IPv6 addr
-               testCommon(jo, 201);
-       }
-       @Test
-       public void testGoodNetMask() {
-               JSONObject jo = buildFeedRequest();
-               JSONObject j2 = jo.getJSONObject("authorization");
-               JSONArray ja = j2.getJSONArray("endpoint_addrs");
-               ja.put("2001:1890:1110:d000:1a29::175/120");
-               testCommon(jo, 201);
-       }
-       private void testCommon(JSONObject jo, int expect) {
-               testCommon(jo, expect, FeedServlet.FEED_CONTENT_TYPE, "JUnit");
-       }
-       private void testCommon(JSONObject jo, int expect, String ctype, String bhdr) {
-               String url   = props.getProperty("test.host") + "/";
-               HttpPost httpPost = new HttpPost(url);
-               try {
-                       if (bhdr != null)
-                               httpPost.addHeader(FeedServlet.BEHALF_HEADER, bhdr);
-                       String t = jo.toString();
-                       HttpEntity body = new ByteArrayEntity(t.getBytes(), ContentType.create(ctype));
-                       httpPost.setEntity(body);
-
-                       HttpResponse response = httpclient.execute(httpPost);
-                   ckResponse(response, expect);
-
-                       HttpEntity entity = response.getEntity();
-                       ctype = entity.getContentType().getValue().trim();
-                       int code = response.getStatusLine().getStatusCode();
-                       if (code == HttpServletResponse.SC_CREATED && !ctype.equals(FeedServlet.FEEDFULL_CONTENT_TYPE))
-                               fail("Got wrong content type: "+ctype);
-
-                       if (code == HttpServletResponse.SC_CREATED) {
-                               Header[] loc = response.getHeaders("Location");
-                               if (loc == null)
-                                       fail("Missing Location header.");
-                       }
-
-                       // do something useful with the response body and ensure it is fully consumed
-                       if (ctype.equals(FeedServlet.FEEDFULL_CONTENT_TYPE)) {
-                               // ck Location header!
-                               JSONObject jo2 = null;
-                               try {
-                                       jo2 = new JSONObject(new JSONTokener(entity.getContent()));
-       System.err.println(jo2.toString());
-                               } catch (Exception e) {
-                                       fail("Bad JSON: "+e.getMessage());
-                               }
-                               try {
-                                       jo2.getString("publisher");
-                                       JSONObject jo3 = jo2.getJSONObject("links");
-                                       jo3.getString("self");
-                                       jo3.getString("publish");
-                                       jo3.getString("subscribe");
-                                       jo3.getString("log");
-                               } catch (JSONException e) {
-                                       fail("required field missing from result: "+e.getMessage());
-                               }
-                       } else {
-                               EntityUtils.consume(entity);
-                       }
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       httpPost.releaseConnection();
-               }
-       }
-       private JSONObject buildFeedRequest() {
-               JSONObject jo = new JSONObject();
-               jo.put("name", "JunitFeed");
-               jo.put("version", ""+System.currentTimeMillis());       // make version unique
-               jo.put("description", "Sample feed used by JUnit to test");
-
-                       JSONObject jo2 = new JSONObject();
-                       jo2.put("classification", "unrestricted");
-
-                       JSONArray ja = new JSONArray();
-                               JSONObject jo3 = new JSONObject();
-                               jo3.put("id", "id001");
-                               jo3.put("password", "re1kwelj");
-                               JSONObject jo4 = new JSONObject();
-                               jo4.put("id", "id002");
-                               jo4.put("password", "o9eqlmbd");
-                               ja.put(jo3);
-                               ja.put(jo4);
-                       jo2.put("endpoint_ids", ja);
-
-                       ja = new JSONArray();
-                               ja.put("10.0.0.1");
-                               ja.put("192.168.0.1");
-                               ja.put("135.207.136.128/25");
-                       jo2.put("endpoint_addrs", ja);
-
-               jo.put("authorization", jo2);
-               return jo;
-       }
-}
-/*
-curl -v -X POST -H 'X-ATT-DR-ON-BEHALF-OF: tester' -H 'Content-type: application/vnd.att-dr.feed' --user publisher:tomcat \
-       --data "$data" http://127.0.0.1:8080/prov/feed/
-*/
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testFeedPut.java b/datarouter-prov/src/test/java/datarouter/provisioning/testFeedPut.java
deleted file mode 100644 (file)
index 1f84540..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-
-public class testFeedPut extends testBase {
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-       }
-
-       @Before
-       public void setUp() throws Exception {
-               super.setUp();
-               getDBstate();
-       }
-
-       @Test
-       public void testPutNoFeedID() {
-               JSONObject jo = buildFeedRequest();
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, "/feed/");
-       }
-       @Test
-       public void testPutNoFeed() {
-               JSONObject jo = buildFeedRequest();
-               testCommon(jo, HttpServletResponse.SC_NOT_FOUND, "/feed/999999");
-       }
-       @Test
-       public void testBadContentType() {
-               JSONObject jo = buildFeedRequest();
-               testCommon(jo, HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE, "bad/bad", "JUnit");
-       }
-       @Test
-       public void testChangeName() {
-               JSONObject jo = buildFeedRequest();
-               jo.put("name", "badname");
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, FeedServlet.FEED_CONTENT_TYPE, "JUnit");
-       }
-       @Test
-       public void testChangeVersion() {
-               JSONObject jo = buildFeedRequest();
-               jo.put("version", "badvers");
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, FeedServlet.FEED_CONTENT_TYPE, "JUnit");
-       }
-       @Test
-       public void testBadPublisher() {
-               JSONObject jo = buildFeedRequest();
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST, FeedServlet.FEED_CONTENT_TYPE, "BadBadBad");
-       }
-       @Test
-       public void testChangeDescription() {
-               JSONObject jo = buildFeedRequest();
-               // change descr
-               jo.put("description", "This description HAS BEEN CHANGED!!!");
-               testCommon(jo, HttpServletResponse.SC_OK, FeedServlet.FEED_CONTENT_TYPE, "JUnit");
-       }
-
-       private void testCommon(JSONObject jo, int expect, String uri) {
-               testCommon(jo, expect, FeedServlet.FEED_CONTENT_TYPE, "Junit", uri);
-       }
-       private void testCommon(JSONObject jo, int expect, String ctype, String bhdr) {
-               JSONArray ja = db_state.getJSONArray("feeds");
-               for (int i = 0; i < ja.length(); i++) {
-                       JSONObject feed0 = ja.getJSONObject(i);
-                       if (!feed0.getBoolean("deleted") && feed0.getString("publisher").equals(bhdr)) {
-                               int feedid = feed0.getInt("feedid");
-                               testCommon(jo, expect, ctype, bhdr, "/feed/"+feedid);
-                               return;
-                       }
-               }
-       }
-       private void testCommon(JSONObject jo, int expect, String ctype, String bhdr, String uri) {
-               String url   = props.getProperty("test.host") + uri;
-               HttpPut put = new HttpPut(url);
-               try {
-                       if (bhdr != null)
-                               put.addHeader(FeedServlet.BEHALF_HEADER, bhdr);
-                       String t = jo.toString();
-                       HttpEntity body = new ByteArrayEntity(t.getBytes(), ContentType.create(ctype));
-                       put.setEntity(body);
-
-                       HttpResponse response = httpclient.execute(put);
-                   ckResponse(response, expect);
-
-                       HttpEntity entity = response.getEntity();
-                       ctype = entity.getContentType().getValue().trim();
-                       int code = response.getStatusLine().getStatusCode();
-                       if (code == HttpServletResponse.SC_CREATED && !ctype.equals(FeedServlet.FEEDFULL_CONTENT_TYPE))
-                               fail("Got wrong content type: "+ctype);
-
-                       if (code == HttpServletResponse.SC_CREATED) {
-                               Header[] loc = response.getHeaders("Location");
-                               if (loc == null)
-                                       fail("Missing Location header.");
-                       }
-
-                       // do something useful with the response body and ensure it is fully consumed
-                       if (ctype.equals(FeedServlet.FEEDFULL_CONTENT_TYPE)) {
-                               // ck Location header!
-                               JSONObject jo2 = null;
-                               try {
-                                       jo2 = new JSONObject(new JSONTokener(entity.getContent()));
-       System.err.println(jo2.toString());
-                               } catch (Exception e) {
-                                       fail("Bad JSON: "+e.getMessage());
-                               }
-                               try {
-                                       jo2.getString("publisher");
-                                       JSONObject jo3 = jo2.getJSONObject("links");
-                                       jo3.getString("self");
-                                       jo3.getString("publish");
-                                       jo3.getString("subscribe");
-                                       jo3.getString("log");
-                               } catch (JSONException e) {
-                                       fail("required field missing from result: "+e.getMessage());
-                               }
-                       } else {
-                               EntityUtils.consume(entity);
-                       }
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       put.releaseConnection();
-               }
-       }
-       private JSONObject buildFeedRequest() {
-               JSONObject jo = new JSONObject();
-               jo.put("name", "feed");
-               jo.put("version", "1.0.0");
-               jo.put("description", "Sample feed used by JUnit to test");
-
-                       JSONObject jo2 = new JSONObject();
-                       jo2.put("classification", "unrestricted");
-
-                       JSONArray ja = new JSONArray();
-                               JSONObject jo3 = new JSONObject();
-                               jo3.put("id", "id001");
-                               jo3.put("password", "re1kwelj");
-                               JSONObject jo4 = new JSONObject();
-                               jo4.put("id", "id002");
-                               jo4.put("password", "o9eqlmbd");
-                               ja.put(jo3);
-                               ja.put(jo4);
-                       jo2.put("endpoint_ids", ja);
-
-                       ja = new JSONArray();
-                               ja.put("20.0.0.1");
-                               ja.put("195.68.12.15");
-                               ja.put("135.207.136.128/25");
-                       jo2.put("endpoint_addrs", ja);
-
-               jo.put("authorization", jo2);
-               return jo;
-       }
-}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testInternalGet.java b/datarouter-prov/src/test/java/datarouter/provisioning/testInternalGet.java
deleted file mode 100644 (file)
index 02c295e..0000000
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-import org.onap.dmaap.datarouter.provisioning.beans.Parameters;
-
-public class testInternalGet extends testBase {
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-       }
-
-       @Test
-       public void testNormal() {
-               String url   = props.getProperty("test.host") + "/internal/prov";
-               HttpGet httpPost = new HttpGet(url);
-               try {
-                       httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-
-                       HttpResponse response = httpclient.execute(httpPost);
-                       int code = response.getStatusLine().getStatusCode();
-                       if (code != 200)
-                               fail("Unexpected response, expect "+200+" got "+code);
-
-                       HttpEntity entity = response.getEntity();
-                       String ctype = entity.getContentType().getValue().trim();
-                       boolean ok  = ctype.equals(FeedServlet.PROVFULL_CONTENT_TYPE1);
-                       ok |= ctype.equals(FeedServlet.PROVFULL_CONTENT_TYPE2);
-                       if (!ok)
-                               fail("Got wrong content type: "+ctype);
-
-                       // do something useful with the response body and ensure it is fully consumed
-                       if (ok) {
-                               JSONObject jo = null;
-                               try {
-                                       jo = new JSONObject(new JSONTokener(entity.getContent()));
-                               } catch (Exception e) {
-                                       fail("Bad JSON: "+e.getMessage());
-                               }
-                               try {
-                                       jo.getJSONArray("feeds");
-                                       jo.getJSONArray("subscriptions");
-                                       JSONObject jo2 = jo.getJSONObject("parameters");
-                                       jo2.getJSONArray(Parameters.NODES);
-                                       jo2.getString(Parameters.ACTIVE_POD);
-                                       jo2.getString(Parameters.STANDBY_POD);
-                                       jo2.getInt(Parameters.LOGROLL_INTERVAL);
-                                       jo2.getInt(Parameters.DELIVERY_INIT_RETRY_INTERVAL);
-                                       jo2.getInt(Parameters.DELIVERY_MAX_RETRY_INTERVAL);
-                                       jo2.getInt(Parameters.DELIVERY_RETRY_RATIO);
-                                       jo2.getInt(Parameters.DELIVERY_MAX_AGE);
-                               } catch (JSONException e) {
-                                       fail("required field missing from result: "+e.getMessage());
-                               }
-                       } else {
-                               EntityUtils.consume(entity);
-                       }
-               } catch (IOException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } finally {
-                       httpPost.releaseConnection();
-               }
-       }
-}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testInternalMisc.java b/datarouter-prov/src/test/java/datarouter/provisioning/testInternalMisc.java
deleted file mode 100644 (file)
index d4339cc..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONArray;
-import org.json.JSONTokener;
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-
-public class testInternalMisc extends testBase {
-       @Test
-       public void testInternalDrlogs() {
-               String url   = props.getProperty("test.host") + "/internal/drlogs";
-               HttpGet httpPost = new HttpGet(url);
-               try {
-                       httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-
-                       HttpResponse response = httpclient.execute(httpPost);
-                       int code = response.getStatusLine().getStatusCode();
-                       if (code != 200)
-                               fail("Unexpected response, expect "+HttpServletResponse.SC_NOT_FOUND+" got "+code);
-
-                       HttpEntity entity = response.getEntity();
-                       String ctype = entity.getContentType().getValue().trim();
-                       boolean ok  = ctype.equals("text/plain");
-                       if (!ok)
-                               fail("Got wrong content type: "+ctype);
-
-                       EntityUtils.consume(entity);
-               } catch (IOException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } finally {
-                       httpPost.releaseConnection();
-               }
-       }
-
-       @Test
-       public void testInternalHalt() {
-               String url   = props.getProperty("test.host") + "/internal/halt";
-               HttpGet httpPost = new HttpGet(url);
-               try {
-                       httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-
-                       HttpResponse response = httpclient.execute(httpPost);
-                       int code = response.getStatusLine().getStatusCode();
-                       if (code != HttpServletResponse.SC_NOT_FOUND)
-                               fail("Unexpected response, expect "+HttpServletResponse.SC_NOT_FOUND+" got "+code);
-
-                       HttpEntity entity = response.getEntity();
-                       EntityUtils.consume(entity);
-               } catch (IOException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } finally {
-                       httpPost.releaseConnection();
-               }
-       }
-
-       @SuppressWarnings("unused")
-       @Test
-       public void testInternalLogs() {
-               String url   = props.getProperty("test.host") + "/internal/logs";
-               HttpGet httpPost = new HttpGet(url);
-               try {
-                       httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-
-                       HttpResponse response = httpclient.execute(httpPost);
-                       int code = response.getStatusLine().getStatusCode();
-                       if (code != 200)
-                               fail("Unexpected response, expect "+200+" got "+code);
-
-                       HttpEntity entity = response.getEntity();
-                       String ctype = entity.getContentType().getValue().trim();
-                       boolean ok  = ctype.equals("application/json");
-                       if (!ok)
-                               fail("Got wrong content type: "+ctype);
-
-                       // do something useful with the response body and ensure it is fully consumed
-                       if (ok) {
-                               try {
-                                       new JSONArray(new JSONTokener(entity.getContent()));
-                               } catch (Exception e) {
-                                       fail("Bad JSON: "+e.getMessage());
-                               }
-                       } else {
-                               EntityUtils.consume(entity);
-                       }
-               } catch (IOException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } finally {
-                       httpPost.releaseConnection();
-               }
-       }
-
-       @Test
-       public void testInternalBadURL() {
-               String url   = props.getProperty("test.host") + "/internal/badurl";
-               HttpGet httpPost = new HttpGet(url);
-               try {
-                       httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-
-                       HttpResponse response = httpclient.execute(httpPost);
-                       int code = response.getStatusLine().getStatusCode();
-                       if (code != HttpServletResponse.SC_NOT_FOUND)
-                               fail("Unexpected response, expect "+HttpServletResponse.SC_NOT_FOUND+" got "+code);
-
-                       HttpEntity entity = response.getEntity();
-                       EntityUtils.consume(entity);
-               } catch (IOException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } finally {
-                       httpPost.releaseConnection();
-               }
-       }
-
-}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testLogGet.java b/datarouter-prov/src/test/java/datarouter/provisioning/testLogGet.java
deleted file mode 100644 (file)
index cf0bc99..0000000
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONArray;
-import org.json.JSONTokener;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-
-public class testLogGet extends testBase {
-       private JSONArray returnedlist;
-       private int feedid = 4;
-       private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
-
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-               // need to seed the DB here
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-               // need to "unseed" the DB
-       }
-
-       @Before
-       public void setUp() throws Exception {
-               super.setUp();
-               getDBstate();
-//             JSONArray ja = db_state.getJSONArray("feeds");
-//             for (int i = 0; i < ja.length(); i++) {
-//                     JSONObject jo = ja.getJSONObject(i);
-//                     if (!jo.getBoolean("deleted"))
-//                             feedid = jo.getInt("feedid");
-//             }
-       }
-
-       @Test
-       public void testNormal() {
-               testCommon(HttpServletResponse.SC_OK);
-       }
-       @Test
-       public void testNormalPubOnly() {
-               testCommon(HttpServletResponse.SC_OK, "?type=pub");
-       }
-       @Test
-       public void testNormalDelOnly() {
-               testCommon(HttpServletResponse.SC_OK, "?type=del");
-       }
-       @Test
-       public void testNormalExpOnly() {
-               testCommon(HttpServletResponse.SC_OK, "?type=exp");
-       }
-       @Test
-       public void testNormalXXXOnly() {
-               testCommon(HttpServletResponse.SC_BAD_REQUEST, "?type=xxx");
-       }
-       @Test
-       public void testNormalStatusSuccess() {
-               testCommon(HttpServletResponse.SC_OK, "?statusCode=success");
-       }
-       @Test
-       public void testNormalStatusRedirect() {
-               testCommon(HttpServletResponse.SC_OK, "?statusCode=redirect");
-       }
-       @Test
-       public void testNormalStatusFailure() {
-               testCommon(HttpServletResponse.SC_OK, "?statusCode=failure");
-       }
-       @Test
-       public void testNormalStatus200() {
-               testCommon(HttpServletResponse.SC_OK, "?statusCode=200");
-       }
-       @Test
-       public void testNormalStatusXXX() {
-               testCommon(HttpServletResponse.SC_BAD_REQUEST, "?statusCode=xxx");
-       }
-       @Test
-       public void testNormalExpiryNotRetryable() {
-               testCommon(HttpServletResponse.SC_OK, "?expiryReason=notRetryable");
-       }
-       @Test
-       public void testNormalExpiryRetriesExhausted() {
-               testCommon(HttpServletResponse.SC_OK, "?expiryReason=retriesExhausted");
-       }
-       @Test
-       public void testNormalExpiryXXX() {
-               testCommon(HttpServletResponse.SC_BAD_REQUEST, "?expiryReason=xxx");
-       }
-       @Test
-       public void testNormalPublishId() {
-               testCommon(HttpServletResponse.SC_OK, "?publishId=1366985877801.mtdvnj00-drtr.proto.research.att.com");
-       }
-       @Test
-       public void testNormalStart() {
-               long n = System.currentTimeMillis() - (5 * 24 * 60 * 60 * 1000L);       // 5 days
-               testCommon(HttpServletResponse.SC_OK, String.format("?start=%s", sdf.format(n)));
-       }
-       @Test
-       public void testBadStart() {
-               testCommon(HttpServletResponse.SC_BAD_REQUEST, "?start=xxx");
-       }
-       @Test
-       public void testLongEnd() {
-               testCommon(HttpServletResponse.SC_OK, "?end=1364837896220");
-       }
-       @Test
-       public void testBadEnd() {
-               testCommon(HttpServletResponse.SC_BAD_REQUEST, "?end=2013-04-25T11:01:25Q");
-       }
-       private void testCommon(int expect) {
-               testCommon(expect, "");
-       }
-       private void testCommon(int expect, String query) {
-               String url = props.getProperty("test.host") + "/feedlog/" + feedid + query;
-               HttpGet httpGet = new HttpGet(url);
-               try {
-                       HttpResponse response = httpclient.execute(httpGet);
-                   ckResponse(response, expect);
-
-                       HttpEntity entity = response.getEntity();
-                       String ctype = entity.getContentType().getValue().trim();
-                       if (expect == HttpServletResponse.SC_OK) {
-                               if (!ctype.equals(FeedServlet.LOGLIST_CONTENT_TYPE))
-                                       fail("Got wrong content type: "+ctype);
-                       }
-
-                       // do something useful with the response body and ensure it is fully consumed
-                       if (ctype.equals(FeedServlet.LOGLIST_CONTENT_TYPE)) {
-                               try {
-                                       returnedlist = new JSONArray(new JSONTokener(entity.getContent()));
-                                       int n = returnedlist.length();
-                                       if (n != 0)
-                                               System.err.println(n + " items");
-                               } catch (Exception e) {
-                                       fail("Bad JSON: "+e.getMessage());
-                               }
-                       } else {
-                               EntityUtils.consume(entity);
-                       }
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       httpGet.releaseConnection();
-               }
-       }
-}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testPublish.java b/datarouter-prov/src/test/java/datarouter/provisioning/testPublish.java
deleted file mode 100644 (file)
index ebbf43f..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.http.Header;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.RedirectStrategy;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpRequestBase;
-import org.apache.http.impl.client.DefaultRedirectStrategy;
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-
-public class testPublish extends testBase {
-       private String publish_url;
-
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-       }
-
-       @Before
-       public void setUp() throws Exception {
-               super.setUp();
-               getDBstate();
-               // Get publish URL from first feed
-               JSONArray ja = db_state.getJSONArray("feeds");
-               for (int i = ja.length()-1; i >= 0; i--) {
-                       JSONObject feed = ja.getJSONObject(i);
-                       if (!feed.getBoolean("deleted")) {
-                               publish_url = feed.getJSONObject("links").getString("publish");
-                               publish_url += "/" + System.currentTimeMillis();
-                               return;
-                       }
-               }
-       }
-
-       @Test
-       public void testDelete() {
-               HttpDelete x = new HttpDelete(publish_url);
-               testCommon(x);
-       }
-       @Test
-       public void testGet() {
-               HttpGet x = new HttpGet(publish_url);
-               testCommon(x);
-       }
-       @Test
-       public void testPut() {
-               HttpPut x = new HttpPut(publish_url);
-               testCommon(x);
-       }
-       @Test
-       public void testPost() {
-               HttpPost x = new HttpPost(publish_url);
-               testCommon(x);
-       }
-       private void testCommon(HttpRequestBase rb) {
-               try {
-                       rb.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
-                       RedirectStrategy strategy = new DefaultRedirectStrategy() {
-                               protected boolean isRedirectable(String method) {
-                                       return false;
-                               }
-                       };
-                       httpclient.setRedirectStrategy(strategy);
-                       HttpResponse response = httpclient.execute(rb);
-                   ckResponse(response, HttpServletResponse.SC_MOVED_PERMANENTLY);
-
-                   // Make sure there is a Location hdr
-                   Header[] loc = response.getHeaders("Location");
-                   if (loc == null || loc.length == 0)
-                       fail("No location header");
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       rb.releaseConnection();
-               }
-       }
-}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testRLEBitSet.java b/datarouter-prov/src/test/java/datarouter/provisioning/testRLEBitSet.java
deleted file mode 100644 (file)
index bd777ad..0000000
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.util.Iterator;
-
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.utils.RLEBitSet;
-
-public class testRLEBitSet {
-       @Test
-       public void testBasicConstructor() {
-               RLEBitSet bs = new RLEBitSet();
-               if (!bs.isEmpty())
-                       fail("bit set not empty");
-       }
-       @Test
-       public void testStringConstructor() {
-               RLEBitSet bs = new RLEBitSet("1-10");
-               if (bs.isEmpty())
-                       fail("bit set is empty");
-               if (!bs.toString().equals("1-10"))
-                       fail("bad value");
-               bs = new RLEBitSet("69,70,71");
-               if (bs.isEmpty())
-                       fail("bit set is empty");
-               if (!bs.toString().equals("69-71"))
-                       fail("bad value");
-               bs = new RLEBitSet("555 444    443  442");
-               if (!bs.toString().equals("442-444,555"))
-                       fail("bad value");
-       }
-       @Test
-       public void testLength() {
-               RLEBitSet bs = new RLEBitSet();
-               if (bs.length() != 0)
-                       fail("testLength fail "+bs + " " + bs.length());
-               bs = new RLEBitSet("1-10");
-               if (bs.length() != 11)
-                       fail("testLength fail "+bs + " " + bs.length());
-               bs = new RLEBitSet("1-20,100000000-100000005");
-               if (bs.length() != 100000006)
-                       fail("testLength fail "+bs + " " + bs.length());
-       }
-       @Test
-       public void testGet() {
-               RLEBitSet bs = new RLEBitSet("1-10");
-               if (!bs.get(5))
-                       fail("get");
-               if (bs.get(69))
-                       fail("get");
-       }
-       @Test
-       public void testSetOneBit() {
-               RLEBitSet bs = new RLEBitSet();
-               for (int i = 12; i < 200; i++)
-                       bs.set(i);
-               bs.set(690);
-               for (int i = 305; i < 309; i++)
-                       bs.set(i);
-               bs.set(304);
-               if (!bs.toString().equals("12-199,304-308,690"))
-                       fail("testSetOneBit fail "+bs);
-       }
-       @Test
-       public void testSetString() {
-               RLEBitSet bs = new RLEBitSet();
-               bs.set("1-100");
-               if (!bs.toString().equals("1-100"))
-                       fail("testSetString fail "+bs);
-       }
-       @Test
-       public void testSetRange() {
-               RLEBitSet bs = new RLEBitSet();
-               bs.set(50,60);
-               if (!bs.toString().equals("50-59"))
-                       fail("testSetRange fail "+bs);
-       }
-       @Test
-       public void testClearOneBit() {
-               RLEBitSet bs = new RLEBitSet("1-10");
-               bs.clear(5);
-               if (!bs.toString().equals("1-4,6-10"))
-                       fail("testClearOneBit fail");
-               bs = new RLEBitSet("1-10");
-               bs.clear(11);
-               if (!bs.toString().equals("1-10"))
-                       fail("testClearOneBit fail "+bs);
-       }
-       @Test
-       public void testClearRangeLeft() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               bs.clear(40,50);
-               if (!bs.toString().equals("100-200"))
-                       fail("testClearRangeLeft fail "+bs);
-       }
-       @Test
-       public void testClearRangeRight() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               bs.clear(400,500);
-               if (!bs.toString().equals("100-200"))
-                       fail("testClearRangeRight fail "+bs);
-       }
-       @Test
-       public void testClearRangeMiddle() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               bs.clear(120,130);
-               if (!bs.toString().equals("100-119,130-200"))
-                       fail("testClearRangeRight fail "+bs);
-       }
-       @Test
-       public void testClearRangeIntersect() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               bs.clear(100,200);
-               if (!bs.toString().equals("200"))
-                       fail("testClearRangeIntersect fail "+bs);
-       }
-       @Test
-       public void testClearOverlapLeft() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               bs.clear(50,150);
-               if (!bs.toString().equals("150-200"))
-                       fail("testClearOverlapLeft fail "+bs);
-       }
-       @Test
-       public void testClearOverlapRight() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               bs.clear(150,250);
-               if (!bs.toString().equals("100-149"))
-                       fail("testClearOverlapRight fail "+bs);
-       }
-       @Test
-       public void testClearOverlapAll() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               bs.clear(50,250);
-               if (!bs.toString().equals(""))
-                       fail("testClearOverlapAll fail "+bs);
-       }
-       @Test
-       public void testAnd() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               RLEBitSet b2 = new RLEBitSet("150-400");
-               bs.and(b2);
-               if (!bs.toString().equals("150-200"))
-                       fail("testAnd fail "+bs);
-               bs = new RLEBitSet("100-200");
-               b2 = new RLEBitSet("1500-4000");
-               bs.and(b2);
-               if (!bs.isEmpty())
-                       fail("testAnd fail "+bs);
-       }
-       @Test
-       public void testAndNot() {
-               RLEBitSet bs = new RLEBitSet("100-200");
-               RLEBitSet b2 = new RLEBitSet("150-159");
-               bs.andNot(b2);
-               if (!bs.toString().equals("100-149,160-200"))
-                       fail("testAndNot fail "+bs);
-       }
-       @Test
-       public void testIsEmpty() {
-               RLEBitSet bs = new RLEBitSet("");
-               if (!bs.isEmpty())
-                       fail("testIsEmpty fail "+bs);
-               bs.set(1);
-               if (bs.isEmpty())
-                       fail("testIsEmpty fail "+bs);
-       }
-       @Test
-       public void testCardinality() {
-               RLEBitSet bs = new RLEBitSet("1-120,10000000-10000005");
-               if (bs.cardinality() != 126)
-                       fail("testCardinality fail 1");
-       }
-       @Test
-       public void testIterator() {
-               RLEBitSet bs = new RLEBitSet("1,5,10-12");
-               Iterator<Long[]> i = bs.getRangeIterator();
-               if (!i.hasNext())
-                       fail("iterator fail 1");
-               Long[] ll = i.next();
-               if (ll == null || ll[0] != 1 || ll[1] != 1)
-                       fail("iterator fail 2");
-
-               if (!i.hasNext())
-                       fail("iterator fail 3");
-               ll = i.next();
-               if (ll == null || ll[0] != 5 || ll[1] != 5)
-                       fail("iterator fail 4");
-
-               if (!i.hasNext())
-                       fail("iterator fail 5");
-               ll = i.next();
-               if (ll == null || ll[0] != 10 || ll[1] != 12)
-                       fail("iterator fail 6");
-
-               if (i.hasNext())
-                       fail("iterator fail 7");
-       }
-       @Test
-       public void testClone() {
-               RLEBitSet bs1 = new RLEBitSet("1,5,10-12");
-               RLEBitSet bs2 = (RLEBitSet) bs1.clone();
-               if (!bs1.toString().equals(bs2.toString()))
-                       fail("clone");
-       }
-}
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/testSubscribePost.java b/datarouter-prov/src/test/java/datarouter/provisioning/testSubscribePost.java
deleted file mode 100644 (file)
index 49ed88d..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START==================================================
- * * org.onap.dmaap
- * * ===========================================================================
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
- * * ===========================================================================
- * * Licensed under the Apache License, Version 2.0 (the "License");
- * * you may not use this file except in compliance with the License.
- * * You may obtain a copy of the License at
- * * 
- *  *      http://www.apache.org/licenses/LICENSE-2.0
- * * 
- *  * Unless required by applicable law or agreed to in writing, software
- * * distributed under the License is distributed on an "AS IS" BASIS,
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * * See the License for the specific language governing permissions and
- * * limitations under the License.
- * * ============LICENSE_END====================================================
- * *
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
- * *
- ******************************************************************************/
-
-package datarouter.provisioning;
-
-import static org.junit.Assert.fail;
-
-import java.io.IOException;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.entity.ContentType;
-import org.apache.http.util.EntityUtils;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.onap.dmaap.datarouter.provisioning.FeedServlet;
-import org.onap.dmaap.datarouter.provisioning.SubscribeServlet;
-
-public class testSubscribePost extends testBase {
-       private int feednum = 0;
-
-       @BeforeClass
-       public static void setUpBeforeClass() throws Exception {
-       }
-
-       @AfterClass
-       public static void tearDownAfterClass() throws Exception {
-       }
-
-       @Before
-       public void setUp() throws Exception {
-               super.setUp();
-               getDBstate();
-               // use the first feed to subscribe to
-               JSONArray ja = db_state.getJSONArray("feeds");
-               for (int i = 0; i < ja.length(); i++) {
-                       JSONObject feed0 = ja.getJSONObject(i);
-                       if (feed0 != null && !feed0.getBoolean("deleted")) {
-                               feednum = feed0.getInt("feedid");
-                               return;
-                       }
-               }
-       }
-
-       @Test
-       public void testNormal() {
-               JSONObject jo = buildSubRequest();
-               testCommon(jo, HttpServletResponse.SC_CREATED);
-       }
-       @Test
-       public void testMissingUrl() {
-               JSONObject jo = buildSubRequest();
-               jo.getJSONObject("delivery").remove("url");
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
-       }
-       @Test
-       public void testTooLongUrl() {
-               JSONObject jo = buildSubRequest();
-               jo.getJSONObject("delivery").put("url", "https://"+s_257);
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
-       }
-       @Test
-       public void testMissingUser() {
-               JSONObject jo = buildSubRequest();
-               jo.getJSONObject("delivery").remove("user");
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
-       }
-       @Test
-       public void testTooLongUser() {
-               JSONObject jo = buildSubRequest();
-               jo.getJSONObject("delivery").put("user", s_33);
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
-       }
-       @Test
-       public void testMissingPassword() {
-               JSONObject jo = buildSubRequest();
-               jo.getJSONObject("delivery").remove("password");
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
-       }
-       @Test
-       public void testTooLongPassword() {
-               JSONObject jo = buildSubRequest();
-               jo.getJSONObject("delivery").put("password", s_33);
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
-       }
-       @Test
-       public void testNonBooleanMetadata() {
-               JSONObject jo = buildSubRequest();
-               jo.put("metadataOnly", s_33);
-               testCommon(jo, HttpServletResponse.SC_BAD_REQUEST);
-       }
-       private void testCommon(JSONObject jo, int expect) {
-               String url   = props.getProperty("test.host") + "/subscribe/" + feednum;
-               HttpPost httpPost = new HttpPost(url);
-               try {
-                       httpPost.addHeader(SubscribeServlet.BEHALF_HEADER, "JUnit");
-                       String t = jo.toString();
-                       HttpEntity body = new ByteArrayEntity(t.getBytes(), ContentType.create(SubscribeServlet.SUB_CONTENT_TYPE));
-                       httpPost.setEntity(body);
-
-                       HttpResponse response = httpclient.execute(httpPost);
-                   ckResponse(response, expect);
-
-                       HttpEntity entity = response.getEntity();
-                       String ctype = entity.getContentType().getValue();
-                       int code = response.getStatusLine().getStatusCode();
-                       if (code == HttpServletResponse.SC_CREATED && !ctype.equals(SubscribeServlet.SUBFULL_CONTENT_TYPE))
-                               fail("Got wrong content type: "+ctype);
-
-                       // do something useful with the response body and ensure it is fully consumed
-                       if (ctype.equals(FeedServlet.SUBFULL_CONTENT_TYPE)) {
-                               JSONObject jo2 = null;
-                               try {
-                                       jo2 = new JSONObject(new JSONTokener(entity.getContent()));
-                               } catch (Exception e) {
-                                       fail("Bad JSON: "+e.getMessage());
-                               }
-                               try {
-                                       jo2.getString("subscriber");
-                                       JSONObject jo3 = jo2.getJSONObject("links");
-                                       jo3.getString("self");
-                                       jo3.getString("feed");
-                                       jo3.getString("log");
-                               } catch (JSONException e) {
-                                       fail("required field missing from result: "+e.getMessage());
-                               }
-                       } else {
-                               EntityUtils.consume(entity);
-                       }
-               } catch (IOException e) {
-                       fail(e.getMessage());
-               } finally {
-                       httpPost.releaseConnection();
-               }
-       }
-       private JSONObject buildSubRequest() {
-               JSONObject jo = new JSONObject();
-
-                       JSONObject jo2 = new JSONObject();
-                       jo2.put("url", "https://www.att.com/");
-                       jo2.put("user", "dmr");
-                       jo2.put("password", "passw0rd");
-                       jo2.put("use100", true);
-
-               jo.put("delivery", jo2);
-               jo.put("metadataOnly", Boolean.FALSE);
-               return jo;
-       }
-}