Skip to content

Commit

Permalink
fix failed ut
Browse files Browse the repository at this point in the history
  • Loading branch information
lepdou committed Aug 5, 2021
1 parent fcb3564 commit 3e53359
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,18 @@
import com.ctrip.framework.apollo.portal.service.ItemService;
import com.ctrip.framework.apollo.portal.service.NamespaceService;
import com.ctrip.framework.apollo.portal.spi.UserInfoHolder;

import com.google.common.base.Charsets;
import com.google.common.io.Files;

import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand Down Expand Up @@ -53,7 +61,7 @@ public class ItemControllerTest {
@Before
public void setUp() throws Exception {
itemController = new ItemController(configService, userInfoHolder, permissionValidator,
namespaceService);
namespaceService);
}

@Test
Expand Down Expand Up @@ -86,8 +94,17 @@ private NamespaceTextModel assemble(String format, String content) {
}

private String loadYaml(String caseName) throws IOException {
File file = new File("src/test/resources/yaml/" + caseName);
InputStream in = ItemControllerTest.class.getClassLoader().getResourceAsStream("yaml/" + caseName);
assert in != null;

Reader reader = new InputStreamReader(in);
BufferedReader bufferedReader = new BufferedReader(reader);
StringBuilder content = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
content.append(line).append("\n");
}

return Files.toString(file, Charsets.UTF_8);
return content.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public void testCreatePublicAppNamespaceWithWrongFormatNotExisted() {

Assert.assertNotNull(createdAppNamespace);
Assert.assertEquals(appNamespace.getName(), createdAppNamespace.getName());
Assert.assertEquals(ConfigFileFormat.Properties.getValue(), createdAppNamespace.getFormat());
Assert.assertEquals(ConfigFileFormat.YAML.getValue(), createdAppNamespace.getFormat());
}


Expand Down

0 comments on commit 3e53359

Please sign in to comment.