BaseAdminConsoleTest.java revision ada1678a4262b208a7b87391f520a7767d25287c
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
/** The base class for admin console tests. Designed for extension.
* @author jdlee@dev.java.net
* @since GlassFish v3 Prelude
*/
public class BaseAdminConsoleTest {
private HttpClient client;
private int port;
private volatile MBeanServerConnection mMBeanServerConnection;
private volatile DomainRoot mDomainRoot;
// Copied from Lloyd's AMX tests
void setUpEnvironment(int port) {
try {
if (mMBeanServerConnection == null) {
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* This BeforeTest method will verify that the login form is available. Once
* it is found, the login form is submitted. If the login succeeds, then
* the tests are allowed to continue. If the login fails, the each test will
* fail.
* @param url
* @throws java.lang.Exception
*/
client = new HttpClient();
boolean formFound = false;
int iteration = 0;
if (!checkForAdminConsoleDirectory()) {
". Please check your installation.");
}
iteration++;
if (!formFound) {
}
}
if (!formFound) {
}
// The login for was found, so let's now POST the form to authenticate our session.
});
if (statusCode == 302) {
if (locationHeader != null) {
} else {
}
}
}
/**
* This method uses the AMX API to get the install directory, then checks to
* see if the admin console directory is present.
* @return
*/
protected boolean checkForAdminConsoleDirectory() {
// Hard-coding "../glassfish" to help cover a deficiency in IPS
}
public void shutdownClient() {
}
/**
* This method will request the specified URL and examine the response for the
* needle specified.
* @param url
* @param needle
* @return
* @throws java.lang.Exception
*/
boolean allFound = true;
allFound = false;
}
}
return allFound;
}
/**
* Request the specified URL and return the contents as a String
* @param url
* @return
* @throws java.io.IOException
*/
get.setFollowRedirects(true);
//Also accepts SC_ACCPTED ie 202 for the case when the console is still loading.
Assert.fail("BaseAdminConsoleTest.getUrlAndTestForString() failed. HTTP Status Code: " + statusCode);
}
return response;
}
/**
* Read the entire contents of the InputStream and return them as a String
* @param in
* @return
* @throws java.io.IOException
*/
byte[] b = new byte[4096];
}
}
/*
* These methods were all copied from Lloyd's AMX QL tests.
*/
protected DomainRoot getDomainRoot() {
return mDomainRoot;
}
return domainRoot;
}
throws MalformedURLException, IOException {
// service:jmx:jmxmp://localhost:8888
// CHANGE to RMI once it's working
//
// final String urlStr = "service:jmx:jmxmp://" + mHost + ":" + mPort;
return conn;
}
}