diff options
Diffstat (limited to 'aai-traversal/src/test/java/org')
17 files changed, 263 insertions, 757 deletions
diff --git a/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java new file mode 100644 index 0000000..4210596 --- /dev/null +++ b/aai-traversal/src/test/java/org/onap/aai/AAIGremlinQueryTest.java @@ -0,0 +1,126 @@ +package org.onap.aai; + +import com.jayway.jsonpath.JsonPath; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.aai.config.PropertyPasswordConfiguration; +import org.onap.aai.exceptions.AAIException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Import; +import org.springframework.http.*; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.client.RestTemplate; + +import javax.ws.rs.core.Response; +import java.io.UnsupportedEncodingException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertNotNull; + +/** + * A sample junit test using spring boot that provides the ability to spin + * up the application from the junit layer and run rest requests against + * SpringBootTest annotation with web environment requires which spring boot + * class to load and the random port starts the application on a random port + * and injects back into the application for the field with annotation LocalServerPort + * <p> + * + * This can be used to potentially replace a lot of the fitnesse tests since + * they will be testing against the same thing except fitnesse uses hbase + */ +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = TraversalApp.class) +@TestPropertySource(locations = "classpath:application-test.properties") +@ContextConfiguration(initializers = PropertyPasswordConfiguration.class) +@Import(TraversalTestConfiguration.class) +public class AAIGremlinQueryTest { + + private HttpTestUtil httpTestUtil; + + private String pserverUri; + + private String hostname; + + @Autowired + RestTemplate restTemplate; + + @LocalServerPort + int randomPort; + + private HttpEntity httpEntity; + + private HttpHeaders headers; + + private String baseUrl; + + @Before + public void setup() throws Exception { + + httpTestUtil = new HttpTestUtil(); + + hostname = UUID.randomUUID().toString(); + + pserverUri ="/aai/v11/cloud-infrastructure/pservers/pserver/" + hostname; + + Map<String, String> pserverMap = new HashMap<>(); + pserverMap.put("hostname", hostname); + String payload = PayloadUtil.getTemplatePayload("pserver.json", pserverMap); + httpTestUtil.doPut(pserverUri, payload); + + headers = new HttpHeaders(); + + headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.add("Real-Time", "true"); + headers.add("X-FromAppId", "JUNIT"); + headers.add("X-TransactionId", "JUNIT"); + + baseUrl = "https://localhost:" + randomPort; + } + + @Test + public void testPserverCount() throws Exception { + Map<String, String> gremlinQueryMap = new HashMap<>(); + gremlinQueryMap.put("gremlin-query", "g.V().has('hostname', '" + hostname + "').count()"); + + String payload = PayloadUtil.getTemplatePayload("gremlin-query.json", gremlinQueryMap); + + ResponseEntity responseEntity = null; + + String endpoint = "/aai/v11/query?format=console"; + + httpEntity = new HttpEntity(payload, headers); + responseEntity = restTemplate.exchange(baseUrl + endpoint, HttpMethod.PUT, httpEntity, String.class); + assertThat(responseEntity.getStatusCode(), is(HttpStatus.OK)); + + String result = JsonPath.read(responseEntity.getBody().toString(), "$.results[0].result"); + assertThat(result, is("1")); + } + + @After + public void tearDown() throws UnsupportedEncodingException, AAIException { + + Response response = httpTestUtil.doGet(pserverUri); + + assertNotNull("Expected the response to be returned", response); + assertThat(response.getStatus(), is(200)); + + String body = response.getEntity().toString(); + String resourceVersion = JsonPath.read(body, "$.resource-version"); + + response = httpTestUtil.doDelete(pserverUri, resourceVersion); + assertNotNull("Expected the response to be returned", response); + assertThat(response.getStatus(), is(204)); + } +} diff --git a/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java b/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java new file mode 100644 index 0000000..e4c6f19 --- /dev/null +++ b/aai-traversal/src/test/java/org/onap/aai/TraversalTestConfiguration.java @@ -0,0 +1,125 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + */ +package org.onap.aai; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.apache.http.client.HttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.core.env.Environment; +import org.springframework.http.HttpStatus; +import org.springframework.http.client.ClientHttpResponse; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; +import org.springframework.util.ResourceUtils; +import org.springframework.web.client.ResponseErrorHandler; +import org.springframework.web.client.RestTemplate; + +import javax.net.ssl.SSLContext; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.security.KeyStore; + +@TestConfiguration +public class TraversalTestConfiguration { + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(TraversalTestConfiguration.class); + + @Autowired + private Environment env; + + /** + * Create a RestTemplate bean, using the RestTemplateBuilder provided + * by the auto-configuration. + */ + @Bean + RestTemplate restTemplate(RestTemplateBuilder builder) throws Exception { + + char[] trustStorePassword = env.getProperty("server.ssl.trust-store-password").toCharArray(); + char[] keyStorePassword = env.getProperty("server.ssl.key-store-password").toCharArray(); + + String keyStore = env.getProperty("server.ssl.key-store"); + String trustStore = env.getProperty("server.ssl.trust-store"); + + SSLContextBuilder sslContextBuilder = SSLContextBuilder.create(); + + if(env.acceptsProfiles("two-way-ssl")){ + sslContextBuilder = sslContextBuilder.loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword); + } + + SSLContext sslContext = sslContextBuilder + .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword) + .build(); + + HttpClient client = HttpClients.custom() + .setSSLContext(sslContext) + .setSSLHostnameVerifier((s, sslSession) -> true) + .build(); + + RestTemplate restTemplate = builder + .requestFactory(new HttpComponentsClientHttpRequestFactory(client)) + .build(); + + restTemplate.setErrorHandler(new ResponseErrorHandler() { + @Override + public boolean hasError(ClientHttpResponse clientHttpResponse) throws IOException { + if (clientHttpResponse.getStatusCode() != HttpStatus.OK) { + + logger.debug("Status code: " + clientHttpResponse.getStatusCode()); + + if (clientHttpResponse.getStatusCode() == HttpStatus.FORBIDDEN) { + logger.debug("Call returned a error 403 forbidden resposne "); + return true; + } + + if(clientHttpResponse.getRawStatusCode() % 100 == 5){ + logger.debug("Call returned a error " + clientHttpResponse.getStatusText()); + return true; + } + } + + return false; + } + + @Override + public void handleError(ClientHttpResponse clientHttpResponse) throws IOException { + } + }); + + return restTemplate; + } + + private KeyStore loadPfx(String file, char[] password) throws Exception { + KeyStore keyStore = KeyStore.getInstance("PKCS12"); + File key = ResourceUtils.getFile(file); + try (InputStream in = new FileInputStream(key)) { + keyStore.load(in, password); + } + return keyStore; + } +} diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java index bd3705e..64d77a9 100644 --- a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingInvalidDataTest.java @@ -38,7 +38,6 @@ import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex; import com.thinkaurelius.titan.graphdb.types.vertices.EdgeLabelVertex; import com.thinkaurelius.titan.graphdb.types.vertices.PropertyKeyVertex; import org.apache.commons.lang.ObjectUtils; -import org.apache.openjpa.kernel.exps.Exp; import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.T; import org.apache.tinkerpop.gremlin.structure.Vertex; @@ -81,7 +80,7 @@ public class ModelBasedProcessingInvalidDataTest { @BeforeClass public static void configure() throws Exception { System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java index 406d122..dc8871d 100644 --- a/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphgen/ModelBasedProcessingTest.java @@ -74,10 +74,9 @@ public class ModelBasedProcessingTest { @BeforeClass public static void configure() throws Exception { System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, AAIProperties.LATEST); - } @Before diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java index 552dbe4..029565d 100644 --- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphNamedQueryTest.java @@ -98,7 +98,7 @@ public class SearchGraphNamedQueryTest { } private void addWidgets() { - String widgetPath = "." + AAIConstants.AAI_FILESEP + "bundleconfig-local" + AAIConstants.AAI_FILESEP + "etc" + + String widgetPath = "." + AAIConstants.AAI_FILESEP + "src/main/resources" + AAIConstants.AAI_FILESEP + "etc" + AAIConstants.AAI_FILESEP + "scriptdata"+ AAIConstants.AAI_FILESEP + "widget-model-json"; File dir = new File(widgetPath); @@ -120,7 +120,7 @@ public class SearchGraphNamedQueryTest { } private void addNamedQueries() { - String namedQueryPath = "." + AAIConstants.AAI_FILESEP + "bundleconfig-local" + AAIConstants.AAI_FILESEP + "etc" + + String namedQueryPath = "." + AAIConstants.AAI_FILESEP + "src/main/resources" + AAIConstants.AAI_FILESEP + "etc" + AAIConstants.AAI_FILESEP + "scriptdata"+ AAIConstants.AAI_FILESEP + "named-query-json"; File dir = new File(namedQueryPath); @@ -152,7 +152,7 @@ public class SearchGraphNamedQueryTest { httpTestUtil = new HttpTestUtil(); System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); searchGraph = new SearchGraph(); diff --git a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java index f624828..ba108a6 100644 --- a/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/dbgraphmap/SearchGraphTest.java @@ -27,7 +27,6 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo import org.apache.tinkerpop.gremlin.structure.Graph; import org.apache.tinkerpop.gremlin.structure.Vertex; import org.apache.tinkerpop.gremlin.structure.VertexProperty; -import org.apache.velocity.util.ArrayListWrapper; import org.eclipse.persistence.dynamic.DynamicEntity; import org.junit.Assert; import org.junit.Before; @@ -100,7 +99,7 @@ public class SearchGraphTest { public void setup(){ System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); searchGraph = new SearchGraph(); @@ -376,4 +375,4 @@ public class SearchGraphTest { searchGraph.runNodesQuery(httpHeaders,"model-ver",edgeFilter, filter,dbEngine,loader,urlBuilder); } -}
\ No newline at end of file +} diff --git a/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java deleted file mode 100644 index 40de5a9..0000000 --- a/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSInInterceptorTest.java +++ /dev/null @@ -1,204 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.onap.aai.interceptors; - -import org.apache.cxf.message.Exchange; -import org.apache.cxf.message.ExchangeImpl; -import org.apache.cxf.message.Message; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.mockito.Mockito.*; - -public class AAILogJAXRSInInterceptorTest { - - private AAILogJAXRSInInterceptor aaiLogJAXRSInInterceptor; - - private Message message; - private Exchange exchange; - private InputStream is; - private Map<String, List<String>> headers; - - - @Before - public void setup(){ - - aaiLogJAXRSInInterceptor = new AAILogJAXRSInInterceptor(); - - message = mock(Message.class); - exchange = spy(new ExchangeImpl()); - - is = getClass().getClassLoader().getResourceAsStream("logback.xml"); - - headers = new HashMap<>(); - headers.put("X-FromAppId", Arrays.asList("JUNIT")); - headers.put("X-TransactionId", Arrays.asList("JUNIT")); - headers.put("Content-Type", Arrays.asList("application/json")); - headers.put("Accept", Arrays.asList("application/json")); - } - - @Test - public void testHandleMessageWhenNotCamelRequest() throws IOException { - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(InputStream.class)).thenReturn(is); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - - when(message.get("CamelHttpUrl")).thenReturn("/somestring"); - aaiLogJAXRSInInterceptor.handleMessage(message); - } - - @Test - public void testHandleMessageWhenUUIDHasMultiple() throws IOException { - - Map<String, List<String>> headers = new HashMap<>(); - - headers.put("X-FromAppId", Arrays.asList("JUNIT")); - headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja")); - headers.put("Content-Type", Arrays.asList("application/json")); - headers.put("Accept", Arrays.asList("application/json")); - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(InputStream.class)).thenReturn(is); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - - when(message.get("CamelHttpUrl")).thenReturn("/somestring"); - aaiLogJAXRSInInterceptor.handleMessage(message); - } - - @Test - public void testHandleMessageWhenMissingTransactionId() throws IOException { - - Map<String, List<String>> headers = new HashMap<>(); - - headers.put("X-FromAppId", Arrays.asList("JUNIT")); - headers.put("Content-Type", Arrays.asList("application/json")); - headers.put("Accept", Arrays.asList("application/json")); - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(InputStream.class)).thenReturn(is); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - - when(message.get("CamelHttpUrl")).thenReturn("/somestring"); - aaiLogJAXRSInInterceptor.handleMessage(message); - } - - @Test - public void testHandleMessageWhenMissingContentType() throws IOException { - - Map<String, List<String>> headers = new HashMap<>(); - - headers.put("X-FromAppId", Arrays.asList("JUNIT")); - headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja")); - headers.put("Accept", Arrays.asList("application/json")); - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(InputStream.class)).thenReturn(is); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - - when(message.get("CamelHttpUrl")).thenReturn("/somestring"); - aaiLogJAXRSInInterceptor.handleMessage(message); - } - - @Test - public void testHandleMessageWhenQueryExistsAndUriEcho() throws IOException { - - Map<String, List<String>> headers = new HashMap<>(); - - headers.put("X-FromAppId", Arrays.asList("JUNIT")); - headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja")); - headers.put("Content-Type", Arrays.asList("application/json")); - headers.put("Accept", Arrays.asList("application/json")); - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(InputStream.class)).thenReturn(is); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - when(message.get(Message.QUERY_STRING)).thenReturn(null); - when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true); - when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn(""); - when(exchange.containsKey("AAI_LOGGING_TRACE_ENABLED")).thenReturn(true); - when(exchange.remove("AAI_LOGGING_TRACE_ENABLED")).thenReturn(""); - when(message.get("CamelHttpUrl")).thenReturn("/util/echo"); - aaiLogJAXRSInInterceptor.handleMessage(message); - } - - @Test - public void testHandleMessageWhenQueryExistsAndUriTranslog() throws IOException { - - Map<String, List<String>> headers = new HashMap<>(); - - headers.put("X-FromAppId", Arrays.asList("JUNIT")); - headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja")); - headers.put("Content-Type", Arrays.asList("application/json")); - headers.put("Accept", Arrays.asList("application/json")); - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(InputStream.class)).thenReturn(is); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - when(message.get(Message.QUERY_STRING)).thenReturn(null); - when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true); - when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn(""); - when(exchange.containsKey("AAI_LOGGING_TRACE_ENABLED")).thenReturn(true); - when(exchange.remove("AAI_LOGGING_TRACE_ENABLED")).thenReturn(""); - when(message.get("CamelHttpUrl")).thenReturn("/translog/"); - aaiLogJAXRSInInterceptor.handleMessage(message); - } - - @Test - public void testHandleMessageWhenPutMessageKeyReturnsException() throws IOException { - - Map<String, List<String>> headers = new HashMap<>(); - - headers.put("X-FromAppId", Arrays.asList("JUNIT")); - headers.put("X-TransactionId", Arrays.asList("jfasodjf:fjaosjfidsaj:afsidjfaodfja")); - headers.put("Content-Type", Arrays.asList("application/json")); - headers.put("Accept", Arrays.asList("application/json")); - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(InputStream.class)).thenReturn(is); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - when(message.get(Message.QUERY_STRING)).thenReturn(null); - when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true); - when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn(""); - when(exchange.containsKey("AAI_LOGGING_TRACE_ENABLED")).thenReturn(true); - when(exchange.remove("AAI_LOGGING_TRACE_ENABLED")).thenReturn(""); - when(message.get("CamelHttpUrl")).thenReturn("/translog/"); - when(message.get(Message.ENCODING)).thenReturn("http"); - when(message.get(Message.RESPONSE_CODE)).thenReturn(200); - - aaiLogJAXRSInInterceptor.handleMessage(message); - } -}
\ No newline at end of file diff --git a/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java deleted file mode 100644 index 52c6a42..0000000 --- a/aai-traversal/src/test/java/org/onap/aai/interceptors/AAILogJAXRSOutInterceptorTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.onap.aai.interceptors; - -import org.apache.cxf.io.CacheAndWriteOutputStream; -import org.apache.cxf.message.Exchange; -import org.apache.cxf.message.ExchangeImpl; -import org.apache.cxf.message.Message; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.io.OutputStream; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.mockito.Mockito.*; - -public class AAILogJAXRSOutInterceptorTest { - - private AAILogJAXRSOutInterceptor aaiLogJAXRSOutInterceptor; - - private Message message; - private Exchange exchange; - private OutputStream out; - private Map<String, List<String>> headers; - private Message outMessage; - private Message inMessage; - - - @Before - public void setup(){ - - aaiLogJAXRSOutInterceptor = new AAILogJAXRSOutInterceptor(); - - message = mock(Message.class); - exchange = spy(new ExchangeImpl()); - out = mock(OutputStream.class); - outMessage = mock(Message.class); - inMessage = mock(Message.class); - - - headers = new HashMap<>(); - headers.put("X-FromAppId", Arrays.asList("JUNIT")); - headers.put("X-TransactionId", Arrays.asList("JUNIT")); - headers.put("Content-Type", Arrays.asList("application/json")); - headers.put("Accept", Arrays.asList("application/json")); - } - - @Test - public void testHandleMessageWhenNotCamelRequest() throws IOException { - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(OutputStream.class)).thenReturn(out); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - when(exchange.getOutMessage()).thenReturn(outMessage); - when(outMessage.getContent(OutputStream.class)).thenReturn(out); - when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true); - when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn(""); - - when(message.get("CamelHttpUrl")).thenReturn("/somestring"); - aaiLogJAXRSOutInterceptor.handleMessage(message); - } - - @Test - public void testLogCallBack(){ - - when(message.getExchange()).thenReturn(exchange); - when(message.getContent(OutputStream.class)).thenReturn(out); - when(message.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(message.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - when(exchange.getOutMessage()).thenReturn(outMessage); - - when(outMessage.getContent(OutputStream.class)).thenReturn(out); - when(exchange.containsKey("AAI_LOGGING_HBASE_ENABLED")).thenReturn(true); - when(exchange.remove("AAI_LOGGING_HBASE_ENABLED")).thenReturn(""); - when(exchange.getInMessage()).thenReturn(inMessage); - - when(inMessage.getExchange()).thenReturn(exchange); - when(inMessage.getContent(OutputStream.class)).thenReturn(out); - when(inMessage.get(Message.PROTOCOL_HEADERS)).thenReturn(headers); - when(inMessage.get(Message.CONTENT_TYPE)).thenReturn("*/*"); - - AAILogJAXRSOutInterceptor.LoggingCallback loggingCallback = new AAILogJAXRSOutInterceptor().new LoggingCallback(message, out); - final CacheAndWriteOutputStream newOut = new CacheAndWriteOutputStream(out); - loggingCallback.onClose(newOut); - } - -}
\ No newline at end of file diff --git a/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java deleted file mode 100644 index fcc1ee3..0000000 --- a/aai-traversal/src/test/java/org/onap/aai/interceptors/PostAaiAjscInterceptorTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.onap.aai.interceptors; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.aai.logging.LoggingContext; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -public class PostAaiAjscInterceptorTest { - - private PostAaiAjscInterceptor postAaiAjscInterceptor; - - @Before - public void setup(){ - postAaiAjscInterceptor = new PostAaiAjscInterceptor(); - } - - @Test - public void getInstance() throws Exception { - PostAaiAjscInterceptor interceptor = PostAaiAjscInterceptor.getInstance(); - assertNotNull(interceptor); - } - - @Test - public void testAllowOrRejectIfSuccess() throws Exception { - - HttpServletRequest request = Mockito.mock(HttpServletRequest.class); - HttpServletResponse response = Mockito.mock(HttpServletResponse.class); - response.setStatus(200); - Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj")); - - boolean success = postAaiAjscInterceptor.allowOrReject(request, response, null); - - assertTrue("Expecting the post interceptor to return success regardless", success); - } - - @Test - public void testAllowOrRejectIfFailure() throws Exception { - - HttpServletRequest request = Mockito.mock(HttpServletRequest.class); - HttpServletResponse response = Mockito.mock(HttpServletResponse.class); - response.setStatus(400); - Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("/fadsjoifj")); - - boolean success = postAaiAjscInterceptor.allowOrReject(request, response, null); - - assertTrue("Expecting the post interceptor to return success regardless", success); - } -}
\ No newline at end of file diff --git a/aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java b/aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java deleted file mode 100644 index 35651c3..0000000 --- a/aai-traversal/src/test/java/org/onap/aai/interceptors/PreAaiAjscInterceptorTest.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.onap.aai.interceptors; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; - -import javax.servlet.http.HttpServletRequest; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.anyString; - -public class PreAaiAjscInterceptorTest { - - private PreAaiAjscInterceptor preAaiAjscInterceptor; - - @Before - public void setup(){ - preAaiAjscInterceptor = new PreAaiAjscInterceptor(); - } - - @Test - public void getInstance() throws Exception { - PreAaiAjscInterceptor interceptor = PreAaiAjscInterceptor.getInstance(); - assertNotNull(interceptor); - } - - @Test - public void testAllowOrRejectIfSuccess() throws Exception { - - HttpServletRequest request = Mockito.mock(HttpServletRequest.class); - - Mockito.when(request.getRequestURI()).thenReturn("/fadsjoifj"); - Mockito.when(request.getHeader(anyString())).thenReturn("JUNIT-Test"); - Mockito.when(request.getMethod()).thenReturn("GET"); - - boolean success = preAaiAjscInterceptor.allowOrReject(request, null, null); - - assertTrue("Expecting the post interceptor to return success regardless", success); - } - -}
\ No newline at end of file diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java index 9001f48..5988b43 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/GetCustomQueryConfigTest.java @@ -16,7 +16,7 @@ public class GetCustomQueryConfigTest { @Before public void setUp() throws Exception { System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); configJson = "{\n \"stored-queries\": [{\n" + diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java index 9ab7bc5..2acf5ec 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/ModelAndNamedQueryRestProviderTest.java @@ -89,7 +89,7 @@ public class ModelAndNamedQueryRestProviderTest { public void setup(){ logger.info("Starting the setup for the integration tests of Rest Endpoints"); System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); modelAndNamedQueryRestProvider = new ModelAndNamedQueryRestProvider(); httpHeaders = mock(HttpHeaders.class); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java index ae54449..25d91ce 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/QueryTest.java @@ -73,7 +73,7 @@ public abstract class QueryTest { public void setUp() throws AAIException, NoEdgeRuleFoundException { System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); MockitoAnnotations.initMocks(this); graph = TinkerGraph.open(); createGraph(); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java index bb04653..102bc2f 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SearchProviderTest.java @@ -85,7 +85,7 @@ public class SearchProviderTest { public void setup(){ logger.info("Starting the setup for the integration tests of Rest Endpoints"); System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); searchProvider = new SearchProvider(); httpHeaders = mock(HttpHeaders.class); diff --git a/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java index 17ddfc5..106bb44 100644 --- a/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java +++ b/aai-traversal/src/test/java/org/onap/aai/rest/search/SimpleFormatTest.java @@ -76,7 +76,7 @@ public class SimpleFormatTest { public void setUp() throws AAIException, NoEdgeRuleFoundException { System.setProperty("AJSC_HOME", "."); - System.setProperty("BUNDLECONFIG_DIR", "bundleconfig-local"); + System.setProperty("BUNDLECONFIG_DIR", "src/main/resources"); MockitoAnnotations.initMocks(this); graph = TinkerGraph.open(); loader = LoaderFactory.createLoaderForVersion(ModelType.MOXY, Version.v10); diff --git a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java b/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java deleted file mode 100644 index 3e323dd..0000000 --- a/aai-traversal/src/test/java/org/onap/aai/retiredcustomer/JaxrsUserServiceTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.onap.aai.retiredcustomer; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.aai.ajsc_aai.JaxrsUserService; -import org.onap.aai.introspection.Version; -import org.onap.aai.rest.retired.RetiredConsumer; - -import javax.ws.rs.core.*; -import java.util.*; - -import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.anyObject; -import static org.mockito.Mockito.when; - -public class JaxrsUserServiceTest { - - - protected static final MediaType APPLICATION_JSON = MediaType.valueOf("application/json"); - - private static final Set<Integer> VALID_HTTP_STATUS_CODES = new HashSet<>(); - - static { - VALID_HTTP_STATUS_CODES.add(200); - VALID_HTTP_STATUS_CODES.add(201); - VALID_HTTP_STATUS_CODES.add(204); - } - - protected JaxrsUserService jaxrsUserService; - protected HttpHeaders httpHeaders; - protected UriInfo uriInfo; - - private MultivaluedMap<String, String> headersMultiMap; - private MultivaluedMap<String, String> queryParameters; - - private List<String> aaiRequestContextList; - - private List<MediaType> outputMediaTypes; - - private static final EELFLogger logger = EELFManager.getInstance().getLogger(RetiredConsumer.class.getName()); - - @Before - public void setup(){ - logger.info("Starting the setup for the integration tests of Rest Endpoints"); - - jaxrsUserService = new JaxrsUserService(); - httpHeaders = Mockito.mock(HttpHeaders.class); - uriInfo = Mockito.mock(UriInfo.class); - - headersMultiMap = new MultivaluedHashMap<>(); - queryParameters = Mockito.spy(new MultivaluedHashMap<>()); - - headersMultiMap.add("X-FromAppId", "JUNIT"); - headersMultiMap.add("X-TransactionId", UUID.randomUUID().toString()); - headersMultiMap.add("Real-Time", "true"); - headersMultiMap.add("Accept", "application/json"); - headersMultiMap.add("aai-request-context", ""); - - outputMediaTypes = new ArrayList<>(); - outputMediaTypes.add(APPLICATION_JSON); - - aaiRequestContextList = new ArrayList<>(); - aaiRequestContextList.add(""); - - when(httpHeaders.getAcceptableMediaTypes()).thenReturn(outputMediaTypes); - when(httpHeaders.getRequestHeaders()).thenReturn(headersMultiMap); - - when(httpHeaders.getRequestHeader("aai-request-context")).thenReturn(aaiRequestContextList); - - - when(uriInfo.getQueryParameters()).thenReturn(queryParameters); - when(uriInfo.getQueryParameters(false)).thenReturn(queryParameters); - - // TODO - Check if this is valid since RemoveDME2QueryParameters seems to be very unreasonable - Mockito.doReturn(null).when(queryParameters).remove(anyObject()); - - when(httpHeaders.getMediaType()).thenReturn(APPLICATION_JSON); - } - @Test - public void lookUpUserTest(){ - when(uriInfo.getPath()).thenReturn("/user?userID1"); - String response = jaxrsUserService.lookupUser("userID1"); - assertNotNull(response); - - - } -} diff --git a/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java b/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java deleted file mode 100644 index 9573d1f..0000000 --- a/aai-traversal/src/test/java/org/onap/aai/util/AAIAppServletContextListenerTest.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * 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. - * ============LICENSE_END========================================================= - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - */ -package org.onap.aai.util; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.Logger; -import ch.qos.logback.classic.PatternLayout; -import ch.qos.logback.classic.spi.ILoggingEvent; -import ch.qos.logback.core.AppenderBase; -import org.apache.commons.lang.ObjectUtils; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.onap.aai.dbmap.AAIGraph; -import org.onap.aai.logging.ErrorLogHelper; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.agent.PowerMockAgent; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.slf4j.LoggerFactory; - -import javax.servlet.ServletContextEvent; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -@PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class}) -public class AAIAppServletContextListenerTest { - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - static { - PowerMockAgent.initializeIfNeeded(); - } - - private ServletContextEvent arg; - private AAIAppServletContextListener listener; - - /** - * Initialize. - */ - @Before - @PrepareForTest({AAIGraph.class, AAIConfig.class, ErrorLogHelper.class}) - public void initialize(){ - arg = PowerMockito.mock(ServletContextEvent.class); - PowerMockito.mockStatic(AAIGraph.class); - PowerMockito.mockStatic(AAIConfig.class); - PowerMockito.mockStatic(ErrorLogHelper.class); - - listener = new AAIAppServletContextListener(); - configureLog(); - } - - /** - * Test contextDestroyed. - */ - @Test(expected = NullPointerException.class) - @Ignore - public void testContextDestroyed(){ - listener.contextDestroyed(arg); - assertTrue(logContains(Level.DEBUG, "AAI Server shutdown")); - assertTrue(logContains(Level.INFO, "AAI graph shutdown")); - } - - /** - * Test contextInitialized. - */ - @Test - //@Ignore - public void testContextInitialized(){ - listener.contextInitialized(arg); - assertFalse(logContains(Level.DEBUG, "Loading aaiconfig.properties")); - assertFalse(logContains(Level.DEBUG, "Loading error.properties")); - assertFalse(logContains(Level.DEBUG, "Loading graph database")); - assertFalse(logContains(Level.INFO, "AAI Server initialization")); - } - - - /** - * Helper method to check if a String appears in the desired log level. - * - * @param level Log level to use - * @param expected String to search for - * @return True if search String is found, false otherwise - */ - private boolean logContains(Level level, String expected) { - String actual[] = RecordingAppender.messages(); - for (String log : actual) { - if (log.contains(level.toString()) && log.contains(expected)) - return true; - } - return false; - } - - /** - * Set logging level, and initialize log-appender. - */ - private void configureLog() { - org.slf4j.Logger rootLogger = LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); - rootLogger.debug("debug"); - // rootLogger.(); - // rootLogger.addAppender(RecordingAppender.appender(new PatternLayout())); - } - -} - - -/** - * Appender class that appends log messages to a String List when some logging event occurs - */ -class RecordingAppender extends AppenderBase<ILoggingEvent> { - private static List<String> messages = new ArrayList<String>(); - private static RecordingAppender appender = new RecordingAppender(); - private PatternLayout patternLayout; - - private RecordingAppender() { - super(); - } - - /** - * @param patternLayout Pattern to format log message - * @return Current appender - */ - public static RecordingAppender appender(PatternLayout patternLayout) { - appender.patternLayout = patternLayout; - appender.clear(); - return appender; - } - - @Override - protected void append(ILoggingEvent event) { - messages.add(patternLayout.doLayout(event)); - } - - public void close() {} - - public boolean requiresLayout() { - return false; - } - - /** - * @return Return logs as a String array - */ - public static String[] messages() { - return (String[]) messages.toArray(new String[messages.size()]); - } - - /** - * Clear the message container - */ - private void clear() { - messages.clear(); - } - -} |