This commit is contained in:
赵禹光 2019-07-11 20:24:13 +08:00
parent 1042831c2a
commit fb5a352ec6
8 changed files with 29 additions and 45 deletions

View File

@ -15,16 +15,13 @@
*/
package com.alibaba.nacos.config.server.utils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import com.alibaba.nacos.config.server.utils.SimpleReadWriteLock;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration

View File

@ -15,6 +15,8 @@
*/
package com.alibaba.nacos.config.server.utils.event;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher.AbstractEventListener;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher.Event;
import org.junit.After;
import org.junit.Ignore;
import org.junit.Test;
@ -22,10 +24,6 @@ import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher.Event;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher.AbstractEventListener;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;

View File

@ -22,32 +22,28 @@ import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
public class AppTest
extends TestCase {
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
public AppTest(String testName) {
super(testName);
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
public static Test suite() {
return new TestSuite(AppTest.class);
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
public void testApp() {
assertTrue(true);
}
}

View File

@ -25,7 +25,8 @@ public class AuthInfo {
private String appKey;
public AuthInfo() {}
public AuthInfo() {
}
public AuthInfo(String operator, String appKey) {
this.operator = operator;
@ -36,8 +37,8 @@ public class AuthInfo {
try {
String[] byteStrs = auth.split(",");
byte[] bytes = new byte[byteStrs.length];
for(int i = 0; i < byteStrs.length; i++) {
bytes[i] = (byte)(~(Short.parseShort(byteStrs[i])));
for (int i = 0; i < byteStrs.length; i++) {
bytes[i] = (byte) (~(Short.parseShort(byteStrs[i])));
}
String contentStr = new String(bytes, encoding);

View File

@ -23,13 +23,10 @@ import com.alibaba.nacos.naming.misc.Loggers;
import com.alibaba.nacos.naming.pojo.Record;
import org.springframework.stereotype.Component;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import static org.apache.commons.lang3.CharEncoding.UTF_8;
/**
* Use FastJSON to serialize data
*

View File

@ -177,7 +177,8 @@ public class RaftStore {
instancesDatum.key = key;
instancesDatum.value = new Instances();
instancesDatum.value.setInstanceList(JSON.parseObject(jsonObject.getString("value"),
new TypeReference<List<Instance>>(){}));
new TypeReference<List<Instance>>() {
}));
if (!instancesDatum.value.getInstanceList().isEmpty()) {
for (Instance instance : instancesDatum.value.getInstanceList()) {
instance.setEphemeral(false);

View File

@ -1,8 +1,9 @@
package com.alibaba.nacos.naming.healthcheck;
import com.alibaba.nacos.api.naming.PreservedMetadataKeys;
import com.alibaba.nacos.core.utils.SystemUtils;
import com.alibaba.nacos.naming.core.*;
import com.alibaba.nacos.naming.core.DistroMapper;
import com.alibaba.nacos.naming.core.Instance;
import com.alibaba.nacos.naming.core.Service;
import com.alibaba.nacos.naming.misc.GlobalConfig;
import com.alibaba.nacos.naming.push.PushService;
import org.junit.Assert;
@ -13,10 +14,7 @@ import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.util.ReflectionTestUtils;
import java.util.ArrayList;

View File

@ -22,32 +22,28 @@ import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
public class AppTest
extends TestCase {
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
public AppTest(String testName) {
super(testName);
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
public static Test suite() {
return new TestSuite(AppTest.class);
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
public void testApp() {
assertTrue(true);
}
}