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


Java LogStream.log方法代码示例

本文整理汇总了Java中java.rmi.server.LogStream.log方法的典型用法代码示例。如果您正苦于以下问题:Java LogStream.log方法的具体用法?Java LogStream.log怎么用?Java LogStream.log使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.rmi.server.LogStream的用法示例。


在下文中一共展示了LogStream.log方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetDefaultStream001

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public final void testGetDefaultStream001() {
    byte[] ba = { 11, 25, 64, 78, 30, 15, 65, 12, 34, 79, 66, 50, 01, 00,
            16 };
    ByteArrayOutputStream bas = new ByteArrayOutputStream();
    try {
        bas.write(ba);
        PrintStream ps1 = new PrintStream(bas);
        ls = LogStream.log("tcp");
        ls.setDefaultStream(ps1);
        PrintStream ps2 = ls.getDefaultStream();
        ps2.flush();
        assertEquals(ps1, ps2);
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:17,代码来源:TestLogStream.java

示例2: testGetDefaultStream003

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public final void testGetDefaultStream003() {
    byte[] ba = { 11, 25, 64, 78, 30, 15, 65, 12, 34, 79, 66, 50, 01, 00,
            16 };
    ByteArrayOutputStream bas = new ByteArrayOutputStream();
    try {
        PrintStream ps1 = new PrintStream(bas);
        ls = LogStream.log("tcp");

        PrintStream ps2 = ls.getDefaultStream();
        ps2.flush();
        int i = 1;
        assertNotNull(ps2);

    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:18,代码来源:TestLogStream.java

示例3: createLog

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public Log createLog(String loggerName, String oldLogName,
                     Level level)
{
    LogStream stream = null;
    if (oldLogName != null) {
        stream = LogStream.log(oldLogName);
    }
    return new LogStreamLog(stream, level);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:Log.java

示例4: testSetOutputStreamBad

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public void testSetOutputStreamBad() throws Exception {
    // Regression test HARMONY-1198
    try {
        LogStream ls = LogStream.log("proba");
        ls.setOutputStream(null);
        fail("Expected NPE");
    } catch (NullPointerException e) {
        // expected
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:LogStreamTest.java

示例5: testWriteArrInvalidOffLen

import java.rmi.server.LogStream; //导入方法依赖的package包/类
/**
 * Test for java.rmi.server.LogStream.write(byte[], int, int)
 * testing invalid offsets/lengths. 
 */
public void testWriteArrInvalidOffLen() throws Exception {
    // Regression test for HARMONY-1691
    // list of invalid offsets/lengths pairs
    int[][] invalidPairs = new int[][] {
        { -2, 1 },
        { 0, -6 },
        { 6, 1 },
        { 0, 6 } };

    // store original default stream for LogStream
    PrintStream prevOut = LogStream.getDefaultStream();

    try {
        // set empty default stream to not print garbage to System.out/err
        LogStream.setDefaultStream(
                new PrintStream(new ByteArrayOutputStream()));
        LogStream ls = LogStream.log("test");

        for (int i = 0; i < invalidPairs.length; ++i) {
            try {
                ls.write(new byte[] { 1, 1 },
                        invalidPairs[i][0], invalidPairs[i][1]);
                fail("IndexOutOfBoundsException "
                        + "is not thrown when off = " + invalidPairs[i][0]
                        + ", len = " + invalidPairs[i][1]);
            } catch (IndexOutOfBoundsException e) {
                //expected
            }
        }
    } finally {
        // restore original stream
        LogStream.setDefaultStream(prevOut);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:39,代码来源:LogStreamTest.java

示例6: testGetDefaultStream002

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public final void testGetDefaultStream002() {
    byte[] ba = new byte[0];
    ByteArrayOutputStream bas = new ByteArrayOutputStream();
    try {
        bas.write(ba);
        PrintStream ps1 = new PrintStream(bas);
        ls = LogStream.log("tcp");
        ls.setDefaultStream(ps1);
        PrintStream ps2 = ls.getDefaultStream();
        assertEquals(ps1, ps2);
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:15,代码来源:TestLogStream.java

示例7: testSetOutputStream

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public final void testSetOutputStream() {
    try {
        FileOutputStream tcpLogFile = new FileOutputStream("C:\\tcplog.txt");
        ls = LogStream.log("tcp");
        ls.setOutputStream(tcpLogFile);
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:10,代码来源:TestLogStream.java

示例8: testParseLevel001

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public final void testParseLevel001() {
    try {
        ls = LogStream.log("tcp");
        int i = ls.parseLevel("VERBOSE");
        assertEquals(i, 20);
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:10,代码来源:TestLogStream.java

示例9: testParseLevel002

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public final void testParseLevel002() {
    try {
        ls = LogStream.log("tcp");
        int i = ls.parseLevel("BRIEF");
        assertEquals(i, 10);
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:10,代码来源:TestLogStream.java

示例10: testParseLevel003

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public final void testParseLevel003() {
    try {
        ls = LogStream.log("tcp");
        int i = ls.parseLevel("SILENT");
        assertEquals(i, 0);
    } catch (Throwable e) {
        fail("Failed with:" + e);
    }
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:10,代码来源:TestLogStream.java

示例11: testWriteArrInvalidOffLen

import java.rmi.server.LogStream; //导入方法依赖的package包/类
/**
 * Test for java.rmi.server.LogStream.write(byte[], int, int) testing
 * invalid offsets/lengths.
 */
public void testWriteArrInvalidOffLen() throws Exception {
    // Regression test for HARMONY-1691
    // list of invalid offsets/lengths pairs
    int[][] invalidPairs = new int[][] { { -2, 1 }, { 0, -6 }, { 6, 1 },
            { 0, 6 } };

    // store original default stream for LogStream
    PrintStream prevOut = LogStream.getDefaultStream();

    try {
        // set empty default stream to not print garbage to System.out/err
        LogStream.setDefaultStream(new PrintStream(
                new ByteArrayOutputStream()));
        LogStream ls = LogStream.log("test");

        for (int i = 0; i < invalidPairs.length; ++i) {
            try {
                ls.write(new byte[] { 1, 1 }, invalidPairs[i][0],
                        invalidPairs[i][1]);
                fail("IndexOutOfBoundsException "
                        + "is not thrown when off = " + invalidPairs[i][0]
                        + ", len = " + invalidPairs[i][1]);
            } catch (IndexOutOfBoundsException e) {
                // expected
            }
        }
    } finally {
        // restore original stream
        LogStream.setDefaultStream(prevOut);
    }

}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:37,代码来源:LogStreamTest.java

示例12: testGetOutputStream

import java.rmi.server.LogStream; //导入方法依赖的package包/类
public void testGetOutputStream() {
    LogStream log = LogStream.log("abc");
    OutputStream output = log.getOutputStream();
    PrintStream defaultPrintStream = LogStream.getDefaultStream();

    assertEquals(output.toString(), defaultPrintStream.toString());
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:8,代码来源:LogStreamTest.java


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