@Override
public ProjectReferentials load(ProjectReactor reactor, TaskProperties taskProperties) {
String projectKey = reactor.getRoot().getKeyWithBranch();
- String url = BATCH_PROJECT_URL + "?key=" + projectKey;
+ String url = BATCH_PROJECT_URL + "?key=" + ServerClient.encodeForUrl(projectKey);
if (taskProperties.properties().containsKey(ModuleQProfiles.SONAR_PROFILE_PROP)) {
LOG.warn("Ability to set quality profile from command line using '" + ModuleQProfiles.SONAR_PROFILE_PROP
+ "' is deprecated and will be dropped in a future SonarQube version. Please configure quality profile used by your project on SonarQube server.");
loader = spy(loader);
doReturn(null).when(loader).lastSnapshotCreationDate(anyString());
when(serverClient.request(anyString())).thenReturn("{}");
- reactor = new ProjectReactor(ProjectDefinition.create().setKey("foo"));
taskProperties = new TaskProperties(Maps.<String, String>newHashMap(), "");
}
@Test
public void passPreviewParameter() {
+ reactor = new ProjectReactor(ProjectDefinition.create().setKey("foo"));
when(analysisMode.isPreview()).thenReturn(false);
loader.load(reactor, taskProperties);
verify(serverClient).request("/batch/project?key=foo&preview=false");
}
@Test
- public void passProfileParameter() {
- taskProperties.properties().put(ModuleQProfiles.SONAR_PROFILE_PROP, "my-profile");
+ public void passAndEncodeProjectKeyParameter() {
+ reactor = new ProjectReactor(ProjectDefinition.create().setKey("foo bàr"));
+ loader.load(reactor, taskProperties);
+ verify(serverClient).request("/batch/project?key=foo+b%C3%A0r&preview=false");
+ }
+
+ @Test
+ public void passAndEncodeProfileParameter() {
+ reactor = new ProjectReactor(ProjectDefinition.create().setKey("foo"));
+ taskProperties.properties().put(ModuleQProfiles.SONAR_PROFILE_PROP, "my-profile#2");
loader.load(reactor, taskProperties);
- verify(serverClient).request("/batch/project?key=foo&profile=my-profile&preview=false");
+ verify(serverClient).request("/batch/project?key=foo&profile=my-profile%232&preview=false");
}
}