aboutsummaryrefslogtreecommitdiffstats
path: root/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/http/server/test/HttpServerTest.java
AgeCommit message (Collapse)AuthorFilesLines
2024-02-07Remove Dmaap references from policy-commonrameshiyer271-8/+13
- updated dependencies for jakarta.* compabilities - other dependency updates for security fixes Issue-ID: POLICY-4881 Change-Id: I979d944fcd21279f618d1bcbfe12e914ba30077f Signed-off-by: rameshiyer27 <ramesh.murugan.iyer@est.tech>
2023-09-21Java 17 Upgradeadheli.tavares1-9/+4
Issue-ID: POLICY-4668 Change-Id: If4e79224de61d66d7514f3abbd7b8bee1c3d5681 Signed-off-by: adheli.tavares <adheli.tavares@est.tech>
2023-03-14Upgrade Jetty and Jerseyliamfallon1-5/+6
The new version of Jetty and Jersey brings in Server Name Checking, which must be eiter enabled or disabled. Also, the bug in Swagger that drags in JUnit 5 with a non "test" scope is worked around by excluding the junit 5 dependencies. Issue-ID: POLICY-4474 Change-Id: Ib5ba23616c8d3cb011c5055a49c9cb325c9fd667 Signed-off-by: liamfallon <liam.fallon@est.tech>
2021-08-18Integrating prometheus with Policy componentsa.sreekumar1-0/+78
With this change, all PF components can export prometheus metrics by default. The prometheus metrics servlet will be running on /metrics servletPath.. If the metrics shouldn't be exported, just add a flag "promethus": false in the restServerParameters of default configuration file. This brings up prometheus servlet on /metrics servletPath. Also as part of standard servlet support, "servletUriPath" and "servletClass" are 2 other fields added to RestServerParameters which can be used to add standard servlets. This can be revisited later if needed. Basically, any servlet can be added by passing these fields, for example, to add prometheus metrics servlet on /test/metrics, add the below to restServerParameters: "servletUriPath": "/test/metrics", "servletClass": "io.prometheus.client.exporter.MetricsServlet" In addition, we can later go to individual components and add more metrics, say for e.g., deployedPoliciesCounter/undeployedPoliciesCounter etc on PAP, executedEvents/failedEvents etc on PDP and so on. This will look something like below, for e.g. in policy-pap component: io.prometheus.client.Counter counter = Counter.build() .name("policies_deployed_total") .help("Number of policies deployed.").register() Whenever a policy is deployed, just call counter.inc() Usage of code like above in the individual component will expose such data as well as part of the exposed metrics. Change-Id: Id667f27b15c012398421ba657b5324cc1d82cf1f Issue-ID: POLICY-3524 Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca> Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Signed-off-by: a.sreekumar <ajith.sreekumar@bell.ca>
2020-07-20Remove jackson from policy-commonJim Hahn1-49/+0
Issue-ID: POLICY-1528 Change-Id: Ic4b9314a770e53cefb93776bfede35591363690e Signed-off-by: Jim Hahn <jrh3@att.com>
2020-06-25Merge "Fix deprecated method in policy-common"Pamela Dragosh1-2/+3
2020-06-25Fix Junit failed after AAF version change 2.1.21Utkarsh Jauhari1-0/+7
Issue-ID: POLICY-2623 Signed-off-by: Utkarsh Jauhari <uj426b@att.com> Change-Id: I86c5b6efac8f62dd0d4ba576d8ec49cfa63a58bb
2020-06-24Fix deprecated method in policy-commonJim Hahn1-2/+3
Probably due to a jar update, some methods are now deprecated. Fixed them. Issue-ID: POLICY-2650 Change-Id: I48aabd4552faaf88671dfbe6556dc739a8c94809 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-06-18Changes for checkstyle 8.32liamfallon1-1/+1
Issue-ID: POLICY-2188 Change-Id: I00843c61a6567001fc35c3ebb77b6843a1eb7da2 Signed-off-by: liamfallon <liam.fallon@est.tech>
2020-06-17Cleanup various sonar issues in policy-commonJim Hahn1-7/+7
Addressed the following issues: - unused imports - unused method parameters - use assertEquals, assertSame instead of assertTrue - provide the parametrized type for this generic Also fixed some checkstyle issues: - removed blank lines between "import" groups Issue-ID: POLICY-2650 Change-Id: I004bb650ac10c49ccd0fc405f6959896fec39f9b Signed-off-by: Jim Hahn <jrh3@att.com>
2020-04-06Address sonar issues in commonJim Hahn1-2/+3
Addressed the following sonar issues: - missing assertion in junit test case - disable sonars about setAccessible() as it's required for jackson emulation - sleep in junit - don't use wild-cards (e.g., "*") with java.util Pattern - use re2j instead of java.util Pattern - use String methods (e.g., startsWith()) - duplicate method bodies - duplicate code in Coder classes - string concatenation in logger calls - UTF-8 encoding - return primitive instead of boxed primitive - add assertion to tests - renamed support methods from doTestXxx to verifyXxx - cognitive complexity - use AtomicRef instead of volatile - use specific Functionals (e.g., IntConsumer) - function always returns the same value - serializable vs transient Issue-ID: POLICY-2305 Change-Id: I08eb7aa495a80bdc1d26827ba17a7946c83b9828 Signed-off-by: Jim Hahn <jrh3@att.com>
2020-03-02Add JettyStaticResourceServer to policy-endpointsHengye1-0/+101
Using DefaultServlet to manage static resources on Jetty Server. Issue-ID: POLICY-2311 Signed-off-by: Hengye <yehui.wang@est.tech> Change-Id: Ife0eda06334eb0b6350110254945975050181f20
2020-02-24Fixes to support dependency upgradePamela Dragosh1-2/+2
Uped the time for Thread.sleep due to new http core dependency. It seems to randomly timeout inconsistently due to that upgrade. Google gson seems to have changed its layout. Did not see any problems with the other repos. Issue-ID: POLICY-2381 Change-Id: Id2a9bfffd42a2c713af042bd2a8cc4abafba2d9f Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2019-09-16Eliminate constructors with side-effectsJim Hahn1-0/+1
Several of the Gson and Jackson handlers take a GsonBuilder, which they then configure with additional adapters prior to create a Gson object that they subsequently use. The code has been modified so that the constructors no longer take a GsonBuilder, thus eliminating the side-effects that they had on the builders. Instead, a configBuilder() method has been added to the handler classes that makes it clear tht they modify the GsonBuilder. This also has the advantage that classes that want a Gson object configured per a given handler need only call that handler's configBuilder() method; previously, they had to constructor the handler and then retrieve its gson object. Also updated a few tests to specify the HTTP "Accept" header to ensure that return results are in yaml format. Change-Id: I2ef98198041ff9f73913d01ee6ee14ecf20ba617 Issue-ID: POLICY-2081 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-13Extract YamlJsonTranslator from StandardYamlCoderJim Hahn1-1/+2
Refactored StandardYamlCoder, extracting a new class, YamlJsonTranslator, from it. This facilitates performing yaml translation when not using a standard "gson" coder. Added YamlJacksonHandler which supports YAML translation layered on top of a JacksonHandler instead of a GsonMessageBodyHandler. Also added junit tests to complete coverage of StandardCoder. Also added public APPLICATION_YAML to YamlMessageBodyHandler. Change-Id: Ia470fa194661fbf1aebeaf0f18b57f2a984cb64b Issue-ID: POLICY-2081 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-09-11Create StandardYamlCoderJim Hahn1-17/+94
Created StandardYamlCoder which is like a StandardCoder, except that the original converts to/from JSON, while the new class converts to/from YAML. Also added YamlMessageBodyHandler and incorporated it into the http server so that it supports a media type of */yaml. Change-Id: Ibd83a9f6d355a330f63e435f2bb41affcf1947c2 Issue-ID: POLICY-2065 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-07-05Fix sonar issues in policy/endpointsJim Hahn1-41/+55
Sonar fixes, other than code coverage. These changes are disruptive and will likely cause breakage in a number of policy repos. Renamed constants. Moved constants/factories from interfaces to classes. Change-Id: I182d50320aa6b53e383081af806c60dd2f806cbe Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-26Fix some sonar issues in policy-endpointsJim Hahn1-15/+8
Refactored various classes to reduce cyclomatic complexity. Introduced some endpoint utility classes to facilitate extraction and conversion of property values, and populating of common "builder" values. Change-Id: Ie1c91cd94cb54700dc9127f72780b4d94b82ec39 Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-14Change getCanonicalName() to getName() in commonJim Hahn1-18/+18
Per javadocs, getName() should generally be used instead of Class.getCanonicalName(). This change only applies to classes; it does not apply to File objects. Change-Id: Iea0995d1167f4837607f194d35f0193eeedeacd7 Issue-ID: POLICY-1646 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-13More sonar fixes in policy/commonJim Hahn1-61/+33
Note: this does not increase code coverage, but should fix other code issues. Resolved cyclomatic complexity issue in ParameterValidationResult. Refactored duplicate code in GroupValidationResult. Removed IOException from NetworkUtil "throws". Replaced null/empty string tests with StringUtils.isBlank(). Added @FunctionalInterface where needed. Replaced anonymous classes with lambda expressions. Replaced duplicate strings with a constant. Added private constructors for utility classes. Removed sleep() from tests. Removed unused parameter from method call. Made some protected methods private. Compute integrity monitor's state-transition table once. Use for-loop instead of iterator. Moved constructors. Fixed some checkstyle issues (tabs => spaces, trailing spaces). Change-Id: I9a962ca45c4ff3f212c6014da799d06f07b232ef Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-06-12Apply simple sonar fixesJim Hahn1-49/+55
Note: A number of these were identified, by SonarLint, in the Test classes, which are not typically scanned by Sonar. Removed unnecessary imports. Removed unneeded "throws Xxx". Replaced lambda with method references. Replaced duplicate strings with constants. Replaced try-fail-catch with assert-j methods to eliminate sonar complaints about duplicate failure messages. Added missing @Override annotations. Use map.computeIfAbsent() where appropriate. Also fixed some minor checkstyle issues. Removed unneeded "volatile" declarations. Replaced some if-else constructs with "?:" construct, per sonar. Replaced Object.wait() with CountDownLatch.await(); according to sonar (and javadocs), Object.wait() can return due to "spurious wakeups". Fixed issue whereby CryptoUtilsTest wouldn't run in my Eclipse. Change-Id: Ib6b71ed65662cfd6209400dac57ed69279bf29ec Issue-ID: POLICY-1791 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-02-13Add gson handler and testsJim Hahn1-0/+11
Added JacksonHandler which provides jackson behavior in gson. Also added classes to facilitate testing of gson serializations. Added compareGson(xxx, Class). Removed trailing spaces from some files. Updated license dates. Replaced incorrect constant with ${xxx} in json test file. Fixed typo in test method name. Change-Id: If05b654d76a4ffc88646f03334be82b32506f28f Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2019-01-23Add gson support to policy-endpointsJim Hahn1-43/+264
Added "provider" property to both http client and server builders. The provider defaults to jackson, to maintain backward compatibility until other policy code has been converted to gson. Removed commented item from pom. Added some comments and re-arranged a few pieces of code. Fixed a few typos and removed spacing at the end of some lines. Reordered imports. Added comments about limitations when using jersey-media-json-jackson. Address ridiculous checkstyle complaint. Support comma-separated list of serialization providers in jersey client. Disabled metainf discovery from jersey client and server so that the media-json dependencies could be re-instated in the pom. Address another ridiculous checkstyle complaint. Change-Id: Ic5a93b475d0ee9b435352b3516de6b865b00a86a Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn <jrh3@att.com>
2018-10-26Detection of AAF enablement3.0.0-ONAPJorge Hernandez1-0/+5
Change-Id: I049e88bec2c83f6224ba1d1f24b93e0fb1aa807e Issue-ID: POLICY-1216 Signed-off-by: Jorge Hernandez <jorge.hernandez-herrero@att.com>
2018-08-15Fix checkstyle comments etc.Pamela Dragosh1-3/+3
Adding javadoc comments, renaming variables names, fixed whitespace and 120 length. Also some variables were made final since they were declared further from usage. Splitting out Asserts. Still remaining are the abbreviations. Issue-ID: POLICY-881 Change-Id: I31ce5a9eea02578bce023c0c607a19108bb726fa Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-08-13Remove simple checkstylePamela Dragosh1-9/+10
Mostly concentrated on the period at the end of summary. But I did clear a few others for longer than 120 characters and placement of methods next to each other. Possibly a few others. I did not clear everything, but will submit a few more reviews to get the others. Issue-ID: POLICY-881 Change-Id: I692a5349d686d52fee4040757cdc2ed8b5cc221b Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
2018-08-08generic jetty filter and cadi supportJorge Hernandez1-0/+5
Change-Id: I363e44e85e1d89c6254218629010d5c3e1507e0a Issue-ID: POLICY-1043 Signed-off-by: Jorge Hernandez <jh1730@att.com>
2018-08-03generic jetty https server supportJorge Hernandez1-3/+3
jetty https support in constructor, or by using ".https" when creating an http server service. Change-Id: I94e8e3e4b93eb6b194657028c740b6781316c7da Issue-ID: POLICY-940 Signed-off-by: Jorge Hernandez <jh1730@att.com>
2018-07-31Copy policy-endpoints from drools-pdp to commonmmis1-39/+35
Removed changes made in commit b40acf2d244058c162a8597968e59f2708e6abf4 that went beyond the scope of POLICY-967 Issue-ID: POLICY-967 Change-Id: Ibbf78540dec8bf8601a62dacc8c7056d43f70ba1 Signed-off-by: mmis <michael.morris@ericsson.com>
2018-07-25Copy policy-endpoints from drools-pdp to commonmmis1-0/+227
Issue-ID: POLICY-967 Change-Id: I374c155ee102c3e157c60d0a22d7191544abb76a Signed-off-by: mmis <michael.morris@ericsson.com>