PageRenderTime 18ms CodeModel.GetById 14ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/ws-tester-engine/src/main/scala/com/googlecode/wstester/config/TestConfig.scala

http://ws-tester.googlecode.com/
Scala | 47 lines | 38 code | 3 blank | 6 comment | 1 complexity | 3c8aa24f5e40f72c39c3ce1375d20dfa MD5 | raw file
 1package com.googlecode.wstester.config
 2
 3import java.io.File
 4import utils._
 5import xml.{Elem, XML}
 6import collection.mutable.ArrayBuffer
 7
 8/**
 9 * Created by IntelliJ IDEA.
10 * User: pablo
11 * Date: 2010-07-05
12 * Time: 09:11:47
13 */
14
15class TestConfig(val testDir: File) {
16  val confFile:File = new File(testDir.getName+"/test.xml");
17  var config: Elem = null;
18  var testType: TestType = null;
19  var requests: List[RequestConfig] = Nil;
20  var tmp = new ArrayBuffer[RequestConfig];
21  def parseConfig = {
22    if(confFile exists) {
23      config = XML.loadFile(confFile);
24      config\\"test" foreach {(test) =>
25        (test\\"test" \ "@type").text match {
26          case "simple" => testType = new Simple;
27          case "conversation" => testType = new Conversation;
28          case "oneshot" => testType = new OneShot;
29          case _ => throw new IllegalArgumentException("Unknown test type");
30        }
31      }
32      config\\"request" foreach {(request) =>
33        var requestConfig = new RequestConfig;
34        (request\ "@type").text match {
35          case "plainXML" => requestConfig.requestType = new PlainXML;
36          case "velocity" => requestConfig.requestType = new Velocity;
37          case _ => throw new IllegalArgumentException("Unknown request type");
38        }
39        requestConfig.requestFileName = request\\"requestMessageFile" text;
40        requestConfig.targetUrl = request\\"targetURL" text;
41        requestConfig.soapAction = request\\"soapAction" text;
42        tmp += requestConfig;
43        requests = tmp.toList;        
44      }
45    }
46  }
47}