Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
imadcn committed Jan 9, 2020
1 parent 356c3d4 commit a80ed23
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
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);
}
}
17 changes: 17 additions & 0 deletions src/test/resources/META-INF/idworker-ctx-persist-mode.xml
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>

0 comments on commit a80ed23

Please sign in to comment.