Revision 87f35b2d
Added by Andreas Kohlbecker over 6 years ago
src/test/java/eu/etaxonomy/cdm/vaadin/CdmVaadinBaseTest.java | ||
---|---|---|
1 | 1 |
package eu.etaxonomy.cdm.vaadin; |
2 | 2 |
|
3 |
import java.sql.SQLException; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.List; |
|
6 |
|
|
3 | 7 |
import javax.servlet.ServletContextEvent; |
4 | 8 |
import javax.servlet.ServletContextListener; |
5 | 9 |
import javax.servlet.ServletException; |
6 | 10 |
|
7 | 11 |
import org.easymock.EasyMock; |
12 |
import org.h2.tools.Server; |
|
8 | 13 |
import org.junit.Assert; |
14 |
import org.junit.Before; |
|
9 | 15 |
import org.junit.BeforeClass; |
10 |
import org.junit.Ignore; |
|
11 | 16 |
import org.junit.runner.RunWith; |
12 | 17 |
import org.springframework.mock.web.MockServletConfig; |
13 | 18 |
import org.springframework.mock.web.MockServletContext; |
14 | 19 |
import org.springframework.web.context.ContextLoaderListener; |
15 |
import org.unitils.UnitilsJUnit4; |
|
20 |
import org.unitils.UnitilsJUnit4TestClassRunner;
|
|
16 | 21 |
import org.unitils.database.DatabaseUnitils; |
17 | 22 |
import org.unitils.database.annotations.Transactional; |
18 | 23 |
import org.unitils.database.util.TransactionMode; |
... | ... | |
26 | 31 |
import com.vaadin.server.VaadinSession; |
27 | 32 |
|
28 | 33 |
import eu.etaxonomy.cdm.vaadin.util.CdmSQLStringDecorator; |
29 |
import unitils.AlternativeUnitilsJUnit4TestClassRunner; |
|
30 | 34 |
|
31 |
@Ignore |
|
32 |
@RunWith(AlternativeUnitilsJUnit4TestClassRunner.class)
|
|
35 |
|
|
36 |
@RunWith(UnitilsJUnit4TestClassRunner.class) |
|
33 | 37 |
@Transactional(TransactionMode.DISABLED) |
34 |
public class CdmVaadinBaseTest extends UnitilsJUnit4 {
|
|
38 |
public abstract class CdmVaadinBaseTest {
|
|
35 | 39 |
|
36 | 40 |
private static MockServletContext servletContext; |
37 | 41 |
private static VaadinServlet vaadinServlet; |
... | ... | |
39 | 43 |
private static VaadinSession vaadinSession; |
40 | 44 |
private static boolean isVaadinServletEnvCreated = false; |
41 | 45 |
|
46 |
private static final String PROPERTY_H2_SERVER = "h2Server"; |
|
42 | 47 |
|
43 | 48 |
@BeforeClass |
44 | 49 |
public static void setup() { |
... | ... | |
62 | 67 |
Assert.assertEquals(vaadinService, VaadinService.getCurrent()); |
63 | 68 |
} |
64 | 69 |
|
70 |
@Before |
|
71 |
public void startH2Server() throws Exception { |
|
72 |
|
|
73 |
if(System.getProperty(PROPERTY_H2_SERVER) != null){ |
|
74 |
try { |
|
75 |
List<String> args = new ArrayList<String>(); |
|
76 |
try { |
|
77 |
Integer port = Integer.parseInt(System.getProperty(PROPERTY_H2_SERVER)); |
|
78 |
args.add("-webPort"); |
|
79 |
args.add(port.toString()); |
|
80 |
} catch (Exception e) { |
|
81 |
// will start at port 8082 by default |
|
82 |
} |
|
83 |
Server.createWebServer(args.toArray(new String[]{})).start(); |
|
84 |
} catch (SQLException e) { |
|
85 |
e.printStackTrace(); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
65 | 90 |
|
66 | 91 |
public static void createNewServletEnvironment() { |
67 | 92 |
servletContext = new MockServletContext("/webapp"); |
Also available in: Unified diff
fxing problems in testsetup: