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 java.io.IOException;
25 import java.util.Date;
27 import org.junit.Test;
28 import org.onap.aaf.auth.dao.CIDAO;
29 import org.onap.aaf.auth.dao.DAOException;
30 import org.onap.aaf.auth.dao.cass.CacheInfoDAO;
31 import org.onap.aaf.auth.dao.cass.RoleDAO;
32 import org.onap.aaf.auth.dao.cass.Status;
33 import org.onap.aaf.auth.env.AuthzTrans;
34 import org.onap.aaf.auth.layer.Result;
35 import org.onap.aaf.misc.env.APIException;
36 import org.onap.aaf.misc.env.util.Chrono;
38 import junit.framework.Assert;
41 public class JU_CacheInfoDAO extends AbsJUCass {
44 public void test() throws DAOException, APIException, IOException {
45 CIDAO<AuthzTrans> id = new CacheInfoDAO(trans, cluster, AUTHZ);
46 Date date = new Date();
48 id.touch(trans, RoleDAO.TABLE,1);
51 } catch (InterruptedException e) {
53 Result<Void> rid = id.check(trans);
54 Assert.assertEquals(rid.status,Status.OK);
55 Date[] dates = CacheInfoDAO.info.get(RoleDAO.TABLE);
56 if(dates.length>0 && dates[1]!=null) {
57 System.out.println(Chrono.dateStamp(dates[1]));
58 System.out.println(Chrono.dateStamp(date));
59 Assert.assertTrue(Math.abs(dates[1].getTime() - date.getTime())<20000); // allow for 4 seconds, given Remote DB