14107. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 1/4/2018 4:54:42 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

14107.1 Files compared

# Location File Last Modified
1 CHAMPVA_Benefit_Eligibility_v1.0.0.zip\webservice\vlh\src\test\java\gov\va\med\mbac\vlh\impl VistaLinkHelperTest.java Thu Dec 21 19:52:28 2017 UTC
2 CHAMPVA_Benefit_Eligibility_v1.0.0.zip\webservice\vlh\src\test\java\gov\va\med\mbac\vlh\impl VistaLinkHelperTest.java Thu Jan 4 21:05:48 2018 UTC

14107.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 2 2214
Changed 1 2
Inserted 0 0
Removed 0 0

14107.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

14107.4 Active regular expressions

No regular expressions were active.

14107.5 Comparison detail

  1   /**
  2    * The pac kage gov.v a.med.mbac .vlh.impl  contains t he VistaLi nkHelper C lass,
  3    * which i mplements  the IVista LinkHelper  interface .
  4    * 
  5    * Includi ng the uni t tests in  the same  package as  the class es under t est allows  test case s access t o
  6    * friendl y and prot ected memb ers, witho ut breakin g encapsul ation.
  7    * 
  8    */
  9   package go v.va.med.m bac.vlh.im pl;
  10  
  11   import sta tic org.ju nit.Assert .assertEqu als;
  12   import sta tic org.ju nit.Assert .assertFal se;
  13   import sta tic org.ju nit.Assert .assertNot Null;
  14   import sta tic org.ju nit.Assert .assertTru e;
  15   import sta tic org.ju nit.Assert .fail;
  16   import sta tic org.mo ckito.Matc hers.any;
  17   import sta tic org.mo ckito.Mock ito.mock;
  18   import sta tic org.mo ckito.Mock ito.stub;
  19   import sta tic org.mo ckito.Mock ito.times;
  20   import sta tic org.mo ckito.Mock ito.verify ;
  21   import sta tic org.mo ckito.Mock ito.when;
  22   import sta tic org.po wermock.ap i.mockito. PowerMocki to.mockSta tic;
  23   import sta tic org.po wermock.ap i.mockito. PowerMocki to.verifyN ew;
  24   import sta tic org.po wermock.ap i.mockito. PowerMocki to.verifyS tatic;
  25   import sta tic org.po wermock.ap i.mockito. PowerMocki to.whenNew ;
  26   import gov .va.med.mb ac.vlh.com mon.IVista LinkHelper ;
  27   import gov .va.med.vi stalink.ad apter.cci. VistaLinkA ppProxyCon nectionSpe c;
  28   import gov .va.med.vi stalink.ad apter.cci. VistaLinkC onnection;
  29   import gov .va.med.vi stalink.ad apter.cci. VistaLinkC onnectionF actory;
  30   import gov .va.med.vi stalink.ad apter.cci. VistaLinkC onnectionS pec;
  31   import gov .va.med.vi stalink.ad apter.cci. VistaLinkD uzConnecti onSpec;
  32   import gov .va.med.vi stalink.in stitution. Institutio nMapNotIni tializedEx ception;
  33   import gov .va.med.vi stalink.in stitution. Institutio nMappingDe legate;
  34   import gov .va.med.vi stalink.in stitution. Institutio nMappingNo tFoundExce ption;
  35   import gov .va.med.vi stalink.rp c.RpcReque st;
  36  
  37   import jav ax.naming. InitialCon text;
  38   import jav ax.naming. NamingExce ption;
  39   import jav ax.resourc e.Resource Exception;
  40  
  41   import org .junit.Aft er;
  42   import org .junit.Bef ore;
  43   import org .junit.Tes t;
  44   import org .junit.run ner.RunWit h;
  45   import org .powermock .core.clas sloader.an notations. PrepareFor Test;
  46   import org .powermock .modules.j unit4.Powe rMockRunne r;
  47   import org .springfra mework.bea ns.BeansEx ception;
  48   import org .springfra mework.con text.suppo rt.ClassPa thXmlAppli cationCont ext;
  49  
  50   /**
  51    * This is  the Vista LinkHelper Test class , which im plements t he unit te sts
  52    * for the  VistaLink Helper cla ss.
  53    * 
  54    * @author   PII
  55    * @versio n 1.0.0
  56    */
  57  
  58   @RunWith(P owerMockRu nner.class )
  59   @PrepareFo rTest({ In stitutionM appingDele gate.class , VistaLin kDuzConnec tionSpec.c lass })
  60   public cla ss VistaLi nkHelperTe st {
  61  
  62           pr ivate stat ic final S tring SITE _ID = "500 ";
  63           pr ivate stat ic final S tring RPC_ CONTEXT =  "ORWS WEB  SERVICES";
  64           pr ivate stat ic final S tring APP_ PROXY_NAME  = "CHAMPV APAY,APPLI CATION PRO XY";
  65  
  66           pr ivate Clas sPathXmlAp plicationC ontext con text = nul l;
  67  
  68           @B efore
  69           pu blic void  setUp() {
  70                    this .context =  new Class PathXmlApp licationCo ntext("/vl hTestBeans .xml");
  71           }
  72  
  73           @A fter
  74           pu blic void  tearDown()  {
  75                    this .context.c lose();
  76           }
  77  
  78           
  79           /* *
  80            *  *** Tests  for Sprin g DI ***
  81            * /
  82  
  83           /* *
  84            *  Test DI o f vistaLin kHelper
  85            * /
  86           @T est
  87           pu blic final  void test VistaLinkH elperInjec tion() {
  88                    IVis taLinkHelp er vistaLi nkHelper =  (VistaLin kHelper) c ontext.get Bean("vist aLinkHelpe r");
  89                    asse rtNotNull( "vistaLink Helper fai led to ins tantiate." , vistaLin kHelper);
  90                    asse rtTrue("vi staLinkHel per instan ce of Vist aLinkHelpe r.", (vist aLinkHelpe r instance of VistaLi nkHelper)) ;
  91                    RpcR equest rpc Request =  vistaLinkH elper.getR pcRequest( );
  92                    asse rtNotNull( "rpcReques t failed t o instanti ate.", rpc Request);
  93                    asse rtTrue("rp cRequest i nstance of  RpcReques t.", (rpcR equest ins tanceof Rp cRequest)) ;
  94                    asse rtEquals(R PC_CONTEXT , rpcReque st.getRpcC ontext());
  95                    asse rtFalse(rp cRequest.i sXmlRespon se());
  96           }
  97  
  98           /* *
  99            *  Test DI o f rpcReque st
  100            * /
  101           @T est
  102           pu blic final  void test RpcRequest Injection( ) {
  103                    IVis taLinkHelp er vistaLi nkHelper =  (VistaLin kHelper) c ontext.get Bean("vist aLinkHelpe r");
  104                    RpcR equest rpc Request =  vistaLinkH elper.getR pcRequest( );
  105                    asse rtNotNull( "rpcReques t failed t o instanti ate.", rpc Request);
  106                    asse rtTrue("rp cRequest i nstance of  RpcReques t.", (rpcR equest ins tanceof Rp cRequest)) ;
  107                    asse rtEquals(R PC_CONTEXT , rpcReque st.getRpcC ontext());
  108                    asse rtFalse(rp cRequest.i sXmlRespon se());
  109           }
  110           
  111           /* *
  112            *  Test that  the appCo ntext is r eturning a  new RpcRe quest bean  with each  call
  113            *  i.e., NOT  a Spring  singleton.
  114            * /
  115           @T est
  116           pu blic final  void test ThatGetRpc RequestRet urnsNewIns tanceEachC all() {
  117                    IVis taLinkHelp er vistaLi nkHelper =  (VistaLin kHelper) c ontext.get Bean("vist aLinkHelpe r");
  118                    RpcR equest rpc Request0 =  vistaLink Helper.get RpcRequest ();
  119                    asse rtNotNull( "rpcReques t failed t o instanti ate.", rpc Request0);
  120                    RpcR equest rpc Request1 =  vistaLink Helper.get RpcRequest ();
  121                    asse rtNotNull( "rpcReques t failed t o instanti ate.", rpc Request1);
  122  
  123                    asse rtFalse(rp cRequest0  == rpcRequ est1);
  124           }
  125  
  126           /* *
  127            *  Test that  getRpcReq uest rethr ows BeansE xception w hen contex t.getBean  fails
  128            * /
  129           @T est
  130           pu blic final  void test GetRpcRequ estThrowsB eansExcept ion() {
  131                    Clas sPathXmlAp plicationC ontext loc alContext  = new Clas sPathXmlAp plicationC ontext("/v lhTestBean sNoReq.xml ");
  132                    try  {
  133                             IVista LinkHelper  vistaLink Helper = ( VistaLinkH elper) loc alContext. getBean("v istaLinkHe lper");
  134                             RpcReq uest rpcRe quest = vi staLinkHel per.getRpc Request();
  135                             assert NotNull("r pcRequest  failed to  instantiat e.", rpcRe quest);
  136                    } ca tch (Beans Exception  be) {
  137                             assert Equals("No  bean name d 'rpcRequ est' is de fined", be .getMessag e());
  138                    } fi nally {
  139                             localC ontext.clo se();
  140                    }
  141           }
  142  
  143           /* *
  144            *  Verify th at getConn ection ret urns a val id VistaLi nk Connect ion (happy  path)
  145            *  
  146            * /
  147           @T est
  148           pu blic void  verifyThat GetConnect ionReturns VistaLinkC onnection( ) {
  149                    IVis taLinkHelp er vlh;
  150                    Stri ng siteId  = SITE_ID;
  151                    Stri ng duz = " 983";
  152                    try  {
  153                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  154                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  155                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  156                                               .thenRetur n(mockedCo nnection);
  157                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  158                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  159                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  160                             assert NotNull("v lh failed  to instant iate.", vl h);
  161  
  162                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  163                             when(
  164                                               Institutio nMappingDe legate
  165                                                                .get JndiConnec torNameFor Institutio n(siteId))
  166                                               .thenRetur n("vlj/myd ev500");
  167  
  168                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  169  
  170                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  171                             assert Equals(moc kedConnect ion, vlc);
  172                    } ca tch (Namin gException  e) {
  173                             fail(e .getMessag e());
  174                    } ca tch (Resou rceExcepti on e) {
  175                             fail(e .getMessag e());
  176                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  177                             fail(e .getMessag e());
  178                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  179                             fail(e .getMessag e());
  180                    }
  181           }
  182  
  183           /* *
  184            *  Test that  getConnec tion throw s Resource Exception  when siteI d == null
  185            * /
  186           @T est
  187           pu blic void  testThatGe tConnectio nThrowsRes ourceExcep tionWhenSi teIdEquals Null() {
  188                    IVis taLinkHelp er vlh;
  189                    try  {
  190                             vlh =  (VistaLink Helper) co ntext.getB ean("vista LinkHelper ");
  191                             assert NotNull("v lh failed  to instant iate.", vl h);
  192                             vlh.ge tConnectio n(null, "7 77");
  193                    } ca tch (Namin gException  e) {
  194                             fail(e .getMessag e());
  195                    } ca tch (Resou rceExcepti on e) {
  196                             assert Equals("Vi stA Site n ot identif ied", e.ge tMessage() );
  197                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  198                             fail(e .getMessag e());
  199                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  200                             fail(e .getMessag e());
  201                    }
  202           }
  203  
  204           /* *
  205            *  Test that  getConnec tion throw s Resource Exception  when siteI d == ""
  206            * /
  207           @T est
  208           pu blic void  testThatGe tConnectio nThrowsRes ourceExcep tionWhenSi teIdEquals EmptyStrin g() {
  209                    IVis taLinkHelp er vlh;
  210                    try  {
  211                             vlh =  (VistaLink Helper) co ntext.getB ean("vista LinkHelper ");
  212                             assert NotNull("v lh failed  to instant iate.", vl h);
  213                             vlh.ge tConnectio n("", "777 ");
  214                    } ca tch (Namin gException  e) {
  215                             fail(e .getMessag e());
  216                    } ca tch (Resou rceExcepti on e) {
  217                             assert Equals("Vi stA Site n ot identif ied", e.ge tMessage() );
  218                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  219                             fail(e .getMessag e());
  220                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  221                             fail(e .getMessag e());
  222                    }
  223           }
  224  
  225           /* *
  226            *  Test that  getConnec tion throw s Resource Exception  when duz = = null
  227            * /
  228           @T est
  229           pu blic void  testThatGe tConnectio nThrowsRes ourceExcep tionWhenDu zEqualsNul l() {
  230                    IVis taLinkHelp er vlh;
  231                    try  {
  232                             vlh =  (VistaLink Helper) co ntext.getB ean("vista LinkHelper ");
  233                             assert NotNull("v lh failed  to instant iate.", vl h);
  234                             vlh.ge tConnectio n(SITE_ID,  null);
  235                    } ca tch (Namin gException  e) {
  236                             fail(e .getMessag e());
  237                    } ca tch (Resou rceExcepti on e) {
  238                             assert Equals("Us er not ide ntified",  e.getMessa ge());
  239                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  240                             fail(e .getMessag e());
  241                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  242                             fail(e .getMessag e());
  243                    }
  244           }
  245  
  246           /* *
  247            *  Test that  getConnec tion throw s Resource Exception  when duz = = ""
  248            * /
  249           @T est
  250           pu blic void  testThatGe tConnectio nThrowsRes ourceExcep tionWhenDu zEqualsEmp tyString()  {
  251                    IVis taLinkHelp er vlh;
  252                    try  {
  253                             vlh =  (VistaLink Helper) co ntext.getB ean("vista LinkHelper ");
  254                             assert NotNull("v lh failed  to instant iate.", vl h);
  255                             vlh.ge tConnectio n(SITE_ID,  "");
  256                    } ca tch (Namin gException  e) {
  257                             fail(e .getMessag e());
  258                    } ca tch (Resou rceExcepti on e) {
  259                             assert Equals("Us er not ide ntified",  e.getMessa ge());
  260                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  261                             fail(e .getMessag e());
  262                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  263                             fail(e .getMessag e());
  264                    }
  265           }
  266  
  267           /* *
  268            *  Verify th at new Vis taLinkConn ectionSpec (siteId, d uz) is cal led from
  269            *  getConnec tion(siteI d, duz)
  270            * /
  271           @T est
  272           pu blic void  verifyThat NewVistaLi nkConnecti onSpecIsCa lledFromGe tConnectio n() {
  273                    IVis taLinkHelp er vlh;
  274                    Stri ng siteId  = SITE_ID;
  275                    Stri ng duz = " 983";
  276                    try  {
  277                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  278                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  279                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  280                                               .thenRetur n(mockedCo nnection);
  281                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  282                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  283                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  284                                               .thenRetur n(mockedIc );
  285                             
  286                             VistaL inkDuzConn ectionSpec  mockedCon nSpec = mo ck(VistaLi nkDuzConne ctionSpec. class);
  287  
  288                             whenNe w(VistaLin kDuzConnec tionSpec.c lass)
  289                                               .withArgum ents(siteI d, duz)
  290                                               .thenRetur n(mockedCo nnSpec);
  291  
  292                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  293                             when(
  294                                               Institutio nMappingDe legate
  295                                                                .get JndiConnec torNameFor Institutio n(siteId))
  296                                               .thenRetur n("vlj/myd ev500");
  297  
  298                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  299                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  300                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  301                             
  302                             verify New(VistaL inkDuzConn ectionSpec .class, ti mes(1));
  303                             
  304                    } ca tch (Namin gException  e) {
  305                             fail(e .getMessag e());
  306                    } ca tch (Resou rceExcepti on e) {
  307                             fail(e .getMessag e());
  308                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  309                             fail(e .getMessag e());
  310                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  311                             fail(e .getMessag e());
  312                    } ca tch (Excep tion e) {
  313                             fail(e .getMessag e());
  314                    }
  315           }
  316  
  317           /* *
  318            *  Verify th at
  319            *  Instituti onMappingD elegate.ge tJndiConne ctorNameFo rInstituti on(siteId)  is
  320            *  called fr om getConn ection(sit eId, duz)
  321            * /
  322           @T est
  323           pu blic void  verifyThat Institutio nMappingDe legateGetJ ndiConnect orNameForI nstitution IsCalledFr omGetConne ction() {
  324                    IVis taLinkHelp er vlh;
  325                    Stri ng siteId  = SITE_ID;
  326                    Stri ng duz = " 983";
  327                    try  {
  328                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  329                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  330                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  331                                               .thenRetur n(mockedCo nnection);
  332                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  333                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  334                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  335                                               .thenRetur n(mockedIc );
  336                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  337                             assert NotNull("v lh failed  to instant iate.", vl h);
  338  
  339                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  340                             when(
  341                                               Institutio nMappingDe legate
  342                                                                .get JndiConnec torNameFor Institutio n(siteId))
  343                                               .thenRetur n("vlj/myd ev500");
  344  
  345                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  346  
  347                             verify Static(tim es(1));
  348                             Instit utionMappi ngDelegate
  349                                               .getJndiCo nnectorNam eForInstit ution(site Id);
  350                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  351                             assert Equals(moc kedConnect ion, vlc);
  352                    } ca tch (Namin gException  e) {
  353                             fail(e .getMessag e());
  354                    } ca tch (Resou rceExcepti on e) {
  355                             fail(e .getMessag e());
  356                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  357                             fail(e .getMessag e());
  358                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  359                             fail(e .getMessag e());
  360                    } ca tch (Excep tion e) {
  361                             fail(e .getMessag e());
  362                    }
  363           }
  364  
  365           /* *
  366            *  Verify th at Initial Context.lo okup(jndiN ame) is ca lled from
  367            *  getConnec tion(siteI d, duz) on ce
  368            * /
  369           @T est
  370           pu blic void  verifyThat InitialCon textLookup IsCalledFr omGetConne ction() {
  371                    IVis taLinkHelp er vlh;
  372                    Stri ng siteId  = SITE_ID;
  373                    Stri ng duz = " 983";
  374                    try  {
  375                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  376                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  377                             stub(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  378                                               .toReturn( mockedConn ection);
  379                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  380                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  381                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  382                                               .thenRetur n(mockedIc );
  383                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  384                             assert NotNull("v lh failed  to instant iate.", vl h);
  385  
  386                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  387                             when(
  388                                               Institutio nMappingDe legate
  389                                                                .get JndiConnec torNameFor Institutio n(siteId))
  390                                               .thenRetur n("vlj/myd ev500");
  391  
  392                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  393  
  394                             verify (mockedIc,  times(1)) .lookup("v lj/mydev50 0");
  395                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  396                             assert Equals(moc kedConnect ion, vlc);
  397                    } ca tch (Namin gException  e) {
  398                             fail(e .getMessag e());
  399                    } ca tch (Resou rceExcepti on e) {
  400                             fail(e .getMessag e());
  401                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  402                             fail(e .getMessag e());
  403                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  404                             fail(e .getMessag e());
  405                    } ca tch (Excep tion e) {
  406                             fail(e .getMessag e());
  407                    }
  408           }
  409  
  410           /* *
  411            *  Verify th at VistaLi nkConnecti onFactory. getConnect ion(connSp ec) is cal led
  412            *  from getC onnection( siteId, du z) once
  413            * /
  414           @T est
  415           pu blic void  verifyThat VistaLinkC onnectionF actoryGetC onnectionI sCalledFro mGetConnec tion() {
  416                    IVis taLinkHelp er vlh;
  417                    Stri ng siteId  = SITE_ID;
  418                    Stri ng duz = " 983";
  419                    try  {
  420                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  421                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  422                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  423                                               .thenRetur n(mockedCo nnection);
  424                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  425                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  426                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  427                                               .thenRetur n(mockedIc );
  428                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  429                             assert NotNull("v lh failed  to instant iate.", vl h);
  430  
  431                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  432                             when(
  433                                               Institutio nMappingDe legate
  434                                                                .get JndiConnec torNameFor Institutio n(siteId))
  435                                               .thenRetur n("vlj/myd ev500");
  436  
  437                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  438  
  439                             verify (mockedVLc f, times(1 )).getConn ection(
  440                                               any(VistaL inkConnect ionSpec.cl ass));
  441                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  442                             assert Equals(moc kedConnect ion, vlc);
  443                    } ca tch (Namin gException  e) {
  444                             fail(e .getMessag e());
  445                    } ca tch (Resou rceExcepti on e) {
  446                             fail(e .getMessag e());
  447                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  448                             fail(e .getMessag e());
  449                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  450                             fail(e .getMessag e());
  451                    } ca tch (Excep tion e) {
  452                             fail(e .getMessag e());
  453                    }
  454           }
  455  
  456           /* *
  457            *  Verify th at getConn ection(sit eId, duz)  rethrows I nstitution MapNotInit ialized
  458            *  when Inst itutionMap pingDelega te.getJndi ConnectorN ameForInst itution(si teId)
  459            *  throws In stitutionM apNotIniti alized
  460            * /
  461           @T est
  462           pu blic void  verifyThat GetConnect ionRethrow sInstituti onMapNotIn itialized( ) {
  463                    IVis taLinkHelp er vlh;
  464                    Stri ng siteId  = SITE_ID;
  465                    Stri ng duz = " 983";
  466                    try  {
  467                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  468                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  469                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  470                                               .thenRetur n(mockedCo nnection);
  471                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  472                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  473                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  474                                               .thenRetur n(mockedIc );
  475                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  476                             assert NotNull("v lh failed  to instant iate.", vl h);
  477  
  478                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  479                             when(
  480                                               Institutio nMappingDe legate
  481                                                                .get JndiConnec torNameFor Institutio n(siteId))
  482                                               .thenThrow (new Insti tutionMapN otInitiali zedExcepti on("NO MAP , GOOGLE!" ));
  483  
  484                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  485  
  486                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  487                    } ca tch (Namin gException  e) {
  488                             fail(e .getMessag e());
  489                    } ca tch (Resou rceExcepti on e) {
  490                             fail(e .getMessag e());
  491                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  492                             assert Equals("NO  MAP, GOOG LE!", e.ge tMessage() );
  493                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  494                             fail(e .getMessag e());
  495                    } ca tch (Excep tion e) {
  496                             fail(e .getMessag e());
  497                    }
  498           }
  499  
  500           /* *
  501            *  Verify th at getConn ection(sit eId, duz)  rethrows I nstitution MappingNot FoundExcep tion
  502            *  when Inst itutionMap pingDelega te.getJndi ConnectorN ameForInst itution(si teId)
  503            *  throws In stitutionM appingNotF oundExcept ion
  504            * /
  505           @T est
  506           pu blic void  verifyThat GetConnect ionRethrow sInstituti onMappingN otFound()  {
  507                    IVis taLinkHelp er vlh;
  508                    Stri ng siteId  = SITE_ID;
  509                    Stri ng duz = " 983";
  510                    try  {
  511                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  512                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  513                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  514                                               .thenRetur n(mockedCo nnection);
  515                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  516                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  517                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  518                                               .thenRetur n(mockedIc );
  519                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  520                             assert NotNull("v lh failed  to instant iate.", vl h);
  521  
  522                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  523                             when(
  524                                               Institutio nMappingDe legate
  525                                                                .get JndiConnec torNameFor Institutio n(siteId))
  526                                               .thenThrow (new Insti tutionMapp ingNotFoun dException ("WHERE'S  THE MAP, G OOGLE!"));
  527  
  528                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  529  
  530                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  531                    } ca tch (Namin gException  e) {
  532                             fail(e .getMessag e());
  533                    } ca tch (Resou rceExcepti on e) {
  534                             fail(e .getMessag e());
  535                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  536                             fail(e .getMessag e());
  537                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  538                             assert Equals("WH ERE'S THE  MAP, GOOGL E!", e.get Message()) ;
  539                    } ca tch (Excep tion e) {
  540                             fail(e .getMessag e());
  541                    }
  542           }
  543  
  544           /* *
  545            *  Verify th at getConn ection(sit eId, duz)  rethrows N amingExcep tion
  546            *  when Init ialContext .lookup(jn diName) th rows Namin gException .
  547            *
  548            * /
  549           @T est
  550           pu blic void  verifyThat GetConnect ionRethrow sNamingExc eption() {
  551                    IVis taLinkHelp er vlh;
  552                    Stri ng siteId  = SITE_ID;
  553                    Stri ng duz = " 983";
  554                    try  {
  555                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  556                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  557                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  558                                               .thenRetur n(mockedCo nnection);
  559                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  560                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenThro w(new Nami ngExceptio n("Rationa l Jazz is  NOT!"));
  561                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  562                                               .thenRetur n(mockedIc );
  563                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  564                             assert NotNull("v lh failed  to instant iate.", vl h);
  565  
  566                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  567                             when(
  568                                               Institutio nMappingDe legate
  569                                                                .get JndiConnec torNameFor Institutio n(siteId))
  570                                               .thenRetur n("vlj/myd ev500");
  571  
  572                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  573  
  574                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  575                    } ca tch (Namin gException  e) {
  576                             assert Equals("Ra tional Jaz z is NOT!" , e.getMes sage());
  577                    } ca tch (Resou rceExcepti on e) {
  578                             fail(e .getMessag e());
  579                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  580                             fail(e .getMessag e());
  581                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  582                             fail(e .getMessag e());
  583                    } ca tch (Excep tion e) {
  584                             fail(e .getMessag e());
  585                    }
  586           }
  587  
  588           /* *
  589            *  Verify th at getConn ection(sit eId, duz)  rethrows R esourceExc eption
  590            *  when conn ectionFact ory.getCon nection(co nnSpec) th rows Resou rceExcepti on.
  591            *
  592            * /
  593           @T est
  594           pu blic void  verifyThat GetConnect ionRethrow sResourceE xception()  {
  595                    IVis taLinkHelp er vlh;
  596                    Stri ng siteId  = SITE_ID;
  597                    Stri ng duz = " 983";
  598                    try  {
  599                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  600                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  601                                               .thenThrow (new Resou rceExcepti on("Team C oncert !=  Agile"));
  602                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  603                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  604                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  605                                               .thenRetur n(mockedIc );
  606                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  607                             assert NotNull("v lh failed  to instant iate.", vl h);
  608  
  609                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  610                             when(
  611                                               Institutio nMappingDe legate
  612                                                                .get JndiConnec torNameFor Institutio n(siteId))
  613                                               .thenRetur n("vlj/myd ev500");
  614  
  615                             VistaL inkConnect ion vlc =  vlh.getCon nection(si teId, duz) ;
  616  
  617                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  618                    } ca tch (Namin gException  e) {
  619                             fail(e .getMessag e());
  620                    } ca tch (Resou rceExcepti on e) {
  621                             assert Equals("Te am Concert  != Agile" , e.getMes sage());
  622                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  623                             fail(e .getMessag e());
  624                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  625                             fail(e .getMessag e());
  626                    } ca tch (Excep tion e) {
  627                             fail(e .getMessag e());
  628                    }
  629           }
  630  
  631           
  632           /* *
  633            *  --- Tests  for getAp pProxyConn ection(sit eId, appPr oxyName) - --
  634            * /
  635           
  636           
  637           /* *
  638            *  Verify th at getAppP roxyConnec tion retur ns a valid  VistaLink  Connectio n (happy p ath)
  639            *  
  640            * /
  641           @T est
  642           pu blic void  verifyThat GetAppProx yConnectio nReturnsVi staLinkCon nection()  {
  643                    IVis taLinkHelp er vlh;
  644                    Stri ng siteId  = SITE_ID;
  645                    try  {
  646                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  647                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  648                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  649                                               .thenRetur n(mockedCo nnection);
  650                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  651                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  652                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  653                             assert NotNull("v lh failed  to instant iate.", vl h);
  654  
  655                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  656                             when(
  657                                               Institutio nMappingDe legate
  658                                                                .get JndiConnec torNameFor Institutio n(siteId))
  659                                               .thenRetur n("vlj/myd ev500");
  660  
  661                             VistaL inkConnect ion vlc =  vlh.getApp ProxyConne ction(site Id, APP_PR OXY_NAME);
  662  
  663                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  664                             assert Equals(moc kedConnect ion, vlc);
  665                    } ca tch (Namin gException  e) {
  666                             fail(e .getMessag e());
  667                    } ca tch (Resou rceExcepti on e) {
  668                             fail(e .getMessag e());
  669                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  670                             fail(e .getMessag e());
  671                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  672                             fail(e .getMessag e());
  673                    }
  674           }
  675  
  676           /* *
  677            *  Test that  getAppPro xyConnecti on throws  ResourceEx ception wh en siteId  == null
  678            * /
  679           @T est
  680           pu blic void  testThatGe tAppProxyC onnectionT hrowsResou rceExcepti onWhenSite IdEqualsNu ll() {
  681                    IVis taLinkHelp er vlh;
  682                    try  {
  683                             vlh =  (VistaLink Helper) co ntext.getB ean("vista LinkHelper ");
  684                             assert NotNull("v lh failed  to instant iate.", vl h);
  685                             vlh.ge tAppProxyC onnection( null, APP_ PROXY_NAME );
  686                    } ca tch (Namin gException  e) {
  687                             fail(e .getMessag e());
  688                    } ca tch (Resou rceExcepti on e) {
  689                             assert Equals("Vi stA Site n ot identif ied", e.ge tMessage() );
  690                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  691                             fail(e .getMessag e());
  692                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  693                             fail(e .getMessag e());
  694                    }
  695           }
  696  
  697           /* *
  698            *  Test that  getAppPro xyConnecti on throws  ResourceEx ception wh en siteId  == ""
  699            * /
  700           @T est
  701           pu blic void  testThatGe tAppProxyC onnectionT hrowsResou rceExcepti onWhenSite IdEqualsEm ptyString( ) {
  702                    IVis taLinkHelp er vlh;
  703                    try  {
  704                             vlh =  (VistaLink Helper) co ntext.getB ean("vista LinkHelper ");
  705                             assert NotNull("v lh failed  to instant iate.", vl h);
  706                             vlh.ge tAppProxyC onnection( "", APP_PR OXY_NAME);
  707                    } ca tch (Namin gException  e) {
  708                             fail(e .getMessag e());
  709                    } ca tch (Resou rceExcepti on e) {
  710                             assert Equals("Vi stA Site n ot identif ied", e.ge tMessage() );
  711                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  712                             fail(e .getMessag e());
  713                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  714                             fail(e .getMessag e());
  715                    }
  716           }
  717  
  718           /* *
  719            *  Test that  getAppPro xyConnecti on throws  ResourceEx ception wh en appProx yName == n ull
  720            * /
  721           @T est
  722           pu blic void  testThatGe tAppProxyC onnectionT hrowsResou rceExcepti onWhenAppP roxyNameEq ualsNull()  {
  723                    IVis taLinkHelp er vlh;
  724                    try  {
  725                             vlh =  (VistaLink Helper) co ntext.getB ean("vista LinkHelper ");
  726                             assert NotNull("v lh failed  to instant iate.", vl h);
  727                             vlh.ge tAppProxyC onnection( SITE_ID, n ull);
  728                    } ca tch (Namin gException  e) {
  729                             fail(e .getMessag e());
  730                    } ca tch (Resou rceExcepti on e) {
  731                             assert Equals("Ap plication  Proxy not  identified ", e.getMe ssage());
  732                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  733                             fail(e .getMessag e());
  734                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  735                             fail(e .getMessag e());
  736                    }
  737           }
  738  
  739           /* *
  740            *  Test that  getAppPro xyConnecti on throws  ResourceEx ception wh en appProx yName == " "
  741            * /
  742           @T est
  743           pu blic void  testThatGe tAppProxyC onnectionT hrowsResou rceExcepti onWhenAppP roxyNameEq ualsEmptyS tring() {
  744                    IVis taLinkHelp er vlh;
  745                    try  {
  746                             vlh =  (VistaLink Helper) co ntext.getB ean("vista LinkHelper ");
  747                             assert NotNull("v lh failed  to instant iate.", vl h);
  748                             vlh.ge tAppProxyC onnection( SITE_ID, " ");
  749                    } ca tch (Namin gException  e) {
  750                             fail(e .getMessag e());
  751                    } ca tch (Resou rceExcepti on e) {
  752                             assert Equals("Ap plication  Proxy not  identified ", e.getMe ssage());
  753                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  754                             fail(e .getMessag e());
  755                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  756                             fail(e .getMessag e());
  757                    }
  758           }
  759  
  760           /* *
  761            *  Verify th at new Vis taLinkAppP roxyConnec tionSpec(s iteId, app ProxyName)  is called  from
  762            *  getAppPro xyConnecti on(siteId,  appProxyN ame)
  763            * /
  764           @T est
  765           pu blic void  verifyThat NewVistaLi nkConnecti onSpecIsCa lledFromGe tAppProxyC onnection( ) {
  766                    IVis taLinkHelp er vlh;
  767                    try  {
  768                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  769                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  770                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  771                                               .thenRetur n(mockedCo nnection);
  772                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  773                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  774                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  775                                               .thenRetur n(mockedIc );
  776                             
  777                             VistaL inkAppProx yConnectio nSpec mock edConnSpec  = mock(Vi staLinkApp ProxyConne ctionSpec. class);
  778  
  779                             whenNe w(VistaLin kAppProxyC onnectionS pec.class)
  780                                               .withArgum ents(SITE_ ID, APP_PR OXY_NAME)
  781                                               .thenRetur n(mockedCo nnSpec);
  782  
  783                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  784                             when(
  785                                               Institutio nMappingDe legate
  786                                                                .get JndiConnec torNameFor Institutio n(SITE_ID) )
  787                                               .thenRetur n("vlj/myd ev500");
  788  
  789                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  790                             VistaL inkConnect ion vlc =  vlh.getApp ProxyConne ction(SITE _ID, APP_P ROXY_NAME) ;
  791                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  792                             
  793                             verify New(VistaL inkAppProx yConnectio nSpec.clas s, times(1 ));
  794                             
  795                    } ca tch (Namin gException  e) {
  796                             fail(e .getMessag e());
  797                    } ca tch (Resou rceExcepti on e) {
  798                             fail(e .getMessag e());
  799                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  800                             fail(e .getMessag e());
  801                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  802                             fail(e .getMessag e());
  803                    } ca tch (Excep tion e) {
  804                             fail(e .getMessag e());
  805                    }
  806           }
  807  
  808           /* *
  809            *  Verify th at
  810            *  Instituti onMappingD elegate.ge tJndiConne ctorNameFo rInstituti on(siteId)  is
  811            *  called fr om getAppP roxyConnec tion(siteI d, appProx yName)
  812            * /
  813           @T est
  814           pu blic void  verifyThat Institutio nMappingDe legateGetJ ndiConnect orNameForI nstitution IsCalledFr omGetAppPr oxyConnect ion() {
  815                    IVis taLinkHelp er vlh;
  816                    try  {
  817                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  818                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  819                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  820                                               .thenRetur n(mockedCo nnection);
  821                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  822                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  823                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  824                                               .thenRetur n(mockedIc );
  825                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  826                             assert NotNull("v lh failed  to instant iate.", vl h);
  827  
  828                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  829                             when(
  830                                               Institutio nMappingDe legate
  831                                                                .get JndiConnec torNameFor Institutio n(SITE_ID) )
  832                                               .thenRetur n("vlj/myd ev500");
  833  
  834                             VistaL inkConnect ion vlc =  vlh.getApp ProxyConne ction(SITE _ID, APP_P ROXY_NAME) ;
  835  
  836                             verify Static(tim es(1));
  837                             Instit utionMappi ngDelegate
  838                                               .getJndiCo nnectorNam eForInstit ution(SITE _ID);
  839                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  840                             assert Equals(moc kedConnect ion, vlc);
  841                    } ca tch (Namin gException  e) {
  842                             fail(e .getMessag e());
  843                    } ca tch (Resou rceExcepti on e) {
  844                             fail(e .getMessag e());
  845                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  846                             fail(e .getMessag e());
  847                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  848                             fail(e .getMessag e());
  849                    } ca tch (Excep tion e) {
  850                             fail(e .getMessag e());
  851                    }
  852           }
  853  
  854           /* *
  855            *  Verify th at Initial Context.lo okup(jndiN ame) is ca lled from
  856            *  getAppPro xyConnecti on(siteId,  appProxyN ame) once
  857            * /
  858           @T est
  859           pu blic void  verifyThat InitialCon textLookup IsCalledFr omGetAppPr oxyConnect ion() {
  860                    IVis taLinkHelp er vlh;
  861                    try  {
  862                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  863                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  864                             stub(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  865                                               .toReturn( mockedConn ection);
  866                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  867                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  868                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  869                                               .thenRetur n(mockedIc );
  870                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  871                             assert NotNull("v lh failed  to instant iate.", vl h);
  872  
  873                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  874                             when(
  875                                               Institutio nMappingDe legate
  876                                                                .get JndiConnec torNameFor Institutio n(SITE_ID) )
  877                                               .thenRetur n("vlj/myd ev500");
  878  
  879                             VistaL inkConnect ion vlc =  vlh.getApp ProxyConne ction(SITE _ID, APP_P ROXY_NAME) ;
  880  
  881                             verify (mockedIc,  times(1)) .lookup("v lj/mydev50 0");
  882                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  883                             assert Equals(moc kedConnect ion, vlc);
  884                    } ca tch (Namin gException  e) {
  885                             fail(e .getMessag e());
  886                    } ca tch (Resou rceExcepti on e) {
  887                             fail(e .getMessag e());
  888                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  889                             fail(e .getMessag e());
  890                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  891                             fail(e .getMessag e());
  892                    } ca tch (Excep tion e) {
  893                             fail(e .getMessag e());
  894                    }
  895           }
  896  
  897           /* *
  898            *  Verify th at VistaLi nkConnecti onFactory. getAppProx yConnectio n(connSpec ) is calle d
  899            *  from getA ppProxyCon nection(si teId, appP roxyName)  once
  900            * /
  901           @T est
  902           pu blic void  verifyThat VistaLinkC onnectionF actoryGetC onnectionI sCalledFro mGetAppPro xyConnecti on() {
  903                    IVis taLinkHelp er vlh;
  904                    try  {
  905                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  906                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  907                             when(m ockedVLcf. getConnect ion(any(Vi staLinkApp ProxyConne ctionSpec. class)))
  908                                               .thenRetur n(mockedCo nnection);
  909                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  910                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  911                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  912                                               .thenRetur n(mockedIc );
  913                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  914                             assert NotNull("v lh failed  to instant iate.", vl h);
  915  
  916                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  917                             when(
  918                                               Institutio nMappingDe legate
  919                                                                .get JndiConnec torNameFor Institutio n(SITE_ID) )
  920                                               .thenRetur n("vlj/myd ev500");
  921  
  922                             VistaL inkConnect ion vlc =  vlh.getCon nection(SI TE_ID, APP _PROXY_NAM E);
  923  
  924                             verify (mockedVLc f, times(1 )).getConn ection(
  925                                               any(VistaL inkConnect ionSpec.cl ass));
  926                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  927                             assert Equals(moc kedConnect ion, vlc);
  928                    } ca tch (Namin gException  e) {
  929                             fail(e .getMessag e());
  930                    } ca tch (Resou rceExcepti on e) {
  931                             fail(e .getMessag e());
  932                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  933                             fail(e .getMessag e());
  934                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  935                             fail(e .getMessag e());
  936                    } ca tch (Excep tion e) {
  937                             fail(e .getMessag e());
  938                    }
  939           }
  940  
  941           /* *
  942            *  Verify th at getAppP roxyConnec tion(siteI d, appProx yName) ret hrows Inst itutionMap NotInitial ized
  943            *  when Inst itutionMap pingDelega te.getJndi ConnectorN ameForInst itution(si teId)
  944            *  throws In stitutionM apNotIniti alized
  945            * /
  946           @T est
  947           pu blic void  verifyThat GetAppProx yConnectio nRethrowsI nstitution MapNotInit ialized()  {
  948                    IVis taLinkHelp er vlh;
  949                    try  {
  950                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  951                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  952                             when(m ockedVLcf. getConnect ion(any(Vi staLinkCon nectionSpe c.class)))
  953                                               .thenRetur n(mockedCo nnection);
  954                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  955                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  956                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  957                                               .thenRetur n(mockedIc );
  958                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  959                             assert NotNull("v lh failed  to instant iate.", vl h);
  960  
  961                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  962                             when(
  963                                               Institutio nMappingDe legate
  964                                                                .get JndiConnec torNameFor Institutio n(SITE_ID) )
  965                                               .thenThrow (new Insti tutionMapN otInitiali zedExcepti on("NO MAP , GOOGLE!" ));
  966  
  967                             VistaL inkConnect ion vlc =  vlh.getApp ProxyConne ction(SITE _ID, APP_P ROXY_NAME) ;
  968  
  969                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  970                    } ca tch (Namin gException  e) {
  971                             fail(e .getMessag e());
  972                    } ca tch (Resou rceExcepti on e) {
  973                             fail(e .getMessag e());
  974                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  975                             assert Equals("NO  MAP, GOOG LE!", e.ge tMessage() );
  976                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  977                             fail(e .getMessag e());
  978                    } ca tch (Excep tion e) {
  979                             fail(e .getMessag e());
  980                    }
  981           }
  982  
  983           /* *
  984            *  Verify th at getAppP roxyConnec tion(siteI d, appProx yName) ret hrows Inst itutionMap pingNotFou ndExceptio n
  985            *  when Inst itutionMap pingDelega te.getJndi ConnectorN ameForInst itution(si teId)
  986            *  throws In stitutionM appingNotF oundExcept ion
  987            * /
  988           @T est
  989           pu blic void  verifyThat GetAppProx yConnectio nRethrowsI nstitution MappingNot Found() {
  990                    IVis taLinkHelp er vlh;
  991                    try  {
  992                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  993                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  994                             when(m ockedVLcf. getConnect ion(any(Vi staLinkApp ProxyConne ctionSpec. class)))
  995                                               .thenRetur n(mockedCo nnection);
  996                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  997                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  998                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  999                                               .thenRetur n(mockedIc );
  1000                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  1001                             assert NotNull("v lh failed  to instant iate.", vl h);
  1002  
  1003                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  1004                             when(
  1005                                               Institutio nMappingDe legate
  1006                                                                .get JndiConnec torNameFor Institutio n(SITE_ID) )
  1007                                               .thenThrow (new Insti tutionMapp ingNotFoun dException ("WHERE'S  THE MAP, G OOGLE!"));
  1008  
  1009                             VistaL inkConnect ion vlc =  vlh.getApp ProxyConne ction(SITE _ID, APP_P ROXY_NAME) ;
  1010  
  1011                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  1012                    } ca tch (Namin gException  e) {
  1013                             fail(e .getMessag e());
  1014                    } ca tch (Resou rceExcepti on e) {
  1015                             fail(e .getMessag e());
  1016                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  1017                             fail(e .getMessag e());
  1018                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  1019                             assert Equals("WH ERE'S THE  MAP, GOOGL E!", e.get Message()) ;
  1020                    } ca tch (Excep tion e) {
  1021                             fail(e .getMessag e());
  1022                    }
  1023           }
  1024  
  1025           /* *
  1026            *  Verify th at getAppP roxyConnec tion(siteI d, appProx yName) ret hrows Nami ngExceptio n
  1027            *  when Init ialContext .lookup(jn diName) th rows Namin gException .
  1028            *
  1029            * /
  1030           @T est
  1031           pu blic void  verifyThat GetAppProx yConnectio nRethrowsN amingExcep tion() {
  1032                    IVis taLinkHelp er vlh;
  1033                    try  {
  1034                             VistaL inkConnect ion mocked Connection  = mock(Vi staLinkCon nection.cl ass);
  1035                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  1036                             when(m ockedVLcf. getConnect ion(any(Vi staLinkApp ProxyConne ctionSpec. class)))
  1037                                               .thenRetur n(mockedCo nnection);
  1038                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  1039                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenThro w(new Nami ngExceptio n("Rationa l Jazz is  NOT!"));
  1040                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  1041                                               .thenRetur n(mockedIc );
  1042                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  1043                             assert NotNull("v lh failed  to instant iate.", vl h);
  1044  
  1045                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  1046                             when(
  1047                                               Institutio nMappingDe legate
  1048                                                                .get JndiConnec torNameFor Institutio n(SITE_ID) )
  1049                                               .thenRetur n("vlj/myd ev500");
  1050  
  1051                             VistaL inkConnect ion vlc =  vlh.getApp ProxyConne ction(SITE _ID, APP_P ROXY_NAME) ;
  1052  
  1053                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  1054                    } ca tch (Namin gException  e) {
  1055                             assert Equals("Ra tional Jaz z is NOT!" , e.getMes sage());
  1056                    } ca tch (Resou rceExcepti on e) {
  1057                             fail(e .getMessag e());
  1058                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  1059                             fail(e .getMessag e());
  1060                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  1061                             fail(e .getMessag e());
  1062                    } ca tch (Excep tion e) {
  1063                             fail(e .getMessag e());
  1064                    }
  1065           }
  1066  
  1067           /* *
  1068            *  Verify th at getAppP roxyConnec tion(siteI d, appProx yName) ret hrows Reso urceExcept ion
  1069            *  when conn ectionFact ory.getCon nection(co nnSpec) th rows Resou rceExcepti on.
  1070            *
  1071            * /
  1072           @T est
  1073           pu blic void  verifyThat GetAppProx yConnectio nRethrowsR esourceExc eption() {
  1074                    IVis taLinkHelp er vlh;
  1075                    try  {
  1076                             VistaL inkConnect ionFactory  mockedVLc f = mock(V istaLinkCo nnectionFa ctory.clas s);
  1077                             when(m ockedVLcf. getConnect ion(any(Vi staLinkApp ProxyConne ctionSpec. class)))
  1078                                               .thenThrow (new Resou rceExcepti on("Team C oncert !=  Agile"));
  1079                             Initia lContext m ockedIc =  (InitialCo ntext) con text.getBe an("mocked InitialCon text");
  1080                             when(m ockedIc.lo okup("vlj/ mydev500") ).thenRetu rn(mockedV Lcf);
  1081                             whenNe w(InitialC ontext.cla ss).withNo Arguments( )
  1082                                               .thenRetur n(mockedIc );
  1083                             vlh =  (VistaLink Helper) co ntext.getB ean("testV istaLinkHe lper");
  1084                             assert NotNull("v lh failed  to instant iate.", vl h);
  1085  
  1086                             mockSt atic(Insti tutionMapp ingDelegat e.class);
  1087                             when(
  1088                                               Institutio nMappingDe legate
  1089                                                                .get JndiConnec torNameFor Institutio n(SITE_ID) )
  1090                                               .thenRetur n("vlj/myd ev500");
  1091  
  1092                             VistaL inkConnect ion vlc =  vlh.getApp ProxyConne ction(SITE _ID, APP_P ROXY_NAME) ;
  1093  
  1094                             assert NotNull("c onnection  not obtain ed.", vlc) ;
  1095                    } ca tch (Namin gException  e) {
  1096                             fail(e .getMessag e());
  1097                    } ca tch (Resou rceExcepti on e) {
  1098                             assert Equals("Te am Concert  != Agile" , e.getMes sage());
  1099                    } ca tch (Insti tutionMapN otInitiali zedExcepti on e) {
  1100                             fail(e .getMessag e());
  1101                    } ca tch (Insti tutionMapp ingNotFoun dException  e) {
  1102                             fail(e .getMessag e());
  1103                    } ca tch (Excep tion e) {
  1104                             fail(e .getMessag e());
  1105                    }
  1106           }
  1107           
  1108   }