View Javadoc

1   /**
2    * Copyright 2008 WebPhotos
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.webphotos.netbeans.project;
17  
18  import org.junit.After;
19  import org.junit.AfterClass;
20  import static org.junit.Assert.*;
21  import org.junit.Before;
22  import org.junit.BeforeClass;
23  import org.junit.Test;
24  import org.netbeans.api.project.Project;
25  import org.netbeans.spi.project.ProjectState;
26  import org.openide.filesystems.FileObject;
27  import org.openide.filesystems.FileSystem;
28  import org.openide.filesystems.FileUtil;
29  
30  /**
31   *
32   * @author Guilherme
33   */
34  public class WebPhotosProjectFactoryTest {
35  
36      private FileObject baseProjectTest;
37      private FileSystem memoryFileSystem;
38  
39      @BeforeClass
40      public static void setUpClass() {
41      }
42  
43      @AfterClass
44      public static void tearDownClass() {
45      }
46  
47      @Before
48      public void setUp() throws Exception {
49          memoryFileSystem = FileUtil.createMemoryFileSystem();
50          baseProjectTest = memoryFileSystem.getRoot();
51          for (String node : WebPhotosProjectFactory.PROJECT_ARCHIVES) {
52              FileUtil.createData(baseProjectTest, node);
53          }
54          assertNotNull(baseProjectTest);
55      }
56  
57      @After
58      public void tearDown() {
59      }
60  
61      /**
62       * Test of isProject method, of class WebPhotosProjectFactory.
63       */
64      @Test
65      public void testIsProject() {
66          System.out.println("isProject");
67          FileObject projectDirectory = baseProjectTest;
68          WebPhotosProjectFactory instance = new WebPhotosProjectFactory();
69          boolean expResult = true;
70          boolean result = instance.isProject(projectDirectory);
71          assertEquals(expResult, result);
72      }
73  
74      /**
75       * Test of loadProject method, of class WebPhotosProjectFactory.
76       */
77      @Test
78      public void testLoadProject() throws Exception {
79          System.out.println("loadProject");
80          FileObject dir = baseProjectTest;
81          ProjectState state = new ProjectState() {
82  
83              @Override
84              public void markModified() {
85                  throw new UnsupportedOperationException("Not supported yet.");
86              }
87  
88              @Override
89              public void notifyDeleted() throws IllegalStateException {
90                  throw new UnsupportedOperationException("Not supported yet.");
91              }
92          };
93          WebPhotosProjectFactory instance = new WebPhotosProjectFactory();
94          Project result = instance.loadProject(dir, state);
95          assertNotNull(result);
96      }
97  
98      /**
99       * Test of saveProject method, of class WebPhotosProjectFactory.
100      */
101     public void testSaveProject() throws Exception {
102         System.out.println("saveProject");
103         Project project = null;
104         WebPhotosProjectFactory instance = new WebPhotosProjectFactory();
105         instance.saveProject(project);
106         // TODO review the generated test code and remove the default call to fail.
107         fail("The test case is a prototype.");
108     }
109 }