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