Mass removal of all Tabs (Style Warnings)
[aaf/authz.git] / auth / auth-core / src / test / java / org / onap / aaf / auth / local / test / JU_AbsData.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 package org.onap.aaf.auth.local.test;
22
23 import static org.junit.Assert.*;
24
25 import org.junit.Test;
26 import org.mockito.Mock;
27 import org.mockito.Mockito;
28 import org.onap.aaf.auth.env.AuthzTrans;
29 import org.onap.aaf.auth.env.AuthzTransFilter;
30 import org.onap.aaf.auth.local.AbsData;
31 import org.onap.aaf.auth.local.DataFile;
32 import org.onap.aaf.auth.local.TextIndex;
33 import org.onap.aaf.auth.local.AbsData.Iter;
34 import org.onap.aaf.auth.local.AbsData.Reuse;
35
36 import junit.framework.Assert;
37
38 import static org.junit.Assert.*;
39 import static org.mockito.Matchers.*;
40 import static org.mockito.Mockito.*;
41
42 import java.io.BufferedWriter;
43 import java.io.File;
44 import java.io.FileOutputStream;
45 import java.io.IOException;
46 import java.io.OutputStreamWriter;
47 import java.lang.reflect.InvocationTargetException;
48 import java.lang.reflect.Method;
49 import java.security.Principal;
50
51 public class JU_AbsData {
52     char character = 'x';
53     String filePath = "test/output_.key";
54     File keyfile = new File(filePath);
55     AuthzTrans trans = mock(AuthzTrans.class);
56     
57     private class AbsDataStub extends AbsData {
58
59         
60         public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) {
61             super(dataf, sepChar, maxLineSize, fieldOffset);
62             // TODO Auto-generated constructor stub
63             
64         }
65         
66     }
67
68     @Test
69     public void testStub() throws IOException {
70         char character = 'x';
71         String filePath = "test/output_.key";
72         File keyfile = new File(filePath);
73         FileOutputStream is = new FileOutputStream(keyfile);
74         OutputStreamWriter osw = new OutputStreamWriter(is);
75         BufferedWriter  w = new BufferedWriter(osw);
76         for(int i = 0; i< 10; i++) {        //Write lines to file
77             w.write("a\nsdfasdfxasdf" + i + "\n");
78         }
79         w.close();
80         AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
81         ads.skipLines(0);
82         ads.name();
83         
84         long lng = 1823286886660L;
85         //ads.open(trans, lng);
86         keyfile.delete();
87     }
88     
89     @Test
90     public void testClose() throws IOException {
91         AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
92         ads.close(trans);
93     }
94     
95     @Test
96     public void testReuse() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
97         char character = 'x';
98         AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
99         Reuse reuse = ads.reuse();
100         reuse.reset();
101         Assert.assertEquals("", reuse.at(1));
102         Assert.assertNull(reuse.next());
103         //reuse.atToEnd(0);
104         //reuse.pos(10);
105         keyfile.delete();
106     }
107     
108     @Test
109     public void testIter() throws IOException {
110         AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
111         TextIndex textIndex = new TextIndex(keyfile);
112         //Iter iter = ads.iterator();        //Need actual input to run textIndex.create to have a datafile to read
113
114     }
115
116 }