當前位置: 首頁>>代碼示例>>Java>>正文


Java IMSPOXRequest類代碼示例

本文整理匯總了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);
}
 
開發者ID:IMSGlobal,項目名稱:basiclti-util-java,代碼行數:19,代碼來源:IMSPOXRequestTest.java

示例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());
  }
}
 
開發者ID:instructure,項目名稱:MinecraftLTI,代碼行數:19,代碼來源:ResultRunner.java

示例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);
}
 
開發者ID:IMSGlobal,項目名稱:basiclti-util-java,代碼行數:14,代碼來源:IMSPOXRequestTest.java


注:本文中的org.imsglobal.pox.IMSPOXRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。