mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
polish #761 update pkg name & maven coordinate for Greenwich
This commit is contained in:
@@ -3,13 +3,12 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba</artifactId>
|
||||
<version>0.9.1.BUILD-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-sentinel-datasource</artifactId>
|
||||
<name>Spring Cloud Alibaba Sentinel DataSource</name>
|
||||
|
||||
|
@@ -1,11 +1,27 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.config.AbstractDataSourceProperties;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.config.AbstractDataSourceProperties;
|
||||
import com.alibaba.csp.sentinel.slots.block.AbstractRule;
|
||||
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule;
|
||||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
@@ -1,11 +1,27 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.config;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.config;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.RuleType;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.RuleType;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.common.api.GatewayApiDefinitionManager;
|
||||
import com.alibaba.csp.sentinel.adapter.gateway.common.rule.GatewayRuleManager;
|
||||
import com.alibaba.csp.sentinel.datasource.AbstractDataSource;
|
@@ -1,8 +1,24 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.config;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.config;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
|
||||
|
||||
/**
|
||||
* Apollo Properties class Using by {@link DataSourcePropertiesConfiguration} and
|
@@ -1,4 +1,20 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.config;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
@@ -1,13 +1,30 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.config;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.config;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
|
||||
|
||||
/**
|
||||
* File Properties class Using by {@link DataSourcePropertiesConfiguration} and
|
||||
* {@link FileRefreshableDataSourceFactoryBean}
|
@@ -1,10 +1,27 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.config;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.config;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.NacosDataSourceFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.NacosDataSourceFactoryBean;
|
||||
|
||||
/**
|
||||
* Nacos Properties class Using by {@link DataSourcePropertiesConfiguration} and
|
||||
* {@link NacosDataSourceFactoryBean}
|
@@ -1,8 +1,25 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.config;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.config;
|
||||
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean;
|
||||
|
||||
/**
|
||||
* Zookeeper Properties class Using by {@link DataSourcePropertiesConfiguration} and
|
||||
* {@link ZookeeperDataSourceFactoryBean}
|
@@ -1,4 +1,20 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.converter;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.converter;
|
||||
|
||||
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule;
|
||||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
|
@@ -1,4 +1,20 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.converter;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.converter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -9,9 +25,9 @@ import java.util.Optional;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.RuleType;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.RuleType;
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule;
|
||||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
|
@@ -1,4 +1,20 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.converter;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.converter;
|
||||
|
||||
import com.alibaba.csp.sentinel.slots.block.authority.AuthorityRule;
|
||||
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeRule;
|
@@ -1,4 +1,20 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.factorybean;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.factorybean;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.factorybean;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
|
||||
|
||||
/**
|
||||
* A {@link FactoryBean} for creating {@link FileRefreshableDataSource} instance.
|
||||
*
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
* @see FileRefreshableDataSource
|
||||
*/
|
||||
public class FileRefreshableDataSourceFactoryBean
|
||||
implements FactoryBean<FileRefreshableDataSource> {
|
||||
|
||||
private String file;
|
||||
private String charset;
|
||||
private long recommendRefreshMs;
|
||||
private int bufSize;
|
||||
private Converter converter;
|
||||
|
||||
@Override
|
||||
public FileRefreshableDataSource getObject() throws Exception {
|
||||
return new FileRefreshableDataSource(new File(file), converter,
|
||||
recommendRefreshMs, bufSize, Charset.forName(charset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return FileRefreshableDataSource.class;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getCharset() {
|
||||
return charset;
|
||||
}
|
||||
|
||||
public void setCharset(String charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
public long getRecommendRefreshMs() {
|
||||
return recommendRefreshMs;
|
||||
}
|
||||
|
||||
public void setRecommendRefreshMs(long recommendRefreshMs) {
|
||||
this.recommendRefreshMs = recommendRefreshMs;
|
||||
}
|
||||
|
||||
public int getBufSize() {
|
||||
return bufSize;
|
||||
}
|
||||
|
||||
public void setBufSize(int bufSize) {
|
||||
this.bufSize = bufSize;
|
||||
}
|
||||
|
||||
public Converter getConverter() {
|
||||
return converter;
|
||||
}
|
||||
|
||||
public void setConverter(Converter converter) {
|
||||
this.converter = converter;
|
||||
}
|
||||
}
|
@@ -1,4 +1,20 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.factorybean;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.factorybean;
|
||||
|
||||
import java.util.Properties;
|
||||
|
@@ -1,4 +1,20 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.factorybean;
|
||||
/*
|
||||
* Copyright (C) 2018 the original author or authors.
|
||||
*
|
||||
* 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 com.alibaba.cloud.sentinel.datasource.factorybean;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
@@ -1,76 +0,0 @@
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource.factorybean;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
|
||||
|
||||
/**
|
||||
* A {@link FactoryBean} for creating {@link FileRefreshableDataSource} instance.
|
||||
*
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
* @see FileRefreshableDataSource
|
||||
*/
|
||||
public class FileRefreshableDataSourceFactoryBean
|
||||
implements FactoryBean<FileRefreshableDataSource> {
|
||||
|
||||
private String file;
|
||||
private String charset;
|
||||
private long recommendRefreshMs;
|
||||
private int bufSize;
|
||||
private Converter converter;
|
||||
|
||||
@Override
|
||||
public FileRefreshableDataSource getObject() throws Exception {
|
||||
return new FileRefreshableDataSource(new File(file), converter,
|
||||
recommendRefreshMs, bufSize, Charset.forName(charset));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getObjectType() {
|
||||
return FileRefreshableDataSource.class;
|
||||
}
|
||||
|
||||
public String getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(String file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public String getCharset() {
|
||||
return charset;
|
||||
}
|
||||
|
||||
public void setCharset(String charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
public long getRecommendRefreshMs() {
|
||||
return recommendRefreshMs;
|
||||
}
|
||||
|
||||
public void setRecommendRefreshMs(long recommendRefreshMs) {
|
||||
this.recommendRefreshMs = recommendRefreshMs;
|
||||
}
|
||||
|
||||
public int getBufSize() {
|
||||
return bufSize;
|
||||
}
|
||||
|
||||
public void setBufSize(int bufSize) {
|
||||
this.bufSize = bufSize;
|
||||
}
|
||||
|
||||
public Converter getConverter() {
|
||||
return converter;
|
||||
}
|
||||
|
||||
public void setConverter(Converter converter) {
|
||||
this.converter = converter;
|
||||
}
|
||||
}
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -23,9 +23,9 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.converter.JsonConverter;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.converter.JsonConverter;
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.datasource.apollo.ApolloDataSource;
|
||||
|
@@ -0,0 +1,250 @@
|
||||
/// *
|
||||
// * Copyright (C) 2018 the original author or authors.
|
||||
// *
|
||||
// * 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 com.alibaba.cloud.sentinel.datasource;
|
||||
//
|
||||
// import static org.junit.Assert.assertEquals;
|
||||
// import static org.junit.Assert.assertNotNull;
|
||||
// import static org.junit.Assert.assertNull;
|
||||
//
|
||||
// import org.junit.Test;
|
||||
// import ApolloDataSourceProperties;
|
||||
// import DataSourcePropertiesConfiguration;
|
||||
// import FileDataSourceProperties;
|
||||
// import NacosDataSourceProperties;
|
||||
// import ZookeeperDataSourceProperties;
|
||||
//
|
||||
/// **
|
||||
// * @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
// */
|
||||
// public class DataSourcePropertiesConfigurationTests {
|
||||
//
|
||||
// @Test
|
||||
// public void testFileAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// FileDataSourceProperties fileDataSourceProperties = buildFileProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setFile(fileDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set file
|
||||
/// attribute",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration file properties was null after set file attribute",
|
||||
// dataSourcePropertiesConfiguration.getFile());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was null after set file attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testNacosAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// NacosDataSourceProperties nacosDataSourceProperties = buildNacosProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setNacos(nacosDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set nacos
|
||||
/// attribute",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration nacos properties was null after set nacos
|
||||
/// attribute",
|
||||
// dataSourcePropertiesConfiguration.getNacos());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was null after set nacos
|
||||
/// attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testZKAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// ZookeeperDataSourceProperties zookeeperDataSourceProperties = buildZKProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setZk(zookeeperDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set zk attribute",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration zk properties was null after set zk attribute",
|
||||
// dataSourcePropertiesConfiguration.getZk());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was null after set zk attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testApolloAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// ApolloDataSourceProperties apolloDataSourceProperties = buildApolloProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setApollo(apolloDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set apollo
|
||||
/// attribute",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration apollo properties was null after set apollo
|
||||
/// attribute",
|
||||
// dataSourcePropertiesConfiguration.getApollo());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was null after set apollo
|
||||
/// attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testMultiAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// FileDataSourceProperties fileDataSourceProperties = buildFileProperties();
|
||||
// NacosDataSourceProperties nacosDataSourceProperties = buildNacosProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setFile(fileDataSourceProperties);
|
||||
// dataSourcePropertiesConfiguration.setNacos(nacosDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set file and nacos
|
||||
/// attribute",
|
||||
// 2, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was not null after set file and
|
||||
/// nacos attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testFileConstructor() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration(
|
||||
// buildFileProperties());
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration file constructor valid field size was wrong",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration file constructor valid properties was null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testNacosConstructor() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration(
|
||||
// buildNacosProperties());
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration nacos constructor valid field size was wrong",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration nacos constructor valid properties was null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testApolloConstructor() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration(
|
||||
// buildApolloProperties());
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration apollo constructor valid field size was wrong",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration apollo constructor valid properties was null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testZKConstructor() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new
|
||||
/// DataSourcePropertiesConfiguration(
|
||||
// buildZKProperties());
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration zk constructor valid field size was wrong",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration zk constructor valid properties was null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// private FileDataSourceProperties buildFileProperties() {
|
||||
// FileDataSourceProperties fileDataSourceProperties = new FileDataSourceProperties();
|
||||
//
|
||||
// fileDataSourceProperties.setFile("/tmp/test.json");
|
||||
// fileDataSourceProperties.setBufSize(1024);
|
||||
// fileDataSourceProperties.setRecommendRefreshMs(2000);
|
||||
// return fileDataSourceProperties;
|
||||
// }
|
||||
//
|
||||
// private NacosDataSourceProperties buildNacosProperties() {
|
||||
// NacosDataSourceProperties nacosDataSourceProperties = new NacosDataSourceProperties();
|
||||
// nacosDataSourceProperties.setServerAddr("127.0.0.1:8848");
|
||||
// nacosDataSourceProperties.setDataId("sentinel");
|
||||
// nacosDataSourceProperties.setGroupId("custom-group");
|
||||
// return nacosDataSourceProperties;
|
||||
// }
|
||||
//
|
||||
// private ApolloDataSourceProperties buildApolloProperties() {
|
||||
// ApolloDataSourceProperties apolloDataSourceProperties = new
|
||||
/// ApolloDataSourceProperties();
|
||||
// apolloDataSourceProperties.setFlowRulesKey("test-key");
|
||||
// apolloDataSourceProperties.setDefaultFlowRuleValue("dft-val");
|
||||
// apolloDataSourceProperties.setNamespaceName("namespace");
|
||||
// return apolloDataSourceProperties;
|
||||
// }
|
||||
//
|
||||
// private ZookeeperDataSourceProperties buildZKProperties() {
|
||||
// ZookeeperDataSourceProperties zookeeperDataSourceProperties = new
|
||||
/// ZookeeperDataSourceProperties();
|
||||
//
|
||||
// zookeeperDataSourceProperties.setServerAddr("localhost:2181");
|
||||
// zookeeperDataSourceProperties.setPath("/path");
|
||||
// return zookeeperDataSourceProperties;
|
||||
// }
|
||||
//
|
||||
// }
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
@@ -22,23 +22,25 @@ import static org.junit.Assert.assertNull;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.config.ApolloDataSourceProperties;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.config.FileDataSourceProperties;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.config.ZookeeperDataSourceProperties;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.config.ApolloDataSourceProperties;
|
||||
import com.alibaba.cloud.sentinel.datasource.config.FileDataSourceProperties;
|
||||
import com.alibaba.cloud.sentinel.datasource.config.ZookeeperDataSourceProperties;
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean;
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
|
||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
|
||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRuleManager;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
*/
|
||||
@@ -57,7 +59,7 @@ public class DataSourcePropertiesTests {
|
||||
apolloDataSourceProperties.getNamespaceName());
|
||||
assertEquals("Apollo default data type was wrong", "json",
|
||||
apolloDataSourceProperties.getDataType());
|
||||
assertEquals("Apollo rule type was wrong", RuleType.DEGRADE,
|
||||
Assert.assertEquals("Apollo rule type was wrong", RuleType.DEGRADE,
|
||||
apolloDataSourceProperties.getRuleType());
|
||||
assertEquals("Apollo default flow value was wrong", "dft-val",
|
||||
apolloDataSourceProperties.getDefaultFlowRuleValue());
|
||||
@@ -92,7 +94,7 @@ public class DataSourcePropertiesTests {
|
||||
zookeeperDataSourceProperties.getFactoryBeanName());
|
||||
assertEquals("ZK custom converter class was wrong", "test.ConverterClass",
|
||||
zookeeperDataSourceProperties.getConverterClass());
|
||||
assertEquals("ZK rule type was wrong", RuleType.AUTHORITY,
|
||||
Assert.assertEquals("ZK rule type was wrong", RuleType.AUTHORITY,
|
||||
zookeeperDataSourceProperties.getRuleType());
|
||||
}
|
||||
|
||||
@@ -114,7 +116,7 @@ public class DataSourcePropertiesTests {
|
||||
assertEquals("File factory bean was wrong",
|
||||
FileRefreshableDataSourceFactoryBean.class.getName(),
|
||||
fileDataSourceProperties.getFactoryBeanName());
|
||||
assertEquals("File rule type was wrong", RuleType.PARAM_FLOW,
|
||||
Assert.assertEquals("File rule type was wrong", RuleType.PARAM_FLOW,
|
||||
fileDataSourceProperties.getRuleType());
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -23,19 +23,20 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
|
||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
*/
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -23,9 +23,9 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.converter.SentinelConverter;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.NacosDataSourceFactoryBean;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.converter.SentinelConverter;
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.NacosDataSourceFactoryBean;
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.datasource.nacos.NacosDataSource;
|
||||
|
@@ -14,13 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.config.NacosDataSourceProperties;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.NacosDataSourceFactoryBean;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.config.NacosDataSourceProperties;
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.NacosDataSourceFactoryBean;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
@@ -42,7 +44,7 @@ public class NacosDataSourcePropertiesTests {
|
||||
nacosDataSourceProperties.getDataId());
|
||||
assertEquals("Nacos default data type was wrong", "xml",
|
||||
nacosDataSourceProperties.getDataType());
|
||||
assertEquals("Nacos rule type was wrong", RuleType.FLOW,
|
||||
Assert.assertEquals("Nacos rule type was wrong", RuleType.FLOW,
|
||||
nacosDataSourceProperties.getRuleType());
|
||||
assertEquals("Nacos default factory bean was wrong",
|
||||
NacosDataSourceFactoryBean.class.getName(),
|
||||
@@ -66,7 +68,7 @@ public class NacosDataSourcePropertiesTests {
|
||||
nacosDataSourceProperties.getEndpoint());
|
||||
assertEquals("Nacos namespace was wrong", "namespace",
|
||||
nacosDataSourceProperties.getNamespace());
|
||||
assertEquals("Nacos rule type was wrong", RuleType.SYSTEM,
|
||||
Assert.assertEquals("Nacos rule type was wrong", RuleType.SYSTEM,
|
||||
nacosDataSourceProperties.getRuleType());
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -23,11 +23,11 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.converter.JsonConverter;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.converter.XmlConverter;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.converter.JsonConverter;
|
||||
import com.alibaba.cloud.sentinel.datasource.converter.XmlConverter;
|
||||
import com.alibaba.csp.sentinel.slots.block.RuleConstant;
|
||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
package com.alibaba.cloud.sentinel.datasource;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
@@ -23,9 +23,9 @@ import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.converter.XmlConverter;
|
||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean;
|
||||
|
||||
import com.alibaba.cloud.sentinel.datasource.converter.XmlConverter;
|
||||
import com.alibaba.cloud.sentinel.datasource.factorybean.ZookeeperDataSourceFactoryBean;
|
||||
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||
import com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource;
|
||||
|
@@ -1,230 +0,0 @@
|
||||
///*
|
||||
// * Copyright (C) 2018 the original author or authors.
|
||||
// *
|
||||
// * 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 org.springframework.cloud.alibaba.sentinel.datasource;
|
||||
//
|
||||
//import static org.junit.Assert.assertEquals;
|
||||
//import static org.junit.Assert.assertNotNull;
|
||||
//import static org.junit.Assert.assertNull;
|
||||
//
|
||||
//import org.junit.Test;
|
||||
//import org.springframework.cloud.alibaba.sentinel.datasource.config.ApolloDataSourceProperties;
|
||||
//import org.springframework.cloud.alibaba.sentinel.datasource.config.DataSourcePropertiesConfiguration;
|
||||
//import org.springframework.cloud.alibaba.sentinel.datasource.config.FileDataSourceProperties;
|
||||
//import org.springframework.cloud.alibaba.sentinel.datasource.config.NacosDataSourceProperties;
|
||||
//import org.springframework.cloud.alibaba.sentinel.datasource.config.ZookeeperDataSourceProperties;
|
||||
//
|
||||
///**
|
||||
// * @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
|
||||
// */
|
||||
//public class DataSourcePropertiesConfigurationTests {
|
||||
//
|
||||
// @Test
|
||||
// public void testFileAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// FileDataSourceProperties fileDataSourceProperties = buildFileProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setFile(fileDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set file attribute",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration file properties was null after set file attribute",
|
||||
// dataSourcePropertiesConfiguration.getFile());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was null after set file attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testNacosAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// NacosDataSourceProperties nacosDataSourceProperties = buildNacosProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setNacos(nacosDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set nacos attribute",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration nacos properties was null after set nacos attribute",
|
||||
// dataSourcePropertiesConfiguration.getNacos());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was null after set nacos attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testZKAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// ZookeeperDataSourceProperties zookeeperDataSourceProperties = buildZKProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setZk(zookeeperDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set zk attribute",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration zk properties was null after set zk attribute",
|
||||
// dataSourcePropertiesConfiguration.getZk());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was null after set zk attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testApolloAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// ApolloDataSourceProperties apolloDataSourceProperties = buildApolloProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setApollo(apolloDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set apollo attribute",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration apollo properties was null after set apollo attribute",
|
||||
// dataSourcePropertiesConfiguration.getApollo());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was null after set apollo attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testMultiAttr() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration();
|
||||
// assertEquals("DataSourcePropertiesConfiguration valid field size was wrong", 0,
|
||||
// dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull("DataSourcePropertiesConfiguration valid properties was not null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
//
|
||||
// FileDataSourceProperties fileDataSourceProperties = buildFileProperties();
|
||||
// NacosDataSourceProperties nacosDataSourceProperties = buildNacosProperties();
|
||||
//
|
||||
// dataSourcePropertiesConfiguration.setFile(fileDataSourceProperties);
|
||||
// dataSourcePropertiesConfiguration.setNacos(nacosDataSourceProperties);
|
||||
//
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration valid field size was wrong after set file and nacos attribute",
|
||||
// 2, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNull(
|
||||
// "DataSourcePropertiesConfiguration valid properties was not null after set file and nacos attribute",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testFileConstructor() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration(
|
||||
// buildFileProperties());
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration file constructor valid field size was wrong",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration file constructor valid properties was null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testNacosConstructor() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration(
|
||||
// buildNacosProperties());
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration nacos constructor valid field size was wrong",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration nacos constructor valid properties was null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testApolloConstructor() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration(
|
||||
// buildApolloProperties());
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration apollo constructor valid field size was wrong",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration apollo constructor valid properties was null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testZKConstructor() {
|
||||
// DataSourcePropertiesConfiguration dataSourcePropertiesConfiguration = new DataSourcePropertiesConfiguration(
|
||||
// buildZKProperties());
|
||||
// assertEquals(
|
||||
// "DataSourcePropertiesConfiguration zk constructor valid field size was wrong",
|
||||
// 1, dataSourcePropertiesConfiguration.getValidField().size());
|
||||
// assertNotNull(
|
||||
// "DataSourcePropertiesConfiguration zk constructor valid properties was null",
|
||||
// dataSourcePropertiesConfiguration.getValidDataSourceProperties());
|
||||
// }
|
||||
//
|
||||
// private FileDataSourceProperties buildFileProperties() {
|
||||
// FileDataSourceProperties fileDataSourceProperties = new FileDataSourceProperties();
|
||||
//
|
||||
// fileDataSourceProperties.setFile("/tmp/test.json");
|
||||
// fileDataSourceProperties.setBufSize(1024);
|
||||
// fileDataSourceProperties.setRecommendRefreshMs(2000);
|
||||
// return fileDataSourceProperties;
|
||||
// }
|
||||
//
|
||||
// private NacosDataSourceProperties buildNacosProperties() {
|
||||
// NacosDataSourceProperties nacosDataSourceProperties = new NacosDataSourceProperties();
|
||||
// nacosDataSourceProperties.setServerAddr("127.0.0.1:8848");
|
||||
// nacosDataSourceProperties.setDataId("sentinel");
|
||||
// nacosDataSourceProperties.setGroupId("custom-group");
|
||||
// return nacosDataSourceProperties;
|
||||
// }
|
||||
//
|
||||
// private ApolloDataSourceProperties buildApolloProperties() {
|
||||
// ApolloDataSourceProperties apolloDataSourceProperties = new ApolloDataSourceProperties();
|
||||
// apolloDataSourceProperties.setFlowRulesKey("test-key");
|
||||
// apolloDataSourceProperties.setDefaultFlowRuleValue("dft-val");
|
||||
// apolloDataSourceProperties.setNamespaceName("namespace");
|
||||
// return apolloDataSourceProperties;
|
||||
// }
|
||||
//
|
||||
// private ZookeeperDataSourceProperties buildZKProperties() {
|
||||
// ZookeeperDataSourceProperties zookeeperDataSourceProperties = new ZookeeperDataSourceProperties();
|
||||
//
|
||||
// zookeeperDataSourceProperties.setServerAddr("localhost:2181");
|
||||
// zookeeperDataSourceProperties.setPath("/path");
|
||||
// return zookeeperDataSourceProperties;
|
||||
// }
|
||||
//
|
||||
//}
|
Reference in New Issue
Block a user