|
| 1 | +package com.alipay.rdf.file.reader; |
| 2 | + |
| 3 | +import java.io.File; |
| 4 | +import java.util.HashMap; |
| 5 | +import java.util.Map; |
| 6 | + |
| 7 | +import org.junit.Before; |
| 8 | +import org.junit.Test; |
| 9 | + |
| 10 | +import com.alipay.rdf.file.interfaces.FileFactory; |
| 11 | +import com.alipay.rdf.file.interfaces.FileReader; |
| 12 | +import com.alipay.rdf.file.interfaces.FileStorage; |
| 13 | +import com.alipay.rdf.file.model.FileConfig; |
| 14 | +import com.alipay.rdf.file.model.StorageConfig; |
| 15 | +import com.alipay.rdf.file.storage.OssConfig; |
| 16 | +import com.alipay.rdf.file.util.OssTestUtil; |
| 17 | +import com.alipay.rdf.file.util.RdfFileUtil; |
| 18 | +import com.alipay.rdf.file.util.TemporaryFolderUtil; |
| 19 | + |
| 20 | +import junit.framework.Assert; |
| 21 | + |
| 22 | +public class BodyEmptyReader { |
| 23 | + private TemporaryFolderUtil temporaryFolder = new TemporaryFolderUtil(); |
| 24 | + private static final StorageConfig storageConfig = OssTestUtil.geStorageConfig(); |
| 25 | + private static String ossPathPrifx = "rdf/rdf-file/open/BodyEmptyReader"; |
| 26 | + private static FileStorage fileStorage = FileFactory.createStorage(storageConfig); |
| 27 | + private OssConfig ossConfig; |
| 28 | + |
| 29 | + @Before |
| 30 | + public void setUp() throws Exception { |
| 31 | + temporaryFolder.create(); |
| 32 | + ossConfig = (OssConfig) storageConfig.getParam(OssConfig.OSS_STORAGE_CONFIG_KEY); |
| 33 | + ossConfig.setOssTempRoot(temporaryFolder.getRoot().getAbsolutePath()); |
| 34 | + System.out.println(temporaryFolder.getRoot().getAbsolutePath()); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + public void testRead() { |
| 39 | + String ossFilePath = RdfFileUtil.combinePath(ossPathPrifx, "test.txt"); |
| 40 | + fileStorage.upload(File.class.getResource("/reader/test.txt").getPath(), ossFilePath, true); |
| 41 | + |
| 42 | + FileConfig normalConfig = new FileConfig(ossFilePath, "/reader/template_Allocation.json", |
| 43 | + storageConfig); |
| 44 | + FileReader reader = FileFactory.createReader(normalConfig); |
| 45 | + |
| 46 | + Map<String, Object> row = null; |
| 47 | + while (null != (row = reader.readRow(HashMap.class))) { |
| 48 | + |
| 49 | + } |
| 50 | + |
| 51 | + Assert.assertNull(row); |
| 52 | + } |
| 53 | +} |
0 commit comments