Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Ground Controller Lvl 1
Message 1 of 1

Test class seems to be running forever

Hello. I have a pretty severe issue when i try to build a repository I have just forked: https://github.com/eirikh1996/SimpleDataLib

 

When building it with mvn install, it runs several tests before it is supposed to build a jar.

 

However, one of the test classes, named TestWriteAndRead, starts, but apparently never ends, meaning that a test that should take a few seconds instead takes forever.

 

Here is the troublesome test class:

package regalowl.simpledatalib.sql;

import static org.junit.Assert.*;

import org.junit.Test;

import regalowl.simpledatalib.SimpleDataLib;
import regalowl.simpledatalib.TestLogger;
import regalowl.simpledatalib.sql.Field;
import regalowl.simpledatalib.sql.FieldType;
import regalowl.simpledatalib.sql.SQLManager;
import regalowl.simpledatalib.sql.Table;

public class TestWriteAndRead {
	@Test
	public void testCreateShutdownAndLoad() {
		SimpleDataLib sdl = new SimpleDataLib("test");
		sdl.initialize();
		sdl.setDebug(true);
		new TestLogger(sdl);
		SQLManager sm = sdl.getSQLManager();
		sm.setWriteTaskInterval(1L);
		sm.createDatabase();
		
		SQLWrite sw = sm.getSQLWrite();
		Table t = sm.addTable("hyperconomy_object_data");
		Field f = t.addField("ID", FieldType.INTEGER);f.setPrimaryKey();f.setAutoIncrement();
		f = t.addField("DATA", FieldType.TEXT);
		sm.saveTables();
		sw.writeSync(true);
		String statement = "DELETE FROM hyperconomy_object_data";
		sw.addToQueue(statement);
		sw.writeSyncQueue();
		sw.writeSync(false);
		
		
		statement = "INSERT INTO hyperconomy_object_data (ID, DATA) VALUES ('" + 1 + "', ?)";
		WriteStatement ws = new WriteStatement(statement, sdl);
		ws.addParameter("test");
		sw.addToQueue(ws);
		
		
		sm.shutDown();
		
		
		sdl.initialize();
		sdl.setDebug(true);
		new TestLogger(sdl);
		sm = sdl.getSQLManager();
		sm.createDatabase();
		SQLRead sr = sm.getSQLRead();
		QueryResult qr  = sr.select("SELECT * FROM hyperconomy_object_data WHERE ID = '1'");
		qr.next();
		assertTrue(qr.getString("DATA").equals("test"));
	}
}

Here is the project's POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>regalowl.simpledatalib</groupId>
  <artifactId>simpledatalib</artifactId>
  <version>0.1.088-SNAPSHOT</version>
	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-shade-plugin</artifactId>
				<version>3.1.0</version>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>shade</goal>
						</goals>
						<configuration>
							<filters>
								<filter>
									<artifact>*:*</artifact>
									<excludes>
										<exclude>META-INF/*.SF</exclude>
										<exclude>META-INF/*.DSA</exclude>
										<exclude>META-INF/*.RSA</exclude>
									</excludes>
								</filter>
							</filters>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
		        <groupId>org.apache.maven.plugins</groupId>
		        <artifactId>maven-compiler-plugin</artifactId>
		        <version>3.7.0</version>
		        <configuration>
		          <source>1.6</source>
		          <target>1.6</target>
		        </configuration>
	      	</plugin>
		</plugins>
	</build>
  <properties>
  	<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  	<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <name>SimpleDataLib</name>
  <description>SimpleDataLib provides fast and easy to use database access, YAML access, CSV access, serialization, and error logging.  SimpleDataLib supports SQLite and MySQL for database access.  Database writes can be queued and written asynchronously in transactions to prevent slowing of the main thread.  Fields can be added, removed, and changed easily for both MySQL and SQLite.</description>
  	<repositories>
		<repository>
		<id>Sonatype-public</id>
		<name>SnakeYAML repository</name>
		<url>http://oss.sonatype.org/content/groups/public/</url>
  		</repository>
	</repositories>
  <dependencies>
  	<dependency>
  		<groupId>org.xerial</groupId>
  		<artifactId>sqlite-jdbc</artifactId>
  		<version>3.20.0</version>
  		<scope>provided</scope>
  	</dependency>
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.44</version>
		<scope>provided</scope>
	</dependency>
  	<dependency>
  		<groupId>net.sf.opencsv</groupId>
  		<artifactId>opencsv</artifactId>
  		<version>2.3</version>
  		<scope>provided</scope>
  	</dependency>
  	<dependency>
  		<groupId>org.yaml</groupId>
  		<artifactId>snakeyaml</artifactId>
  		<version>1.18</version>
  		<scope>provided</scope>
  	</dependency>
	<dependency>
		<groupId>junit</groupId>
		<artifactId>junit</artifactId>
		<version>4.12</version>
		<scope>test</scope>
	</dependency>
  </dependencies>
</project>

What exactly is causing this test to take so long time? Any help will be appreciated