Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
テストのためのjarファイルを作るため、test_jarというmavenで管理するプロジェクトを追加しました。
- Loading branch information
Showing
11 changed files
with
266 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
require 'test/unit' | ||
require 'rubygems' | ||
require 'rubeus' | ||
require File.expand_path('../../rubeus_test.jar', File.dirname(__FILE__)) | ||
|
||
Rubeus.verbose = true | ||
|
||
class TestMethodModifier < Test::Unit::TestCase | ||
include Rubeus::Reflection | ||
|
||
VariousMethods = jp.rubybizcommons.rubeus.test.reflection.VariousMethods | ||
|
||
def test_static? | ||
[java.lang.String, java.lang.Object, java.lang.Class, VariousMethods].each do |klass| | ||
klass.java_class.java_class_methods.each do |m| | ||
assert_equal true, m.static? | ||
end | ||
klass.java_class.java_instance_methods.each do |m| | ||
assert_equal false, m.static? | ||
end | ||
end | ||
end | ||
|
||
def test_abstract? | ||
m = java.util.AbstractList.java_class.java_instance_methods.detect{|m| m.name == "get"} | ||
assert_equal true, m.abstract? | ||
m = java.util.AbstractList.java_class.java_instance_methods.detect{|m| m.name == "add"} | ||
assert_equal false, m.abstract? | ||
end | ||
|
||
ALL_METHOD_NAMES = %w[main | ||
staticPublicStrictfp staticProtectedFinal staticPackageSynchronized staticPrivate | ||
publicStrictfp protectedFinal packageSynchronized privateFinal] | ||
|
||
def test_public? | ||
each_java_methods do |m| | ||
assert_equal %w[main staticPublicStrictfp publicStrictfp].include?(m.name), m.public? | ||
end | ||
end | ||
|
||
def test_protected? | ||
each_java_methods do |m| | ||
assert_equal %w[staticProtectedFinal protectedFinal].include?(m.name), m.protected? | ||
end | ||
end | ||
|
||
def test_package_scope? | ||
each_java_methods do |m| | ||
assert_equal %w[staticPackageSynchronized packageSynchronized].include?(m.name), m.package_scope? | ||
end | ||
end | ||
|
||
def test_private? | ||
each_java_methods do |m| | ||
assert_equal %w[staticPrivate privateFinal].include?(m.name), m.private? | ||
end | ||
end | ||
|
||
def test_final? | ||
each_java_methods do |m| | ||
assert_equal %w[staticProtectedFinal protectedFinal privateFinal].include?(m.name), m.final? | ||
end | ||
end | ||
|
||
def test_strict? | ||
each_java_methods do |m| | ||
assert_equal %w[main staticPublicStrictfp publicStrictfp].include?(m.name), m.public? | ||
end | ||
end | ||
|
||
def test_synchronized? | ||
each_java_methods do |m| | ||
assert_equal %w[staticPackageSynchronized packageSynchronized].include?(m.name), m.synchronized? | ||
end | ||
end | ||
|
||
private | ||
|
||
def each_java_methods(&block) | ||
unless @test_methods | ||
selector = lambda{|m| ALL_METHOD_NAMES.include?(m.name)} | ||
@test_methods = | ||
VariousMethods.java_class.java_instance_methods.select(&selector) + | ||
VariousMethods.java_class.java_class_methods.select(&selector) | ||
end | ||
@test_methods.each(&block) | ||
end | ||
|
||
end |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src/main/java"/> | ||
<classpathentry kind="src" path="src/test/java"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>test_jar</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
- clean | ||
- compiler | ||
- deploy | ||
- install | ||
- resources | ||
- site | ||
- surefire | ||
- verifier | ||
- ear | ||
- ejb | ||
- jar | ||
- rar | ||
- war | ||
- shade | ||
- changelog | ||
- changes | ||
- checkstyle | ||
- clover | ||
- doap | ||
- docck | ||
- javadoc | ||
- jxr | ||
- pmd | ||
- project-info-reports | ||
- surefire-report | ||
- ant | ||
- antrun | ||
- archetype | ||
- assembly | ||
- dependency | ||
- enforcer | ||
- gpg | ||
- help | ||
- invoker | ||
- one | ||
- patch | ||
- plugin | ||
- release | ||
- remote-resources | ||
- repository | ||
- scm | ||
- source | ||
- stage | ||
- eclipse | ||
- idea | ||
- build-helper | ||
- castor | ||
- javacc | ||
- jdepend | ||
- native | ||
- sql | ||
- taglist | ||
- cargo | ||
- jaxme | ||
- jetty | ||
- jalopy |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>jp.rubybizcommons.rubeus.test</groupId> | ||
<artifactId>rubeus_test</artifactId> | ||
<version>0.0.10</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>rubeus_test</name> | ||
<url>http://code.google.com/p/rubeus/</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>3.8.1</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
test_jar/src/main/java/jp/rubybizcommons/rubeus/test/reflection/VariousFields.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package jp.rubybizcommons.rubeus.test.reflection; | ||
|
||
public final class VariousFields { | ||
public volatile int publicVolatile; | ||
protected final int protectedFinal = 0; | ||
final int packageFinal = 0; | ||
private transient int privateTransientField; | ||
|
||
static public volatile int staticPublicVolatile; | ||
static protected final int staticProtectedFinal = 0; | ||
static final int staticPackageFinal = 0; | ||
static private transient int staticPrivateTransientField; | ||
} |
14 changes: 14 additions & 0 deletions
14
test_jar/src/main/java/jp/rubybizcommons/rubeus/test/reflection/VariousMethods.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package jp.rubybizcommons.rubeus.test.reflection; | ||
|
||
public final class VariousMethods { | ||
public static void main( String[] args ) {} | ||
static public strictfp void staticPublicStrictfp() {} | ||
static protected final void staticProtectedFinal() {} | ||
static synchronized void staticPackageSynchronized() {} | ||
static private void staticPrivate() {} | ||
|
||
public strictfp void publicStrictfp() {} | ||
protected final void protectedFinal() {} | ||
synchronized void packageSynchronized() {} | ||
private final void privateFinal() {} | ||
} |
38 changes: 38 additions & 0 deletions
38
test_jar/src/test/java/jp/rubybizcommons/rubeus/test/AppTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package jp.rubybizcommons.rubeus.test; | ||
|
||
import junit.framework.Test; | ||
import junit.framework.TestCase; | ||
import junit.framework.TestSuite; | ||
|
||
/** | ||
* Unit test for simple App. | ||
*/ | ||
public class AppTest | ||
extends TestCase | ||
{ | ||
/** | ||
* Create the test case | ||
* | ||
* @param testName name of the test case | ||
*/ | ||
public AppTest( String testName ) | ||
{ | ||
super( testName ); | ||
} | ||
|
||
/** | ||
* @return the suite of tests being tested | ||
*/ | ||
public static Test suite() | ||
{ | ||
return new TestSuite( AppTest.class ); | ||
} | ||
|
||
/** | ||
* Rigourous Test :-) | ||
*/ | ||
public void testApp() | ||
{ | ||
assertTrue( true ); | ||
} | ||
} |