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 embedded media on the
010: * test Server and abstract over naming for usage in testcases
011: */
012: public class EmbeddedMediaLocationInfo {
013:
014: protected EMBTestConfiguration tstCfg = null;
015:
016: protected String extension = "";
017:
018: protected String mediaName = "";
019:
020: protected URL mediaURL = null;
021:
022: protected File mediaFile = null;
023:
024: /**
025: * contructor
026: */
027: public EmbeddedMediaLocationInfo(String argMediaName)
028: throws MalformedURLException, IOException {
029: this .tstCfg = EMBTestConfiguration.instance();
030: this .mediaName = argMediaName;
031: prepareMedia();
032: }
033:
034: /**
035: *
036: */
037: protected void prepareMedia() throws MalformedURLException,
038: IOException {
039:
040: // remove C:
041: this .mediaFile = new File(tstCfg.getMediaDir() + File.separator
042: + this .mediaName);
043: this .mediaURL = new URL("file",
044: tstCfg.getTestClientIPAddress(), tstCfg.getMediaDir()
045: + "/" + this .mediaName);
046: this .extension = this .mediaName.substring(this .mediaName
047: .lastIndexOf("."));
048:
049: }
050:
051: /**
052: * Gets the mediaFile
053: * @return Returns a File
054: */
055: public File getMediaFile() {
056: return mediaFile;
057: }
058:
059: /**
060: * Sets the mediaFile
061: * @param mediaFile The mediaFile to set
062: */
063: public void setMediaFile(File mediaFile) {
064: this .mediaFile = mediaFile;
065: }
066:
067: /**
068: * Gets the extension
069: * @return Returns a String
070: */
071: public String getExtension() {
072: return extension;
073: }
074:
075: /**
076: * Sets the extension
077: * @param extension The extension to set
078: */
079: public void setExtension(String extension) {
080: this .extension = extension;
081: }
082:
083: /**
084: * Gets the mediaName
085: * @return Returns a String
086: */
087: public String getMediaName() {
088: return mediaName;
089: }
090:
091: /**
092: * Sets the mediaName
093: * @param mediaName The mediaName to set
094: */
095: public void setMediaName(String mediaName) {
096: this .mediaName = mediaName;
097: }
098:
099: /**
100: * Gets the mediaURL
101: * @return Returns a URL
102: */
103: public URL getMediaURL() {
104: return mediaURL;
105: }
106:
107: /**
108: * Sets the mediaURL
109: * @param mediaURL The mediaURL to set
110: */
111: public void setMediaURL(URL mediaURL) {
112: this.mediaURL = mediaURL;
113: }
114:
115: }
|