예제 #1
0
  private void processMessage(Message message) throws IOException {
    if (message.getType().equals("SimpleMessage")) {
      MessageType messageType = (MessageType) message.getValue();
      String receiver = messageType.getToUser();
      history.get(receiver).add(messageType);
    }

    if (message.getType().equals("ConnectUserMessage")) {
      String user = (String) message.getValue();
      Messages messages = history.get(user);
      Operations.sendHistory(messages.getLastFiveWith(user), out);
    }
  }
예제 #2
0
 /**
  * ns4 is declared on Body and is used in faultcode. So making sure it is picked up after copy()
  */
 public void testCopy20() throws Exception {
   String soap18Msg =
       "<S:Envelope xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'>"
           + "<S:Body xmlns:ns4='http://schemas.xmlsoap.org/soap/envelope/'>"
           + "<S:Fault>"
           + "<faultcode>ns4:Server</faultcode>"
           + "<faultstring>com.sun.istack.XMLStreamException2</faultstring>"
           + "</S:Fault>"
           + "</S:Body>"
           + "</S:Envelope>";
   Message message = useStreamCodec(soap18Msg);
   message.copy();
   SOAPFaultBuilder.create(message).createException(null);
 }
예제 #3
0
 /**
  * ns4 is declared on Envelope and Body and is used in faultcode. So making sure the correct ns4
  * is picked up for payload source
  */
 public void testPayloadSource1() throws Exception {
   String soap18Msg =
       "<S:Envelope xmlns:S='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ns4='A'>"
           + "<S:Body xmlns:ns4='http://schemas.xmlsoap.org/soap/envelope/'>"
           + "<S:Fault>"
           + "<faultcode>ns4:Server</faultcode>"
           + "<faultstring>com.sun.istack.XMLStreamException2</faultstring>"
           + "</S:Fault>"
           + "</S:Body>"
           + "</S:Envelope>";
   Message message = useStreamCodec(soap18Msg);
   Source source = message.readPayloadAsSource();
   InputStream is = getInputStream(source);
   XMLStreamReader xsr = XMLInputFactory.newInstance().createXMLStreamReader(is);
   xsr.next();
   xsr.next();
   assertEquals("http://schemas.xmlsoap.org/soap/envelope/", xsr.getNamespaceURI("ns4"));
 }
예제 #4
0
  private void prepareClient() throws IOException {
    logger.info("Waiting for client's name");
    Message mes = Operations.receive(in);
    setClientName((String) mes.getValue());
    logger.info("Username for " + s.getInetAddress() + " received: " + userName);

    users.add(this);
    logger.info("User " + getClientName() + " has been added to the userlist.");

    messages = new Messages();
    logger.info("Message list created");

    if (!history.containsKey(userName)) {
      history.put(userName, messages);
    } else {
      messages = history.get(userName);
    }
    messages.addObserver(this);
    logger.info("Message list assigned to history");

    logger.info("Sending the list of users.");
    Operations.sendUserNamesList(users.getUserNames(), out);
    logger.info("Userlist has been sent");
  }
예제 #5
0
 public void testCopy16() throws IOException {
   String soap16Msg =
       "<S:Envelope xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'> <S:Body> <a> </a><b> </b> <c/> </S:Body> </S:Envelope>";
   Message message = useStreamCodec(soap16Msg);
   message.copy();
 }
예제 #6
0
 public void testCopyWithSpaces() throws IOException {
   String soap12Msg =
       "<?xml version='1.0'?><S:Envelope xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'> <S:Header> <m:ut xmlns:m='a'> <u xmlns='' id='a'>user</u> </m:ut> <b> hello </b> </S:Header> <S:Body> <ns2:c xmlns:ns2='local'> <clientName>Test</clientName> <ns2:year>2007</ns2:year> </ns2:c> </S:Body> </S:Envelope>";
   Message message = useStreamCodec(soap12Msg);
   message.copy();
 }
예제 #7
0
 public void testCopyStreamMessage1() throws IOException {
   String soap11Msg =
       "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'><Header xmlns='http://schemas.xmlsoap.org/soap/envelope/'> <SubscriptionInfo xmlns='http://ws.strikeiron.com'> <LicenseStatusCode>0</LicenseStatusCode> </SubscriptionInfo> </Header> <soap:Body> <GetCountryCodesResponse xmlns='http://www.strikeiron.com'> <GetCountryCodesResult/></GetCountryCodesResponse></soap:Body></soap:Envelope>";
   Message message = useStreamCodec(soap11Msg);
   message.copy();
 }