260N/A/*
260N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
260N/A *
260N/A * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
260N/A *
260N/A * The contents of this file are subject to the terms of either the GNU
260N/A * General Public License Version 2 only ("GPL") or the Common Development
260N/A * and Distribution License("CDDL") (collectively, the "License"). You
260N/A * may not use this file except in compliance with the License. You can
260N/A * obtain a copy of the License at
260N/A * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
260N/A * or packager/legal/LICENSE.txt. See the License for the specific
260N/A * language governing permissions and limitations under the License.
260N/A *
260N/A * When distributing the software, include this License Header Notice in each
260N/A * file and include the License file at packager/legal/LICENSE.txt.
260N/A *
260N/A * GPL Classpath Exception:
260N/A * Oracle designates this particular file as subject to the "Classpath"
260N/A * exception as provided by Oracle in the GPL Version 2 section of the License
5680N/A * file that accompanied this code.
5680N/A *
5575N/A * Modifications:
260N/A * If applicable, add the following below the License Header, with the fields
260N/A * enclosed by brackets [] replaced by your own identifying information:
5795N/A * "Portions Copyright [year] [name of copyright owner]"
5795N/A *
5795N/A * Contributor(s):
5795N/A * If you wish your version of this file to be governed by only the CDDL or
260N/A * only the GPL Version 2, indicate your decision by adding "[Contributor]
5795N/A * elects to include this software in this distribution under the [CDDL or GPL
5795N/A * Version 2] license." If you don't indicate a single choice of license, a
5795N/A * recipient has the option to distribute your version of this file under
5795N/A * either the CDDL, the GPL Version 2 or to extend the choice of license to
5795N/A * its licensees as provided above. However, if you add GPL Version 2 code
5795N/A * and therefore, elected the GPL Version 2 license, then the option applies
5795N/A * only if the new code is made subject to such option by the copyright
5795N/A * holder.
5795N/A */
5795N/A
5795N/Apackage test;
5795N/Aimport org.testng.annotations.*;
5795N/Aimport org.testng.Assert;
5795N/A
5795N/Aimport java.io.*;
5795N/Aimport java.net.*;
260N/Aimport java.util.*;
260N/A
260N/A/**
260N/A * Simple TestNG client for basic WAR containing one JSP,one Servlet and one static
260N/A *HTML resource.Each resources (HTML,JSP,Servlet) is invoked as a separate test.
5795N/A *
5795N/A */
260N/Apublic class CmpRosterTestNG {
5795N/A
5795N/A private static final String TEST_NAME = "Roster";
2980N/A
5795N/A private String strContextRoot="roster";
5795N/A
3558N/A static String result = "";
5795N/A String host=System.getProperty("http.host");
5795N/A String port=System.getProperty("http.port");
4744N/A
5795N/A /*
5795N/A *If two asserts are mentioned in one method, then last assert is taken in
4089N/A *to account.
5795N/A *Each method can act as one test within one test suite
4089N/A */
5795N/A
260N/A
5795N/A @Test(groups ={ "pulse"} ) // test method
5795N/A public void test() throws Exception{
1413N/A
260N/A try{
260N/A
260N/A String testurl = "http://" + host + ":" + port + "/"+
260N/A strContextRoot + "/" + TEST_NAME;
260N/A
260N/A URL url = new URL(testurl);
260N/A //echo("Connecting to: " + url.toString());
260N/A HttpURLConnection conn = (HttpURLConnection) url.openConnection();
260N/A conn.connect();
260N/A int responseCode = conn.getResponseCode();
1413N/A
260N/A InputStream is = conn.getInputStream();
260N/A BufferedReader input = new BufferedReader(new InputStreamReader(is));
260N/A
260N/A String line = null;
1780N/A boolean result=false;
1780N/A String testLine = null;
1780N/A String EXPECTED_RESPONSE ="ROSTER-FINISHED-OK";
260N/A while ((line = input.readLine()) != null) {
260N/A // echo(line);
260N/A if(line.indexOf(EXPECTED_RESPONSE)!=-1){
260N/A testLine = line;
260N/A //echo(testLine);
260N/A result=true;
1413N/A break;
260N/A }
260N/A }
260N/A
260N/A Assert.assertEquals(result, true,"Unexpected Results");
260N/A
260N/A }catch(Exception e){
260N/A e.printStackTrace();
3558N/A throw new Exception(e);
7122N/A }
3558N/A
3864N/A }
3864N/A
3864N/A public static void echo(String msg) {
3864N/A System.out.println(msg);
3558N/A }
260N/A
4089N/A}
4089N/A