001: package com.sun.portal.fabric.upgrade.test;
002:
003: import junit.framework.*;
004: import com.sun.portal.fabric.upgrade.UpgradeUtils;
005: import com.sun.portal.fabric.upgrade.UpgradeConstants;
006: import com.sun.portal.fabric.upgrade.UpgradeException;
007: import com.sun.portal.fabric.util.FileUtil;
008: import com.sun.portal.fabric.util.ExecuteUtil;
009:
010: import java.io.File;
011: import java.util.Properties;
012: import java.util.logging.Logger;
013:
014: public class UpgradeUtilsTest extends TestCase {
015: UpgradeUtils upgradeUtils;
016:
017: public void testAnything() {
018: Properties p = new Properties();
019: boolean PORTAL_INSTALLED = true;
020: p.setProperty("PORTAL_INSTALLED", "" + PORTAL_INSTALLED);
021: if (p.getProperty("PORTAL_INSTALLED").equalsIgnoreCase("true"))
022: System.out.print("ok");
023: }
024:
025: public void testCopyAllAMFilesToVarTmpPortal() throws Exception {
026: System.out.println("Test File copy operation.");
027: System.out.println("List of Files in PS631 directory:");
028: String[] resDirs631 = UpgradeConstants.RESOURCE_DIRS_PS631;
029:
030: String[] flist = null;
031: flist = UpgradeUtils.returnFileListEndingWith(resDirs631[0],
032: null, ".xml");
033: if (flist != null)
034: for (int i = 0; i < flist.length; i++)
035: System.out.println("File in resource dir " + flist[i]);
036:
037: System.out.println();
038: //Method to test.
039: upgradeUtils.copyAllAMFilesToVarTmpPortal(resDirs631);
040:
041: String portalUpgradeTmpDir = UpgradeConstants.SOLARIS_TMP_DIR
042: + File.separator
043: + "portal"
044: + File.separator
045: + resDirs631[0].substring(resDirs631[0]
046: .lastIndexOf(File.separator) + 1, resDirs631[0]
047: .length());
048: flist = UpgradeUtils.returnFileListEndingWith(
049: portalUpgradeTmpDir, null, ".xml");
050: if (flist != null)
051: for (int i = 0; i < flist.length; i++)
052: System.out.println("File in " + portalUpgradeTmpDir
053: + " is " + flist[i]);
054: }
055:
056: public void testReturnFileListHavingPattern() throws Exception {
057: String[] flist = null;
058: flist = UpgradeUtils
059: .returnFileListEndingWith(".", null, ".xml");
060: if (flist != null)
061: System.out.println("Files count=" + flist.length);
062:
063: flist = new File(".").list();
064: for (int i = 0; i < flist.length; i++)
065: System.out.println(flist[i]);
066: System.out.println(new File(".").getAbsolutePath());
067: }
068:
069: /**
070: * This Test case verifies that for a given upgrade scenario, whether DP updates processing is Fine.
071: * Example here is for PS6.3.1-->PS7.1 upgrade
072: * @throws Exception
073: * @throws UpgradeException
074: */
075: public void testExecuteDesktopProfileUpdates631To71()
076: throws Exception, UpgradeException {
077: //Print the Test Case name for diagonistic purposes.
078: System.out
079: .println("Test case description : DP Updates for PS6.3.1-->PS7.1 upgrade");
080:
081: //Create a Properties object we want to past to the executeDesktopProfileUpdates method.
082: Properties props = new Properties();
083:
084: //These are the directories to Scan for DPChanges.txt for PS6.3.1-->PS7.1 upgrade.
085: String[] resDirs631 = { "meta/psupgrade/ps631",
086: "meta/psupgrade/ps70" };
087:
088: //This is required. Otherwise an exception is thrown.
089: //TODO: The Logger Actually should be PortalLogger with a well defined FileHandler.
090: UpgradeUtils.setLogger(Logger
091: .getLogger("UpgradeUtilsTest.class"));
092:
093: //Print the current directory for diagonistic purposes.
094: System.out.println("Current Directory is : " + new File("."));
095: //Print the Resource directories for diagonistic purposes.
096: for (int i = 0; i < resDirs631.length; i++) {
097: File f = new File(resDirs631[i]);
098: if (f.exists()) {
099: System.out
100: .println("Upgrade resource directory complete path now is: "
101: + f.getAbsolutePath());
102: } else {
103: fail("Upgrade resource directory "
104: + f.getAbsolutePath()
105: + " does not exist!"
106: + "Make sure the test infrastructure is Setup properly.");
107: }
108: }
109:
110: //Now test the case.
111: try {
112: UpgradeUtils
113: .executeDesktopProfileUpdates(props, resDirs631);
114: } catch (Exception e) {
115: fail("DP updates processing failed for PS6.3.1-->PS7.1 with Exception!\n"
116: + e);
117: }
118: }
119:
120: /**
121: * This Test case verifies that for a given upgrade scenario, whether AccessManager updates processing is Fine.
122: * Example here is for PS6.3.1-->PS7.1 upgrade
123: *
124: */
125: public void testExecuteAccessManager631Updates() {
126: //Create a Properties object we want to past to the executeAccessManagerUpdates method.
127: Properties props = new Properties();
128: props.setProperty("PORTAL_INSTALLED", "true");
129: props.setProperty("ORG_DN", "dc=india,dc=sun,dc=com");
130: props.setProperty("AM_BASEDIR", "/opt");
131: props.setProperty("AM_PRODUCT_DIR", "SUNWam");
132: props.setProperty("ADMIN_DN", "amadmin");
133: props.setProperty("IDSAME_ADMIN_PASSWORD", "ampassword");
134: props.setProperty("DS_HOST", "dagarwal.india.sun.com");
135: props.setProperty("DS_PORT", "389");
136: props.setProperty("DS_DIRMGR_DN", "cn=Directory Manager");
137: props.setProperty("DS_DIRMGR_PASSWORD", "dmpassword");
138:
139: String[] resDirs631 = { "meta/psupgrade/ps631",
140: "meta/psupgrade/ps70" };
141: UpgradeUtils.setLogger(Logger
142: .getLogger("UpgradeUtilsTest.class"));
143: UpgradeUtils.setExecUtil(new ExecuteUtil());
144:
145: //Print the current directory for diagonistic purposes.
146: System.out.println("Current Directory is : " + new File("."));
147: //Print the Resource directories for diagonistic purposes.
148: for (int i = 0; i < resDirs631.length; i++) {
149: File f = new File(resDirs631[i]);
150: if (f.exists()) {
151: System.out
152: .println("Upgrade resource directory complete path now is: "
153: + f.getAbsolutePath());
154: } else {
155: fail("Upgrade resource directory "
156: + f.getAbsolutePath()
157: + " does not exist!"
158: + "Make sure the test infrastructure is Setup properly.");
159: }
160: }
161:
162: //Now test the case.
163: try {
164: UpgradeUtils.executeAccessManagerUpdates(props, resDirs631);
165: } catch (UpgradeException e) {
166: fail("AM updates failed for PS6.3.1-->PS7.1 with Exception!\n"
167: + e);
168: }
169: }
170:
171: }
|