Search in sources :

Example 86 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.

the class FtpMonitorTest method testMonitorFailureWithNoResponse.

public void testMonitorFailureWithNoResponse() throws Exception {
    Thread m_serverThread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                m_serverSocket.setSoTimeout(1000);
                m_serverSocket.accept();
                Thread.sleep(3000);
            } catch (Throwable e) {
                throw new UndeclaredThrowableException(e);
            }
        }
    });
    m_serverThread.start();
    PollStatus status = doPoll();
    assertTrue("status should be unavailable (Down), but is: " + status, status.isUnavailable());
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Example 87 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.

the class FtpMonitorTest method testMonitorSuccess.

public void testMonitorSuccess() throws Exception {
    Thread m_serverThread = new Thread(new Runnable() {

        @Override
        public void run() {
            try {
                m_serverSocket.setSoTimeout(1000);
                Socket s = m_serverSocket.accept();
                s.getOutputStream().write("220 Hello!!!\r\n".getBytes());
                BufferedReader r = new BufferedReader(new InputStreamReader(s.getInputStream()));
                String command = r.readLine();
                if (command.equals("QUIT")) {
                    s.getOutputStream().write("221 See ya\r\n".getBytes());
                }
            } catch (Throwable e) {
                throw new UndeclaredThrowableException(e);
            }
        }
    });
    m_serverThread.start();
    PollStatus status = doPoll();
    assertTrue("status should be available (Up), but is: " + status, status.isAvailable());
}
Also used : PollStatus(org.opennms.netmgt.poller.PollStatus) InputStreamReader(java.io.InputStreamReader) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) BufferedReader(java.io.BufferedReader) ServerSocket(java.net.ServerSocket) Socket(java.net.Socket)

Example 88 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.

the class AvailabilityReportFullIT method testBuiltCalendarReport.

//TODO indigo: Spring Injection for DefaultRemoteRepositoryConfigDao necessary
@Ignore
@Test
public void testBuiltCalendarReport() {
    long oneHundred = 100;
    Day day;
    try {
        calendarAvailabilityCalculator.setPeriodEndDate(m_calendar.getTime());
        calendarAvailabilityCalculator.setLogoURL("wahtever");
        calendarAvailabilityCalculator.setReportFormat("PDF");
        calendarAvailabilityCalculator.setMonthFormat("calendar");
        calendarAvailabilityCalculator.setCategoryName("Network Interfaces");
        calendarAvailabilityCalculator.calculate();
        Report report = calendarAvailabilityCalculator.getReport();
        Assert.assertNotNull("report", report);
        Assert.assertNotNull("report categories", report.getCategories());
        Categories categories = report.getCategories();
        Assert.assertEquals("category count", 1, categories.getCategoryCount());
        Category category = categories.getCategory(0);
        Assert.assertEquals("category node count", Integer.valueOf(2), category.getNodeCount());
        Assert.assertEquals("category ip address count", Integer.valueOf(3), category.getIpaddrCount());
        Assert.assertEquals("category service count", Integer.valueOf(3), category.getServiceCount());
        // Section calSection = getSectionByName(category, "LastMonthsDailyAvailability");
        // First four days in month are invisible for US...
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 0, 0);
        Assert.assertNotNull("day 0,0 object", day);
        Assert.assertFalse("day 0,0 visibility", day.getVisible());
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 0, 1);
        Assert.assertNotNull("day 0,1 object", day);
        Assert.assertFalse("day 0,1 visibility", day.getVisible());
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 0, 2);
        Assert.assertNotNull("day 0,2 object", day);
        Assert.assertFalse("day 0,2 visibility", day.getVisible());
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 0, 4);
        Assert.assertNotNull("day 0,4 object", day);
        Assert.assertFalse("day 0,4 visibility", day.getVisible());
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 0, 5);
        Assert.assertNotNull("day 0,5 object", day);
        Assert.assertEquals("day 0,5 percentage value", oneHundred, day.getPctValue(), 0);
        Assert.assertTrue("day 0,5 visibility", day.getVisible());
        Assert.assertEquals("day 0,5 date", Integer.valueOf(1), day.getDate());
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 0, 6);
        Assert.assertNotNull("day 0,6 object", day);
        Assert.assertEquals("day 0,6 percentage value", 99.3056, fourDec(day.getPctValue()), 0);
        Assert.assertTrue("day 0,6 visibility", day.getVisible());
        Assert.assertEquals("day 0,6 date", Integer.valueOf(2), day.getDate());
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 1, 0);
        Assert.assertNotNull("day 1,0 object", day);
        Assert.assertEquals("day 1,0 percentage value", 97.2454, fourDec(day.getPctValue()), 0);
        Assert.assertTrue("day 1,0 visibility", day.getVisible());
        Assert.assertEquals("day 1,0 date", Integer.valueOf(3), day.getDate());
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 1, 1);
        Assert.assertNotNull("day 1,1 object", day);
        Assert.assertEquals("day 1,1 percentage value", 99.3056, fourDec(day.getPctValue()), 0);
        Assert.assertTrue("day 1,1 visibility", day.getVisible());
        Assert.assertEquals("day 1,1 date", Integer.valueOf(4), day.getDate());
        day = getCalSectionDay(category, "LastMonthsDailyAvailability", 1, 2);
        Assert.assertNotNull("day 1,2 object", day);
        Assert.assertEquals("day 1,2 percentage value", 99.3056, fourDec(day.getPctValue()), 0);
        Assert.assertTrue("day 1,2 visibility", day.getVisible());
        Assert.assertEquals("day 1,2 date", Integer.valueOf(5), day.getDate());
    } catch (Throwable e) {
        throw new UndeclaredThrowableException(e);
    }
}
Also used : UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 89 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.

the class Syslogd method onStop.

/**
     * <p>onStop</p>
     */
@Override
protected void onStop() {
    if (m_udpEventReceiver != null) {
        LOG.debug("stop: Stopping the Syslogd UDP receiver");
        try {
            m_udpEventReceiver.stop();
        } catch (InterruptedException e) {
            LOG.info("stop: Exception when stopping the Syslog UDP receiver: " + e.getMessage());
        } catch (Throwable e) {
            LOG.error("stop: Failed to stop the Syslog UDP receiver", e);
            throw new UndeclaredThrowableException(e);
        }
        LOG.debug("stop: Stopped the Syslogd UDP receiver");
    }
}
Also used : UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Example 90 with UndeclaredThrowableException

use of java.lang.reflect.UndeclaredThrowableException in project opennms by OpenNMS.

the class AvailabilityCalculatorIT method buildReport.

/*
    private int numRowsWithValue(Section section, String title, String data) {

        int rowMatched = 0;
        boolean titlematch;
        boolean datamatch;

        ClassicTable table = section.getClassicTable();
        Rows rows = table.getRows();
        Row[] row = rows.getRow();
        for (int j = 0; j < row.length; j++) {
            Value[] value = row[j].getValue();
            titlematch = false;
            datamatch = false;
            for (int k = 0; k < value.length; k++) {
                if (value[k].getType().equals("title")
                        && value[k].getContent().equals(title))
                    titlematch = true;
                if (value[k].getType().equals("data")
                        && value[k].getContent().equals(data))
                    datamatch = true;
                if (datamatch && titlematch)
                    rowMatched++;
            }
        }
        return rowMatched;
    }
    */
private Report buildReport(Calendar calendar, String calFormat) {
    Report report = null;
    //AvailabilityData availData = null;
    try {
        AvailabilityCalculator calculator = new AvailabilityCalculatorImpl();
        AvailabilityData data = new AvailabilityData();
        data.setAvailabilityDataService(new LegacyAvailabilityDataService());
        calculator.setAvailabilityData(data);
        calculator.setPeriodEndDate(m_calendar.getTime());
        calculator.setLogoURL("wahtever");
        calculator.setReportFormat("PDF");
        calculator.setMonthFormat(calFormat);
        calculator.setCategoryName("Network Interfaces");
        calculator.calculate();
        report = calculator.getReport();
    } catch (Throwable e) {
        throw new UndeclaredThrowableException(e);
    }
    return report;
}
Also used : LegacyAvailabilityDataService(org.opennms.reporting.availability.svclayer.LegacyAvailabilityDataService) UndeclaredThrowableException(java.lang.reflect.UndeclaredThrowableException)

Aggregations

UndeclaredThrowableException (java.lang.reflect.UndeclaredThrowableException)121 IOException (java.io.IOException)36 InvocationTargetException (java.lang.reflect.InvocationTargetException)14 YarnException (org.apache.hadoop.yarn.exceptions.YarnException)14 Test (org.junit.Test)12 BufferedReader (java.io.BufferedReader)10 InputStreamReader (java.io.InputStreamReader)10 ServerSocket (java.net.ServerSocket)10 Socket (java.net.Socket)9 PollStatus (org.opennms.netmgt.poller.PollStatus)9 HashMap (java.util.HashMap)8 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)7 AuthorizationException (org.apache.hadoop.security.authorize.AuthorizationException)7 BadRequestException (org.apache.hadoop.yarn.webapp.BadRequestException)7 Method (java.lang.reflect.Method)6 AccessControlException (java.security.AccessControlException)6 SQLException (java.sql.SQLException)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 UserGroupInformation (org.apache.hadoop.security.UserGroupInformation)6