List of usage examples for org.apache.commons.lang.mutable MutableBoolean MutableBoolean
public MutableBoolean(Boolean value)
From source file:com.hp.alm.ali.idea.entity.table.QuerySharingManager.java
public void addSharedQuery(final QuerySharing model, final String id) { final MutableBoolean ignore = new MutableBoolean(false); model.addFilterListener(new FilterListener<EntityQuery>() { @Override//w w w . j a v a 2 s . c o m public void filterChanged(EntityQuery query) { if (!ignore.booleanValue()) { fireChangedEvent(query, id); } } }); FilterListener<EntityQuery> listener = new FilterListener<EntityQuery>() { @Override public void filterChanged(EntityQuery query) { LinkedHashMap<String, Integer> columns = query.getColumns(); if (query == model.getFilter()) { conf.getFilter(id).setColumns(columns); return; // ignore our own event (only store in project configuration) } ignore.setValue(true); try { model.setColumns(columns); } finally { ignore.setValue(false); } } }; addListener(id, listener); ref.put(model, listener); // make sure the listener is not garbage collected }
From source file:net.itransformers.expect4java.Expect4JavaTest.java
@Test public void testEof() throws IOException, MalformedPatternException, Expect4jException { final MutableBoolean status = new MutableBoolean(false); e4j.send("hello\n"); e4j.expect(new Match[] { new GlobMatch("hello\n", it -> { System.out.println("Hello World!"); e4j.getWriter().close();//from w w w . j a v a 2 s . c o m System.out.println("reader closed"); it.exp_continue(); }), new EofMatch(it1 -> status.setValue(true)) }); Assert.assertTrue(status.booleanValue()); }
From source file:net.itransformers.expect4java.Expect4JavaTest.java
@Test public void testGlob() throws IOException, MalformedPatternException { final MutableBoolean status = new MutableBoolean(false); e4j.send("hello\n"); e4j.expect(new GlobMatch("hello\n", it -> { System.out.println("Hello World!"); status.setValue(true);//ww w. jav a2s . c o m })); Assert.assertTrue(status.booleanValue()); }
From source file:com.jivesoftware.os.rcvs.api.keys.SymetricalHashableKeyTest.java
License:asdf
@Test public void testThreadSafe() throws Exception { System.out.println("testThreadSafe"); final SymetricalHashableKey instance = new SymetricalHashableKey("asdfghjk"); int poolSize = 4; ExecutorService threadPool = Executors.newFixedThreadPool(poolSize); final CountDownLatch latch = new CountDownLatch(poolSize); final MutableBoolean failed = new MutableBoolean(false); for (int i = 0; i < poolSize; i++) { threadPool.submit(new Runnable() { @Override// w w w . jav a2 s .c o m public void run() { try { int count = 1000000; for (long i = 0; i < count; i++) { long a = Math.abs(rand.nextLong()); byte[] hash = instance.toHash(longBytes(a)); byte[] output = instance.toBytes(hash); long b = bytesLong(output); if (a != b) { System.out.println("Failed a:" + a + " ne b:" + b); failed.setValue(true); return; } } } catch (InvalidKeyException | ShortBufferException | IllegalBlockSizeException | BadPaddingException | ExecutionException x) { failed.setValue(true); } finally { latch.countDown(); } } }); } latch.await(); Assert.assertFalse(failed.booleanValue()); }
From source file:net.itransformers.expect4java.Expect4jLoggingTest.java
@Test public void testEof() throws IOException, MalformedPatternException, Expect4jException { final MutableBoolean status = new MutableBoolean(false); e4j.send("hello\n"); e4j.expect(new Match[] { new GlobMatch("hello\n", it -> { System.out.println("Hello World!"); e4j.getWriter().close();/*from w ww.j a v a2s . c o m*/ System.out.println("reader closed"); it.exp_continue(); }), new EofMatch(it1 -> status.setValue(true)) }); Assert.assertTrue(status.booleanValue()); Assert.assertEquals(1, inLogger.getMessages().size()); Assert.assertEquals("(localhost) >>> hello[\\n]", inLogger.getMessages().get(0)); Assert.assertEquals(1, outLogger.getMessages().size()); Assert.assertEquals("(nms) <<< hello[\\n]", outLogger.getMessages().get(0)); }
From source file:net.itransformers.expect4java.Expect4JavaTest.java
@Test public void testSetTimeout() throws IOException, MalformedPatternException { final MutableBoolean status = new MutableBoolean(false); e4j.setTimeout(new TimeoutMatch(1000L, it -> { status.setValue(true);/*from w w w. j a v a 2s. c o m*/ })); e4j.send("hello\n"); e4j.expect(new GlobMatch("hello\n", it -> { System.out.println("Hello World!"); Thread.sleep(1100); it.exp_continue(); })); Assert.assertTrue(status.booleanValue()); }
From source file:net.itransformers.expect4java.Expect4JavaTest.java
@Test public void testRegex() throws IOException, MalformedPatternException { final MutableBoolean status = new MutableBoolean(false); e4j.send("hello World\n"); e4j.expect(new RegExpMatch("hello ([^\n]*)\n", (ExpectContext context) -> { System.out.println("Hello " + context.getMatch(1)); status.setValue(true);//from w w w . j a va 2s. c o m })); Assert.assertTrue(status.booleanValue()); }
From source file:net.contextfw.web.application.internal.page.PageScopeTest.java
@Before public void setup() throws IOException { storage = new DefaultWebApplicationStorage(Configuration.getDefaults()); pageScope = new PageScope(); pageScope.setListener(createMock(LifecycleListener.class)); request = createMock(HttpServletRequest.class); servlet = createMock(HttpServlet.class); response = createMock(HttpServletResponse.class); expect(request.getRequestURI()).andReturn("/test"); expect(request.getQueryString()).andReturn(null); expect(request.getRemoteAddr()).andReturn(LOCALHOST); replay(request, servlet, response);//w w w .j av a 2s . co m servlet = createMock(HttpServlet.class); response = createMock(HttpServletResponse.class); page = pageScope.createPage(servlet, request, response); final MutableBoolean executionRun = new MutableBoolean(false); storage.initialize(page, request, System.currentTimeMillis() + MAX_INACTIVITY, new ScopedWebApplicationExecution() { @Override public void execute(WebApplication application) { executionRun.setValue(true); assertEquals(page, application); } }); assertTrue(executionRun.booleanValue()); }
From source file:net.itransformers.expect4java.Expect4jLoggingTest.java
@Test public void testLogging() throws IOException, MalformedPatternException { final MutableBoolean status = new MutableBoolean(false); e4j.send("h"); e4j.send("ello\n"); e4j.expect(new Match[] { new GlobMatch("hello\n", it -> { System.out.println("Hello World!"); e4j.getWriter().close();/*from ww w . jav a 2 s .co m*/ System.out.println("reader closed"); it.exp_continue(); }), new EofMatch(it1 -> status.setValue(true)) }); Assert.assertTrue(status.booleanValue()); Assert.assertEquals(1, inLogger.getMessages().size()); Assert.assertEquals("(localhost) >>> hello[\\n]", inLogger.getMessages().get(0)); Assert.assertEquals(1, outLogger.getMessages().size()); Assert.assertEquals("(nms) <<< hello[\\n]", outLogger.getMessages().get(0)); }
From source file:net.itransformers.expect4java.Expect4JavaTest.java
@Test public void testRegexpArrTwoMatch() throws IOException, MalformedPatternException { final MutableBoolean status = new MutableBoolean(false); final MutableBoolean firsMatch = new MutableBoolean(false); e4j.send("hello World\n"); e4j.send("hello2 World\n"); e4j.expect(new Match[] { new RegExpMatch("hello ([^\n]*)\n", (ExpectContext it) -> { System.out.println("Hello " + it.getMatch(1)); firsMatch.setValue(true);/*w w w . java 2s . c o m*/ it.exp_continue(); }), new RegExpMatch("hello2 ([^\n]*)\n", (ExpectContext context2) -> { System.out.println("Hello2 " + context2.getMatch(1)); if (firsMatch.booleanValue()) status.setValue(true); }) }); Assert.assertTrue(status.booleanValue()); }