My Note on Solutions.

Thursday, May 1, 2014

Sublime Text Tips, Emmet, Proxy

If you want to install a package through the console and you are behind the firewall. you can run the code in console 1st to setup the proxy.

urllib.request.ProxyHandler({"http":"http://[proxy_user]:[proxy_password]@[proxy_IP]:[proxy_port]"} )

image


there is another plugin called emmet, which is a must have tool for web developers.
install it,
image
in your html page, just type html then tab, you will see the boilerplate code,
image


in the body, If you type .container>ul>li.content*5>a[href='#']{item $}    
image

to show a route layout by typing “#content>h1.header>^panel.body>^footer”
image


if you want to put some contens in the body, type “lorem”

image



then tab



image

Friday, April 25, 2014

How To: Test Activemq 5.9.1 Master/Slave by replicatedLevelDB/Zookeeper

Start from 5.9, Activemq comes with another HA option called ReplicatedLevelDB. I would recommend start from 5.9.1 at least, and I found a lot bugs in the 5.9.
  basic idea, Zookeeper as the central coordination point, every broker talked to the Zk , ZK wills tell the member information like who is the master. slave talks to master node to fetch the incremental change when it come online.
 
for the configuration, each member in a cluster share the same broker name, zookeepeer address, and zkPass.

image

and transportconnector is transparent to the underlining persistence layer.

image

when you startup the broker, for the 1st one, since we setup the replica to 2,that means we have to start at least 2 brokers to meet the quota requirement.
 image

after 2 broker ready, you can see it’s a slave node,
image

for the 1st ndoe, which is the master node, will turn on the transportconnector that is openwire here,
image

3rd one will be a slave node too.
image

Thursday, April 24, 2014

How To: test Activemq using Maven plugins

ActiveMQ has two useful Maven plugins which enable you to test different Activemq deployment layout and Performace (Producer/Consumer) quickly. the plugins have been renamed since 5.7, and this demo is based on latest version 5.9.

Demo: Setup one standard broker quickly.

Create one maven eclipse project, and add the plugin dependency called activemq-maven-plugin to the POM file.
image

Now the pom.xml looks like this

image

for this plugin , we will add configuration later on this plugin, like the Activem.xml config, etc.
now by default, we can run the plugin on the command

image

then A simple queue broker is there, and by default using the openwire transport and memoryPersistenceAdapter.

image

TO Change the configuration, we can customize the plugin.
we setup the persistent=true and use 8888 as the openwire port.
image

Run Again,
image

if we want to change it to levelDB or more customized setting,
image

 

For the producer, you can setup another plugin, here I setup two profile, one for producer and another one is for consumer

image

the for producer, you can add different settings by passed –D to the command,
image

and consumer,
image

to start another consumer , change the prefix , otherwise, they want get any message, since they use the same consumerid

image

after done, you should see some test results, like

image

Tuesday, March 25, 2014

SoapUI, Groovy Script tutorial

Groovy is built on JVM, so does the SoapUI, it’s no surprise that SoapUI offers the Groovy script support by default. Let’s do a simple test, basically send out a Http request with dynamic parameters, and parse the result using the regular expression capability of Groovy and IO capablity to save the result back to a file. for the parameter we can use the groorvy to poll a file and return some randomized keywords.

so the keywords file looks like
image

we create one project with one test suite, then under the suite, we can add test case, and for the test step, let’s add first step called GetKeyword as a groovy script.


image

then we put some script here, which will assign a keyword property to the context randomly.
image

then we can access this keyword using context.keyword in next step, now, let’s create a http request to bing.com

image

Click extract params,now if we run this test

image

the query keyword is hardcoded, we can replace it with a groovy expression

image

then add the 3rd step, that we read the response in step 2 and save it to a file

image

if we run the test case, you will see file named keyword.txt with the http response from bing.com search

also you can just copy and save the following xml as a project file, you open in in SoapUI

<?xml version="1.0" encoding="UTF-8"?>
<con:soapui-project activeEnvironment="Default" name="tst" soapui-version="4.6.4" xmlns:con="http://eviware.com/soapui/config"><con:settings/><con:testSuite name="testgroovy"><con:settings/><con:runType>SEQUENTIAL</con:runType><con:testCase failOnError="true" failTestCaseOnErrors="true" keepSession="false" maxResults="0" name="TestCase 1" searchProperties="true" id="cdd185b8-b6ae-4455-9713-ec70b5404569"><con:settings/><con:testStep type="groovy" name="GetKeyword"><con:settings/><con:config><script>def file=new File("c:\\a.txt")
def lines=file.readLines();
def randomindex=new Random()
def keyword=lines[randomindex.nextInt(lines.size())];
context.keyword=keyword
log.info(keyword)</script></con:config></con:testStep><con:testStep type="httprequest" name="Req2Bing"><con:settings/><con:config method="GET" xsi:type="con:HttpRequest" name="Req2Bing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><con:settings><con:setting id="com.eviware.soapui.impl.wsdl.WsdlRequest@request-headers">&lt;xml-fragment/></con:setting></con:settings><con:endpoint>http://www.bing.com/search</con:endpoint><con:request/><con:credentials><con:authType>Global HTTP Settings</con:authType></con:credentials><con:jmsConfig JMSDeliveryMode="PERSISTENT"/><con:jmsPropertyConfig/><con:parameters><con:parameter><con:name>q</con:name><con:value>${=context.keyword}</con:value><con:style>QUERY</con:style><con:default>androidyou</con:default><con:path xsi:nil="true"/><con:description xsi:nil="true"/></con:parameter></con:parameters></con:config></con:testStep><con:testStep type="groovy" name="SaveitToFile"><con:settings/><con:config><script>def resp=testRunner.getTestCase().getTestStepByName("Req2Bing").httpRequest.response
def raw=resp.getContentAsString()
//save it fo file
def resultFile=new File("c:\\" + context.keyword + "t.txt")
resultFile.write(raw);</script></con:config></con:testStep><con:properties/></con:testCase><con:properties/></con:testSuite><con:properties/><con:wssContainer/></con:soapui-project>

Monday, March 24, 2014

WMIC Tips, Export format and get hint about callable Actions

On windows , you can use wmic to list all process running by type process in the wmic console.
image

Also you can run some filter, like listing all  notepad.exe
procecss where name=”notepad.exe” list brief

image

if we don’t know which field are available to get for this Process object, try get /?

image

so we can call process where name=”notepad.exe” get commandline, name, processid

image

if we want to kill those processes, we can call call /? to see available actions

image

So we can call terninate method to kill all notepad.exe

image

then all process are gone,

we can do this same thing on service,

image

to export all the service you can run wmic /output:file  service where state=”running” /format:htable

image

image

Thursday, March 13, 2014

Apache Archiva, yet another simple Maven repository in your enterprise

Before I got a chance to play Archiva, I’ve always used the Nexus as the my maven repository across different machines. Now it turns out the Archiva is very easy to use and pretty powerful for most features I used in Nexus.
  Apache archiva is s standard jsp application, we can hosted in any container or just run as standalone,
image

the major usage of Archiva for me is to use it as a central repository to store all my artifacts. Basically when you are done with your project, run a “maven deploy” it will deploy it to your central repository, then across the computers you work, you can find those jars both on runtime or compile time. 

To do that, we need config a setting on the ~/.m2/settings.xml, put the server credentials there , and one your project pom file, put the repository as one of the distributionManagement subnode.

on the settings.xml,
add my own repositories that are proxyed and cached to remote,
image

then on the client pom.xml. just add the repository to the distributionmgmt

image

then once we run the mvn deploy, it will be deployed to the centorl internal repo.

Monday, March 10, 2014

Apache Camel tutorial : Quick start from scratch (Console App using Xml as the routes definition , without Spring)

Following the last post Apache Camel tutorial : Quick start from scratch (Console App , without Spring), if you don’t want to hard code the routes, we can simply use xml as keep the routes definition.

to do that , let’s change the code a little bit.

image

then in the route.xml, add the route definition there,
image

when run, you see the similar results,

image

for this code, check the branch demoxml

https://github.com/ryandh/apacheCamelTutorial/tree/demoxml

 
Locations of visitors to this page