001: /**
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 2006 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or 1any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: C_j2eemanagement.java 10557 2007-06-07 09:21:44Z coqp $
023: * --------------------------------------------------------------------------
024: */package org.objectweb.jonas.examples.clients.j2eemanagement;
025:
026: import junit.framework.TestSuite;
027:
028: import org.objectweb.jonas.examples.util.JExampleTestCase;
029:
030: import com.meterware.httpunit.WebResponse;
031:
032: /**
033: * Define a class to test the j2eemanagement example
034: * Test authentication, and check the sample is ok
035: * @author Adriana Danes
036: */
037: public class C_j2eemanagement extends JExampleTestCase {
038:
039: /**
040: * URL of the earsample page
041: */
042: private static final String URL_J2EEMANAGEMENT_DOMAIN = "/j2eemanagement/mgmt?domainName=jonas";
043:
044: /**
045: * Main method
046: * @param args the arguments
047: */
048: public static void main(String[] args) {
049:
050: String testtorun = null;
051: // Get args
052: for (int argn = 0; argn < args.length; argn++) {
053: String sArg = args[argn];
054: if (sArg.equals("-n")) {
055: testtorun = args[++argn];
056: }
057: }
058:
059: if (testtorun == null) {
060: junit.textui.TestRunner.run(suite());
061: } else {
062: junit.textui.TestRunner
063: .run(new C_j2eemanagement(testtorun));
064: }
065: }
066:
067: /**
068: * Get a new TestSuite for this class
069: * @return a new TestSuite for this class
070: */
071: public static TestSuite suite() {
072: return new TestSuite(C_j2eemanagement.class);
073: }
074:
075: /**
076: * Setup need for these tests
077: * earsample is required
078: * @throws Exception if it fails
079: */
080: protected void setUp() throws Exception {
081: super .setUp();
082: useEar("j2eemanagement");
083: }
084:
085: /**
086: * Constructor with a specified name
087: * @param s name
088: */
089: public C_j2eemanagement(String s) {
090: super (s, URL_J2EEMANAGEMENT_DOMAIN);
091: }
092:
093: /**
094: * Check if the sample is OK. Analyze response
095: * @throws Exception if an error occurs
096: */
097: public void testIsSampleOk() throws Exception {
098: WebResponse wr = wc.getResponse(url);
099: String txt = wr.getText();
100:
101: if (txt.indexOf("Application is OK") == -1) {
102: fail("The example was not ok : " + txt);
103: }
104: }
105:
106: }
|