lock_jar 0.10.0 → 0.10.2
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.
- checksums.yaml +4 -4
- data/.gitignore +59 -59
- data/.travis.yml +8 -8
- data/CHANGELOG.md +30 -21
- data/Gemfile +13 -13
- data/Guardfile +9 -9
- data/README.md +375 -375
- data/Rakefile +24 -24
- data/bundler/Gemfile +21 -21
- data/bundler/LICENSE.txt +22 -22
- data/bundler/README.md +29 -29
- data/bundler/Rakefile +2 -2
- data/bundler/lib/lock_jar_bundler/bundler.rb +35 -35
- data/bundler/lib/lock_jar_bundler/piggy_back.rb +97 -97
- data/bundler/lib/lock_jar_bundler/version.rb +5 -5
- data/bundler/lib/lock_jar_bundler.rb +4 -4
- data/bundler/lock_jar_bundler.gemspec +24 -24
- data/bundler/spec/Jarfile +2 -2
- data/bundler/spec/dummy_gem/dummy_gem.gemspec +19 -19
- data/bundler/spec/lock_jar_bundler_spec.rb +48 -48
- data/bundler/spec/spec_helper.rb +88 -88
- data/lib/lock_jar/buildr.rb +144 -144
- data/lib/lock_jar/bundler.rb +154 -154
- data/lib/lock_jar/cli.rb +64 -64
- data/lib/lock_jar/domain/artifact.rb +123 -123
- data/lib/lock_jar/domain/dsl.rb +187 -187
- data/lib/lock_jar/domain/dsl_helper.rb +83 -83
- data/lib/lock_jar/domain/gem_dsl.rb +44 -44
- data/lib/lock_jar/domain/jarfile_dsl.rb +46 -46
- data/lib/lock_jar/domain/lockfile.rb +113 -113
- data/lib/lock_jar/maven.rb +111 -111
- data/lib/lock_jar/registry.rb +92 -92
- data/lib/lock_jar/resolver.rb +95 -95
- data/lib/lock_jar/runtime.rb +359 -355
- data/lib/lock_jar/version.rb +3 -3
- data/lib/lock_jar.rb +172 -177
- data/lock_jar.gemspec +27 -27
- data/spec/fixtures/Jarfile +13 -13
- data/spec/fixtures/Jarfile2 +1 -0
- data/spec/lock_jar/class_loader_spec.rb +57 -57
- data/spec/lock_jar/cli_spec.rb +100 -100
- data/spec/lock_jar/domain/dsl_helper_spec.rb +52 -52
- data/spec/lock_jar/domain/dsl_spec.rb +57 -57
- data/spec/lock_jar/maven_spec.rb +23 -23
- data/spec/lock_jar/resolver_spec.rb +26 -26
- data/spec/lock_jar/runtime_spec.rb +26 -26
- data/spec/lock_jar_spec.rb +372 -295
- data/spec/pom.xml +34 -34
- data/spec/spec_helper.rb +38 -38
- data/spec/support/helper.rb +44 -44
- metadata +3 -1
data/lib/lock_jar/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module LockJar
|
2
|
-
VERSION = '0.10.
|
3
|
-
end
|
1
|
+
module LockJar
|
2
|
+
VERSION = '0.10.2'
|
3
|
+
end
|
data/lib/lock_jar.rb
CHANGED
@@ -1,177 +1,172 @@
|
|
1
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
-
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
-
# work for additional information regarding copyright ownership. The ASF
|
4
|
-
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
-
# "License"); you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
-
# License for the specific language governing permissions and limitations under
|
14
|
-
# the License.
|
15
|
-
|
16
|
-
require "yaml"
|
17
|
-
require 'rubygems'
|
18
|
-
require 'lock_jar/resolver'
|
19
|
-
require 'lock_jar/runtime'
|
20
|
-
require 'lock_jar/version'
|
21
|
-
require 'lock_jar/domain/lockfile'
|
22
|
-
require 'lock_jar/domain/dsl'
|
23
|
-
|
24
|
-
#
|
25
|
-
# LockJar manages Java Jars for Ruby.
|
26
|
-
#
|
27
|
-
# @author Michael Guymon
|
28
|
-
#
|
29
|
-
module LockJar
|
30
|
-
|
31
|
-
#
|
32
|
-
# Override LockJar configuration
|
33
|
-
#
|
34
|
-
def self.config( opts )
|
35
|
-
Runtime.instance.resolver( opts )
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.install( *args, &blk )
|
39
|
-
lockfile =
|
40
|
-
opts
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
Runtime.instance.
|
59
|
-
end
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
#
|
64
|
-
# * An arg of a
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
#
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
LockJar::Domain::Lockfile.read( lockfile )
|
174
|
-
end
|
175
|
-
|
176
|
-
end
|
177
|
-
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
require "yaml"
|
17
|
+
require 'rubygems'
|
18
|
+
require 'lock_jar/resolver'
|
19
|
+
require 'lock_jar/runtime'
|
20
|
+
require 'lock_jar/version'
|
21
|
+
require 'lock_jar/domain/lockfile'
|
22
|
+
require 'lock_jar/domain/dsl'
|
23
|
+
|
24
|
+
#
|
25
|
+
# LockJar manages Java Jars for Ruby.
|
26
|
+
#
|
27
|
+
# @author Michael Guymon
|
28
|
+
#
|
29
|
+
module LockJar
|
30
|
+
|
31
|
+
#
|
32
|
+
# Override LockJar configuration
|
33
|
+
#
|
34
|
+
def self.config( opts )
|
35
|
+
Runtime.instance.resolver( opts )
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.install( *args, &blk )
|
39
|
+
lockfile, groups, opts = extract_args :lockfile, args, &blk
|
40
|
+
Runtime.instance.install( lockfile, groups, opts, &blk )
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
# Lists all dependencies as notations for groups from the Jarfile.lock. Depending on the type of arg, a different configuration is set.
|
45
|
+
#
|
46
|
+
# * An arg of a String will set the Jarfile.lock, e.g. 'Better.lock'. Default lock file is *Jarfile.lock*.
|
47
|
+
# * An arg of an Array will set the groups, e.g. ['development','test']. Defaults group is *default*
|
48
|
+
# * An arg of a Hash will set the options, e.g. { :local_repo => 'path' }
|
49
|
+
# * :local_repo [String] sets the local repo path
|
50
|
+
# * :local_paths [Boolean] to true converts the notations to paths to jars in the local repo path
|
51
|
+
# * :resolve [Boolean] to true will make transitive dependences resolve before loading to classpath
|
52
|
+
#
|
53
|
+
# A block can be passed in, overriding values from a Jarfile.lock.
|
54
|
+
#
|
55
|
+
# @return [Array] of jar and mapped path
|
56
|
+
def self.list( *args, &blk )
|
57
|
+
lockfile, groups, opts = extract_args :lockfile, args, &blk
|
58
|
+
Runtime.instance.list( lockfile, groups, opts, &blk )
|
59
|
+
end
|
60
|
+
|
61
|
+
# LockJar.load(*args): Loads all dependencies to the classpath for groups from the Jarfile.lock. Depending on the type of arg, a different configuration is set.
|
62
|
+
# * An arg of a String will set the Jarfile.lock, e.g. 'Better.lock'. Default lock file is *Jarfile.lock*.
|
63
|
+
# * An arg of an Array will set the groups, e.g. ['development','test'].Defaults group is *default*.
|
64
|
+
# * An arg of a Hash will set the options, e.g. { :local_repo => 'path' }
|
65
|
+
# * :local_repo sets the local repo path
|
66
|
+
# * :resolve to true will make transitive dependences resolve before loading to classpath
|
67
|
+
#
|
68
|
+
# A block can be passed in, overriding values from a Jarfile.lock.
|
69
|
+
#
|
70
|
+
# @return [Array] of absolute paths of jars and mapped paths loaded into claspath
|
71
|
+
def self.load( *args, &blk )
|
72
|
+
lockfile, groups, opts = extract_args :lockfile, args, &blk
|
73
|
+
Runtime.instance.load( lockfile, groups, opts, &blk )
|
74
|
+
end
|
75
|
+
|
76
|
+
# Lock a Jarfile and generate a Jarfile.lock.
|
77
|
+
#
|
78
|
+
# LockJar.lock accepts an Array for parameters. Depending on the type of arg, a different configuration is set.
|
79
|
+
#
|
80
|
+
# * An arg of a String will set the Jarfile, e.g. 'Jarfile.different'. Default Jarfile is *Jarfile*.
|
81
|
+
# * An arg of a Hash will set the options, e.g. { :local_repo => 'path' }
|
82
|
+
# * :download_artifacts if true, will download jars to local repo. Defaults to true.
|
83
|
+
# * :local_repo sets the local repo path
|
84
|
+
# * :lockfile sets the Jarfile.lock path. Default lockfile is *Jarfile.lock*.
|
85
|
+
#
|
86
|
+
# A block can be passed in, overriding values from a Jarfile.
|
87
|
+
#
|
88
|
+
# @return [Hash] Lock data
|
89
|
+
def self.lock( *args, &blk )
|
90
|
+
jarfile, groups, opts = extract_args :jarfile, args, &blk
|
91
|
+
Runtime.instance.lock( jarfile, opts, &blk )
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# Read a Jafile.lock and convert it to a LockJar::Domain::Lockfile
|
96
|
+
#
|
97
|
+
# @param [String] lockfile path to lockfile
|
98
|
+
# @return [Hash] Lock Data
|
99
|
+
def self.read( lockfile )
|
100
|
+
LockJar::Domain::Lockfile.read( lockfile )
|
101
|
+
end
|
102
|
+
|
103
|
+
# Add a Jarfile to be included when LockJar.lock_registered_jarfiles is called.
|
104
|
+
#
|
105
|
+
# @param [String] jarfile path to register
|
106
|
+
# @return [Array] All registered jarfiles
|
107
|
+
def self.register_jarfile( jarfile )
|
108
|
+
fail "Jarfile not found: #{ jarfile }" unless File.exists? jarfile
|
109
|
+
registered_jarfiles << jarfile
|
110
|
+
end
|
111
|
+
|
112
|
+
def self.reset_registered_jarfiles
|
113
|
+
@@registered_jarfiles = []
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.registered_jarfiles
|
117
|
+
@@registered_jarfiles ||= []
|
118
|
+
end
|
119
|
+
|
120
|
+
# Lock the registered Jarfiles and generate a Jarfile.lock.
|
121
|
+
#
|
122
|
+
# Options and groups are passed through to the LockJar.lock method, but
|
123
|
+
# if a Jarfile is specified, it will be ignored. Use LockJar.register_jarfile
|
124
|
+
# to add dependencies.
|
125
|
+
#
|
126
|
+
# A block can be passed in, overriding values from the Jarfiles.
|
127
|
+
#
|
128
|
+
# @return [Hash] Lock data
|
129
|
+
def self.lock_registered_jarfiles( *args, &blk )
|
130
|
+
jarfiles = registered_jarfiles
|
131
|
+
return if jarfiles.empty?
|
132
|
+
instances = jarfiles.map do |jarfile|
|
133
|
+
LockJar::Domain::JarfileDsl.create jarfile
|
134
|
+
end
|
135
|
+
combined = instances.reduce do |result, inst|
|
136
|
+
LockJar::Domain::DslHelper.merge result, inst
|
137
|
+
end
|
138
|
+
args = args.reject { |arg| arg.is_a? String }
|
139
|
+
lock combined, *args, &blk
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
def self.extract_args(type, args, &blk )
|
145
|
+
lockfile_or_path = nil
|
146
|
+
opts = {}
|
147
|
+
groups = ['default']
|
148
|
+
args.each do |arg|
|
149
|
+
case arg
|
150
|
+
when Hash
|
151
|
+
opts.merge!( arg )
|
152
|
+
when String
|
153
|
+
lockfile_or_path = arg
|
154
|
+
when LockJar::Domain::Lockfile
|
155
|
+
lockfile_or_path = arg if type == :lockfile
|
156
|
+
when LockJar::Domain::Dsl
|
157
|
+
lockfile_or_path = arg if type == :jarfile
|
158
|
+
when Array
|
159
|
+
groups = arg
|
160
|
+
end
|
161
|
+
end
|
162
|
+
if blk.nil? && lockfile_or_path.nil?
|
163
|
+
if type == :lockfile
|
164
|
+
lockfile_or_path = opts.fetch(:lockfile, 'Jarfile.lock')
|
165
|
+
elsif type == :jarfile
|
166
|
+
lockfile_or_path = 'Jarfile'
|
167
|
+
end
|
168
|
+
end
|
169
|
+
[lockfile_or_path, groups, opts]
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
data/lock_jar.gemspec
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
|
5
|
-
require 'lock_jar/version'
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = 'lock_jar'
|
9
|
-
s.version = LockJar::VERSION
|
10
|
-
s.authors = ['Michael Guymon']
|
11
|
-
s.date = '2014-03-06'
|
12
|
-
s.description = 'Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test. The Jarfile.lock can be used to populate the classpath'
|
13
|
-
s.email = 'michael@tobedevoured.com'
|
14
|
-
s.files = `git ls-files -z`.split("\x0")
|
15
|
-
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
-
s.extra_rdoc_files = %w(LICENSE README.md)
|
18
|
-
s.homepage = 'http://github.com/mguymon/lock_jar'
|
19
|
-
s.licenses = %w(Apache)
|
20
|
-
s.require_paths = %w(lib)
|
21
|
-
s.summary = 'Manage Jar files for Ruby'
|
22
|
-
|
23
|
-
s.add_dependency(%q<naether>, ['~> 0.13.1'])
|
24
|
-
s.add_dependency(%q<thor>, ['>= 0.18.1'])
|
25
|
-
|
26
|
-
end
|
27
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
require 'lock_jar/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'lock_jar'
|
9
|
+
s.version = LockJar::VERSION
|
10
|
+
s.authors = ['Michael Guymon']
|
11
|
+
s.date = '2014-03-06'
|
12
|
+
s.description = 'Manage Jar files for Ruby. In the spirit of Bundler, a Jarfile is used to generate a Jarfile.lock that contains all the resolved jar dependencies for scopes runtime, compile, and test. The Jarfile.lock can be used to populate the classpath'
|
13
|
+
s.email = 'michael@tobedevoured.com'
|
14
|
+
s.files = `git ls-files -z`.split("\x0")
|
15
|
+
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
17
|
+
s.extra_rdoc_files = %w(LICENSE README.md)
|
18
|
+
s.homepage = 'http://github.com/mguymon/lock_jar'
|
19
|
+
s.licenses = %w(Apache)
|
20
|
+
s.require_paths = %w(lib)
|
21
|
+
s.summary = 'Manage Jar files for Ruby'
|
22
|
+
|
23
|
+
s.add_dependency(%q<naether>, ['~> 0.13.1'])
|
24
|
+
s.add_dependency(%q<thor>, ['>= 0.18.1'])
|
25
|
+
|
26
|
+
end
|
27
|
+
|
data/spec/fixtures/Jarfile
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
local_repo '~/.m2/repository'
|
2
|
-
repository 'http://mirrors.ibiblio.org/pub/mirrors/maven2'
|
3
|
-
|
4
|
-
jar "org.apache.mina:mina-core:2.0.4"
|
5
|
-
local "spec/fixtures/naether-0.13.0.jar"
|
6
|
-
pom 'spec/pom.xml'
|
7
|
-
|
8
|
-
group 'development' do
|
9
|
-
jar 'com.typesafe:config:jar:0.5.0'
|
10
|
-
end
|
11
|
-
|
12
|
-
group 'test' do
|
13
|
-
jar 'junit:junit:jar:4.10'
|
1
|
+
local_repo '~/.m2/repository'
|
2
|
+
repository 'http://mirrors.ibiblio.org/pub/mirrors/maven2'
|
3
|
+
|
4
|
+
jar "org.apache.mina:mina-core:2.0.4"
|
5
|
+
local "spec/fixtures/naether-0.13.0.jar"
|
6
|
+
pom 'spec/pom.xml'
|
7
|
+
|
8
|
+
group 'development' do
|
9
|
+
jar 'com.typesafe:config:jar:0.5.0'
|
10
|
+
end
|
11
|
+
|
12
|
+
group 'test' do
|
13
|
+
jar 'junit:junit:jar:4.10'
|
14
14
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
jar "org.eclipse.jetty:jetty-servlet:8.1.3.v20120416"
|
@@ -1,57 +1,57 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'lock_jar/class_loader'
|
3
|
-
|
4
|
-
|
5
|
-
describe LockJar::ClassLoader, "#isolate" do
|
6
|
-
|
7
|
-
if Naether.platform != 'java'
|
8
|
-
pending "need tests for RJB backed classloader"
|
9
|
-
else
|
10
|
-
it "should create a SimpleEmail" do
|
11
|
-
# Generate the IsolateJarfile.lock
|
12
|
-
LockJar.lock( :lockfile => "#{TEMP_DIR}/IsolateJarfile.lock" ) do
|
13
|
-
jar 'org.apache.commons:commons-email:1.2'
|
14
|
-
end
|
15
|
-
|
16
|
-
email = LockJar::ClassLoader.new( "#{TEMP_DIR}/IsolateJarfile.lock" ).isolate do
|
17
|
-
email = new_instance( 'org.apache.commons.mail.SimpleEmail' )
|
18
|
-
email.setSubject( 'test subject' )
|
19
|
-
|
20
|
-
email
|
21
|
-
end
|
22
|
-
|
23
|
-
email.getSubject().should eql 'test subject'
|
24
|
-
|
25
|
-
unless $CLASSPATH.nil?
|
26
|
-
$CLASSPATH.to_a.join(' ').should_not =~ /commons-email-1\.2\.jar/
|
27
|
-
end
|
28
|
-
|
29
|
-
expect { org.apache.commons.mail.SimpleEmail.new }.to raise_error
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should create a JsonFactory and ObjectMapper" do
|
33
|
-
# Generate the IsolateJarfile.lock
|
34
|
-
LockJar.lock( :lockfile => "#{TEMP_DIR}/IsolateJarfile.lock" ) do
|
35
|
-
jar 'com.fasterxml.jackson.core:jackson-core:2.0.6'
|
36
|
-
jar 'com.fasterxml.jackson.core:jackson-databind:2.0.6'
|
37
|
-
end
|
38
|
-
|
39
|
-
json = '{ "test1": "1test1", "test2": "2test2"}'
|
40
|
-
|
41
|
-
map = LockJar::ClassLoader.new( "#{TEMP_DIR}/IsolateJarfile.lock" ).isolate do
|
42
|
-
factory = new_instance( 'com.fasterxml.jackson.core.JsonFactory' )
|
43
|
-
mapper = new_instance( 'com.fasterxml.jackson.databind.ObjectMapper', factory)
|
44
|
-
mapper.readValue(json, java.util.Map.java_class)
|
45
|
-
end
|
46
|
-
|
47
|
-
map.get('test1').should eql "1test1"
|
48
|
-
map.get('test2').should eql "2test2"
|
49
|
-
|
50
|
-
unless $CLASSPATH.nil?
|
51
|
-
$CLASSPATH.to_a.join(' ').should_not =~ /jackson-databind-2\.0\.6\.jar/
|
52
|
-
end
|
53
|
-
|
54
|
-
expect { com.fasterxml.jackson.core.JsonFactory.new }.to raise_error
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lock_jar/class_loader'
|
3
|
+
|
4
|
+
|
5
|
+
describe LockJar::ClassLoader, "#isolate" do
|
6
|
+
|
7
|
+
if Naether.platform != 'java'
|
8
|
+
pending "need tests for RJB backed classloader"
|
9
|
+
else
|
10
|
+
it "should create a SimpleEmail" do
|
11
|
+
# Generate the IsolateJarfile.lock
|
12
|
+
LockJar.lock( :lockfile => "#{TEMP_DIR}/IsolateJarfile.lock" ) do
|
13
|
+
jar 'org.apache.commons:commons-email:1.2'
|
14
|
+
end
|
15
|
+
|
16
|
+
email = LockJar::ClassLoader.new( "#{TEMP_DIR}/IsolateJarfile.lock" ).isolate do
|
17
|
+
email = new_instance( 'org.apache.commons.mail.SimpleEmail' )
|
18
|
+
email.setSubject( 'test subject' )
|
19
|
+
|
20
|
+
email
|
21
|
+
end
|
22
|
+
|
23
|
+
email.getSubject().should eql 'test subject'
|
24
|
+
|
25
|
+
unless $CLASSPATH.nil?
|
26
|
+
$CLASSPATH.to_a.join(' ').should_not =~ /commons-email-1\.2\.jar/
|
27
|
+
end
|
28
|
+
|
29
|
+
expect { org.apache.commons.mail.SimpleEmail.new }.to raise_error
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should create a JsonFactory and ObjectMapper" do
|
33
|
+
# Generate the IsolateJarfile.lock
|
34
|
+
LockJar.lock( :lockfile => "#{TEMP_DIR}/IsolateJarfile.lock" ) do
|
35
|
+
jar 'com.fasterxml.jackson.core:jackson-core:2.0.6'
|
36
|
+
jar 'com.fasterxml.jackson.core:jackson-databind:2.0.6'
|
37
|
+
end
|
38
|
+
|
39
|
+
json = '{ "test1": "1test1", "test2": "2test2"}'
|
40
|
+
|
41
|
+
map = LockJar::ClassLoader.new( "#{TEMP_DIR}/IsolateJarfile.lock" ).isolate do
|
42
|
+
factory = new_instance( 'com.fasterxml.jackson.core.JsonFactory' )
|
43
|
+
mapper = new_instance( 'com.fasterxml.jackson.databind.ObjectMapper', factory)
|
44
|
+
mapper.readValue(json, java.util.Map.java_class)
|
45
|
+
end
|
46
|
+
|
47
|
+
map.get('test1').should eql "1test1"
|
48
|
+
map.get('test2').should eql "2test2"
|
49
|
+
|
50
|
+
unless $CLASSPATH.nil?
|
51
|
+
$CLASSPATH.to_a.join(' ').should_not =~ /jackson-databind-2\.0\.6\.jar/
|
52
|
+
end
|
53
|
+
|
54
|
+
expect { com.fasterxml.jackson.core.JsonFactory.new }.to raise_error
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|