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====================================================
21 package org.onap.aaf.auth.local.test;
23 import static org.junit.Assert.*;
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;
36 import junit.framework.Assert;
38 import static org.junit.Assert.*;
39 import static org.mockito.Matchers.*;
40 import static org.mockito.Mockito.*;
42 import java.io.BufferedWriter;
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;
51 public class JU_AbsData {
53 String filePath = "test/output_.key";
54 File keyfile = new File(filePath);
55 AuthzTrans trans = mock(AuthzTrans.class);
57 private class AbsDataStub extends AbsData {
60 public AbsDataStub(File dataf, char sepChar, int maxLineSize, int fieldOffset) {
61 super(dataf, sepChar, maxLineSize, fieldOffset);
62 // TODO Auto-generated constructor stub
68 public void testStub() throws IOException {
70 String filePath = "test/output_.key";
71 File keyfile = new File(filePath);
72 FileOutputStream is = new FileOutputStream(keyfile);
73 OutputStreamWriter osw = new OutputStreamWriter(is);
74 BufferedWriter w = new BufferedWriter(osw);
75 for(int i = 0; i< 10; i++) { //Write lines to file
76 w.write("a\nsdfasdfxasdf" + i + "\n");
79 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
83 long lng = 1823286886660L;
84 //ads.open(trans, lng);
89 public void testClose() throws IOException {
90 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
95 public void testReuse() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
97 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
98 Reuse reuse = ads.reuse();
100 Assert.assertEquals("", reuse.at(1));
101 Assert.assertNull(reuse.next());
108 public void testIter() throws IOException {
109 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
110 TextIndex textIndex = new TextIndex(keyfile);
111 //Iter iter = ads.iterator(); //Need actual input to run textIndex.create to have a datafile to read