AT&T 2.0.19 Code drop, stage 2
[aaf/authz.git] / cadi / aaf / src / test / java / org / onap / aaf / cadi / oauth / test / JU_OAuthToken.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 package org.onap.aaf.cadi.oauth.test;
23
24 import static org.junit.Assert.*;
25
26 import java.util.UUID;
27
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;
35
36 import junit.framework.Assert;
37
38 public class JU_OAuthToken {
39
40         @BeforeClass
41         public static void setUpBeforeClass() throws Exception {
42         }
43
44         @AfterClass
45         public static void tearDownAfterClass() throws Exception {
46         }
47
48         @Before
49         public void setUp() throws Exception {
50         }
51
52         @After
53         public void tearDown() throws Exception {
54         }
55
56         @Test
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);
63         }
64         
65         @Test
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);
72         }
73
74         @Test
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);
82                 }
83         }
84
85
86 }