correction to junit bugs in r1754691

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1754698 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Murphy 2016-08-01 02:53:55 +00:00
parent 0fe7cd5299
commit 8c0adfe55f
2 changed files with 101 additions and 73 deletions

View File

@ -890,8 +890,8 @@ public final class CellStyleTemplate {
return getNumBorderColors(new CellAddress(row, col));
}
/**
* Retrieves the border style for a given cell
/**
* Retrieves a template property as a short for a given cell
*
* @param cell
* @param property
@ -909,7 +909,7 @@ public final class CellStyleTemplate {
}
/**
* Retrieves the border style for a given cell
* Retrieves a template property as a short for a given cell
*
* @param row
* @param col
@ -919,6 +919,34 @@ public final class CellStyleTemplate {
return getTemplateProperty(new CellAddress(row, col), property);
}
/**
* Retrieves the border style for a given cell
*
* @param cell
* @param property
*/
public BorderStyle getBorderStyle(CellAddress cell, String property) {
Map<String, Object> cellProperties = _cellStyleTemplate.get(cell);
if (cellProperties != null) {
Object obj = cellProperties.get(property);
if (obj instanceof BorderStyle) {
return (BorderStyle) obj;
}
}
return null;
}
/**
* Retrieves the border style for a given cell
*
* @param row
* @param col
* @param property
*/
public BorderStyle getBorderStyle(int row, int col, String property) {
return getBorderStyle(new CellAddress(row, col), property);
}
/**
* Converts a Short object to a short value or 0 if the object is not a
* Short

View File

@ -50,10 +50,10 @@ public final class TestCellStyleTemplate {
CellStyleTemplate cst = new CellStyleTemplate();
cst.drawBorders(a1, BorderStyle.THIN, BorderExtent.TOP);
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(0, 0, CellUtil.BORDER_TOP));
cst.getBorderStyle(0, 0, CellUtil.BORDER_TOP));
cst.drawBorders(a1, BorderStyle.MEDIUM, BorderExtent.BOTTOM);
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(0, 0, CellUtil.BORDER_BOTTOM));
cst.getBorderStyle(0, 0, CellUtil.BORDER_BOTTOM));
cst.drawBorderColors(a1, IndexedColors.RED.getIndex(), BorderExtent.TOP);
assertEquals(IndexedColors.RED.getIndex(),
cst.getTemplateProperty(0, 0, CellUtil.TOP_BORDER_COLOR));
@ -72,13 +72,13 @@ public final class TestCellStyleTemplate {
for (int j = 0; j <= 2; j++) {
assertEquals(4, cst.getNumBorders(i, j));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
cst.getBorderStyle(i, j, CellUtil.BORDER_TOP));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
cst.getBorderStyle(i, j, CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
cst.getBorderStyle(i, j, CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
cst.getBorderStyle(i, j, CellUtil.BORDER_RIGHT));
}
}
cst.drawBorders(a1c3, BorderStyle.MEDIUM,
@ -89,124 +89,124 @@ public final class TestCellStyleTemplate {
if (i == 0) {
if (j == 0) {
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
} else if (j == 2) {
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
} else {
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
}
} else if (i == 2) {
if (j == 0) {
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
} else if (j == 2) {
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
} else {
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
}
} else {
if (j == 0) {
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
} else if (j == 2) {
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
} else {
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_TOP));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.THIN,
cst.getTemplateProperty(i, j,
cst.getBorderStyle(i, j,
CellUtil.BORDER_RIGHT));
}
}
@ -226,7 +226,7 @@ public final class TestCellStyleTemplate {
if (i == 0) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
cst.getBorderStyle(i, j, CellUtil.BORDER_TOP));
} else {
assertEquals(0, cst.getNumBorders(i, j));
}
@ -241,7 +241,7 @@ public final class TestCellStyleTemplate {
if (i == 2) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM, cst
.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
.getBorderStyle(i, j, CellUtil.BORDER_BOTTOM));
} else {
assertEquals(0, cst.getNumBorders(i, j));
}
@ -256,7 +256,7 @@ public final class TestCellStyleTemplate {
if (j == 0) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
cst.getBorderStyle(i, j, CellUtil.BORDER_LEFT));
} else {
assertEquals(0, cst.getNumBorders(i, j));
}
@ -271,7 +271,7 @@ public final class TestCellStyleTemplate {
if (j == 2) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM, cst
.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
.getBorderStyle(i, j, CellUtil.BORDER_RIGHT));
} else {
assertEquals(0, cst.getNumBorders(i, j));
}
@ -285,9 +285,9 @@ public final class TestCellStyleTemplate {
for (int j = 0; j <= 2; j++) {
assertEquals(2, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
cst.getBorderStyle(i, j, CellUtil.BORDER_TOP));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
cst.getBorderStyle(i, j, CellUtil.BORDER_BOTTOM));
}
}
cst.drawBorders(a1c3, BorderStyle.NONE,
@ -299,17 +299,17 @@ public final class TestCellStyleTemplate {
if (i == 0) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM, cst
.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
.getBorderStyle(i, j, CellUtil.BORDER_BOTTOM));
} else if (i == 2) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
cst.getBorderStyle(i, j, CellUtil.BORDER_TOP));
} else {
assertEquals(2, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
cst.getBorderStyle(i, j, CellUtil.BORDER_TOP));
assertEquals(BorderStyle.MEDIUM, cst
.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
.getBorderStyle(i, j, CellUtil.BORDER_BOTTOM));
}
}
}
@ -322,11 +322,11 @@ public final class TestCellStyleTemplate {
if (i == 0) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
cst.getBorderStyle(i, j, CellUtil.BORDER_TOP));
} else if (i == 2) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM, cst
.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
.getBorderStyle(i, j, CellUtil.BORDER_BOTTOM));
} else {
assertEquals(0, cst.getNumBorders(i, j));
}
@ -340,9 +340,9 @@ public final class TestCellStyleTemplate {
for (int j = 0; j <= 2; j++) {
assertEquals(2, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
cst.getBorderStyle(i, j, CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
cst.getBorderStyle(i, j, CellUtil.BORDER_RIGHT));
}
}
cst.drawBorders(a1c3, BorderStyle.NONE,
@ -354,17 +354,17 @@ public final class TestCellStyleTemplate {
if (j == 0) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM, cst
.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
.getBorderStyle(i, j, CellUtil.BORDER_RIGHT));
} else if (j == 2) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
cst.getBorderStyle(i, j, CellUtil.BORDER_LEFT));
} else {
assertEquals(2, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
cst.getBorderStyle(i, j, CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.MEDIUM, cst
.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
.getBorderStyle(i, j, CellUtil.BORDER_RIGHT));
}
}
}
@ -377,11 +377,11 @@ public final class TestCellStyleTemplate {
if (j == 0) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
cst.getBorderStyle(i, j, CellUtil.BORDER_LEFT));
} else if (j == 2) {
assertEquals(1, cst.getNumBorders(i, j));
assertEquals(BorderStyle.MEDIUM, cst
.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
.getBorderStyle(i, j, CellUtil.BORDER_RIGHT));
} else {
assertEquals(0, cst.getNumBorders(i, j));
}
@ -792,13 +792,13 @@ public final class TestCellStyleTemplate {
assertEquals(4, cst.getNumBorders(i, j));
assertEquals(4, cst.getNumBorderColors(i, j));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
cst.getBorderStyle(i, j, CellUtil.BORDER_TOP));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
cst.getBorderStyle(i, j, CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
cst.getBorderStyle(i, j, CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.MEDIUM,
cst.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
cst.getBorderStyle(i, j, CellUtil.BORDER_RIGHT));
assertEquals(IndexedColors.RED.getIndex(), cst
.getTemplateProperty(i, j, CellUtil.TOP_BORDER_COLOR));
assertEquals(IndexedColors.RED.getIndex(),
@ -818,13 +818,13 @@ public final class TestCellStyleTemplate {
assertEquals(4, cst.getNumBorders(i, j));
assertEquals(0, cst.getNumBorderColors(i, j));
assertEquals(BorderStyle.NONE,
cst.getTemplateProperty(i, j, CellUtil.BORDER_TOP));
cst.getBorderStyle(i, j, CellUtil.BORDER_TOP));
assertEquals(BorderStyle.NONE,
cst.getTemplateProperty(i, j, CellUtil.BORDER_BOTTOM));
cst.getBorderStyle(i, j, CellUtil.BORDER_BOTTOM));
assertEquals(BorderStyle.NONE,
cst.getTemplateProperty(i, j, CellUtil.BORDER_LEFT));
cst.getBorderStyle(i, j, CellUtil.BORDER_LEFT));
assertEquals(BorderStyle.NONE,
cst.getTemplateProperty(i, j, CellUtil.BORDER_RIGHT));
cst.getBorderStyle(i, j, CellUtil.BORDER_RIGHT));
}
}
}