Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ sourceSets {
}
}

tasks.withType(ProcessResources) {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}

googleJavaFormat {
toolVersion = '1.7'
options style: 'AOSP'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package org.fisco.bcos.sdk.v3.test.config.exceptions;

import org.fisco.bcos.sdk.v3.config.exceptions.ConfigException;
import org.junit.Assert;
import org.junit.Test;

public class ConfigExceptionTest {

@Test
public void testConstructorWithMessage() {
String message = "Configuration error occurred";
ConfigException exception = new ConfigException(message);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testConstructorWithCause() {
Exception cause = new RuntimeException("Root cause");
ConfigException exception = new ConfigException(cause);

Assert.assertNotNull(exception);
Assert.assertEquals(cause, exception.getCause());
Assert.assertTrue(exception.getMessage().contains("Root cause"));
}

@Test
public void testConstructorWithMessageAndCause() {
String message = "Configuration error";
Exception cause = new IllegalArgumentException("Invalid argument");
ConfigException exception = new ConfigException(message, cause);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
Assert.assertEquals(cause, exception.getCause());
}

@Test
public void testExceptionIsThrowable() {
ConfigException exception = new ConfigException("Test");
Assert.assertTrue(exception instanceof Exception);
Assert.assertTrue(exception instanceof Throwable);
}

@Test
public void testExceptionCanBeCaught() {
try {
throw new ConfigException("Test exception");
} catch (ConfigException e) {
Assert.assertEquals("Test exception", e.getMessage());
} catch (Exception e) {
Assert.fail("Should have caught ConfigException specifically");
}
}

@Test
public void testNullMessage() {
ConfigException exception = new ConfigException((String) null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getMessage());
}

@Test
public void testNullCause() {
ConfigException exception = new ConfigException((Throwable) null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getCause());
}

@Test
public void testEmptyMessage() {
String message = "";
ConfigException exception = new ConfigException(message);
Assert.assertEquals(message, exception.getMessage());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.fisco.bcos.sdk.v3.test.crypto.exceptions;

import org.fisco.bcos.sdk.v3.crypto.exceptions.HashException;
import org.junit.Assert;
import org.junit.Test;

public class HashExceptionTest {

@Test
public void testConstructorWithMessage() {
String message = "Hash computation failed";
HashException exception = new HashException(message);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testConstructorWithMessageAndCause() {
String message = "Hash error occurred";
Exception cause = new IllegalArgumentException("Invalid input");
HashException exception = new HashException(message, cause);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
Assert.assertEquals(cause, exception.getCause());
}

@Test
public void testExceptionIsRuntimeException() {
HashException exception = new HashException("Test");
Assert.assertTrue(exception instanceof RuntimeException);
Assert.assertTrue(exception instanceof Exception);
}

@Test
public void testExceptionCanBeCaught() {
try {
throw new HashException("Hash exception");
} catch (HashException e) {
Assert.assertEquals("Hash exception", e.getMessage());
} catch (Exception e) {
Assert.fail("Should have caught HashException specifically");
}
}

@Test
public void testNullMessage() {
HashException exception = new HashException(null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getMessage());
}

@Test
public void testEmptyMessage() {
String message = "";
HashException exception = new HashException(message);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testNullCause() {
HashException exception = new HashException("Message", null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getCause());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.fisco.bcos.sdk.v3.test.crypto.exceptions;

import org.fisco.bcos.sdk.v3.crypto.exceptions.KeyPairException;
import org.junit.Assert;
import org.junit.Test;

public class KeyPairExceptionTest {

@Test
public void testConstructorWithMessage() {
String message = "Key pair generation failed";
KeyPairException exception = new KeyPairException(message);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testConstructorWithMessageAndCause() {
String message = "Key pair error occurred";
Exception cause = new IllegalStateException("Invalid state");
KeyPairException exception = new KeyPairException(message, cause);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
Assert.assertEquals(cause, exception.getCause());
}

@Test
public void testExceptionIsRuntimeException() {
KeyPairException exception = new KeyPairException("Test");
Assert.assertTrue(exception instanceof RuntimeException);
Assert.assertTrue(exception instanceof Exception);
}

@Test
public void testExceptionCanBeCaught() {
try {
throw new KeyPairException("Key pair exception");
} catch (KeyPairException e) {
Assert.assertEquals("Key pair exception", e.getMessage());
} catch (Exception e) {
Assert.fail("Should have caught KeyPairException specifically");
}
}

@Test
public void testNullMessage() {
KeyPairException exception = new KeyPairException(null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getMessage());
}

@Test
public void testEmptyMessage() {
String message = "";
KeyPairException exception = new KeyPairException(message);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testNullCause() {
KeyPairException exception = new KeyPairException("Message", null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getCause());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.fisco.bcos.sdk.v3.test.crypto.exceptions;

import org.fisco.bcos.sdk.v3.crypto.exceptions.LoadKeyStoreException;
import org.junit.Assert;
import org.junit.Test;

public class LoadKeyStoreExceptionTest {

@Test
public void testConstructorWithMessage() {
String message = "Failed to load keystore";
LoadKeyStoreException exception = new LoadKeyStoreException(message);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testConstructorWithMessageAndCause() {
String message = "Keystore load error";
Exception cause = new java.io.IOException("File not found");
LoadKeyStoreException exception = new LoadKeyStoreException(message, cause);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
Assert.assertEquals(cause, exception.getCause());
}

@Test
public void testExceptionIsRuntimeException() {
LoadKeyStoreException exception = new LoadKeyStoreException("Test");
Assert.assertTrue(exception instanceof RuntimeException);
Assert.assertTrue(exception instanceof Exception);
}

@Test
public void testExceptionCanBeCaught() {
try {
throw new LoadKeyStoreException("Load exception");
} catch (LoadKeyStoreException e) {
Assert.assertEquals("Load exception", e.getMessage());
} catch (Exception e) {
Assert.fail("Should have caught LoadKeyStoreException specifically");
}
}

@Test
public void testNullMessage() {
LoadKeyStoreException exception = new LoadKeyStoreException(null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getMessage());
}

@Test
public void testEmptyMessage() {
String message = "";
LoadKeyStoreException exception = new LoadKeyStoreException(message);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testNullCause() {
LoadKeyStoreException exception = new LoadKeyStoreException("Message", null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getCause());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.fisco.bcos.sdk.v3.test.crypto.exceptions;

import org.fisco.bcos.sdk.v3.crypto.exceptions.SignatureException;
import org.junit.Assert;
import org.junit.Test;

public class SignatureExceptionTest {

@Test
public void testConstructorWithMessage() {
String message = "Signature verification failed";
SignatureException exception = new SignatureException(message);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testConstructorWithMessageAndCause() {
String message = "Signature error occurred";
Exception cause = new IllegalArgumentException("Invalid signature");
SignatureException exception = new SignatureException(message, cause);

Assert.assertNotNull(exception);
Assert.assertEquals(message, exception.getMessage());
Assert.assertEquals(cause, exception.getCause());
}

@Test
public void testExceptionIsRuntimeException() {
SignatureException exception = new SignatureException("Test");
Assert.assertTrue(exception instanceof RuntimeException);
Assert.assertTrue(exception instanceof Exception);
}

@Test
public void testExceptionCanBeCaught() {
try {
throw new SignatureException("Signature exception");
} catch (SignatureException e) {
Assert.assertEquals("Signature exception", e.getMessage());
} catch (Exception e) {
Assert.fail("Should have caught SignatureException specifically");
}
}

@Test
public void testNullMessage() {
SignatureException exception = new SignatureException(null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getMessage());
}

@Test
public void testEmptyMessage() {
String message = "";
SignatureException exception = new SignatureException(message);
Assert.assertEquals(message, exception.getMessage());
}

@Test
public void testNullCause() {
SignatureException exception = new SignatureException("Message", null);
Assert.assertNotNull(exception);
Assert.assertNull(exception.getCause());
}
}
Loading
Loading