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