2101 |
11 Oct 07 |
olle |
1 |
/* |
2101 |
11 Oct 07 |
olle |
$Id$ |
2101 |
11 Oct 07 |
olle |
3 |
|
2101 |
11 Oct 07 |
olle |
Copyright (C) 2006 Gregory Vincic, Olle Mansson |
2101 |
11 Oct 07 |
olle |
Copyright (C) 2007 Olle Mansson |
2101 |
11 Oct 07 |
olle |
6 |
|
2101 |
11 Oct 07 |
olle |
This file is part of Proteios. |
2101 |
11 Oct 07 |
olle |
Available at http://www.proteios.org/ |
2101 |
11 Oct 07 |
olle |
9 |
|
2101 |
11 Oct 07 |
olle |
Proteios is free software; you can redistribute it and/or modify it |
2101 |
11 Oct 07 |
olle |
under the terms of the GNU General Public License as published by |
2101 |
11 Oct 07 |
olle |
the Free Software Foundation; either version 2 of the License, or |
2101 |
11 Oct 07 |
olle |
(at your option) any later version. |
2101 |
11 Oct 07 |
olle |
14 |
|
2101 |
11 Oct 07 |
olle |
Proteios is distributed in the hope that it will be useful, but |
2101 |
11 Oct 07 |
olle |
WITHOUT ANY WARRANTY; without even the implied warranty of |
2101 |
11 Oct 07 |
olle |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
2101 |
11 Oct 07 |
olle |
General Public License for more details. |
2101 |
11 Oct 07 |
olle |
19 |
|
2101 |
11 Oct 07 |
olle |
You should have received a copy of the GNU General Public License |
2101 |
11 Oct 07 |
olle |
along with this program; if not, write to the Free Software |
2101 |
11 Oct 07 |
olle |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
2101 |
11 Oct 07 |
olle |
02111-1307, USA. |
2101 |
11 Oct 07 |
olle |
24 |
*/ |
2101 |
11 Oct 07 |
olle |
25 |
package utilities; |
2101 |
11 Oct 07 |
olle |
26 |
|
2101 |
11 Oct 07 |
olle |
//import org.proteios.PropertiesFile; |
2101 |
11 Oct 07 |
olle |
28 |
import org.proteios.core.Application; |
2101 |
11 Oct 07 |
olle |
29 |
import org.proteios.core.SessionControl; |
2101 |
11 Oct 07 |
olle |
30 |
import junit.extensions.TestSetup; |
2101 |
11 Oct 07 |
olle |
31 |
import junit.framework.Test; |
2101 |
11 Oct 07 |
olle |
32 |
|
2101 |
11 Oct 07 |
olle |
33 |
/** |
2101 |
11 Oct 07 |
olle |
* This class performs setup operations that only should be |
2101 |
11 Oct 07 |
olle |
* performed once for all tests in a test suite containing tests |
2101 |
11 Oct 07 |
olle |
* of Proteios items. Method Application.start() is called before |
2101 |
11 Oct 07 |
olle |
* the first test, and Application.stop() after the last test. |
2101 |
11 Oct 07 |
olle |
38 |
* |
2101 |
11 Oct 07 |
olle |
* @author Olle |
2101 |
11 Oct 07 |
olle |
* @version 2.0 |
2101 |
11 Oct 07 |
olle |
* @proteios.modified $Date$ |
2101 |
11 Oct 07 |
olle |
42 |
*/ |
2101 |
11 Oct 07 |
olle |
43 |
public class ApplicationSetup |
2101 |
11 Oct 07 |
olle |
44 |
extends TestSetup |
2101 |
11 Oct 07 |
olle |
45 |
{ |
2101 |
11 Oct 07 |
olle |
46 |
private SessionControl sc = null; |
2101 |
11 Oct 07 |
olle |
47 |
|
2101 |
11 Oct 07 |
olle |
48 |
public ApplicationSetup(Test suite) |
2101 |
11 Oct 07 |
olle |
49 |
{ |
2101 |
11 Oct 07 |
olle |
50 |
super(suite); |
2101 |
11 Oct 07 |
olle |
51 |
} |
2101 |
11 Oct 07 |
olle |
52 |
|
2101 |
11 Oct 07 |
olle |
53 |
protected void setUp() |
2101 |
11 Oct 07 |
olle |
54 |
throws Exception |
2101 |
11 Oct 07 |
olle |
55 |
{ |
2101 |
11 Oct 07 |
olle |
56 |
Application.start(); |
2101 |
11 Oct 07 |
olle |
57 |
SessionControl sc = null; |
2101 |
11 Oct 07 |
olle |
58 |
try |
2101 |
11 Oct 07 |
olle |
59 |
{ |
2101 |
11 Oct 07 |
olle |
60 |
sc = Application.getSessionControl("testSession", "test"); |
2101 |
11 Oct 07 |
olle |
61 |
} |
2101 |
11 Oct 07 |
olle |
62 |
catch (Exception e) |
2101 |
11 Oct 07 |
olle |
63 |
{ |
2101 |
11 Oct 07 |
olle |
//System.out.println("ApplicationSetup:: setUp: Exception when getting session control: " + e); |
2101 |
11 Oct 07 |
olle |
65 |
sc = Application.newSessionControl("org.proteios.default", "test", "testSession"); |
2101 |
11 Oct 07 |
olle |
66 |
} |
2101 |
11 Oct 07 |
olle |
67 |
setSessionControl(sc); |
2101 |
11 Oct 07 |
olle |
68 |
/* |
2101 |
11 Oct 07 |
olle |
* Optional - log in to Proteios |
2101 |
11 Oct 07 |
olle |
70 |
*/ |
2101 |
11 Oct 07 |
olle |
//PropertiesFile pf = new PropertiesFile(); |
2101 |
11 Oct 07 |
olle |
//sc.login(pf.getProperty("test.username"), pf.getProperty("test.password"), "", false); |
2101 |
11 Oct 07 |
olle |
73 |
} |
2101 |
11 Oct 07 |
olle |
74 |
|
2101 |
11 Oct 07 |
olle |
75 |
|
2101 |
11 Oct 07 |
olle |
76 |
protected void tearDown() |
2101 |
11 Oct 07 |
olle |
77 |
throws Exception |
2101 |
11 Oct 07 |
olle |
78 |
{ |
2101 |
11 Oct 07 |
olle |
79 |
Application.stop(); |
2101 |
11 Oct 07 |
olle |
//sc.logout(); |
2101 |
11 Oct 07 |
olle |
81 |
} |
2101 |
11 Oct 07 |
olle |
82 |
|
2101 |
11 Oct 07 |
olle |
83 |
/** |
2101 |
11 Oct 07 |
olle |
* Get the SessionControl object. |
2101 |
11 Oct 07 |
olle |
85 |
* |
2101 |
11 Oct 07 |
olle |
* @return the SessionControl object |
2101 |
11 Oct 07 |
olle |
87 |
*/ |
2101 |
11 Oct 07 |
olle |
88 |
public SessionControl getSessionControl() |
2101 |
11 Oct 07 |
olle |
89 |
{ |
2101 |
11 Oct 07 |
olle |
90 |
return this.sc; |
2101 |
11 Oct 07 |
olle |
91 |
} |
2101 |
11 Oct 07 |
olle |
92 |
|
2101 |
11 Oct 07 |
olle |
93 |
/** |
2101 |
11 Oct 07 |
olle |
* Set the SessionControl object. |
2101 |
11 Oct 07 |
olle |
95 |
* |
2101 |
11 Oct 07 |
olle |
* @param sc the SessionControl object to set. |
2101 |
11 Oct 07 |
olle |
97 |
*/ |
2101 |
11 Oct 07 |
olle |
98 |
public void setSessionControl(SessionControl sc) |
2101 |
11 Oct 07 |
olle |
99 |
{ |
2101 |
11 Oct 07 |
olle |
100 |
this.sc = sc; |
2101 |
11 Oct 07 |
olle |
101 |
} |
2101 |
11 Oct 07 |
olle |
102 |
} |