001/*
002 * Copyright 2019-2021 M. Sean Gilligan.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package app.supernaut.fx.test;
017
018import app.supernaut.fx.ApplicationDelegate;
019import javafx.application.Platform;
020import javafx.stage.Stage;
021import org.slf4j.Logger;
022import org.slf4j.LoggerFactory;
023
024/**
025 * No-op ApplicationDelegate which exits immediately (used for testing)
026 */
027public final class NoopAppDelegate implements ApplicationDelegate {
028    private static final Logger log = LoggerFactory.getLogger(NoopAppDelegate.class);
029
030    @Override
031    public void start(Stage primaryStage) {
032        log.info("Entered");
033        primaryStage.show();
034        noop();
035    }
036    
037    private void noop() {
038        log.info("Calling Plaform.exit()");
039        Platform.exit();    // Exit OpenJFX
040    }
041}