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
69 public void testStub() throws IOException {
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");
80 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
84 long lng = 1823286886660L;
85 //ads.open(trans, lng);
90 public void testClose() throws IOException {
91 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
96 public void testReuse() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
98 AbsDataStub ads = new AbsDataStub(keyfile, character, 0, 0);
99 Reuse reuse = ads.reuse();
101 Assert.assertEquals("", reuse.at(1));
102 Assert.assertNull(reuse.next());
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