--- /dev/null
+/*******************************************************************************\r
+ * ============LICENSE_START====================================================\r
+ * * org.onap.aaf\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
+package org.onap.aaf.dao.aaf.test;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+import static org.junit.Assert.assertTrue;\r
+\r
+import java.io.IOException;\r
+import java.nio.ByteBuffer;\r
+import java.security.NoSuchAlgorithmException;\r
+import java.util.Date;\r
+import java.util.List;\r
+\r
+import org.junit.Test;\r
+import org.onap.aaf.authz.layer.Result;\r
+import org.onap.aaf.dao.aaf.cass.CredDAO;\r
+import org.onap.aaf.dao.aaf.cass.CredDAO.Data;\r
+\r
+import org.onap.aaf.inno.env.APIException;\r
+\r
+public class JU_FastCalling extends AbsJUCass {\r
+\r
+ @Test\r
+ public void test() throws IOException, NoSuchAlgorithmException, APIException {\r
+ trans.setProperty("cassandra.writeConsistency.cred","ONE");\r
+ \r
+ CredDAO udao = new CredDAO(env.newTransNoAvg(),cluster,"authz");\r
+ System.out.println("Starting calls");\r
+ for(iterations=0;iterations<8;++iterations) {\r
+ try {\r
+ // Create\r
+ CredDAO.Data data = new CredDAO.Data();\r
+ data.id = "m55555@aaf.att.com";\r
+ data.type = CredDAO.BASIC_AUTH;\r
+ data.cred = ByteBuffer.wrap(userPassToBytes("m55555","mypass"));\r
+ data.expires = new Date(System.currentTimeMillis() + 60000*60*24*90);\r
+ udao.create(trans,data);\r
+ \r
+ // Validate Read with key fields in Data\r
+ Result<List<CredDAO.Data>> rlcd = udao.read(trans,data);\r
+ assertTrue(rlcd.isOKhasData());\r
+ for(CredDAO.Data d : rlcd.value) {\r
+ checkData1(data,d);\r
+ }\r
+ \r
+ // Update\r
+ data.cred = ByteBuffer.wrap(userPassToBytes("m55555","mynewpass"));\r
+ udao.update(trans,data);\r
+ rlcd = udao.read(trans,data);\r
+ assertTrue(rlcd.isOKhasData());\r
+ for(CredDAO.Data d : rlcd.value) {\r
+ checkData1(data,d);\r
+ } \r
+ \r
+ udao.delete(trans,data, true);\r
+ } finally {\r
+ updateTotals();\r
+ newTrans();\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+ private void checkData1(Data data, Data d) {\r
+ assertEquals(data.id,d.id);\r
+ assertEquals(data.type,d.type);\r
+ assertEquals(data.cred,d.cred);\r
+ assertEquals(data.expires,d.expires);\r
+ }\r
+\r
+}\r