added test listener for logging
This commit is contained in:
		
							parent
							
								
									c5e1c5a1a5
								
							
						
					
					
						commit
						290e0894ff
					
				@ -25,8 +25,7 @@
 | 
				
			|||||||
        </encoder>
 | 
					        </encoder>
 | 
				
			||||||
    </appender>
 | 
					    </appender>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <logger name="org.thingsboard.server" level="DEBUG"/>
 | 
					    <logger name="org.thingsboard.server" level="INFO"/>
 | 
				
			||||||
    <logger name="org.thingsboard.server.transport.mqtt" level="TRACE"/>
 | 
					 | 
				
			||||||
    <logger name="org.apache.kafka.common.utils.AppInfoParser" level="WARN"/>
 | 
					    <logger name="org.apache.kafka.common.utils.AppInfoParser" level="WARN"/>
 | 
				
			||||||
    <logger name="org.apache.kafka.clients" level="WARN"/>
 | 
					    <logger name="org.apache.kafka.clients" level="WARN"/>
 | 
				
			||||||
    <!-- To enable the logging of scanned rule engine components-->
 | 
					    <!-- To enable the logging of scanned rule engine components-->
 | 
				
			||||||
 | 
				
			|||||||
@ -20,31 +20,21 @@ import com.google.common.collect.ImmutableMap;
 | 
				
			|||||||
import com.google.gson.JsonArray;
 | 
					import com.google.gson.JsonArray;
 | 
				
			||||||
import com.google.gson.JsonObject;
 | 
					import com.google.gson.JsonObject;
 | 
				
			||||||
import com.google.gson.JsonParser;
 | 
					import com.google.gson.JsonParser;
 | 
				
			||||||
import io.restassured.RestAssured;
 | 
					 | 
				
			||||||
import io.restassured.filter.log.RequestLoggingFilter;
 | 
					 | 
				
			||||||
import io.restassured.filter.log.ResponseLoggingFilter;
 | 
					 | 
				
			||||||
import lombok.extern.slf4j.Slf4j;
 | 
					import lombok.extern.slf4j.Slf4j;
 | 
				
			||||||
import org.apache.http.config.Registry;
 | 
					 | 
				
			||||||
import org.apache.http.config.RegistryBuilder;
 | 
					 | 
				
			||||||
import org.apache.http.conn.socket.ConnectionSocketFactory;
 | 
					 | 
				
			||||||
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
 | 
					 | 
				
			||||||
import org.apache.http.conn.ssl.TrustStrategy;
 | 
					import org.apache.http.conn.ssl.TrustStrategy;
 | 
				
			||||||
import org.apache.http.impl.client.CloseableHttpClient;
 | 
					 | 
				
			||||||
import org.apache.http.impl.client.HttpClients;
 | 
					 | 
				
			||||||
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 | 
					 | 
				
			||||||
import org.apache.http.ssl.SSLContextBuilder;
 | 
					import org.apache.http.ssl.SSLContextBuilder;
 | 
				
			||||||
import org.apache.http.ssl.SSLContexts;
 | 
					import org.apache.http.ssl.SSLContexts;
 | 
				
			||||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 | 
					 | 
				
			||||||
import org.testng.annotations.AfterSuite;
 | 
					import org.testng.annotations.AfterSuite;
 | 
				
			||||||
import org.testng.annotations.BeforeSuite;
 | 
					import org.testng.annotations.BeforeSuite;
 | 
				
			||||||
 | 
					import org.testng.annotations.Listeners;
 | 
				
			||||||
import org.thingsboard.server.common.data.EntityType;
 | 
					import org.thingsboard.server.common.data.EntityType;
 | 
				
			||||||
import org.thingsboard.server.common.data.id.DeviceId;
 | 
					import org.thingsboard.server.common.data.id.DeviceId;
 | 
				
			||||||
 | 
					 | 
				
			||||||
import javax.net.ssl.SSLContext;
 | 
					 | 
				
			||||||
import java.net.URI;
 | 
					import java.net.URI;
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Slf4j
 | 
					@Slf4j
 | 
				
			||||||
 | 
					@Listeners(TestListener.class)
 | 
				
			||||||
public abstract class AbstractContainerTest {
 | 
					public abstract class AbstractContainerTest {
 | 
				
			||||||
    protected static long timeoutMultiplier = 1;
 | 
					    protected static long timeoutMultiplier = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -161,20 +151,4 @@ public abstract class AbstractContainerTest {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static HttpComponentsClientHttpRequestFactory getRequestFactoryForSelfSignedCert() throws Exception {
 | 
					 | 
				
			||||||
        SSLContextBuilder builder = SSLContexts.custom();
 | 
					 | 
				
			||||||
        builder.loadTrustMaterial(null, (TrustStrategy) (chain, authType) -> true);
 | 
					 | 
				
			||||||
        SSLContext sslContext = builder.build();
 | 
					 | 
				
			||||||
        SSLConnectionSocketFactory sslSelfSigned = new SSLConnectionSocketFactory(sslContext, (s, sslSession) -> true);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder
 | 
					 | 
				
			||||||
                .<ConnectionSocketFactory>create()
 | 
					 | 
				
			||||||
                .register("https", sslSelfSigned)
 | 
					 | 
				
			||||||
                .build();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
 | 
					 | 
				
			||||||
        CloseableHttpClient httpClient = HttpClients.custom().setConnectionManager(cm).build();
 | 
					 | 
				
			||||||
        return new HttpComponentsClientHttpRequestFactory(httpClient);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -0,0 +1,53 @@
 | 
				
			|||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * Copyright © 2016-2022 The Thingsboard 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.thingsboard.server.msa;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import lombok.extern.slf4j.Slf4j;
 | 
				
			||||||
 | 
					import org.testng.ITestContext;
 | 
				
			||||||
 | 
					import org.testng.ITestResult;
 | 
				
			||||||
 | 
					import org.testng.TestListenerAdapter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import static org.testng.internal.Utils.log;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@Slf4j
 | 
				
			||||||
 | 
					public class TestListener  extends TestListenerAdapter {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onTestStart(ITestResult result) {
 | 
				
			||||||
 | 
					        super.onTestStart(result);
 | 
				
			||||||
 | 
					        log.info("===>>> Test started: " + result.getName());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Invoked when a test succeeds
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onTestSuccess(ITestResult result) {
 | 
				
			||||||
 | 
					        super.onTestSuccess(result);
 | 
				
			||||||
 | 
					        if (result != null) {
 | 
				
			||||||
 | 
					            log.info("<<<=== Test completed successfully: " + result.getName());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * Invoked when a test fails
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onTestFailure(ITestResult result) {
 | 
				
			||||||
 | 
					        super.onTestFailure(result);
 | 
				
			||||||
 | 
					        log.info("<<<=== Test failed: " + result.getName());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -30,11 +30,11 @@ public class DevicePrototypes {
 | 
				
			|||||||
        return device;
 | 
					        return device;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public static Device defaultGatewayPrototype() throws JsonProcessingException {
 | 
					    public static Device defaultGatewayPrototype() {
 | 
				
			||||||
        String isGateway = "{\"gateway\":true}";
 | 
					        String isGateway = "{\"gateway\":true}";
 | 
				
			||||||
        JsonNode additionalInfo = JacksonUtil.valueToTree(isGateway);
 | 
					        JsonNode additionalInfo = JacksonUtil.valueToTree(isGateway);
 | 
				
			||||||
        Device gatewayDeviceTemplate = new Device();
 | 
					        Device gatewayDeviceTemplate = new Device();
 | 
				
			||||||
        gatewayDeviceTemplate.setName("mqtt_gateway_" + RandomStringUtils.randomAlphabetic(5));
 | 
					        gatewayDeviceTemplate.setName("mqtt_gateway_" + RandomStringUtils.randomAlphanumeric(5));
 | 
				
			||||||
        gatewayDeviceTemplate.setType("gateway");
 | 
					        gatewayDeviceTemplate.setType("gateway");
 | 
				
			||||||
        gatewayDeviceTemplate.setAdditionalInfo(additionalInfo);
 | 
					        gatewayDeviceTemplate.setAdditionalInfo(additionalInfo);
 | 
				
			||||||
        return gatewayDeviceTemplate;
 | 
					        return gatewayDeviceTemplate;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							@ -1643,7 +1643,7 @@
 | 
				
			|||||||
            <dependency>
 | 
					            <dependency>
 | 
				
			||||||
                <groupId>org.hamcrest</groupId>
 | 
					                <groupId>org.hamcrest</groupId>
 | 
				
			||||||
                <artifactId>hamcrest-all</artifactId>
 | 
					                <artifactId>hamcrest-all</artifactId>
 | 
				
			||||||
                <version>${hamcrest}</version>
 | 
					                <version>${hamcrest.version}</version>
 | 
				
			||||||
                <scope>test</scope>
 | 
					                <scope>test</scope>
 | 
				
			||||||
            </dependency>
 | 
					            </dependency>
 | 
				
			||||||
            <dependency>
 | 
					            <dependency>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user