<commit_before>package org.lantern;

import static org.junit.Assert.assertTrue;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Test;
import org.lastbamboo.common.portmapping.PortMapListener;
import org.lastbamboo.common.portmapping.PortMappingProtocol;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class NatPmpTest {
    private final Logger log = LoggerFactory.getLogger(getClass());
    
    @Test 
    public void testNatPmp() throws Exception {
        final NatPmpImpl pmp =
            new NatPmpImpl(TestUtils.getStatsTracker());
        final AtomicInteger ai = new AtomicInteger(-1);
        final AtomicBoolean error = new AtomicBoolean();
        final PortMapListener portMapListener = new PortMapListener() {
            
            @Override
            public void onPortMapError() {
                error.set(true);
                synchronized(ai) {
                    ai.notifyAll();
                }
            }
            
            @Override
            public void onPortMap(final int port) {
                ai.set(port);<commit_msg>do not test nat-pmp on public networks<commit_after>package org.lantern;

import static org.junit.Assert.assertTrue;

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;

import org.junit.Test;
import org.lastbamboo.common.portmapping.PortMapListener;
import org.lastbamboo.common.portmapping.PortMappingProtocol;
import org.littleshoot.util.NetworkUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class NatPmpTest {
    private final Logger log = LoggerFactory.getLogger(getClass());
    
    @Test 
    public void testNatPmp() throws Exception {
        if (NetworkUtils.isPublicAddress()) {
            log.debug("Not testing NAT-PMP on public network");
            return;
        }

        final NatPmpImpl pmp =
            new NatPmpImpl(TestUtils.getStatsTracker());
        final AtomicInteger ai = new AtomicInteger(-1);
        final AtomicBoolean error = new AtomicBoolean();
        final PortMapListener portMapListener = new PortMapListener() {
            
            @Override
            public void onPortMapError() {
                error.set(true);
                synchronized(ai) {
                    ai.notifyAll();
                }
            }
            
            @Override
            public void onPortMap(final int port) {
                ai.set(port);
{'fraction_non_alphanumeric': 0.08326724821570182, 'fraction_numerical': 0.0023790642347343376, 'mean_word_length': 2.3023560209424083, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2967017', 'n_tokens_mistral': 686, 'n_tokens_neox': 664, 'n_words': 150}