Search in sources :

Example 1 with MessageException

use of org.sonar.api.utils.MessageException in project sonarqube by SonarSource.

the class LoadReportAnalysisMetadataHolderStepTest method execute_sets_branch_even_if_MessageException_is_thrown_because_projectKey_in_report_is_different_from_componentKey_in_CE_task.

@Test
public void execute_sets_branch_even_if_MessageException_is_thrown_because_projectKey_in_report_is_different_from_componentKey_in_CE_task() {
    ComponentDto otherProject = db.components().insertPublicProject();
    reportReader.setMetadata(ScannerReport.Metadata.newBuilder().setProjectKey(otherProject.getDbKey()).build());
    try {
        underTest.execute(new TestComputationStepContext());
    } catch (MessageException e) {
        assertThat(analysisMetadataHolder.getBranch()).isNotNull();
    }
}
Also used : MessageException(org.sonar.api.utils.MessageException) ComponentDto(org.sonar.db.component.ComponentDto) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext) Test(org.junit.Test)

Example 2 with MessageException

use of org.sonar.api.utils.MessageException in project sonarqube by SonarSource.

the class OracleTest method test_driver_versions.

@Test
public void test_driver_versions() throws Exception {
    DatabaseMetaData metadata = newMetadata(11, 2, "18.3.0.0.0");
    underTest.init(metadata);
    metadata = newMetadata(11, 2, "12.2.0.1.0");
    underTest.init(metadata);
    // no error
    metadata = newMetadata(11, 2, "12.1.0.2.0");
    underTest.init(metadata);
    // no error
    metadata = newMetadata(11, 2, "12.1.0.1.0");
    underTest.init(metadata);
    // no error
    metadata = newMetadata(11, 2, "12.0.2");
    underTest.init(metadata);
    // no error
    metadata = newMetadata(11, 2, "11.1.0.2");
    try {
        underTest.init(metadata);
        fail();
    } catch (MessageException e) {
        assertThat(e).hasMessage("Unsupported Oracle driver version: 11.1.0.2. Minimal supported version is 12.1.");
    }
}
Also used : MessageException(org.sonar.api.utils.MessageException) DatabaseMetaData(java.sql.DatabaseMetaData) Test(org.junit.Test)

Example 3 with MessageException

use of org.sonar.api.utils.MessageException in project sonarqube by SonarSource.

the class LoadPeriodsStepTest method verifyFailWithInvalidValueMessageException.

private void verifyFailWithInvalidValueMessageException(String propertyValue, String debugLog, String... otherDebugLogs) {
    try {
        underTest.execute(new TestComputationStepContext());
        fail("a Message Exception should have been thrown");
    } catch (MessageException e) {
        verifyInvalidValueMessage(e, propertyValue);
        verifyDebugLogs(debugLog, otherDebugLogs);
    }
}
Also used : MessageException(org.sonar.api.utils.MessageException) TestComputationStepContext(org.sonar.ce.task.step.TestComputationStepContext)

Example 4 with MessageException

use of org.sonar.api.utils.MessageException in project sonarqube by SonarSource.

the class DatabaseCheckerTest method requires_oracle_driver_11_2.

@Test
public void requires_oracle_driver_11_2() throws Exception {
    Database db = mockDb(new Oracle(), 11, 2, "11.2.0.0.1");
    new DatabaseChecker(db).start();
    // no error
    db = mockDb(new Oracle(), 11, 2, "11.3.1");
    new DatabaseChecker(db).start();
    // no error
    db = mockDb(new Oracle(), 11, 2, "12.0.2");
    new DatabaseChecker(db).start();
    // no error
    db = mockDb(new Oracle(), 11, 2, "11.1.0.2");
    try {
        new DatabaseChecker(db).start();
        fail();
    } catch (MessageException e) {
        assertThat(e).hasMessage("Unsupported Oracle driver version: 11.1.0.2. Minimal supported version is 11.2.");
    }
}
Also used : MessageException(org.sonar.api.utils.MessageException) Oracle(org.sonar.db.dialect.Oracle) Test(org.junit.Test)

Example 5 with MessageException

use of org.sonar.api.utils.MessageException in project sonarqube by SonarSource.

the class DatabaseCheckerTest method requires_oracle_11g_or_greater.

@Test
public void requires_oracle_11g_or_greater() throws Exception {
    // oracle 11.0 is ok
    Database db = mockDb(new Oracle(), 11, 0, "11.2.0.0.1");
    new DatabaseChecker(db).start();
    // oracle 11.1 is ok
    db = mockDb(new Oracle(), 11, 1, "11.2.0.0.1");
    new DatabaseChecker(db).start();
    // oracle 11.2 is ok
    db = mockDb(new Oracle(), 11, 2, "11.2.0.0.1");
    new DatabaseChecker(db).start();
    // oracle 12 is ok
    db = mockDb(new Oracle(), 12, 0, "11.2.0.0.1");
    new DatabaseChecker(db).start();
    // oracle 10 is not supported
    db = mockDb(new Oracle(), 10, 2, "11.2.0.0.1");
    try {
        new DatabaseChecker(db).start();
        fail();
    } catch (MessageException e) {
        assertThat(e).hasMessage("Unsupported oracle version: 10.2. Minimal supported version is 11.0.");
    }
}
Also used : MessageException(org.sonar.api.utils.MessageException) Oracle(org.sonar.db.dialect.Oracle) Test(org.junit.Test)

Aggregations

MessageException (org.sonar.api.utils.MessageException)12 Test (org.junit.Test)11 Languages (org.sonar.api.resources.Languages)3 TestComputationStepContext (org.sonar.ce.task.step.TestComputationStepContext)3 DatabaseMetaData (java.sql.DatabaseMetaData)2 ComponentDto (org.sonar.db.component.ComponentDto)2 Oracle (org.sonar.db.dialect.Oracle)2 DefaultLanguagesRepository (org.sonar.scanner.repository.language.DefaultLanguagesRepository)2 LanguagesRepository (org.sonar.scanner.repository.language.LanguagesRepository)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 LogAndArguments (org.sonar.api.utils.log.LogAndArguments)1 CeTask (org.sonar.ce.task.CeTask)1 HttpException (org.sonarqube.ws.client.HttpException)1