|
|
@ -1,20 +1,33 @@ |
|
|
|
package com.fr.file; |
|
|
|
package com.fr.file; |
|
|
|
|
|
|
|
|
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
import com.fr.base.extension.FileExtension; |
|
|
|
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
import com.fr.file.filter.ChooseFileFilter; |
|
|
|
import com.fr.file.filter.ChooseFileFilter; |
|
|
|
import com.fr.invoke.Reflect; |
|
|
|
import com.fr.invoke.Reflect; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
import org.easymock.EasyMock; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Assert; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
|
|
|
|
import org.junit.runner.RunWith; |
|
|
|
|
|
|
|
import org.powermock.api.easymock.PowerMock; |
|
|
|
|
|
|
|
import org.powermock.core.classloader.annotations.PowerMockIgnore; |
|
|
|
|
|
|
|
import org.powermock.core.classloader.annotations.PrepareForTest; |
|
|
|
|
|
|
|
import org.powermock.modules.junit4.PowerMockRunner; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Created by kerry on 2019-10-15 |
|
|
|
* Created by kerry on 2019-10-15 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
@RunWith(PowerMockRunner.class) |
|
|
|
|
|
|
|
@PowerMockIgnore({"javax.management.*", "javax.swing.*"}) |
|
|
|
|
|
|
|
@PrepareForTest({Toolkit.class, FileNodeFILE.class}) |
|
|
|
public class FILEChooserPaneTest { |
|
|
|
public class FILEChooserPaneTest { |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void testAddChooseFileFilter() { |
|
|
|
public void testAddChooseFileFilter() { |
|
|
|
FILEChooserPane chooserPane = Reflect.on(FILEChooserPane.class).field("INSTANCE").get(); |
|
|
|
PowerMock.mockStatic(Toolkit.class); |
|
|
|
|
|
|
|
EasyMock.expect(Toolkit.i18nText(EasyMock.anyString())).andReturn("test").anyTimes(); |
|
|
|
|
|
|
|
PowerMock.replayAll(); |
|
|
|
|
|
|
|
FILEChooserPane chooserPane = EasyMock.mock(FILEChooserPane.class); |
|
|
|
Reflect.on(chooserPane).set("suffix", ".cpt"); |
|
|
|
Reflect.on(chooserPane).set("suffix", ".cpt"); |
|
|
|
String result1 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", null).get(); |
|
|
|
String result1 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", null).get(); |
|
|
|
Assert.assertEquals("WorkBook1.cpt", result1); |
|
|
|
Assert.assertEquals("WorkBook1.cpt", result1); |
|
|
@ -25,11 +38,11 @@ public class FILEChooserPaneTest { |
|
|
|
|
|
|
|
|
|
|
|
ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); |
|
|
|
ChooseFileFilter chooseFileFilter2 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); |
|
|
|
String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get(); |
|
|
|
String result3 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cpt", chooseFileFilter2).get(); |
|
|
|
Assert.assertEquals("WorkBook1.cpt.cptx", result3); |
|
|
|
Assert.assertEquals("WorkBook1.cptx", result3); |
|
|
|
|
|
|
|
|
|
|
|
ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); |
|
|
|
ChooseFileFilter chooseFileFilter3 = new ChooseFileFilter(FileExtension.CPT, StringUtils.EMPTY); |
|
|
|
String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get(); |
|
|
|
String result4 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter3).get(); |
|
|
|
Assert.assertEquals("WorkBook1.cptx.cpt", result4); |
|
|
|
Assert.assertEquals("WorkBook1.cpt", result4); |
|
|
|
|
|
|
|
|
|
|
|
ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); |
|
|
|
ChooseFileFilter chooseFileFilter5 = new ChooseFileFilter(FileExtension.CPTX, StringUtils.EMPTY); |
|
|
|
String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get(); |
|
|
|
String result5 = Reflect.on(chooserPane).call("calProperFileName", "WorkBook1.cptx", chooseFileFilter5).get(); |
|
|
|