bee_java 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2008-2009 Michel Casabianca <michel.casabianca@gmail.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'bee'
18
+ require 'test/unit'
19
+ $:.unshift(File.expand_path(File.dirname(__FILE__)))
20
+ require 'test_build'
21
+ require 'test_build_listener'
22
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
23
+ require 'bee_task_java'
24
+
25
+ # Test case for bee task.
26
+ class TestBeeTaskJava < Test::Unit::TestCase
27
+
28
+ # Create a context object and load tasks in it.
29
+ def setup
30
+ super
31
+ @context = Bee::Context.new(nil)
32
+ @listener = TestBuildListener.new
33
+ @build = TestBuild.new(@context, @listener)
34
+ @package = Bee::Task::Java.new(@build)
35
+ end
36
+
37
+ def test_javac
38
+ # change directory to test dir
39
+ previous_dir = Dir.pwd
40
+ Dir.chdir(File.expand_path(File.dirname(__FILE__)))
41
+ begin
42
+ # run nominal case
43
+ @package.javac({'src' => 'src', 'dest' => 'build/classes'})
44
+ assert_equal("Compiling 1 Java source file(s)\n", @listener.output)
45
+ assert(File.exists?('build/classes/test/Test.class'))
46
+ # run error case: missing src parameter
47
+ begin
48
+ @package.javac({'dest' => 'build/classes'})
49
+ rescue
50
+ assert_equal("javac 'src' parameter is mandatory", $!.message)
51
+ end
52
+ # run error case: missing dest parameter
53
+ begin
54
+ @package.javac({'src' => 'src'})
55
+ rescue
56
+ assert_equal("javac 'dest' parameter is mandatory", $!.message)
57
+ end
58
+ ensure
59
+ if File.exists?('build')
60
+ FileUtils.rm_rf('build')
61
+ end
62
+ Dir.chdir(previous_dir)
63
+ end
64
+ end
65
+
66
+ def test_jar
67
+ # change directory to test dir
68
+ previous_dir = Dir.pwd
69
+ Dir.chdir(File.expand_path(File.dirname(__FILE__)))
70
+ begin
71
+ # run nominal case
72
+ @package.javac({'src' => 'src', 'dest' => 'build/classes'})
73
+ @listener.output = ''
74
+ @package.jar({'src' => 'build/classes', 'dest' => 'build/test.jar'})
75
+ assert_equal("Processing Jar archive 'build/test.jar'\n",
76
+ @listener.output)
77
+ assert(File.exists?('build/test.jar'))
78
+ ensure
79
+ if File.exists?('build')
80
+ FileUtils.rm_rf('build')
81
+ end
82
+ Dir.chdir(previous_dir)
83
+ end
84
+ end
85
+
86
+ def test_java
87
+ # change directory to test dir
88
+ previous_dir = Dir.pwd
89
+ Dir.chdir(File.expand_path(File.dirname(__FILE__)))
90
+ begin
91
+ # run nominal case
92
+ @package.javac({'src' => 'src', 'dest' => 'build/classes'})
93
+ @listener.output = ''
94
+ @package.java({'classpath' => 'build/classes', 'main' => 'test.Test'})
95
+ assert_equal("Running java class 'test.Test'\n",
96
+ @listener.output)
97
+ ensure
98
+ if File.exists?('build')
99
+ FileUtils.rm_rf('build')
100
+ end
101
+ Dir.chdir(previous_dir)
102
+ end
103
+ 1 end
104
+
105
+ def test_javadoc
106
+ # change directory to test dir
107
+ previous_dir = Dir.pwd
108
+ Dir.chdir(File.expand_path(File.dirname(__FILE__)))
109
+ begin
110
+ # run nominal case
111
+ @package.javadoc({'src' => 'src', 'dest' => 'build/api'})
112
+ assert_equal("Running javadoc on 1 Java source file(s)\n",
113
+ @listener.output)
114
+ assert(File.exists?('build/api/index.html'))
115
+ ensure
116
+ if File.exists?('build')
117
+ FileUtils.rm_rf('build')
118
+ end
119
+ Dir.chdir(previous_dir)
120
+ end
121
+ end
122
+
123
+ def test_junit
124
+ if ENV['NET_TEST'] == 'true'
125
+ # change directory to test dir
126
+ previous_dir = Dir.pwd
127
+ Dir.chdir(File.expand_path(File.dirname(__FILE__)))
128
+ begin
129
+ # run nominal case
130
+ @package.javac({'src' => 'src', 'dest' => 'build/classes'})
131
+ @package.deps({ 'src' => 'dependencies.yml', 'dest' => 'build/lib',
132
+ 'repos' => 'http://www.ibiblio.org/maven'})
133
+ @package.javac({ 'src' => 'test',
134
+ 'dest' => 'build/classes',
135
+ 'classpath' => ['build/classes', 'build/lib/*.jar']})
136
+ @listener.output = ''
137
+ @package.junit({ 'src' => 'test',
138
+ 'classpath' => ['build/classes', 'build/lib/*.jar']})
139
+ assert_equal("Running JUnit on 1 test file(s)\n",
140
+ @listener.output)
141
+ ensure
142
+ if File.exists?('build')
143
+ FileUtils.rm_rf('build')
144
+ end
145
+ Dir.chdir(previous_dir)
146
+ end
147
+ end
148
+ end
149
+
150
+ def test_deps
151
+ if ENV['NET_TEST'] == 'true'
152
+ # change directory to test dir
153
+ previous_dir = Dir.pwd
154
+ Dir.chdir(File.expand_path(File.dirname(__FILE__)))
155
+ begin
156
+ # run nominal case
157
+ @package.deps({ 'src' => 'dependencies.yml',
158
+ 'dest' => 'build/lib',
159
+ 'repos' => 'http://www.ibiblio.org/maven'})
160
+ assert_equal("Fetching 1 dependency(ies) to directory 'build/lib'\n",
161
+ @listener.output)
162
+ assert(File.exists?('build/lib/junit-4.3.jar'))
163
+ ensure
164
+ if File.exists?('build')
165
+ FileUtils.rm_rf('build')
166
+ end
167
+ Dir.chdir(previous_dir)
168
+ end
169
+ end
170
+ end
171
+
172
+ def test_classpath
173
+ if ENV['NET_TEST'] == 'true'
174
+ # change directory to test dir
175
+ previous_dir = Dir.pwd
176
+ Dir.chdir(File.expand_path(File.dirname(__FILE__)))
177
+ begin
178
+ @package.classpath( { 'file' => 'pom.xml',
179
+ 'property' => 'classpath' } )
180
+ dependencies = ['ehcache:ehcache:1.2beta4:jar',
181
+ 'commons-logging-api:commons-logging:1.0.4:jar',
182
+ 'commons-collections:commons-collections:2.1.1:jar']
183
+ message = dependencies.map { |dep| "Downloading dependency '#{dep}'...\n" }.join
184
+ assert_equal(messages, @listener.output)
185
+ root = File.expand('~/.m2/repository')
186
+ puts 'TEST'
187
+ puts @package.build.get_property('classpath')
188
+ ensure
189
+ Dir.chdir(previous_dir)
190
+ end
191
+ end
192
+ end
193
+
194
+ end
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2008-2009 Michel Casabianca <michel.casabianca@gmail.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ require 'bee'
18
+ require 'test/unit'
19
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
20
+ require 'dependency_resolver'
21
+
22
+ # Test case for dependency resolver.
23
+ class TestDependencyResolver < Test::Unit::TestCase
24
+
25
+ # Create a context object and load tasks in it.
26
+ def setup
27
+ super
28
+ @resolver = Bee::Task::Maven2DependencyResolver.new('test/pom.xml', false)
29
+ end
30
+
31
+ def test_classpath
32
+ classpath = @resolver.classpath
33
+ # TODO
34
+ end
35
+
36
+ end
@@ -0,0 +1,28 @@
1
+ // Copyright 2008-2009 Michel Casabianca <michel.casabianca@gmail.com>
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ package test;
16
+
17
+ import junit.framework.TestCase;
18
+
19
+ public class TestTest
20
+ extends TestCase {
21
+
22
+ public void testHello() {
23
+ String expected = "Hello World!";
24
+ String actual = Test.hello("World");
25
+ assertEquals(expected, actual);
26
+ }
27
+
28
+ }
@@ -0,0 +1,26 @@
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Empty build for testing purpose. Contains a single context.
16
+ class TestBuild
17
+
18
+ attr_reader :context
19
+ attr_reader :listener
20
+
21
+ def initialize(context, listener)
22
+ @context = context
23
+ @listener = listener
24
+ end
25
+
26
+ end
@@ -0,0 +1,62 @@
1
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Test build listener.
16
+ class TestBuildListener
17
+
18
+ attr_reader :started
19
+ attr_reader :finished
20
+ attr_reader :targets
21
+ attr_reader :tasks
22
+ attr_reader :success
23
+ attr_reader :errors
24
+ attr_accessor :output
25
+ attr_reader :verbose
26
+
27
+ def initialize
28
+ @targets = []
29
+ @tasks = []
30
+ @output = ''
31
+ @verbose = false
32
+ end
33
+
34
+ def build_started(build)
35
+ @started = true
36
+ end
37
+
38
+ def build_finished(build)
39
+ @finished = true
40
+ end
41
+
42
+ def target(target)
43
+ @targets << target
44
+ end
45
+
46
+ def task(task)
47
+ @tasks << tasks
48
+ end
49
+
50
+ def error(exception)
51
+ @errors = exception
52
+ end
53
+
54
+ def print(text)
55
+ @output << text
56
+ end
57
+
58
+ def puts(text)
59
+ @output << text + "\n"
60
+ end
61
+
62
+ end
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Copyright 2006-2010 Michel Casabianca <michel.casabianca@gmail.com>
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Script that runs all tests in current directory (and subdirectories)
18
+ # in a single test suite.
19
+
20
+ require 'find'
21
+
22
+ Find.find(File.dirname(__FILE__)) do |path|
23
+ if File.file?(path) and path =~ /tc_.+\.rb$/
24
+ load path
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bee_java
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Michel Casabianca
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-10-11 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bee
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.8.0
24
+ version:
25
+ description:
26
+ email: michel.casabianca@gmail.com
27
+ executables:
28
+ - bee2maven
29
+ - maven2bee
30
+ - gendeps
31
+ extensions: []
32
+
33
+ extra_rdoc_files:
34
+ - build/README
35
+ - LICENSE
36
+ files:
37
+ - bin/bee2maven
38
+ - bin/beedoc
39
+ - bin/gendeps
40
+ - bin/maven2bee
41
+ - lib/bee_task_java.rb
42
+ - lib/dependency_resolver.rb
43
+ - test/build.yml
44
+ - test/dependencies.xml
45
+ - test/dependencies.yml
46
+ - test/manifest.erb
47
+ - test/pom.xml
48
+ - test/src/test/Test.java
49
+ - test/tc_bee_task_java.rb
50
+ - test/tc_dependency_resolver.rb
51
+ - test/test/test/TestTest.java
52
+ - test/test_build.rb
53
+ - test/test_build_listener.rb
54
+ - test/ts_bee_java.rb
55
+ - egg/lib/build.erb
56
+ - egg/lib/dependencies.yml
57
+ - egg/lib/source.erb
58
+ - egg/lib/test.erb
59
+ - egg/lib.yml
60
+ - egg/tiny/build.erb
61
+ - egg/tiny/source.erb
62
+ - egg/tiny.yml
63
+ - egg/xmlrpc/build.yml
64
+ - egg/xmlrpc/dependencies.yml
65
+ - egg/xmlrpc/src/test/Client.java
66
+ - egg/xmlrpc/src/test/handlers.properties
67
+ - egg/xmlrpc/src/test/Server.java
68
+ - egg/xmlrpc/src/test/TestHandler.java
69
+ - egg/xmlrpc.yml
70
+ - build/README
71
+ - LICENSE
72
+ has_rdoc: true
73
+ homepage: http://bee.rubyforge.org
74
+ licenses: []
75
+
76
+ post_install_message: Enjoy bee!
77
+ rdoc_options: []
78
+
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: "0"
86
+ version:
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: "0"
92
+ version:
93
+ requirements: []
94
+
95
+ rubyforge_project: none
96
+ rubygems_version: 1.3.5
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: BeeJava is a package to build and generate Java project using Bee.
100
+ test_files:
101
+ - test/ts_bee_java.rb