test_class.declarator: logger = LoggerFactory.getLogger(SxmpServletProcessorTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(SxmpServletProcessorTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.declarator: thrown= ExpectedException.none()
test_class.modifier: @Rule
      public
test_class.original_string: @Rule
      public ExpectedException thrown= ExpectedException.none();
test_class.type: ExpectedException
test_class.var_name: thrown
test_class.file: ch-sxmp/src/test/java/com/cloudhopper/sxmp/servlet/SxmpServletProcessorTest.java
test_class.identifier: SxmpServletProcessorTest
test_case.body: @Test
      public void doProcessSubmitWithSxmpErrorThrown() throws Exception {
          StringBuilder string0 = new StringBuilder(200)
              .append("<?xml version=\"1.0\"?>\n")
              .append("<operation type=\"submit\">\n")
              .append(" <account username=\"customer1\" password=\"test1\"/>\n")
              .append(" <submitRequest referenceId=\"MYREF102020022\">\n")
              .append("  <operatorId>10</operatorId>\n")
              .append("  <deliveryReport>true</deliveryReport>\n")
              .append("  <sourceAddress type=\"network\">40404</sourceAddress>\n")
              .append("  <destinationAddress type=\"international\">+12065551212</destinationAddress>\n")
              .append("  <text encoding=\"ISO-8859-1\">48656c6c6f20576f726c64</text>\n")
              .append(" </submitRequest>\n")
              .append("</operation>\n")
              .append("");
          
          ByteArrayInputStream is = new ByteArrayInputStream(string0.toString().getBytes());
          StringWriter sw = new StringWriter();
  
          SxmpProcessor requestProcessor = new SxmpProcessor() {
              public boolean authenticate(Account account) throws SxmpErrorException {
                  return true;
              }
  
              public SubmitResponse submit(Account account, SubmitRequest submitReq) throws SxmpErrorException {
                  throw new SxmpErrorException(SxmpErrorCode.INVALID_VALUE, "Short code not allowed");
              }
  
              public DeliverResponse deliver(Account account, DeliverRequest deliverRequest) throws SxmpErrorException {
                  throw new UnsupportedOperationException("Not supported yet.");
              }
  
              public DeliveryReportResponse deliveryReport(Account account, DeliveryReportRequest deliveryRequest) throws SxmpErrorException {
                  throw new UnsupportedOperationException("Not supported yet.");
              }
          };
  
          SxmpServletProcessor processor = new SxmpServletProcessor();
          processor.doProcess(requestProcessor, is, new PrintWriter(sw), "/1.0", "POST", "text/xml; charset=ISO-8859-1");
  
          logger.debug(sw.toString());
      }
test_case.class_method_signature: SxmpServletProcessorTest.doProcessSubmitWithSxmpErrorThrown()
test_case.full_signature: @Test public void doProcessSubmitWithSxmpErrorThrown()
test_case.identifier: doProcessSubmitWithSxmpErrorThrown
test_case.invocations: append append append append append append append append append append append append getBytes toString doProcess debug toString
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void doProcessSubmitWithSxmpErrorThrown()
focal_class.declarator: logger = LoggerFactory.getLogger(SxmpServletProcessor.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(SxmpServletProcessor.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: fatal = MarkerFactory.getMarker("FATAL")
focal_class.modifier: private static final
focal_class.original_string: private static final Marker fatal = MarkerFactory.getMarker("FATAL");
focal_class.type: Marker
focal_class.var_name: fatal
focal_class.file: ch-sxmp/src/main/java/com/cloudhopper/sxmp/servlet/SxmpServletProcessor.java
focal_class.identifier: SxmpServletProcessor
focal_class.class_method_signature: SxmpServletProcessor.SxmpServletProcessor()
focal_class.full_signature: public  SxmpServletProcessor()
focal_class.identifier: SxmpServletProcessor
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  SxmpServletProcessor()
focal_class.class_method_signature: SxmpServletProcessor.process(SxmpProcessor processor, HttpServletRequest request, HttpServletResponse response)
focal_class.full_signature: public void process(SxmpProcessor processor, HttpServletRequest request, HttpServletResponse response)
focal_class.identifier: process
focal_class.modifiers: public
focal_class.parameters: (SxmpProcessor processor, HttpServletRequest request, HttpServletResponse response)
focal_class.return: void
focal_class.signature: void process(SxmpProcessor processor, HttpServletRequest request, HttpServletResponse response)
focal_class.class_method_signature: SxmpServletProcessor.doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_class.full_signature: public static void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_class.identifier: doProcess
focal_class.modifiers: public static
focal_class.parameters: (SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_class.return: void
focal_class.signature: void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_method.body: public static void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType) throws IOException, HttpStatusCodeException {
          // validate the user went to the correct URL
          // E.g. /api/sxmp/1.0
          // find the next position of last / (to extract version)
          int posOfVersion = uri.lastIndexOf('/');
          if (posOfVersion < 0 || posOfVersion+1 >= uri.length()) {
              throw new HttpStatusCodeException(HttpServletResponse.SC_NOT_FOUND, "Bad URL used, could not extract version or no data for version");
          }
  
          String version = uri.substring(posOfVersion+1);
          //logger.debug("Parsed API Version: " + version);
  
          // check if the version is supported
          if (!version.equals(SxmpParser.VERSION_1_0) && !version.equals(SxmpParser.VERSION_1_1)) {
              throw new HttpStatusCodeException(HttpServletResponse.SC_BAD_REQUEST, "Unsupported API version in URL");
          }
  
          // validate the user did a POST
          if (!method.equalsIgnoreCase("POST")) {
              throw new HttpStatusCodeException(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Only HTTP POST methods are acceptable");
          }
  
          // validate the user posted "text/xml"
          //logger.debug("Request contentType: " + contentType);
          if (contentType == null || !contentType.toLowerCase().startsWith("text/xml")) {
              throw new HttpStatusCodeException(HttpServletResponse.SC_BAD_REQUEST, "Unsupported Content-Type HTTP Header - Must Be text/xml");
          }
  
          // create a new session tied to this processor
          SxmpSession session = new SxmpSession(processor, version);
  
          Response response = null;
          try {
              // process request, get response
              response = session.process(in);
          } catch (Exception e) {
              // any exception thrown in process() should generate a non-200 HTTP status code
              // the exception also would have already been logged in the SxmpSession, so we
              // won't print it here and duplicate it -- any error during processing
              // would actually have returned an ErrorResponse
              throw new HttpStatusCodeException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
          }
  
          // at this point, we should have a response
          if (response == null) {
              logger.error(fatal, "The response from SxmpSession.process() was null -- should be impossible");
              throw new HttpStatusCodeException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Response was empty");
          }
  
          try {
              // if we get here, write a response
              SxmpWriter.write(out, response);
          } catch (SxmpErrorException e) {
              logger.error("Error while writing response", e);
              throw new HttpStatusCodeException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Unable to cleanly write response to OutputStream");
          }
      }
focal_method.class_method_signature: SxmpServletProcessor.doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_method.full_signature: public static void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_method.identifier: doProcess
focal_method.invocations: lastIndexOf length substring equals equals equalsIgnoreCase startsWith toLowerCase process getMessage error write error
focal_method.modifiers: public static
focal_method.parameters: (SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)
focal_method.return: void
focal_method.signature: void doProcess(SxmpProcessor processor, InputStream in, PrintWriter out, String uri, String method, String contentType)