Search in sources :

Example 66 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestPutRpc method executeRuntimeException.

@SuppressWarnings("unchecked")
@Test(expected = RuntimeException.class)
public void executeRuntimeException() throws Exception {
    when(tsdb.addPoint(anyString(), anyLong(), anyLong(), (HashMap<String, String>) any())).thenThrow(new RuntimeException("Fail!"));
    final PutDataPointRpc put = new PutDataPointRpc();
    final Channel chan = NettyMocks.fakeChannel();
    put.execute(tsdb, chan, new String[] { "put", "doesnotexist", "1365465600", "42", "host=web01" });
}
Also used : Channel(org.jboss.netty.channel.Channel) Matchers.anyString(org.mockito.Matchers.anyString) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 67 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestPutRpc method execute.

// Socket RPC Tests ------------------------------------
@Test
public void execute() throws Exception {
    final PutDataPointRpc put = new PutDataPointRpc();
    final Channel chan = NettyMocks.fakeChannel();
    assertNotNull(put.execute(tsdb, chan, new String[] { "put", "sys.cpu.nice", "1365465600", "42", "host=web01" }).joinUninterruptibly());
    assertEquals(1, requests.get());
    assertEquals(0, invalid_values.get());
    verify(chan, never()).write(any());
    verify(chan, never()).isConnected();
    verify(tsdb, never()).getStorageExceptionHandler();
}
Also used : Channel(org.jboss.netty.channel.Channel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 68 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestPutRpc method executeUnknownMetric.

@Test
public void executeUnknownMetric() throws Exception {
    final PutDataPointRpc put = new PutDataPointRpc();
    final Channel chan = NettyMocks.fakeChannel();
    assertNull(put.execute(tsdb, chan, new String[] { "put", "doesnotexist", "1365465600", "42", "host=web01" }).joinUninterruptibly());
    assertEquals(1, requests.get());
    assertEquals(0, invalid_values.get());
    assertEquals(1, unknown_metrics.get());
    verify(chan, times(1)).write(any());
    verify(chan, times(1)).isConnected();
    verify(tsdb, never()).getStorageExceptionHandler();
}
Also used : Channel(org.jboss.netty.channel.Channel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 69 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestPutRpc method executeShortArray.

@Test
public void executeShortArray() throws Exception {
    final PutDataPointRpc put = new PutDataPointRpc();
    final Channel chan = NettyMocks.fakeChannel();
    assertNull(put.execute(tsdb, chan, new String[] { "put", "sys.cpu.nice", "1365465600", "42" }).joinUninterruptibly());
    assertEquals(1, requests.get());
    assertEquals(0, invalid_values.get());
    assertEquals(1, illegal_arguments.get());
    verify(chan, times(1)).write(any());
    verify(chan, times(1)).isConnected();
    verify(tsdb, never()).getStorageExceptionHandler();
}
Also used : Channel(org.jboss.netty.channel.Channel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 70 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestPutRpc method executeNullTSDB.

@Test(expected = NullPointerException.class)
public void executeNullTSDB() throws Exception {
    final PutDataPointRpc put = new PutDataPointRpc();
    final Channel chan = NettyMocks.fakeChannel();
    put.execute(null, chan, new String[] { "put", "sys.cpu.nice", "1365465600", "42", "host=web01" });
}
Also used : Channel(org.jboss.netty.channel.Channel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Channel (org.jboss.netty.channel.Channel)187 InetSocketAddress (java.net.InetSocketAddress)57 Test (org.junit.Test)52 HttpRequest (org.jboss.netty.handler.codec.http.HttpRequest)40 DefaultHttpRequest (org.jboss.netty.handler.codec.http.DefaultHttpRequest)37 DefaultHttpResponse (org.jboss.netty.handler.codec.http.DefaultHttpResponse)34 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)34 SocketAddress (java.net.SocketAddress)33 ChannelFuture (org.jboss.netty.channel.ChannelFuture)33 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)30 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)27 Test (org.testng.annotations.Test)23 ConditionCheck (com.linkedin.databus2.test.ConditionCheck)22 IOException (java.io.IOException)21 SimpleObjectCaptureHandler (com.linkedin.databus2.test.container.SimpleObjectCaptureHandler)19 Logger (org.apache.log4j.Logger)19 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)17 DefaultHttpChunk (org.jboss.netty.handler.codec.http.DefaultHttpChunk)16 HttpChunk (org.jboss.netty.handler.codec.http.HttpChunk)16 ArrayList (java.util.ArrayList)14