-
Notifications
You must be signed in to change notification settings - Fork 70
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
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/test/java/com/imadcn/system/test/idworker/ZKPersistModeTest.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,27 @@ | ||
package com.imadcn.system.test.idworker; | ||
|
||
import org.junit.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import com.imadcn.framework.idworker.generator.SnowflakeGenerator; | ||
import com.imadcn.system.test.spring.AbstractZookeeperJUnit4SpringContextTests; | ||
|
||
@ContextConfiguration(locations = "classpath:META-INF/idworker-ctx-persist-mode.xml") | ||
public final class ZKPersistModeTest extends AbstractZookeeperJUnit4SpringContextTests { | ||
|
||
@Autowired | ||
private SnowflakeGenerator idGenerator; | ||
|
||
@Test | ||
public void testGetId() { | ||
Object object = idGenerator.nextId(); | ||
print(object); | ||
} | ||
|
||
@Test | ||
public void testBatchGetId() { | ||
Object object = idGenerator.nextId(20); | ||
print(object); | ||
} | ||
} |
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,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:idworker="http://code.imadcn.com/schema/idworker" | ||
xsi:schemaLocation=" | ||
http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://code.imadcn.com/schema/idworker | ||
http://code.imadcn.com/schema/idworker/idworker.xsd"> | ||
|
||
<import resource="base.xml"/> | ||
|
||
<idworker:registry id="zkRegistryCenter" server-lists="${zk.servers}" base-sleep-time-milliseconds="${zk.baseSleepTimeMilliseconds}" | ||
max-sleep-time-milliseconds="${zk.maxSleepTimeMilliseconds}" max-retries="${zk.maxRetries}" session-timeout-milliseconds="${zk.sessionTimeoutMilliseconds}" | ||
connection-timeout-milliseconds="${zk.connectionTimeoutMilliseconds}" namespace="${zk.namespace}"/> | ||
<idworker:generator id="snowflakeGenerator" registry-center-ref="zkRegistryCenter" group="${idworker.group}" durable="true"/> | ||
</beans> |