summaryrefslogtreecommitdiff
path: root/svl/qa/complex/passwordcontainer
diff options
context:
space:
mode:
Diffstat (limited to 'svl/qa/complex/passwordcontainer')
-rw-r--r--svl/qa/complex/passwordcontainer/MasterPasswdHandler.java61
-rw-r--r--svl/qa/complex/passwordcontainer/PasswordContainerTest.java36
-rw-r--r--svl/qa/complex/passwordcontainer/PasswordContainerUnitTest.java77
-rw-r--r--svl/qa/complex/passwordcontainer/Test01.java115
-rw-r--r--svl/qa/complex/passwordcontainer/Test02.java159
-rw-r--r--svl/qa/complex/passwordcontainer/Test03.java122
-rw-r--r--svl/qa/complex/passwordcontainer/TestHelper.java92
-rw-r--r--svl/qa/complex/passwordcontainer/makefile.mk91
8 files changed, 753 insertions, 0 deletions
diff --git a/svl/qa/complex/passwordcontainer/MasterPasswdHandler.java b/svl/qa/complex/passwordcontainer/MasterPasswdHandler.java
new file mode 100644
index 000000000000..bf6159ee38c5
--- /dev/null
+++ b/svl/qa/complex/passwordcontainer/MasterPasswdHandler.java
@@ -0,0 +1,61 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author zxf
+ */
+
+package complex.passwordcontainer;
+
+import com.sun.star.lib.uno.helper.WeakBase;
+import com.sun.star.task.XInteractionContinuation;
+import com.sun.star.ucb.XInteractionSupplyAuthentication;
+import com.sun.star.task.XInteractionRequest;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.task.MasterPasswordRequest;
+import com.sun.star.uno.UnoRuntime;
+
+public class MasterPasswdHandler extends WeakBase
+ implements XInteractionHandler {
+ XInteractionHandler m_xHandler;
+
+ public MasterPasswdHandler( XInteractionHandler xHandler ) {
+ m_xHandler = xHandler;
+ }
+
+ public void handle( XInteractionRequest xRequest ) {
+ try {
+ MasterPasswordRequest aMasterPasswordRequest;
+ if( xRequest.getRequest() instanceof MasterPasswordRequest ) {
+ aMasterPasswordRequest = (MasterPasswordRequest)xRequest.getRequest();
+ if( aMasterPasswordRequest != null ) {
+ XInteractionContinuation xContinuations[] = xRequest.getContinuations();
+ XInteractionSupplyAuthentication xAuthentication = null;
+
+ for( int i = 0; i < xContinuations.length; ++i ) {
+ xAuthentication = (XInteractionSupplyAuthentication)UnoRuntime.queryInterface( XInteractionSupplyAuthentication.class, xContinuations[i]);
+ if( xAuthentication != null )
+ break;
+ }
+ if( xAuthentication.canSetPassword() )
+ xAuthentication.setPassword( "abcdefghijklmnopqrstuvwxyz123456" );
+ xAuthentication.select();
+ }
+ } else {
+ m_xHandler.handle( xRequest );
+ }
+ } catch( Exception e ) {
+ System.out.println( "MasterPasswordHandler Error: " + e );
+ }
+ }
+}
+
+
+
+
+
+
+
diff --git a/svl/qa/complex/passwordcontainer/PasswordContainerTest.java b/svl/qa/complex/passwordcontainer/PasswordContainerTest.java
new file mode 100644
index 000000000000..5da0676f8bb9
--- /dev/null
+++ b/svl/qa/complex/passwordcontainer/PasswordContainerTest.java
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: PasswordContainerTest.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package complex.passwordcontainer;
+
+public interface PasswordContainerTest {
+ boolean test();
+}
diff --git a/svl/qa/complex/passwordcontainer/PasswordContainerUnitTest.java b/svl/qa/complex/passwordcontainer/PasswordContainerUnitTest.java
new file mode 100644
index 000000000000..aee1c9355a3f
--- /dev/null
+++ b/svl/qa/complex/passwordcontainer/PasswordContainerUnitTest.java
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: PasswordContainerUnitTest.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package complex.passwordcontainer;
+
+import complexlib.ComplexTestCase;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class PasswordContainerUnitTest extends ComplexTestCase {
+ private XMultiServiceFactory m_xMSF = null;
+
+ public String[] getTestMethodNames() {
+ return new String[] {
+ "ExecuteTest01",
+ "ExecuteTest02",
+ "ExecuteTest03"};
+ }
+ public String getTestObjectName() {
+ return "PasswordContainerUnitTest";
+ }
+
+ public void before() {
+ try {
+ m_xMSF = (XMultiServiceFactory) param.getMSF();
+ } catch (Exception e) {
+ failed ("Cannot create service factory!");
+ }
+ if (m_xMSF == null) {
+ failed ("Cannot create service factory!");
+ }
+ }
+
+ public void after() {
+ m_xMSF = null;
+ }
+
+ public void ExecuteTest01() {
+ PasswordContainerTest aTest = new Test01(m_xMSF, log);
+ assure("Test01 failed!", aTest.test());
+ }
+ public void ExecuteTest02() {
+ PasswordContainerTest aTest = new Test02(m_xMSF, log);
+ assure("Test02 failed!", aTest.test());
+ }
+ public void ExecuteTest03() {
+ PasswordContainerTest aTest = new Test03(m_xMSF, log);
+ assure("Test03 failed!", aTest.test());
+ }
+}
diff --git a/svl/qa/complex/passwordcontainer/Test01.java b/svl/qa/complex/passwordcontainer/Test01.java
new file mode 100644
index 000000000000..6de96de05ec9
--- /dev/null
+++ b/svl/qa/complex/passwordcontainer/Test01.java
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Test01.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package complex.passwordcontainer;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.task.XPasswordContainer;
+import com.sun.star.task.UrlRecord;
+import com.sun.star.task.UserRecord;
+import com.sun.star.task.XMasterPasswordHandling;
+
+import com.sun.star.uno.UnoRuntime;
+
+import share.LogWriter;
+
+public class Test01 implements PasswordContainerTest {
+ XMultiServiceFactory m_xMSF = null;
+ XPasswordContainer m_xPasswordContainer = null;
+ TestHelper m_aTestHelper = null;
+
+ public Test01 ( XMultiServiceFactory xMSF, LogWriter aLogWriter )
+ {
+ m_xMSF = xMSF;
+ m_aTestHelper = new TestHelper (aLogWriter, "Test01: ");
+ }
+
+ public boolean test() {
+ final String sURL = "http://www.openoffice.org";
+ final String sUserPre = "OOoUser";
+ final String sPwdPre = "Password";
+ final int iUserNum1 = 10;
+ final int iUserNum2 = 5;
+
+ UserRecord aInputUserList1[] = new UserRecord[iUserNum1];
+ for(int i = 0; i < iUserNum1; i++) {
+ String sTemp[] = {sPwdPre + "_1_" + i}; // currently one password for one user
+ aInputUserList1[i] = new UserRecord(sUserPre + "_1_" + i, sTemp);
+ }
+ UserRecord aInputUserList2[] = new UserRecord[iUserNum2];
+ for(int i = 0; i < iUserNum2; i++) {
+ String sTemp[] = {sPwdPre + "_2_" + i};
+ aInputUserList2[i] = new UserRecord(sUserPre + "_2_" + i, sTemp);
+ }
+ try {
+ Object oPasswordContainer = m_xMSF.createInstance( "com.sun.star.task.PasswordContainer" );
+ XPasswordContainer xContainer = (XPasswordContainer)UnoRuntime.queryInterface(XPasswordContainer.class, oPasswordContainer);
+ Object oHandler = m_xMSF.createInstance( "com.sun.star.task.InteractionHandler" );
+ XInteractionHandler xHandler = (XInteractionHandler)UnoRuntime.queryInterface(XInteractionHandler.class, oHandler);
+ MasterPasswdHandler aMHandler = new MasterPasswdHandler( xHandler );
+
+ // add a set of users and passwords for the same URL for runtime
+ for(int i = 0; i < iUserNum1; i++) {
+ xContainer.add(sURL, aInputUserList1[i].UserName, aInputUserList1[i].Passwords, aMHandler);
+ }
+ for (int i = 0; i < iUserNum2; i++) {
+ xContainer.add(sURL, aInputUserList2[i].UserName, aInputUserList2[i].Passwords, aMHandler);
+ }
+
+ // remove some of the passwords
+ for (int i = 0; i < iUserNum1; i++) {
+ xContainer.remove(sURL, aInputUserList1[i].UserName);
+ }
+
+ // get the result and check it with the expected one
+ UrlRecord aRecord = xContainer.find(sURL, aMHandler);
+ if(!aRecord.Url.equals(sURL)) {
+ m_aTestHelper.Error("URL mismatch. Got " + aRecord.Url + "; should be " + sURL);
+ return false;
+ }
+ if(!m_aTestHelper.sameLists(aRecord.UserList, aInputUserList2)) {
+ m_aTestHelper.Error("User list is not the expected");
+ return false;
+ }
+
+ // remove the runtime passwords
+ aRecord = xContainer.find(sURL, aMHandler);
+ for(int i = 0; i < aRecord.UserList.length; i++) {
+ xContainer.remove(sURL, aRecord.UserList[i].UserName);
+ }
+ } catch(Exception e) {
+ m_aTestHelper.Error("Exception: " + e);
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/svl/qa/complex/passwordcontainer/Test02.java b/svl/qa/complex/passwordcontainer/Test02.java
new file mode 100644
index 000000000000..5d65d8090cf9
--- /dev/null
+++ b/svl/qa/complex/passwordcontainer/Test02.java
@@ -0,0 +1,159 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Test02.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package complex.passwordcontainer;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.task.XPasswordContainer;
+import com.sun.star.task.XMasterPasswordHandling;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.task.UrlRecord;
+import com.sun.star.task.UserRecord;
+
+import com.sun.star.uno.UnoRuntime;
+
+import share.LogWriter;
+
+public class Test02 implements PasswordContainerTest {
+ XMultiServiceFactory m_xMSF = null;
+ XPasswordContainer m_xPasswordContainer = null;
+ TestHelper m_aTestHelper = null;
+
+ public Test02 ( XMultiServiceFactory xMSF, LogWriter aLogWriter )
+ {
+ m_xMSF = xMSF;
+ m_aTestHelper = new TestHelper (aLogWriter, "Test02: ");
+ }
+
+ public boolean test() {
+ final String sURL = "http://www.openoffice.org";
+ final String sUserPre = "OOoUser";
+ final String sPwdPre = "Password";
+ final int iUserNum1 = 10;
+ final int iUserNum2 = 5;
+
+ UserRecord aInputUserList1[] = new UserRecord[iUserNum1];
+ for(int i = 0; i < iUserNum1; i++) {
+ String sTemp[] = {sPwdPre + "_1_" + i}; // currently one password for one user
+ aInputUserList1[i] = new UserRecord(sUserPre + "_1_" + i, sTemp);
+ }
+ UserRecord aInputUserList2[] = new UserRecord[iUserNum2];
+ for(int i = 0; i < iUserNum2; i++) {
+ String sTemp[] = {sPwdPre + "_2_" + i};
+ aInputUserList2[i] = new UserRecord(sUserPre + "_2_" + i, sTemp);
+ }
+
+ try {
+ Object oPasswordContainer = m_xMSF.createInstance("com.sun.star.task.PasswordContainer");
+ XPasswordContainer xContainer = (XPasswordContainer)UnoRuntime.queryInterface(XPasswordContainer.class, oPasswordContainer);
+ Object oHandler = m_xMSF.createInstance("com.sun.star.task.InteractionHandler");
+ XInteractionHandler xHandler = (XInteractionHandler)UnoRuntime.queryInterface(XInteractionHandler.class, oHandler);
+ MasterPasswdHandler aMHandler = new MasterPasswdHandler(xHandler);
+ XMasterPasswordHandling xMHandling = (XMasterPasswordHandling)UnoRuntime.queryInterface(XMasterPasswordHandling.class, oPasswordContainer);
+
+ // allow the storing of the passwords
+ xMHandling.allowPersistentStoring(true);
+
+ // add a set of users and passwords for the same URL persistently
+ for(int i = 0; i < iUserNum1; ++i) {
+ xContainer.addPersistent(sURL, aInputUserList1[i].UserName, aInputUserList1[i].Passwords, aMHandler);
+ }
+ for(int i = 0; i < iUserNum2; ++i) {
+ xContainer.addPersistent(sURL, aInputUserList2[i].UserName, aInputUserList2[i].Passwords, aMHandler);
+ }
+
+ // remove some of the passwords
+ for(int i = 0; i < iUserNum1; ++i) {
+ xContainer.remove(sURL, aInputUserList1[i].UserName);
+ }
+
+ // get the result with find() and check it with the expected one
+ UrlRecord aRecord = xContainer.find(sURL, aMHandler);
+ if(!aRecord.Url.equals(sURL)) {
+ m_aTestHelper.Error("URL mismatch. Got " + aRecord.Url + "; should be " + sURL);
+ return false;
+ }
+ if(!m_aTestHelper.sameLists(aRecord.UserList, aInputUserList2)) {
+ m_aTestHelper.Error("User list is not the expected");
+ return false;
+ }
+
+ // get the result with getAllPersistent() and check
+ UrlRecord aRecords[] = xContainer.getAllPersistent(aMHandler);
+ if(!aRecords[0].Url.equals(sURL)) {
+ m_aTestHelper.Error("URL mismatch");
+ return false;
+ }
+ if(!m_aTestHelper.sameLists(aRecords[0].UserList, aInputUserList2)) {
+ m_aTestHelper.Error("User list is not the expected");
+ return false;
+ }
+
+ // remove all the persistent passwords
+ xContainer.removeAllPersistent();
+
+ // remove the runtime passwords
+ for(int i = 0; i < aRecords[0].UserList.length; ++i) {
+ xContainer.remove(sURL, aRecords[0].UserList[i].UserName);
+ }
+
+ // disallow the storing of the passwords
+ xMHandling.allowPersistentStoring(false);
+ } catch(Exception e) {
+ m_aTestHelper.Error("Exception: " + e);
+ return false;
+ }
+ return true;
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svl/qa/complex/passwordcontainer/Test03.java b/svl/qa/complex/passwordcontainer/Test03.java
new file mode 100644
index 000000000000..69de8b88578b
--- /dev/null
+++ b/svl/qa/complex/passwordcontainer/Test03.java
@@ -0,0 +1,122 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: Test03.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package complex.passwordcontainer;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.task.UrlRecord;
+import com.sun.star.task.UserRecord;
+import com.sun.star.task.XPasswordContainer;
+import com.sun.star.task.XMasterPasswordHandling;
+import com.sun.star.task.XInteractionHandler;
+
+
+import com.sun.star.uno.UnoRuntime;
+import share.LogWriter;
+
+public class Test03 implements PasswordContainerTest {
+ XMultiServiceFactory m_xMSF = null;
+ XPasswordContainer m_xPasswordContainer = null;
+ TestHelper m_aTestHelper = null;
+
+ public Test03 ( XMultiServiceFactory xMSF, LogWriter aLogWriter )
+ {
+ m_xMSF = xMSF;
+ m_aTestHelper = new TestHelper (aLogWriter, "Test03: ");
+ }
+
+ public boolean test() {
+ final String sURL = "http://www.openoffice.org";
+ final String sUserPre = "OOoUser";
+ final String sPwdPre = "Password";
+ final int iPersistentUserNum = 10;
+ final int iRuntimeUserNum = 5;
+
+ UserRecord aInputUserList[] = new UserRecord[iPersistentUserNum+iRuntimeUserNum];
+ for(int i = 0; i < iPersistentUserNum; i++) {
+ String sTemp[] = {sPwdPre + "_1_" + i}; // currently one password for one user
+ aInputUserList[i] = new UserRecord(sUserPre + "_1_" + i, sTemp);
+ }
+ for(int i = 0; i < iRuntimeUserNum; i++) {
+ String sTemp[] = {sPwdPre + "_2_" + i};
+ aInputUserList[i+iPersistentUserNum] = new UserRecord(sUserPre + "_2_" + i, sTemp);
+ }
+
+ try {
+ Object oPasswordContainer = m_xMSF.createInstance("com.sun.star.task.PasswordContainer");
+ XPasswordContainer xContainer = (XPasswordContainer)UnoRuntime.queryInterface(XPasswordContainer.class, oPasswordContainer);
+ Object oHandler = m_xMSF.createInstance("com.sun.star.task.InteractionHandler");
+ XInteractionHandler xHandler = (XInteractionHandler)UnoRuntime.queryInterface(XInteractionHandler.class, oHandler);
+ MasterPasswdHandler aMHandler = new MasterPasswdHandler(xHandler);
+ XMasterPasswordHandling xMHandling = (XMasterPasswordHandling)UnoRuntime.queryInterface(XMasterPasswordHandling.class, oPasswordContainer);
+
+ // allow the storing of the passwords
+ xMHandling.allowPersistentStoring(true);
+
+ // add a set of users and passwords for the same URL persistently
+ for(int i = 0; i < iPersistentUserNum; i++) {
+ xContainer.addPersistent(sURL, aInputUserList[i].UserName, aInputUserList[i].Passwords, aMHandler);
+ }
+
+ // add a set of users and passwords for the same URL for runtime
+ for(int i = 0; i < iRuntimeUserNum; i++) {
+ xContainer.add(sURL, aInputUserList[i+iPersistentUserNum].UserName, aInputUserList[i+iPersistentUserNum].Passwords, aMHandler);
+ }
+
+ // get the result for the URL and check that it contains persistent and runtime passwords
+ UrlRecord aRecord = xContainer.find(sURL, aMHandler);
+ if(!aRecord.Url.equals(sURL)) {
+ m_aTestHelper.Error("URL mismatch. Got " + aRecord.Url + "; should be " + sURL);
+ return false;
+ }
+ if(!m_aTestHelper.sameLists(aRecord.UserList, aInputUserList)) {
+ m_aTestHelper.Error("User list is not the expected");
+ return false;
+ }
+
+ // remove all the persistent passwords
+ xContainer.removeAllPersistent();
+
+ // remove the runtime passwords
+ aRecord = xContainer.find(sURL, aMHandler);
+ for(int i = 0; i < aRecord.UserList.length; i++) {
+ xContainer.remove(sURL, aRecord.UserList[i].UserName);
+ }
+
+ // disallow the storing of the passwords
+ xMHandling.allowPersistentStoring(false);
+ }catch(Exception e){
+ m_aTestHelper.Error("Exception: " + e);
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/svl/qa/complex/passwordcontainer/TestHelper.java b/svl/qa/complex/passwordcontainer/TestHelper.java
new file mode 100644
index 000000000000..0f83a9ef9963
--- /dev/null
+++ b/svl/qa/complex/passwordcontainer/TestHelper.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: TestHelper.java,v $
+ *
+ * $Revision: 1.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package complex.passwordcontainer;
+
+import com.sun.star.task.UserRecord;
+
+import share.LogWriter;
+
+public class TestHelper {
+ LogWriter m_aLogWriter;
+ String m_sTestPrefix;
+
+ public TestHelper( LogWriter aLogWriter, String sTestPrefix ) {
+ m_aLogWriter = aLogWriter;
+ m_sTestPrefix = sTestPrefix;
+ }
+
+ public void Error( String sError ) {
+ m_aLogWriter.println( m_sTestPrefix + "Error: " + sError );
+ }
+
+ public void Message( String sMessage ) {
+ m_aLogWriter.println( m_sTestPrefix + sMessage );
+ }
+
+ public boolean sameLists(UserRecord aUserList1[], UserRecord aUserList2[]) {
+ // only works when every name is unique within the list containing it
+
+ if(aUserList1.length != aUserList2.length) {
+ Message("User list lengths: " + aUserList1.length + " <--> " + aUserList2.length + " respectively ");
+ return false;
+ }
+
+ for(int i = 0; i < aUserList1.length; i++) {
+ int j;
+ for(j = 0; j < aUserList2.length; j++) {
+ if(!aUserList1[i].UserName.equals(aUserList2[j].UserName))
+ continue;
+ if(aUserList1[i].Passwords[0].equals(aUserList2[j].Passwords[0])) {
+ break;
+ }
+ }
+ if(j == aUserList2.length) {
+ for(int k = 0; k < aUserList1.length; k++) {
+ Message(aUserList1[k].UserName + " <--> " + aUserList2[i].UserName);
+ }
+ return false;
+ }
+ }
+ return true;
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/svl/qa/complex/passwordcontainer/makefile.mk b/svl/qa/complex/passwordcontainer/makefile.mk
new file mode 100644
index 000000000000..c3ff7538af0f
--- /dev/null
+++ b/svl/qa/complex/passwordcontainer/makefile.mk
@@ -0,0 +1,91 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# $RCSfile: makefile.mk,v $
+#
+# $Revision: 1.2.38.1 $
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = PasswordContainerUnitTest
+PRJNAME=svl
+PACKAGE = complex$/passwordcontainer
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+
+JAVAFILES =\
+ PasswordContainerUnitTest.java\
+ PasswordContainerTest.java\
+ TestHelper.java\
+ Test01.java\
+ Test02.java\
+ Test03.java\
+ MasterPasswdHandler.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# test looks something like the.full.package.TestName
+CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE: target.mk
+
+RUN: run
+
+run:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_APPEXECCOMMAND) $(CT_TEST)
+
+