当前位置: 首页>>代码示例>>Java>>正文


Java MediaContent类代码示例

本文整理汇总了Java中com.alibaba.dubbo.common.model.media.MediaContent的典型用法代码示例。如果您正苦于以下问题:Java MediaContent类的具体用法?Java MediaContent怎么用?Java MediaContent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MediaContent类属于com.alibaba.dubbo.common.model.media包,在下文中一共展示了MediaContent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_MultiObject_WithType

import com.alibaba.dubbo.common.model.media.MediaContent; //导入依赖的package包/类
@Test
public void test_MultiObject_WithType() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeBool(false);
    objectOutput.writeObject(bigPerson);
    objectOutput.writeByte((byte) 23);
    objectOutput.writeObject(mediaContent);
    objectOutput.writeInt(-23);
    objectOutput.flushBuffer();

    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(
            byteArrayOutputStream.toByteArray());
    ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);

    assertEquals(false, deserialize.readBool());
    assertEquals(bigPerson, deserialize.readObject(BigPerson.class));
    assertEquals((byte) 23, deserialize.readByte());
    assertEquals(mediaContent, deserialize.readObject(MediaContent.class));
    assertEquals(-23, deserialize.readInt());

    try {
        deserialize.readObject();
        fail();
    } catch (IOException expected) {
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:27,代码来源:AbstractSerializationTest.java

示例2: test_MediaContent_WithType_badStream

import com.alibaba.dubbo.common.model.media.MediaContent; //导入依赖的package包/类
@Test
public void test_MediaContent_WithType_badStream() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(mediaContent);
    objectOutput.flushBuffer();

    byte[] byteArray = byteArrayOutputStream.toByteArray();
    for (int i = 0; i < byteArray.length; i++) {
        if(i%3 == 0) {
            byteArray[i] = (byte)~byteArray[i];
        }
    }
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    
    try {
        ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
        @SuppressWarnings("unused") // local variable, convenient for debug
        Object read = deserialize.readObject(MediaContent.class);
        fail();
    } catch (IOException expected) {
        System.out.println(expected);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:24,代码来源:AbstractSerializationTest.java

示例3: test_MediaContent_WithType_badStream

import com.alibaba.dubbo.common.model.media.MediaContent; //导入依赖的package包/类
@Test
public void test_MediaContent_WithType_badStream() throws Exception {
    ObjectOutput objectOutput = serialization.serialize(url, byteArrayOutputStream);
    objectOutput.writeObject(mediaContent);
    objectOutput.flushBuffer();

    byte[] byteArray = byteArrayOutputStream.toByteArray();
    for (int i = 0; i < byteArray.length; i++) {
        if(i%3 == 0) {
            byteArray[i] = (byte)~byteArray[i];
        }
    }
    ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);
    
    try {
        ObjectInput deserialize = serialization.deserialize(url, byteArrayInputStream);
        @SuppressWarnings("unused") // local variable, convenient for debug
        Object read = deserialize.readObject(MediaContent.class);
        fail();
    } catch (JSONException expected) {
        System.out.println(expected);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:24,代码来源:FastJsonSerializationTest.java


注:本文中的com.alibaba.dubbo.common.model.media.MediaContent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。