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.auth.local.test;
24 import static org.junit.Assert.*;
26 import org.junit.Test;
27 import org.mockito.Mock;
28 import org.mockito.Mockito;
29 import org.onap.aaf.auth.env.AuthzTrans;
30 import org.onap.aaf.auth.env.AuthzTransFilter;
31 import org.onap.aaf.auth.local.AbsData;
32 import org.onap.aaf.auth.local.DataFile;
33 import org.onap.aaf.auth.local.TextIndex;
34 import org.onap.aaf.auth.local.AbsData.Iter;
35 import org.onap.aaf.auth.local.AbsData.Reuse;
37 import junit.framework.Assert;
39 import static org.junit.Assert.*;
40 import static org.mockito.Matchers.*;
41 import static org.mockito.Mockito.*;
43 import java.io.BufferedWriter;
45 import java.io.FileOutputStream;
46 import java.io.IOException;
47 import java.io.OutputStreamWriter;
48 import java.lang.reflect.InvocationTargetException;
49 import java.lang.reflect.Method;
50 import java.security.Principal;
52 public class JU_AbsData {
54 String filePath = "test/output_.key";
55 File keyfile = new File(filePath);
56 AuthzTrans trans = mock(AuthzTrans.class);
58 private class AbsDataStub extends AbsData {
61 public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) {
62 super(dataf, sepChar, maxLineSize, fieldOffset);
63 // TODO Auto-generated constructor stub
70 public void testStub() throws IOException {
72 String filePath = "test/output_.key";
73 File keyfile = new File(filePath);
74 FileOutputStream is = new FileOutputStream(keyfile);
75 OutputStreamWriter osw = new OutputStreamWriter(is);
76 BufferedWriter w = new BufferedWriter(osw);
77 for (int i = 0; i< 10; i++) { //Write lines to file
78 w.write("a\nsdfasdfxasdf" + i + "\n");
81 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
85 long lng = 1823286886660L;
86 //ads.open(trans, lng);
91 public void testClose() throws IOException {
92 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
97 public void testReuse() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
99 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
100 Reuse reuse = ads.reuse();
102 Assert.assertEquals("", reuse.at(1));
103 Assert.assertNull(reuse.next());
110 public void testIter() throws IOException {
111 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
112 TextIndex textIndex = new TextIndex(keyfile);
113 //Iter iter = ads.iterator(); //Need actual input to run textIndex.create to have a datafile to read