This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 973dd62  Fixes travis ci failure (#6642)
973dd62 is described below

commit 973dd624a132ccab8b8c42bbd1ae68063a928abd
Author: Andrew <[email protected]>
AuthorDate: Thu Aug 6 11:52:55 2020 +0800

    Fixes travis ci failure (#6642)
    
    * fixes travis ci failure
    
    * Try fixes travis ci
---
 .../proxy/backend/schema/ProxySchemaContexts.java  |  2 +-
 .../backend/schema/ProxySchemaContextsTest.java    | 24 ++++++++--------------
 2 files changed, 10 insertions(+), 16 deletions(-)

diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/schema/ProxySchemaContexts.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/schema/ProxySchemaContexts.java
index 7e2a5cc..de0f300 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/schema/ProxySchemaContexts.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/schema/ProxySchemaContexts.java
@@ -110,7 +110,7 @@ public final class ProxySchemaContexts {
             return Optional.empty();
         }
         Map<String, DataSource> dataSources = 
Objects.requireNonNull(getSchema(schemaNames.get(0))).getSchema().getDataSources();
-        return Optional.of(dataSources.values().iterator().next());
+        return dataSources.values().stream().findFirst();
     }
     
     public final class JDBCBackendDataSource implements BackendDataSource {
diff --git 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/schema/ProxySchemaContextsTest.java
 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/schema/ProxySchemaContextsTest.java
index e016b6e..e5de12f 100644
--- 
a/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/schema/ProxySchemaContextsTest.java
+++ 
b/shardingsphere-proxy/shardingsphere-proxy-backend/src/test/java/org/apache/shardingsphere/proxy/backend/schema/ProxySchemaContextsTest.java
@@ -24,8 +24,6 @@ import 
org.apache.shardingsphere.kernel.context.StandardSchemaContexts;
 import org.apache.shardingsphere.kernel.context.runtime.RuntimeContext;
 import org.apache.shardingsphere.kernel.context.schema.ShardingSphereSchema;
 import 
org.apache.shardingsphere.proxy.backend.communication.jdbc.datasource.MockDataSource;
-import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 import javax.sql.DataSource;
@@ -43,28 +41,24 @@ import static org.mockito.Mockito.when;
 
 public final class ProxySchemaContextsTest {
     
-    private Map<String, DataSource> mockDataSourceMap;
-    
-    @Before
-    public void setUp() {
-        mockDataSourceMap = new HashMap<>(2, 1);
-        mockDataSourceMap.put("ds_1", new MockDataSource());
-        mockDataSourceMap.put("ds_2", new MockDataSource());
+    @Test
+    public void assertGetDataSourceSampleEmpty() {
+        assertThat(ProxySchemaContexts.getInstance().getDataSourceSample(), 
is(Optional.empty()));
     }
     
     @Test
-    @Ignore
-    // FIXME #6628
     public void assertGetDataSourceSample() throws NoSuchFieldException, 
IllegalAccessException {
-        assertThat(ProxySchemaContexts.getInstance().getDataSourceSample(), 
is(Optional.empty()));
+        Map<String, DataSource> mockDataSourceMap = new HashMap<>(2, 1);
+        mockDataSourceMap.put("ds_1", new MockDataSource());
+        mockDataSourceMap.put("ds_2", new MockDataSource());
         Field schemaContexts = 
ProxySchemaContexts.getInstance().getClass().getDeclaredField("schemaContexts");
         schemaContexts.setAccessible(true);
-        schemaContexts.set(ProxySchemaContexts.getInstance(), new 
StandardSchemaContexts(getSchemaContextMap(), new Authentication(), new 
ConfigurationProperties(new Properties())));
+        schemaContexts.set(ProxySchemaContexts.getInstance(), new 
StandardSchemaContexts(getSchemaContextMap(mockDataSourceMap), new 
Authentication(), new ConfigurationProperties(new Properties())));
         Optional<DataSource> actual = 
ProxySchemaContexts.getInstance().getDataSourceSample();
-        assertThat(actual, 
is(Optional.of(mockDataSourceMap.entrySet().iterator().next().getValue())));
+        assertThat(actual, is(Optional.of(mockDataSourceMap.get("ds_1"))));
     }
     
-    private Map<String, SchemaContext> getSchemaContextMap() {
+    private Map<String, SchemaContext> getSchemaContextMap(final Map<String, 
DataSource> mockDataSourceMap) {
         SchemaContext schemaContext = mock(SchemaContext.class);
         ShardingSphereSchema shardingSphereSchema = 
mock(ShardingSphereSchema.class);
         RuntimeContext runtimeContext = mock(RuntimeContext.class);

Reply via email to