1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  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,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package complex.passwordcontainer;
25 
26 import com.sun.star.task.UserRecord;
27 
28 // import share.LogWriter;
29 
30 public class TestHelper {
31     // LogWriter m_aLogWriter;
32     String m_sTestPrefix;
33 
TestHelper( String sTestPrefix )34     public TestHelper(  String sTestPrefix ) {
35         // m_aLogWriter = aLogWriter;
36         m_sTestPrefix = sTestPrefix;
37     }
38 
Error( String sError )39     public void Error( String sError ) {
40         System.out.println( m_sTestPrefix + "Error: " + sError );
41     }
42 
Message( String sMessage )43     public void Message( String sMessage ) {
44         System.out.println( m_sTestPrefix + sMessage );
45     }
46 
sameLists(UserRecord aUserList1[], UserRecord aUserList2[])47     public boolean sameLists(UserRecord aUserList1[], UserRecord aUserList2[]) {
48         // only works when every name is unique within the list containing it
49 
50         if(aUserList1.length != aUserList2.length) {
51             Message("User list lengths: " + aUserList1.length + " <--> " + aUserList2.length + " respectively ");
52             return false;
53         }
54 
55         for(int i = 0; i < aUserList1.length; i++) {
56             int j;
57             for(j = 0; j < aUserList2.length; j++) {
58                 if(!aUserList1[i].UserName.equals(aUserList2[j].UserName))
59                 {
60                     continue;
61                 }
62                 if(aUserList1[i].Passwords[0].equals(aUserList2[j].Passwords[0])) {
63                     break;
64                 }
65             }
66             if(j == aUserList2.length) {
67                 for(int k = 0; k < aUserList1.length; k++) {
68                     Message(aUserList1[k].UserName + " <--> " + aUserList2[i].UserName);
69                 }
70                 return false;
71             }
72         }
73         return true;
74     }
75 }
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87