List of usage examples for java.util.concurrent.atomic AtomicBoolean set
public final void set(boolean newValue)
From source file:io.cloudslang.engine.queue.services.recovery.ExecutionRecoveryServiceImpl.java
protected void assignRecoveredMessages() { if (logger.isDebugEnabled()) logger.debug("Reassigning recovered messages is being started"); long time = System.currentTimeMillis(); final AtomicBoolean shouldContinue = new AtomicBoolean(true); while (shouldContinue.get()) { List<ExecutionMessage> messages = executionQueueService.readMessagesByStatus(DEFAULT_POLL_SIZE, ExecStatus.RECOVERED);/* w ww.j a v a 2s . c o m*/ messageRecoveryService.enqueueMessages(messages, ExecStatus.PENDING); shouldContinue.set(messages != null && messages.size() == DEFAULT_POLL_SIZE); } if (logger.isDebugEnabled()) logger.debug( "Reassigning recovered messages is done in " + (System.currentTimeMillis() - time) + " ms"); }
From source file:com.jayway.restassured.path.xml.XmlPathObjectDeserializationTest.java
@Test public void xml_path_supports_custom_deserializer_using_static_configuration() { // Given//from ww w .ja va 2s . c o m final AtomicBoolean customDeserializerUsed = new AtomicBoolean(false); XmlPath.config = xmlPathConfig().defaultObjectDeserializer(new XmlPathObjectDeserializer() { public <T> T deserialize(ObjectDeserializationContext ctx) { customDeserializerUsed.set(true); final String xml = ctx.getDataToDeserialize().asString(); final Greeting greeting = new Greeting(); greeting.setFirstName(StringUtils.substringBetween(xml, "<firstName>", "</firstName>")); greeting.setLastName(StringUtils.substringBetween(xml, "<lastName>", "</lastName>")); return (T) greeting; } }); // When try { final XmlPath xmlPath = new XmlPath(COOL_GREETING); final Greeting greeting = xmlPath.getObject("", Greeting.class); // Then assertThat(greeting.getFirstName(), equalTo("John")); assertThat(greeting.getLastName(), equalTo("Doe")); assertThat(customDeserializerUsed.get(), is(true)); } finally { XmlPath.reset(); } }
From source file:com.collaborne.jsonschema.generator.pojo.PojoGeneratorTest.java
@Test public void generateInternalPrimitiveTypeReturnsPrimitiveTypeWithoutGeneration() throws CodeGenerationException, IOException { JsonNode schemaNode = jsonNodeReader.fromReader(new StringReader("{\"type\": \"string\"}")); SchemaTree schema = schemaLoader.load(schemaNode); Mapping mapping = new Mapping(URI.create("http://example.com/type.json#"), ClassName.create(Integer.TYPE)); final AtomicBoolean writeSourceCalled = new AtomicBoolean(); PojoGenerator generator = new PojoGenerator(null, null, null) { @Override/*from w w w. j a v a 2 s. com*/ protected void writeSource(URI type, ClassName className, Buffer buffer) throws IOException { writeSourceCalled.set(true); } }; ClassName className = generator.generateInternal(mapping.getTarget(), schema, mapping); assertEquals(mapping.getClassName(), className); assertFalse(writeSourceCalled.get()); }
From source file:com.collaborne.jsonschema.generator.pojo.PojoGeneratorTest.java
@Test public void generateInternalExistingTypeReturnsExistingTypeWithoutGeneration() throws CodeGenerationException, IOException { JsonNode schemaNode = jsonNodeReader.fromReader(new StringReader("{\"type\": \"string\"}")); SchemaTree schema = schemaLoader.load(schemaNode); Mapping mapping = new Mapping(URI.create("http://example.com/type.json#"), ClassName.create(TestClass.class)); final AtomicBoolean writeSourceCalled = new AtomicBoolean(); PojoGenerator generator = new PojoGenerator(null, null, null) { @Override//from w ww. j av a 2 s . c om protected void writeSource(URI type, ClassName className, Buffer buffer) throws IOException { writeSourceCalled.set(true); } }; ClassName className = generator.generateInternal(mapping.getTarget(), schema, mapping); assertEquals(mapping.getClassName(), className); assertFalse(writeSourceCalled.get()); }
From source file:com.tobedevoured.json.SimpleStreamTest.java
@Test public void testCallback() throws StreamException { final AtomicBoolean isCalledBack = new AtomicBoolean(false); simpleStream.setCallback(new Function<Object, Object>() { @Override/*from w w w . j a v a 2s . c o m*/ public Object apply(Object entity) { assertNotNull(entity); isCalledBack.set(true); return null; } }); simpleStream.stream("{\"test\": \"this is a test\"} [1,2,3]"); List entities = simpleStream.flush(); assertTrue("callback was called", isCalledBack.get()); Map<String, String> expectedEntity = ImmutableMap.of("test", "this is a test"); assertEquals(expectedEntity, entities.get(0)); assertEquals(Arrays.asList(1L, 2L, 3L), entities.get(1)); }
From source file:com.ebay.cloud.cms.entmgr.entity.impl.EntityFieldTargetMerger.java
private List<?> mergeTargetContent(List<?> giveValues, List<?> foundValues, AtomicBoolean hasChange) { List<?> result = null;/*from w w w .ja v a 2s . c o m*/ if (pull) { result = ListUtils.subtract(foundValues, giveValues); } else { result = ListUtils.sum(foundValues, giveValues); } hasChange.set(!ListUtils.isEqualList(result, foundValues)); return result; }
From source file:com.couchbase.client.dcp.state.SessionState.java
/** * Check if the current sequence numbers for all partitions are equal to the ones set as end. * * @return true if all are at the end, false otherwise. *///from w w w . j av a 2 s . c o m public boolean isAtEnd() { final AtomicBoolean atEnd = new AtomicBoolean(true); foreachPartition(new Action1<PartitionState>() { @Override public void call(PartitionState ps) { if (!ps.isAtEnd()) { atEnd.set(false); } } }); return atEnd.get(); }
From source file:org.apache.hadoop.hive.ql.TestTxnCommands2.java
@Ignore("alter table") @Test/*from ww w . j a v a2 s . c o m*/ public void testAlterTable() throws Exception { int[][] tableData = { { 1, 2 } }; runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData)); runStatementOnDriver("alter table " + Table.ACIDTBL + " compact 'MAJOR'"); Worker t = new Worker(); t.setThreadId((int) t.getId()); t.setHiveConf(hiveConf); AtomicBoolean stop = new AtomicBoolean(); AtomicBoolean looped = new AtomicBoolean(); stop.set(true); t.init(stop, looped); t.run(); int[][] tableData2 = { { 5, 6 } }; runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b) " + makeValuesClause(tableData2)); List<String> rs1 = runStatementOnDriver("select a,b from " + Table.ACIDTBL + " where b > 0 order by a,b"); runStatementOnDriver("alter table " + Table.ACIDTBL + " add columns(c int)"); int[][] moreTableData = { { 7, 8, 9 } }; runStatementOnDriver("insert into " + Table.ACIDTBL + "(a,b,c) " + makeValuesClause(moreTableData)); List<String> rs0 = runStatementOnDriver( "select a,b,c from " + Table.ACIDTBL + " where a > 0 order by a,b,c"); }
From source file:com.frostwire.platform.FileSystemWalkTest.java
@Test public void testAnyFile() { final AtomicBoolean b = new AtomicBoolean(false); fs.walk(new File("any.txt"), new FileFilter() { @Override/* w ww .j a v a 2 s . c o m*/ public boolean accept(File file) { return true; } @Override public void file(File file) { b.set(true); } }); assertFalse(b.get()); b.set(false); fs.walk(new File("any.txt"), new FileFilter() { @Override public boolean accept(File file) { return !file.isDirectory(); } @Override public void file(File file) { b.set(true); } }); assertFalse(b.get()); }
From source file:io.restassured.path.xml.XmlPathObjectDeserializationTest.java
@Test public void xml_path_supports_custom_deserializer_using_static_configuration() { // Given// w ww. jav a 2 s .c o m final AtomicBoolean customDeserializerUsed = new AtomicBoolean(false); XmlPath.config = XmlPathConfig.xmlPathConfig().defaultObjectDeserializer(new XmlPathObjectDeserializer() { public <T> T deserialize(ObjectDeserializationContext ctx) { customDeserializerUsed.set(true); final String xml = ctx.getDataToDeserialize().asString(); final Greeting greeting = new Greeting(); greeting.setFirstName(StringUtils.substringBetween(xml, "<firstName>", "</firstName>")); greeting.setLastName(StringUtils.substringBetween(xml, "<lastName>", "</lastName>")); return (T) greeting; } }); // When try { final XmlPath xmlPath = new XmlPath(COOL_GREETING); final Greeting greeting = xmlPath.getObject("", Greeting.class); // Then assertThat(greeting.getFirstName(), equalTo("John")); assertThat(greeting.getLastName(), equalTo("Doe")); assertThat(customDeserializerUsed.get(), is(true)); } finally { XmlPath.reset(); } }