For this annotation to have any effect, the surefire and failsafe plugin must be configured
31 | * accordingly.
32 | */
33 | @Target({ElementType.TYPE})
34 | @Retention(RetentionPolicy.RUNTIME)
35 | @Inherited
36 | @Tag("forked")
37 | public @interface Forked {
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/exonum-java-binding/common/src/test/java/com/exonum/binding/common/runtime/JavaArtifactUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2020 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.binding.common.runtime;
18 |
19 | import static com.exonum.binding.common.runtime.JavaArtifactUtils.checkNoForbiddenChars;
20 | import static org.junit.jupiter.api.Assertions.assertThrows;
21 |
22 | import org.junit.jupiter.api.Test;
23 |
24 | class JavaArtifactUtilsTest {
25 |
26 | @Test
27 | void checkArtifactWithNoForbiddenCharacters() {
28 | String name = "com.acme/foo:1.0";
29 | checkNoForbiddenChars(name);
30 | }
31 |
32 | @Test
33 | void checkArtifactWithForbiddenCharacters() {
34 | String name = "com.acme foo:1.0";
35 | assertThrows(IllegalArgumentException.class, () -> checkNoForbiddenChars(name));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/exonum-java-binding/common/src/test/java/com/exonum/binding/common/serialization/BoolSerializerTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2018 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 |
18 | package com.exonum.binding.common.serialization;
19 |
20 | import static com.exonum.binding.common.serialization.StandardSerializersTestUtils.invalidBytesValueTest;
21 | import static com.exonum.binding.common.serialization.StandardSerializersTestUtils.roundTripTest;
22 |
23 | import org.junit.jupiter.api.Test;
24 |
25 | class BoolSerializerTest {
26 |
27 | private final Serializer Enables easier unit testing of the {@link ServiceRuntime} and {@link ServiceNodeProxy}.
26 | */
27 | interface BlockchainDataFactory {
28 |
29 | /**
30 | * Creates a BlockchainData for the service with the given name.
31 | *
32 | * @see BlockchainData#fromRawAccess(AbstractAccess, String)
33 | */
34 | default BlockchainData fromRawAccess(AbstractAccess rawAccess, String serviceName) {
35 | return BlockchainData.fromRawAccess(rawAccess, serviceName);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/exonum-java-binding/core/src/main/java/com/exonum/binding/core/runtime/ServiceLoadingException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.binding.core.runtime;
18 |
19 | /**
20 | * Indicates that a service runtime failed to load the service artifact.
21 | */
22 | public class ServiceLoadingException extends Exception {
23 |
24 | private static final long serialVersionUID = -5073976663800635538L;
25 |
26 | public ServiceLoadingException(String message) {
27 | super(message);
28 | }
29 |
30 | public ServiceLoadingException(String message, Throwable cause) {
31 | super(message, cause);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/exonum-java-binding/core/src/main/java/com/exonum/binding/core/service/AbstractServiceModule.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.binding.core.service;
18 |
19 | import com.google.inject.AbstractModule;
20 |
21 | /**
22 | * A base class for {@link ServiceModule} implementations provided for convenience.
23 | *
24 | * The implementation must be specified as an {@linkplain org.pf4j.Extension extension}:
25 | * Also contains an utility factory to produce proxies of native accesses.
27 | */
28 | package com.exonum.binding.core.service.adapters;
29 |
--------------------------------------------------------------------------------
/exonum-java-binding/core/src/main/java/com/exonum/binding/core/storage/indices/ImmutableModificationCounter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.binding.core.storage.indices;
18 |
19 | enum ImmutableModificationCounter implements ModificationCounter {
20 |
21 | INSTANCE;
22 |
23 | private static final int INITIAL_VALUE = 0;
24 |
25 | @Override
26 | public boolean isModifiedSince(int lastValue) {
27 | return false;
28 | }
29 |
30 | @Override
31 | public int getCurrentValue() {
32 | return INITIAL_VALUE;
33 | }
34 |
35 | @Override
36 | public void notifyModified() {
37 | throw new IllegalStateException("Immutable counter cannot be modified");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/exonum-java-binding/core/src/main/java/com/exonum/binding/core/storage/indices/IncrementalModificationCounter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.binding.core.storage.indices;
18 |
19 | final class IncrementalModificationCounter implements ModificationCounter {
20 |
21 | private int counter = 0;
22 |
23 | @Override
24 | public boolean isModifiedSince(int lastValue) {
25 | return counter != lastValue;
26 | }
27 |
28 | @Override
29 | public int getCurrentValue() {
30 | return counter;
31 | }
32 |
33 | @Override
34 | public void notifyModified() {
35 | counter++;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/exonum-java-binding/core/src/main/java/com/exonum/binding/core/storage/indices/RustIter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.binding.core.storage.indices;
18 |
19 | import java.util.Optional;
20 |
21 | /**
22 | * An interface corresponding to
23 | * std::iter::Iterator
24 | * from the Rust standard library.
25 | *
26 | * @param An adapter of {@link Iterator} to {@link RustIter}.
26 | */
27 | public class RustIterTestFake implements RustIter See more examples in the project readme.
31 | */
32 | package com.exonum.client;
33 |
--------------------------------------------------------------------------------
/exonum-light-client/src/main/java/com/exonum/client/request/BlockTimeOption.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.client.request;
18 |
19 | import com.exonum.client.response.Block;
20 |
21 | /**
22 | * Request option for block commit time.
23 | * See {@link Block#getCommitTime()}.
24 | */
25 | public enum BlockTimeOption {
26 | /**
27 | * Do not include block commit times in a response.
28 | */
29 | NO_COMMIT_TIME,
30 | /**
31 | * Include block commit times in a response.
32 | */
33 | INCLUDE_COMMIT_TIME
34 | }
35 |
--------------------------------------------------------------------------------
/exonum-light-client/src/main/java/com/exonum/client/response/TransactionStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.client.response;
18 |
19 | import com.exonum.messages.core.runtime.Errors.ExecutionStatus;
20 | import com.google.gson.annotations.SerializedName;
21 |
22 | /**
23 | * Status of a particular transaction.
24 | */
25 | public enum TransactionStatus {
26 | /**
27 | * Shows that transaction is in unconfirmed transaction pool currently.
28 | */
29 | @SerializedName("in-pool")
30 | IN_POOL,
31 | /**
32 | * Shows that transaction is committed to the blockchain.
33 | * Please note that a committed transaction has not necessarily completed
34 | * successfully — use the {@linkplain ExecutionStatus execution result}
35 | * to check that.
36 | */
37 | @SerializedName("committed")
38 | COMMITTED
39 | }
40 |
--------------------------------------------------------------------------------
/exonum-light-client/src/main/lombok/com/exonum/client/response/BlockResponse.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.client.response;
18 |
19 | import com.exonum.binding.common.hash.HashCode;
20 | import com.exonum.binding.common.message.TransactionMessage;
21 | import java.util.List;
22 | import lombok.Value;
23 |
24 | @Value
25 | public class BlockResponse {
26 | /**
27 | * Blockchain block.
28 | */
29 | Block block;
30 | /**
31 | * Transaction hashes included at this block.
32 | * @see TransactionMessage#hash()
33 | */
34 | List
26 | * @Extension
27 | * class MyServiceModule extends AbstractServiceModule {
28 | *
29 | * }
30 | *
31 | */
32 | public abstract class AbstractServiceModule extends AbstractModule implements ServiceModule {
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/exonum-java-binding/core/src/main/java/com/exonum/binding/core/service/TransactionSubmissionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package com.exonum.binding.core.service;
18 |
19 | import com.exonum.binding.core.transaction.RawTransaction;
20 |
21 | /**
22 | * Indicates that a transaction could not be
23 | * {@linkplain Node#submitTransaction(RawTransaction) submitted}.
24 | * For example, the submitted transaction is not valid — belongs to an unknown service.
25 | */
26 | public final class TransactionSubmissionException extends RuntimeException {
27 |
28 | private static final long serialVersionUID = -4818447239123659240L;
29 |
30 | public TransactionSubmissionException(String message) {
31 | super(message);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/exonum-java-binding/core/src/main/java/com/exonum/binding/core/service/adapters/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2019 The Exonum Team
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * 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,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | /**
18 | * An internal package with adapters of Java Service interfaces
19 | * to the interface, convenient to the native code. That brings such benefits:
20 | *
21 | *
25 | *
26 | *
22 | * {@code
23 | * ExonumClient exonumClient = ExonumClient.newBuilder()
24 | * .setExonumHost("http://
29 | *
30 | *