KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > applicationshortctus > ApplicationShortcutsTests


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.applicationshortctus;
21
22 import java.util.Calendar JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.List JavaDoc;
25
26 import org.junit.BeforeClass;
27 import org.junit.Test;
28
29 import com.sslexplorer.applications.ApplicationShortcut;
30 import com.sslexplorer.applications.ApplicationShortcutDatabase;
31 import com.sslexplorer.applications.ApplicationShortcutDatabaseFactory;
32 import com.sslexplorer.applications.ApplicationsPlugin;
33 import com.sslexplorer.applications.DefaultApplicationShortcut;
34 import com.sslexplorer.policyframework.ResourceType;
35 import com.sslexplorer.testcontainer.policyframework.AbstractTestPolicyEnabledResource;
36
37 public class ApplicationShortcutsTests extends AbstractTestPolicyEnabledResource<ApplicationShortcut> {
38
39     @BeforeClass
40     public static void oneTimeSetUp() throws Exception JavaDoc {
41         setUp("sslexplorer-agent,sslexplorer-community-applications,sslexplorer-community-tunnels");
42     }
43
44     @Override JavaDoc
45     public ApplicationShortcut getEmptyResource() throws Exception JavaDoc {
46         Calendar JavaDoc calendar = Calendar.getInstance();
47         return new DefaultApplicationShortcut(getDefaultRealm().getRealmID(), -1, "", "", calendar, calendar, "", Collections.<String JavaDoc,String JavaDoc>emptyMap());
48     }
49
50     @Override JavaDoc
51     public ApplicationShortcut getNormalResource() throws Exception JavaDoc {
52         Calendar JavaDoc calendar = Calendar.getInstance();
53         return new DefaultApplicationShortcut(getDefaultRealm().getRealmID(), -1, "RDP Name", "This is a RDP Description", calendar, calendar, "RDP", Collections.<String JavaDoc,String JavaDoc>emptyMap());
54     }
55
56     @Override JavaDoc
57     public ApplicationShortcut getNullResource() throws Exception JavaDoc {
58         Calendar JavaDoc calendar = Calendar.getInstance();
59         return new DefaultApplicationShortcut(getDefaultRealm().getRealmID(), -1, null, null, calendar, calendar, null, Collections.<String JavaDoc,String JavaDoc>emptyMap());
60     }
61
62     @Override JavaDoc
63     public ApplicationShortcut createResource(ApplicationShortcut resource) throws Exception JavaDoc {
64         return getApplicationShortcutService().getShortcut(
65             getApplicationShortcutService().createApplicationShortcut(resource.getApplication(), resource.getResourceName(),
66                 resource.getResourceDescription(), resource.getParameters(), resource.getRealmID()));
67     }
68
69     @Override JavaDoc
70     public ApplicationShortcut updateResource(ApplicationShortcut resource) throws Exception JavaDoc {
71         getApplicationShortcutService().updateApplicationShortcut(resource.getResourceId(), resource.getResourceName(),
72             resource.getResourceDescription(), resource.getParameters());
73         return getApplicationShortcutService().getShortcut(resource.getResourceId());
74     }
75
76     @Override JavaDoc
77     public List JavaDoc<ApplicationShortcut> getAllResources() throws Exception JavaDoc {
78         return getApplicationShortcutService().getShortcuts();
79     }
80
81     @Override JavaDoc
82     public ResourceType getResourceType() throws Exception JavaDoc {
83         return ApplicationsPlugin.APPLICATION_SHORTCUT_RESOURCE_TYPE;
84     }
85
86     @Override JavaDoc
87     public ApplicationShortcut deleteResource(ApplicationShortcut resource) throws Exception JavaDoc {
88         ApplicationShortcut shortcut = ApplicationShortcutDatabaseFactory.getInstance().getShortcut(resource.getResourceId());
89         getApplicationShortcutService().deleteShortcut(shortcut.getResourceId());
90         return shortcut;
91     }
92
93     @Override JavaDoc
94     public ApplicationShortcut getResource(ApplicationShortcut resource) throws Exception JavaDoc {
95         return getApplicationShortcutService().getShortcut(resource.getResourceId());
96     }
97
98     protected static ApplicationShortcutDatabase getApplicationShortcutService() throws Exception JavaDoc {
99         return ApplicationShortcutDatabaseFactory.getInstance();
100     }
101
102     @Override JavaDoc
103     public void createNullResource() throws Exception JavaDoc {
104     }
105
106     @Test
107     public void mustHaveTests() {
108     }
109 }
Popular Tags