KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > repo > action > executer > SpecialiseTypeActionExecuterTest


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.repo.action.executer;
18
19 import org.alfresco.model.ContentModel;
20 import org.alfresco.repo.action.ActionImpl;
21 import org.alfresco.service.cmr.repository.NodeRef;
22 import org.alfresco.service.namespace.QName;
23 import org.alfresco.util.BaseAlfrescoSpringTest;
24 import org.alfresco.util.GUID;
25
26 /**
27  * Specialise type action execution test
28  *
29  * @author Roy Wetherall
30  */

31 public class SpecialiseTypeActionExecuterTest extends BaseAlfrescoSpringTest
32 {
33     /**
34      * The test node reference
35      */

36     private NodeRef nodeRef;
37     
38     /**
39      * The specialise action executer
40      */

41     private SpecialiseTypeActionExecuter executer;
42     
43     /**
44      * Id used to identify the test action created
45      */

46     private final static String JavaDoc ID = GUID.generate();
47     
48     /**
49      * Called at the begining of all tests
50      */

51     @Override JavaDoc
52     protected void onSetUpInTransaction() throws Exception JavaDoc
53     {
54         super.onSetUpInTransaction();
55         
56         // Create the node used for tests
57
this.nodeRef = this.nodeService.createNode(
58                 this.rootNodeRef,
59                 ContentModel.ASSOC_CHILDREN,
60                 QName.createQName("{test}testnode"),
61                 ContentModel.TYPE_CONTENT).getChildRef();
62         
63         // Get the executer instance
64
this.executer = (SpecialiseTypeActionExecuter)this.applicationContext.getBean(SpecialiseTypeActionExecuter.NAME);
65     }
66     
67     /**
68      * Test execution
69      */

70     public void testExecution()
71     {
72         // Check the type of the node
73
assertEquals(ContentModel.TYPE_CONTENT, this.nodeService.getType(this.nodeRef));
74         
75         // Execute the action
76
ActionImpl action = new ActionImpl(ID, SpecialiseTypeActionExecuter.NAME, null);
77         action.setParameterValue(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME, ContentModel.TYPE_FOLDER);
78         this.executer.execute(action, this.nodeRef);
79         
80         // Check that the node's type has not been changed since it would not be a specialisation
81
assertEquals(ContentModel.TYPE_CONTENT, this.nodeService.getType(this.nodeRef));
82         
83         // Execute the action agian
84
action.setParameterValue(SpecialiseTypeActionExecuter.PARAM_TYPE_NAME, ContentModel.TYPE_DICTIONARY_MODEL);
85         this.executer.execute(action, this.nodeRef);
86         
87         // Check that the node's type has now been changed
88
assertEquals(ContentModel.TYPE_DICTIONARY_MODEL, this.nodeService.getType(this.nodeRef));
89     }
90 }
91
Popular Tags