⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multimediacontenttest.java

📁 openwave公司的用于彩信开发的MM7协议实现java原代码,决对超值.
💻 JAVA
字号:
package com.openwave.mms.content.test;import java.io.*;import com.openwave.mms.content.*;import junit.framework.TestCase;public class MultimediaContentTest extends TestCase {    public MultimediaContentTest( String name ) {        super(name);    }    protected void setUp() {    }    protected void tearDown() {    }    private InputStream getTestDataStream( String fileName ) throws Exception {        return this.getClass().getResourceAsStream("/" + fileName);    }    public void testDecompose() throws Exception {        MultimediaContent content = Factory.getInstance()                                           .newMultimediaContent(                                               getTestDataStream( "catch_all.txt" ) );        Template template = content.getTemplate();        RegionAttributes textAttr = template.getTextAttributes();        RegionAttributes imageAttr = template.getImageAttributes();        assertNotNull( "text attributes", textAttr );        assertNotNull( "image attributes", imageAttr );        IntOrPercent textTop = textAttr.getTop();        assertNotNull( "text attributes top", textTop );        assertEquals( "text attributes top", 10, textTop.getValue() );        assertEquals( "text attributes top", IntOrPercent.PERCENT, textTop.getType() );        IntOrPercent textLeft = textAttr.getLeft();        assertNotNull( "text attributes left", textLeft );        assertEquals( "text attributes left", 20, textLeft.getValue() );        assertEquals( "text attributes left", IntOrPercent.INT, textLeft.getType() );        IntOrPercent textWidth = textAttr.getWidth();        assertNotNull( "text attributes width", textWidth );        assertEquals( "text attributes width", 40, textWidth.getValue() );        assertEquals( "text attributes width", IntOrPercent.PERCENT, textWidth.getType() );        IntOrPercent textHeight = textAttr.getHeight();        assertNotNull( "text attributes height", textHeight );        assertEquals( "text attributes height", 30, textHeight.getValue() );        assertEquals( "text attributes height", IntOrPercent.PERCENT, textHeight.getType() );        Fit textFit = textAttr.getFit();        assertNotNull( "text attributes fit", textFit );        assertEquals( "text attributes fit", Fit.HIDDEN, textFit );        IntOrPercent imageTop = imageAttr.getTop();        assertNotNull( "image attributes top", imageTop );        assertEquals( "image attributes top", 50, imageTop.getValue() );        assertEquals( "image attributes top", IntOrPercent.INT, imageTop.getType() );        IntOrPercent imageLeft = imageAttr.getLeft();        assertNotNull( "image attributes left", imageLeft );        assertEquals( "image attributes left", 60, imageLeft.getValue() );        assertEquals( "image attributes left", IntOrPercent.INT, imageLeft.getType() );        IntOrPercent imageWidth = imageAttr.getWidth();        assertNotNull( "image attributes width", imageWidth );        assertEquals( "image attributes width", 80, imageWidth.getValue() );        assertEquals( "image attributes width", IntOrPercent.PERCENT, imageWidth.getType() );        IntOrPercent imageHeight = imageAttr.getHeight();        assertNotNull( "image attributes height", imageHeight );        assertEquals( "image attributes height", 70, imageHeight.getValue() );        assertEquals( "image attributes height", IntOrPercent.PERCENT, imageHeight.getType() );        Fit imageFit = imageAttr.getFit();        assertNotNull( "image attributes fit", imageFit );        assertEquals( "image attributes fit", Fit.HIDDEN, imageFit );        Slide slide1 = content.getSlide( 0 );        assertEquals( "slide 1 duration", 300, slide1.getDuration() );        Text text1 = slide1.getText();        assertEquals( "slide 1 text file name", "test1.txt", text1.getFileName() );        Audio audio1 = slide1.getAudio();        assertEquals( "slide 1 audio file name", "yahoo.amr", audio1.getFileName() );        Image image1 = slide1.getImage();        assertEquals( "slide 1 image file name", "peachro.jpg", image1.getFileName() );        assertEquals( "slide 1 image begin", 300, image1.getBegin() );        assertEquals( "slide 1 image end", 400, image1.getEnd() );        assertEquals( "slide 1 image alt", "image alt", image1.getAlt() );        Slide slide2 = content.getSlide( 1 );        Text text2 = slide2.getText();        assertEquals( "slide 2 text file name", "test2.txt", text2.getFileName() );        Image image2 = slide2.getImage();        assertEquals( "slide 2 image file name", "yellowfl.gif", image2.getFileName() );        assertEquals( "slide 2 image begin", 0, image2.getBegin() );        assertEquals( "slide 2 image end", 0, image2.getEnd() );        assertNull( "slide 2 image alt", image2.getAlt() );    }    public void testAudioVideo() throws Exception {        try {            MultimediaContent content =                Factory.getInstance()                       .newMultimediaContent(                           getTestDataStream( "audio_video.txt" ) );            fail("audio with video did not throw an exception");        } catch( ContentException ce ) {            assertEquals( "audio video", IllegalStateException.class,                          ce.getWrappedException().getClass() );        }    }    public void testImageAudioVideo() throws Exception {        try {            MultimediaContent content =                Factory.getInstance()                       .newMultimediaContent(                           getTestDataStream( "image_audio_video.txt" ) );            fail("image and audio with video did not throw an exception");        } catch( ContentException ce ) {            assertEquals( "image audio video", IllegalStateException.class,                          ce.getWrappedException().getClass() );        }    }    public void testTextVideo() throws Exception {        try {            MultimediaContent content =                Factory.getInstance()                       .newMultimediaContent(                           getTestDataStream( "text_video.txt" ) );            Slide slide1 = content.getSlide( 0 );            assertEquals( "slide 1 duration", 300, slide1.getDuration() );            Text text = slide1.getText();            assertEquals( "slide 1 text file name", "test1.txt", text.getFileName() );            Video video = slide1.getVideo();            assertEquals( "slide 1 video file name", "peachro.mpg", video.getFileName() );            assertEquals( "slide 1 video begin", 300, video.getBegin() );            assertEquals( "slide 1 video end", 400, video.getEnd() );            assertEquals( "slide 1 video alt", "video alt", video.getAlt() );        } catch( ContentException ce ) {            fail("text with video threw an exception");        }    }    public void testTextImageVideo() throws Exception {        try {            MultimediaContent content =                Factory.getInstance()                       .newMultimediaContent(                           getTestDataStream( "text_image_video.txt" ) );            fail("text and image with video did not throw an exception");        } catch( ContentException ce ) {            assertEquals( "text image video", IllegalStateException.class,                          ce.getWrappedException().getClass() );        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -