refactoring and add test
This commit is contained in:
parent
a9c9e52bd0
commit
5ab657f721
|
@ -0,0 +1,32 @@
|
|||
package org.bench4q.master.service;
|
||||
|
||||
import java.util.Vector;
|
||||
|
||||
public class PortPoolService {
|
||||
|
||||
private Vector<Integer> ScriptPortPool = new Vector<Integer>();
|
||||
|
||||
public PortPoolService() {
|
||||
this.setScriptPortPool(new Vector<Integer>());
|
||||
}
|
||||
|
||||
public Vector<Integer> getScriptPortPool() {
|
||||
return ScriptPortPool;
|
||||
}
|
||||
|
||||
private void setScriptPortPool(Vector<Integer> scriptPortPool) {
|
||||
ScriptPortPool = scriptPortPool;
|
||||
}
|
||||
|
||||
public void addPortToPool(int port)
|
||||
{
|
||||
this.getScriptPortPool().add(port);
|
||||
}
|
||||
|
||||
public void removePortFromPool(int port)
|
||||
{
|
||||
if(this.getScriptPortPool().contains(port)){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package org.bench4q.master.test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.bench4q.master.api.model.RegisterResponseModel;
|
||||
import org.bench4q.master.communication.HttpRequester;
|
||||
import org.bench4q.master.communication.HttpRequester.HttpResponse;
|
||||
|
||||
public class AuthTest {
|
||||
private HttpRequester httpRequester;
|
||||
|
||||
public AuthTest() {
|
||||
this.setHttpRequester(new HttpRequester());
|
||||
}
|
||||
|
||||
public HttpRequester getHttpRequester() {
|
||||
return httpRequester;
|
||||
}
|
||||
|
||||
private void setHttpRequester(HttpRequester httpRequester) {
|
||||
this.httpRequester = httpRequester;
|
||||
}
|
||||
|
||||
private RegisterResponseModel extractRegisterResponseModel(String content)
|
||||
throws JAXBException {
|
||||
RegisterResponseModel resultModel = new RegisterResponseModel();
|
||||
Unmarshaller ummarshaller = JAXBContext.newInstance(
|
||||
resultModel.getClass()).createUnmarshaller();
|
||||
resultModel = (RegisterResponseModel) ummarshaller
|
||||
.unmarshal(new ByteArrayInputStream(content.getBytes()));
|
||||
return resultModel;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
AuthTest authTest = new AuthTest();
|
||||
String urlString = "133.133.12.1:8080/user/register?userName=rk&password=123";
|
||||
try {
|
||||
HttpResponse httpResponse = authTest.getHttpRequester().sendGet(
|
||||
urlString, null, null);
|
||||
RegisterResponseModel registerResponseModel = authTest
|
||||
.extractRegisterResponseModel(httpResponse.getContent());
|
||||
|
||||
if (registerResponseModel.isSuccess()) {
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
} catch (JAXBException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue