This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CyclicBarrierTest { | |
public static void main(String[] args) { | |
final CyclicBarrier barrier = new CyclicBarrier(2); | |
Runnable r = new Runnable() { | |
@Override | |
public void run() { | |
try { | |
for (int i = 0; i < 5; i++) { | |
System.out.println(Thread.currentThread().getName() + " waits for the other ones"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ExceptionRethrow { | |
void foo() throws IOException { | |
try { | |
bar(); | |
} | |
catch (Exception e) { | |
throw e; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VerticalTabDemo { | |
public static String buildMessage() { | |
StringBuilder message = new StringBuilder(); | |
message.append('\u000b'); | |
message.append('H'); | |
char[] characters = message.toString().toCharArray(); // returns length 2 | |
System.out.println("characters.length in buildMessage = " + characters.length); | |
dumpString(message.toString()); | |
return message.toString(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Bar { | |
} | |
public class Foo { | |
@Autowired | |
public void setBar(Bar bar) { | |
System.out.println("setBar() was called"); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LocalDateExample { | |
public static void main(String[] args) { | |
LocalDate ld1 = LocalDate.now(); | |
LocalDate ld2 = LocalDate.now().plusDays(2); | |
System.out.println("comparison = " + compare(ld1, ld2)); | |
} | |
private static <T extends Temporal> int compare(T t1, T t2) { | |
Comparable<T> c1 = (Comparable<T>) t1; | |
return c1.compareTo(t2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.ByteArrayOutputStream; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.io.InputStream; | |
public class LockFileTest { | |
public static void main(String[] args) throws IOException { | |
File lockFile = File.createTempFile("foo", ".lock"); | |
int read; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EscapeTest { | |
@Test | |
public void jacksonShouldEscape() throws IOException { | |
ObjectMapper om = new ObjectMapper(); | |
String json = "{\"name\": \"O;\\\\l-wslD6RQ5@M)\"}"; | |
Foo foo = om.reader(Foo.class).readValue(json); | |
assertThat(foo.getName()).isEqualTo("O;\\l-wslD6RQ5@M)"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class Rectangle { | |
private final int width; | |
private final int height; | |
public Rectangle(int width, int height) { | |
this.width = width; | |
this.height = height; | |
} | |
public int area() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ninja_squad.dbsetup.operation.Operation; | |
import static com.ninja_squad.dbsetup.Operations.*; | |
public class Foo { | |
public static void main(String[] args) { | |
Operation insertVendorsAndProducts = | |
sequenceOf( | |
insertInto("VENDOR") | |
.columns("ID", "CODE", "NAME") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.ninja_squad.dbsetup.operation.Operation; | |
import static com.ninja_squad.dbsetup.Operations.*; | |
public class Foo { | |
public static void main(String[] args) { | |
Operation insertVendorsAndProducts = | |
sequenceOf( | |
insertInto("VENDOR") | |
.columns("ID", "CODE", "NAME") |