下面列出了java.lang.InterruptedException#java.lang.System 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void main(String[] args) throws Exception {
boolean endResult = true;
if (!arePaddedPairwise(R1.class, "int1", "int2")) {
System.err.println("R1 failed");
endResult &= false;
}
if (!arePaddedPairwise(R2.class, "int1", "int2")) {
System.err.println("R2 failed");
endResult &= false;
}
if (!arePaddedPairwise(R3.class, "int1", "int2")) {
System.err.println("R3 failed");
endResult &= false;
}
System.out.println(endResult ? "Test PASSES" : "Test FAILS");
if (!endResult) {
throw new Error("Test failed");
}
}
@Test public void indexedElseIf() throws Exception {
TypeSpec taco = TypeSpec.classBuilder("Taco")
.addMethod(MethodSpec.methodBuilder("choices")
.beginControlFlow("if ($1L != null || $1L == $2L)", "taco", "otherTaco")
.addStatement("$T.out.println($S)", System.class, "only one taco? NOO!")
.nextControlFlow("else if ($1L.$3L && $2L.$3L)", "taco", "otherTaco", "isSupreme()")
.addStatement("$T.out.println($S)", System.class, "taco heaven")
.endControlFlow()
.build())
.build();
assertThat(toString(taco)).isEqualTo(""
+ "package com.squareup.tacos;\n"
+ "\n"
+ "import java.lang.System;\n"
+ "\n"
+ "class Taco {\n"
+ " void choices() {\n"
+ " if (taco != null || taco == otherTaco) {\n"
+ " System.out.println(\"only one taco? NOO!\");\n"
+ " } else if (taco.isSupreme() && otherTaco.isSupreme()) {\n"
+ " System.out.println(\"taco heaven\");\n"
+ " }\n"
+ " }\n"
+ "}\n");
}
public static void main(String[] args) throws Exception {
boolean endResult = true;
if (!arePaddedPairwise(R1.class, "int1", "int2")) {
System.err.println("R1 failed");
endResult &= false;
}
if (!arePaddedPairwise(R2.class, "int1", "int2")) {
System.err.println("R2 failed");
endResult &= false;
}
if (!arePaddedPairwise(R3.class, "int1", "int2")) {
System.err.println("R3 failed");
endResult &= false;
}
System.out.println(endResult ? "Test PASSES" : "Test FAILS");
if (!endResult) {
throw new Error("Test failed");
}
}
private void setHasFrame(JFrame frame, boolean hasFrame) {
if (!this.frameless) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
System.out.println(windowName + " hasFrame=" + hasFrame);
WinDef.HWND hWnd = new WinDef.HWND();
hWnd.setPointer(Native.getComponentPointer(frame));
LayoutFrame.this.externalWindowObserver.setHasFrame(hWnd, hasFrame);
frame.setResizable(hasFrame);
frame.invalidate();
frame.validate();
frame.repaint();
SwingUtilities.updateComponentTreeUI(frame);
}
});
}
}
private void writeJavaProperties(Hashtable javaProperties, Node appendTo)
{
writeKey("Properties", appendTo);
Node propertiesDict = createNode("dict", appendTo);
for (Iterator i = javaProperties.keySet().iterator(); i.hasNext(); )
{
String key = (String) i.next();
if (key.startsWith("com.apple.") && (bundleProperties.getJavaVersion() >= 1.4))
{
System.out.println("Deprecated as of 1.4: " + key);
continue;
}
writeKeyStringPair(key, (String) javaProperties.get(key), propertiesDict);
}
}
@Test public void elseIf() throws Exception {
TypeSpec taco = TypeSpec.classBuilder("Taco")
.addMethod(MethodSpec.methodBuilder("choices")
.beginControlFlow("if (5 < 4) ")
.addStatement("$T.out.println($S)", System.class, "wat")
.nextControlFlow("else if (5 < 6)")
.addStatement("$T.out.println($S)", System.class, "hello")
.endControlFlow()
.build())
.build();
assertThat(toString(taco)).isEqualTo(""
+ "package com.squareup.tacos;\n"
+ "\n"
+ "import java.lang.System;\n"
+ "\n"
+ "class Taco {\n"
+ " void choices() {\n"
+ " if (5 < 4) {\n"
+ " System.out.println(\"wat\");\n"
+ " } else if (5 < 6) {\n"
+ " System.out.println(\"hello\");\n"
+ " }\n"
+ " }\n"
+ "}\n");
}
/***************************************************************
Function: pset
**************************************************************/
private void pset
(
Vector dtrans_group
)
{
int i;
int size;
CDTrans dtrans;
size = dtrans_group.size();
for (i = 0; i < size; ++i)
{
dtrans = (CDTrans) dtrans_group.elementAt(i);
System.out.print(dtrans.m_label + " ");
}
}
public void display(){
JFrame frame = new JFrame("Cursor Stim");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Cursor Stim");
frame.getContentPane().add(this, BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
// start the experiment controller thread
startControllerThread();
// run the main-loop rendering loop
renderloop();
// run the experiment
frame.dispose();
System.exit(0);
}
@SuppressWarnings({"unchecked"})
public ArrayListCursor(String[] columnNames, ArrayList<ArrayList> rows) {
int colCount = columnNames.length;
boolean foundID = false;
// Add an _id column if not in columnNames
for (int i = 0; i < colCount; ++i) {
if (columnNames[i].compareToIgnoreCase("_id") == 0) {
mColumnNames = columnNames;
foundID = true;
break;
}
}
if (!foundID) {
mColumnNames = new String[colCount + 1];
System.arraycopy(columnNames, 0, mColumnNames, 0, columnNames.length);
mColumnNames[colCount] = "_id";
}
int rowCount = rows.size();
mRows = new ArrayList[rowCount];
for (int i = 0; i < rowCount; ++i) {
mRows[i] = rows.get(i);
if (!foundID) {
mRows[i].add(i);
}
}
}
public static void main(String args[]) throws Exception {
try {
//
TestDynamicPolicy jstest = new TestDynamicPolicy();
jstest.doit();
} catch(Exception e) {
System.out.println("Failed. Unexpected exception:" + e);
throw e;
}
System.out.println("Passed. OKAY");
}
private String getUserName() {
String usr = null;
try {
usr = System.getProperty("user.name");
} catch (Exception e) {
}
return usr;
}
private String getUserName() {
String usr = null;
try {
usr = System.getProperty("user.name");
} catch (Exception e) {
}
return usr;
}
private String getUserName() {
String usr = null;
try {
usr = System.getProperty("user.name");
} catch (Exception e) {
}
return usr;
}
public void run() {
try {
startedSignal.countDown();
long start = System.nanoTime();
reference = queue.remove(TIMEOUT);
actual = NANOSECONDS.toMillis(System.nanoTime() - start);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
}
private TypeSpec importStaticTypeSpec(String name) {
MethodSpec method = MethodSpec.methodBuilder("minutesToSeconds")
.addModifiers(Modifier.PUBLIC, Modifier.STATIC)
.returns(long.class)
.addParameter(long.class, "minutes")
.addStatement("$T.gc()", System.class)
.addStatement("return $1T.SECONDS.convert(minutes, $1T.MINUTES)", TimeUnit.class)
.build();
return TypeSpec.classBuilder(name).addMethod(method).build();
}
@Test
public void testClosedZipFile() throws IOException {
ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."), "input.zip"));
zf.close();
try {
Stream s = zf.stream();
fail("Should have thrown IllegalStateException");
} catch (IllegalStateException e) {
// expected;
}
}
public void run() {
try {
startedSignal.countDown();
long start = System.nanoTime();
reference = queue.remove(TIMEOUT);
actual = NANOSECONDS.toMillis(System.nanoTime() - start);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
}
@Test
public void testClosedJarFile() throws IOException {
JarFile jf = new JarFile(new File(System.getProperty("test.src", "."), "input.jar"));
jf.close();
try {
Stream s = jf.stream();
fail("Should have thrown IllegalStateException");
} catch (IllegalStateException e) {
// expected;
}
}
@Test
public void testClosedJarFile() throws IOException {
JarFile jf = new JarFile(new File(System.getProperty("test.src", "."), "input.jar"));
jf.close();
try {
Stream s = jf.stream();
fail("Should have thrown IllegalStateException");
} catch (IllegalStateException e) {
// expected;
}
}
@Test
public void testStreamJar() throws IOException {
try (JarFile jf = new JarFile(new File(System.getProperty("test.src", "."), "input.jar"))) {
jf.stream().forEach(e -> assertTrue(e instanceof JarEntry));
Object elements[] = jf.stream().toArray();
assertEquals(3, elements.length);
assertEquals(elements[0].toString(), "META-INF/");
assertEquals(elements[1].toString(), "META-INF/MANIFEST.MF");
assertEquals(elements[2].toString(), "ReleaseInflater.java");
}
}
private void new_block(int idx, int bnum) {
if (size==bits.length) { // resize
long[] nbits = new long[size*3];
int [] noffs = new int [size*3];
System.arraycopy(bits, 0, nbits, 0, size);
System.arraycopy(offs, 0, noffs, 0, size);
bits = nbits;
offs = noffs;
}
CUtility.ASSERT(size<bits.length);
insert_block(idx, bnum);
}
@Test
public void testClosedZipFile() throws IOException {
ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."), "input.zip"));
zf.close();
try {
Stream s = zf.stream();
fail("Should have thrown IllegalStateException");
} catch (IllegalStateException e) {
// expected;
}
}
@Test
public void testClosedZipFile() throws IOException {
ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."), "input.zip"));
zf.close();
try {
Stream s = zf.stream();
fail("Should have thrown IllegalStateException");
} catch (IllegalStateException e) {
// expected;
}
}
private String getUserName() {
String usr = null;
try {
usr = System.getProperty("user.name");
} catch (Exception e) {
}
return usr;
}
public static void main(String args[]) throws Exception {
try {
//
TestDynamicPolicy jstest = new TestDynamicPolicy();
jstest.doit();
} catch(Exception e) {
System.out.println("Failed. Unexpected exception:" + e);
throw e;
}
System.out.println("Passed. OKAY");
}
public void run() {
try {
startedSignal.countDown();
long start = System.nanoTime();
reference = queue.remove(TIMEOUT);
actual = NANOSECONDS.toMillis(System.nanoTime() - start);
} catch (InterruptedException ex) {
throw new RuntimeException(ex);
}
}
@Test
public void testClosedJarFile() throws IOException {
JarFile jf = new JarFile(new File(System.getProperty("test.src", "."), "input.jar"));
jf.close();
try {
Stream s = jf.stream();
fail("Should have thrown IllegalStateException");
} catch (IllegalStateException e) {
// expected;
}
}
@Test
public void testStreamZip() throws IOException {
try (ZipFile zf = new ZipFile(new File(System.getProperty("test.src", "."), "input.zip"))) {
zf.stream().forEach(e -> assertTrue(e instanceof ZipEntry));
zf.stream().forEach(e -> assertEquals(e.toString(), "ReadZip.java"));
Object elements[] = zf.stream().toArray();
assertEquals(1, elements.length);
assertEquals(elements[0].toString(), "ReadZip.java");
}
}
@Test(expected = ValidationFailedException.class)
public void emptyCustomId() {
Post post = new Post();
post.setUserId(1);
post.setClientId(null);
post.setText("abc");
post.setCreated(System.currentTimeMillis());
post.validate();
}
public void cleanup() {
try {
System.out.println(windowName + " cleaning up ");
this.externalWindowObserver.dispose();
}
catch (Exception e) {
e.printStackTrace();
}
}