コード例 #1
0
  /** Test for third service option. Creates and gets a test task. */
  @Test
  public void testCreateTaskWithService3() {
    String result = null;

    // Service 3
    String[] args1 = {testXMLTask, "3"};
    invokeServiceMethod("createTask", args1);
    String[] args2 = {"TestAttendee", "3"};
    result = invokeServiceMethod("getAttendantTasks", args2);
    TaskList taskList = JaxbUtils.xmlToTaskList(result);
    assertTrue(taskList.list.contains(JaxbUtils.xmlToTask(testXMLTask)));
  }
コード例 #2
0
    @Override
    protected Soap createMessage(byte[] rawXml, SOAPMessage soap, String charset) throws Exception {
      if (soap.getSOAPHeader() != null) {
        SoapHeader header = unmarshalHeader(SoapHeader.class, soap.getSOAPHeader());
        if (header.getCentralService() != null) {
          if (header.getService() != null) {
            throw new CodedException(
                X_MALFORMED_SOAP,
                "Message header must contain either service id" + " or central service id");
          }

          ServiceId serviceId = GlobalConf.getServiceId(header.getCentralService());
          header.setService(serviceId);

          SOAPEnvelope envelope = soap.getSOAPPart().getEnvelope();
          envelope.removeChild(soap.getSOAPHeader());

          Node soapBody = envelope.removeChild(soap.getSOAPBody());
          envelope.removeContents(); // removes newlines etc.

          Marshaller marshaller =
              JaxbUtils.createMarshaller(SoapHeader.class, new SoapNamespacePrefixMapper());
          marshaller.marshal(header, envelope);

          envelope.appendChild(soapBody);

          byte[] newRawXml = SoapUtils.getBytes(soap);
          return super.createMessage(newRawXml, soap, charset);
        }
      }
      return super.createMessage(rawXml, soap, charset);
    }
コード例 #3
0
  /** Test for third service option. Creates and gets a test task. */
  @Test
  public void testCreateTaskWithService3HashCheck() {
    String result = null;
    boolean pass = false;
    Task testTask = JaxbUtils.xmlToTask(testXMLTask);

    // Service 3
    String[] args1 = {testXMLTask, "3"};
    invokeServiceMethod("createTask", args1);
    String[] args2 = {"TestAttendee", "3"};
    result = invokeServiceMethod("getAttendantTasks", args2);
    TaskList taskList = JaxbUtils.xmlToTaskList(result);
    Iterator<Task> it = taskList.list.iterator();
    Task task = null;
    while (it.hasNext()) {
      task = it.next();
      if (task.equals(testTask)) {
        pass = true;
        break;
      }
    }
    assertTrue(pass);
  }
コード例 #4
0
  /**
   * Application entry point.
   *
   * @param args Command line args (See code for more information)
   */
  public static void main(String[] args) {
    // try load the schema
    File schema = new File("input" + File.separator + "gw-packet-schema.xsd");
    if (!schema.exists()) {
      LOGGER.error("Schema file not found: {}", schema.getAbsolutePath());
      return;
    }

    // try load the templates
    File packXML = new File("input" + File.separator + "PacketTemplates.xml");
    if (!packXML.exists()) {
      LOGGER.error("Packet templates file not found: {}", packXML.getAbsolutePath());
      return;
    }

    try {
      // generate from out of the schema
      generate(JaxbUtils.validateAndUnmarshal(Templates.class, packXML, schema));
    } catch (JAXBException | SAXException | IOException | JClassAlreadyExistsException ex) {
      LOGGER.error("Error in Code-Generation: ", ex);
    }
  }