List of usage examples for org.apache.commons.lang StringUtils repeat
public static String repeat(String str, int repeat)
Repeat a String repeat
times to form a new String.
From source file:org.apache.activemq.bugs.AMQ7067Test.java
@Test public void testCommit() throws Exception { final Connection connection = ACTIVE_MQ_NON_XA_CONNECTION_FACTORY.createConnection(); connection.start();// ww w .jav a2 s. co m Session session = connection.createSession(true, Session.SESSION_TRANSACTED); Queue holdKahaDb = session.createQueue("holdKahaDb"); MessageProducer holdKahaDbProducer = session.createProducer(holdKahaDb); TextMessage helloMessage = session.createTextMessage(StringUtils.repeat("a", 10)); holdKahaDbProducer.send(helloMessage); Queue queue = session.createQueue("test"); produce(connection, queue, 100, 512 * 1024); session.commit(); produce(connection, queue, 100, 512 * 1024); System.out.println(String.format("QueueSize %s: %d", holdKahaDb.getQueueName(), getQueueSize(holdKahaDb.getQueueName()))); purgeQueue(queue.getQueueName()); Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { return 0 == getQueueSize(queue.getQueueName()); } }); // force gc broker.getPersistenceAdapter().checkpoint(true); connection.close(); curruptIndexFile(getDataDirectory()); broker.stop(); broker.waitUntilStopped(); createBroker(); broker.waitUntilStarted(); while (true) { try { TimeUnit.SECONDS.sleep(1); System.out.println(String.format("QueueSize %s: %d", holdKahaDb.getQueueName(), getQueueSize(holdKahaDb.getQueueName()))); break; } catch (Exception ex) { System.out.println(ex.getMessage()); break; } } // THIS SHOULD NOT FAIL AS THERE SHOULD BE ONLY 1 TRANSACTION! assertEquals(1, getQueueSize(holdKahaDb.getQueueName())); }
From source file:org.apache.activemq.bugs.AMQ7067Test.java
@Test public void testRollback() throws Exception { final Connection connection = ACTIVE_MQ_NON_XA_CONNECTION_FACTORY.createConnection(); connection.start();//from www. j av a 2 s.c om Session session = connection.createSession(true, Session.SESSION_TRANSACTED); Queue holdKahaDb = session.createQueue("holdKahaDb"); MessageProducer holdKahaDbProducer = session.createProducer(holdKahaDb); TextMessage helloMessage = session.createTextMessage(StringUtils.repeat("a", 10)); holdKahaDbProducer.send(helloMessage); Queue queue = session.createQueue("test"); produce(connection, queue, 100, 512 * 1024); session.rollback(); produce(connection, queue, 100, 512 * 1024); System.out.println(String.format("QueueSize %s: %d", holdKahaDb.getQueueName(), getQueueSize(holdKahaDb.getQueueName()))); purgeQueue(queue.getQueueName()); Wait.waitFor(new Wait.Condition() { @Override public boolean isSatisified() throws Exception { return 0 == getQueueSize(queue.getQueueName()); } }); // force gc broker.getPersistenceAdapter().checkpoint(true); connection.close(); curruptIndexFile(getDataDirectory()); broker.stop(); broker.waitUntilStopped(); createBroker(); broker.waitUntilStarted(); // no sign of the test queue on recovery, rollback is the default for any inflight // this test serves as a sanity check on existing behaviour try { getQueueSize(holdKahaDb.getQueueName()); fail("expect InstanceNotFoundException"); } catch (UndeclaredThrowableException expected) { assertTrue(expected.getCause() instanceof InstanceNotFoundException); } }
From source file:org.apache.activemq.bugs.AMQ7067Test.java
protected static void createDanglingTransaction(XAResource xaRes, XASession xaSession, Queue queue) throws JMSException, IOException, XAException { MessageProducer producer = xaSession.createProducer(queue); XATransactionId txId = createXATransaction(); xaRes.start(txId, TMNOFLAGS);/*from ww w . j a v a 2 s . c o m*/ TextMessage helloMessage = xaSession.createTextMessage(StringUtils.repeat("dangler", 10)); producer.send(helloMessage); xaRes.end(txId, TMSUCCESS); xaRes.prepare(txId); System.out.println("****** createDanglingTransaction txId = " + txId); }
From source file:org.apache.activemq.bugs.AMQ7067Test.java
protected static void produce(XAResource xaRes, XASession xaSession, Queue queue, int messageCount, int messageSize) throws JMSException, IOException, XAException { MessageProducer producer = xaSession.createProducer(queue); for (int i = 0; i < messageCount; i++) { XATransactionId txid = createXATransaction(); xaRes.start(txid, TMNOFLAGS);//from ww w . ja v a 2s .c om TextMessage helloMessage = xaSession.createTextMessage(StringUtils.repeat("a", messageSize)); producer.send(helloMessage); xaRes.end(txid, TMSUCCESS); xaRes.commit(txid, true); } }
From source file:org.apache.activemq.bugs.AMQ7067Test.java
protected static void produce(Connection connection, Queue queue, int messageCount, int messageSize) throws JMSException, IOException, XAException { Session session = connection.createSession(true, Session.SESSION_TRANSACTED); MessageProducer producer = session.createProducer(queue); for (int i = 0; i < messageCount; i++) { TextMessage helloMessage = session.createTextMessage(StringUtils.repeat("a", messageSize)); producer.send(helloMessage);/*w w w . j a v a 2 s . c om*/ session.commit(); } }
From source file:org.apache.activemq.bugs.AMQ7118Test.java
protected static boolean produce(Session session, Topic topic, int messageCount, int messageSize) throws JMSException { MessageProducer producer = session.createProducer(topic); for (int i = 0; i < messageCount; i++) { TextMessage helloMessage = session.createTextMessage(StringUtils.repeat("a", messageSize)); try {/*w w w .j a v a 2 s . c om*/ producer.send(helloMessage); } catch (ResourceAllocationException e) { return false; } } return true; }
From source file:org.apache.ambari.server.serveraction.upgrades.ConfigureAction.java
private static String mask(Masked mask, String value) { if (mask.mask) { return StringUtils.repeat("*", value.length()); }//from w w w.j a v a2 s. c o m return value; }
From source file:org.apache.archiva.web.startup.Banner.java
public static void display(String version) { String banner = getBanner(version); LoggerFactory.getLogger(Banner.class).info("{} {}{}", StringUtils.repeat("_", 25), eol, banner); }
From source file:org.apache.camel.component.cxf.CxfConsumerPayloadXPathClientServerTest.java
private void buildTestMessage(int size) { testMessage = StringUtils.repeat("x", size); }
From source file:org.apache.camel.component.cxf.CxfConsumerPayloadXPathTest.java
private void simpleTest(int repeat, BaseRouteBuilder builder) throws Exception { setUseRouteBuilder(false);//ww w . j a va 2s . c o m context.addRoutes(builder); startCamelContext(); String content = StringUtils.repeat("x", repeat); String msgIn = constructSoapMessage(content); Exchange exchgIn = new DefaultExchange(context); exchgIn.setPattern(ExchangePattern.InOut); exchgIn.getIn().setBody(msgIn); //Execute Exchange exchgOut = template.send(builder.getTestAddress(), exchgIn); //Verify String result = exchgOut.getOut().getBody(String.class); assertNotNull("response on http call", result); //check for data loss in received input (after xpath) String headerSize = exchgOut.getOut().getHeader(HEADER_SIZE, String.class); assertEquals("" + repeat, headerSize); assertTrue("dataloss in output occurred", result.length() > repeat); stopCamelContext(); }