-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e1abf3
commit 7a7cec1
Showing
10 changed files
with
548 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
core/src/test/java/io/seata/core/compressor/CompressorTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.core.compressor; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* The CompressorType Test | ||
* | ||
* @author zhongxiang.wang | ||
*/ | ||
public class CompressorTypeTest { | ||
@Test | ||
public void testGetByCode() { | ||
int code = 1; | ||
CompressorType expectedType = CompressorType.GZIP; | ||
|
||
CompressorType actualType = CompressorType.getByCode(code); | ||
|
||
// Assert the returned type matches the expected type | ||
Assertions.assertEquals(expectedType, actualType); | ||
} | ||
|
||
@Test | ||
public void testGetByName() { | ||
String name = "gzip"; | ||
CompressorType expectedType = CompressorType.GZIP; | ||
|
||
CompressorType actualType = CompressorType.getByName(name); | ||
|
||
// Assert the returned type matches the expected type | ||
Assertions.assertEquals(expectedType, actualType); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
core/src/test/java/io/seata/core/constants/DBTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.core.constants; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Fail.fail; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
/** | ||
* The DBType Test | ||
* | ||
* @author zhongxiang.wang | ||
*/ | ||
public class DBTypeTest { | ||
@Test | ||
public void testValueOf() { | ||
// Test valid DBType values | ||
assertEquals(DBType.MYSQL, DBType.valueof("MYSQL")); | ||
assertEquals(DBType.ORACLE, DBType.valueof("ORACLE")); | ||
assertEquals(DBType.DB2, DBType.valueof("DB2")); | ||
|
||
// Test invalid DBType value | ||
try { | ||
DBType.valueof("INVALID"); | ||
fail("Expected IllegalArgumentException to be thrown"); | ||
} catch (IllegalArgumentException e) { | ||
assertEquals("unknown dbtype:INVALID", e.getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
core/src/test/java/io/seata/core/context/ThreadLocalContextCoreTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.core.context; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* The type Thread local context core test. | ||
* | ||
* @author zhongxiang.wang | ||
*/ | ||
public class ThreadLocalContextCoreTest { | ||
private static ThreadLocalContextCore contextCore ; | ||
|
||
|
||
@BeforeAll | ||
public static void setUp() { | ||
contextCore = new ThreadLocalContextCore(); | ||
} | ||
@Test | ||
public void testPutAndGet() { | ||
// Test putting and getting a value | ||
contextCore.put("key", "value"); | ||
assertEquals("value", contextCore.get("key")); | ||
contextCore.remove("key"); | ||
} | ||
|
||
@Test | ||
public void testRemove() { | ||
// Test putting and removing a value | ||
contextCore.put("key", "value"); | ||
assertEquals("value", contextCore.remove("key")); | ||
assertNull(contextCore.get("key")); | ||
} | ||
|
||
@Test | ||
public void testEntries() { | ||
// Test getting all entries | ||
contextCore.put("key1", "value1"); | ||
contextCore.put("key2", "value2"); | ||
contextCore.put("key3", "value3"); | ||
assertEquals(3, contextCore.entries().size()); | ||
assertTrue(contextCore.entries().containsKey("key1")); | ||
assertTrue(contextCore.entries().containsKey("key2")); | ||
assertTrue(contextCore.entries().containsKey("key3")); | ||
contextCore.remove("key1"); | ||
contextCore.remove("key2"); | ||
contextCore.remove("key3"); | ||
assertNull(contextCore.get("key1")); | ||
assertNull(contextCore.get("key2")); | ||
assertNull(contextCore.get("key3")); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
core/src/test/java/io/seata/core/event/ExceptionEventTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 1999-2019 Seata.io Group. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.seata.core.event; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* The ExceptionEvent Test | ||
* | ||
* @author zhongxiang.wang | ||
*/ | ||
public class ExceptionEventTest { | ||
@Test | ||
public void testGetName() { | ||
// Create an ExceptionEvent with a code | ||
ExceptionEvent exceptionEvent = new ExceptionEvent("CODE123"); | ||
|
||
// Test the getName method | ||
assertEquals("CODE123", exceptionEvent.getName()); | ||
} | ||
} |
Oops, something went wrong.