<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="org.eclipse.cosmos.dr.tests.drs.service.handler.ServiceHandlerTestGenerator"%>
<%
/*******************************************************************************
 * Copyright (c) 2007 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
%>      
if(!dojo._hasResource["tests.org.eclipse.cosmos.tests.dr.drs.service.handler._base"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
dojo._hasResource["tests.org.eclipse.cosmos.tests.dr.drs.service.handler._base"] = true;
var testGlobal = this;
try{
	dojo.provide("tests.org.eclipse.cosmos.tests.dr.drs.service.handler._base");
}catch(e){ }

dojo.require("org.eclipse.cosmos.provisional.dr.ps.components.utility.common");

/******************************************************************************
 * This is convience method that will make two asynchronous calls
 * The first call will make a request to an outputter and recieve the json that it produces.
 * The second call will make a request to a control file that contains the expected json
 * that the outputter should produce.  When both calls are recieved the response
 * from each call is compared to each other.  If the responses are not equal
 * an exception is thrown otherwise the test passes.
 *******************************************************************************/
function _staticOutputterTest(testURL, controlURL, postData){
    var d = new doh.Deferred();
	var testObject = new org.eclipse.cosmos.provisional.dr.ps.components.utility.BasicQuery({queryHandler:testURL, postData:postData});
	var context = new org.eclipse.cosmos.provisional.dr.ps.components.utility.UIContext();                        
    context.submitQuery({queryObject:testObject, item:null, onItem:function(testContent){
            		var controlObject = new org.eclipse.cosmos.provisional.dr.ps.components.utility.BasicQuery({queryHandler:controlURL});
            		var defer = d; 
                    context.submitQuery({queryObject:controlObject, item:null, onItem:function(controlContent){
                        try{	
                        	doh.assertEqual(testContent, controlContent);
                            d.callback(true);
                        }catch(e){
                                d.errback(e);
                        }
                    }});
                    
		}});
    
    return d;
}

<%= ServiceHandlerTestGenerator.generateTests(getServletContext().getRealPath(""), getServletContext().getInitParameter("TESTCONTEXT"),getServletContext().getInitParameter("CONTROLCONTEXT")) %> 

}