Commit 19e2fdde authored by Piotr Gawron's avatar Piotr Gawron
Browse files

all unit tests use test database (but they are still slow...)

parent e16e68e2
Pipeline #2371 failed with stage
in 36 seconds
......@@ -57,7 +57,7 @@ import lcsb.mapviewer.persist.dao.cache.CacheTypeDao;
@Transactional(value = "txManager")
@Rollback(false)
@ContextConfiguration(locations = { //
"/dataSource.xml", //
"/test-dataSource.xml", //
"/applicationContext-annotation.xml", //
"/applicationContext-persist.xml", //
"/test-applicationContext.xml", //
......
......@@ -95,6 +95,15 @@
<artifactId>commons-cli</artifactId>
<version>${commons-cli.version}</version>
</dependency>
<!-- Test db definition -->
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>persist</artifactId>
<version>1.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -20,7 +20,8 @@ import lcsb.mapviewer.persist.DbUtils;
import lcsb.mapviewer.persist.dao.map.ModelDao;
@Transactional(value = "txManager")
@ContextConfiguration(locations = { "/applicationContext-persist.xml", //
@ContextConfiguration(locations = { "/test-dataSource.xml", //
"/applicationContext-persist.xml", //
"/test-applicationContext.xml",//
})
@RunWith(SpringJUnit4ClassRunner.class)
......
......@@ -43,13 +43,13 @@ public class DataMining implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idDb", unique = true, nullable = false)
private Integer id;
private int id;
/**
* For which element this entry was created.
*/
@ManyToOne(optional = false)
private Element element;
private Element element;
/**
* List of the suggested connection.
......
......@@ -40,7 +40,7 @@ public class User implements Serializable, DbObject {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idDb", unique = true, nullable = false)
private Integer id;
private int id;
/**
* User login.
......
......@@ -38,13 +38,13 @@ public class UserAnnotationSchema implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* Default class logger.
*/
@Transient
private final transient Logger logger = Logger.getLogger(UserAnnotationSchema.class);
private final transient Logger logger = Logger.getLogger(UserAnnotationSchema.class);
/**
* Unique identifier in the database.
......@@ -52,7 +52,7 @@ public class UserAnnotationSchema implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idDb", unique = true, nullable = false)
private Integer id;
private int id;
/**
* {@link User} for which annotation schema is defined.
......@@ -63,18 +63,18 @@ public class UserAnnotationSchema implements Serializable {
/**
* Should the miriam types be validated?
*/
private Boolean validateMiriamTypes = false;
private Boolean validateMiriamTypes = false;
/**
* Should map be visualized as sbgn?
*/
private Boolean sbgnFormat = false;
private Boolean sbgnFormat = false;
/**
* Should the default view be network (if not then it will be pathways and
* compartments)?
*/
private Boolean networkLayoutAsDefault = false;
private Boolean networkLayoutAsDefault = false;
/**
* List of class annotators for specific object types.
......@@ -82,7 +82,7 @@ public class UserAnnotationSchema implements Serializable {
@Cascade({ CascadeType.ALL })
@OneToMany(mappedBy = "annotationSchema")
@OrderBy("id")
private List<UserClassAnnotators> classAnnotators = new ArrayList<UserClassAnnotators>();
private List<UserClassAnnotators> classAnnotators = new ArrayList<UserClassAnnotators>();
/**
* List of valid annotations for given object type.
......@@ -90,7 +90,7 @@ public class UserAnnotationSchema implements Serializable {
@Cascade({ CascadeType.ALL })
@OneToMany(mappedBy = "annotationSchema")
@OrderBy("id")
private List<UserClassValidAnnotations> classValidAnnotators = new ArrayList<UserClassValidAnnotations>();
private List<UserClassValidAnnotations> classValidAnnotators = new ArrayList<UserClassValidAnnotations>();
/**
* List of required annotations for given object type.
......@@ -321,7 +321,8 @@ public class UserAnnotationSchema implements Serializable {
}
/**
* @param sbgnFormat the sbgnFormat to set
* @param sbgnFormat
* the sbgnFormat to set
* @see #sbgnFormat
*/
public void setSbgnFormat(Boolean sbgnFormat) {
......@@ -337,7 +338,8 @@ public class UserAnnotationSchema implements Serializable {
}
/**
* @param networkLayoutAsDefault the networkLayoutAsDefault to set
* @param networkLayoutAsDefault
* the networkLayoutAsDefault to set
* @see #networkLayoutAsDefault
*/
public void setNetworkLayoutAsDefault(Boolean networkLayoutAsDefault) {
......
......@@ -32,7 +32,7 @@ public class UserClassAnnotators implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* Unique identifier in the database.
......@@ -40,19 +40,19 @@ public class UserClassAnnotators implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idDb", unique = true, nullable = false)
private Integer id;
private int id;
/**
* {@link UserAnnotationSchema} that defines which user is using this set of
* annotators.
*/
@ManyToOne
private UserAnnotationSchema annotationSchema;
private UserAnnotationSchema annotationSchema;
/**
* Class for which this set of annotators is defined.
*/
private String className;
private String className;
/**
* List of strings defining set of annotators (canonical class names).
......@@ -61,7 +61,7 @@ public class UserClassAnnotators implements Serializable {
@CollectionTable(name = "class_annotator_annotators_table", joinColumns = @JoinColumn(name = "class_annotator_iddb"))
@IndexColumn(name = "idx")
@Column(name = "annotator_name")
private List<String> annotators = new ArrayList<String>();
private List<String> annotators = new ArrayList<String>();
/**
* Default constructor.
......
......@@ -52,7 +52,7 @@ public class UserClassRequiredAnnotations implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idDb", unique = true, nullable = false)
private Integer id;
private int id;
/**
* {@link UserAnnotationSchema} in which this set of required
......
......@@ -35,7 +35,7 @@ public class UserClassValidAnnotations implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 1L;
/**
* Unique identifier in the database.
......@@ -43,19 +43,19 @@ public class UserClassValidAnnotations implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "idDb", unique = true, nullable = false)
private Integer id;
private int id;
/**
* {@link UserAnnotationSchema} in which this set of valid {@link MiriamType
* annotations} is used.
*/
@ManyToOne
private UserAnnotationSchema annotationSchema;
private UserAnnotationSchema annotationSchema;
/**
* Name of the class for which this set is defined.
*/
private String className;
private String className;
/**
* List of annotations that are valid.
......@@ -65,7 +65,7 @@ public class UserClassValidAnnotations implements Serializable {
@Column(name = "miriam_type_name", nullable = false)
@IndexColumn(name = "idx")
@Enumerated(EnumType.STRING)
private List<MiriamType> validMiriamTypes = new ArrayList<MiriamType>();
private List<MiriamType> validMiriamTypes = new ArrayList<MiriamType>();
/**
* Default constructor.
......
......@@ -56,7 +56,7 @@ import lcsb.mapviewer.persist.dao.user.UserDao;
@Transactional(value = "txManager")
@Rollback(true)
@ContextConfiguration(locations = { "/dataSource.xml", "/applicationContext-persist.xml", "/test-applicationContext.xml" })
@ContextConfiguration(locations = { "/test-dataSource.xml", "/applicationContext-persist.xml", "/test-applicationContext.xml" })
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class PersistTestFunctions {
private Logger logger = Logger.getLogger(PersistTestFunctions.class);
......
database.uri=jdbc:postgresql://localhost:5432/map_viewer_test
\ No newline at end of file
......@@ -12,14 +12,14 @@
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd">
<context:property-placeholder location="classpath:db.properties" />
<context:property-placeholder location="classpath:test-db.properties" />
<!-- Data Source Declaration -->
<bean id="DataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name="driverClassName" value="org.postgresql.Driver" />
<property name="url" value="${database.uri}" />
<property name="username" value="map_viewer" />
<property name="password" value="123qweasdzxc" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>
<jdbc:initialize-database data-source="DataSource">
......
database.uri=jdbc:postgresql://localhost:5432/map_viewer_test
database.username=map_viewer
database.password=123qweasdzxc
......@@ -83,6 +83,15 @@
<artifactId>spring-faces</artifactId>
<version>${springframework.webflow.version}</version>
</dependency>
<!-- Test db definition -->
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>persist</artifactId>
<version>1.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
......
......@@ -51,26 +51,27 @@ import org.xml.sax.SAXException;
@Transactional(value = "txManager")
@Rollback(false)
@ContextConfiguration(locations = { "/applicationContext-annotation.xml", //
@ContextConfiguration(locations = { "/test-dataSource.xml", //
"/applicationContext-annotation.xml", //
"/applicationContext-reactome.xml", //
"/applicationContext-persist.xml", //
"/test-applicationContext.xml", //
})
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class ReactomeTestFunctions {
private Logger logger = Logger.getLogger(ReactomeTestFunctions.class);
private Logger logger = Logger.getLogger(ReactomeTestFunctions.class);
@Autowired
protected PermanentDatabaseLevelCacheInterface cache;
protected PermanentDatabaseLevelCacheInterface cache;
@Autowired
protected DataSourceUpdater rc;
protected DataSourceUpdater rc;
@Autowired
protected DbUtils dbUtils;
protected DbUtils dbUtils;
@Autowired
protected ReactomeQueryUtil rcu;
protected ReactomeQueryUtil rcu;
protected String readFile(String file) throws IOException {
StringBuilder stringBuilder = new StringBuilder();
......@@ -132,7 +133,7 @@ public abstract class ReactomeTestFunctions {
return doc;
}
private static Map<String, Model> models = new HashMap<String, Model>();
private static Map<String, Model> models = new HashMap<String, Model>();
protected Model getModelForFile(String fileName, boolean fromCache) throws Exception {
if (!fromCache) {
......@@ -248,8 +249,9 @@ public abstract class ReactomeTestFunctions {
protected void waitForRefreshCacheQueueToEmpty() throws InterruptedException {
while (cache.refreshIsBusy()) {
logger.debug("Waiting for refresh queue to empty. " + cache.getRefreshPendingQueueSize() + " pending. " + cache.getRefreshExecutingTasksSize()
+ " tasks are executed.");
logger.debug(
"Waiting for refresh queue to empty. " + cache.getRefreshPendingQueueSize() + " pending. " + cache.getRefreshExecutingTasksSize()
+ " tasks are executed.");
Thread.sleep(100);
}
}
......
......@@ -74,6 +74,15 @@
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<!-- Test db definition -->
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>persist</artifactId>
<version>1.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
......@@ -63,8 +63,13 @@ import lcsb.mapviewer.services.view.AuthenticationToken;
@Transactional(value = "txManager")
@Rollback(true)
@ContextConfiguration(
locations = { "/applicationContext-persist.xml", "/applicationContext-annotation.xml", "/applicationContext-service.xml", "/applicationContext-rest.xml" })
@ContextConfiguration(locations = { "/test-dataSource.xml", //
"/applicationContext-persist.xml", //
"/applicationContext-annotation.xml", //
"/applicationContext-service.xml", //
"/applicationContext-rest.xml", //
})
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class RestTestFunctions {
private Logger logger = Logger.getLogger(RestTestFunctions.class);
......@@ -200,9 +205,9 @@ public abstract class RestTestFunctions {
complexParams.entry(entry4);
complexParams.entry(entry5);
Model model =parser.createModel(complexParams);
Model model = parser.createModel(complexParams);
model.setTileSize(256);
for (ModelSubmodelConnection connection: model.getSubmodelConnections()) {
for (ModelSubmodelConnection connection : model.getSubmodelConnections()) {
connection.getSubmodel().setTileSize(256);
}
model.setProject(new Project());
......
......@@ -126,6 +126,15 @@
<scope>test</scope>
</dependency>
<!-- Test db definition -->
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>persist</artifactId>
<version>1.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -83,7 +83,11 @@ import lcsb.mapviewer.services.search.db.drug.IDrugService;
@Transactional(value = "txManager")
@Rollback(false)
@ContextConfiguration(locations = { "/applicationContext-annotation.xml", "/applicationContext-persist.xml", "/applicationContext-service.xml" })
@ContextConfiguration(locations = { "/test-dataSource.xml", //
"/applicationContext-annotation.xml", //
"/applicationContext-persist.xml", //
"/applicationContext-service.xml",//
})
@RunWith(SpringJUnit4ClassRunner.class)
public abstract class ServiceTestFunctions {
private Logger logger = Logger.getLogger(ServiceTestFunctions.class);
......@@ -178,7 +182,7 @@ public abstract class ServiceTestFunctions {
protected ReactionDao reactionDao;
@Autowired
protected ElementDao aliasDao;
protected ElementDao aliasDao;
protected User user;
protected User user2 = null;
......
......@@ -194,6 +194,16 @@
<scope>test</scope>
</dependency>
<!-- Test db definition -->
<dependency>
<groupId>lcsb.mapviewer</groupId>
<artifactId>persist</artifactId>
<version>1.0</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment