コード例 #1
0
  @Test
  public void testDefaultSerde() throws Exception {
    RabbitMQFirehoseConfig config = RabbitMQFirehoseConfig.makeDefaultConfig();

    JacksonifiedConnectionFactory connectionFactory =
        JacksonifiedConnectionFactory.makeDefaultConnectionFactory();

    RabbitMQFirehoseFactory factory =
        new RabbitMQFirehoseFactory(
            connectionFactory,
            config,
            new StringInputRowParser(
                new JSONParseSpec(
                    new TimestampSpec("timestamp", "auto"),
                    new DimensionsSpec(
                        Arrays.asList("dim"),
                        Lists.<String>newArrayList(),
                        Lists.<SpatialDimensionSchema>newArrayList())),
                null,
                null,
                null,
                null));

    byte[] bytes = mapper.writeValueAsBytes(factory);
    RabbitMQFirehoseFactory factory2 = mapper.readValue(bytes, RabbitMQFirehoseFactory.class);
    byte[] bytes2 = mapper.writeValueAsBytes(factory2);

    Assert.assertArrayEquals(bytes, bytes2);

    Assert.assertEquals(factory.getConfig(), factory2.getConfig());
    Assert.assertEquals(factory.getConnectionFactory(), factory2.getConnectionFactory());

    Assert.assertEquals(300, factory2.getConfig().getMaxDurationSeconds());

    Assert.assertEquals(ConnectionFactory.DEFAULT_HOST, factory2.getConnectionFactory().getHost());
    Assert.assertEquals(
        ConnectionFactory.DEFAULT_USER, factory2.getConnectionFactory().getUsername());
    Assert.assertEquals(
        ConnectionFactory.DEFAULT_AMQP_PORT, factory2.getConnectionFactory().getPort());
  }
コード例 #2
0
  @Test
  public void testSerde() throws Exception {
    RabbitMQFirehoseConfig config =
        new RabbitMQFirehoseConfig("test", "test2", "test3", true, true, true, 5, 10, 20);

    JacksonifiedConnectionFactory connectionFactory =
        new JacksonifiedConnectionFactory(
            "foo",
            9978,
            "user",
            "pw",
            "host",
            null,
            5,
            10,
            11,
            12,
            ImmutableMap.<String, Object>of("hi", "bye"));

    RabbitMQFirehoseFactory factory =
        new RabbitMQFirehoseFactory(
            connectionFactory,
            config,
            new StringInputRowParser(
                new JSONParseSpec(
                    new TimestampSpec("timestamp", "auto"),
                    new DimensionsSpec(
                        Arrays.asList("dim"),
                        Lists.<String>newArrayList(),
                        Lists.<SpatialDimensionSchema>newArrayList())),
                null,
                null,
                null,
                null));

    byte[] bytes = mapper.writeValueAsBytes(factory);
    RabbitMQFirehoseFactory factory2 = mapper.readValue(bytes, RabbitMQFirehoseFactory.class);
    byte[] bytes2 = mapper.writeValueAsBytes(factory2);

    Assert.assertArrayEquals(bytes, bytes2);

    Assert.assertEquals(factory.getConfig(), factory2.getConfig());
    Assert.assertEquals(factory.getConnectionFactory(), factory2.getConnectionFactory());
  }