@Test
  public void testApp() {
    try {
      ICertificate cert = CertificateDetails.getInstance();
      cert.setCertificate(
          "openxds_2010/OpenXDS_2010_Truststore.jks",
          "password",
          "openxds_2010/OpenXDS_2010_Truststore.jks",
          "password");
      QueryType query = new QueryType();
      query.setQueryUUID(new QueryUUIDType(RegistryStoredQueryUUIDs.GET_FOLDER_AND_CONTENTS_UUID));
      query.setReturnType(new ReturnTypeType("ObjectRef"));

      ParameterType p1 = new ParameterType(StoredQueryConstants.FOL_ENTRY_UUID);
      p1.addValues(
          new ValueType(
              "'urn:uuid:61a029d4-37f4-4599-b532-527b293b9a60'")); // urn:uuid:1ded6009-68e4-4a4f-9cd5-48f6be1eaa7f
      query.addParameters(p1);

      RegistryStoredQuery rsq = new RegistryStoredQuery();
      OMElement response = rsq.QueryGenerator(query);
      InputStream is = new ByteArrayInputStream(response.toString().trim().getBytes("utf-8"));

      JAXBContext jaxbContext = JAXBContext.newInstance(AdhocQueryResponseType.class);
      Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
      AdhocQueryResponseType aqs = (AdhocQueryResponseType) jaxbUnmarshaller.unmarshal(is);

      //			Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
      //			jaxbMarshaller.marshal(aqs, System.out);
    } catch (JAXBException e) {
      logger.error(e.toString());
    } catch (UnsupportedEncodingException e) {
      e.printStackTrace();
    }
  }
 @Before
 public void init() {
   ICertificate cert = CertificateDetails.getInstance();
   cert.setCertificate(
       "openxds_2010/OpenXDS_2010_Truststore.jks",
       "password",
       "openxds_2010/OpenXDS_2010_Truststore.jks",
       "password");
 }
  public void Submit() {

    ProvideAndRegisterDocumentSet pnr = new ProvideAndRegisterDocumentSet(false);
    ICertificate cert = CertificateDetails.getInstance();
    cert.setCertificate(
        "openxds_2010/OpenXDS_2010_Truststore.jks",
        "password",
        "openxds_2010/OpenXDS_2010_Truststore.jks",
        "password");

    MetadataType md = MetadataType.getInstance();
    md.setContentTypeCode("Communication"); // SubmissionSet 分類

    pInfo = new PatientInfoType();
    pInfo.setPid03("20140606^^^&1.3.6.1.4.1.21367.2005.3.7&ISO");
    pInfo.setPid05("王大尾");
    pInfo.setPid07("19990801000000");
    pInfo.setPid08("M");
    md.setPatientInfo(pInfo);
    md.setSourcePatientId(sourcePatientId);

    AuthorType a = new AuthorType();
    a.addAuthorRole("行政");
    a.addAuthorPerson("Gaduo");
    a.addAuthorInstitution("台北醫學大學附設醫院");
    a.addAuthorSpecialty("行政");
    md.addAuthor(a);

    FolderType folder = new FolderType();
    folder.setTitle("FF01");
    folder.setDescription("FF01");
    folder.setSourcePatientId(sourcePatientId);
    folder.addFolderCodeList("Referrals");
    folder.addFolderCodeList("Referrals");
    md.addFolder(folder);

    Class<SubmitNewFolderInclude5DocTest> clazz = SubmitNewFolderInclude5DocTest.class;
    ClassLoader loader = clazz.getClassLoader();
    {
      String title = "出院病摘_1010222_V101.0_Signed.xml";
      InputStream is = loader.getResourceAsStream("公告範例_已簽章/" + title);

      DocumentType document = new DocumentType();
      document.setSoap(pnr.getSoap());
      document.setTitle(title);
      document.setDescription(title);
      document.setSourcePatientId(sourcePatientId);
      document.setContent(is);
      document.setPatientInfo(pInfo);
      DocumentAuthorType author = new DocumentAuthorType();
      author.addAuthorRole("主治醫師");
      author.addAuthorPerson("黃柏榮醫師");
      author.addAuthorInstitution("台北醫學大學附設醫院");
      author.addAuthorSpecialty("乳房專科醫師");
      document.addAuthor(author);
      document.setClassCode("10160-0");
      document.setFormatCode("urn:ihe:pcc:apr:lab:2008");
      document.setHealthcareFacilityTypeCode("281PC2000N");
      document.setPracticeSettingCode("394802001");
      document.setTypeCode("34096-8");
      document.addConfidentialityCode("N");
      document.addConfidentialityCode("N");
      document.addEventCodeList("T-D4909");
      document.addEventCodeList("TRID1001");
      folder.addDocument(document);
    }
    {
      String title = "血液檢驗_1010222_V101.0_Signed.xml";
      InputStream is = loader.getResourceAsStream("公告範例_已簽章/" + title);

      DocumentType document = new DocumentType();
      document.setSoap(pnr.getSoap());
      document.setTitle(title);
      document.setDescription(title);
      document.setSourcePatientId(sourcePatientId);
      document.setContent(is);
      document.setPatientInfo(pInfo);
      DocumentAuthorType author = new DocumentAuthorType();
      author.addAuthorRole("主治醫師");
      author.addAuthorPerson("黃柏榮醫師");
      author.addAuthorInstitution("台北醫學大學附設醫院");
      author.addAuthorSpecialty("乳房專科醫師");
      document.addAuthor(author);
      document.setClassCode("10160-0");
      document.setFormatCode("urn:ihe:pcc:apr:lab:2008");
      document.setHealthcareFacilityTypeCode("281PC2000N");
      document.setPracticeSettingCode("394802001");
      document.setTypeCode("34096-8");
      document.addConfidentialityCode("N");
      document.addConfidentialityCode("N");
      document.addEventCodeList("T-D4909");
      document.addEventCodeList("TRID1001");
      folder.addDocument(document);
    }

    {
      String title = "門診用藥紀錄_1020814_V101.0_Signed.xml";
      InputStream is = loader.getResourceAsStream("公告範例_已簽章/" + title);

      DocumentType document = new DocumentType();
      document.setSoap(pnr.getSoap());
      document.setTitle(title);
      document.setDescription(title);
      document.setSourcePatientId(sourcePatientId);
      document.setContent(is);
      document.setPatientInfo(pInfo);
      DocumentAuthorType author = new DocumentAuthorType();
      author.addAuthorRole("主治醫師");
      author.addAuthorPerson("黃柏榮醫師");
      author.addAuthorInstitution("台北醫學大學附設醫院");
      author.addAuthorSpecialty("乳房專科醫師");
      document.addAuthor(author);
      document.setClassCode("10160-0");
      document.setFormatCode("urn:ihe:pcc:apr:lab:2008");
      document.setHealthcareFacilityTypeCode("281PC2000N");
      document.setPracticeSettingCode("394802001");
      document.setTypeCode("34096-8");
      document.addConfidentialityCode("N");
      document.addConfidentialityCode("N");
      document.addEventCodeList("T-D4909");
      document.addEventCodeList("TRID1001");
      folder.addDocument(document);
    }

    {
      String title = "門診病歷單_1020821_121_Signed.xml";
      InputStream is = loader.getResourceAsStream("公告範例_已簽章/" + title);

      DocumentType document = new DocumentType();
      document.setSoap(pnr.getSoap());
      document.setTitle(title);
      document.setDescription(title);
      document.setSourcePatientId(sourcePatientId);
      document.setContent(is);
      document.setPatientInfo(pInfo);
      DocumentAuthorType author = new DocumentAuthorType();
      author.addAuthorRole("主治醫師");
      author.addAuthorPerson("黃柏榮醫師");
      author.addAuthorInstitution("台北醫學大學附設醫院");
      author.addAuthorSpecialty("乳房專科醫師");
      document.addAuthor(author);
      document.setClassCode("10160-0");
      document.setFormatCode("urn:ihe:pcc:apr:lab:2008");
      document.setHealthcareFacilityTypeCode("281PC2000N");
      document.setPracticeSettingCode("394802001");
      document.setTypeCode("34096-8");
      document.addConfidentialityCode("N");
      document.addConfidentialityCode("N");
      document.addEventCodeList("T-D4909");
      document.addEventCodeList("TRID1001");
      folder.addDocument(document);
    }

    {
      String title = "醫療影像及報告_1010221_V101.0_Signed.xml";
      InputStream is = loader.getResourceAsStream("公告範例_已簽章/" + title);

      DocumentType document = new DocumentType();
      document.setSoap(pnr.getSoap());
      document.setTitle(title);
      document.setDescription(title);
      document.setSourcePatientId(sourcePatientId);
      document.setContent(is);
      document.setPatientInfo(pInfo);
      DocumentAuthorType author = new DocumentAuthorType();
      author.addAuthorRole("主治醫師");
      author.addAuthorPerson("黃柏榮醫師");
      author.addAuthorInstitution("台北醫學大學附設醫院");
      author.addAuthorSpecialty("乳房專科醫師");
      document.addAuthor(author);
      document.setClassCode("10160-0");
      document.setFormatCode("urn:ihe:pcc:apr:lab:2008");
      document.setHealthcareFacilityTypeCode("281PC2000N");
      document.setPracticeSettingCode("394802001");
      document.setTypeCode("34096-8");
      document.addConfidentialityCode("N");
      document.addConfidentialityCode("N");
      document.addEventCodeList("T-D4909");
      document.addEventCodeList("TRID1001");
      folder.addDocument(document);
    }

    OMElement response = pnr.MetadataGenerator(md);
    assertEquals(
        "<rs:RegistryResponse xmlns:rs=\"urn:oasis:names:tc:ebxml-regrep:xsd:rs:3.0\" status=\"urn:oasis:names:tc:ebxml-regrep:ResponseStatusType:Success\"/>",
        response.toString());
    logger.info(Thread.currentThread().getName() + "====" + response);
  }