Remove spaces from dockerbuild script
[aaf/authz.git] / auth / auth-cass / src / test / java / org / onap / aaf / auth / dao / aaf / test / JU_FastCalling.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
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
10  * * 
11  *  *      http://www.apache.org/licenses/LICENSE-2.0
12  * * 
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====================================================
19  * *
20  * *
21  ******************************************************************************/
22 package org.onap.aaf.auth.dao.aaf.test;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertTrue;
26
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;
32
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;
38
39 public class JU_FastCalling extends AbsJUCass {
40
41         @Test
42         public void test() throws IOException, NoSuchAlgorithmException, APIException {
43                 trans.setProperty("cassandra.writeConsistency.cred","ONE");
44                 
45                 CredDAO udao = new CredDAO(env.newTransNoAvg(),cluster,"authz");
46                 System.out.println("Starting calls");
47                 for(iterations=0;iterations<8;++iterations) {
48                         try {
49                                 // Create
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);
56                                 
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) {
61                                         checkData1(data,d);
62                                 }
63                                 
64                                 // Update
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) {
70                                         checkData1(data,d);
71                                 }                       
72                                 
73                                 udao.delete(trans,data, true);
74                         } finally {
75                                 updateTotals();
76                                 newTrans();
77                         }
78                 }
79
80         }
81
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);
87         }
88
89 }