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


Java ByteChunk类代码示例

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


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

示例1: testLookupException

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
/**
 * Check https://jira.springsource.org/browse/SPR-7350 isn't really an issue
 */
@Test
public void testLookupException() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0-fragments");
    // app dir is relative to server home
    tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

    tomcat.start();

    ByteChunk bc = getUrl("http://localhost:" + getPort() +
            "/test/warDirContext.jsp");
    assertEquals("<p>java.lang.ClassNotFoundException</p>",
            bc.toString());
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:19,代码来源:TestWarDirContext.java

示例2: testParameterImmutability

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testParameterImmutability() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    Tomcat.addServlet(ctx, "forward", new ForwardServlet("/modify"));
    ctx.addServletMapping("/forward", "forward");

    Tomcat.addServlet(ctx, "modify", new ModifyParameterServlet());
    ctx.addServletMapping("/modify", "modify");

    tomcat.start();

    ByteChunk response = new ByteChunk();
    StringBuilder target = new StringBuilder("http://localhost:");
    target.append(getPort());
    target.append("/forward");
    int rc = getUrl(target.toString(), response, null);

    Assert.assertEquals(200, rc);
    Assert.assertEquals("OK", response.toString());
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:25,代码来源:TestApplicationHttpRequest.java

示例3: testBug56147

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testBug56147() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    StandardContext ctx = (StandardContext) tomcat.addWebapp(
            null, "/test", appDir.getAbsolutePath());

    // This test needs the JSTL libraries
    File lib = new File("webapps/examples/WEB-INF/lib");
    ctx.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56147.jsp");

    String result = res.toString();
    assertEcho(result, "00-OK");
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:22,代码来源:TestELInJsp.java

示例4: testBug56612

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testBug56612() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug56612.jsp");

    String result = res.toString();
    Assert.assertTrue(result.contains("00-''"));
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestELInJsp.java

示例5: testSecurityAnnotationsNoWebXmlLoginConfig

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testSecurityAnnotationsNoWebXmlLoginConfig() throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0-servletsecurity2");
    tomcat.addWebapp(null, "", appDir.getAbsolutePath());

    tomcat.start();

    ByteChunk bc = new ByteChunk();
    int rc;
    rc = getUrl("http://localhost:" + getPort() + "/protected.jsp",
            bc, null, null);

    assertTrue(bc.getLength() > 0);
    assertEquals(403, rc);

    bc.recycle();

    rc = getUrl("http://localhost:" + getPort() + "/unprotected.jsp",
            bc, null, null);

    assertEquals(200, rc);
    assertTrue(bc.toString().contains("00-OK"));
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:27,代码来源:TestStandardWrapper.java

示例6: testBug54220SetNotFound

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testBug54220SetNotFound() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("", null);

    Tomcat.addServlet(ctx, "bug54220", new Bug54220Servlet(true));
    ctx.addServletMapping("/", "bug54220");

    tomcat.start();

    ByteChunk res = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort(), res, null);

    Assert.assertNull(res.toString());
    Assert.assertEquals(HttpServletResponse.SC_NOT_FOUND, rc);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:TestErrorReportValve.java

示例7: pathParamExtenionTest

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
private void pathParamExtenionTest(String path, String expected)
        throws Exception {
    // Setup Tomcat instance
    Tomcat tomcat = getTomcatInstance();

    // No file system docBase required
    Context ctx = tomcat.addContext("/testapp", null);

    Tomcat.addServlet(ctx, "servlet", new PathParamServlet());
    ctx.addServletMapping("*.txt", "servlet");

    tomcat.start();

    ByteChunk res = getUrl("http://localhost:" + getPort() + path);
    Assert.assertEquals(expected, res.toString());
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:TestCoyoteAdapter.java

示例8: testBug53467

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testBug53467() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

    tomcat.start();

    ByteChunk res = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug53467].jsp", res, null);

    Assert.assertEquals(HttpServletResponse.SC_OK, rc);
    Assert.assertTrue(res.toString().contains("<p>OK</p>"));
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:18,代码来源:TestApplicationContext.java

示例9: testBug45015b

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testBug45015b() throws Exception {
    Tomcat tomcat = getTomcatInstance();

    File appDir =
        new File("test/webapp-3.0");
    // app dir is relative to server home
    tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

    tomcat.start();

    int rc = getUrl("http://localhost:" + getPort() +
            "/test/bug45nnn/bug45015b.jsp", new ByteChunk(), null);

    assertEquals(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, rc);
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:17,代码来源:TestGenerator.java

示例10: testBug49297MultiplePageEncoding3

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testBug49297MultiplePageEncoding3() throws Exception {

    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

    tomcat.start();

    ByteChunk res = new ByteChunk();
    int sc = getUrl("http://localhost:" + getPort() +
            "/test/bug49nnn/bug49297MultiplePageEncoding3.jsp", res,
            new HashMap<String,List<String>>());

    assertEquals(500, sc);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:TestParser.java

示例11: doRead

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
/**
 * Read bytes into the specified chunk.
 */
@Override
public int doRead(ByteChunk chunk, Request req )
    throws IOException {

    if (pos >= lastValid) {
        if (!fill())
            return -1;
    }

    int length = lastValid - pos;
    chunk.setBytes(buf, pos, length);
    pos = lastValid;

    return (length);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:InternalAprInputBuffer.java

示例12: testBug49297MultiplePageEncoding4

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testBug49297MultiplePageEncoding4() throws Exception {

    Tomcat tomcat = getTomcatInstance();

    File appDir = new File("test/webapp-3.0");
    // app dir is relative to server home
    tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

    tomcat.start();

    ByteChunk res = new ByteChunk();
    int sc = getUrl("http://localhost:" + getPort() +
            "/test/bug49nnn/bug49297MultiplePageEncoding4.jsp", res,
            new HashMap<String,List<String>>());

    assertEquals(500, sc);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:19,代码来源:TestParser.java

示例13: doWrite

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
/**
 * Write chunk.
 */
@Override
public int doWrite(ByteChunk chunk, Response res) throws IOException {
    try {
        int length = chunk.getLength();
        if (useSocketBuffer) {
            socketBuffer.append(chunk.getBuffer(), chunk.getStart(),
                                length);
        } else {
            outputStream.write(chunk.getBuffer(), chunk.getStart(),
                               length);
        }
        byteCount += chunk.getLength();
        return chunk.getLength();
    } catch (IOException ioe) {
        response.action(ActionCode.CLOSE_NOW, ioe);
        // Re-throw
        throw ioe;
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:23,代码来源:InternalOutputBuffer.java

示例14: testBug53465

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testBug53465() throws Exception {
    Tomcat tomcat = getTomcatInstance();
    tomcat.enableNaming();

    File appDir =
        new File("test/webapp-3.0");
    // app dir is relative to server home
    org.apache.catalina.Context ctxt =
            tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());

    tomcat.start();

    ByteChunk bc = new ByteChunk();
    int rc = getUrl("http://localhost:" + getPort() +
            "/test/bug5nnnn/bug53465.jsp", bc, null);

    Assert.assertEquals(HttpServletResponse.SC_OK, rc);
    Assert.assertTrue(bc.toString().contains("<p>10</p>"));

    ContextEnvironment ce =
            ctxt.getNamingResources().findEnvironment("bug53465");
    Assert.assertEquals("Bug53465MappedName", ce.getProperty("mappedName"));
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:25,代码来源:TestNamingContext.java

示例15: testSimpleSsl

import org.apache.tomcat.util.buf.ByteChunk; //导入依赖的package包/类
@Test
public void testSimpleSsl() throws Exception {
    TesterSupport.configureClientSsl();

    Tomcat tomcat = getTomcatInstance();

    File appDir = new File(getBuildDirectory(), "webapps/examples");
    tomcat.addWebapp(null, "/examples", appDir.getAbsolutePath());

    TesterSupport.initSsl(tomcat);

    tomcat.start();
    ByteChunk res = getUrl("https://localhost:" + getPort() +
        "/examples/servlets/servlet/HelloWorldExample");
    assertTrue(res.toString().indexOf("<a href=\"../helloworld.html\">") > 0);
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:17,代码来源:TestSsl.java


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