本文整理匯總了Java中org.imsglobal.pox.IMSPOXRequest類的典型用法代碼示例。如果您正苦於以下問題:Java IMSPOXRequest類的具體用法?Java IMSPOXRequest怎麽用?Java IMSPOXRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IMSPOXRequest類屬於org.imsglobal.pox包,在下文中一共展示了IMSPOXRequest類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: test
import org.imsglobal.pox.IMSPOXRequest; //導入依賴的package包/類
@Test
public void test() {
String messageId = String.valueOf(new Date().getTime());
String inputTestData = String.format(IMSPOXRequest.ReplaceResultMessageTemplate, messageId, "3124567", "A", "");
IMSPOXRequest pox = new IMSPOXRequest(inputTestData);
Assert.assertEquals("V1.0", pox.getHeaderVersion());
Assert.assertEquals("replaceResultRequest", pox.getOperation());
Assert.assertEquals("should match messageId", messageId, pox.getHeaderMessageIdentifier());
Map<String, String> bodyMap = pox.getBodyMap();
String guid = bodyMap.get("/resultRecord/sourcedGUID/sourcedId");
Assert.assertEquals("3124567", guid);
String grade = bodyMap.get("/resultRecord/result/resultScore/textString");
Assert.assertEquals("A", grade);
String resultScoreLang = bodyMap.get("/resultRecord/result/resultScore/language");
Assert.assertEquals("should have resultScore lang set to en", "en", resultScoreLang);
}
示例2: run
import org.imsglobal.pox.IMSPOXRequest; //導入依賴的package包/類
public void run() {
LTIConsumer consumer = user.getConsumer();
try {
String url = user.getServiceUrl();
String key = consumer.getKey().toString();
String secret = consumer.getSecret().toString();
String sourcedid = user.getSourcedid();
String gradeStr = grade == null ? "" : grade.toString();
IMSPOXRequest.sendReplaceResult(url, key, secret, sourcedid, gradeStr, text);
} catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
MinecraftLTI.instance.getLogger().warning("Failed to send submission ("+e.getClass().getSimpleName()+"): "
+sw.toString());
}
}
示例3: testBuildReplaceResult
import org.imsglobal.pox.IMSPOXRequest; //導入依賴的package包/類
@Test
public void testBuildReplaceResult() throws Exception {
HttpPost post = IMSPOXRequest.buildReplaceResult("http://example.com", "key", "secret", "sourcedid", "0.95", "A", false);
String header = post.getHeaders("Authorization")[0].getValue();
InputStream input = post.getEntity().getContent();
Reader reader = new InputStreamReader(input);
String body = IMSPOXRequest.readPostBody(reader);
IMSPOXRequest pox = new IMSPOXRequest(body);
pox.setAuthHeader(header);
pox.validatePostBody();
Assert.assertNull(pox.errorMessage);
}