Java Code Examples for org.junit.jupiter.api.Assumptions#assumeFalse()

The following examples show how to use org.junit.jupiter.api.Assumptions#assumeFalse() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScrUpdateAlertTest.java    From PolyGlot with MIT License 6 votes vote down vote up
public ScrUpdateAlertTest() {
        Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());
        
            try {
                // TODO: Re-enstate this later when I have network access...
                // TODO: Rewrite so that these are skipped when there is no internet onnection (use Assumptions as above)
//                updateAlert = new ScrUpdateAlert(false, DummyCore.newCore());
            } catch (Exception e) {
                boolean noConnection = e.getLocalizedMessage().contains("No Internet connection detected.");
                
                Assumptions.assumeFalse(noConnection);
                
                if (!noConnection) {
                    fail(e);
                }
            }
    }
 
Example 2
Source File: GradleReportParserFunctionalTest.java    From synopsys-detect with Apache License 2.0 6 votes vote down vote up
@Test
void extractCodeLocationTest() {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS); //Does not work on windows due to path issues.

    final GradleReportParser gradleReportParser = new GradleReportParser();
    final Optional<GradleReport> gradleReport = gradleReportParser.parseReport(FunctionalTestFiles.asFile("/gradle/dependencyGraph.txt"));
    Assertions.assertTrue(gradleReport.isPresent());
    final GradleReportTransformer transformer = new GradleReportTransformer(new ExternalIdFactory());
    final CodeLocation codeLocation = transformer.transform(gradleReport.get());
    Assertions.assertNotNull(codeLocation);

    Assertions.assertEquals("hub-detect", gradleReport.get().getProjectName());
    Assertions.assertEquals("2.0.0-SNAPSHOT", gradleReport.get().getProjectVersionName());

    final String actual = new Gson().toJson(codeLocation);

    try {
        JSONAssert.assertEquals(FunctionalTestFiles.asString("/gradle/dependencyGraph-expected.json"), actual, false);
    } catch (final JSONException e) {
        throw new RuntimeException(e);
    }
}
 
Example 3
Source File: PipelinesTest.java    From synopsys-detect with Apache License 2.0 6 votes vote down vote up
@Test
public void testMavenInstall() throws IntegrationException {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);

    final List<String> userProvidedCqueryAdditionalOptions = null;

    final MutableDependencyGraph dependencyGraph = doTest(WorkspaceRule.MAVEN_INSTALL, MAVEN_INSTALL_STANDARD_BAZEL_COMMAND_ARGS, userProvidedCqueryAdditionalOptions, MAVEN_INSTALL_CQUERY_OUTPUT_SIMPLE);
    assertEquals(8, dependencyGraph.getRootDependencies().size());
    int foundCount = 0;
    for (final Dependency dependency : dependencyGraph.getRootDependencies()) {
        if ("com.google.guava".equals(dependency.getExternalId().getGroup()) &&
                "guava".equals(dependency.getExternalId().getName()) &&
                "27.0-jre".equals(dependency.getExternalId().getVersion())) {
            foundCount++;
        }
        if ("com.google.code.findbugs".equals(dependency.getExternalId().getGroup()) &&
                "jsr305".equals(dependency.getExternalId().getName()) &&
                "3.0.2".equals(dependency.getExternalId().getVersion())) {
            foundCount++;
        }
    }
    assertEquals(2, foundCount);
}
 
Example 4
Source File: PipelinesTest.java    From synopsys-detect with Apache License 2.0 6 votes vote down vote up
@Test
public void testMavenInstallMixedTags() throws IntegrationException {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);

    final List<String> userProvidedCqueryAdditionalOptions = null;

    final MutableDependencyGraph dependencyGraph = doTest(WorkspaceRule.MAVEN_INSTALL, MAVEN_INSTALL_STANDARD_BAZEL_COMMAND_ARGS, userProvidedCqueryAdditionalOptions, MAVEN_INSTALL_OUTPUT_MIXED_TAGS);
    assertEquals(2, dependencyGraph.getRootDependencies().size());
    int foundCount = 0;
    for (final Dependency dependency : dependencyGraph.getRootDependencies()) {
        if ("com.company.thing".equals(dependency.getExternalId().getGroup()) &&
                "thing-common-client".equals(dependency.getExternalId().getName()) &&
                "2.100.0".equals(dependency.getExternalId().getVersion())) {
            foundCount++;
        }
        if ("javax.servlet".equals(dependency.getExternalId().getGroup()) &&
                "javax.servlet-api".equals(dependency.getExternalId().getName()) &&
                "3.0.1".equals(dependency.getExternalId().getVersion())) {
            foundCount++;
        }
    }
    assertEquals(2, foundCount);
}
 
Example 5
Source File: PipelinesTest.java    From synopsys-detect with Apache License 2.0 6 votes vote down vote up
@Test
public void testMavenInstallMixedTagsReversedOrder() throws IntegrationException {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);

    final List<String> userProvidedCqueryAdditionalOptions = null;

    final MutableDependencyGraph dependencyGraph = doTest(WorkspaceRule.MAVEN_INSTALL, MAVEN_INSTALL_STANDARD_BAZEL_COMMAND_ARGS, userProvidedCqueryAdditionalOptions, MAVEN_INSTALL_OUTPUT_MIXED_TAGS_REVERSED_ORDER);
    assertEquals(1, dependencyGraph.getRootDependencies().size());
    int foundCount = 0;
    for (final Dependency dependency : dependencyGraph.getRootDependencies()) {
        if ("com.company.thing".equals(dependency.getExternalId().getGroup()) &&
                "thing-common-client".equals(dependency.getExternalId().getName()) &&
                "2.100.0".equals(dependency.getExternalId().getVersion())) {
            foundCount++;
        }
    }
    assertEquals(1, foundCount);
}
 
Example 6
Source File: PipelinesTest.java    From synopsys-detect with Apache License 2.0 6 votes vote down vote up
@Test
public void haskellCabalLibraryTest() throws IntegrationException {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);

    final List<String> userProvidedCqueryAdditionalOptions = null;

    final MutableDependencyGraph dependencyGraph = doTest(WorkspaceRule.HASKELL_CABAL_LIBRARY,
        HASKELL_CABAL_LIBRARY_STANDARD_BAZEL_COMMAND_ARGS, userProvidedCqueryAdditionalOptions, HASKELL_CABAL_LIBRARY_JSONPROTO);
    assertEquals(1, dependencyGraph.getRootDependencies().size());
    int foundCount = 0;
    for (final Dependency dependency : dependencyGraph.getRootDependencies()) {
        if ("optparse-applicative".equals(dependency.getExternalId().getName()) &&
                "0.14.3.0".equals(dependency.getExternalId().getVersion())) {
            foundCount++;
        }
    }
    assertEquals(1, foundCount);
}
 
Example 7
Source File: FormattedTextHelperTest.java    From PolyGlot with MIT License 5 votes vote down vote up
public FormattedTextHelperTest() {
    Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());
    
    System.out.println("FormattedTextHelperTest.FormattedTextHelperTest");
    core = DummyCore.newCore();
    try {
        core.readFile(PGTUtil.TESTRESOURCES + "Lodenkur_TEST.pgd");
    } catch (IOException | IllegalStateException e) {
        IOHandler.writeErrorLog(e, "FORMATTEDTEXTHELPERTEST");
    }
}
 
Example 8
Source File: SoundRecorderTest.java    From PolyGlot with MIT License 5 votes vote down vote up
@Test
public void testSoundRecordingSuite() {
    Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());
    
    System.out.println("SoundRecorderTest.testSoundRecordingSuite");
    
    ImageIcon playButtonUp = PGTUtil.getButtonSizeIcon(new ImageIcon(getClass().getResource(PGTUtil.PLAY_BUTTON_UP)));
    ImageIcon playButtonDown = PGTUtil.getButtonSizeIcon(new ImageIcon(getClass().getResource(PGTUtil.PLAY_BUTTON_DOWN)));
    ImageIcon recordButtonUp = PGTUtil.getButtonSizeIcon(new ImageIcon(getClass().getResource(PGTUtil.RECORD_BUTTON_UP)));
    ImageIcon recordButtonDown = PGTUtil.getButtonSizeIcon(new ImageIcon(getClass().getResource(PGTUtil.RECORD_BUTTON_DOWN)));
    
    try {
        SoundRecorder recorder = new SoundRecorder(null);
        recorder.setButtons(new JButton(), new JButton(), playButtonUp, playButtonDown, recordButtonUp, recordButtonDown);
        recorder.setTimer(new JTextField());
        recorder.setSlider(new JSlider());
        recorder.beginRecording();
        Thread.sleep(1000);
        recorder.endRecording();
        byte[] sound = recorder.getSound();
        recorder.setSound(sound);
        recorder.playPause();
        assertTrue(recorder.isPlaying());
    } catch (Exception e) {
        fail(e);
    } 
}
 
Example 9
Source File: IPAHandlerTest.java    From PolyGlot with MIT License 5 votes vote down vote up
@Test
public void testPlaySounds() {
    Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());

    System.out.println("IPAHandlerTest.testPlaySounds");
    IPAHandler handler = new IPAHandler(null);

    try {
        Class<?> myClass = handler.getClass();
        Field field = myClass.getDeclaredField("charMap");
        field.setAccessible(true);
        Map<String, String> charMap = (Map<String, String>)field.get(handler);

        field = myClass.getDeclaredField("soundRecorder");
        field.setAccessible(true);
        SoundRecorder soundRecorder = (SoundRecorder)field.get(handler);

        // only test playing the first sounds of each library (just test the rest exist)
        String firstSound = (String)charMap.values().toArray()[0];

        soundRecorder.playAudioFile(PGTUtil.IPA_SOUNDS_LOCATION + PGTUtil.UCLA_WAV_LOCATION + firstSound + PGTUtil.WAV_SUFFIX);
        soundRecorder.playAudioFile(PGTUtil.IPA_SOUNDS_LOCATION + PGTUtil.WIKI_WAV_LOCATION + firstSound + PGTUtil.WAV_SUFFIX);
    } catch (Exception e) {
        IOHandler.writeErrorLog(e, e.getLocalizedMessage());
        fail(e);
    }
}
 
Example 10
Source File: IPAHandlerTest.java    From PolyGlot with MIT License 5 votes vote down vote up
@Test
public void testPlayProcWiki() {
    Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());
    
    System.out.println("IPAHandlerTest.testPlayProcWiki");
    
    IPAHandler handler = new IPAHandler(null);
    
    try {
        handler.playChar("a", IPAHandler.IPALibrary.WIKI_IPA);
    } catch (Exception e) {
        fail(e);
    }
}
 
Example 11
Source File: UsersRepositoryContract.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Test
default void nonVirtualHostedUsersRepositoryShouldUseLocalPartAsUsername() throws Exception {
    // Some implementations do not support changing virtual hosting value
    Assumptions.assumeFalse(testee().supportVirtualHosting());

    assertThat(testee().getUsername(new MailAddress("local@domain"))).isEqualTo(Username.of("local"));
}
 
Example 12
Source File: MetadataImportBasedOnSchemasTest.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@ParameterizedTest
@MethodSource( "getSchemaEndpoints" )
public void postBasedOnSchema( String endpoint, String schema )
{
    RestApiActions apiActions = new RestApiActions( endpoint );

    List blacklistedEndpoints = Arrays.asList( "jobConfigurations",
        "relationshipTypes",
        "messageConversations",
        "users" ); //blacklisted because contains conditionally required properties, which are not marked as required

    List<SchemaProperty> schemaProperties = schemasActions.getRequiredProperties( schema );

    Assumptions.assumeFalse( blacklistedEndpoints.contains( endpoint ), "N/A test case - blacklisted endpoint." );
    Assumptions.assumeFalse(
        schemaProperties.stream().anyMatch( schemaProperty -> schemaProperty.getPropertyType() == PropertyType.COMPLEX ),
        "N/A test case - body would require COMPLEX objects." );

    // post
    JsonObject object = DataGenerator.generateObjectMatchingSchema( schemaProperties );
    ApiResponse response = apiActions.post( object );

    // validate response;
    ResponseValidationHelper.validateObjectCreation( response );

    // validate removal;
    response = apiActions.delete( response.extractUid() );

    ResponseValidationHelper.validateObjectRemoval( response, endpoint + " was not deleted" );
}
 
Example 13
Source File: SynthesisCommandsTests.java    From workcraft with MIT License 5 votes vote down vote up
@Test
public void duplicatorCscHierStandardCelementSynthesis() {
    // FIXME: Skip this test on Windows as petrify.exe produces significantly different circuit
    Assumptions.assumeFalse(DesktopApi.getOs().isWindows());
    String workName = PackageUtils.getPackagePath(getClass(), "duplicator-hier-csc.stg.work");
    testStandardCelementSynthesisCommand(workName, 8, 9);
}
 
Example 14
Source File: DetectorFinderTest.java    From synopsys-detect with Apache License 2.0 5 votes vote down vote up
@Test
@DisabledOnOs(WINDOWS) //TODO: See if we can fix on windows.
public void testSimple() throws DetectorFinderDirectoryListException {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);

    final File initialDirectory = initialDirectoryPath.toFile();
    final File subDir = new File(initialDirectory, "testSimple");
    subDir.mkdirs();

    final File subSubDir1 = new File(subDir, "subSubDir1");
    subSubDir1.mkdir();

    final File subSubDir2 = new File(subDir, "subSubDir2");
    subSubDir2.mkdir();

    final DetectorRuleSet detectorRuleSet = new DetectorRuleSet(new ArrayList<>(0), new HashMap<>(0), new HashMap<>());
    final Predicate<File> fileFilter = f -> true;
    final int maximumDepth = 10;
    final DetectorFinderOptions options = new DetectorFinderOptions(fileFilter, maximumDepth);

    final DetectorFinder finder = new DetectorFinder();
    final Optional<DetectorEvaluationTree> tree = finder.findDetectors(initialDirectory, detectorRuleSet, options);

    // make sure both dirs were found
    final Set<DetectorEvaluationTree> testDirs = tree.get().getChildren();
    DetectorEvaluationTree simpleTestDir = null;
    for (final DetectorEvaluationTree testDir : testDirs) {
        if (testDir.getDirectory().getName().equals("testSimple")) {
            simpleTestDir = testDir;
            break;
        }
    }
    final Set<DetectorEvaluationTree> subDirResults = simpleTestDir.getChildren();
    assertEquals(2, subDirResults.size());
    final String subDirContentsName = subDirResults.iterator().next().getDirectory().getName();
    assertTrue(subDirContentsName.startsWith("subSubDir"));
}
 
Example 15
Source File: NativeImageIT.java    From quarkus with Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the {@code java.library.path} can be overridden/configurable by passing the system property
 * when launching the generated application's native image.
 *
 * @throws Exception
 */
@Test
public void testJavaLibraryPathAtRuntime() throws Exception {
    final File testDir = initProject("projects/native-image-app", "projects/native-image-app-output");
    final RunningInvoker running = new RunningInvoker(testDir, false);

    // trigger mvn package -Pnative -Dquarkus.ssl.native=true
    final String[] mvnArgs = new String[] { "package", "-DskipTests", "-Pnative", "-Dquarkus.ssl.native=true" };
    final MavenProcessInvocationResult result = running.execute(Arrays.asList(mvnArgs), Collections.emptyMap());
    await().atMost(5, TimeUnit.MINUTES).until(() -> result.getProcess() != null && !result.getProcess().isAlive());
    final String processLog = running.log();
    try {
        assertThat(processLog).containsIgnoringCase("BUILD SUCCESS");
    } catch (AssertionError ae) {
        // skip this test (instead of failing), if the native-image command wasn't available.
        // Bit brittle to rely on the log message, but it's OK in the context of this test
        Assumptions.assumeFalse(processLog.contains("Cannot find the `native-image"),
                "Skipping test since native-image tool isn't available");
        // native-image command was available but the build failed for some reason, throw the original error
        throw ae;
    } finally {
        running.stop();
    }

    // now that the native image is built, run it
    final Path nativeImageRunner = testDir.toPath().toAbsolutePath().resolve(Paths.get("target/acme-1.0-SNAPSHOT-runner"));
    final Path tmpDir = Files.createTempDirectory("native-image-test");
    tmpDir.toFile().deleteOnExit();
    final Process nativeImageRunWithAdditionalLibPath = runNativeImage(nativeImageRunner,
            new String[] { "-Djava.library.path=" + tmpDir.toString() });
    try {
        final String response = DevModeTestUtils.getHttpResponse("/hello/javaLibraryPath");
        Assertions.assertTrue(response.contains(tmpDir.toString()),
                "Response " + response + " for java.library.path was expected to contain the " + tmpDir + ", but didn't");
    } finally {
        nativeImageRunWithAdditionalLibPath.destroy();
    }

}
 
Example 16
Source File: IPAHandlerTest.java    From PolyGlot with MIT License 5 votes vote down vote up
@Test
public void testPlayProcUcla() {
    Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());
    
    System.out.println("IPAHandlerTest.testPlayProcUcla");
    
    IPAHandler handler = new IPAHandler(null);
    
    try {
        handler.playChar("a", IPAHandler.IPALibrary.UCLA_IPA);
    } catch (Exception e) {
        fail(e);
    }
}
 
Example 17
Source File: PLanguageStatsTest.java    From PolyGlot with MIT License 4 votes vote down vote up
public PLanguageStatsTest() {
    Assumptions.assumeFalse(GraphicsEnvironment.isHeadless());
}
 
Example 18
Source File: SDNTest.java    From SDNotify with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void getPidReturnsInteger() {
    Assumptions.assumeFalse(Platform.isWindows());
    int pid = CLibrary.clib.getpid();
    assert (pid > 1);
}
 
Example 19
Source File: BazelExtractorTest.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@Test
public void testMavenInstall() throws ExecutableRunnerException, IntegrationException {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);

    final BazelCommandExecutor bazelCommandExecutor = Mockito.mock(BazelCommandExecutor.class);
    final BazelVariableSubstitutor bazelVariableSubstitutor = Mockito.mock(BazelVariableSubstitutor.class);
    final ExternalIdFactory externalIdFactory = new ExternalIdFactory();
    final Pipelines pipelines = new Pipelines(bazelCommandExecutor, bazelVariableSubstitutor, externalIdFactory);
    final File workspaceDir = new File(".");
    final ExecutableRunner executableRunner = Mockito.mock(ExecutableRunner.class);
    final BazelWorkspace bazelWorkspace = Mockito.mock(BazelWorkspace.class);
    Mockito.when(bazelWorkspace.getDependencyRule()).thenReturn(WorkspaceRule.MAVEN_INSTALL);
    final WorkspaceRuleChooser workspaceRuleChooser = Mockito.mock(WorkspaceRuleChooser.class);
    Mockito.when(workspaceRuleChooser.choose(Mockito.eq(WorkspaceRule.MAVEN_INSTALL), Mockito.isNull())).thenReturn(WorkspaceRule.MAVEN_INSTALL);
    final BazelExtractor bazelExtractor = new BazelExtractor(executableRunner, externalIdFactory, workspaceRuleChooser);
    final File bazelExe = new File("/usr/bin/bazel");

    // bazel cquery --noimplicit_deps "kind(j.*import, deps(//:ProjectRunner))" --output build
    final List<String> bazelArgsGetDependencies = new ArrayList<>();
    bazelArgsGetDependencies.add("cquery");
    bazelArgsGetDependencies.add("--noimplicit_deps");
    bazelArgsGetDependencies.add("kind(j.*import, deps(//:ProjectRunner))");
    bazelArgsGetDependencies.add("--output");
    bazelArgsGetDependencies.add("build");
    final ExecutableOutput bazelCmdExecutableOutputGetDependencies = Mockito.mock(ExecutableOutput.class);
    Mockito.when(bazelCmdExecutableOutputGetDependencies.getReturnCode()).thenReturn(0);
    Mockito.when(bazelCmdExecutableOutputGetDependencies.getStandardOutput()).thenReturn(
        "jvm_import(\n  name = \"com_google_guava_failureaccess\",\n" +
            "  tags = [\"maven_coordinates=com.google.guava:failureaccess:1.0\"],\n" +
            "  tags = [\"maven_coordinates=com.google.errorprone:error_prone_annotations:2.2.0\"],");
    Mockito.when(executableRunner.execute(workspaceDir, bazelExe, bazelArgsGetDependencies)).thenReturn(bazelCmdExecutableOutputGetDependencies);

    final Extraction result = bazelExtractor.extract(bazelExe, workspaceDir, bazelWorkspace, "//:ProjectRunner", new BazelProjectNameGenerator(), null, null);

    assertEquals(1, result.getCodeLocations().size());
    final Set<Dependency> dependencies = result.getCodeLocations().get(0).getDependencyGraph().getRootDependencies();
    assertEquals(2, dependencies.size());
    boolean foundFailureAccess = false;
    boolean foundErrorProneAnnotations = false;
    for (final Dependency dep : dependencies) {
        System.out.printf("externalId: %s\n", dep.getExternalId());
        if ("failureaccess".equals(dep.getExternalId().getName())) {
            foundFailureAccess = true;
        }
        if ("error_prone_annotations".equals(dep.getExternalId().getName())) {
            foundErrorProneAnnotations = true;
        }
    }
    assertTrue(foundFailureAccess);
    assertTrue(foundErrorProneAnnotations);
}
 
Example 20
Source File: DetectorFinderTest.java    From synopsys-detect with Apache License 2.0 4 votes vote down vote up
@Test
@DisabledOnOs(WINDOWS) //TODO: See if we can fix on windows.
public void testSymLinksNotFollowed() throws IOException, DetectorFinderDirectoryListException {
    Assumptions.assumeFalse(SystemUtils.IS_OS_WINDOWS);

    // Create a subDir with a symlink that loops back to its parent
    final File initialDirectory = initialDirectoryPath.toFile();
    final File subDir = new File(initialDirectory, "testSymLinksNotFollowed");
    subDir.mkdirs();
    final File link = new File(subDir, "linkToInitial");
    final Path linkPath = link.toPath();
    Files.createSymbolicLink(linkPath, initialDirectoryPath);

    final File regularDir = new File(subDir, "regularDir");
    regularDir.mkdir();

    final DetectorRuleSet detectorRuleSet = new DetectorRuleSet(new ArrayList<>(0), new HashMap<>(0), new HashMap<>(0));
    final Predicate<File> fileFilter = f -> {
        return true;
    };
    final int maximumDepth = 10;
    final DetectorFinderOptions options = new DetectorFinderOptions(fileFilter, maximumDepth);

    final DetectorFinder finder = new DetectorFinder();
    final Optional<DetectorEvaluationTree> tree = finder.findDetectors(initialDirectory, detectorRuleSet, options);

    // make sure the symlink was omitted from results
    //        final Set<DetectorEvaluationTree> subDirResults = tree.get().getChildren().iterator().next().getChildren();
    final Set<DetectorEvaluationTree> testDirs = tree.get().getChildren();
    DetectorEvaluationTree symLinkTestDir = null;
    for (final DetectorEvaluationTree testDir : testDirs) {
        if (testDir.getDirectory().getName().equals("testSymLinksNotFollowed")) {
            symLinkTestDir = testDir;
            break;
        }
    }
    final Set<DetectorEvaluationTree> subDirResults = symLinkTestDir.getChildren();

    assertEquals(1, subDirResults.size());
    final String subDirContentsName = subDirResults.iterator().next().getDirectory().getName();
    assertEquals("regularDir", subDirContentsName);
}