reSIProcate/stack  9694
Defines | Functions
testExternalBodyContents.cxx File Reference
#include <iostream>
#include <memory>
#include <list>
#include "rutil/DataStream.hxx"
#include "resip/stack/SipMessage.hxx"
#include "resip/stack/Helper.hxx"
#include "resip/stack/Uri.hxx"
#include "resip/stack/ExternalBodyContents.hxx"
#include "TestSupport.hxx"
#include "rutil/Logger.hxx"
Include dependency graph for testExternalBodyContents.cxx:

Go to the source code of this file.

Defines

#define CRLF   "\r\n"
#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Functions

int main (int argc, char *argv[])

Define Documentation

#define CRLF   "\r\n"

Definition at line 18 of file testExternalBodyContents.cxx.

#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Definition at line 20 of file testExternalBodyContents.cxx.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 23 of file testExternalBodyContents.cxx.

References resip::Data::c_str(), resip::Log::Cout, resip::Contents::getContents(), resip::SipMessage::header(), resip::Log::Info, resip::Log::initialize(), resip::SipMessage::isRequest(), resip::SipMessage::isResponse(), resip::TestSupport::makeMessage(), and resip::SipFrag::message().

{
  Log::initialize(Log::Cout, Log::Info, argv[0]);

  {  
     Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
              "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n"
              "To: Bob <sip:bob@biloxi.com>\r\n"
              "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
              "Call-ID: a84b4c76e66710\r\n"
              "CSeq: 314159 INVITE\r\n"
              "Max-Forwards: 70\r\n"
              "Contact: <sip:alice@pc33.atlanta.com>\r\n"
              "Content-Type: message/external-body\r\n"
              "Content-Length: 57\r\n"
              "\r\n"
              "Content-Type: text/plain\r\n"
              "Content-Length: 11\r\n");
     try
     {
        auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str()));
        Contents* body = msg->getContents();

        assert(body != 0);
        ExternalBodyContents* frag = dynamic_cast<ExternalBodyContents*>(body);
        assert(frag != 0);
        assert(frag->message().header(h_ContentType) == Mime("text", "plain"));
        assert(frag->message().header(h_ContentLength).value() == 11);
        assert(!(frag->message().isRequest() ||frag->message().isResponse()));
     }
     catch (BaseException& e)
     {
        assert(false);
     }
  }

  {
      Data txt("INVITE sip:bob@biloxi.com SIP/2.0\r\n"
               "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\r\n"
               "To: Bob <sip:bob@biloxi.com>\r\n"
               "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
               "Call-ID: a84b4c76e66710\r\n"
               "CSeq: 314159 INVITE\r\n"
               "Max-Forwards: 70\r\n"
               "Contact: <sip:alice@pc33.atlanta.com>\r\n"
               "Content-Type: message/sipfrag\r\n"
               "Content-Length: 35\r\n"
               "\r\n"
               "INVITE sip:bob@biloxi.com SIP/2.0\r\n");
      auto_ptr<SipMessage> msg(TestSupport::makeMessage(txt.c_str()));
      
      Contents* body = msg->getContents();

      assert(body);
      SipFrag* frag = dynamic_cast<SipFrag*>(body);
      assert(frag);
  }
  return 0;
}

Here is the call graph for this function: