Commit 2c79eb6f authored by gmantele's avatar gmantele
Browse files

[ALL] Restore some sleeping JUnit tests + Allow a reset of custom types

in DBType.DBDatatype (for UNKNOWN and UNKNOWN_NUMERIC). This reset is performed
after each JUnit setting a special custom value (otherwise it prevents other
JUnit to run correctly)
parent 2a136e65
Loading
Loading
Loading
Loading
+13 −8
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ package adql.db;
 * It is used to set the attribute type/datatype of this class.</p>
 * 
 * @author Gr&eacute;gory Mantelet (ARI)
 * @version 1.4 (03/2016)
 * @version 1.4 (07/2016)
 * @since 1.3
 */
public class DBType {
@@ -40,7 +40,7 @@ public class DBType {
	 * List of all datatypes declared in the IVOA recommendation of TAP (in the section UPLOAD).
	 * 
	 * @author Gr&eacute;gory Mantelet (ARI)
	 * @version 1.4 (03/2016)
	 * @version 1.4 (07/2016)
	 * @since 1.3
	 */
	public static enum DBDatatype{
@@ -70,8 +70,9 @@ public class DBType {
		 * <b>ONLY FOR {@link #UNKNOWN} and {@link #UNKNOWN_NUMERIC} {@link DBDatatype}s</b>.</p>
		 * 
		 * <p><i><b>Important:</b>
		 * 	If this {@link DBDatatype} is not {@link #UNKNOWN} or {@link #UNKNOWN_NUMERIC} or
		 * 	if the given name is NULL or empty, this function has no effect.
		 * 	If this {@link DBDatatype} is not {@link #UNKNOWN} or {@link #UNKNOWN_NUMERIC} this function has no effect.
		 * 	But if the given name is NULL or empty, no custom type will be set ; instead the default value (i.e. name of
		 * 	the unknown enum item) will be returned.
		 * </i></p>
		 * 
		 * @param typeName	User type name.
@@ -79,8 +80,12 @@ public class DBType {
		 * @since 1.4
		 */
		public void setCustomType(final String typeName){
			if ((this == UNKNOWN || this == UNKNOWN_NUMERIC) && typeName != null && typeName.trim().length() > 0)
			if ((this == UNKNOWN || this == UNKNOWN_NUMERIC)){
				if (typeName != null && typeName.trim().length() > 0)
					strExp = "?" + typeName.trim() + "?";
				else
					strExp = this.name();
			}
		}
	}

+6 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import org.junit.AfterClass;
import org.junit.Test;

import adql.db.DBType.DBDatatype;
@@ -20,6 +21,11 @@ import adql.query.operand.function.geometry.PointFunction;

public class TestFunctionDef {

	@AfterClass
	public static void tearDownAfterClass() throws Exception{
		DBType.DBDatatype.UNKNOWN.setCustomType(null);
	}

	@Test
	public void testIsString(){
		for(DBDatatype type : DBDatatype.values()){
+4 −2
Original line number Diff line number Diff line
@@ -26,13 +26,15 @@ import adql.db.DefaultDBTable;
import adql.db.FunctionDef;
import adql.query.ADQLQuery;

public class UnknownTypes {
public class TestUnknownTypes {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception{}

	@AfterClass
	public static void tearDownAfterClass() throws Exception{}
	public static void tearDownAfterClass() throws Exception{
		DBType.DBDatatype.UNKNOWN.setCustomType(null);
	}

	@Before
	public void setUp() throws Exception{}
+4 −4
Original line number Diff line number Diff line
@@ -21,13 +21,13 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import tap.TAPException;
import tap.metadata.TableSetParser.ForeignKey;
import adql.db.DBType;
import adql.db.DBType.DBDatatype;
import tap.TAPException;
import tap.metadata.TableSetParser.ForeignKey;

@SuppressWarnings("deprecation")
public class TableSetParserTest {
public class TestTableSetParser {

	private static TableSetParser parser = null;
	private static XMLInputFactory factory = null;
@@ -903,7 +903,7 @@ public class TableSetParserTest {
			col = parser.parseColumn(reader);
			assertEquals("col1", col.getADQLName());
			assertNull(col.getDescription());
			assertEquals(DBDatatype.VARCHAR, col.getDatatype().type);
			assertEquals(DBDatatype.UNKNOWN, col.getDatatype().type);
			assertEquals(-1, col.getDatatype().length);
			assertNull(col.getUtype());
			assertNull(col.getUcd());
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ import javax.servlet.http.Part;
import org.junit.Before;
import org.junit.Test;

public class UWSUrlTest {
public class TestUWSUrl {

	public static final class TestHttpServletRequest implements HttpServletRequest {