Remove spaces from dockerbuild script
[aaf/authz.git] / auth / auth-cass / src / test / java / com / att / dao / aaf / test / JU_CacheInfoDAO.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
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
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
23 package com.att.dao.aaf.test;
24
25 import java.io.IOException;
26 import java.util.Date;
27
28 import org.junit.Test;
29 import org.onap.aaf.auth.dao.CIDAO;
30 import org.onap.aaf.auth.dao.DAOException;
31 import org.onap.aaf.auth.dao.cass.CacheInfoDAO;
32 import org.onap.aaf.auth.dao.cass.RoleDAO;
33 import org.onap.aaf.auth.dao.cass.Status;
34 import org.onap.aaf.auth.env.AuthzTrans;
35 import org.onap.aaf.auth.layer.Result;
36 import org.onap.aaf.misc.env.APIException;
37 import org.onap.aaf.misc.env.util.Chrono;
38
39 import junit.framework.Assert;
40
41
42 public class JU_CacheInfoDAO extends AbsJUCass {
43
44         @Test
45         public void test() throws DAOException, APIException, IOException {
46                 CIDAO<AuthzTrans> id = new CacheInfoDAO(trans, cluster, AUTHZ);
47                 Date date  = new Date();
48                 
49                 id.touch(trans, RoleDAO.TABLE,1);
50                 try {
51                         Thread.sleep(3000);
52                 } catch (InterruptedException e) {
53                 }
54                 Result<Void> rid = id.check(trans);
55                 Assert.assertEquals(rid.status,Status.OK);
56                 Date[] dates = CacheInfoDAO.info.get(RoleDAO.TABLE);
57                 if(dates.length>0 && dates[1]!=null) {
58                         System.out.println(Chrono.dateStamp(dates[1]));
59                         System.out.println(Chrono.dateStamp(date));
60                         Assert.assertTrue(Math.abs(dates[1].getTime() - date.getTime())<20000); // allow for 4 seconds, given Remote DB
61                 }
62         }
63
64 }