001: package com.ibm.emb.test.mfb;
002:
003: // java stuff
004: import java.io.File;
005: import java.io.FileInputStream;
006: import java.io.IOException;
007: import java.io.InputStream;
008:
009: import javax.emb.MediaBean;
010: import javax.emb.MediaException;
011: import javax.emb.MediaFormatRegistry;
012: import javax.emb.MediaHeader;
013:
014: import org.objectweb.jonas.emb.mfb.formats.image.BmpFormat;
015: import org.objectweb.jonas.emb.mfb.formats.image.BmpHeader;
016:
017: import com.ibm.emb.junit.EMBTestRunner;
018: import com.ibm.emb.test.MediaHeaderTest;
019:
020: public class BmpHeaderTest extends MediaHeaderTest {
021:
022: public BmpHeaderTest(String name) throws MediaException {
023: super (name);
024: }
025:
026: public static void main(String args[]) {
027: EMBTestRunner.run(BmpHeaderTest.class);
028: }
029:
030: /**
031: * do initialisation here
032: */
033: protected void setUp() {
034: }
035:
036: /**
037: * freeup resources
038: */
039: protected void tearDown() {
040: }
041:
042: /**
043: * creates an instance of BmpHeader with the given Parameters used in super
044: * class of BmpHeaderTest
045: */
046: public MediaHeader createMediaHeader() throws MediaException,
047: IOException {
048:
049: // register media format
050: MediaFormatRegistry formatRegistry = MediaFormatRegistry.SINGLETON;
051: formatRegistry.rebind("bmp", new BmpFormat());
052:
053: // name of a bmp sample
054: String mediaBmp = embTestConfig.getBmpPictureName1();
055:
056: // full path of the bmp sample
057: String mediaBmpFullPath = embTestConfig.getMediaDir()
058: + File.separator + mediaBmp;
059:
060: // creates media bean
061: File mediaBmpFile = new File(mediaBmpFullPath);
062: MediaBean mediaBean = new MediaBean(mediaBmpFile, "bmp");
063:
064: // creates bmp format
065: InputStream mediaBmpInputStream = new FileInputStream(
066: mediaBmpFile);
067: BmpFormat bmpFormat = new BmpFormat();
068: BmpHeader bmpHeader = (BmpHeader) bmpFormat
069: .extractHeader(mediaBmpInputStream);
070: mediaBmpInputStream.close();
071:
072: return bmpHeader;
073:
074: }
075:
076: /**
077: * <pre>
078: *
079: *
080: *
081: * Testcase Name: getField(String)
082: * Testcase Number: TEMB0062SBA
083: *
084: * Test 1:
085: * iterate over fieldnames, check for these results:
086: * version: "BM"
087: * fileSize: 699994
088: * dataOffset: 54
089: *
090: *
091: *
092: * </pre>
093: */
094: public void testTEMB0062SBA() throws MediaException, IOException {
095:
096: BmpHeader testInstance;
097: testInstance = (BmpHeader) createMediaHeader();
098:
099: //
100: // test 1
101: //
102:
103: // error report
104: logProductError("reported error TEMB0053RMD, NullPointerException");
105:
106: assertTrue("test 1", testInstance.getField("version")
107: .toString().equals("BM")
108: && testInstance.getField("filesize").toString().equals(
109: "699994")
110: && testInstance.getField("dataoffset").toString()
111: .equals("54"));
112: testTrace("test 1 passed");
113:
114: //
115: // test 2
116: //
117:
118: //TODO : EMB 006 : getInfoHeader does not exist any more
119: // BmpHeader mediaHeader = (BmpHeader) testInstance.getInfoHeader();
120: //
121: // assertTrue("test 2", mediaHeader.getField("infoHeaderSize").toString().equals("40")
122: // && mediaHeader.getField("width").toString().equals("526")
123: // && mediaHeader.getField("hight").toString().equals("443")
124: // && mediaHeader.getField("bumberOfPlanes").toString().equals("1")
125: // && mediaHeader.getField("colorDepth").toString().toString().equals("24")
126: // && mediaHeader.getField("compressionIdentifier").toString().equals("0")
127: // && mediaHeader.getField("datasize").toString().equals("699940")
128: // && mediaHeader.getField("horizontalResolution").toString().equals("3780")
129: // && mediaHeader.getField("verticalResolution").toString().equals("3780")
130: // && mediaHeader.getField("numberOfColorsIndexes").toString().equals("0")
131: // && mediaHeader.getField("numberOfDiplayColorIndexes").toString().equals("0"));
132: // testTrace("test 2 passed");
133:
134: succeed();
135:
136: }
137:
138: }
|