Skip to content

Commit

Permalink
テストのためのjarファイルを作るため、test_jarというmavenで管理するプロジェクトを追加しました。
Browse files Browse the repository at this point in the history
  • Loading branch information
akm committed Aug 14, 2010
1 parent f5f1642 commit 67c5512
Show file tree
Hide file tree
Showing 11 changed files with 266 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rmaven.yml
Expand Up @@ -4,3 +4,8 @@ java:
group_id: jp.rubybizcommons.rubeus
rake_prefix: java
pom_dir: java
test_jar:
artifact_id: java_supply
group_id: jp.rubybizcommons.rubeus.test
rake_prefix: test_jar
pom_dir: test_jar
89 changes: 89 additions & 0 deletions test/rubeus/reflection/test_method_modifier.rb
@@ -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 added test/rubeus_test.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions test_jar/.classpath
@@ -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>
1 change: 1 addition & 0 deletions test_jar/.gitignore
@@ -0,0 +1 @@
/target
17 changes: 17 additions & 0 deletions test_jar/.project
@@ -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>
57 changes: 57 additions & 0 deletions test_jar/mvn_plugins.yml
@@ -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
25 changes: 25 additions & 0 deletions test_jar/pom.xml
@@ -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>
@@ -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;
}
@@ -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 test_jar/src/test/java/jp/rubybizcommons/rubeus/test/AppTest.java
@@ -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 );
}
}

0 comments on commit 67c5512

Please sign in to comment.