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: DefaultSiteTest.java,v f214f4c8488f 2014/01/03 18:03:50 fabrizio $
  *
  * *********************************************************************************************************************
  * #L%
  */
 package it.tidalwave.northernwind.core.impl.model;
 
 import  javax.annotation.Nonnull;
 import static org.mockito.Mockito.*;
 import static org.hamcrest.MatcherAssert.*;
 import static org.hamcrest.CoreMatchers.sameInstance;
 import static org.hamcrest.CoreMatchers.is;
 import static org.hamcrest.CoreMatchers.nullValue;

Author(s):
Fabrizio Giudici
Version:
$Id: DefaultSiteTest.java,v f214f4c8488f 2014/01/03 18:03:50 fabrizio $ /
 
 public class DefaultSiteTest
   {
 
     private MockModelFactory modelFactory;
 
     private RequestHolder requestHolder;
 
 
 
     private DefaultSite fixture;
 
     private Site.Builder siteBuilder;

    
/
 
     @BeforeMethod
     public void setupFixture()
       throws Exception
       {
          = new ClassPathXmlApplicationContext("DefaultSiteTestBeans.xml");
          = .getBean(MockModelFactory.class);
 
         final Request request = mock(Request.class);
         when(request.getBaseUrl()).thenReturn("/baseUrl");
          = .getBean(RequestHolder.class);
         when(.get()).thenReturn(request);
 
          = mock(ResourceFileSystem.class);
 
         final Site.Builder.CallBack callback = mock(Site.Builder.CallBack.class);
          = new Site.Builder(callback)
                                         .withContextPath("/contextpath"// TODO: should also test ""
                                        .withDocumentPath("/content/document")
                                        .withMediaPath("/content/media")
                                        .withLibraryPath("/content/library")
                                        .withNodePath("/structure")
                                        .withLogConfigurationEnabled(true)
                                        .withConfiguredLocales(Arrays.asList(new Locale("en"), new Locale("it"), new Locale("fr")))
                                        .withIgnoredFolders(Arrays.asList("ignored1""ignored2"));
      }

    
/
    @Test
    public void must_properly_construct()
      throws Exception
      {
         = new DefaultSite();
        assertThat(.getContextPath(), is("/contextpath"));
        assertThat(.is("/content/document"));
        assertThat(.is("/content/media"));
        assertThat(.is("/content/library"));
        assertThat(.is("/structure"));
        assertThat(.getConfiguredLocales(), is(Arrays.asList(new Locale("en"), new Locale("it"), new Locale("fr"))));
        assertThat(.is(Arrays.asList("ignored1""ignored2")));
      }

    
/
    @Test(dataProvider = "fileSystems")
    public void must_properly_initialize (final @Nonnull FileSystemTestSupport fsTestSupport)
      throws Exception
      {
         = new DefaultSite();
        .initialize();
        fsTestSupport.performAssertions();
      }

    
/
    @Test
      throws Exception
      {
        final FileSystemTestSupport fsTestSupport = new EmptyTestFileSystem();
         = new DefaultSite();
        .initialize();
        final DefaultSiteFinder<Contentfinder = (DefaultSiteFinder<Content>).find(Content.class);
//        assertThat(finder.getName) TODO
        assertThat(finder.mapByRelativePathis(sameInstance(.)));
        assertThat(finder.mapByRelativeUri,  is(nullValue()));
      }

    
/
    @Test
      throws Exception
      {
        final FileSystemTestSupport fsTestSupport = new EmptyTestFileSystem();
         = new DefaultSite();
        .initialize();
        final DefaultSiteFinder<Resourcefinder = (DefaultSiteFinder<Resource>).find(Resource.class);
//        assertThat(finder.getName) TODO
        assertThat(finder.mapByRelativePathis(sameInstance(.)));
        assertThat(finder.mapByRelativeUri,  is(nullValue()));
      }

    
/
    @Test
      throws Exception
      {
        final FileSystemTestSupport fsTestSupport = new EmptyTestFileSystem();
         = new DefaultSite();
        .initialize();
        final DefaultSiteFinder<Mediafinder = (DefaultSiteFinder<Media>).find(Media.class);
//        assertThat(finder.getName) TODO
        assertThat(finder.mapByRelativePathis(sameInstance(.)));
        assertThat(finder.mapByRelativeUri,  is(nullValue()));
      }

    
/
    @Test
      throws Exception
      {
        final FileSystemTestSupport fsTestSupport = new EmptyTestFileSystem();
         = new DefaultSite();
        .initialize();
        final DefaultSiteFinder<SiteNodefinder = (DefaultSiteFinder<SiteNode>).find(SiteNode.class);
//        assertThat(finder.getName) TODO
        assertThat(finder.mapByRelativePathis(sameInstance(.)));
        assertThat(finder.mapByRelativeUri,  is(sameInstance(.)));
      }

    
/
    @Test
    public void must_create_correct_links()
      throws Exception
      {
         = new DefaultSite();
        final String result = .createLink(new ResourcePath("link"));
        assertThat(resultis("lpp3-lpp2-lpp1-/baseUrl/contextpath/link"));
      }

    
/
    @DataProvider(name = "fileSystems")
    public Object[][] fileSystemsDataProvider()
      {
        return new Object[][]
          {
            { new EmptyTestFileSystem()                },
            { new TestFileSystemWithOnlyIgnoredFiles() },
            { new TestFileSystemWithAFewStuff1()       }
                // TODO: add more filesystem configurations
          };
      }
  }
New to GrepCode? Check out our FAQ X