This file contains 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
def xml = new XmlParser().parseText("""<?xml version="1.0" encoding="UTF-8"?> | |
<testsuite name="sample.HelloTest" tests="1" skipped="0" failures="0" errors="0" timestamp="2015-12-04T00:11:21" hostname="iProf.local" time="0.22"> | |
<properties/> | |
<testcase name="test_sayHello" classname="sample.HelloTest" time="0.22"/> | |
<system-out><![CDATA[system-out-text]]></system-out> | |
<system-err><![CDATA[system-err-text]]></system-err> | |
</testsuite>""") | |
assert xml."system-out".text() == "system-out-text" |
This file contains 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
死因 死因 = new SiinBuilder() | |
.外傷(無し) | |
.死亡推定時刻(2015-10-20T12:34:56) | |
.死亡場所(自宅近くの道路) | |
.add目撃証言(2015-10-18, 近隣住民) | |
.年齢(98) | |
.build(); | |
assert 死因 == 交通事故; // => false |
This file contains 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.time.LocalDateTime; | |
import java.util.Date; | |
import static org.junit.Assert.assertFalse; | |
/** | |
* @author irof | |
*/ | |
public class DateAndDateTimeTest { | |
@org.junit.Test |
This file contains 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
(https://github.com/irof/sandbox/tree/blog/20150501/jaxrs/jersey をちょっと削ったの) | |
% gradle dependencies --configuration testCompile :jersey:dependencies | |
------------------------------------------------------------ | |
Project :jersey | |
------------------------------------------------------------ | |
testCompile - Compile classpath for source set 'test'. | |
+--- org.glassfish.jersey.core:jersey-server:2.17 |
This file contains 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
mkdir ~/hoge | |
mkdir work | |
cd work | |
echo "class Hoge { public static void main(String... args) { System.out.println(1); } }" > Hoge.java | |
echo "class Fuga { public static void main(String... args) { System.out.println(2); } }" > Fuga.java | |
javac Hoge.java Fuga.java | |
jar cvf Hoge.jar Hoge.class | |
jar cvf Fuga.jar Fuga.class | |
mv ./*.jar ~/hoge |
This file contains 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 DiamondProblem implements IHoge, IPiyo { | |
public static void main(String[] args) { | |
System.out.println(new DiamondProblem().hoge()); | |
} | |
} |
This file contains 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
Classfile /x/Hoge.class | |
Last modified 2013/03/10; size 301 bytes | |
MD5 checksum 41f968697a1e7fe44a4d38e2d709d560 | |
Compiled from "Hoge.java" | |
public class Hoge | |
SourceFile: "Hoge.java" | |
minor version: 0 | |
major version: 52 | |
flags: ACC_PUBLIC, ACC_SUPER | |
Constant pool: |
This file contains 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.lang.reflect.Method; | |
import java.util.Arrays; | |
public class ParameterNameExample { | |
public static void main(String... args) { | |
Class<ParameterNameExample> clz = ParameterNameExample.class; | |
Arrays.stream(clz.getMethods()).filter(m -> m.getName().startsWith("method")) | |
.map(m -> m.getName() + Arrays.toString(m.getParameters())) |
This file contains 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
package net.hogedriven.irof.sandbox; | |
import org.dbunit.JdbcDatabaseTester; | |
import org.dbunit.database.DatabaseConfig; | |
import org.dbunit.database.IDatabaseConnection; | |
import org.dbunit.dataset.IDataSet; | |
import org.dbunit.ext.h2.H2DataTypeFactory; | |
import org.junit.rules.TestRule; | |
import org.junit.runner.Description; | |
import org.junit.runners.model.Statement; |
This file contains 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
package app; | |
public class CalcSpec extends Specs { | |
{ | |
it("1 足す 2 は 3", () -> { | |
expect(() -> 1 + 2).toEqual(3); | |
}); | |
it("1 割る 0 は例外", () -> { | |
expect(() -> 1 / 0).toThrow(ArithmeticException.class); | |
}); |