how to test xqueries manually where elements >200? - xquery

currently i am working on one of the service where consumer can send 250 elements in request and i need to do the mapping for all inbound elements using xquery transformation.
Can someone let me know if there is any optimal way or any tool to test the mapping of 250 elements in one go ?
thanks in advance.

This is what I use.
https://github.com/TrentBartlem/osbutils/tree/master/XQTestFramework
I put the jar into my maven repo (along with various OSB/weblogic jars), then write JUnit test cases. Doesn't even need an OSB server running.

Related

How to fetch data of a a vertex or an edge from JanusGraph using its Java driver?

I'm connecting to a remote JanusGraph server. There is no problem with the connection but I can't understand the Java API.
I'm running a Java Spring HTTP server. Inside the HTTP response method, I'm creating a graph traversal source like
GraphTraversalSource g = traversal().withRemote("conf/remote-graph.properties");
It seems fine. But When I want to get data about a Vertex I can not with the below code.
g.V(28712).next().keys()
IT GIVES AN EMPTY RESPONSE! WHY?
If I do the same with gremlin shell, I see it. See the below picture
If I do g.V(28712).valueMap(true).unfold().toList(); in Java, I see some results.
I just want to fetch data for a vertex or edge with Java. How should I do that?
thanks
By default, when you connect to a Gremlin Server using one of the Gremlin clients and you ask for a vertex, what you get back is a reference vertex. A reference vertex just contains the ID and the label. To get some properties you need to include them using valueMap, elementMap, project etc. Alternatively you can configure the Gremlin Server to return all properties. The default is set this way to reduce the amount of data that gets sent back to a client.
Please see the documentation for further details.
https://tinkerpop.apache.org/docs/current/reference/#gremlin-applications
https://tinkerpop.apache.org/docs/current/reference/#_properties_of_elements
There is a link in that documentation to a post about why the decisions were made. For convenience, I am including that link here as well.
https://lists.apache.org/thread.html/e959e85d4f8b3d46d281f2742a6e574c7d27c54bfc52f802f7c04af3%40%3Cdev.tinkerpop.apache.org%3E

How to integrate gRPC with karate [duplicate]

We have a requirement where we need to send .avro file as an input request to our API's. Really stuck at this point. If any detail example provided would be more appreciated.
Just use Java interop: https://github.com/intuit/karate#calling-java
You need to write a helper (start with a static method) to convert JSON to Avro and vice versa. I know teams using this for gRPC. Read this thread for tips: https://github.com/intuit/karate/issues/412
Also there is even a "karate-grpc" project: https://github.com/pecker-io/karate-grpc
Also see:
https://twitter.com/KarateDSL/status/1128170638223364097
https://twitter.com/KarateDSL/status/1417023536082812935

How to define custom step in Tinkerpop 3?

Tinkerpop 2 used to support user-defined step through Gremlin.defineStep(..)
How can I achieve the same using Tinkerpop 3 ?
Is there any Gremlin API to create a custom step and combine a set of traversal steps ?
Any suggestion will be highly appreciated.
Thanks
Kaniska
Patterns for DSL development are not completely established for TinkerPop 3.x, so expect some changes in advice as time progresses. There is surrounding information on this on the gremlin-users mailing list.
If you are using Gremlin Server (or can incorporate Groovy into your project) I don't see a reason to not just do some groovy metaprogramming to get this to work. Using the standard Gremlin Server zip distribution edit the generate-modern.groovy file to include this line at the start:
GraphTraversal.metaClass.knows = { delegate.out('knows') }
then start the server with:
bin/gremlin-server.sh conf/gremlin-server-rest-modern.yaml
Then a simple curl:
$ curl "http://localhost:8182?gremlin=g.V(1).knows().values('name')"
{"requestId":"66c2c929-9cc2-491d-acb0-ae4d7eef6b00","status":{"message":"","code":200,"attributes":{}},"result":{"data":["vadas","josh"],"meta":{}}}
If you have a complex DSL you might not want all that logic trapped in a groovy script. Easy enough - just build a standard groovy project, construct a jar, include some form of static initializer to call your metaprogramming code and place it on Gremlin Server's path. then your init script just needs to call that static initializer and your DSL is loaded.

which s best way to test the database packages?

I am currently working on a project where we need to test the database packages and functions.
We need to provide the input parameters to the database package and test the packages returns the expected value, also we want to test the response time of the request.
Please advice, if there is any tool available to perform this or we can write our test cases in Junit or some other framework.
Which one will be best approach?
I've used a more native approach when I had to do DWH testing. I've arranged the Test framework around the Dev data integration framework that was already in place. So i had a lot of reusable jobs, configurations and code. But using OOP like you suggest
write our test cases in Junit
is a way to go too. But keep in mind that very often the DWH design is very complex (with a lot of aspects to consider) and interacting with the Persistence layer is not always the best candidate for testing strategy. A more DB oriented solution (like tSQLt) offers a significant performance.
Those resources helped me a lot:
dwh_testing
data-warehouse-testing
what-is-a-data-warehouse-and-how-do-i-test-it
My framework Acolyte provides a JDBC driver & tools, designed for such purposes (mock up, testing, ...): http://tour.acolyte.eu.org
It's used already in some open source projects (Anorm, Youtube Vitess, ...), either in vanilla Java, or using its Scala DSL.
handler = handleStatement.withQueryDetection(...).
withQueryHandler(/* which result for which query */).
withUpdateHandler(/* which result for which update */).
// Register prepared handler with expected ID 'my-unique-id'
acolyte.Driver.register("my-unique-id", handler);
// then ...
Connection con = DriverManager.getConnection(jdbcUrl);
// ... Connection |con| is managed through |handler|

Access file system through query string or params

I have been given a task of reproducing the issue/testing the unauthorized access to file system through request.param and query string.
For instance i have something like this. request.querystring("blah");
How could somebody pass "../../../b1/b2" in the query string and access file system.
This may be related to cross site scripting.
Need help..at least provide resources. Thanks in advance.
Wish I could provide a definitive answer, but can at least steer you in some direction. Not sure how confident you are that request.querystring() was indeed responsible, but some possibilities are:
Directory Traversal/Path Traversal:
Overview: http://en.wikipedia.org/wiki/Directory_traversal
Testing For: http://www.owasp.org/index.php/Testing_for_Path_Traversal
Remote File Inclusion:
Overview: http://en.wikipedia.org/wiki/Remote_file_inclusion
Tutorial: http://www.offensivecomputing.net/?q=node/624 (KnightLighter's Tutorial)
Hope this moves you in the right direction.

Resources