23. EPMO Open Source Coordination Office Redaction File Detail Report

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

23.1 Files compared

# Location File Last Modified
1 C:\AraxisMergeCompare\Pri_un\ZIP\DSM-cif\Direct Implementation\java\config\config-service-jar\src\test\java\org\nhindirect\config\resources TrustBundleResource_getTrustBundlesTest.java Tue May 22 13:45:46 2018 UTC
2 C:\AraxisMergeCompare\Pri_re\ZIP\DSM-cif\Direct Implementation\java\config\config-service-jar\src\test\java\org\nhindirect\config\resources TrustBundleResource_getTrustBundlesTest.java Tue May 22 20:51:54 2018 UTC

23.2 Comparison summary

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

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

23.4 Active regular expressions

No regular expressions were active.

23.5 Comparison detail

  1   package or g.nhindire ct.config. resources;
  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 jav ax.ws.rs.c ore.MediaT ype;
  12  
  13   import org .junit.Tes t;
  14   import org .nhindirec t.config.B aseTestPla n;
  15   import org .nhindirec t.config.C onfigServi ceRunner;
  16   import org .nhindirec t.config.T estUtils;
  17   import org .nhindirec t.config.m odel.Trust Bundle;
  18   import org .nhindirec t.config.s tore.dao.T rustBundle Dao;
  19  
  20   import com .sun.jerse y.api.clie nt.Generic Type;
  21   import com .sun.jerse y.api.clie nt.Uniform InterfaceE xception;
  22   import com .sun.jerse y.api.clie nt.WebReso urce;
  23  
  24   public cla ss TrustBu ndleResour ce_getTrus tBundlesTe st 
  25   {
  26               protected  TrustBund leDao bund leDao;
  27                
  28                    stat ic WebReso urce resou rce;
  29                    
  30                    abst ract class  TestPlan  extends Ba seTestPlan  
  31                    {
  32                             @Overr ide
  33                             protec ted void s etupMocks( )
  34                             {
  35                                      try
  36                                      {
  37                                               bundleDao  = (TrustBu ndleDao)Co nfigServic eRunner.ge tSpringApp licationCo ntext().ge tBean("tru stBundleDa o");
  38                                              
  39                                               resource =       getR esource(Co nfigServic eRunner.ge tConfigSer viceURL()) ;         
  40                                      }
  41                                      catch (T hrowable t )
  42                                      {
  43                                               throw new  RuntimeExc eption(t);
  44                                      }
  45                             }
  46                             
  47                             @Overr ide
  48                             protec ted void t earDownMoc ks()
  49                             {
  50  
  51                             }
  52  
  53                             protec ted abstra ct Collect ion<TrustB undle> get BundlesToA dd();
  54                             
  55                             protec ted String  getFetchA nchors()
  56                             {
  57                                      return " true";
  58                             }
  59                             
  60                             @Overr ide
  61                             protec ted void p erformInne r() throws  Exception
  62                             {                                  
  63                                      
  64                                      final Co llection<T rustBundle > bundlesT oAdd = get BundlesToA dd();
  65                                      
  66                                      if (bund lesToAdd ! = null)
  67                                      {
  68                                               for (Trust Bundle add Bundle : b undlesToAd d)
  69                                               {
  70                                                       tr y
  71                                                       {
  72                                                                reso urce.path( "/api/trus tbundle"). entity(add Bundle, Me diaType.AP PLICATION_ JSON).put( addBundle) ;
  73                                                       }
  74                                                       ca tch (Unifo rmInterfac eException  e)
  75                                                       {
  76                                                                thro w e;
  77                                                       }
  78                                               }
  79                                      }
  80                                      
  81                                      try
  82                                      {
  83                                              
  84                                               final Gene ricType<Ar rayList<Tr ustBundle> > genType  = new Gene ricType<Ar rayList<Tr ustBundle> >(){};
  85                                               final Coll ection<Tru stBundle>  getBundles  = resourc e.path("/a pi/trustbu ndle/").qu eryParam(" fetchAncho rs", getFe tchAnchors ()) .get(g enType);
  86  
  87                                               doAssertio ns(getBund les);
  88                                      }
  89                                      catch (U niformInte rfaceExcep tion e)
  90                                      {
  91                                               if (e.getR esponse(). getStatus( ) == 204)
  92                                                       do Assertions (new Array List<Trust Bundle>()) ;
  93                                               else
  94                                                       th row e;
  95                                      }
  96                                      
  97                             }
  98                                      
  99                             protec ted void d oAssertion s(Collecti on<TrustBu ndle> cert s) throws  Exception
  100                             {
  101                                      
  102                             }
  103                    }        
  104           
  105                    @Tes t
  106                    publ ic void te stGetAllBu ndles_noSi gningCert_ assertBund lesRetriev ed()  thro ws Excepti on
  107                    {
  108                             new Te stPlan()
  109                             {
  110                                      protecte d Collecti on<TrustBu ndle> bund les;
  111                                      
  112                                      @Overrid e
  113                                      protecte d Collecti on<TrustBu ndle> getB undlesToAd d()
  114                                      {
  115                                               try
  116                                               {
  117                                                       bu ndles = ne w ArrayLis t<TrustBun dle>();
  118                                                       
  119                                                       Tr ustBundle  bundle = n ew TrustBu ndle();
  120                                                       bu ndle.setBu ndleName(" testBundle 1");
  121                                                        bundle.set BundleURL( "http:// IP        /bundle");
  122                                                       bu ndle.setRe freshInter val(24);
  123                                                       bu ndle.setSi gningCerti ficateData (null);          
  124                                                       bu ndles.add( bundle);
  125                             
  126                                                       
  127                                                       bu ndle = new  TrustBund le();
  128                                                       bu ndle.setBu ndleName(" testBundle 2");
  129                                                        bundle.set BundleURL( "http:// IP        /bundle2") ;
  130                                                       bu ndle.setRe freshInter val(12);
  131                                                       bu ndle.setSi gningCerti ficateData (null);
  132                                                       
  133                                                       
  134                                                       bu ndles.add( bundle);
  135                                                       
  136                                                       re turn bundl es;
  137                                               }
  138                                               catch (Exc eption e)
  139                                               {
  140                                                       th row new Ru ntimeExcep tion (e);
  141                                               }
  142                                      }
  143  
  144                                      
  145                                      protecte d void doA ssertions( Collection <TrustBund le> bundle s) throws  Exception
  146                                      {
  147                                               assertNotN ull(bundle s);
  148                                               assertEqua ls(2, bund les.size() );
  149                                              
  150                                               final Iter ator<Trust Bundle> ad dedBundles Iter = thi s.bundles. iterator() ;
  151                                              
  152                                               for (Trust Bundle ret rievedBund le : bundl es)
  153                                               {       
  154                                                       fi nal TrustB undle adde dBundle =  addedBundl esIter.nex t(); 
  155                                                       
  156                                                       as sertEquals (addedBund le.getBund leName(),  retrievedB undle.getB undleName( ));
  157                                                       as sertEquals (addedBund le.getBund leURL(), r etrievedBu ndle.getBu ndleURL()) ;
  158                                                       as sertEquals (addedBund le.getRefr eshInterva l(), retri evedBundle .getRefres hInterval( ));
  159                                                       as sertNull(r etrievedBu ndle.getSi gningCerti ficateData ());
  160                                                       as sertEquals (addedBund le.getTrus tBundleAnc hors().siz e(), retri evedBundle .getTrustB undleAncho rs().size( ));
  161                                               }
  162                                              
  163                                      }
  164                             }.perf orm();
  165                    }                 
  166                    
  167                    @Tes t
  168                    publ ic void te stGetAllBu ndles_hasS igningCert _assertBun dlesRetrie ved()  thr ows Except ion
  169                    {
  170                             new Te stPlan()
  171                             {
  172                                      protecte d Collecti on<TrustBu ndle> bund les;
  173                                      
  174                                      @Overrid e
  175                                      protecte d Collecti on<TrustBu ndle> getB undlesToAd d()
  176                                      {
  177                                               try
  178                                               {
  179                                                       bu ndles = ne w ArrayLis t<TrustBun dle>();
  180                                                       
  181                                                       Tr ustBundle  bundle = n ew TrustBu ndle();
  182                                                       bu ndle.setBu ndleName(" testBundle 1");
  183                                                       bu ndle.setBu ndleURL("h ttp://loca lhost:9999 /bundle");
  184                                                       bu ndle.setRe freshInter val(24);
  185                                                       bu ndle.setSi gningCerti ficateData (TestUtils .loadSigne r("bundleS igner.der" ).getEncod ed());                  
  186                                                       bu ndles.add( bundle);
  187                             
  188                                                       
  189                                                       bu ndle = new  TrustBund le();
  190                                                       bu ndle.setBu ndleName(" testBundle 2");
  191                                                       bu ndle.setBu ndleURL("h ttp://loca lhost:9999 /bundle2") ;
  192                                                       bu ndle.setRe freshInter val(12);
  193                                                       bu ndle.setSi gningCerti ficateData (TestUtils .loadSigne r("bundleS igner.der" ).getEncod ed());
  194                                                       
  195                                                       
  196                                                       bu ndles.add( bundle);
  197                                                       
  198                                                       re turn bundl es;
  199                                               }
  200                                               catch (Exc eption e)
  201                                               {
  202                                                       th row new Ru ntimeExcep tion (e);
  203                                               }
  204                                      }
  205  
  206                                      
  207                                      protecte d void doA ssertions( Collection <TrustBund le> bundle s) throws  Exception
  208                                      {
  209                                               assertNotN ull(bundle s);
  210                                               assertEqua ls(2, bund les.size() );
  211                                              
  212                                               final Iter ator<Trust Bundle> ad dedBundles Iter = thi s.bundles. iterator() ;
  213                                              
  214                                               for (Trust Bundle ret rievedBund le : bundl es)
  215                                               {       
  216                                                       fi nal TrustB undle adde dBundle =  addedBundl esIter.nex t(); 
  217                                                       
  218                                                       as sertEquals (addedBund le.getBund leName(),  retrievedB undle.getB undleName( ));
  219                                                       as sertEquals (addedBund le.getBund leURL(), r etrievedBu ndle.getBu ndleURL()) ;
  220                                                       as sertEquals (addedBund le.getRefr eshInterva l(), retri evedBundle .getRefres hInterval( ));
  221                                                       as sertEquals (TestUtils .loadSigne r("bundleS igner.der" ), retriev edBundle.g etSigningC ertificate AsX509Cert ificate()) ;
  222                                                       as sertEquals (addedBund le.getTrus tBundleAnc hors().siz e(), retri evedBundle .getTrustB undleAncho rs().size( ));
  223                                               }
  224                                              
  225                                      }
  226                             }.perf orm();
  227                    }        
  228                    
  229                    @Tes t
  230                    publ ic void te stGetAllBu ndles_bund leHasAncho rs_request Anchors_as sertBundle sRetrieved ()  throws  Exception
  231                    {
  232                             new Te stPlan()
  233                             {
  234                                      protecte d Collecti on<TrustBu ndle> bund les;
  235                                      
  236                                      @Overrid e
  237                                      protecte d Collecti on<TrustBu ndle> getB undlesToAd d()
  238                                      {
  239                                               try
  240                                               {
  241                                                       bu ndles = ne w ArrayLis t<TrustBun dle>();
  242                                                       
  243                                                       Tr ustBundle  bundle = n ew TrustBu ndle();
  244                                                       bu ndle.setBu ndleName(" testBundle 1");
  245                                                       Fi le fl = ne w File("sr c/test/res ources/bun dles/provi derTestBun dle.p7b");
  246                                                       bu ndle.setBu ndleURL(fi lePrefix +  fl.getAbs olutePath( )); 
  247                                                       bu ndle.setRe freshInter val(24);
  248                                                       bu ndle.setSi gningCerti ficateData (null);          
  249                                                       bu ndles.add( bundle);
  250                             
  251                                                       
  252                                                       bu ndle = new  TrustBund le();
  253                                                       bu ndle.setBu ndleName(" testBundle 2");
  254                                                       bu ndle.setBu ndleURL(fi lePrefix +  fl.getAbs olutePath( )); 
  255                                                       bu ndle.setRe freshInter val(12);
  256                                                       bu ndle.setSi gningCerti ficateData (null);
  257                                                       
  258                                                       
  259                                                       bu ndles.add( bundle);
  260                                                       
  261                                                       re turn bundl es;
  262                                               }
  263                                               catch (Exc eption e)
  264                                               {
  265                                                       th row new Ru ntimeExcep tion (e);
  266                                               }
  267                                      }
  268  
  269                                      
  270                                      protecte d void doA ssertions( Collection <TrustBund le> bundle s) throws  Exception
  271                                      {
  272                                               assertNotN ull(bundle s);
  273                                               assertEqua ls(2, bund les.size() );
  274                                              
  275                                               final Iter ator<Trust Bundle> ad dedBundles Iter = thi s.bundles. iterator() ;
  276                                              
  277                                               for (Trust Bundle ret rievedBund le : bundl es)
  278                                               {       
  279                                                       fi nal TrustB undle adde dBundle =  addedBundl esIter.nex t(); 
  280                                                       
  281                                                       as sertEquals (addedBund le.getBund leName(),  retrievedB undle.getB undleName( ));
  282                                                       as sertEquals (addedBund le.getBund leURL(), r etrievedBu ndle.getBu ndleURL()) ;
  283                                                       as sertEquals (addedBund le.getRefr eshInterva l(), retri evedBundle .getRefres hInterval( ));
  284                                                       as sertNull(r etrievedBu ndle.getSi gningCerti ficateAsX5 09Certific ate());
  285                                                       as sertTrue(r etrievedBu ndle.getTr ustBundleA nchors().s ize() > 0) ;
  286                                               }
  287                                              
  288                                      }
  289                             }.perf orm();
  290                    }        
  291                    
  292                    @Tes t
  293                    publ ic void te stGetAllBu ndles_bund leHasAncho rs_suppres sAnchors_a ssertBundl esRetrieve dWithNoAnc hors()  th rows Excep tion
  294                    {
  295                             new Te stPlan()
  296                             {
  297                                      protecte d Collecti on<TrustBu ndle> bund les;
  298                                      
  299                                      @Overrid e
  300                                      protecte d Collecti on<TrustBu ndle> getB undlesToAd d()
  301                                      {
  302                                               try
  303                                               {
  304                                                       bu ndles = ne w ArrayLis t<TrustBun dle>();
  305                                                       
  306                                                       Tr ustBundle  bundle = n ew TrustBu ndle();
  307                                                       bu ndle.setBu ndleName(" testBundle 1");
  308                                                       Fi le fl = ne w File("sr c/test/res ources/bun dles/provi derTestBun dle.p7b");
  309                                                       bu ndle.setBu ndleURL(fi lePrefix +  fl.getAbs olutePath( )); 
  310                                                       bu ndle.setRe freshInter val(24);
  311                                                       bu ndle.setSi gningCerti ficateData (null);          
  312                                                       bu ndles.add( bundle);
  313                             
  314                                                       
  315                                                       bu ndle = new  TrustBund le();
  316                                                       bu ndle.setBu ndleName(" testBundle 2");
  317                                                       bu ndle.setBu ndleURL(fi lePrefix +  fl.getAbs olutePath( )); 
  318                                                       bu ndle.setRe freshInter val(12);
  319                                                       bu ndle.setSi gningCerti ficateData (null);
  320                                                       
  321                                                       
  322                                                       bu ndles.add( bundle);
  323                                                       
  324                                                       re turn bundl es;
  325                                               }
  326                                               catch (Exc eption e)
  327                                               {
  328                                                       th row new Ru ntimeExcep tion (e);
  329                                               }
  330                                      }
  331  
  332                                      @Overrid e
  333                                      protecte d String g etFetchAnc hors()
  334                                      {
  335                                               return "fa lse";
  336                                      }
  337                                      
  338                                      protecte d void doA ssertions( Collection <TrustBund le> bundle s) throws  Exception
  339                                      {
  340                                               assertNotN ull(bundle s);
  341                                               assertEqua ls(2, bund les.size() );
  342                                              
  343                                               final Iter ator<Trust Bundle> ad dedBundles Iter = thi s.bundles. iterator() ;
  344                                              
  345                                               for (Trust Bundle ret rievedBund le : bundl es)
  346                                               {       
  347                                                       fi nal TrustB undle adde dBundle =  addedBundl esIter.nex t(); 
  348                                                       
  349                                                       as sertEquals (addedBund le.getBund leName(),  retrievedB undle.getB undleName( ));
  350                                                       as sertEquals (addedBund le.getBund leURL(), r etrievedBu ndle.getBu ndleURL()) ;
  351                                                       as sertEquals (addedBund le.getRefr eshInterva l(), retri evedBundle .getRefres hInterval( ));
  352                                                       as sertNull(r etrievedBu ndle.getSi gningCerti ficateAsX5 09Certific ate());
  353                                                       as sertTrue(r etrievedBu ndle.getTr ustBundleA nchors().i sEmpty());
  354                                               }
  355                                              
  356                                      }
  357                             }.perf orm();
  358                    }        
  359                    
  360                    @Tes t
  361                    publ ic void te stGetAllBu ndles_noBu ndlesInSto re_assertN oBundlesRe trieved()   throws Ex ception
  362                    {
  363                             new Te stPlan()
  364                             {        
  365                                      @Overrid e
  366                                      protecte d Collecti on<TrustBu ndle> getB undlesToAd d()
  367                                      {
  368                                               return nul l;
  369                                      }
  370  
  371                                      
  372                                      protecte d void doA ssertions( Collection <TrustBund le> bundle s) throws  Exception
  373                                      {
  374                                               assertNotN ull(bundle s);
  375                                               assertEqua ls(0, bund les.size() );
  376                                              
  377                                      }
  378                             }.perf orm();
  379                    }        
  380                    
  381                    @Tes t
  382                    publ ic void te stGetAllBu ndles_erro rInLookup_ assertServ iceError()   throws E xception
  383                    {
  384                             new Te stPlan()
  385                             {
  386  
  387                                      protecte d TrustBun dleResourc e bundleSe rvice;
  388                                      
  389                                      @Overrid e
  390                                      protecte d void set upMocks()
  391                                      {
  392                                               try
  393                                               {
  394                                                       su per.setupM ocks();
  395                                                       
  396                                                       bu ndleServic e = (Trust BundleReso urce)Confi gServiceRu nner.getSp ringApplic ationConte xt().getBe an("trustB undleResou rce");
  397  
  398                                                       Tr ustBundleD ao mockDAO  = mock(Tr ustBundleD ao.class);
  399                                                       do Throw(new  RuntimeExc eption()). when(mockD AO).getTru stBundles( );
  400                                                       
  401                                                       bu ndleServic e.setTrust BundleDao( mockDAO);
  402                                               }
  403                                               catch (Thr owable t)
  404                                               {
  405                                                       th row new Ru ntimeExcep tion(t);
  406                                               }
  407                                      }
  408                                      
  409                                      @Overrid e
  410                                      protecte d void tea rDownMocks ()
  411                                      {
  412                                               super.tear DownMocks( );
  413                                              
  414                                               bundleServ ice.setTru stBundleDa o(bundleDa o);
  415                                      }                                  
  416                                      
  417                                      @Overrid e
  418                                      protecte d Collecti on<TrustBu ndle> getB undlesToAd d()
  419                                      {
  420                                               return nul l;
  421                                      }
  422  
  423                                      
  424                                      @Overrid e
  425                                      protecte d void ass ertExcepti on(Excepti on excepti on) throws  Exception  
  426                                      {
  427                                               assertTrue (exception  instanceo f UniformI nterfaceEx ception);
  428                                               UniformInt erfaceExce ption ex =  (UniformI nterfaceEx ception)ex ception;
  429                                               assertEqua ls(500, ex .getRespon se().getSt atus());
  430                                      }
  431                             }.perf orm();
  432                    }                         
  433   }