本文整理汇总了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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}