Skip to content

Commit 4b13232

Browse files
committed
Table implementation in java shim with example
This will fix issue FAB-215 https://jira.hyperledger.org/browse/FAB-215 Change-Id: I2599ba09f81ae44f9e6f28b53917300d2922a897 Signed-off-by: Satheesh Kathamuthu <[email protected]>
1 parent 0c3fb65 commit 4b13232

File tree

9 files changed

+784
-592
lines changed

9 files changed

+784
-592
lines changed

Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -209,16 +209,16 @@ build/image/ccenv/.dummy: build/image/src/.dummy build/image/ccenv/bin/protoc-ge
209209
@touch $@
210210

211211
# Special override for java-image
212+
# Following items are packed and sent to docker context while building image
213+
# 1. Java shim layer source code
214+
# 2. Proto files used to generate java classes
215+
# 3. Gradle settings file
212216
build/image/javaenv/.dummy: Makefile $(JAVASHIM_DEPS)
213217
@echo "Building docker javaenv-image"
214218
@mkdir -p $(@D)
215219
@cat images/javaenv/Dockerfile.in > $(@D)/Dockerfile
216-
# Following items are packed and sent to docker context while building image
217-
# 1. Java shim layer source code
218-
# 2. Proto files used to generate java classes
219-
# 3. Gradle settings file
220220
@git ls-files core/chaincode/shim/java | tar -jcT - > $(@D)/javashimsrc.tar.bz2
221-
@git ls-files protos settings.gradle | tar -jcT - > $(@D)/protos.tar.bz2
221+
@git ls-files protos core/chaincode/shim/table.proto settings.gradle | tar -jcT - > $(@D)/protos.tar.bz2
222222
docker build -t $(PROJECT_NAME)-javaenv $(@D)
223223
docker tag $(PROJECT_NAME)-javaenv $(PROJECT_NAME)-javaenv:$(DOCKER_TAG)
224224
@touch $@

bddtests/java_shim.feature

+74-18
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,44 @@
2525

2626

2727
#@chaincodeImagesUpToDate
28-
Feature: SimpleSample Java example
28+
Feature: Java chaincode example
2929

3030
Scenario: java SimpleSample chaincode example single peer
3131
Given we compose "docker-compose-1.yml"
3232
When requesting "/chain" from "vp0"
3333
Then I should get a JSON response with "height" = "1"
34-
When I deploy lang chaincode "examples/chaincode/java/SimpleSample" of "JAVA" with ctor "init" to "vp0"
35-
| arg1 | arg2 | arg3 | arg4 |
36-
| a | 100 | b | 200 |
37-
Then I should have received a chaincode name
38-
Then I wait up to "300" seconds for transaction to be committed to all peers
34+
When I deploy lang chaincode "examples/chaincode/java/SimpleSample" of "JAVA" with ctor "init" to "vp0"
35+
| arg1 | arg2 | arg3 | arg4 |
36+
| a | 100 | b | 200 |
37+
Then I should have received a chaincode name
38+
Then I wait up to "300" seconds for transaction to be committed to all peers
3939

40-
When requesting "/chain" from "vp0"
41-
Then I should get a JSON response with "height" = "2"
40+
When requesting "/chain" from "vp0"
41+
Then I should get a JSON response with "height" = "2"
4242

4343
When I query chaincode "SimpleSample" function name "query" on "vp0":
4444
|arg1|
4545
| a |
46-
Then I should get a JSON response with "result.message" = "{'Name':'a','Amount':'100'}"
46+
Then I should get a JSON response with "result.message" = "{'Name':'a','Amount':'100'}"
4747

4848
When I invoke chaincode "SimpleSample" function name "transfer" on "vp0"
49-
|arg1|arg2|arg3|
50-
| a | b | 10 |
51-
Then I should have received a transactionID
52-
Then I wait up to "25" seconds for transaction to be committed to all peers
49+
|arg1|arg2|arg3|
50+
| a | b | 10 |
51+
Then I should have received a transactionID
52+
Then I wait up to "25" seconds for transaction to be committed to all peers
5353

54-
When requesting "/chain" from "vp0"
55-
Then I should get a JSON response with "height" = "3"
54+
When requesting "/chain" from "vp0"
55+
Then I should get a JSON response with "height" = "3"
5656

5757
When I query chaincode "SimpleSample" function name "query" on "vp0":
5858
|arg1|
5959
| a |
60-
Then I should get a JSON response with "result.message" = "{'Name':'a','Amount':'90'}"
60+
Then I should get a JSON response with "result.message" = "{'Name':'a','Amount':'90'}"
6161

6262
When I query chaincode "SimpleSample" function name "query" on "vp0":
6363
|arg1|
6464
| b |
65-
Then I should get a JSON response with "result.message" = "{'Name':'b','Amount':'210'}"
65+
Then I should get a JSON response with "result.message" = "{'Name':'b','Amount':'210'}"
6666

6767
Scenario: java RangeExample chaincode single peer
6868
Given we compose "docker-compose-1.yml"
@@ -116,4 +116,60 @@ Scenario: java RangeExample chaincode single peer
116116
When I query chaincode "RangeExample" function name "keys" on "vp0":
117117
||
118118
||
119-
Then I should get a JSON response with "result.message" = "[a]"
119+
Then I should get a JSON response with "result.message" = "[a]"
120+
121+
Scenario: Java TableExample chaincode single peer
122+
Given we compose "docker-compose-1.yml"
123+
When requesting "/chain" from "vp0"
124+
Then I should get a JSON response with "height" = "1"
125+
When I deploy lang chaincode "examples/chaincode/java/TableExample" of "JAVA" with ctor "init" to "vp0"
126+
||
127+
||
128+
Then I should have received a chaincode name
129+
Then I wait up to "30" seconds for transaction to be committed to all peers
130+
131+
When requesting "/chain" from "vp0"
132+
Then I should get a JSON response with "height" = "2"
133+
When I invoke chaincode "TableExample" function name "insert" on "vp0"
134+
|arg1|arg2|
135+
| 0 | Alice |
136+
Then I should have received a transactionID
137+
Then I wait up to "25" seconds for transaction to be committed to all peers
138+
When I invoke chaincode "TableExample" function name "insert" on "vp0"
139+
|arg1|arg2|
140+
| 1 | Bob |
141+
Then I should have received a transactionID
142+
Then I wait up to "25" seconds for transaction to be committed to all peers
143+
When I invoke chaincode "TableExample" function name "insert" on "vp0"
144+
|arg1|arg2|
145+
| 2 | Charlie |
146+
Then I should have received a transactionID
147+
Then I wait up to "25" seconds for transaction to be committed to all peers
148+
149+
When I query chaincode "TableExample" function name "get" on "vp0":
150+
|arg1|
151+
| 0 |
152+
Then I should get a JSON response with "result.message" = "Alice"
153+
154+
When I query chaincode "TableExample" function name "get" on "vp0":
155+
|arg1|
156+
| 2 |
157+
Then I should get a JSON response with "result.message" = "Charlie"
158+
When I invoke chaincode "TableExample" function name "update" on "vp0"
159+
|arg1|arg2|
160+
| 2 | Chaitra |
161+
Then I should have received a transactionID
162+
Then I wait up to "25" seconds for transaction to be committed to all peers
163+
When I query chaincode "TableExample" function name "get" on "vp0":
164+
|arg1|
165+
| 2 |
166+
Then I should get a JSON response with "result.message" = "Chaitra"
167+
When I invoke chaincode "TableExample" function name "delete" on "vp0"
168+
|arg1|
169+
| 2 |
170+
Then I should have received a transactionID
171+
Then I wait up to "25" seconds for transaction to be committed to all peers
172+
When I query chaincode "TableExample" function name "get" on "vp0":
173+
|arg1|
174+
| 2 |
175+
Then I should get a JSON response with "result.message" = "No record found !"

core/chaincode/shim/java/build.gradle

+13-4
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,21 @@ task copyToLib(type: Copy) {
8383

8484

8585
task copyProtos(type:Copy){
86-
into "${projectDir}/src/main/proto"
87-
from "${rootDir}/protos"
88-
include '**/chaincodeevent.proto'
89-
include '**/chaincode.proto'
86+
87+
from ("${rootDir}/protos"){
88+
include '**/chaincodeevent.proto'
89+
include '**/chaincode.proto'
90+
}
91+
from ("../") {
92+
duplicatesStrategy.EXCLUDE
93+
include '**/table.proto'
94+
exclude 'java'
95+
}
96+
into "${projectDir}/src/main/proto"
97+
9098
}
9199

100+
92101
tasks['build'].mustRunAfter tasks['copyProtos']
93102
build.dependsOn(copyProtos)
94103
build.finalizedBy(copyToLib)

0 commit comments

Comments
 (0)