2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package com.att.dao.aaf.test;
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
27 import java.io.IOException;
28 import java.nio.ByteBuffer;
29 import java.security.NoSuchAlgorithmException;
30 import java.util.Date;
31 import java.util.List;
33 import org.junit.Test;
34 import org.onap.aaf.auth.dao.CassAccess;
35 import org.onap.aaf.auth.dao.cass.CredDAO;
36 import org.onap.aaf.auth.dao.cass.CredDAO.Data;
37 import org.onap.aaf.auth.layer.Result;
38 import org.onap.aaf.misc.env.APIException;
40 public class JU_FastCalling extends AbsJUCass {
43 public void test() throws IOException, NoSuchAlgorithmException, APIException {
44 trans.setProperty("cassandra.writeConsistency.cred","ONE");
46 CredDAO udao = new CredDAO(env.newTransNoAvg(),cluster,CassAccess.KEYSPACE);
47 System.out.println("Starting calls");
48 for(iterations=0;iterations<8;++iterations) {
51 CredDAO.Data data = new CredDAO.Data();
52 data.id = "m55555@aaf.att.com";
53 data.type = CredDAO.BASIC_AUTH;
54 data.cred = ByteBuffer.wrap(userPassToBytes("m55555","mypass"));
55 data.expires = new Date(System.currentTimeMillis() + 60000*60*24*90);
56 udao.create(trans,data);
58 // Validate Read with key fields in Data
59 Result<List<CredDAO.Data>> rlcd = udao.read(trans,data);
60 assertTrue(rlcd.isOKhasData());
61 for(CredDAO.Data d : rlcd.value) {
66 data.cred = ByteBuffer.wrap(userPassToBytes("m55555","mynewpass"));
67 udao.update(trans,data);
68 rlcd = udao.read(trans,data);
69 assertTrue(rlcd.isOKhasData());
70 for(CredDAO.Data d : rlcd.value) {
74 udao.delete(trans,data, true);
83 private void checkData1(Data data, Data d) {
84 assertEquals(data.id,d.id);
85 assertEquals(data.type,d.type);
86 assertEquals(data.cred,d.cred);
87 assertEquals(data.expires,d.expires);