text:
import django.http
from django.views.decorators.cache import cache_control
from django.contrib.auth.decorators import login_required
import MySQLdb
import cStringIO
import re

from ndauth.authentication import PublicAuthentication, AnonAllowedAuthentication
from rest_framework.authentication import SessionAuthentication, TokenAuthentication
from rest_framework.decorators import api_view, authentication_classes, permission_classes
from rest_framework.permissions import IsAuthenticated, AllowAny
from nduser.models import Token

import webservices.ndwsrest as ndwsrest
import webservices.ndwsprojingest as ndwsprojingest
from webservices.ndwserror import NDWSError, IncorrectSyntaxError
import logging
logger=logging.getLogger("neurodata")

GET_SLICE_SERVICES = ['xy', 'yz', 'xz']
GET_ANNO_SERVICES = ['xyanno', 'yzanno', 'xzanno']
POST_SERVICES = ['hdf5', 'npz', 'raw', 'hdf5_async', 'propagate', 'tiff', 'blosc', 'blaze']

@api_view(['GET','POST'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def cutout (request, webargs):
  """Restful URL for all read services to annotation projects"""

  try:
    m = re.match(r"(\w+)/(?P<channel>[\w+,-]+)?/?(xy|xz|yz|tiff|hdf5|jpeg|blosc|blaze|npz|raw|zip|id|diff|ids|xyanno|xzanno|yzanno)/([\w\.,/-]*)$", webargs)
    [token, channel, service, cutoutargs] = [i for i in m.groups()]

    if channel is None:
      webargs = '{}/default/{}/{}'.format(token, service, cutoutargs)

  except Exception as e:
    logger.warning("Incorrect format for arguments {}. {}".format(webargs, e))
    raise IncorrectSyntaxError("Incorrect format for arguments {}. {}".format(webargs, e))

  try:
    # GET methods
    if request.method == 'GET':
      if service in GET_SLICE_SERVICES+GET_ANNO_SERVICES:
        return django.http.HttpResponse(ndwsrest.getCutout(webargs), content_type="image/png" )
      elif service in ['hdf5']:
        fname = re.sub ( r',','_', webargs )
        fname = re.sub ( r'/','-', fname )
        response = django.http.HttpResponse(ndwsrest.getCutout(webargs), content_type="product/hdf5" )
        response['Content-Disposition'] = "attachment; filename={}ndcutout.h5".format(fname)
        return response
      elif service in ['blosc', 'diff']:
        fname = re.sub ( r',','_', webargs )
        fname = re.sub ( r'/','-', fname )
        response = django.http.HttpResponse(ndwsrest.getCutout(webargs), content_type="product/blosc" )
        response['Content-Disposition'] = "attachment; filename={}ndcutout.blosc".format(fname)
        return response
      elif service in ['jpeg']:
        fname = re.sub ( r',','_', webargs )
        fname = re.sub ( r'/','-', fname )
        response = django.http.HttpResponse(ndwsrest.getCutout(webargs), content_type="product/jpeg" )
        response['Content-Disposition'] = "attachment; filename={}ndcutout.jpeg".format(fname)
        return response
      elif service in ['npz']:
        return django.http.HttpResponse(ndwsrest.getCutout(webargs), content_type="product/npz" )
      elif service in ['raw']:
        fname = re.sub ( r',','_', webargs )
        fname = re.sub ( r'/','-', fname )
        response = django.http.HttpResponse(ndwsrest.getCutout(webargs), content_type="product/raw" )
        response['Content-Disposition'] = "attachment; filename={}ndcutout.raw".format(fname)
        return response
      elif service in ['tiff']:
        # build a file name from the webarguments
        fname = re.sub ( r',','_', webargs )
        fname = re.sub ( r'/','-', fname )
        response = django.http.HttpResponse(ndwsrest.getCutout(webargs), content_type="image/tiff" )
        response['Content-Disposition'] = "attachment; filename={}ndcutout.tif".format(fname)
        return response
      elif service in ['zip']:
        return django.http.HttpResponse(ndwsrest.getCutout(webargs), content_type="product/zip" )
      elif service in ['id','ids']:
        return django.http.HttpResponse(ndwsrest.getCutout(webargs))
      elif service in ['blaze']:
        logger.warning("HTTP Bad request. {} service not supported for GET. Only for POST".format(service))
        return django.http.HttpResponseBadRequest("{} service not supported for GET. Only for POST".format(service))
      else:
        logger.warning("HTTP Bad request. Could not find service {}".format(service))
        return django.http.HttpResponseBadRequest("Could not find service {}".format(service))

    # RBTODO control caching?
    # POST methods
    elif request.method == 'POST':

      if service in POST_SERVICES:
        django.http.HttpResponse(ndwsrest.postCutout(webargs, request.body))
        return django.http.HttpResponse("Success", content_type='text/html')
      else:
        logger.warning("HTTP Bad request. Could not find service {}".format(service))
        return django.http.HttpResponseBadRequest("Could not find service {}".format(service))

    else:
      logger.warning("Invalid HTTP method {}. Not GET or POST.".format(request.method))
      return django.http.HttpResponseBadRequest("Invalid HTTP method {}. Not GET or POST.".format(request.method))

  except NDWSError as e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error as e:
    return django.http.HttpResponseNotFound(e)
  except Exception as e:
    logger.exception("Unknown exception in getCutout. {}".format(e))
    raise NDWSError("Unknown exception in getCutout. {}".format(e))

@api_view(['GET','POST'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def nifti (request, webargs):
  """Get put interface for nifti files"""

  try:
    if request.method == 'GET':
      fname = "".join([x if x.isalnum() else "_" for x in webargs])
      response = django.http.HttpResponse(ndwsrest.getNIFTI(webargs), content_type="product/nii" )
      response['Content-Disposition'] = "attachment; filename={}.nii.gz".format(fname)
      return response
    elif request.method == 'POST':
      return django.http.HttpResponse(ndwsrest.putNIFTI(webargs,request.body))
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in NIFTI. {}".format(e))
    raise NDWSError("Unknown exception in NIFTI. {}".format(e))
    raise

@api_view(['GET','POST'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def swc (request, webargs):
  """Get put interface for swc tracing files"""

  try:
    if request.method == 'GET':
      fname = "".join([x if x.isalnum() else "_" for x in webargs])
      response = django.http.HttpResponse(ndwsrest.getSWC(webargs), content_type="product/swc" )
      response['Content-Disposition'] = "attachment; filename={}.swc".format(fname)
      return response
    elif request.method == 'POST':
      return django.http.HttpResponse(ndwsrest.putSWC(webargs,request.body))
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in SWC. {}".format(e))
    raise NDWSError("Unknown exception in SWC. {}".format(e))
    raise

@api_view(['GET', 'POST', 'DELETE'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def jsonramon (request, webargs):
  """Get put object interface for JSON-ified RAMON objects"""

  [token, channel, rest] = webargs.split('/',2)

  try:
    if request.method == 'GET':
      print "JSON get"
      return django.http.HttpResponse(ndwsrest.getJSONAnnotation(webargs), content_type="application/json" )
    elif request.method == 'POST':
      print "JSON post"
      return django.http.HttpResponse(ndwsrest.putJSONAnnotation(webargs,request.body))
    elif request.method == 'DELETE':
      ndwsrest.deleteAnnotation(webargs)
      return django.http.HttpResponse ("Success", content_type='text/html')
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in jsonramon. {}".format(e))
    raise NDWSError("Unknown exception in jsonramon. {}".format(e))

@api_view(['GET', 'POST', 'DELETE'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def annotation (request, webargs):
  """Get put object interface for RAMON objects"""
  [token, channel, rest] = webargs.split('/',2)

  try:
    if request.method == 'GET':
      # check for json vs hdf5
      if rest.split('/')[1] == 'json':
        return django.http.HttpResponse(ndwsrest.getAnnotation(webargs), content_type="application/json" )
      else:
        return django.http.HttpResponse(ndwsrest.getAnnotation(webargs), content_type="product/hdf5" )
    elif request.method == 'POST':
      return django.http.HttpResponse(ndwsrest.putAnnotation(webargs,request.body))
    elif request.method == 'DELETE':
      ndwsrest.deleteAnnotation(webargs)
      return django.http.HttpResponse ("Success", content_type='text/html')
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in annotation. {}".format(e))
    raise NDWSError("Unknown exception in annotation. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def csv (request, webargs):
  """Get (not yet put) csv interface for RAMON objects"""

  try:
    if request.method == 'GET':
      return django.http.HttpResponse(ndwsrest.getCSV(webargs), content_type="text/html" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in csv. {}".format(e))
    raise NDWSError("Unknown exception in csv. {}".format(e))

@api_view(['GET','POST'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def queryObjects ( request, webargs ):
  """Return a list of objects matching predicates and cutout"""

  try:
    if request.method == 'GET':
      return django.http.HttpResponse(ndwsrest.queryAnnoObjects(webargs), content_type="product/hdf5")
    elif request.method == 'POST':
      return django.http.HttpResponse(ndwsrest.queryAnnoObjects(webargs,request.body), content_type="product/hdf5")

  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in listObjects. {}".format(e))
    raise NDWSError("Unknown exception in listObjects. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def catmaid (request, webargs):
  """Convert a CATMAID request into an cutout."""

  try:
    catmaidimg = ndwsrest.ndcatmaid_legacy(webargs)

    fobj = cStringIO.StringIO ( )
    catmaidimg.save ( fobj, "PNG" )
    fobj.seek(0)
    return django.http.HttpResponse(fobj.read(), content_type="image/png")

  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in catmaid {}.".format(e))
    raise NDWSError("Unknown exception in catmaid {}.".format(e))

@api_view(['GET'])
@permission_classes((AllowAny,))
def publictokens (request, webargs):
  """Return list of public tokens"""
  try:
    return django.http.HttpResponse(ndwsrest.publicTokens(webargs), content_type="application/json" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in publictokens. {}".format(e))
    raise NDWSError("Unknown exception in publictokens. {}".format(e))

@api_view(['GET'])
@permission_classes((AllowAny,))
def publicdatasets (request, webargs):
  """Return list of public datasets"""
  try:
    return django.http.HttpResponse(ndwsrest.publicDatasets(webargs), content_type="application/json" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in publictokens. {}".format(e))
    raise NDWSError("Unknown exception in publictokens. {}".format(e))

@api_view(['GET'])
@authentication_classes((AnonAllowedAuthentication,))
@permission_classes((PublicAuthentication,))
def jsoninfo (request, webargs):
  """Return project and dataset configuration information"""

  try:
    return django.http.HttpResponse(ndwsrest.jsonInfo(webargs), content_type="application/json" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in jsoninfo. {}".format(e))
    raise NDWSError("Unknown exception in jsoninfo. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def xmlinfo (request, webargs):
  """Return project and dataset configuration information"""

  try:
    return django.http.HttpResponse(ndwsrest.xmlInfo(webargs), content_type="application/xml" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in xmlinfo. {}".format(e))
    raise NDWSError("Unknown exception in xmlinfo. {}".format(e))

@api_view(['GET'])
@authentication_classes((AnonAllowedAuthentication,))
@permission_classes((PublicAuthentication,))
def projinfo (request, webargs):
  """Return project and dataset configuration information"""

  try:
    return django.http.HttpResponse(ndwsrest.projInfo(webargs), content_type="product/hdf5" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in projInfo. {}".format(e))
    raise NDWSError("Unknown exception in projInfo. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def mcFalseColor (request, webargs):
  """Cutout of multiple channels with false color rendering"""

  try:
    return django.http.HttpResponse(ndwsrest.mcFalseColor(webargs), content_type="image/png" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in mcFalseColor. {}".format(e))
    raise NDWSError("Unknown exception in mcFalseColor. {}".format(e))

@api_view(['POST'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def reserve (request, webargs):
  """Preallocate a range of ids to an application."""

  try:
    return django.http.HttpResponse(ndwsrest.reserve(webargs), content_type="application/json" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in reserve. {}".format(e))
    raise NDWSError("Unknown exception in reserve. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def setField (request, webargs):
  """Set an individual RAMON field for an object"""

  try:
    ndwsrest.setField(webargs)
    return django.http.HttpResponse()
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in setField. {}".format(e))
    raise NDWSError("Unknown exception in setField. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def getField (request, webargs):
  """Get an individual RAMON field for an object"""

  try:
    return django.http.HttpResponse(ndwsrest.getField(webargs), content_type="text/html" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in getField. {}".format(e))
    raise NDWSError("Unknown exception in getField. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def getPropagate (request, webargs):
  """ Get the value for Propagate field for a given project """

  try:
    return django.http.HttpResponse(ndwsrest.getPropagate(webargs), content_type="text/html" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in getPropagate. {}".format(e))
    raise NDWSError("Unknown exception in getPropagate. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def setPropagate (request, webargs):
  """ Set the value for Propagate field for a given project """

  try:
    ndwsrest.setPropagate(webargs)
    return django.http.HttpResponse()
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in setPropagate. {}".format(e))
    raise NDWSError("Unknown exception in setPropagate. {}".format(e))

@api_view(['POST'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def merge (request, webargs):
  """Merge annotation objects"""

  try:
    return django.http.HttpResponse(ndwsrest.merge(webargs), content_type="text/html" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in global Merge. {}".format(e))
    raise NDWSError("Unknown exception in global Merge. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def exceptions (request, webargs):
  """Return a list of multiply labeled pixels in a cutout region"""

  try:
    return django.http.HttpResponse(ndwsrest.exceptions(webargs), content_type="product/hdf5" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in exceptions Web service. {}".format(e))
    raise NDWSError("Unknown exception in exceptions Web service. {}".format(e))

@api_view(['GET'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def minmaxProject (request, webargs):
  """Restful URL for all read services to annotation projects"""

  try:
    return django.http.HttpResponse(ndwsrest.minmaxProject(webargs), content_type="image/png" )
  except NDWSError, e:
    return django.http.HttpResponseNotFound(e.value)
  except MySQLdb.Error, e:
    return django.http.HttpResponseNotFound(e)
  except Exception, e:
    logger.exception("Unknown exception in (min|max) projection Web service. {}".format(e))
    raise NDWSError("Unknown exception in (min|max) projection Web service. {}".format(e))

# @api_view(['POST'])
# @authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
# @permission_classes((PublicAuthentication,))
def autoIngest(request, webargs):
  """RESTful URL for creating a project using a JSON file"""

  try:
    return ndwsprojingest.autoIngest(webargs, request.body)
  except NDWSError, e:
    return django.http.HttpResponseNotFound()
  except Exception, e:
    logger.exception("Unknown exception in jsonProject Web service. {}".format(e))
    raise NDWSError("Unknown exception in jsonProject Web service. {}".format(e))

@api_view(['POST'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def createChannel(request, webargs):
  """RESTful URL for creating a list of channels using a JSON file"""

  try:
    return ndwsprojingest.createChannel(webargs, request.body)
  except NDWSError, e:
    return django.http.HttpResponseNotFound()
  except Exception, e:
    logger.exception("Unknown exception in jsonProject Web service. {}".format(e))
    raise NDWSError("Unknown exception in jsonProject Web service. {}".format(e))

@api_view(['POST'])
@authentication_classes((SessionAuthentication, AnonAllowedAuthentication))
@permission_classes((PublicAuthentication,))
def deleteChannel(request, webargs):
  """RESTful URL for deleting a list of channels using a JSON file"""

  try:
    return ndwsprojingest.deleteChannel(webargs, request.body)
  except NDWSError, e:
    return django.http.HttpResponseNotFound()
  except Exception, e:
    logger.exception("Unknown exception in jsonProject Web service. {}".format(e))
    raise NDWSError("Unknown exception in jsonProject Web service. {}".format(e))


text:
using namespace Rcpp;

// metadataFeather
List metadataFeather(const std::string& path);
RcppExport SEXP feather_metadataFeather(SEXP pathSEXP) {
BEGIN_RCPP
    Rcpp::RObject __result;
    Rcpp::RNGScope __rngScope;
    Rcpp::traits::input_parameter< const std::string& >::type path(pathSEXP);
    __result = Rcpp::wrap(metadataFeather(path));
    return __result;
END_RCPP
}
// openFeather
List openFeather(const std::string& path);
RcppExport SEXP feather_openFeather(SEXP pathSEXP) {
BEGIN_RCPP
    Rcpp::RObject __result;
    Rcpp::RNGScope __rngScope;
    Rcpp::traits::input_parameter< const std::string& >::type path(pathSEXP);
    __result = Rcpp::wrap(openFeather(path));
    return __result;
END_RCPP
}
// rowsFeather
double rowsFeather(const List& feather);
RcppExport SEXP feather_rowsFeather(SEXP featherSEXP) {
BEGIN_RCPP
    Rcpp::RObject __result;
    Rcpp::RNGScope __rngScope;
    Rcpp::traits::input_parameter< const List& >::type feather(featherSEXP);
    __result = Rcpp::wrap(rowsFeather(feather));
    return __result;
END_RCPP
}
// coldataFeather
List coldataFeather(const List& feather, const IntegerVector& indexes);
RcppExport SEXP feather_coldataFeather(SEXP featherSEXP, SEXP indexesSEXP) {
BEGIN_RCPP
    Rcpp::RObject __result;
    Rcpp::RNGScope __rngScope;
    Rcpp::traits::input_parameter< const List& >::type feather(featherSEXP);
    Rcpp::traits::input_parameter< const IntegerVector& >::type indexes(indexesSEXP);
    __result = Rcpp::wrap(coldataFeather(feather, indexes));
    return __result;
END_RCPP
}
// writeFeather
void writeFeather(DataFrame df, const std::string& path);
RcppExport SEXP feather_writeFeather(SEXP dfSEXP, SEXP pathSEXP) {
BEGIN_RCPP
    Rcpp::RNGScope __rngScope;
    Rcpp::traits::input_parameter< DataFrame >::type df(dfSEXP);
    Rcpp::traits::input_parameter< const std::string& >::type path(pathSEXP);
    writeFeather(df, path);
    return R_NilValue;
END_RCPP
}

redpajama_set_name: RedPajamaGithub


text:
package com.popbill.api.kako.test;

import static org.junit.Assert.assertNotNull;

import java.io.File;
import java.util.ArrayList;

import org.junit.Test;

import com.popbill.api.ChargeInfo;
import com.popbill.api.KakaoService;
import com.popbill.api.PopbillException;
import com.popbill.api.Response;
import com.popbill.api.kakao.ATSTemplate;
import com.popbill.api.kakao.KakaoButton;
import com.popbill.api.kakao.KakaoReceiver;
import com.popbill.api.kakao.KakaoSearchResult;
import com.popbill.api.kakao.KakaoSentInfo;
import com.popbill.api.kakao.KakaoServiceImp;
import com.popbill.api.kakao.KakaoType;
import com.popbill.api.kakao.PlusFriendID;
import com.popbill.api.kakao.SenderNumber;

public class KakaoServiceTest {
    private final String testLinkID = "TESTER";
    private final String testSecretKey = "SwWxqU+0TErBXy/9TVjIPEnI0VTUMMSQZtJf3Ed8q3I=";

    private KakaoService kakaoService;

    public KakaoServiceTest() {
        KakaoServiceImp service = new KakaoServiceImp();

        service.setLinkID(testLinkID);
        service.setSecretKey(testSecretKey);
        service.setTest(true);

        kakaoService = service;
    }

    @Test
    public void GetPlusFriendMgtURL_TEST() throws PopbillException {

        String url = kakaoService.getPlusFriendMgtURL("1234567890","testkorea");

        System.out.println(url);
    }

    @Test
    public void listPlusFriend_TEST() throws PopbillException {

        PlusFriendID[] friendList = kakaoService.listPlusFriendID("1234567890");

        int i;
        for (i=0; i<friendList.length; i++){
            System.out.println(friendList[i].getPlusFriendID());
            System.out.println(friendList[i].getPlusFriendName());
            System.out.println(friendList[i].getRegDT());
            System.out.println(friendList[i].getState());
            System.out.println(friendList[i].getStateDT());
        }
    }

    @Test
    public void checkSenderNumber_TEST() throws PopbillException {
        Response response = kakaoService.checkSenderNumber("1234567890", "1400-00");
        assertNotNull(response);

        System.out.println(response.getCode());
        System.out.println(response.getMessage());
    }

    @Test
    public void GetSenderNumerMgtURL_TEST() throws PopbillException {

        String url = kakaoService.getSenderNumberMgtURL("1234567890","testkorea");

        System.out.println(url);
    }

    @Test
    public void getSenderNumberList_TEST() throws PopbillException {

        SenderNumber[] listInfo = kakaoService.getSenderNumberList("1234567890");

        int i;
        for (i=0; i<listInfo.length; i++){
            System.out.println(listInfo[i].getNumber());
            System.out.println(listInfo[i].getState());
            System.out.println(listInfo[i].getRepresentYN());
            System.out.println(listInfo[i].getMemo());
        }
    }

    @Test
    public void GetATSTemplateMgtURL_TEST() throws PopbillException {

        String url = kakaoService.getATSTemplateMgtURL("1234567890","testkorea");

        System.out.println(url);
    }

    @Test
    public void getATSTemplate_TEST() throws PopbillException {

        ATSTemplate templateInfo = kakaoService.getATSTemplate("1234567890", "022070000338");

        assertNotNull(templateInfo);

        System.out.println(templateInfo.getPlusFriendID());
        System.out.println(templateInfo.getTemplateCode());
        System.out.println(templateInfo.getTemplateName());
        System.out.println(templateInfo.getTemplate());
        System.out.println(templateInfo.getAds());
        System.out.println(templateInfo.getAppendix());
        System.out.println(templateInfo.getBtns());
        System.out.println(templateInfo.getSecureYN());
        System.out.println(templateInfo.getState());
        System.out.println(templateInfo.getStateDT());
    }

    @Test
    public void listATSTempalte_TEST() throws PopbillException {

        ATSTemplate[] templateList = kakaoService.listATSTemplate("1234567890");

        int i;
        for (i=0; i<templateList.length; i++){
            System.out.println(templateList[i].getTemplateCode());
            System.out.println(templateList[i].getTemplateName());
            System.out.println(templateList[i].getTemplate());
            System.out.println(templateList[i].getPlusFriendID());
            System.out.println(templateList[i].getAds());
            System.out.println(templateList[i].getAppendix());
            System.out.println(templateList[i].getBtns());
            System.out.println(templateList[i].getSecureYN());
            System.out.println(templateList[i].getState());
            System.out.println(templateList[i].getStateDT());
        }
    }

    @Test
    public void sendATS_01_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "01수신자명";
        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altContent, altSendType,
                receiverNum, receiverName, sndDT);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_02_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "01022223333";
        String receiverName = "02수신자명";
        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altContent, altSendType,
                receiverNum, receiverName, sndDT, "testkorea");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_03_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "03수신자명";
        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altContent, altSendType,
                receiverNum, receiverName, sndDT, "testkorea", "20180724_ats_13");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_04_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altSubject = "대체문자제목";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "03수신자명";
        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altSubject, altContent, altSendType,
                receiverNum, receiverName, sndDT, "testkorea", "20180724_ats_13");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_05_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altContent = "대체문자 내용";
        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("04-1수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[0] = message;
        message.setReceiverNum("010111222");
        message.setReceiverName("04-2수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[1] = message;

        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, altSendType, receivers, sndDT);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_06_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altContent = "대체문자 내용";
        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("05-1수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[0] = message;
        message.setReceiverNum("010111222");
        message.setReceiverName("05-2수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[1] = message;

        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, altSendType, receivers, sndDT,
                "testkorea");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_07_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altContent = "대체문자 내용";
        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("06-1수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[0] = message;
        message.setReceiverNum("010111222");
        message.setReceiverName("06-2수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[1] = message;

        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, altSendType, receivers, sndDT,
                "testkorea", "20180724_ats_16");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_08_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altContent = "대체문자 내용";
        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("07-1수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[0] = message;
        message.setReceiverNum("010111222");
        message.setReceiverName("07-2수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[1] = message;

        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altContent,
                altSendType, receivers, sndDT);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_09_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "018060000159";
        String senderNum = "01011112222";
        String content = "[믿을 수 있는 팝빌]"
                + "안녕하세요. "
                + "고객 님!고객님의 공인인증서가 등록처리 되었음을 알려드립니다!"
                + "- 등록일자 : 2018-07-24 "
                + "- 인증서용도 : 전자세금계산서용 공인인증서 삭제는 팝빌 사이트에서 가능합니다. "
                + "감사합니다.";
        String altContent = "대체문자 내용";
        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("08-1수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[0] = message;
        message.setReceiverNum("010111222");
        message.setReceiverName("08-2수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[1] = message;

        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altContent,
                altSendType, receivers, sndDT, "testkorea");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_10_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "019020000163";
        String senderNum = "07043042991";
        String content = "[ 팝빌 ]\n"
                + "신청하신 #{템플릿코드}에 대한 심사가 완료되어 승인 처리되었습니다."
                + "해당 템플릿으로 전송 가능합니다.\n\n"
                + "문의사항 있으시면 파트너센터로 편하게 연락주시기 바랍니다.\n\n"
                + "팝빌 파트너센터 : 1600-8536\n"
                + "support@linkhub.co.kr";
        String altContent = "대체문자 내용";
        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("09-1수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[0] = message;

        String sndDT = "";

        KakaoButton[] btns = new KakaoButton[1];
        KakaoButton button = new KakaoButton();
        button.setN("템플릿 안내");
        button.setT("WL");
        button.setU1("https://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altContent,
                altSendType, receivers, sndDT, "testkorea", "", btns);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_11_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String templateCode = "019020000163";
        String senderNum = "07043042991";
        String content = "[ 팝빌 ]\n"
                + "신청하신 #{템플릿코드}에 대한 심사가 완료되어 승인 처리되었습니다."
                + "해당 템플릿으로 전송 가능합니다.\n\n"
                + "문의사항 있으시면 파트너센터로 편하게 연락주시기 바랍니다.\n\n"
                + "팝빌 파트너센터 : 1600-8536\n"
                + "support@linkhub.co.kr";
        String altSubject = "대체문자 제목";
        String altContent = "대체문자 내용";
        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("09-1수신자명");
        message.setMessage(content);
        message.setAltMessage(altContent);
        receivers[0] = message;

        String sndDT = "";

        KakaoButton[] btns = new KakaoButton[1];
        KakaoButton button = new KakaoButton();
        button.setN("템플릿 안내");
        button.setT("WL");
        button.setU1("https://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altSubject, altContent,
                altSendType, receivers, sndDT, "testkorea", "", btns);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_01_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "01수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_02_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "02수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN,
                "testkorea");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_03_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "03수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN,
                "testkorea", "20180724_fts_13");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_04_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altSubject = "";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "03수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altSubject, altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN,
                "testkorea", "20180724_fts_13");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_05_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "07043042991";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = true;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명ddd");
        button.setT("WL");
        button.setU1("http://dddwww.popbill.com");
        button.setU2("http://dddtest.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("04-1수신자명");
        message.setBtns(new ArrayList<KakaoButton>());
        message.getBtns().add(btns[0]);
        message.getBtns().add(btns[1]);

        receivers[0] = message;

        button = new KakaoButton();
        button.setN("버튼명ddd");
        button.setT("WL");
        button.setU1("http://cccwww.popbill.com");
        button.setU2("http://ccctest.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("04-2수신자명");
        message.setBtns(new ArrayList<KakaoButton>());
        message.getBtns().add(btns[0]);
        message.getBtns().add(btns[1]);

        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, receivers, btns, sndDT, adsYN);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_06_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = true;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("05-1수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("05-2수신자명");
        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, receivers, btns, sndDT, adsYN, "testkorea");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_07_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = true;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("06-1수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("06-2수신자명");
        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, receivers, btns, sndDT, adsYN, "testkorea", "20180724_fts_16");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_08_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altSubject = "대체문자 제목";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = true;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("06-1수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("06-2수신자명");
        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
               altSubject, altContent, altSendType, receivers, btns, sndDT, adsYN, "testkorea", "20180724_fts_16");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_09_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("07-1수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요1");
        message.setAltMessage("대체문자 내용");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("07-2수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요2");
        message.setAltMessage("대체문자 내용");
        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, altSendType,
                receivers, btns, sndDT, adsYN);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_10_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("08-1수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요1");
        message.setAltMessage("대체문자 내용");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("08-2수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요2");
        message.setAltMessage("대체문자 내용");
        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, altSendType,
                receivers, btns, sndDT, adsYN, "testkorea");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_11_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("09-1수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요1");
        message.setAltMessage("대체문자 내용");
        message.setInterOPRefKey("01");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("09-2수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요2");
        message.setAltMessage("대체문자 내용");
        message.setInterOPRefKey("02");
        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, altSendType,
                receivers, btns, sndDT, adsYN, "testkorea", "20190203_01");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_01_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용~~!";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "01수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";
        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN, file, imageURL);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_02_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용~~!";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "02수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";
        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN, file, imageURL,
                "testkorea");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_03_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용~~!";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "03수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";
        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN, file, imageURL,
                "testkorea" , "20180724_fms_13");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_04_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용~~!";
        String altSubject = "대체문자 제목";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "010111222";
        String receiverName = "03수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";
        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content, altSubject,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN, file, imageURL,
                "testkorea" , "20180724_fms_13");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_05_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("04-1수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010222333");
        message.setReceiverName("04-2수신자명");
        receivers[1] = message;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";

        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, receivers, btns, sndDT, adsYN, file, imageURL);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_06_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("05-1수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010222333");
        message.setReceiverName("05-2수신자명");
        receivers[1] = message;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";

        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, receivers, btns, sndDT, adsYN, file, imageURL,
                "testkorea");

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_07_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("06-1수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010222333");
        message.setReceiverName("06-2수신자명");
        receivers[1] = message;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";

        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, receivers, btns, sndDT, adsYN, file, imageURL,
                "testkorea", "20180724_fms_16");

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_08_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String content = "친구톡 메시지 내용";
        String altSubject = "대체문자 제목";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("06-1수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010222333");
        message.setReceiverName("06-2수신자명");
        receivers[1] = message;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";

        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altSubject, altContent, altSendType, receivers, btns, sndDT, adsYN, file, imageURL,
                "testkorea", "20180724_fms_16");

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_09_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = true;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("07-1수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요1");
        message.setAltMessage("대체문자 내용");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("07-2수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요2");
        message.setAltMessage("대체문자 내용");
        receivers[1] = message;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";
        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, altSendType,
                receivers, btns, sndDT, adsYN, file, imageURL);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_10_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = true;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("08-1수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요1");
        message.setAltMessage("대체문자 내용");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("08-2수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요2");
        message.setAltMessage("대체문자 내용");
        receivers[1] = message;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";
        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, altSendType,
                receivers, btns, sndDT, adsYN, file, imageURL, "testkorea");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_11_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "01011112222";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = true;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("010111222");
        message.setReceiverName("09-1수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요1");
        message.setAltMessage("대체문자 내용");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("010333444");
        message.setReceiverName("09-2수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요2");
        message.setAltMessage("대체문자 내용");
        receivers[1] = message;

        File file = new File("./test.jpg");
        String imageURL = "http://test.popbill.com";
        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, altSendType,
                receivers, btns, sndDT, adsYN, file, imageURL, "testkorea", "20180724_fms_19");

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_Single_TEST() throws PopbillException {
        String testCorpNum = "1234567890";

        String templateCode = "018020000001";

        String senderNum = "07043042993";

        String content = "[테스트] 테스트 템플릿입니다.d";

        String altContent = "대체문자 내용";

        String altSendType = "";

        String receiverNum = "01022223333";

        String receiverName = "수신자명";

        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altContent, altSendType,
                receiverNum, receiverName, sndDT);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_same_TEST() throws PopbillException {
        String testCorpNum = "1234567890";

        String templateCode = "018020000001";

        String senderNum = "07043042993";

        String content = "[테스트] 테스트 템플릿입니다";

        String altContent = "대체문자 내용";

        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        receivers[0] = message;
        receivers[1] = message;

        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, content, altContent, altSendType, receivers, sndDT);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendATS_multi_TEST() throws PopbillException {
        String testCorpNum = "1234567890";

        String templateCode = "018020000001";

        String senderNum = "07043042993";

        String altSendType = "";

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다");
        message.setAltMessage("대체문자 내용");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요");
        message.setAltMessage("대체문자 내용");
        receivers[1] = message;

        String sndDT = "";

        String receiptNum = kakaoService.sendATS(testCorpNum, templateCode, senderNum, altSendType, receivers, sndDT);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_single_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "07043042993";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "01022223333";
        String receiverName = "수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_same_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "07043042993";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, receivers, btns, sndDT, adsYN);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFTS_multi_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "07043042993";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요1");
        message.setAltMessage("대체문자 내용");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요2");
        message.setAltMessage("대체문자 내용");
        receivers[1] = message;

        String receiptNum = kakaoService.sendFTS(testCorpNum, plusFriendID, senderNum, altSendType,
                receivers, btns, sndDT, adsYN);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_single_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "07043042993";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String receiverNum = "01022223333";
        String receiverName = "수신자명";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        File file = new File("/Users/John/Desktop/tmp/test03.jpg");

        String imageURL = "http://test.popbill.com";

        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, btns, receiverNum, receiverName, sndDT, adsYN, file, imageURL);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_same_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "07043042993";
        String content = "친구톡 메시지 내용";
        String altContent = "대체문자 내용";
        String altSendType = "";
        String sndDT = "";
        Boolean adsYN = false;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        receivers[1] = message;

        File file = new File("/Users/John/Desktop/tmp/test03.jpg");

        String imageURL = "http://test.popbill.com";

        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, content,
                altContent, altSendType, receivers, btns, sndDT, adsYN, file, imageURL);

        assertNotNull(receiptNum);

        System.out.println(receiptNum);
    }

    @Test
    public void sendFMS_multi_TEST() throws PopbillException {
        String testCorpNum = "1234567890";
        String plusFriendID = "@팝빌";
        String senderNum = "07043042993";
        String altSendType = "";
        String sndDT = "20180305200000";
        Boolean adsYN = true;

        KakaoButton[] btns = new KakaoButton[2];
        KakaoButton button = new KakaoButton();
        button.setN("버튼명");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[0] = button;

        button = new KakaoButton();
        button.setN("버튼명2");
        button.setT("WL");
        button.setU1("http://www.popbill.com");
        button.setU2("http://test.popbill.com");
        btns[1] = button;

        KakaoReceiver[] receivers = new KakaoReceiver[2];

        KakaoReceiver message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요1");
        message.setAltMessage("대체문자 내용");
        receivers[0] = message;

        message = new KakaoReceiver();
        message.setReceiverNum("01022223333");
        message.setReceiverName("수신자명");
        message.setMessage("[테스트] 테스트 템플릿입니다요2");
        message.setAltMessage("대체문자 내용");
        receivers[1] = message;

        File file = new File("/Users/John/Desktop/tmp/test03.jpg");
        String imageURL = "http://test.popbill.com";
        String receiptNum = kakaoService.sendFMS(testCorpNum, plusFriendID, senderNum, altSendType,
                receivers, btns, sndDT, adsYN, file, imageURL);

        assertNotNull(receiptNum);
        System.out.println(receiptNum);
    }

    @Test
    public void cancelReserve_TEST() throws PopbillException {

        String receiptNum = "018072410120300001";

        Response response = kakaoService.cancelReserve("1234567890", receiptNum);
        assertNotNull(response);

        System.out.println(response.getMessage());
    }

    @Test
    public void cancelReserveRN_TEST() throws PopbillException {

        String requestNum = "20180724_fms_19";

        Response response = kakaoService.cancelReserveRN("1234567890", requestNum);
        assertNotNull(response);

        System.out.println(response.getMessage());
    }

    @Test
    public void getMessage_TEST() throws PopbillException {

        String receiptNum = "020020314162900001";

        KakaoSentInfo result = kakaoService.getMessages("1234567890", receiptNum);

        assertNotNull(result);

        System.out.println("contentType : " + result.getContentType());
        System.out.println("templateCode : " + result.getTemplateCode());
        System.out.println("plusFriendID : " + result.getPlusFriendID());
        System.out.println("sendNum : " + result.getSendNum());
        System.out.println("altSubject : " + result.getAltSubject());
        System.out.println("altContent : " + result.getAltContent());
        System.out.println("altSendType : " + result.getAltSendType());
        System.out.println("reserveDT : " + result.getReserveDT());
        System.out.println("adsYN : " + result.getAdsYN());
        System.out.println("imageURL : " + result.getImageURL());
        System.out.println("sendCnt : " + result.getSendCnt());
        System.out.println("successCnte : " + result.getSuccessCnt());
        System.out.println("failCnt : " + result.getFailCnt());
        System.out.println("altCnt : " + result.getAltCnt());
        System.out.println("cancelCnt : " + result.getCancelCnt());

        for (int i=0; i<result.getMsgs().size(); i++)
        {

            System.out.println("state : " + result.getMsgs().get(i).getState());
            System.out.println("sendDT : " + result.getMsgs().get(i).getSendDT());
            System.out.println("receiveNum : " + result.getMsgs().get(i).getReceiveNum());
            System.out.println("receiveName : " + result.getMsgs().get(i).getReceiveName());
            System.out.println("content : " + result.getMsgs().get(i).getContent());
            System.out.println("result : " + result.getMsgs().get(i).getResult());
            System.out.println("resultDT : " + result.getMsgs().get(i).getResultDT());
            System.out.println("altSubject : " + result.getMsgs().get(i).getAltSubject());
            System.out.println("altContent : " + result.getMsgs().get(i).getAltContent());
            System.out.println("altContentType : " + result.getMsgs().get(i).getAltContentType());
            System.out.println("altSendDT : " + result.getMsgs().get(i).getAltSendDT());
            System.out.println("altResult : " + result.getMsgs().get(i).getAltResult());
            System.out.println("altResultDT : " + result.getMsgs().get(i).getAltResultDT());
            System.out.println("receiptNum : " + result.getMsgs().get(i).getReceiptNum());
            System.out.println("requestNum : " + result.getMsgs().get(i).getRequestNum());
            System.out.println("interOPRefKey : " + result.getMsgs().get(i).getInterOPRefKey());
        }
    }

    @Test
    public void getMessageRN_TEST() throws PopbillException {

        String requestNum = "20180724_fms_19";

        KakaoSentInfo result = kakaoService.getMessagesRN("1234567890", requestNum);

        assertNotNull(result);

        System.out.println("contentType : " + result.getContentType());
        System.out.println("templateCode : " + result.getTemplateCode());
        System.out.println("plusFriendID : " + result.getPlusFriendID());
        System.out.println("sendNum : " + result.getSendNum());
        System.out.println("altSubject : " + result.getAltSubject());
        System.out.println("altContent : " + result.getAltContent());
        System.out.println("altSendType : " + result.getAltSendType());
        System.out.println("reserveDT : " + result.getReserveDT());
        System.out.println("adsYN : " + result.getAdsYN());
        System.out.println("imageURL : " + result.getImageURL());
        System.out.println("sendCnt : " + result.getSendCnt());
        System.out.println("successCnte : " + result.getSuccessCnt());
        System.out.println("failCnt : " + result.getFailCnt());
        System.out.println("altCnt : " + result.getAltCnt());
        System.out.println("cancelCnt : " + result.getCancelCnt());

        for (int i=0; i<result.getMsgs().size(); i++)
        {
            System.out.println("state : " + result.getMsgs().get(i).getState());
            System.out.println("sendDT : " + result.getMsgs().get(i).getSendDT());
            System.out.println("receiveNum : " + result.getMsgs().get(i).getReceiveNum());
            System.out.println("receiveName : " + result.getMsgs().get(i).getReceiveName());
            System.out.println("content : " + result.getMsgs().get(i).getContent());
            System.out.println("result : " + result.getMsgs().get(i).getResult());
            System.out.println("resultDT : " + result.getMsgs().get(i).getResultDT());
            System.out.println("altSubject : " + result.getMsgs().get(i).getAltSubject());
            System.out.println("altContent : " + result.getMsgs().get(i).getAltContent());
            System.out.println("altContentType : " + result.getMsgs().get(i).getAltContentType());
            System.out.println("altSendDT : " + result.getMsgs().get(i).getAltSendDT());
            System.out.println("altResult : " + result.getMsgs().get(i).getAltResult());
            System.out.println("altResultDT : " + result.getMsgs().get(i).getAltResultDT());
            System.out.println("receiptNum : " + result.getMsgs().get(i).getReceiptNum());
            System.out.println("requestNum : " + result.getMsgs().get(i).getRequestNum());
        }
    }

    @Test
    public void search_TEST() throws PopbillException {

        String SDate = "20220111";
        String EDate = "20220206";
        String[] State = {"0", "1","2","3","4", "5"};
        String[] Item = {"ATS", "FTS", "FMS"};
        String ReserveYN = "";
        Boolean SenderYN = false;
        int Page = 1;
        int PerPage = 3;
        String Order = "D";
        String QString = "지헌 테스트";

        KakaoSearchResult result = kakaoService.search("1234567890", SDate, EDate, State, Item, ReserveYN, SenderYN, Page, PerPage, Order, "testkorea", QString);

        assertNotNull(result);

        System.out.println(result.getTotal());

        System.out.println("code : " + result.getCode());
        System.out.println("message : " + result.getMessage());
        System.out.println("total : " + result.getTotal());
        System.out.println("perPage : " + result.getPerPage());
        System.out.println("pageNum : " + result.getPageNum());
        System.out.println("pageCount : " + result.getPageCount());

        for (int i=0; i<result.getList().size(); i++)
        {
            System.out.println("****************************************************");
            System.out.println("state : " + result.getList().get(i).getState());
            System.out.println("sendDT : " + result.getList().get(i).getSendDT());
            System.out.println("receiveNum : " + result.getList().get(i).getReceiveNum());
            System.out.println("receiveName : " + result.getList().get(i).getReceiveName());
            System.out.println("content : " + result.getList().get(i).getContent());
            System.out.println("result : " + result.getList().get(i).getResult());
            System.out.println("resultDT : " + result.getList().get(i).getResultDT());
            System.out.println("altSubject : " + result.getList().get(i).getAltSubject());
            System.out.println("altContent : " + result.getList().get(i).getAltContent());
            System.out.println("altContentType : " + result.getList().get(i).getAltContentType());
            System.out.println("altSendDT : " + result.getList().get(i).getAltSendDT());
            System.out.println("altResult : " + result.getList().get(i).getAltResult());
            System.out.println("altResultDT : " + result.getList().get(i).getAltResultDT());
            System.out.println("reserveDT : " + result.getList().get(i).getReserveDT());
        }

    }

    @Test
    public void GetSentListURL_TEST() throws PopbillException {

        String url = kakaoService.getSentListURL("1234567890","testkorea");

        System.out.println(url);
    }

    @Test
    public void getURL_TEST() throws PopbillException {

        String url =  kakaoService.getURL("1234567890", "PLUSFRIEND", "testkorea");

        assertNotNull(url);
        System.out.println(url);
    }

    @Test
    public void getUnitCost_TEST() throws PopbillException {
        float UnitCost = kakaoService.getUnitCost("1234567890",KakaoType.FMS);
        System.out.println(UnitCost);
    }

    @Test
    public void getChargeInfo_TEST() throws PopbillException {

        ChargeInfo chrgInfo = kakaoService.getChargeInfo("1234567890", KakaoType.FMS);

        System.out.println(chrgInfo.getChargeMethod());
        System.out.println(chrgInfo.getRateSystem());
        System.out.println(chrgInfo.getUnitCost());
    }
}