Skip to content

Commit c5356ac

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: I2cfcd4b08596195e3acaff97db8b8234a899cad1 Signed-off-by: Satheesh Kathamuthu <[email protected]>
1 parent 18a44d0 commit c5356ac

File tree

9 files changed

+784
-589
lines changed

9 files changed

+784
-589
lines changed

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,10 @@ build/image/ccenv/.dummy: build/image/ccenv/bin/protoc-gen-go build/image/ccenv/
202202
@touch $@
203203

204204
# Special override for java-image
205+
# Following items are packed and sent to docker context while building image
206+
# 1. Java shim layer source code
207+
# 2. Proto files used to generate java classes
208+
# 3. Gradle settings file
205209
build/image/javaenv/.dummy: Makefile $(JAVASHIM_DEPS)
206210
@echo "Building docker javaenv-image"
207211
@mkdir -p $(@D)
@@ -214,7 +218,7 @@ build/image/javaenv/.dummy: Makefile $(JAVASHIM_DEPS)
214218
# 2. Proto files used to generate java classes
215219
# 3. Gradle settings file
216220
@git ls-files core/chaincode/shim/java | tar -jcT - > $(@D)/javashimsrc.tar.bz2
217-
@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
218222
docker build -t $(PROJECT_NAME)-javaenv $(@D)
219223
docker tag $(PROJECT_NAME)-javaenv $(PROJECT_NAME)-javaenv:$(DOCKER_TAG)
220224
@touch $@

bddtests/java_shim.feature

+74-19
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,43 @@
2626

2727
#@chaincodeImagesUpToDate
2828
@preV1
29-
Feature: SimpleSample Java example
30-
29+
Feature: Java chaincode example
3130
Scenario: java SimpleSample chaincode example single peer
3231
Given we compose "docker-compose-1.yml"
3332
When requesting "/chain" from "vp0"
3433
Then I should get a JSON response with "height" = "1"
35-
When I deploy lang chaincode "examples/chaincode/java/SimpleSample" of "JAVA" with ctor "init" to "vp0"
36-
| arg1 | arg2 | arg3 | arg4 |
37-
| a | 100 | b | 200 |
38-
Then I should have received a chaincode name
39-
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
4039

41-
When requesting "/chain" from "vp0"
42-
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"
4342

4443
When I query chaincode "SimpleSample" function name "query" on "vp0":
4544
|arg1|
4645
| a |
47-
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'}"
4847

4948
When I invoke chaincode "SimpleSample" function name "transfer" on "vp0"
50-
|arg1|arg2|arg3|
51-
| a | b | 10 |
52-
Then I should have received a transactionID
53-
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
5453

55-
When requesting "/chain" from "vp0"
56-
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"
5756

5857
When I query chaincode "SimpleSample" function name "query" on "vp0":
5958
|arg1|
6059
| a |
61-
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'}"
6261

6362
When I query chaincode "SimpleSample" function name "query" on "vp0":
6463
|arg1|
6564
| b |
66-
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'}"
6766

6867
Scenario: java RangeExample chaincode single peer
6968
Given we compose "docker-compose-1.yml"
@@ -117,4 +116,60 @@ Scenario: java RangeExample chaincode single peer
117116
When I query chaincode "RangeExample" function name "keys" on "vp0":
118117
||
119118
||
120-
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)