Package org.springframework.beans

Examples of org.springframework.beans.DirectFieldAccessor


        throw new RuntimeException("bar");
      }
    });
    container.start();
    Log logger = spy(TestUtils.getPropertyValue(container, "logger", Log.class));
    new DirectFieldAccessor(container).setPropertyValue("logger", logger);
    when(logger.isWarnEnabled()).thenReturn(true);
    template.convertAndSend(queue.getName(), "baz");
    assertTrue(messageReceived.await(10, TimeUnit.SECONDS));
    Object consumer = TestUtils.getPropertyValue(container, "consumers", Map.class)
        .keySet().iterator().next();
    Log qLogger = spy(TestUtils.getPropertyValue(consumer, "logger", Log.class));
    new DirectFieldAccessor(consumer).setPropertyValue("logger", qLogger);
    when(qLogger.isDebugEnabled()).thenReturn(true);
    spiedQLogger.countDown();
    assertTrue(errorHandled.await(10, TimeUnit.SECONDS));
    container.stop();
    verify(logger, never()).warn(contains("Consumer raised exception"), any(Throwable.class));
View Full Code Here


    n = 0;
    while (n++ < 100 && missingQueues.size() == 0) {
      Thread.sleep(200);
    }
    assertTrue("Failed to detect missing queue", n < 100);
    DirectFieldAccessor dfa = new DirectFieldAccessor(newConsumer);
    dfa.setPropertyValue("lastRetryDeclaration", 0);
    dfa.setPropertyValue("retryDeclarationInterval", 100);
    admin.declareQueue(queue1);
    n = 0;
    while (n++ < 100 && missingQueues.size() > 0) {
      Thread.sleep(100);
    }
View Full Code Here

    assertTrue(containerStoppedForAbortWithBadListener());
  }

  private boolean containerStoppedForAbortWithBadListener() throws InterruptedException {
    Log logger = spy(TestUtils.getPropertyValue(container, "logger", Log.class));
    new DirectFieldAccessor(container).setPropertyValue("logger", logger);
    this.template.convertAndSend(queue.getName(), "foo");
    int n = 0;
    while (n++ < 100 && this.container.isRunning()) {
      Thread.sleep(100);
    }
View Full Code Here

    template.convertAndSend("retry.test.exchange", "retry.test.binding", "Hello, world!");
    template.convertAndSend("retry.test.exchange", "retry.test.binding", "Hello, world!");
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    Thread.sleep(2000);
    assertEquals(0, ((Map) new DirectFieldAccessor(cache).getPropertyValue("map")).size());
    container.stop();
    ctx.close();
  }
View Full Code Here

    Message message = new Message("Hello, world!".getBytes(), messageProperties);
    template.send("retry.test.exchange", "retry.test.binding", message);
    template.send("retry.test.exchange", "retry.test.binding", message);
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    Thread.sleep(2000);
    assertEquals(0, ((Map) new DirectFieldAccessor(cache).getPropertyValue("map")).size());
    container.stop();
    ctx.close();
  }
View Full Code Here

    verify(onlyChannel).txCommit();
    verify(onlyChannel).basicPublish(Mockito.anyString(), Mockito.anyString(), Mockito.anyBoolean(),
        Mockito.any(BasicProperties.class), Mockito.any(byte[].class));

    // verify close() was never called on the channel
    DirectFieldAccessor dfa = new DirectFieldAccessor(cachingConnectionFactory);
    List<?> channels = (List<?>) dfa.getPropertyValue("cachedChannelsTransactional");
    assertEquals(0, channels.size());

    container.stop();

  }
View Full Code Here

          latch.countDown();
        }
        return invocation.callRealMethod();
      }
    }).when(logger).warn(any());
    new DirectFieldAccessor(container).setPropertyValue("logger", logger);
    consumer.get().handleCancel("foo");
    assertTrue(latch.await(10, TimeUnit.SECONDS));
    container.stop();
  }
View Full Code Here

    testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer);
  }

  private void testRequeueOrNotGuts(Exception ex, boolean expectedRequeue,
      Channel channel, BlockingQueueConsumer blockingQueueConsumer) throws Exception {
    DirectFieldAccessor dfa = new DirectFieldAccessor(blockingQueueConsumer);
    dfa.setPropertyValue("channel", channel);
    Set<Long> deliveryTags = new HashSet<Long>();
    deliveryTags.add(1L);
    dfa.setPropertyValue("deliveryTags", deliveryTags);
    blockingQueueConsumer.rollbackOnExceptionIfNecessary(ex);
    Mockito.verify(channel).basicReject(1L, expectedRequeue);
  }
View Full Code Here

    RabbitTemplate template = context.getBean(RabbitTemplate.class);
    template.convertAndSend("testContainerWithAutoDeleteQueues", "anon", "foo");
    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    this.listenerContainer1.stop();
    RabbitAdmin admin = spy(TestUtils.getPropertyValue(this.listenerContainer1, "rabbitAdmin", RabbitAdmin.class));
    new DirectFieldAccessor(this.listenerContainer1).setPropertyValue("rabbitAdmin", admin);
    this.listenerContainer1.start();
    template.convertAndSend("testContainerWithAutoDeleteQueues", "anon", "foo");
    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    verify(admin, times(1)).initialize(); // should only be called by one of the consumers
  }
View Full Code Here

    assertNotNull(queue.poll(10, TimeUnit.SECONDS));
    SimpleMessageListenerContainer listenerContainer = context.getBean("container3",
        SimpleMessageListenerContainer.class);
    listenerContainer.stop();
    RabbitAdmin admin = spy(TestUtils.getPropertyValue(listenerContainer, "rabbitAdmin", RabbitAdmin.class));
    new DirectFieldAccessor(listenerContainer).setPropertyValue("rabbitAdmin", admin);
    int n = 0;
    while (admin.getQueueProperties("xExpires") != null && n < 100) {
      Thread.sleep(100);
      n++;
    }
View Full Code Here

TOP

Related Classes of org.springframework.beans.DirectFieldAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.