17. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 5/25/2018 9:21:41 AM Central Daylight 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.

17.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\ZIP\DSM-cif\Direct Implementation\java\config\config-service-client\src\test\java\org\nhind\config\rest\impl DefaultTrustBundleService_getTrustBundlesTest.java Tue May 22 13:50:20 2018 UTC
2 C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\config\config-service-client\src\test\java\org\nhind\config\rest\impl DefaultTrustBundleService_getTrustBundlesTest.java Tue May 22 20:51:00 2018 UTC

17.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 3 862
Changed 2 4
Inserted 0 0
Removed 0 0

17.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

17.4 Active regular expressions

No regular expressions were active.

17.5 Comparison detail

  1   package or g.nhind.co nfig.rest. impl;
  2  
  3   import sta tic org.mo ckito.Mock ito.doThro w;
  4   import sta tic org.mo ckito.Mock ito.mock;
  5  
  6   import jav a.io.File;
  7   import jav a.util.Arr ayList;
  8   import jav a.util.Col lection;
  9   import jav a.util.Ite rator;
  10  
  11   import org .junit.Tes t;
  12   import org .nhind.con fig.client .ConfigSer viceRunner ;
  13  
  14   import org .nhind.con fig.rest.T rustBundle Service;
  15   import org .nhind.con fig.testba se.BaseTes tPlan;
  16   import org .nhind.con fig.testba se.TestUti ls;
  17  
  18   import org .nhindirec t.common.r est.except ions.Servi ceExceptio n;
  19   import org .nhindirec t.common.r est.except ions.Servi ceMethodEx ception;
  20  
  21   import org .nhindirec t.config.m odel.Trust Bundle;
  22   import org .nhindirec t.config.r esources.T rustBundle Resource;
  23  
  24   import org .nhindirec t.config.s tore.dao.T rustBundle Dao;
  25  
  26   public cla ss Default TrustBundl eService_g etTrustBun dlesTest 
  27   {
  28       protec ted TrustB undleDao b undleDao;
  29       
  30           st atic Trust BundleServ ice resour ce;
  31           
  32           ab stract cla ss TestPla n extends  BaseTestPl an 
  33           {
  34                    @Ove rride
  35                    prot ected void  setupMock s()
  36                    {
  37                             try
  38                             {
  39                                      bundleDa o = (Trust BundleDao) ConfigServ iceRunner. getSpringA pplication Context(). getBean("t rustBundle Dao");
  40                                      
  41                                      resource  =      (T rustBundle Service)Ba seTestPlan .getServic e(ConfigSe rviceRunne r.getRestA PIBaseURL( ), TRUST_B UNDLE_SERV ICE);     
  42  
  43                             }
  44                             catch  (Throwable  t)
  45                             {
  46                                      throw ne w RuntimeE xception(t );
  47                             }
  48                    }
  49                    
  50                    @Ove rride
  51                    prot ected void  tearDownM ocks()
  52                    {
  53  
  54                    }
  55  
  56                    prot ected abst ract Colle ction<Trus tBundle> g etBundlesT oAdd();
  57                    
  58                    prot ected Stri ng getFetc hAnchors()
  59                    {
  60                             return  "true";
  61                    }
  62                    
  63                    @Ove rride
  64                    prot ected void  performIn ner() thro ws Excepti on
  65                    {                                  
  66                             
  67                             final  Collection <TrustBund le> bundle sToAdd = g etBundlesT oAdd();
  68                             
  69                             if (bu ndlesToAdd  != null)
  70                             {
  71                                      for (Tru stBundle a ddBundle :  bundlesTo Add)
  72                                      {
  73                                               try
  74                                               {
  75                                                       re source.add TrustBundl e(addBundl e);
  76                                               }
  77                                               catch (Ser viceExcept ion e)
  78                                               {
  79                                                       th row e;
  80                                               }
  81                                      }
  82                             }
  83                             
  84                             try
  85                             {
  86                                      final Co llection<T rustBundle > getBundl es = resou rce.getTru stBundles( Boolean.pa rseBoolean (getFetchA nchors())) ;
  87                                      doAssert ions(getBu ndles);
  88                             }
  89                             catch  (ServiceMe thodExcept ion e)
  90                             {
  91                                      if (e.ge tResponseC ode() == 2 04)
  92                                               doAssertio ns(new Arr ayList<Tru stBundle>( ));
  93                                      else
  94                                               throw e;
  95                             }
  96                             
  97                    }
  98                             
  99                    prot ected void  doAsserti ons(Collec tion<Trust Bundle> ce rts) throw s Exceptio n
  100                    {
  101                             
  102                    }
  103           }        
  104  
  105           @T est
  106           pu blic void  testGetAll Bundles_no SigningCer t_assertBu ndlesRetri eved()  th rows Excep tion
  107           {
  108                    new  TestPlan()
  109                    {
  110                             protec ted Collec tion<Trust Bundle> bu ndles;
  111                             
  112                             @Overr ide
  113                             protec ted Collec tion<Trust Bundle> ge tBundlesTo Add()
  114                             {
  115                                      try
  116                                      {
  117                                               bundles =  new ArrayL ist<TrustB undle>();
  118                                              
  119                                               TrustBundl e bundle =  new Trust Bundle();
  120                                               bundle.set BundleName ("testBund le1");
  121                                                bundle.set BundleURL( "http:// IP        /bundle");
  122                                               bundle.set RefreshInt erval(24);
  123                                               bundle.set SigningCer tificateDa ta(null);          
  124                                               bundles.ad d(bundle);
  125                    
  126                                              
  127                                               bundle = n ew TrustBu ndle();
  128                                               bundle.set BundleName ("testBund le2");
  129                                                bundle.set BundleURL( "http:// IP        /bundle2") ;
  130                                               bundle.set RefreshInt erval(12);
  131                                               bundle.set SigningCer tificateDa ta(null);
  132                                              
  133                                              
  134                                               bundles.ad d(bundle);
  135                                              
  136                                               return bun dles;
  137                                      }
  138                                      catch (E xception e )
  139                                      {
  140                                               throw new  RuntimeExc eption (e) ;
  141                                      }
  142                             }
  143  
  144                             
  145                             protec ted void d oAssertion s(Collecti on<TrustBu ndle> bund les) throw s Exceptio n
  146                             {
  147                                      assertNo tNull(bund les);
  148                                      assertEq uals(2, bu ndles.size ());
  149                                      
  150                                      final It erator<Tru stBundle>  addedBundl esIter = t his.bundle s.iterator ();
  151                                      
  152                                      for (Tru stBundle r etrievedBu ndle : bun dles)
  153                                      {       
  154                                               final Trus tBundle ad dedBundle  = addedBun dlesIter.n ext(); 
  155                                              
  156                                               assertEqua ls(addedBu ndle.getBu ndleName() , retrieve dBundle.ge tBundleNam e());
  157                                               assertEqua ls(addedBu ndle.getBu ndleURL(),  retrieved Bundle.get BundleURL( ));
  158                                               assertEqua ls(addedBu ndle.getRe freshInter val(), ret rievedBund le.getRefr eshInterva l());
  159                                               assertNull (retrieved Bundle.get SigningCer tificateDa ta());
  160                                               assertEqua ls(addedBu ndle.getTr ustBundleA nchors().s ize(), ret rievedBund le.getTrus tBundleAnc hors().siz e());
  161                                      }
  162                                      
  163                             }
  164                    }.pe rform();
  165           }                 
  166           
  167           @T est
  168           pu blic void  testGetAll Bundles_ha sSigningCe rt_assertB undlesRetr ieved()  t hrows Exce ption
  169           {
  170                    new  TestPlan()
  171                    {
  172                             protec ted Collec tion<Trust Bundle> bu ndles;
  173                             
  174                             @Overr ide
  175                             protec ted Collec tion<Trust Bundle> ge tBundlesTo Add()
  176                             {
  177                                      try
  178                                      {
  179                                               bundles =  new ArrayL ist<TrustB undle>();
  180                                              
  181                                               TrustBundl e bundle =  new Trust Bundle();
  182                                               bundle.set BundleName ("testBund le1");
  183                                               bundle.set BundleURL( "http://lo calhost:99 99/bundle" );
  184                                               bundle.set RefreshInt erval(24);
  185                                               bundle.set SigningCer tificateDa ta(TestUti ls.loadSig ner("bundl eSigner.de r").getEnc oded());                  
  186                                               bundles.ad d(bundle);
  187                    
  188                                              
  189                                               bundle = n ew TrustBu ndle();
  190                                               bundle.set BundleName ("testBund le2");
  191                                               bundle.set BundleURL( "http://lo calhost:99 99/bundle2 ");
  192                                               bundle.set RefreshInt erval(12);
  193                                               bundle.set SigningCer tificateDa ta(TestUti ls.loadSig ner("bundl eSigner.de r").getEnc oded());
  194                                              
  195                                              
  196                                               bundles.ad d(bundle);
  197                                              
  198                                               return bun dles;
  199                                      }
  200                                      catch (E xception e )
  201                                      {
  202                                               throw new  RuntimeExc eption (e) ;
  203                                      }
  204                             }
  205  
  206                             
  207                             protec ted void d oAssertion s(Collecti on<TrustBu ndle> bund les) throw s Exceptio n
  208                             {
  209                                      assertNo tNull(bund les);
  210                                      assertEq uals(2, bu ndles.size ());
  211                                      
  212                                      final It erator<Tru stBundle>  addedBundl esIter = t his.bundle s.iterator ();
  213                                      
  214                                      for (Tru stBundle r etrievedBu ndle : bun dles)
  215                                      {       
  216                                               final Trus tBundle ad dedBundle  = addedBun dlesIter.n ext(); 
  217                                              
  218                                               assertEqua ls(addedBu ndle.getBu ndleName() , retrieve dBundle.ge tBundleNam e());
  219                                               assertEqua ls(addedBu ndle.getBu ndleURL(),  retrieved Bundle.get BundleURL( ));
  220                                               assertEqua ls(addedBu ndle.getRe freshInter val(), ret rievedBund le.getRefr eshInterva l());
  221                                               assertEqua ls(TestUti ls.loadSig ner("bundl eSigner.de r"), retri evedBundle .getSignin gCertifica teAsX509Ce rtificate( ));
  222                                               assertEqua ls(addedBu ndle.getTr ustBundleA nchors().s ize(), ret rievedBund le.getTrus tBundleAnc hors().siz e());
  223                                      }
  224                                      
  225                             }
  226                    }.pe rform();
  227           }        
  228           
  229           @T est
  230           pu blic void  testGetAll Bundles_bu ndleHasAnc hors_reque stAnchors_ assertBund lesRetriev ed()  thro ws Excepti on
  231           {
  232                    new  TestPlan()
  233                    {
  234                             protec ted Collec tion<Trust Bundle> bu ndles;
  235                             
  236                             @Overr ide
  237                             protec ted Collec tion<Trust Bundle> ge tBundlesTo Add()
  238                             {
  239                                      try
  240                                      {
  241                                               bundles =  new ArrayL ist<TrustB undle>();
  242                                              
  243                                               TrustBundl e bundle =  new Trust Bundle();
  244                                               bundle.set BundleName ("testBund le1");
  245                                               File fl =  new File(" src/test/r esources/b undles/pro viderTestB undle.p7b" );
  246                                               bundle.set BundleURL( filePrefix  + fl.getA bsolutePat h()); 
  247                                               bundle.set RefreshInt erval(24);
  248                                               bundle.set SigningCer tificateDa ta(null);          
  249                                               bundles.ad d(bundle);
  250                    
  251                                              
  252                                               bundle = n ew TrustBu ndle();
  253                                               bundle.set BundleName ("testBund le2");
  254                                               bundle.set BundleURL( filePrefix  + fl.getA bsolutePat h()); 
  255                                               bundle.set RefreshInt erval(12);
  256                                               bundle.set SigningCer tificateDa ta(null);
  257                                              
  258                                              
  259                                               bundles.ad d(bundle);
  260                                              
  261                                               return bun dles;
  262                                      }
  263                                      catch (E xception e )
  264                                      {
  265                                               throw new  RuntimeExc eption (e) ;
  266                                      }
  267                             }
  268  
  269                             
  270                             protec ted void d oAssertion s(Collecti on<TrustBu ndle> bund les) throw s Exceptio n
  271                             {
  272                                      assertNo tNull(bund les);
  273                                      assertEq uals(2, bu ndles.size ());
  274                                      
  275                                      final It erator<Tru stBundle>  addedBundl esIter = t his.bundle s.iterator ();
  276                                      
  277                                      for (Tru stBundle r etrievedBu ndle : bun dles)
  278                                      {       
  279                                               final Trus tBundle ad dedBundle  = addedBun dlesIter.n ext(); 
  280                                              
  281                                               assertEqua ls(addedBu ndle.getBu ndleName() , retrieve dBundle.ge tBundleNam e());
  282                                               assertEqua ls(addedBu ndle.getBu ndleURL(),  retrieved Bundle.get BundleURL( ));
  283                                               assertEqua ls(addedBu ndle.getRe freshInter val(), ret rievedBund le.getRefr eshInterva l());
  284                                               assertNull (retrieved Bundle.get SigningCer tificateAs X509Certif icate());
  285                                               assertTrue (retrieved Bundle.get TrustBundl eAnchors() .size() >  0);
  286                                      }
  287                                      
  288                             }
  289                    }.pe rform();
  290           }        
  291           
  292           @T est
  293           pu blic void  testGetAll Bundles_bu ndleHasAnc hors_suppr essAnchors _assertBun dlesRetrie vedWithNoA nchors()   throws Exc eption
  294           {
  295                    new  TestPlan()
  296                    {
  297                             protec ted Collec tion<Trust Bundle> bu ndles;
  298                             
  299                             @Overr ide
  300                             protec ted Collec tion<Trust Bundle> ge tBundlesTo Add()
  301                             {
  302                                      try
  303                                      {
  304                                               bundles =  new ArrayL ist<TrustB undle>();
  305                                              
  306                                               TrustBundl e bundle =  new Trust Bundle();
  307                                               bundle.set BundleName ("testBund le1");
  308                                               File fl =  new File(" src/test/r esources/b undles/pro viderTestB undle.p7b" );
  309                                               bundle.set BundleURL( filePrefix  + fl.getA bsolutePat h()); 
  310                                               bundle.set RefreshInt erval(24);
  311                                               bundle.set SigningCer tificateDa ta(null);          
  312                                               bundles.ad d(bundle);
  313                    
  314                                              
  315                                               bundle = n ew TrustBu ndle();
  316                                               bundle.set BundleName ("testBund le2");
  317                                               bundle.set BundleURL( filePrefix  + fl.getA bsolutePat h()); 
  318                                               bundle.set RefreshInt erval(12);
  319                                               bundle.set SigningCer tificateDa ta(null);
  320                                              
  321                                              
  322                                               bundles.ad d(bundle);
  323                                              
  324                                               return bun dles;
  325                                      }
  326                                      catch (E xception e )
  327                                      {
  328                                               throw new  RuntimeExc eption (e) ;
  329                                      }
  330                             }
  331  
  332                             @Overr ide
  333                             protec ted String  getFetchA nchors()
  334                             {
  335                                      return " false";
  336                             }
  337                             
  338                             protec ted void d oAssertion s(Collecti on<TrustBu ndle> bund les) throw s Exceptio n
  339                             {
  340                                      assertNo tNull(bund les);
  341                                      assertEq uals(2, bu ndles.size ());
  342                                      
  343                                      final It erator<Tru stBundle>  addedBundl esIter = t his.bundle s.iterator ();
  344                                      
  345                                      for (Tru stBundle r etrievedBu ndle : bun dles)
  346                                      {       
  347                                               final Trus tBundle ad dedBundle  = addedBun dlesIter.n ext(); 
  348                                              
  349                                               assertEqua ls(addedBu ndle.getBu ndleName() , retrieve dBundle.ge tBundleNam e());
  350                                               assertEqua ls(addedBu ndle.getBu ndleURL(),  retrieved Bundle.get BundleURL( ));
  351                                               assertEqua ls(addedBu ndle.getRe freshInter val(), ret rievedBund le.getRefr eshInterva l());
  352                                               assertNull (retrieved Bundle.get SigningCer tificateAs X509Certif icate());
  353                                               assertTrue (retrieved Bundle.get TrustBundl eAnchors() .isEmpty() );
  354                                      }
  355                                      
  356                             }
  357                    }.pe rform();
  358           }        
  359           
  360           @T est
  361           pu blic void  testGetAll Bundles_no BundlesInS tore_asser tNoBundles Retrieved( )  throws  Exception
  362           {
  363                    new  TestPlan()
  364                    {        
  365                             @Overr ide
  366                             protec ted Collec tion<Trust Bundle> ge tBundlesTo Add()
  367                             {
  368                                      return n ull;
  369                             }
  370  
  371                             
  372                             protec ted void d oAssertion s(Collecti on<TrustBu ndle> bund les) throw s Exceptio n
  373                             {
  374                                      assertNo tNull(bund les);
  375                                      assertEq uals(0, bu ndles.size ());
  376                                      
  377                             }
  378                    }.pe rform();
  379           }        
  380           
  381           @T est
  382           pu blic void  testGetAll Bundles_er rorInLooku p_assertSe rviceError ()  throws  Exception
  383           {
  384                    new  TestPlan()
  385                    {
  386  
  387                             protec ted TrustB undleResou rce bundle Service;
  388                             
  389                             @Overr ide
  390                             protec ted void s etupMocks( )
  391                             {
  392                                      try
  393                                      {
  394                                               super.setu pMocks();
  395                                              
  396                                               bundleServ ice = (Tru stBundleRe source)Con figService Runner.get SpringAppl icationCon text().get Bean("trus tBundleRes ource");
  397  
  398                                               TrustBundl eDao mockD AO = mock( TrustBundl eDao.class );
  399                                               doThrow(ne w RuntimeE xception() ).when(moc kDAO).getT rustBundle s();
  400                                              
  401                                               bundleServ ice.setTru stBundleDa o(mockDAO) ;
  402                                      }
  403                                      catch (T hrowable t )
  404                                      {
  405                                               throw new  RuntimeExc eption(t);
  406                                      }
  407                             }
  408                             
  409                             @Overr ide
  410                             protec ted void t earDownMoc ks()
  411                             {
  412                                      super.te arDownMock s();
  413                                      
  414                                      bundleSe rvice.setT rustBundle Dao(bundle Dao);
  415                             }                                  
  416                             
  417                             @Overr ide
  418                             protec ted Collec tion<Trust Bundle> ge tBundlesTo Add()
  419                             {
  420                                      return n ull;
  421                             }
  422  
  423                             
  424                             @Overr ide
  425                             protec ted void a ssertExcep tion(Excep tion excep tion) thro ws Excepti on 
  426                             {
  427                                      assertTr ue(excepti on instanc eof Servic eMethodExc eption);
  428                                      ServiceM ethodExcep tion ex =  (ServiceMe thodExcept ion)except ion;
  429                                      assertEq uals(500,  ex.getResp onseCode() );
  430                             }
  431                    }.pe rform();
  432           }                          
  433   }