public void testShiftJISFile() throws Exception {
// ShiftJIS is an encoding of Japanese texts.
// I test here that a non-UTF-8 encoding also works.
//create triggered build, with capture env builder
Project projectB = createFreeStyleProject();
CaptureAllEnvironmentBuilder builder = new CaptureAllEnvironmentBuilder();
projectB.getBuildersList().add(builder);
//create triggering build
FreeStyleProject projectA = createFreeStyleProject();
projectA.getBuildersList().add(new TestBuilder() {
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
BuildListener listener) throws InterruptedException, IOException {
build.getWorkspace().child("abc.txt").write(
"TEST=こんにちは\n" // "hello" in Japanese.
+ "TEST=hello_abc", // TEST in multibytes.
"Shift_JIS"
);
return true;
}
});
// add Trigger builder, with file paramter factory
projectA.getBuildersList().add(createTriggerBuilder(projectB, NoFilesFoundEnum.SKIP, "Shift_JIS"));
projectA.scheduleBuild2(0).get();
// check triggered builds are correct.
waitUntilNoActivity();
List<FreeStyleBuild> builds = projectB.getBuilds();
assertEquals(1, builds.size());
for (FreeStyleBuild build : builds) {
EnvVars buildEnvVar = builder.getEnvVars().get(build.getId());
assertEquals("こんにちは", buildEnvVar.get("TEST"));