Example usage for org.eclipse.jdt.core.tests.util AbstractCompilerTest getPossibleComplianceLevels

List of usage examples for org.eclipse.jdt.core.tests.util AbstractCompilerTest getPossibleComplianceLevels

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.tests.util AbstractCompilerTest getPossibleComplianceLevels.

Prototype

public static int getPossibleComplianceLevels() 

Source Link

Usage

From source file:de.fau.cs.i2.jamp.testsuite.TestAll.java

License:Open Source License

public static Test suite() {

    // Common test suites
    ArrayList standardTests = new ArrayList();

    // Tests to run when compliance is greater than 1.3
    ArrayList since_1_4 = new ArrayList();

    // Tests to run when compliance is greater than 1.4
    ArrayList since_1_5 = new ArrayList();

    // Tests to run when compliance is greater than 1.5
    ArrayList since_1_6 = new ArrayList();
    since_1_5.add(JampBarrierTest.class);
    since_1_5.add(JampCustomLoopSliceTest.class);
    since_1_5.add(JampFirstPrivateTest.class);
    since_1_5.add(JampForSemanticTest.class);
    since_1_5.add(JampForTest.class);
    since_1_5.add(JampIfTest.class);
    since_1_5.add(JampLockTest.class);
    since_1_5.add(JampMasterTest.class);
    since_1_5.add(JampParallelSyntaxTest.class);
    since_1_5.add(JampPrivateTest.class);
    since_1_5.add(JampReductionTest.class);
    since_1_5.add(JampScheduleTest.class);
    since_1_5.add(JampSectionsSyntaxTest.class);
    since_1_5.add(JampManagedTest.class);
    since_1_5.add(JampSpecification25Test.class);

    // Build final test suite
    TestSuite all = new TestSuite(TestAll.class.getName());
    int possibleComplianceLevels = AbstractCompilerTest.getPossibleComplianceLevels();
    if ((possibleComplianceLevels & AbstractCompilerTest.F_1_3) != 0) {
        ArrayList tests_1_3 = (ArrayList) standardTests.clone();
        // Reset forgotten subsets tests
        TestCase.TESTS_PREFIX = null;// w ww. j  av a  2 s  . c  om
        TestCase.TESTS_NAMES = null;
        TestCase.TESTS_NUMBERS = null;
        TestCase.TESTS_RANGE = null;
        TestCase.RUN_ONLY_ID = null;
        all.addTest(
                AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_3, tests_1_3));
    }
    if ((possibleComplianceLevels & AbstractCompilerTest.F_1_4) != 0) {
        ArrayList tests_1_4 = (ArrayList) standardTests.clone();
        tests_1_4.addAll(since_1_4);
        // Reset forgotten subsets tests
        TestCase.TESTS_PREFIX = null;
        TestCase.TESTS_NAMES = null;
        TestCase.TESTS_NUMBERS = null;
        TestCase.TESTS_RANGE = null;
        TestCase.RUN_ONLY_ID = null;
        all.addTest(
                AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_4, tests_1_4));
    }
    if ((possibleComplianceLevels & AbstractCompilerTest.F_1_5) != 0) {
        ArrayList tests_1_5 = (ArrayList) standardTests.clone();
        tests_1_5.addAll(since_1_4);
        tests_1_5.addAll(since_1_5);
        // Reset forgotten subsets tests
        TestCase.TESTS_PREFIX = null;
        TestCase.TESTS_NAMES = null;
        TestCase.TESTS_NUMBERS = null;
        TestCase.TESTS_RANGE = null;
        TestCase.RUN_ONLY_ID = null;
        all.addTest(
                AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_5, tests_1_5));
    }
    if ((possibleComplianceLevels & AbstractCompilerTest.F_1_6) != 0) {
        ArrayList tests_1_6 = (ArrayList) standardTests.clone();
        tests_1_6.addAll(since_1_4);
        tests_1_6.addAll(since_1_5);
        tests_1_6.addAll(since_1_6);
        // Reset forgotten subsets tests
        TestCase.TESTS_PREFIX = null;
        TestCase.TESTS_NAMES = null;
        TestCase.TESTS_NUMBERS = null;
        TestCase.TESTS_RANGE = null;
        TestCase.RUN_ONLY_ID = null;
        all.addTest(
                AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_6, tests_1_6));
    }
    if ((possibleComplianceLevels & AbstractCompilerTest.F_1_7) != 0) {
        ArrayList tests_1_7 = (ArrayList) standardTests.clone();
        tests_1_7.addAll(since_1_4);
        tests_1_7.addAll(since_1_5);
        tests_1_7.addAll(since_1_6);
        // Reset forgotten subsets tests
        TestCase.TESTS_PREFIX = null;
        TestCase.TESTS_NAMES = null;
        TestCase.TESTS_NUMBERS = null;
        TestCase.TESTS_RANGE = null;
        TestCase.RUN_ONLY_ID = null;
        all.addTest(
                AbstractCompilerTest.buildComplianceTestSuite(AbstractCompilerTest.COMPLIANCE_1_7, tests_1_7));
    }
    return all;
}

From source file:org.eclipse.objectteams.otdt.tests.AbstractJavaModelTests.java

License:Open Source License

protected String[] get15LibraryIfNeeded(String compliance) throws JavaModelException, IOException {
    if (compliance.charAt(compliance.length() - 1) >= '5'
            && (AbstractCompilerTest.getPossibleComplianceLevels() & AbstractCompilerTest.F_1_5) == 0) {
        // ensure that the JCL 15 lib is setup (i.e. that the jclMin15.jar is copied)
        setUpJCLClasspathVariables("1.5");
        return new String[] { getExternalJCLPathString("1.5") };
    }//from  w ww .j  a v a  2s  . co m
    return null;
}

From source file:org.eclipse.pde.api.tools.builder.tests.ApiTestingEnvironment.java

License:Open Source License

/**
 * Sets the given compliance on the given project.
 * //  www.  j a  v a  2 s  . co m
 * @param project
 * @param compliance
 */
public void setProjectCompliance(IJavaProject project, String compliance) {
    int requiredComplianceFlag = 0;
    String compilerVersion = null;
    if (JavaCore.VERSION_1_4.equals(compliance)) {
        requiredComplianceFlag = AbstractCompilerTest.F_1_4;
        compilerVersion = JavaCore.VERSION_1_4;
    } else if (JavaCore.VERSION_1_5.equals(compliance)) {
        requiredComplianceFlag = AbstractCompilerTest.F_1_5;
        compilerVersion = JavaCore.VERSION_1_5;
    } else if (JavaCore.VERSION_1_6.equals(compliance)) {
        requiredComplianceFlag = AbstractCompilerTest.F_1_6;
        compilerVersion = JavaCore.VERSION_1_6;
    } else if (JavaCore.VERSION_1_7.equals(compliance)) {
        requiredComplianceFlag = AbstractCompilerTest.F_1_7;
        compilerVersion = JavaCore.VERSION_1_7;
    } else if (JavaCore.VERSION_1_8.equals(compliance)) {
        requiredComplianceFlag = AbstractCompilerTest.F_1_8;
        compilerVersion = JavaCore.VERSION_1_8;
    } else if (!JavaCore.VERSION_1_4.equals(compliance) && !JavaCore.VERSION_1_3.equals(compliance)) {
        throw new UnsupportedOperationException(
                "Test framework doesn't support compliance level: " + compliance); //$NON-NLS-1$
    }
    if (requiredComplianceFlag != 0) {
        if ((AbstractCompilerTest.getPossibleComplianceLevels() & requiredComplianceFlag) == 0) {
            throw new RuntimeException("This test requires a " + compliance + " JRE"); //$NON-NLS-1$ //$NON-NLS-2$
        }
        HashMap<String, String> options = new HashMap<String, String>();
        options.put(JavaCore.COMPILER_COMPLIANCE, compilerVersion);
        options.put(JavaCore.COMPILER_SOURCE, compilerVersion);
        options.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, compilerVersion);
        project.setOptions(options);
    }
}