コード例 #1
0
  @Test
  public void validSessionUnvalidUsernoXML() throws Exception {
    try {

      GetUserConfigurationType userConfig = new GetUserConfigurationType();
      userConfig.getProject().add("Demo");

      edu.harvard.i2b2.pm.datavo.pm.ObjectFactory of =
          new edu.harvard.i2b2.pm.datavo.pm.ObjectFactory();
      BodyType bodyType = new BodyType();
      bodyType.getAny().add(of.createGetUserConfiguration(userConfig));

      RequestMessageType requestMessageType =
          buildRequestMessage(bodyType, "i2b2", "demouser", "Demo");
      StringWriter strWriter = new StringWriter();
      edu.harvard.i2b2.pm.datavo.i2b2message.ObjectFactory of2 =
          new edu.harvard.i2b2.pm.datavo.i2b2message.ObjectFactory();
      PMJAXBUtil.getJAXBUtil().marshaller(of2.createRequest(requestMessageType), strWriter);

      OMElement requestElement = convertStringToOMElement(strWriter.toString());
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);

      // read test file and store query instance ;
      // unmarshall this response string
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      ConfigureType masterInstanceResult =
          (ConfigureType) helper.getObjectByClass(r.getMessageBody().getAny(), ConfigureType.class);
      assertNotNull(masterInstanceResult);

      // try calling with another user
      requestMessageType =
          buildRequestMessage(
              bodyType, "demo", masterInstanceResult.getUser().getPassword().getValue(), "Demo");
      strWriter = new StringWriter();
      of2 = new edu.harvard.i2b2.pm.datavo.i2b2message.ObjectFactory();
      PMJAXBUtil.getJAXBUtil().marshaller(of2.createRequest(requestMessageType), strWriter);

      requestElement = convertStringToOMElement(strWriter.toString());
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);

      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      String err = r.getResponseHeader().getResultStatus().getStatus().getType();
      assertEquals("ERROR", err);

    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    }
  }
コード例 #2
0
ファイル: PmServiceController.java プロジェクト: URMC/i2b2
  public void setUserInfo(String responseXML) throws Exception {
    // log.info("PM response message: /n"+responseXML);
    UserInfoBean.pmResponse(responseXML);

    JAXBUtil jaxbUtil =
        new JAXBUtil(
            new String[] {
              "edu.harvard.i2b2.pm.datavo.pm", //$NON-NLS-1$
              "edu.harvard.i2b2.pm.datavo.i2b2message" //$NON-NLS-1$
            });
    JAXBElement jaxbElement = jaxbUtil.unMashallFromString(responseXML);
    ResponseMessageType responseMessageType = (ResponseMessageType) jaxbElement.getValue();

    String procStatus =
        responseMessageType.getResponseHeader().getResultStatus().getStatus().getType();
    String procMessage =
        responseMessageType.getResponseHeader().getResultStatus().getStatus().getValue();

    // String serverVersion = responseMessageType.getMessageHeader()
    // .getSendingApplication().getApplicationVersion();
    // System.setProperty("serverVersion", serverVersion);

    if (procStatus.equals("ERROR")) { // $NON-NLS-1$
      setMsg(procMessage);
    } else if (procStatus.equals("WARNING")) { // $NON-NLS-1$
      setMsg(procMessage);
    } else {
      BodyType bodyType = responseMessageType.getMessageBody();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      ConfigureType response =
          (ConfigureType) helper.getObjectByClass(bodyType.getAny(), ConfigureType.class);

      userInfoBean.setEnvironment(response.getEnvironment());
      userInfoBean.setUserName(response.getUser().getUserName());
      userInfoBean.setUserFullName(response.getUser().getFullName());
      // userInfoBean.setUserPassword(response.getUser().getPassword());
      userInfoBean.setUserKey(response.getUser().getKey());
      userInfoBean.setUserDomain(response.getUser().getDomain());
      userInfoBean.setHelpURL(response.getHelpURL());

      // Save Global variables in properties
      if (response.getGlobalData() != null) {
        for (ParamType param : response.getGlobalData().getParam())
          userInfoBean.setGlobals(param.getName(), param.getValue());
      }
      // Save projects
      if (response.getUser().getProject() != null)
        // userInfoBean.setProjects( response.getUser().getProject());

        // Save Cell
        if (response.getCellDatas() != null) {}
      // userInfoBean.setCellDatas(response.getCellDatas());
    }
  }
コード例 #3
0
ファイル: WorkplaceResponseData.java プロジェクト: URMC/i2b2
 public FoldersType doReadFolders() {
   FoldersType folders = null;
   try {
     BodyType bodyType = respMessageType.getMessageBody();
     JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
     if (bodyType != null)
       folders = (FoldersType) helper.getObjectByClass(bodyType.getAny(), FoldersType.class);
   } catch (JAXBUtilException e) {
     log.error(e.getMessage());
     ;
   }
   return folders;
 }
コード例 #4
0
  @Test
  public void createProjetUserParamWithValidUser() throws Exception {
    String filename = testFileDir + "/pm_create_project_user_param_with_valid_user.xml";
    ParamType ctype = null;
    String masterInstanceResult = null;
    try {
      String requestString = getQueryString(filename);
      OMElement requestElement = convertStringToOMElement(requestString);
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);

      // read test file and store query instance ;
      // unmarshall this response string
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);

      // Check to see if really added
      filename = testFileDir + "/pm_create_project_user_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);

      // read test file and store query instance ;
      // unmarshall this response string
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ParamsType allParams =
          (ParamsType) helper.getObjectByClass(r.getMessageBody().getAny(), ParamsType.class);

      assertEquals(allParams.getParam().size(), 1);
      for (ParamType param : allParams.getParam()) {
        if (param.getName().equals("Bamboo_Param")) {
          ctype = param;
          break;
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
    assertNotNull(masterInstanceResult);
    assertNotNull(ctype);
    assertEquals(ctype.getName(), "Bamboo_Param");
    assertEquals(ctype.getValue(), "my test");
    assertEquals(ctype.getDatatype(), "T");
  }
コード例 #5
0
  @Test
  public void CreateUserRoleforCRC() throws Exception {
    String filename = testFileDir + "/pm_create_user_for_crc.xml";
    ConfigureType ctype = null;
    String masterInstanceResult = null;
    try {
      String requestString = getQueryString(filename);
      OMElement requestElement = convertStringToOMElement(requestString);
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Add Role 1
      filename = testFileDir + "/pm_set_role1_for_crc.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Add Role 1
      filename = testFileDir + "/pm_set_role2_for_crc.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }
  public AnalysisDefinitionType getAnalysisDefinition() throws JAXBUtilException {
    BodyType bodyType = getBodyType();

    AnalysisDefinitionRequestType analysisDefReqType =
        (AnalysisDefinitionRequestType)
            unWrapHelper.getObjectByClass(bodyType.getAny(), AnalysisDefinitionRequestType.class);
    AnalysisDefinitionType analysisDef = null;
    if (analysisDefReqType != null) {
      analysisDef = analysisDefReqType.getAnalysisDefinition();
    }
    return analysisDef;
  }
コード例 #7
0
  @Test
  public void validUser() throws Exception {
    String filename = testFileDir + "/pm_valid_user.xml";
    try {
      String requestString = getQueryString(filename);
      OMElement requestElement = convertStringToOMElement(requestString);
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);

      // read test file and store query instance ;
      // unmarshall this response string
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      ConfigureType masterInstanceResult =
          (ConfigureType) helper.getObjectByClass(r.getMessageBody().getAny(), ConfigureType.class);
      assertNotNull(masterInstanceResult);
    } catch (Exception e) {
      e.printStackTrace();
      throw e;
    }
  }
  public QueryDefinitionType getQueryDefinition() throws JAXBUtilException {
    BodyType bodyType = getBodyType();

    QueryDefinitionRequestType queryDefReqType =
        (QueryDefinitionRequestType)
            unWrapHelper.getObjectByClass(bodyType.getAny(), QueryDefinitionRequestType.class);

    QueryDefinitionType queryDef = null;
    if (queryDefReqType != null) {
      queryDef = queryDefReqType.getQueryDefinition();
    }
    return queryDef;
  }
コード例 #9
0
  @Test
  public void CRUDGlobalParamWithValidUser() throws Exception {
    String filename = testFileDir + "/pm_create_global_param_with_valid_user.xml";
    // ParamType ctype = null;
    int id = -1;
    String masterInstanceResult = null;
    try {
      String requestString = getQueryString(filename);
      OMElement requestElement = convertStringToOMElement(requestString);
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really added
      filename = testFileDir + "/pm_create_global_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ParamsType allParams =
          (ParamsType) helper.getObjectByClass(r.getMessageBody().getAny(), ParamsType.class);

      for (ParamType param : allParams.getParam()) {
        if (param.getName().equals("Global") && param.getValue().equals("Global Value")) {
          assertNotNull(param);
          assertEquals(param.getName(), "Global");
          assertEquals(param.getValue(), "Global Value");
          assertEquals(param.getDatatype(), "T");
          id = param.getId();
          break;
        }
      }

      // Update the project
      filename = testFileDir + "/pm_update_global_param_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really added
      filename = testFileDir + "/pm_recreate_global_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      GlobalDataType global =
          (GlobalDataType)
              helper.getObjectByClass(r.getMessageBody().getAny(), GlobalDataType.class);

      for (ParamType param : global.getParam()) {
        if (param.getId() == id) {
          assertNotNull(param);
          assertEquals(param.getName(), "Global");
          assertEquals(param.getValue(), "Global Value2");
          assertEquals(param.getDatatype(), "N");
          break;
        }
      }

      // Delete project
      filename = testFileDir + "/pm_delete_global_param_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really deleted
      filename = testFileDir + "/pm_recreate_global_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      String err = r.getResponseHeader().getResultStatus().getStatus().getType();
      assertEquals("ERROR", err);

      // Reenable project
      // Update the project
      filename = testFileDir + "/pm_update_global_param_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really reenabled
      filename = testFileDir + "/pm_recreate_global_param_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestString = requestString.replace("{{{id}}}", Integer.toString(id));
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      global =
          (GlobalDataType)
              helper.getObjectByClass(r.getMessageBody().getAny(), GlobalDataType.class);

      for (ParamType param : global.getParam()) {
        if (param.getId() == id) {
          assertNotNull(param);
          assertEquals(param.getName(), "Global");
          assertEquals(param.getValue(), "Global Value2");
          assertEquals(param.getDatatype(), "N");
          break;
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }
コード例 #10
0
  @Test
  public void CRUDProjectWithValidUser() throws Exception {
    String filename = testFileDir + "/pm_create_project_with_valid_user.xml";
    ProjectType ctype = null;
    String masterInstanceResult = null;
    try {
      String requestString = getQueryString(filename);
      OMElement requestElement = convertStringToOMElement(requestString);
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really added
      filename = testFileDir + "/pm_create_project_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ctype = (ProjectType) helper.getObjectByClass(r.getMessageBody().getAny(), ProjectType.class);
      assertNotNull(ctype);
      assertEquals(ctype.getId(), "BAMBOO");
      assertEquals(ctype.getName(), "Bamboo Test");
      assertEquals(ctype.getKey(), "e80");
      assertEquals(ctype.getWiki(), "http://127.0.0.1/wiki");
      assertEquals(ctype.getDescription(), "This is a message");
      assertEquals(ctype.getPath(), "/bamboo");

      // Update the project
      filename = testFileDir + "/pm_update_project_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really added
      filename = testFileDir + "/pm_create_project_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ctype = (ProjectType) helper.getObjectByClass(r.getMessageBody().getAny(), ProjectType.class);
      assertNotNull(ctype);
      assertEquals(ctype.getId(), "BAMBOO");
      assertEquals(ctype.getName(), "Bamboo Test2");
      assertEquals(ctype.getKey(), "e82");
      assertEquals(ctype.getWiki(), "http://127.0.0.1/wiki2");
      assertEquals(ctype.getDescription(), "This is a message2");
      assertEquals(ctype.getPath(), "/bamboo");

      // Delete project
      filename = testFileDir + "/pm_delete_project_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really deleted
      filename = testFileDir + "/pm_create_project_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      String err = r.getResponseHeader().getResultStatus().getStatus().getType();
      assertEquals("ERROR", err);

      // Reenable project
      // Update the project
      filename = testFileDir + "/pm_create_project_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really reenabled
      filename = testFileDir + "/pm_create_project_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ctype = (ProjectType) helper.getObjectByClass(r.getMessageBody().getAny(), ProjectType.class);
      assertNotNull(ctype);
      assertEquals(ctype.getId(), "BAMBOO");
      assertEquals(ctype.getName(), "Bamboo Test");
      assertEquals(ctype.getWiki(), "http://127.0.0.1/wiki");
      assertEquals(ctype.getDescription(), "This is a message");
      assertEquals(ctype.getPath(), "/bamboo");
      assertEquals(ctype.getKey(), "e80");
    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }
コード例 #11
0
  @Test
  public void CRUDUserWithValidUser() throws Exception {
    String filename = testFileDir + "/pm_create_user_with_valid_user.xml";
    ConfigureType ctype = null;
    String masterInstanceResult = null;
    try {
      String requestString = getQueryString(filename);
      OMElement requestElement = convertStringToOMElement(requestString);
      OMElement responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      JAXBElement responseJaxb =
          PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      ResponseMessageType r = (ResponseMessageType) responseJaxb.getValue();
      JAXBUnWrapHelper helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really added
      filename = testFileDir + "/pm_create_user_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ctype =
          (ConfigureType) helper.getObjectByClass(r.getMessageBody().getAny(), ConfigureType.class);
      assertNotNull(ctype);
      assertEquals(ctype.getUser().getFullName(), "Bamboo User");
      //	assertEquals(ctype.getUser().getEmail(),"*****@*****.**");
      assertTrue(ctype.getUser().isIsAdmin());

      // Update the user
      filename = testFileDir + "/pm_update_user_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really added
      filename = testFileDir + "/pm_create_user_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ctype =
          (ConfigureType) helper.getObjectByClass(r.getMessageBody().getAny(), ConfigureType.class);
      assertNotNull(ctype);
      assertEquals(ctype.getUser().getFullName(), "Bamboo User2");
      //	assertEquals(ctype.getUser().getEmail(),"*****@*****.**");
      assertFalse(ctype.getUser().isIsAdmin());

      // Delete User
      filename = testFileDir + "/pm_delete_user_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really deleted
      filename = testFileDir + "/pm_create_user_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      String err = r.getResponseHeader().getResultStatus().getStatus().getType();
      assertEquals("ERROR", err);

      // Reenable user
      // Update the user
      filename = testFileDir + "/pm_create_user_with_valid_user.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      masterInstanceResult =
          (String) helper.getObjectByClass(r.getMessageBody().getAny(), String.class);
      assertNotNull(masterInstanceResult);

      // Check to see if really reenabled
      filename = testFileDir + "/pm_create_user_with_valid_user_check.xml";
      requestString = getQueryString(filename);
      requestElement = convertStringToOMElement(requestString);
      responseElement = getServiceClient(pmTargetEPR).sendReceive(requestElement);
      responseJaxb = PMJAXBUtil.getJAXBUtil().unMashallFromString(responseElement.toString());
      r = (ResponseMessageType) responseJaxb.getValue();
      helper = new JAXBUnWrapHelper();
      ctype =
          (ConfigureType) helper.getObjectByClass(r.getMessageBody().getAny(), ConfigureType.class);
      assertNotNull(ctype);
      assertEquals(ctype.getUser().getFullName(), "Bamboo User");
      //	assertEquals(ctype.getUser().getEmail(),"*****@*****.**");
      assertTrue(ctype.getUser().isIsAdmin());

    } catch (Exception e) {
      e.printStackTrace();
      assertTrue(false);
    }
  }