Local Testing of Couchbase Views - couchbase

I am developing Couchbase views and using the console is limiting because the output lines are truncated and JavaScript errors are not displayed. Is there a convenient way to test views locally with an engine like Node.js?
Thanks!

What about couchnode?
https://github.com/couchbase/couchnode
https://github.com/couchbase/couchnode/blob/master/tests/08-views.js
Also since basically view query is HTTP request you can use any Web/HTTP/REST client or library for debugging. But apparently official SDK seems to be more convenient way.

Also,
If you use the couchbase mock() function with the nodejs SDK, when you do your unit tests, the errors and console.log() inside your views are displayed.

Related

Server side data fetching

I'm trying to set up a basic component that is rendered on the server and the client. The component is populated with data from a JSON API. I've got this working on the client-side by loading my data in componentDidMount and calling this.setState when it has loaded.
The problem I have is that the data isn't loaded on the server. How do I get the initial data into the server-rendered version of my component?
https://github.com/rackt/react-router/blob/latest/docs/guides/advanced/ServerRendering.md is very vague about this:
For data loading, you can use the renderProps argument to build
whatever convention you want--like adding static load methods to your
route components, or putting data loading functions on the
routes--it's up to you.
Do you have an example anywhere of how to do this? It seems like a very basic thing for a universal application to want to do!
Yup - we have https://github.com/rackt/async-props that provides a library for dealing with async data between server and client, and provides an example for doing so. If you're using a Flux framework, you'll want to make appropriate adjustments, but the basic approach will be quite similar.

How to use JSON API without document

This might be a weird question but I am open for all the suggestions.
The background is I want to use script to automatically deploy/remove docker container on Jelastic, but unfortunately this part is not well documented in Jelastic official API document. Jelastic provided me a piece of sample code demonstrated how to use bash to create a new environment with a new docker container but it is not enough, I still don't know how to create/remove docker container by looking at the sample code.
Since Jelastic is using standard JSON API, I am wondering is there any tool which can automatically retrieve/detect that the parameters I can use with Jelastic JSON API?
If you were me, how would you get over this if there is no document as reference?
I am keen to use Jelastic, but this issue stopped me from onboarding, many thanks.
J.
All the parameters that can be used with Jelastic JSON API are specified at http://docs.jelastic.com/api/ page.
To use JSON API without document I suggests to you check the Postman API tool https://www.getpostman.com/. This application allows you to see all the sent/received data and allows you to passes JSON values without any document or any additional actions.
Simplest scenario for beginners: Go to API docs, section Users>Authorization, using Signin method you should to obtain the session value, that is necessary almost for all further actions. Then you need to obtain information about environment, section Environment>Environment, at first you should to executes GetEnvs method, then using the application identifier of the environment that was obtained from the previous command you should to executes GetEnvInfo method. As a results of the described scenario you will get all parameters and values that can be used with Jelastic JSON API for certain type of the environment.

Mock a web server for ajax in IntelliJ environment

IntelliJ can deploy HTML/JS code at localhost:63342 on the fly. I can see how the frontend behaves immediately.
Now I have a web application.
http://localhost:8080/frontend
http://localhost:8080/backend
The frontend will fetch data from its backend. Now I cannot start a real backend at localhost:63342. How can mock some ajax response at localhost:63342. Is there any magic plugin of IntelliJ can help?
My current solution is put all ajax call in an Angular service module and replace it with a mocked service module. I believe there must be some better solutions.
If you want to mock up some endpoints for you to test with I would suggest you use Mockjax. This will allow you to do exactly what you want and you won't have to run two separate apps to do so. I'm not familiar with IntelliJ, but Mockjax only has a dependency on jQuery and you should be able to easily set it up with any project that at least uses jQuery.

Creating WSO2 BPEL project for JSON webservices

I have the WSO2 Developer Studio Eclipse Plugin downloaded. And I was looking at this tutorial: http://wso2.com/library/tutorials/2010/07/eclipse-bpel-designer-wso2bps-tutorial/. But it seems to be talking about using SOAP. But my webservices, which are written in PHP(in live servers) are REST using JSON. Accepts data via HTTP GET methods by these webservices and respond back with JSON data.
So how will I implement a BPEL project making use of the JSON webservices? Any ideas or suggestion? Am completely new to this. Thank you.
EDIT
When I created the BPEL Process, I have used HTTP from the dropdown instead of SOAP
WSO2 uses a custom variant of the Apache ODE engine for executing BPEL processes. ODE provides extensions for REST, which you can try out. However, I am not sure if these extensions also support JSON or if they just allow XML data. Also have a look at this answer.

Executing JSON in Selenium

I need to know the easiest way to execute JSON in a selenium test. An example would be i want to POST { "UserId":"234234" } and test against what is returned. Currently using Advanced REST client chrome app to manually test. I've done a lot of searching on this topic but haven't come across any good examples.
This doesn't sound like it's best solved by selenium. With Selenium you would interact with the form to get that value to post, and handle the subsequent AJAX response / page refresh. If you wish to POST data you should look at a library that performs those types of operations across the wire.
If you are looking for a HTTP library, then Apache has a good one (Java based).