Search in sources :

Example 1 with DisabledIfEnvironmentVariable

use of org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable in project jgnash by ccavanaugh.

the class YahooEventParserTest method testParser.

@SuppressWarnings("ConstantConditions")
@Test
// disable on Travis-CI
@DisabledIfEnvironmentVariable(named = "CI", matches = "true")
@Disabled
void testParser() throws IOException {
    if (System.getenv(GITHUB_ACTION) != null) {
        // don't test with Github actions
        return;
    }
    for (int i = 0; i < ATTEMPTS; i++) {
        // try multiple times to pass
        final SecurityNode ibm = new SecurityNode(e.getDefaultCurrency());
        ibm.setSymbol("IBM");
        ibm.setScale((byte) 2);
        ibm.setQuoteSource(QuoteSource.YAHOO);
        final SecurityHistoryNode historyNode = new SecurityHistoryNode(LocalDate.of(1962, Month.JANUARY, 1), BigDecimal.TEN, 1000, BigDecimal.TEN, BigDecimal.TEN);
        e.addSecurity(ibm);
        e.addSecurityHistory(ibm, historyNode);
        QuoteSource quoteSource = ibm.getQuoteSource();
        Objects.requireNonNull(quoteSource);
        SecurityParser securityParser = quoteSource.getParser();
        Objects.requireNonNull(securityParser);
        final Set<SecurityHistoryEvent> events = securityParser.retrieveHistoricalEvents(ibm, LocalDate.of(2015, Month.AUGUST, 22));
        assertNotNull(events);
        // size fluctuates
        if (events.size() <= 221 && events.size() >= 220) {
            assertTrue(events.size() <= 221 && events.size() >= 220);
            return;
        }
    }
    fail("Failed to pass test");
}
Also used : SecurityNode(jgnash.engine.SecurityNode) SecurityHistoryNode(jgnash.engine.SecurityHistoryNode) QuoteSource(jgnash.engine.QuoteSource) SecurityParser(jgnash.net.security.SecurityParser) SecurityHistoryEvent(jgnash.engine.SecurityHistoryEvent) AbstractEngineTest(jgnash.engine.AbstractEngineTest) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled) DisabledIfEnvironmentVariable(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)

Example 2 with DisabledIfEnvironmentVariable

use of org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable in project jgnash by ccavanaugh.

the class YahooEventParserTest method testHistoricalDownload.

@Test
// disable on Travis-CI
@DisabledIfEnvironmentVariable(named = "CI", matches = "true")
@Disabled
void testHistoricalDownload() throws IOException {
    if (System.getenv(GITHUB_ACTION) != null) {
        // don't test with Github actions
        return;
    }
    for (int i = 0; i < ATTEMPTS; i++) {
        // try multiple times to pass
        final SecurityNode ibm = new SecurityNode(e.getDefaultCurrency());
        ibm.setSymbol("IBM");
        ibm.setScale((byte) 2);
        e.addSecurity(ibm);
        // force re-authorization to prevent failed unit test
        YahooCrumbManager.clearAuthorization();
        final List<SecurityHistoryNode> events = Objects.requireNonNull(QuoteSource.YAHOO.getParser()).retrieveHistoricalPrice(ibm, LocalDate.of(2016, Month.JANUARY, 1), LocalDate.of(2016, Month.DECEMBER, 30));
        if (events.size() == 252) {
            assertEquals(252, events.size());
            return;
        }
    }
    fail("Failed to pass test");
}
Also used : SecurityNode(jgnash.engine.SecurityNode) SecurityHistoryNode(jgnash.engine.SecurityHistoryNode) AbstractEngineTest(jgnash.engine.AbstractEngineTest) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled) DisabledIfEnvironmentVariable(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)

Example 3 with DisabledIfEnvironmentVariable

use of org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable in project jgnash by ccavanaugh.

the class IEXParserTest method testHistoricalDividendsDownload.

@Test
// disable on Travis-CI
@DisabledIfEnvironmentVariable(named = "CI", matches = "true")
void testHistoricalDividendsDownload() throws IOException {
    if (System.getenv(GITHUB_ACTION) != null) {
        // don't test with Github actions
        return;
    }
    // test env must be configured with a valid token
    if (System.getenv(TEST_TOKEN) == null) {
        // don't test with Github actions
        return;
    }
    final SecurityNode spy = new SecurityNode(e.getDefaultCurrency());
    spy.setSymbol("SPY");
    spy.setScale((byte) 2);
    spy.setQuoteSource(QuoteSource.IEX_CLOUD);
    e.addSecurity(spy);
    final QuoteSource quoteSource = spy.getQuoteSource();
    assertNotNull(quoteSource);
    final SecurityParser securityParser = quoteSource.getParser();
    assertNotNull(securityParser);
    assertThat(securityParser, instanceOf(IEXParser.class));
    ((IEXParser) securityParser).setUseSandbox();
    securityParser.setTokenSupplier(() -> System.getenv(TEST_TOKEN));
    final Set<SecurityHistoryEvent> historicalEvents = securityParser.retrieveHistoricalEvents(spy, LocalDate.of(2015, Month.JANUARY, 1));
    assertNotNull(historicalEvents);
    assertEquals(1, historicalEvents.size());
}
Also used : IEXParser(jgnash.net.security.iex.IEXParser) SecurityNode(jgnash.engine.SecurityNode) QuoteSource(jgnash.engine.QuoteSource) SecurityParser(jgnash.net.security.SecurityParser) SecurityHistoryEvent(jgnash.engine.SecurityHistoryEvent) AbstractEngineTest(jgnash.engine.AbstractEngineTest) Test(org.junit.jupiter.api.Test) DisabledIfEnvironmentVariable(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)

Example 4 with DisabledIfEnvironmentVariable

use of org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable in project jPOS by jpos.

the class TSpaceTest method testNotifyReaders.

@SuppressWarnings("unchecked")
@Test
@DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = "true")
public void testNotifyReaders() {
    final Space sp = new TSpace();
    final AtomicInteger ai = new AtomicInteger(10);
    for (int i = 0; i < 10; i++) {
        new Thread() {

            public void run() {
                if (sp.rd("TEST", 5000L) != null)
                    ai.decrementAndGet();
            }
        }.start();
    }
    sp.out("TEST", Boolean.TRUE);
    ISOUtil.sleep(500L);
    assertTrue(ai.get() == 0, "Counter should be zero");
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Test(org.junit.jupiter.api.Test) DisabledIfEnvironmentVariable(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)

Example 5 with DisabledIfEnvironmentVariable

use of org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable in project apm-agent-java by elastic.

the class ReporterFactoryTest method testNotValidatingSslCertificate.

@Test
// tbh, I have no clue why
@DisabledIfEnvironmentVariable(named = "JENKINS_HOME", matches = ".*")
void testNotValidatingSslCertificate() throws IOException {
    when(configuration.isVerifyServerCert()).thenReturn(false);
    final OkHttpClient okHttpClient = reporterFactory.getOkHttpClient(configuration);
    final Response response = okHttpClient.newCall(new okhttp3.Request.Builder().url("https://localhost:" + getPort()).build()).execute();
    assertThat(response.code()).isEqualTo(200);
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(okhttp3.Response) OkHttpClient(okhttp3.OkHttpClient) Test(org.junit.jupiter.api.Test) DisabledIfEnvironmentVariable(org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)

Aggregations

Test (org.junit.jupiter.api.Test)7 DisabledIfEnvironmentVariable (org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)7 AbstractEngineTest (jgnash.engine.AbstractEngineTest)5 SecurityNode (jgnash.engine.SecurityNode)5 QuoteSource (jgnash.engine.QuoteSource)4 SecurityParser (jgnash.net.security.SecurityParser)4 SecurityHistoryEvent (jgnash.engine.SecurityHistoryEvent)3 SecurityHistoryNode (jgnash.engine.SecurityHistoryNode)3 IEXParser (jgnash.net.security.iex.IEXParser)3 Disabled (org.junit.jupiter.api.Disabled)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 OkHttpClient (okhttp3.OkHttpClient)1 Response (okhttp3.Response)1