KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > MailResourceConfigTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  
24 /*
25  * $Header: /cvs/glassfish/admin/mbeanapi-impl/tests/com/sun/enterprise/management/config/MailResourceConfigTest.java,v 1.6 2006/03/09 20:30:54 llc Exp $
26  * $Revision: 1.6 $
27  * $Date: 2006/03/09 20:30:54 $
28  */

29 package com.sun.enterprise.management.config;
30
31 import java.util.Collections JavaDoc;
32 import java.util.Map JavaDoc;
33
34 import com.sun.appserv.management.base.Container;
35 import com.sun.appserv.management.base.XTypes;
36
37 import com.sun.appserv.management.config.AMXConfig;
38 import com.sun.appserv.management.config.DomainConfig;
39 import com.sun.appserv.management.config.MailResourceConfig;
40 import com.sun.appserv.management.config.SecurityServiceConfig;
41
42
43
44 /**
45  */

46 public final class MailResourceConfigTest extends ResourceConfigTestBase
47 {
48     private static final String JavaDoc MAIL_RESOURCE_HOST = "localhost";
49     private static final String JavaDoc MAIL_RESOURCE_USER = "someone";
50     private static final String JavaDoc MAIL_RESOURCE_FROM = "someone@somewhere.com";
51
52     public MailResourceConfigTest()
53     {
54         if ( checkNotOffline( "ensureDefaultInstance" ) )
55         {
56             ensureDefaultInstance( getDomainConfig() );
57         }
58     }
59     
60          public static String JavaDoc
61     getDefaultInstanceName()
62     {
63         return getDefaultInstanceName( "MailResourceConfig" );
64     }
65     
66         public static MailResourceConfig
67     ensureDefaultInstance( final DomainConfig dc )
68     {
69         MailResourceConfig result = dc.getMailResourceConfigMap().get( getDefaultInstanceName() );
70         
71         if ( result == null )
72         {
73             result = createInstance( dc, getDefaultInstanceName(),
74                 MAIL_RESOURCE_HOST, MAIL_RESOURCE_USER, MAIL_RESOURCE_FROM, null);
75         }
76         
77         return result;
78     }
79     
80         public static MailResourceConfig
81     createInstance(
82         final DomainConfig ss,
83         final String JavaDoc name,
84         final String JavaDoc host,
85         final String JavaDoc user,
86         final String JavaDoc from,
87         Map JavaDoc<String JavaDoc,String JavaDoc> optional)
88     {
89         return ss.createMailResourceConfig( name, host, user, from, optional );
90     }
91     
92         protected String JavaDoc
93     getProgenyTestName()
94     {
95         return( "jndi/MailResourceConfigMgrTest" );
96     }
97     
98         protected Container
99     getProgenyContainer()
100     {
101         return getDomainConfig();
102     }
103
104         protected String JavaDoc
105     getProgenyJ2EEType()
106     {
107         return XTypes.MAIL_RESOURCE_CONFIG;
108     }
109
110
111         protected void
112     removeProgeny( final String JavaDoc name )
113     {
114         getDomainConfig().removeMailResourceConfig( name );
115     }
116     
117         protected final AMXConfig
118     createProgeny( final String JavaDoc name, final Map JavaDoc<String JavaDoc,String JavaDoc> options )
119     {
120         final MailResourceConfig config =
121             getDomainConfig().createMailResourceConfig( name,
122                                     MAIL_RESOURCE_HOST,
123                                     MAIL_RESOURCE_USER,
124                                     MAIL_RESOURCE_FROM,
125                                     options);
126         assert( config != null );
127         return( config );
128     }
129     
130 }
131
132
133
Popular Tags