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