fix:使用springboot来封装

上级 bd3706d5
......@@ -16,6 +16,11 @@
<artifactId>spring-boot-starter</artifactId>
<version>2.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
......@@ -32,7 +32,7 @@ public class CuratorTest_02_Create {
public void testCreate2() throws Exception {
//基本创建
//如果创建节点,没有指定数据,则默认将当前客户端的ip作为数据存储
String path = client.create().forPath("/app5");
String path = client.create().forPath("/app34");
System.out.println(path);
}
}
\ No newline at end of file
......@@ -3,7 +3,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.apache.zookeeper.CreateMode;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 设置节点的类型
......@@ -12,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_03_Create {
@Autowired
......
......@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 创建多级节点
......@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_04_Create {
@Autowired
......
......@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 查询数据
......@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_05_Get {
@Autowired
......@@ -25,7 +30,7 @@ public class CuratorTest_05_Get {
@Test
public void testGet1() throws Exception {
//1. 查询数据:get
byte[] data = client.getData().forPath("/app1");
byte[] data = client.getData().forPath("/app5");
System.out.println(new String(data));
}
}
\ No newline at end of file
......@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.List;
......@@ -13,6 +16,8 @@ import java.util.List;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_06_Get {
@Autowired
......
......@@ -3,7 +3,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.apache.zookeeper.data.Stat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 查询节点状态信息
......@@ -12,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_07_Get {
@Autowired
......
......@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 基本修改数据
......@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_08_Set {
@Autowired
......
......@@ -3,7 +3,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.apache.zookeeper.data.Stat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 根据版本修改
......@@ -12,6 +15,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_09_Set {
@Autowired
......
......@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 删除单个节点
......@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_10_Delete {
@Autowired
......
......@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 删除带有子节点的节点
......@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_11_Delete {
@Autowired
......
......@@ -2,7 +2,10 @@ package com.kwan.shuyu.crud;
import org.apache.curator.framework.CuratorFramework;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 必须成功的删除:为了防止网络抖动。本质就是重试。
......@@ -11,6 +14,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_12_Delete {
@Autowired
......
......@@ -4,7 +4,10 @@ import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.api.BackgroundCallback;
import org.apache.curator.framework.api.CuratorEvent;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* 删除回调:inBackground
......@@ -13,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 09:54
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class CuratorTest_13_Delete {
@Autowired
......
......@@ -4,7 +4,10 @@ import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.recipes.cache.NodeCache;
import org.apache.curator.framework.recipes.cache.NodeCacheListener;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Watcher监听
......@@ -13,6 +16,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 10:29
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class Watcher_01_NodeCache {
@Autowired
......
......@@ -5,7 +5,10 @@ import org.apache.curator.framework.recipes.cache.PathChildrenCache;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Watcher监听
......@@ -14,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 10:29
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class Watcher_02_PathChildrenCache {
@Autowired
......
......@@ -5,7 +5,10 @@ import org.apache.curator.framework.recipes.cache.TreeCache;
import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
import org.apache.curator.framework.recipes.cache.TreeCacheListener;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* Watcher监听
......@@ -14,6 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
* @version : 2.2.0
* @date : 2023/5/15 10:29
*/
@SpringBootTest
@RunWith(SpringRunner.class)
public class Watcher_03_TreeCache {
@Autowired
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册