mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
add test
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1925420 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9e30ffc0de
commit
c37b4ee0d5
@ -266,7 +266,7 @@ public final class AnalysisToolPak implements UDFFinder {
|
||||
* @throws IllegalArgumentException if the function is unknown or already registered.
|
||||
* @since 3.8 beta6
|
||||
*/
|
||||
public static void registerFunction(String name, FreeRefFunction func){
|
||||
public static void registerFunction(String name, FreeRefFunction func) {
|
||||
AnalysisToolPak inst = (AnalysisToolPak)instance;
|
||||
if(!isATPFunction(name)) {
|
||||
FunctionMetadata metaData = FunctionMetadataRegistry.getFunctionByName(name);
|
||||
|
||||
@ -26,6 +26,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
|
||||
import org.apache.poi.hssf.record.CountryRecord;
|
||||
import org.apache.poi.hssf.record.FontRecord;
|
||||
import org.apache.poi.hssf.record.RecalcIdRecord;
|
||||
@ -170,4 +171,20 @@ final class TestWorkbook {
|
||||
int newRecordsCount = iwb.getNumRecords();
|
||||
assertEquals(oldRecordsCount, newRecordsCount, "records count after getWriteAccess");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSetUserName() throws IOException {
|
||||
try (HSSFWorkbook wb = new HSSFWorkbook()) {
|
||||
InternalWorkbook iwb = wb.getInternalWorkbook();
|
||||
iwb.getWriteAccess().setUsername("username");
|
||||
assertEquals("username", iwb.getWriteAccess().getUsername());
|
||||
try (UnsynchronizedByteArrayOutputStream os = UnsynchronizedByteArrayOutputStream.builder().get()) {
|
||||
wb.write(os);
|
||||
try (HSSFWorkbook wb2 = new HSSFWorkbook(os.toInputStream())) {
|
||||
InternalWorkbook iwb2 = wb2.getInternalWorkbook();
|
||||
assertEquals("username", iwb2.getWriteAccess().getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user