001: package com.ibm.emb.junit;
002:
003: import java.io.File;
004: import java.io.IOException;
005: import java.net.MalformedURLException;
006: import java.net.URL;
007:
008: /**
009: * this class provides Helper functionality to prepare comlex media on the test
010: * client for usage in testcases
011: */
012: public class ComplexMediaLocationInfo {
013:
014: protected EMBTestConfiguration tstCfg = null;
015:
016: public static final int MEDIAGPL1 = 1;
017:
018: public static final int MEDIAGPL2 = 2;
019:
020: protected String extension = "";
021:
022: protected int mediaID = 0;
023:
024: URL rootURL = null;
025:
026: File rootFile = null;
027:
028: URL[] childURLs = null;
029:
030: File[] childFiles = null;
031:
032: /**
033: * contructor
034: */
035: public ComplexMediaLocationInfo(int arg1)
036: throws MalformedURLException, IOException {
037: this .tstCfg = EMBTestConfiguration.instance();
038: this .mediaID = arg1;
039: switch (mediaID) {
040: case (MEDIAGPL1):
041: prepareGPL1();
042: break;
043: case (MEDIAGPL2):
044: prepareGPL2();
045: break;
046: default:
047: EMBStaticHelper
048: .testError("no suitable mediaID specified in "
049: + this .getClass().getName());
050: break;
051: }
052:
053: }
054:
055: protected void prepareGPL1() throws MalformedURLException,
056: IOException {
057: rootFile = new File(tstCfg.getMediaDir() + File.separator
058: + tstCfg.getPlaylistName1());
059: File C1 = new File(tstCfg.getMediaDir() + File.separator
060: + "Gpl" + File.separator + "testPlaylist1"
061: + File.separator + "testPlaylist1_1.jpg");
062: File C2 = new File(tstCfg.getMediaDir() + File.separator
063: + "Gpl" + File.separator + "testPlaylist1"
064: + File.separator + "testPlaylist1_2.bmp");
065: File C3 = new File(tstCfg.getMediaDir() + File.separator
066: + "Gpl" + File.separator + "testPlaylist1"
067: + File.separator + "testPlaylist1_3.jpg");
068: this .childFiles = new File[] { C1, C2, C3 };
069: // removce /c:
070: this .rootURL = new URL("file", tstCfg.getTestClientIPAddress(),
071: tstCfg.getMediaDir() + "/" + tstCfg.getPlaylistName1());
072: URL C1Url = new URL("file", tstCfg.getTestClientIPAddress(),
073: tstCfg.getMediaDir()
074: + "/Gpl/testPlaylist1/testPlaylist1_1.jpg");
075: URL C2Url = new URL("file", tstCfg.getTestClientIPAddress(),
076: tstCfg.getMediaDir()
077: + "/Gpl/testPlaylist1/testPlaylist1_2.jpg");
078: URL C3Url = new URL("file", tstCfg.getTestClientIPAddress(),
079: tstCfg.getMediaDir()
080: + "/Gpl/testPlaylist1/testPlaylist1_3.jpg");
081: this .childURLs = new URL[] { C1Url, C2Url, C3Url };
082: this .extension = ".gpl";
083: }
084:
085: protected void prepareGPL2() throws MalformedURLException,
086: IOException {
087: rootFile = new File(tstCfg.getMediaDir() + File.separator
088: + tstCfg.getPlaylistName2());
089: File C1 = new File(tstCfg.getMediaDir() + File.separator
090: + "Gpl" + File.separator + "testPlaylist1"
091: + File.separator + "testPlaylist1_1.jpg");
092:
093: this .childFiles = new File[] { C1 };
094: // removce /c:
095: this .rootURL = new URL("file", tstCfg.getTestClientIPAddress(),
096: tstCfg.getMediaDir() + "/" + tstCfg.getPlaylistName2());
097: URL C1Url = new URL("file", tstCfg.getTestClientIPAddress(),
098: tstCfg.getMediaDir()
099: + "/Gpl/testPlaylist1/testPlaylist1_1.jpg");
100:
101: this .childURLs = new URL[] { C1Url };
102: this .extension = ".gpl";
103: }
104:
105: /**
106: * Gets the rootURL
107: * @return Returns a URL
108: */
109: public URL getRootURL() {
110: return rootURL;
111: }
112:
113: /**
114: * Sets the rootURL
115: * @param rootURL The rootURL to set
116: */
117: public void setRootURL(URL rootURL) {
118: this .rootURL = rootURL;
119: }
120:
121: /**
122: * Gets the rootFile
123: * @return Returns a File
124: */
125: public File getRootFile() {
126: return rootFile;
127: }
128:
129: /**
130: * Sets the rootFile
131: * @param rootFile The rootFile to set
132: */
133: public void setRootFile(File rootFile) {
134: this .rootFile = rootFile;
135: }
136:
137: /**
138: * Gets the extension
139: * @return Returns a String
140: */
141: public String getExtension() {
142: return extension;
143: }
144:
145: /**
146: * Sets the extension
147: * @param extension The extension to set
148: */
149: public void setExtension(String extension) {
150: this .extension = extension;
151: }
152:
153: /**
154: * Gets the childURLs
155: * @return Returns a URL[]
156: */
157: public URL[] getChildURLs() {
158: return childURLs;
159: }
160:
161: /**
162: * Sets the childURLs
163: * @param childURLs The childURLs to set
164: */
165: public void setChildURLs(URL[] childURLs) {
166: this .childURLs = childURLs;
167: }
168:
169: /**
170: * Gets the childFiles
171: * @return Returns a File[]
172: */
173: public File[] getChildFiles() {
174: return childFiles;
175: }
176:
177: /**
178: * Sets the childFiles
179: * @param childFiles The childFiles to set
180: */
181: public void setChildFiles(File[] childFiles) {
182: this.childFiles = childFiles;
183: }
184: }
|