Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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