Skip to content
This repository has been archived by the owner on Jan 1, 2019. It is now read-only.

Commit

Permalink
add test Case for Trace Connect and Patch
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerqiu712 committed Aug 2, 2017
1 parent da87d16 commit 44681d6
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.parallec.core.main.http;

import java.util.Map;

import io.parallec.core.ParallecResponseHandler;
import io.parallec.core.ParallelClient;
import io.parallec.core.ParallelTask;
import io.parallec.core.TestBase;
import io.parallec.core.ResponseOnSingleTask;
import io.parallec.core.util.PcStringUtils;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class ParallelClientHttpConnectTest extends TestBase{
private static ParallelClient pc;

@BeforeClass
public static void setUp() throws Exception {
pc = new ParallelClient();
}

@AfterClass
public static void shutdown() throws Exception {
pc.releaseExternalResources();
}
@Test
public void hitConnectTest() {

ParallelTask pt = pc
.prepareHttpConnect("")
.setConcurrency(1000)
.setSaveResponseToTask(true)
.setTargetHostsFromLineByLineText(FILEPATH_TOP_100,
SOURCE_LOCAL).execute(new ParallecResponseHandler() {

@Override
public void onCompleted(ResponseOnSingleTask res,
Map<String, Object> responseContext) {
logger.info("Responose Code:" + res.getStatusCode()
+ " host: " + res.getHost()+ " Reponse Content: " +res.getResponseContent());
}
});
logger.info("Result Summary\n{}",
PcStringUtils.renderJson(pt.getAggregateResultFullSummary()));

pt.saveLogToLocal();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.parallec.core.main.http;

import java.util.Map;

import io.parallec.core.ParallecResponseHandler;
import io.parallec.core.ParallelClient;
import io.parallec.core.ParallelTask;
import io.parallec.core.TestBase;
import io.parallec.core.ResponseOnSingleTask;
import io.parallec.core.util.PcStringUtils;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class ParallelClientHttpPatchTest extends TestBase{
private static ParallelClient pc;

@BeforeClass
public static void setUp() throws Exception {
pc = new ParallelClient();
}

@AfterClass
public static void shutdown() throws Exception {
pc.releaseExternalResources();
}
@Test
public void hitPatchTest() {

ParallelTask pt = pc
.prepareHttpPatch("")
.setConcurrency(1000)
.setSaveResponseToTask(true)
.setTargetHostsFromLineByLineText(FILEPATH_TOP_100,
SOURCE_LOCAL).execute(new ParallecResponseHandler() {

@Override
public void onCompleted(ResponseOnSingleTask res,
Map<String, Object> responseContext) {
logger.info("Responose Code:" + res.getStatusCode()
+ " host: " + res.getHost()+ " Reponse Content: " +res.getResponseContent());
}
});
logger.info("Result Summary\n{}",
PcStringUtils.renderJson(pt.getAggregateResultFullSummary()));

pt.saveLogToLocal();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.parallec.core.main.http;

import java.util.Map;

import io.parallec.core.ParallecResponseHandler;
import io.parallec.core.ParallelClient;
import io.parallec.core.ParallelTask;
import io.parallec.core.TestBase;
import io.parallec.core.ResponseOnSingleTask;
import io.parallec.core.util.PcStringUtils;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

public class ParallelClientHttpTraceTest extends TestBase{
private static ParallelClient pc;

@BeforeClass
public static void setUp() throws Exception {
pc = new ParallelClient();
}

@AfterClass
public static void shutdown() throws Exception {
pc.releaseExternalResources();
}
@Test
public void hitTraceTest() {

ParallelTask pt = pc
.prepareHttpTrace("")
.setConcurrency(1000)
.setSaveResponseToTask(true)
.setTargetHostsFromLineByLineText(FILEPATH_TOP_100,
SOURCE_LOCAL).execute(new ParallecResponseHandler() {

@Override
public void onCompleted(ResponseOnSingleTask res,
Map<String, Object> responseContext) {
logger.info("Responose Code:" + res.getStatusCode()
+ " host: " + res.getHost()+ " Reponse Content: " +res.getResponseContent());
}
});
logger.info("Result Summary\n{}",
PcStringUtils.renderJson(pt.getAggregateResultFullSummary()));

pt.saveLogToLocal();
}


}

1 comment on commit 44681d6

@tigerqiu712
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add bad test Case for HTTP methods of Trace Connect and Patch, it's hard to deploy web server to do test

Please sign in to comment.