prevent concurrent test execution in DirAccessTest

This commit is contained in:
Lee moon soo 2017-02-10 11:34:39 +09:00
parent 7860259ecf
commit b14b97e637

View file

@ -28,24 +28,28 @@ public class DirAccessTest extends AbstractTestRestApi {
@Test
public void testDirAccessForbidden() throws Exception {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED.getVarName(), "false");
AbstractTestRestApi.startUpWithAuthenticationEnable();
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(getUrlToTest() + "/app/");
httpClient.executeMethod(getMethod);
AbstractTestRestApi.shutDown();
assert getMethod.getStatusCode() == HttpStatus.SC_FORBIDDEN;
synchronized (this) {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED.getVarName(), "false");
AbstractTestRestApi.startUpWithAuthenticationEnable();
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(getUrlToTest() + "/app/");
httpClient.executeMethod(getMethod);
AbstractTestRestApi.shutDown();
assert getMethod.getStatusCode() == HttpStatus.SC_FORBIDDEN;
}
}
@Test
public void testDirAccessOk() throws Exception {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED.getVarName(), "true");
AbstractTestRestApi.startUpWithAuthenticationEnable();
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(getUrlToTest() + "/app/");
httpClient.executeMethod(getMethod);
AbstractTestRestApi.shutDown();
assert getMethod.getStatusCode() == HttpStatus.SC_OK;
synchronized (this) {
System.setProperty(ZeppelinConfiguration.ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED.getVarName(), "true");
AbstractTestRestApi.startUpWithAuthenticationEnable();
HttpClient httpClient = new HttpClient();
GetMethod getMethod = new GetMethod(getUrlToTest() + "/app/");
httpClient.executeMethod(getMethod);
AbstractTestRestApi.shutDown();
assert getMethod.getStatusCode() == HttpStatus.SC_OK;
}
}
protected static String getUrlToTest() {