KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > server > repo > CifsIntegrationTest


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.smb.server.repo;
18
19 import org.alfresco.filesys.CIFSServer;
20 import org.alfresco.filesys.server.filesys.DiskSharedDevice;
21 import org.alfresco.service.ServiceRegistry;
22 import org.alfresco.service.cmr.repository.NodeRef;
23 import org.alfresco.service.cmr.repository.NodeService;
24 import org.alfresco.util.BaseAlfrescoTestCase;
25
26 /**
27  * Checks that the required configuration details are obtainable from the CIFS components.
28  *
29  * @author Derek Hulley
30  */

31 public class CifsIntegrationTest extends BaseAlfrescoTestCase
32 {
33     
34     public void testGetServerName()
35     {
36         CIFSServer cifsServer = (CIFSServer) ctx.getBean("cifsServer");
37         assertNotNull("No CIFS server available", cifsServer);
38         // the server might, quite legitimately, not start
39
if (!cifsServer.isStarted())
40         {
41             return;
42         }
43         
44         // get the server name
45
String JavaDoc serverName = cifsServer.getConfiguration().getServerName();
46         assertNotNull("No server name available", serverName);
47         assertTrue("No server name available (zero length)", serverName.length() > 0);
48
49         // Get the primary filesystem, might be null if the home folder mapper is configured
50

51         DiskSharedDevice mainFilesys = cifsServer.getConfiguration().getPrimaryFilesystem();
52         
53         if ( mainFilesys != null)
54         {
55             // Check the share name
56

57             String JavaDoc shareName = mainFilesys.getName();
58             assertNotNull("No share name available", shareName);
59             assertTrue("No share name available (zero length)", shareName.length() > 0);
60
61             // Check that the context is valid
62

63             ContentContext filesysCtx = (ContentContext) mainFilesys.getContext();
64             assertNotNull("Content context is null", filesysCtx);
65             assertNotNull("Store id is null", filesysCtx.getStoreName());
66             assertNotNull("Root path is null", filesysCtx.getRootPath());
67             assertNotNull("Root node is null", filesysCtx.getRootNode());
68             
69             // Check the root node
70

71             NodeService nodeService = (NodeService) ctx.getBean(ServiceRegistry.NODE_SERVICE.getLocalName());
72             // get the share root node and check that it exists
73
NodeRef shareNodeRef = filesysCtx.getRootNode();
74             assertNotNull("No share root node available", shareNodeRef);
75             assertTrue("Share root node doesn't exist", nodeService.exists(shareNodeRef));
76         }
77     }
78 }
79
Popular Tags