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


Java MockHttpServletRequest类代码示例

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


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

示例1: testAuth02

import mondrian.tui.MockHttpServletRequest; //导入依赖的package包/类
public void testAuth02() throws Exception {
    String reqFileName = "EmptyExecute.xml";
    Fault expectedFault = new Fault(XmlaException.formatFaultCode(
                CLIENT_FAULT_FC,
                CHH_AUTHORIZATION_CODE),
                CHH_AUTHORIZATION_FAULT_FS,
                FAULT_ACTOR,
                MONDRIAN_NAMESPACE,
                CHH_AUTHORIZATION_CODE, null);

    doAuthorization = true;

    String requestText = fileToString(reqFileName);
    byte[] reqBytes = requestText.getBytes();

    MockHttpServletRequest req = new MockHttpServletRequest(reqBytes);
    req.setMethod("POST");
    req.setContentType("text/xml");

    req.setAuthType(HttpServletRequest.BASIC_AUTH);
    req.setHeader(
        XmlaRequestCallback.AUTHORIZATION, HttpServletRequest.BASIC_AUTH);
    req.setHeader(XmlaRequestCallback.AUTHORIZATION, "FOOBAR");

    try {
        doTest(req, expectedFault);
    } finally {
        clearServlet();
        doAuthorization = false;
    }
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:32,代码来源:XmlaErrorTest.java

示例2: testAuth03

import mondrian.tui.MockHttpServletRequest; //导入依赖的package包/类
public void testAuth03() throws Exception {
        String reqFileName = "EmptyExecute.xml";
        Fault expectedFault = null;

        doAuthorization = true;

        String requestText = fileToString(reqFileName);
        byte[] reqBytes = requestText.getBytes();

        MockHttpServletRequest req = new MockHttpServletRequest(reqBytes);
        req.setMethod("POST");
        req.setContentType("text/xml");

        req.setAuthType(HttpServletRequest.BASIC_AUTH);
        req.setHeader(
            XmlaRequestCallback.AUTHORIZATION, HttpServletRequest.BASIC_AUTH);

        String user = "MY_USER";
        String password = "MY_PASSWORD";
        XmlaErrorTest.user = user;
        XmlaErrorTest.password = password;
        String credential = user + ':' + password;
        String encoded = Base64.encodeBytes(credential.getBytes());

        req.setHeader(XmlaRequestCallback.AUTHORIZATION, encoded);

        try {
            doTest(req, expectedFault);
            req.setHeader(
                XmlaRequestCallback.EXPECT,
                XmlaRequestCallback.EXPECT_100_CONTINUE);
if (DEBUG) {
System.out.println("DO IT AGAIN");
}
            doTest(req, expectedFault);
        } finally {
            clearServlet();
            XmlaErrorTest.doAuthorization = false;
            XmlaErrorTest.user = null;
            XmlaErrorTest.password = null;
        }
    }
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:43,代码来源:XmlaErrorTest.java

示例3: testAuth04

import mondrian.tui.MockHttpServletRequest; //导入依赖的package包/类
public void testAuth04() throws Exception {
    String reqFileName = "EmptyExecute.xml";
    Fault expectedFault = new Fault(XmlaException.formatFaultCode(
                CLIENT_FAULT_FC,
                CHH_AUTHORIZATION_CODE),
                CHH_AUTHORIZATION_FAULT_FS,
                FAULT_ACTOR,
                MONDRIAN_NAMESPACE,
                CHH_AUTHORIZATION_CODE, null);

    doAuthorization = true;

    String requestText = fileToString(reqFileName);
    byte[] reqBytes = requestText.getBytes();

    MockHttpServletRequest req = new MockHttpServletRequest(reqBytes);
    req.setMethod("POST");
    req.setContentType("text/xml");

    req.setAuthType(HttpServletRequest.BASIC_AUTH);
    req.setHeader(
        XmlaRequestCallback.AUTHORIZATION, HttpServletRequest.BASIC_AUTH);

    String user = "MY_USER";
    String password = "MY_PASSWORD";
    XmlaErrorTest.user = user + "FOO";
    XmlaErrorTest.password = password;
    String credential = user + ':' + password;
    String encoded = Base64.encodeBytes(credential.getBytes());

    req.setHeader(XmlaRequestCallback.AUTHORIZATION, encoded);

    try {
        doTest(req, expectedFault);
    } finally {
        clearServlet();
        XmlaErrorTest.doAuthorization = false;
        XmlaErrorTest.user = null;
        XmlaErrorTest.password = null;
    }
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:42,代码来源:XmlaErrorTest.java

示例4: testAuth05

import mondrian.tui.MockHttpServletRequest; //导入依赖的package包/类
public void testAuth05() throws Exception {
    String reqFileName = "EmptyExecute.xml";
    Fault expectedFault = new Fault(XmlaException.formatFaultCode(
                CLIENT_FAULT_FC,
                CHH_AUTHORIZATION_CODE),
                CHH_AUTHORIZATION_FAULT_FS,
                FAULT_ACTOR,
                MONDRIAN_NAMESPACE,
                CHH_AUTHORIZATION_CODE, null);

    doAuthorization = true;

    String requestText = fileToString(reqFileName);
    byte[] reqBytes = requestText.getBytes();

    MockHttpServletRequest req = new MockHttpServletRequest(reqBytes);
    req.setMethod("POST");
    req.setContentType("text/xml");

    req.setAuthType(HttpServletRequest.BASIC_AUTH);
    req.setHeader(
        XmlaRequestCallback.AUTHORIZATION, HttpServletRequest.BASIC_AUTH);

    String user = "MY_USER";
    String password = "MY_PASSWORD";
    XmlaErrorTest.user = user;
    XmlaErrorTest.password = password + "FOO";
    String credential = user + ':' + password;
    String encoded = Base64.encodeBytes(credential.getBytes());

    req.setHeader(XmlaRequestCallback.AUTHORIZATION, encoded);

    try {
        doTest(req, expectedFault);
    } finally {
        clearServlet();
        XmlaErrorTest.doAuthorization = false;
        XmlaErrorTest.user = null;
        XmlaErrorTest.password = null;
    }
}
 
开发者ID:Twixer,项目名称:mondrian-3.1.5,代码行数:42,代码来源:XmlaErrorTest.java


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