[bug-62038] add mockito based unit test

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1822517 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2018-01-29 15:21:59 +00:00
parent 6dc0f74269
commit 4637ffcbca
5 changed files with 22 additions and 0 deletions

View File

@ -35,5 +35,6 @@
<classpathentry exported="true" kind="lib" path="lib/commons-logging-1.2.jar"/> <classpathentry exported="true" kind="lib" path="lib/commons-logging-1.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-collections4-4.1.jar"/> <classpathentry exported="true" kind="lib" path="lib/commons-collections4-4.1.jar"/>
<classpathentry kind="lib" path="lib/commons-math3-3.6.1.jar"/> <classpathentry kind="lib" path="lib/commons-math3-3.6.1.jar"/>
<classpathentry kind="lib" path="lib/mockito-core-2.13.0.jar"/>
<classpathentry kind="output" path="bin"/> <classpathentry kind="output" path="bin"/>
</classpath> </classpath>

View File

@ -211,6 +211,7 @@ project('ooxml') {
compile files('../../ooxml-lib/ooxml-security-1.1.jar') compile files('../../ooxml-lib/ooxml-security-1.1.jar')
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:2.13.0'
testCompile project(path: ':main', configuration: 'tests') testCompile project(path: ':main', configuration: 'tests')
testCompile 'org.openjdk.jmh:jmh-core:1.19' testCompile 'org.openjdk.jmh:jmh-core:1.19'
testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19' testCompile 'org.openjdk.jmh:jmh-generator-annprocess:1.19'

View File

@ -164,6 +164,8 @@ under the License.
<property name="main.hamcrest.jar" location="${main.lib}/hamcrest-core-1.3.jar"/> <property name="main.hamcrest.jar" location="${main.lib}/hamcrest-core-1.3.jar"/>
<property name="main.hamcrest.url" value="${repository.m2}/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"/> <property name="main.hamcrest.url" value="${repository.m2}/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar"/>
<property name="main.mockito.jar" location="${main.lib}/mockito-core-2.13.0.jar"/>
<property name="main.mockito.url" value="${repository.m2}/maven2/org/mockito/mockito-core/2.13.0/mockito-core-2.13.0.jar"/>
<property name="main.ant.jar" location="${main.lib}/ant-1.10.1.jar"/> <property name="main.ant.jar" location="${main.lib}/ant-1.10.1.jar"/>
<property name="main.ant.url" value="${repository.m2}/maven2/org/apache/ant/ant/1.10.1/ant-1.10.1.jar"/> <property name="main.ant.url" value="${repository.m2}/maven2/org/apache/ant/ant/1.10.1/ant-1.10.1.jar"/>
<property name="main.antlauncher.jar" location="${main.lib}/ant-launcher-1.10.1.jar"/> <property name="main.antlauncher.jar" location="${main.lib}/ant-launcher-1.10.1.jar"/>
@ -317,6 +319,7 @@ under the License.
<pathelement location="${main.jmh.jar}"/> <pathelement location="${main.jmh.jar}"/>
<pathelement location="${main.jmhAnnotation.jar}"/> <pathelement location="${main.jmhAnnotation.jar}"/>
<pathelement location="${main.hamcrest.jar}"/> <pathelement location="${main.hamcrest.jar}"/>
<pathelement location="${main.mockito.jar}"/>
</path> </path>
<path id="scratchpad.classpath"> <path id="scratchpad.classpath">
@ -620,6 +623,7 @@ under the License.
<available file="${main.jmh.jar}"/> <available file="${main.jmh.jar}"/>
<available file="${main.jmhAnnotation.jar}"/> <available file="${main.jmhAnnotation.jar}"/>
<available file="${main.hamcrest.jar}"/> <available file="${main.hamcrest.jar}"/>
<available file="${main.mockito.jar}"/>
<available file="${main.ant.jar}"/> <available file="${main.ant.jar}"/>
<available file="${main.antlauncher.jar}"/> <available file="${main.antlauncher.jar}"/>
<available file="${asm.jar}"/> <available file="${asm.jar}"/>
@ -651,6 +655,7 @@ under the License.
<downloadfile src="${main.jmh.url}" dest="${main.jmh.jar}"/> <downloadfile src="${main.jmh.url}" dest="${main.jmh.jar}"/>
<downloadfile src="${main.jmhAnnotation.url}" dest="${main.jmhAnnotation.jar}"/> <downloadfile src="${main.jmhAnnotation.url}" dest="${main.jmhAnnotation.jar}"/>
<downloadfile src="${main.hamcrest.url}" dest="${main.hamcrest.jar}"/> <downloadfile src="${main.hamcrest.url}" dest="${main.hamcrest.jar}"/>
<downloadfile src="${main.mockito.url}" dest="${main.mockito.jar}"/>
<downloadfile src="${main.ant.url}" dest="${main.ant.jar}"/> <downloadfile src="${main.ant.url}" dest="${main.ant.jar}"/>
<downloadfile src="${main.antlauncher.url}" dest="${main.antlauncher.jar}"/> <downloadfile src="${main.antlauncher.url}" dest="${main.antlauncher.jar}"/>
<downloadfile src="${asm.url}" dest="${asm.jar}"/> <downloadfile src="${asm.url}" dest="${asm.jar}"/>

Binary file not shown.

View File

@ -22,6 +22,8 @@ import static org.apache.poi.sl.TestCommonSL.sameColor;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import java.awt.Color; import java.awt.Color;
import java.io.IOException; import java.io.IOException;
@ -96,4 +98,17 @@ public class TestXSLFTextRun {
assertEquals(unicodeSurrogates, r.getRenderableText(unicodeSurrogates)); assertEquals(unicodeSurrogates, r.getRenderableText(unicodeSurrogates));
} }
} }
@Test
public void testCopyNullFontSize() throws IOException {
XMLSlideShow ppt = new XMLSlideShow();
XSLFSlide slide = ppt.createSlide();
XSLFTextShape sh = slide.createAutoShape();
XSLFTextRun r = sh.addNewTextParagraph().addNewTextRun();
XSLFTextRun s = mock(XSLFTextRun.class);
when(s.getFontSize()).thenReturn(null);
r.copy(s);
}
} }