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====================================================
22 package org.onap.aaf.cadi.oauth.test;
24 import static org.junit.Assert.*;
26 import java.util.UUID;
28 import org.junit.After;
29 import org.junit.AfterClass;
30 import org.junit.Before;
31 import org.junit.BeforeClass;
32 import org.junit.Test;
33 import org.onap.aaf.cadi.CadiException;
34 import org.onap.aaf.cadi.oauth.AAFToken;
36 import junit.framework.Assert;
38 public class JU_OAuthToken {
41 public static void setUpBeforeClass() throws Exception {
45 public static void tearDownAfterClass() throws Exception {
49 public void setUp() throws Exception {
53 public void tearDown() throws Exception {
57 public void testMax() throws CadiException {
58 UUID uuid = new UUID(Long.MAX_VALUE,Long.MAX_VALUE);
59 String token = AAFToken.toToken(uuid);
60 System.out.println(token);
61 UUID uuid2 = AAFToken.fromToken(token);
62 Assert.assertEquals(uuid, uuid2);
66 public void testMin() throws CadiException {
67 UUID uuid = new UUID(Long.MIN_VALUE,Long.MIN_VALUE);
68 String token = AAFToken.toToken(uuid);
69 System.out.println(token);
70 UUID uuid2 = AAFToken.fromToken(token);
71 Assert.assertEquals(uuid, uuid2);
75 public void testRandom() throws CadiException {
76 for(int i=0;i<100;++i) {
77 UUID uuid = UUID.randomUUID();
78 String token = AAFToken.toToken(uuid);
79 System.out.println(token);
80 UUID uuid2 = AAFToken.fromToken(token);
81 Assert.assertEquals(uuid, uuid2);