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====================================================
23 package com.att.dao.aaf.test;
25 import java.io.IOException;
26 import java.util.Date;
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;
39 import junit.framework.Assert;
42 public class JU_CacheInfoDAO extends AbsJUCass {
45 public void test() throws DAOException, APIException, IOException {
46 CIDAO<AuthzTrans> id = new CacheInfoDAO(trans, cluster, AUTHZ);
47 Date date = new Date();
49 id.touch(trans, RoleDAO.TABLE,1);
52 } catch (InterruptedException e) {
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