24hours SELECT TO_CHAR(date_column,’YYYY-MM-DD HH24:MI:SS’) FROM tablename
Read MoreMockito for JUnit5 test cases
1. One of NPE solutions for mock SomeClass someclass = mock(SomeClass.class,Mockito.RETURNS_DEEP_STUBS); 2. Assert Any Exceptions assertThrows(RunTimeException.class, ()->{ //logic code }); 3. Mock/Test private method @InjectMocks PrivateInClass privateInClass; ReflectionTestUtils.invokeMethod(privateInClass, “privateMethodName”, param1, param2, …); 4. Mock final class Add below file in test path …/test/resources/mockkito-extensions/org.mockito.plugins.MockMaker MockMaker content mock-maker-inline
Read MoreBloomRPC cant import proto files issue and solutions
1. Try to import path which includes all files are needed as class and resources 2. When shows “boolmrpc e is not a construtor, error construct request” need to check proto files whether are correct 1) one or more proto files are not necessary 2) grammar errors in porto 3) related files in the import […]
Read MoreForify fix for DocumentBuilderFactory : XML External Entity Injection
Reference code: DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); documentBuilderFactory.setFeature(“http://xml.org/sax/features/external-general-entities”, false); documentBuilderFactory.setFeature(“http://xml.org/sax/features/external-parameter-entities”, false); documentBuilderFactory.setFeature(“http://apache.org/xml/features/disallow-doctype-decl”, true); documentBuilderFactory.setXIncludeAware(false); documentBuilderFactory.setExpandEntityReferences(false); ……
Read MoreOverride tomcat version of springboot in pom
We know org.springframework.boot 2.2.1 version includes tomcat 9.027 version, if we need to upgrade to 9.037, we need to add it like below in pom.xml <tomcat-embed.version>9.0.37</tomcat-embed.version> <dependencyManagement> <dependencies> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-core</artifactId> <version>${tomcat-embed.version}</version> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-el</artifactId> <version>${tomcat-embed.version}</version> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-websocket</artifactId> <version>${tomcat-embed.version}</version> </dependency> </dependencies> Suggest to use Maven Helper plugin for Idea to see
Read MoreChange Server port and show hibernate sql in application.yaml
Change Server Port in application.yml … server: port: 8081 … Show sql ….. spring: datasource: jpa: show-sql: true properties: hibernate: format_sql: true
Read MoreConfig Sona and Run
settings.xml add below <profiles> <profile> <id>sonar</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <!– Sonar Host e.g. http://localhost:9000 –> <sonar.host.url> http://localhost:9000 </sonar.host.url> </properties> </profile> </profiles> Exclusion files in pom.xml <sonar.exclusions> /usr/file1 /usr/file2 </sonar.exclusions> Run Sona using maven mvn clean install sonar:sonar -s /maven/location/settings.xml
Read More