diff --git a/build/resources/main/excel2db.properties b/build/resources/main/excel2db.properties index 244c517..a045761 100644 --- a/build/resources/main/excel2db.properties +++ b/build/resources/main/excel2db.properties @@ -1,5 +1,5 @@ # names of input tables -input.files=test-input.xls,test-input1.xls +input.files=test.xls # db implementation classes diff --git a/common/src/main/java/com/ge/mdm/tools/common/ApplicationException.java b/common/src/main/java/com/ge/mdm/tools/common/ApplicationException.java deleted file mode 100644 index 35b636e..0000000 --- a/common/src/main/java/com/ge/mdm/tools/common/ApplicationException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.ge.mdm.tools.common; - -public class ApplicationException extends Exception { - static final long serialVersionUID = 1L; - - public ApplicationException() { - super(); - } - - public ApplicationException(String message) { - super(message); - } - - public ApplicationException(String message, Throwable cause) { - super(message, cause); - } - - public ApplicationException(Throwable cause) { - super(cause); - } -} \ No newline at end of file diff --git a/common/src/main/java/com/ge/mdm/tools/common/AuthOutInterceptor.java b/common/src/main/java/com/ge/mdm/tools/common/AuthOutInterceptor.java deleted file mode 100644 index 5f5d1c2..0000000 --- a/common/src/main/java/com/ge/mdm/tools/common/AuthOutInterceptor.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.ge.mdm.tools.common; - -import org.apache.cxf.interceptor.Fault; -import org.apache.cxf.interceptor.LoggingMessage; -import org.apache.cxf.message.Message; -import org.apache.cxf.phase.AbstractPhaseInterceptor; -import org.apache.cxf.phase.Phase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; - -public class AuthOutInterceptor extends AbstractPhaseInterceptor { - - private static final Logger logger = LoggerFactory.getLogger(AuthOutInterceptor.class); - - private static final String DEFAULT_USERNAME_HEADER_NAME = "USERNAME"; - private static final String DEFAULT_PASSWORD_HEADER_NAME = "PASSWORD"; - - private String username; - private String password; - private String usernameHeaderName = DEFAULT_USERNAME_HEADER_NAME; - private String passwordHeaderName = DEFAULT_PASSWORD_HEADER_NAME; - - - public AuthOutInterceptor() { - super(Phase.PRE_PROTOCOL); - } - - @Override - public void handleMessage(Message message) throws Fault { - Map> headers = new HashMap<>(); - headers.put(usernameHeaderName, Collections.singletonList(username)); - headers.put(passwordHeaderName, Collections.singletonList(password)); - message.put(Message.PROTOCOL_HEADERS, headers); - } - - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getUsernameHeaderName() { - return usernameHeaderName; - } - - public void setUsernameHeaderName(String usernameHeaderName) { - this.usernameHeaderName = usernameHeaderName; - } - - public String getPasswordHeaderName() { - return passwordHeaderName; - } - - public void setPasswordHeaderName(String passwordHeaderName) { - this.passwordHeaderName = passwordHeaderName; - } -} - diff --git a/common/src/main/java/com/ge/mdm/tools/common/SheetEntityManager.java b/common/src/main/java/com/ge/mdm/tools/common/SheetEntityManager.java deleted file mode 100644 index efc7827..0000000 --- a/common/src/main/java/com/ge/mdm/tools/common/SheetEntityManager.java +++ /dev/null @@ -1,677 +0,0 @@ -package com.ge.mdm.tools.common; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.DateUtil; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.util.NumberToTextConverter; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.persistence.*; -import java.beans.BeanInfo; -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.lang.annotation.Annotation; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.*; - -/** - * Read Excel files in JPA way, considering sheet as a simple database table with columns and rows. - * First row is assumed to be header containing column names, which could be mapped to JPA @Entity. - * - */ -public class SheetEntityManager implements EntityManager { - - private static final Logger logger = LoggerFactory.getLogger(SheetEntityManager.class); - - private Sheet sheet; - - /* - * Mappings between header name and its column index - */ - public Map header; - - - public SheetEntityManager(Sheet sheet) { - requireNotNull(sheet); - this.sheet = sheet; - this.header = readSheetHeader(sheet); - } - - - /* - * Insert a row into spread sheet, determined by entity's PK (row number). - * This method assumes there's no row at such position yet. - */ - @Override - public synchronized void persist(Object entity) { - int id = id(entity); - Row row = sheet.createRow(id); // overrides old row if it's exists - writeRow(entity, row, true); - } - - /* - * Update a row of a spread sheet, determined by entity's PK (row number). - * Overwrited only cells whcih have different value than in entity object. - */ - @Override - public synchronized T merge(T entity) { - int id = id(entity); - Row row = sheet.getRow(id); - writeRow(entity, row, false); - return entity; - } - - /* - * Removes a row at position determined by by entity's PK (row number) - * from a sheet. - */ - @Override - public synchronized void remove(Object entity) { - int id = id(entity); - - Row row = sheet.getRow(id); - if(row != null) { - sheet.removeRow(row); - } - } - - - @Override - public T find(Class entityClass, Object primaryKey) { - - if(primaryKey instanceof Integer) { - int id = (Integer) primaryKey; - Row row = sheet.getRow(id); - return readRow(entityClass, row); - } else { - throw new IllegalArgumentException("The primary key must be an of integer type"); - } - } - - @Override - public T getReference(Class entityClass, Object primaryKey) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void flush() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void setFlushMode(FlushModeType flushMode) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public FlushModeType getFlushMode() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void lock(Object entity, LockModeType lockMode) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void refresh(Object entity) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void clear() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public boolean contains(Object entity) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public Query createQuery(String qlString) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public Query createNamedQuery(String name) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public Query createNativeQuery(String sqlString) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public Query createNativeQuery(String sqlString, Class resultClass) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public Query createNativeQuery(String sqlString, String resultSetMapping) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void joinTransaction() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public Object getDelegate() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void close() { - // no-op - } - - @Override - public boolean isOpen() { - return true; - } - - @Override - public EntityTransaction getTransaction() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - - - public synchronized List findAll(Class entityClass) { - List list = new ArrayList(); - Iterator it = sheet.rowIterator(); - - if(it.hasNext()) { - it.next(); // skip header - } - - while(it.hasNext()) { - Row row = it.next(); - T entity = readRow(entityClass, row); - if(entity != null) { - list.add(entity); - } - } - return Collections.unmodifiableList(list); - } - - - //!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - private static Map readSheetHeader(Sheet sheet) { - // first row is always considered as header - Row firstRow = sheet.getRow(sheet.getFirstRowNum()); - if(firstRow == null) { - throw new IllegalArgumentException("Sheet is empty"); - } - - Map header = new LinkedHashMap(); - - Iterator it = firstRow.cellIterator(); - - while(it.hasNext()) { - Cell cell = it.next(); - - if(cell.getCellType() == Cell.CELL_TYPE_STRING) { - String name = cell.getStringCellValue(); - if(! name.equals("")) { - name = name.toUpperCase(); - if(! header.containsKey(name)) { - header.put(name, cell.getColumnIndex()); - } else { - logger.warn("Ignoring duplicate header name {} at ({}, {})", - name, cell.getRowIndex(), cell.getColumnIndex()); - } - } - } else { - logger.warn("Ignoring header cell with non-string type {} at ({}, {})", - cell.getCellType(), cell.getRowIndex(), cell.getColumnIndex()); - } - - } - return header; - } - - - private static EntityMetadata getEntityMetadata(Class entityClass) { - try { - return EntityMetadata.get(entityClass); - } catch (IntrospectionException e) { - throw new IllegalArgumentException("Unable to read metadata from " + entityClass, e); - } - } - - private static T getInstance(Class entityClass) { - try { - return entityClass.newInstance(); - } catch (InstantiationException e) { - throw new IllegalArgumentException("Failed create an instance of " + entityClass, e); - } catch (IllegalAccessException e) { - throw new IllegalArgumentException("Failed create an instance of " + entityClass, e); - } - } - - private static Object invokeMethod(Method m, Object entity, Object ... args) { - try { - return m.invoke(entity, args); - } catch(InvocationTargetException e) { - throw new IllegalArgumentException("Failed to call " + m, e); - } catch(IllegalAccessException e) { - throw new IllegalArgumentException("Failed to call " + m, e); - } - } - - - private T readRow(Class entityClass, Row row) { - T entity = getInstance(entityClass); - EntityMetadata md = getEntityMetadata(entityClass); - - for(Map.Entry entry: md.getColumnMetadataMap().entrySet()) { - String name = entry.getKey(); - if(! header.containsKey(name)) { - continue; - } - int columnIndex = header.get(name); - - EntityMetadata.ColumnMetadata cmd = entry.getValue(); - String cellValue = getCellValueAsString(row.getCell(columnIndex)); - if(! cmd.isNullable() && (cellValue == null || cellValue.equals(""))) { - // non-nullable field not set, consider row as empty - return null; - } - - Class fieldType = cmd.getEntityField().getType(); - if(cellValue != null) { - invokeMethod(cmd.getEntityFieldSetter(), entity, TypeConverter.convert(cellValue, fieldType)); - } - } - - // finally set an id field and return entity - invokeMethod(md.getIdColumnMetadata().getEntityFieldSetter(), entity, row.getRowNum()); - return entity; - } - - - - - private void writeRow(Object entity, Row row, boolean forceOverwrite) { - - Class entityClass = entity.getClass(); - EntityMetadata md = getEntityMetadata(entityClass); - - for(Map.Entry entry: - md.getColumnMetadataMap().entrySet()) { - String name = entry.getKey(); - EntityMetadata.ColumnMetadata cmd = entry.getValue(); - - if(! header.containsKey(name)) { - continue; - } - int columnIndex = header.get(name); - String fieldStringValue = toString(invokeMethod(cmd.getEntityFieldGetter(), entity)); - Cell cell = row.getCell(columnIndex); - - if(! forceOverwrite) { - String cellValue = getCellValueAsString(cell); - if(cellValue == null && fieldStringValue == null || - cellValue != null && cellValue.equals(fieldStringValue)) { - // okay, do not overwrite - continue; - } - } - - if(cell == null) { - cell = row.createCell(columnIndex); - } - cell.setCellValue(fieldStringValue); - } - - } - - private static String toString(Object o) { - if(o == null) { - return null; - } - return o.toString(); - } - - - private static void requireNotNull(Object reference) { - if(reference == null) { - throw new NullPointerException(); - } - } - - - private static String getCellValueAsString(Cell cell) { - if(cell == null) { - return null; - } - switch (cell.getCellType()) { - case Cell.CELL_TYPE_STRING: - return cell.getRichStringCellValue().getString(); - case Cell.CELL_TYPE_NUMERIC: - if (DateUtil.isCellDateFormatted(cell)) { - return cell.getDateCellValue().toString(); // XXX - } else { - return NumberToTextConverter.toText(cell.getNumericCellValue()); - } - case Cell.CELL_TYPE_BOOLEAN: - return String.valueOf(cell.getBooleanCellValue()); - case Cell.CELL_TYPE_FORMULA: - return cell.getCellFormula(); - default: - return ""; - } - } - - - - - private static int id(Object entity) { - if(entity == null) { - throw new NullPointerException(); - } - Class entityClass = entity.getClass(); - EntityMetadata md = getEntityMetadata(entityClass); - Method getter = md.getIdColumnMetadata().getEntityFieldGetter(); - return (Integer) invokeMethod(getter, entity); - } - - - - private static class EntityMetadata { - - private ColumnMetadata idColumnMetadata; - private Map columnMetadataMap; - - - - private EntityMetadata(Class entityType) throws IntrospectionException { - if(entityType == null) { - throw new NullPointerException(); - } - - // TODO check for @Entity annotation - readColumnMetadata(entityType); - } - - - - private void readColumnMetadata(Class entityType) throws IntrospectionException { - - columnMetadataMap = new HashMap(); - - BeanInfo beanInfo = Introspector.getBeanInfo(entityType, Object.class); - - Set set = new HashSet(); - - for(PropertyDescriptor propertyDescriptor: beanInfo.getPropertyDescriptors()) { - ColumnMetadata md = getColumnMetadata(entityType, propertyDescriptor); - - if(md == null) { // not annotated, ignore field - continue; - } - - if(md.columnName.equals("")) { - if(idColumnMetadata != null) { - throw new IllegalArgumentException("Two annotated @Column fields are defined as identifier: " + - idColumnMetadata.entityField + " and " + md.entityField); - } - idColumnMetadata = md; - } else { - String key = md.columnName.toUpperCase(); - if(columnMetadataMap.containsKey(key)) { - throw new IllegalArgumentException("Two annotated @Column fields have the same name " + - key + ": " + md.entityField + " and " + columnMetadataMap.get(key).entityField); - } - columnMetadataMap.put(key, md); - } - - } - - if(idColumnMetadata == null) { - throw new IllegalArgumentException("Entity " + entityType + " must has an identifier"); - } - - } - - - - - private static boolean checkPropertyTypeSupported(Class type) { - return TypeConverter.isTypeSupported(type); - } - - - private static ColumnMetadata getColumnMetadata(Class entityType, PropertyDescriptor pd) { - Field field = null; - try { - field = entityType.getDeclaredField(pd.getName()); - } catch (NoSuchFieldException e) { - return null; - //throw new RuntimeException("WTF?? " + e); - } - - Id idAnnotation = getFieldAnnotation(field, Id.class); - Column columnAnnotation = getFieldAnnotation(field, Column.class); - - if(idAnnotation != null && columnAnnotation != null) { - throw new IllegalArgumentException("Field should not be annotated both with @Column and @Id: " + field); - } else if (idAnnotation == null && columnAnnotation == null) { - return null; - } - - if(idAnnotation != null) { - if(field.getType() != int.class) { - throw new IllegalArgumentException("@Id-annotated property must be of type int" + field); - } - } else { - if (!checkPropertyTypeSupported(field.getType())) { - throw new IllegalArgumentException("@Column-annotated field type not supported: " + field); - } - } - - - - ColumnMetadata md = new ColumnMetadata(); - md.entityField = field; - - Method getter = pd.getReadMethod(); - if(getter == null) { - throw new IllegalArgumentException("@Column-annotated field must has getter method: " + field); - } - - md.entityFieldGetter = getter; - - Method setter = pd.getWriteMethod(); - if(setter == null) { - throw new IllegalArgumentException("@Column-annotated field must has setter method: " + field); - } - md.entityFieldSetter = setter; - - String name; - - if(idAnnotation != null) { - name = ""; - md.isNullable = false; - } else { // columnAnnotation always not null here - name = columnAnnotation.name(); - if(name == null) { - name = field.getName(); - } - - if(name.equals("")) { - throw new IllegalArgumentException("@Column(name) should not be empty for field " + field); - } - - md.isNullable = columnAnnotation.nullable(); - } - - md.columnName = name; - return md; - } - - - - - - - private static T getFieldAnnotation(Field field, Class annotationType) { - for(Annotation annotation: field.getDeclaredAnnotations()) { - if(annotation.annotationType() == annotationType) { - return annotationType.cast(annotation); - } - } - return null; - } - - - public ColumnMetadata getIdColumnMetadata() { - return idColumnMetadata; - } - - - public Map getColumnMetadataMap() { - return Collections.unmodifiableMap(columnMetadataMap); - } - - - public ColumnMetadata getColumnMetadata(String name) { - if(name == null) { - throw new NullPointerException("name is null"); - } else if (name.equals("")) { - throw new IllegalArgumentException("Empty name"); - } - return columnMetadataMap.get(name.toUpperCase()); - } - - //!~-------------------------------------------------------------------- - - - private static Map, EntityMetadata> metadataStore = new HashMap, EntityMetadata>(); - - - /* - * TODO thread safety!! - */ - public static EntityMetadata get(Class entityType) throws IntrospectionException { - if(! metadataStore.containsKey(entityType)) { - EntityMetadata md = new EntityMetadata(entityType); - metadataStore.put(entityType, md); - return md; - } - return metadataStore.get(entityType); - } - - - - public static class ColumnMetadata { - - private String columnName; - private boolean isNullable; - private Field entityField; - private Method entityFieldGetter; - private Method entityFieldSetter; - - - public String getColumnName() { - return columnName; - } - - public boolean isNullable() { - return isNullable; - } - - public Field getEntityField() { - return entityField; - } - - public Method getEntityFieldGetter() { - return entityFieldGetter; - } - - public Method getEntityFieldSetter() { - return entityFieldSetter; - } - - - @Override - public String toString() { - return "ColumnMetadata{" + - "columnName='" + columnName + '\'' + - ", isNullable=" + isNullable + - ", entityField=" + entityField + - ", entityFieldGetter=" + entityFieldGetter + - ", entityFieldSetter=" + entityFieldSetter + - "}"; - } - } - - } - - - - private static class TypeConverter { - - - private static final Set> supportedTypes = new HashSet>(Arrays.asList(new Class[] { - - String.class, - Integer.class, int.class, - Long.class, long.class, - Short.class, short.class, - Float.class, float.class, - Double.class, double.class, - BigInteger.class, - BigDecimal.class - - })); - - - public static boolean isTypeSupported(Class type) { - return supportedTypes.contains(type); - } - - public static T convert(String any, Class toType) { - if(any == null) { - return null; - } - - if(toType == String.class) { - return toType.cast(any); - } else if(toType == Integer.class || toType == int.class) { - return toType.cast(Integer.parseInt(any)); - } else if(toType == Long.class || toType == long.class) { - return toType.cast(Long.parseLong(any)); - } else if(toType == Short.class || toType == short.class) { - return toType.cast(Short.parseShort(any)); - } else if(toType == Float.class || toType == float.class) { - return toType.cast(Float.parseFloat(any)); - } else if(toType == Double.class || toType == double.class) { - return toType.cast(Double.parseDouble(any)); - } else if(toType == Byte.class || toType == byte.class) { - return toType.cast(Byte.parseByte(any)); - } else if(toType == BigInteger.class) { - return toType.cast(new BigInteger(any)); - } else if(toType == BigDecimal.class) { - return toType.cast(new BigDecimal(any)); - } else { - throw new IllegalArgumentException("Type not supported " + toType); - } - } - } - - - -} diff --git a/common/src/main/java/com/ge/mdm/tools/common/TaskExecutor.java b/common/src/main/java/com/ge/mdm/tools/common/TaskExecutor.java deleted file mode 100644 index aa87cc1..0000000 --- a/common/src/main/java/com/ge/mdm/tools/common/TaskExecutor.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.ge.mdm.tools.common; - -import java.util.*; -import java.util.concurrent.*; -import java.util.function.Consumer; -import java.util.function.Supplier; - - -public class TaskExecutor { - - private int poolSize; - - private Supplier taskSupplier; - - private Consumer taskConsumer; - - private Map, T> futureTaskMap; - - private int numTasksSupplied; - - private int numTasksConsumed; - - private Date executionStartDate; - - private Date executionEndDate; - - - - - public TaskExecutor(int poolSize) { - this.poolSize = poolSize; - futureTaskMap = new HashMap<>(); - } - - - - public void execute() { - Objects.requireNonNull(taskSupplier, "taskSupplier"); - - ThreadPoolExecutor fixedThreadPool = new ThreadPoolExecutor(poolSize, poolSize, 0L, TimeUnit.MILLISECONDS, new BlockingOnOfferSynchronousQueue<>()); - - numTasksSupplied = 0; - numTasksConsumed = 0; - executionStartDate = new Date(); - executionEndDate = null; - - T task; - - while((task = taskSupplier.get()) != null) { - numTasksSupplied++; - consumeCompletedTasks(false); - - Future future = fixedThreadPool.submit(task); - futureTaskMap.put(future, task); - } - - consumeCompletedTasks(true); - - executionEndDate = new Date(); - - fixedThreadPool.shutdown(); // must terminate immediately as all tasks completed - } - - - private void consumeCompletedTasks(boolean force) { - Iterator> it = futureTaskMap.keySet().iterator(); - while(it.hasNext()) { - Future f = it.next(); - - // if task still not completed and force = true, wait until it will complete - if(! f.isDone() && force) { - try { - f.get(); // block until task completed, always returns null - } catch (InterruptedException ignored) { - Thread.currentThread().interrupt(); - return; // thread interrupted, stop consuming tasks - } catch (ExecutionException e) { - e.printStackTrace(); - continue; // do not allow to consume as task has not completed - } - } - - // consume task if it was done - if(f.isDone()) { - T t = futureTaskMap.get(f); - taskConsumer.accept(t); - it.remove(); - numTasksConsumed++; - } - - } - } - - - public void setTaskSupplier(Supplier taskSupplier) { - this.taskSupplier = taskSupplier; - } - - public void setTaskConsumer(Consumer taskConsumer) { - this.taskConsumer = taskConsumer; - } - - - public int getNumTasksSupplied() { - return numTasksSupplied; - } - - public int getNumTasksConsumed() { - return numTasksConsumed; - } - - public Date getExecutionStartDate() { - return executionStartDate; - } - - public Date getExecutionEndDate() { - return executionEndDate; - } - - - private static class BlockingOnOfferSynchronousQueue extends SynchronousQueue { - - public BlockingOnOfferSynchronousQueue() { - super(); - } - - @Override - public boolean offer(E e) { - try { - put(e); - return true; - } catch (InterruptedException ie) { - Thread.currentThread().interrupt(); - } - return false; - } - - } - -} diff --git a/src/main/java/excel2db/excel2db.java b/src/main/java/excel2db/excel2db.java index 001b582..3907c37 100644 --- a/src/main/java/excel2db/excel2db.java +++ b/src/main/java/excel2db/excel2db.java @@ -20,9 +20,7 @@ public class excel2db - { - public static final Logger logger = LoggerFactory.getLogger(excel2db.class); // declaring the constructor to meet to the Spring framework convention diff --git a/src/main/resources/excel2db.properties b/src/main/resources/excel2db.properties index 244c517..a045761 100644 --- a/src/main/resources/excel2db.properties +++ b/src/main/resources/excel2db.properties @@ -1,5 +1,5 @@ # names of input tables -input.files=test-input.xls,test-input1.xls +input.files=test.xls # db implementation classes diff --git a/src/test/java/InitInputFilesImplTest.java b/src/test/java/InitInputFilesImplTest.java index ea19f69..958bfe8 100644 --- a/src/test/java/InitInputFilesImplTest.java +++ b/src/test/java/InitInputFilesImplTest.java @@ -37,7 +37,7 @@ public void testInitInputFilesImpl() throws Exception { excel2db app = (excel2db) context.getBean("excel2db"); //executing the test - File fileName = new File(app.initConstants.workingDir + "/unitTest.xls"); + File fileName = new File(app.initConstants.workingDir + "/test.xls"); //here we should initialize the sheet object assertEquals("UnitTestSheet", app.initInputFiles.initInputFiles(fileName).getSheetName()); diff --git a/src/test/java/PopulateTablePostgresImplTest.java b/src/test/java/PopulateTablePostgresImplTest.java index 72c1b46..7ae689b 100644 --- a/src/test/java/PopulateTablePostgresImplTest.java +++ b/src/test/java/PopulateTablePostgresImplTest.java @@ -34,7 +34,7 @@ public void testPopulateTable() throws Exception { excel2db app = (excel2db) context.getBean("excel2db"); //executing the test - File fileName = new File(app.initConstants.workingDir + "/unitTest.xls"); + File fileName = new File(app.initConstants.workingDir + "/test.xls"); sheet = app.initInputFiles.initInputFiles(fileName); app.dbConnection.establishDBConnection(); app.createTable.createTable(sheet, "testTable"); diff --git a/test-input-old.xlsx b/test-input-old.xlsx deleted file mode 100644 index 7eadb0f..0000000 Binary files a/test-input-old.xlsx and /dev/null differ diff --git a/test-input.xlsx b/test-input.xlsx deleted file mode 100644 index cfcb3d9..0000000 Binary files a/test-input.xlsx and /dev/null differ diff --git a/test.xls b/test.xls new file mode 100644 index 0000000..3b58ff3 Binary files /dev/null and b/test.xls differ