Skip to content

Commit

Permalink
Make ConfigsExportServiceTest support windows (#4765)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangJian He authored Mar 3, 2023
1 parent bd0600f commit e78712b
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.ctrip.framework.apollo.portal.environment.Env;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;

import org.assertj.core.util.Files;
import org.assertj.core.util.Lists;
import org.junit.Test;
import org.mockito.InjectMocks;
Expand Down Expand Up @@ -82,11 +83,9 @@ public class ConfigsExportServiceTest extends AbstractUnitTest {

@Test
public void testNamespaceExportImport() throws FileNotFoundException {
String filePath = "/tmp/apollo.zip";
File file = new File(filePath);
if (file.exists()) {
file.delete();
}
File temporaryFolder = Files.newTemporaryFolder();
temporaryFolder.deleteOnExit();
String filePath = temporaryFolder + File.separator + "export.zip";

//export config
UserInfo userInfo = genUser();
Expand Down Expand Up @@ -152,7 +151,7 @@ public void testNamespaceExportImport() throws FileNotFoundException {
when(namespaceService.findNamespaceBOs(appId2, Env.DEV, clusterName1, false)).thenReturn(app2Cluster1Namespace);
when(namespaceService.findNamespaceBOs(appId2, Env.DEV, clusterName2, false)).thenReturn(app2Cluster2Namespace);

FileOutputStream fileOutputStream = new FileOutputStream("/tmp/apollo.zip");
FileOutputStream fileOutputStream = new FileOutputStream(filePath);

configsExportService.exportData(fileOutputStream, Lists.newArrayList(Env.DEV));

Expand All @@ -171,7 +170,7 @@ public void testNamespaceExportImport() throws FileNotFoundException {
HttpStatusCodeException itemNotFoundException = new HttpClientErrorException(HttpStatus.NOT_FOUND);
when(itemService.loadItem(any(), any(), any(), any(), anyString())).thenThrow(itemNotFoundException);

FileInputStream fileInputStream = new FileInputStream("/tmp/apollo.zip");
FileInputStream fileInputStream = new FileInputStream(filePath);
ZipInputStream zipInputStream = new ZipInputStream(fileInputStream);

try {
Expand Down

0 comments on commit e78712b

Please sign in to comment.