001 /****************************************************************************** 002 * Copyright (C) MActor Developers. All rights reserved. * 003 * ---------------------------------------------------------------------------* 004 * This file is part of MActor. * 005 * * 006 * MActor is free software; you can redistribute it and/or modify * 007 * it under the terms of the GNU General Public License as published by * 008 * the Free Software Foundation; either version 2 of the License, or * 009 * (at your option) any later version. * 010 * * 011 * MActor is distributed in the hope that it will be useful, * 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 014 * GNU General Public License for more details. * 015 * * 016 * You should have received a copy of the GNU General Public License * 017 * along with MActor; if not, write to the Free Software * 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * 019 ******************************************************************************/ 020 package org.mactor.framework.spec; 021 022 import org.dom4j.Document; 023 import org.dom4j.Element; 024 import org.mactor.framework.MactorException; 025 026 public class TestRunSpec { 027 private String name; 028 private String dataSource; 029 private String test; 030 private int threadCount = 1; 031 public String getType() { 032 return "test_run"; 033 } 034 public static TestRunSpec loadFromFile(String name) throws MactorException { 035 return TestRunSpec.loadFromDocument(ProjectContext.getGlobalInstance().readFromFile(name, false), name); 036 } 037 public static TestRunSpec loadFromDocument(Document doc, String name) throws MactorException { 038 if (doc == null) 039 throw new MactorException("Invalid document: null"); 040 Element element = doc.getRootElement(); 041 if (element == null) 042 throw new MactorException("Invalid Test Run: null"); 043 TestRunSpec b = new TestRunSpec(); 044 b.name = name; 045 b.dataSource = element.attributeValue("data_source"); 046 b.test = element.attributeValue("test"); 047 if (element.attributeValue("test_threads") != null) 048 b.threadCount = Integer.parseInt(element.attributeValue("test_threads")); 049 return b; 050 } 051 public String getName() { 052 return name; 053 } 054 public String getDataSource() { 055 return dataSource; 056 } 057 public int getThreadCount() { 058 return threadCount; 059 } 060 public String getTest() { 061 return test; 062 } 063 }