You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/10/12 11:49:21 UTC

[GitHub] [shardingsphere] terrymanu opened a new issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

terrymanu opened a new issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jiang2015 commented on issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

Posted by GitBox <gi...@apache.org>.
jiang2015 commented on issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761#issuecomment-707425495


   assin to me


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jiang2015 edited a comment on issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

Posted by GitBox <gi...@apache.org>.
jiang2015 edited a comment on issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761#issuecomment-712738297


   In 【MetaDataConnectionAdapterTest】  I add one function as follows:
   
   ```
   private final DatabaseType **databaseType4Oracle** = DatabaseTypes.getTrunkDatabaseType("Oracle");
   
       @Test
       public void assertGetSchema4Oracle() throws SQLException {
           when(connection.getSchema()).thenReturn(TEST_SCHEMA);
           MetaDataConnectionAdapter connectionAdapter = new MetaDataConnectionAdapter(**databaseType4Oracle**, connection);
           assertThat(connectionAdapter.getSchema(), is(TEST_SCHEMA));
       }
   ```
   
   when test, NullPointerException occured as follow 
   
   java.lang.NullPointerException
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.handler.impl.OracleJDBCSchemaHandler.getSchema(OracleJDBCSchemaHandler.java:46)
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.MetaDataConnectionAdapter.getSchema(MetaDataConnectionAdapter.java:79)
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.MetaDataConnectionAdapterTest.assertGetSchema4Oracle(MetaDataConnectionAdapterTest.java:78)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
   	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
   	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
   	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
   	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
   	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
   	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
   	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
   	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
   	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
   	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
   	at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:68)
   	at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:74)
   	at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
   	at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:161)
   	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
   	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
   	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
   	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
   	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
   
   the reason:
   OracleJDBCSchemaHandler 
   ```
   
       public String getSchema(final Connection connection) {
           try {
               return Optional.ofNullable(connection.getMetaData().getUserName()).map(String::toUpperCase).orElse(null);
           } catch (final SQLException ignored) {
               return null;
           }
       }
   
   ```
   connection.getMetaData() is null, this issue how to add testcase ,please give me advice ,thanks。
   @terrymanu 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] tristaZero closed issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

Posted by GitBox <gi...@apache.org>.
tristaZero closed issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jiang2015 edited a comment on issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

Posted by GitBox <gi...@apache.org>.
jiang2015 edited a comment on issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761#issuecomment-712738297


   sorry, I have no idea how to add the TestCase for this issue;
   In 【MetaDataConnectionAdapterTest】  I add one function as follows:
   
   ```
   private final DatabaseType **databaseType4Oracle** = DatabaseTypes.getTrunkDatabaseType("Oracle");
   
       @Test
       public void assertGetSchema4Oracle() throws SQLException {
           when(connection.getSchema()).thenReturn(TEST_SCHEMA);
           MetaDataConnectionAdapter connectionAdapter = new MetaDataConnectionAdapter(**databaseType4Oracle**, connection);
           assertThat(connectionAdapter.getSchema(), is(TEST_SCHEMA));
       }
   ```
   
   when test, NullPointerException occured as follow 
   
   java.lang.NullPointerException
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.handler.impl.OracleJDBCSchemaHandler.getSchema(OracleJDBCSchemaHandler.java:46)
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.MetaDataConnectionAdapter.getSchema(MetaDataConnectionAdapter.java:79)
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.MetaDataConnectionAdapterTest.assertGetSchema4Oracle(MetaDataConnectionAdapterTest.java:78)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
   	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
   	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
   	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
   	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
   	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
   	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
   	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
   	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
   	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
   	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
   	at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:68)
   	at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:74)
   	at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
   	at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:161)
   	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
   	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
   	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
   	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
   	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
   
   the reason:
   OracleJDBCSchemaHandler 
   ```
   
       public String getSchema(final Connection connection) {
           try {
               return Optional.ofNullable(connection.getMetaData().getUserName()).map(String::toUpperCase).orElse(null);
           } catch (final SQLException ignored) {
               return null;
           }
       }
   
   ```
   connection.getMetaData() is null, this issue how to add testcase ,please give me advice ,thanks。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jiang2015 edited a comment on issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

Posted by GitBox <gi...@apache.org>.
jiang2015 edited a comment on issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761#issuecomment-712738297


   In 【MetaDataConnectionAdapterTest】  I add one function as follows:
   
   ```
   private final DatabaseType **databaseType4Oracle** = DatabaseTypes.getTrunkDatabaseType("Oracle");
   
       @Test
       public void assertGetSchema4Oracle() throws SQLException {
           when(connection.getSchema()).thenReturn(TEST_SCHEMA);
           MetaDataConnectionAdapter connectionAdapter = new MetaDataConnectionAdapter(**databaseType4Oracle**, connection);
           assertThat(connectionAdapter.getSchema(), is(TEST_SCHEMA));
       }
   ```
   
   when test, NullPointerException occured as follow 
   
   java.lang.NullPointerException
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.handler.impl.OracleJDBCSchemaHandler.getSchema(OracleJDBCSchemaHandler.java:46)
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.MetaDataConnectionAdapter.getSchema(MetaDataConnectionAdapter.java:79)
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.MetaDataConnectionAdapterTest.assertGetSchema4Oracle(MetaDataConnectionAdapterTest.java:78)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
   	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
   	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
   	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
   	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
   	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
   	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
   	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
   	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
   	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
   	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
   	at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:68)
   	at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:74)
   	at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
   	at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:161)
   	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
   	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
   	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
   	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
   	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
   
   the reason:
   OracleJDBCSchemaHandler 
   ```
   
       public String getSchema(final Connection connection) {
           try {
               return Optional.ofNullable(connection.getMetaData().getUserName()).map(String::toUpperCase).orElse(null);
           } catch (final SQLException ignored) {
               return null;
           }
       }
   
   ```
   connection.getMetaData() is null, this issue how to add testcase ,please give me advice ,thanks。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] jiang2015 commented on issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

Posted by GitBox <gi...@apache.org>.
jiang2015 commented on issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761#issuecomment-712738297


   sorry, I have no idea how to add the TestCase for this issue;
   In 【MetaDataConnectionAdapterTest】  I add one function as follows:
   
   ```
   private final DatabaseType **databaseType4Oracle** = DatabaseTypes.getTrunkDatabaseType("Oracle");
   
       @Test
       public void assertGetSchema4Oracle() throws SQLException {
           when(connection.getSchema()).thenReturn(TEST_SCHEMA);
           MetaDataConnectionAdapter connectionAdapter = new MetaDataConnectionAdapter(**databaseType4Oracle**, connection);
           assertThat(connectionAdapter.getSchema(), is(TEST_SCHEMA));
       }
   ```
   
   when test, NullPointerException occured as follow 
   
   java.lang.NullPointerException
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.handler.impl.OracleJDBCSchemaHandler.getSchema(OracleJDBCSchemaHandler.java:46)
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.MetaDataConnectionAdapter.getSchema(MetaDataConnectionAdapter.java:79)
   	at org.apache.shardingsphere.infra.metadata.model.physical.jdbc.MetaDataConnectionAdapterTest.assertGetSchema4Oracle(MetaDataConnectionAdapterTest.java:78)
   	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   	at java.lang.reflect.Method.invoke(Method.java:498)
   	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
   	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
   	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
   	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
   	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
   	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
   	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
   	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
   	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
   	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
   	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
   	at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:68)
   	at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:74)
   	at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
   	at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:161)
   	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
   	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
   	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
   	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
   	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
   
   the reason:
   OracleJDBCSchemaHandler 
   
   `    public String getSchema(final Connection connection) {
           try {
               return Optional.ofNullable(connection.getMetaData().getUserName()).map(String::toUpperCase).orElse(null);
           } catch (final SQLException ignored) {
               return null;
           }
       }`
   
   connection.getMetaData() is null, this issue how to add testcase ,please give me advice ,thanks。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] strongduanmu commented on issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761#issuecomment-707442274


   @jiang2015 Assigned, and welcome to join the SS community. 😀
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [shardingsphere] taojintianxia commented on issue #7761: Add test case for MetaDataConnectionAdapter.getSchema with SPI

Posted by GitBox <gi...@apache.org>.
taojintianxia commented on issue #7761:
URL: https://github.com/apache/shardingsphere/issues/7761#issuecomment-717827563


   @jiang2015 hi there
   
   after check the source code of `OracleDatabaseMetaDataDialectHandler` we could find out that the handler implementation for Oracle is different than MySQL like followings : 
   
   ```java
   
       @Override
       public String getSchema(final Connection connection) {
           try {
               return Optional.ofNullable(connection.getMetaData().getUserName()).map(String::toUpperCase).orElse(null);
           } catch (final SQLException ignored) {
               return null;
           }
       }
   ``` 
   
   in your test case, you just mock the getSchema, but the schema for Oracle is from userName in metadata. ^_^


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org