<commit_before>/*
 * Copyright 2015 <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.parse4cn1.test.javaapplication;

import com.codename1.io.Log;
import com.codename1.ui.Display;
import com.parse4cn1.ParseException;
import com.parse4cn1.BaseParseTest;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import org.reflections.Reflections;

/**
 * A simple test app to illustrate how to create a regular Java application
 * using parse4cn1.jar.
 *
 * It executes the Parse4CN1 tests written using CodenameOne's (Java) test
 * library.
 *
 * @author sidiabale
 */
public class CN1TestJavaApplication {

    private static class Status {
        private int value = -1;
        
        public void setValue(int value) {
            this.value = value;
        }
        
        public int getValue() {
            return value;
        }
    }
    /**
     * A helper class to initialize the application's main frame.
     */
    public static class MainFrame extends JFrame {

        public MainFrame() {
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            BorderLayout layout = new BorderLayout();
            getContentPane().setLayout(layout);
            this.setSize(new Dimension(500, 500));
            this.setPreferredSize(new Dimension(500, 500));
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Status status = new Status();
        try {
            status = createAppWithoutProperContext();
//            status = createAppWithProperContext(false);
        } finally {
            System.out.println("Return code: " + status.getValue());
            System.exit(status.getValue());
        }
    }

    private static Status createAppWithoutProperContext() {
        // This approach is handy for a non-GUI application
        Status status = new Status();
        try {
            Display.init(null);
        } catch (java.awt.HeadlessException ex) {
            System.err.println("Ignoring HeadlessException: " + ex.getMessage());
        }
        status.setValue(runTests());
        Display.getInstance().exitApplication();
        return status;
    }

    private static Status createAppWithProperContext(final boolean aShowFrame) {<commit_msg>Exception caused a failure; now checking return code again<commit_after>/*
 * Copyright 2015 <NAME>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.parse4cn1.test.javaapplication;

import com.codename1.io.Log;
import com.codename1.ui.Display;
import com.parse4cn1.ParseException;
import com.parse4cn1.BaseParseTest;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import org.reflections.Reflections;

/**
 * A simple test app to illustrate how to create a regular Java application
 * using parse4cn1.jar.
 *
 * It executes the Parse4CN1 tests written using CodenameOne's (Java) test
 * library.
 *
 * @author sidiabale
 */
public class CN1TestJavaApplication {

    private static class Status {
        private int value = -1;
        
        public void setValue(int value) {
            this.value = value;
        }
        
        public int getValue() {
            return value;
        }
    }
    /**
     * A helper class to initialize the application's main frame.
     */
    public static class MainFrame extends JFrame {

        public MainFrame() {
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            BorderLayout layout = new BorderLayout();
            getContentPane().setLayout(layout);
            this.setSize(new Dimension(500, 500));
            this.setPreferredSize(new Dimension(500, 500));
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        
        Status status = new Status();
        try {
            status = createAppWithoutProperContext();
//            status = createAppWithProperContext(false);
        } finally {
            System.out.println("Return code: " + status.getValue());
            System.exit(status.getValue());
        }
    }

    private static Status createAppWithoutProperContext() {
        // This approach is handy for a non-GUI application
        Status status = new Status();
        try {
            Display.init(null);
        } catch (java.awt.HeadlessException ex) {
            System.err.println("Ignoring HeadlessException: " + ex.getMessage());
        }
        status.setValue(runTests());
//        Display.getInstance().exitApplication();
        return status;
    }

    private static Status createAppWithProperContext(final boolean aShowFrame) {
{'fraction_non_alphanumeric': 0.09215462404175502, 'fraction_numerical': 0.01109117599086609, 'mean_word_length': 2.6478286734086853, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3755871', 'n_tokens_mistral': 1651, 'n_tokens_neox': 1604, 'n_words': 508}