forked from loafle/openapi-generator-original
Completed changes related running test scripts
This commit is contained in:
@@ -40,13 +40,15 @@ public class JavaLibCodeGen extends LibraryCodeGenerator {
|
||||
JavaLibCodeGen codeGenerator = new JavaLibCodeGen(configPath);
|
||||
codeGenerator.generateCode();
|
||||
}
|
||||
if(args.length == 6) {
|
||||
if(args.length == 4) {
|
||||
String apiServerURL = args[0];
|
||||
String apiKey = args[1];
|
||||
String modelPackageName = args[2];
|
||||
String apiPackageName = args[3];
|
||||
String classOutputDir = args[4];
|
||||
String libraryHome = args[5];
|
||||
String packageName = args[2];
|
||||
String libraryHome = args[3];
|
||||
|
||||
String modelPackageName = packageName+".model";
|
||||
String apiPackageName = packageName+".api";
|
||||
String classOutputDir = libraryHome + "/src/main/java/" + packageName.replace(".","/");
|
||||
JavaLibCodeGen codeGenerator = new JavaLibCodeGen(apiServerURL, apiKey, modelPackageName,
|
||||
apiPackageName, classOutputDir, libraryHome);
|
||||
codeGenerator.generateCode();
|
||||
|
||||
@@ -80,7 +80,8 @@ public class APITestRunner {
|
||||
* Arg[4] --> test data class name (class to which test data file will be deserialized)
|
||||
* Arg[5] --> package where API classes are available
|
||||
* Arg[6] --> Language to execute test cases
|
||||
* Arg[7] --> Optional test cases id. provide this if you need to execute only one test case
|
||||
* Arg[7] --> Library location
|
||||
* Arg[8] --> Optional test cases id. provide this if you need to execute only one test case
|
||||
*
|
||||
* @param args
|
||||
* @throws Exception
|
||||
@@ -93,17 +94,19 @@ public class APITestRunner {
|
||||
String testDataLocation = args[3];
|
||||
String testDataClass = args[4];
|
||||
String apiPackageName = args[5];
|
||||
String language = args[6];
|
||||
String libraryLocation = args[6];
|
||||
String language = args[7];
|
||||
|
||||
String suiteId = "0";
|
||||
if(args.length > 7){
|
||||
suiteId = args[7];
|
||||
if(args.length > 8){
|
||||
suiteId = args[8];
|
||||
}
|
||||
|
||||
ApiKeyAuthTokenBasedSecurityHandler securityHandler = new ApiKeyAuthTokenBasedSecurityHandler(apiKey, "");
|
||||
APIInvoker.initialize(securityHandler, apiServer, true);
|
||||
APITestRunner runner = new APITestRunner();
|
||||
runner.initialize(testScriptLocation, testDataLocation, testDataClass);
|
||||
runner.runTests(apiServer, apiPackageName, runner.getTestPackage(), language, new Integer(suiteId), apiPackageName, securityHandler);
|
||||
runner.runTests(apiServer, apiPackageName, runner.getTestPackage(), language, new Integer(suiteId), apiPackageName, securityHandler, libraryLocation);
|
||||
}
|
||||
|
||||
public void initialize(String testScriptLocation, String testDataLocation, String testDataClass) throws Exception {
|
||||
@@ -152,7 +155,8 @@ public class APITestRunner {
|
||||
* @param testPackage
|
||||
*/
|
||||
private void runTests(String apiServer, String apiPackageName, TestPackage testPackage, String language, int suiteId,
|
||||
String libraryPackageName, ApiKeyAuthTokenBasedSecurityHandler securityHandler) throws Exception {
|
||||
String libraryPackageName, ApiKeyAuthTokenBasedSecurityHandler securityHandler,
|
||||
String libraryLocation) throws Exception {
|
||||
/**
|
||||
* Logic:
|
||||
*
|
||||
@@ -231,7 +235,7 @@ public class APITestRunner {
|
||||
String[] externalCommand = constructExternalCommand(apiServer, apiPackageName,
|
||||
securityHandler.getApiKey(), authToken,
|
||||
resource.getPath(), resource.getHttpMethod(), resource.getSuggestedMethodName(),
|
||||
queryPathParameters.toString(), postData, language);
|
||||
queryPathParameters.toString(), postData, language, libraryLocation);
|
||||
//print the command
|
||||
System.out.println("Test Case :" + testCasePath);
|
||||
for(String arg : externalCommand){
|
||||
@@ -502,11 +506,12 @@ public class APITestRunner {
|
||||
*/
|
||||
private String[] constructExternalCommand(String apiServer, String apiPackageName, String apiKey, String authToken,
|
||||
String resource, String httpMethod, String suggestedMethodName, String queryAndPathParams,
|
||||
String postData, String language) {
|
||||
String postData, String language, String libraryLocation) {
|
||||
List<String> command = new ArrayList<String>();
|
||||
if(language.equals(JAVA)){
|
||||
command.add("./bin/runjava.sh");
|
||||
command.add("./bin/runjavaTestCase.sh");
|
||||
command.add("com.wordnik.swagger.testframework.JavaTestCaseExecutor");
|
||||
command.add( libraryLocation );
|
||||
}else if (language.equals(PYTHON)){
|
||||
command.add("../python/runtest.py ");
|
||||
}else if (language.equals(ANDROID)){
|
||||
|
||||
@@ -38,24 +38,24 @@ public class JavaTestCaseExecutor {
|
||||
|
||||
|
||||
JavaTestCaseExecutor runner = new JavaTestCaseExecutor();
|
||||
String apiServer = args[0];
|
||||
String servicePackageName = args[1];
|
||||
String apiKey = args[2];
|
||||
String authToken = args[3];
|
||||
String resource = args[4];
|
||||
String httpMethod = args[5];
|
||||
String suggestedMethodName = args[6];
|
||||
String apiServer = args[1];
|
||||
String servicePackageName = args[2];
|
||||
String apiKey = args[3];
|
||||
String authToken = args[4];
|
||||
String resource = args[5];
|
||||
String httpMethod = args[6];
|
||||
String suggestedMethodName = args[7];
|
||||
Map<String, String> queryAndPathParameters = new HashMap<String, String>();
|
||||
String postData = null;
|
||||
if(args.length > 7 && args[7].length() > 0){
|
||||
String[] qpTuple = args[7].split("~");
|
||||
if(args.length > 8 && args[8].length() > 0){
|
||||
String[] qpTuple = args[8].split("~");
|
||||
for(String tuple: qpTuple){
|
||||
String[] nameValue = tuple.split("=");
|
||||
queryAndPathParameters.put(nameValue[0], nameValue[1]);
|
||||
}
|
||||
}
|
||||
if(args.length > 8 ){
|
||||
postData = args[8];
|
||||
if(args.length > 9 ){
|
||||
postData = args[9];
|
||||
}
|
||||
queryAndPathParameters.put("authToken", authToken);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user