Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * *********************************************************************************************************************
   *
   * NorthernWind - lightweight CMS
   * http://northernwind.tidalwave.it - hg clone https://bitbucket.org/tidalwave/northernwind-src
   * %%
   * Copyright (C) 2011 - 2014 Tidalwave s.a.s. (http://tidalwave.it)
   * %%
  * *********************************************************************************************************************
  *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  *
  *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations under the License.
  *
  * *********************************************************************************************************************
  *
  * $Id: DefaultViewFactoryTest.java,v f214f4c8488f 2014/01/03 18:03:50 fabrizio $
  *
  * *********************************************************************************************************************
  * #L%
  */
 package it.tidalwave.northernwind.frontend.impl.ui;
 
 import  it.tidalwave.util.Id;
 import  it.tidalwave.util.NotFoundException;
 import static org.mockito.Mockito.*;
 import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.CoreMatchers.*;

Author(s):
Fabrizio Giudici
Version:
$Id: DefaultViewFactoryTest.java,v f214f4c8488f 2014/01/03 18:03:50 fabrizio $ /
 
 public class DefaultViewFactoryTest
   {
     private DefaultViewFactory fixture;

    
/
 
     @BeforeMethod
     public void setupFixture()
       throws Exception
       {
          = new DefaultViewFactory();
       }

    
/
 
     @Test
       throws Exception
       {
         .setLogConfigurationEnabled(true);
         .initialize();
 
 
         final ViewBuilder viewBuilder1 = ..get("type1");
         assertThat(viewBuilder1is(not(nullValue())));
         assertThat(viewBuilder1.viewConstructor,           is((Constructor)MockView1.class.getConstructors()[0]));
         assertThat(viewBuilder1.viewControllerConstructoris((Constructor)MockController1.class.getConstructors()[0]));
 
         final ViewBuilder viewBuilder2 = ..get("type2");
         assertThat(viewBuilder2is(not(nullValue())));
         assertThat(viewBuilder2.viewConstructor,           is((Constructor)MockView2.class.getConstructors()[0]));
         assertThat(viewBuilder2.viewControllerConstructoris((Constructor)MockController2.class.getConstructors()[0]));
 
         final ViewBuilder viewBuilder3 = ..get("type3");
         assertThat(viewBuilder3is(not(nullValue())));
         assertThat(viewBuilder3.viewConstructor,           is((Constructor)MockView3.class.getConstructors()[0]));
         assertThat(viewBuilder3.viewControllerConstructoris((Constructor)MockController3.class.getConstructors()[0]));
       }

    
/
 
     @Test
      throws Exception
      {
        final ViewBuilder viewBuilder = mock(ViewBuilder.class);
        final SiteNode siteNode = mock(SiteNode.class);
        final Id id = new Id("theId");
        final ViewAndController viewAndController = mock(ViewAndController.class);
        when(viewBuilder.createViewAndController(eq(id), same(siteNode))).thenReturn(viewAndController);
        ..put("type1"viewBuilder);
        final ViewAndController vac = .createViewAndController("type1"idsiteNode);
        verify(viewBuilder).createViewAndController(eq(id), same(siteNode));
        assertThat(vacis(sameInstance(viewAndController)));
      }

    
/
    @Test(enabled = false// FIXME: often, but not always, fails
          expectedExceptions = NotFoundException.class,
          expectedExceptionsMessageRegExp = "\\QCannot find type3: available: [type1]\\E")
      throws Exception
      {
        final ViewBuilder viewBuilder = mock(ViewBuilder.class);
        final SiteNode siteNode = mock(SiteNode.class);
        final Id id = new Id("theId");
        ..put("type1"viewBuilder);
        final ViewAndController vac = .createViewAndController("type3"idsiteNode);
      }
  }
New to GrepCode? Check out our FAQ X