This commit is contained in:
coderfengyun 2013-12-23 17:30:02 +08:00
parent 50b5e7e969
commit 260c8282e3
4 changed files with 11 additions and 11 deletions

View File

@ -9,7 +9,7 @@ import org.bench4q.agent.scenario.behavior.BehaviorFactory;
import org.bench4q.share.models.agent.ParameterModel;
import org.bench4q.share.models.agent.RunScenarioModel;
import org.bench4q.share.models.agent.scriptrecord.BatchModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorBaseModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
import org.bench4q.share.models.agent.scriptrecord.PageModel;
import org.bench4q.share.models.agent.scriptrecord.UsePluginModel;
@ -124,7 +124,7 @@ public class Scenario {
}
}
private static Behavior extractBehavior(BehaviorBaseModel behaviorModel) {
private static Behavior extractBehavior(BehaviorModel behaviorModel) {
Behavior behavior = BehaviorFactory.getBuisinessObject(behaviorModel);
behavior.setName(behaviorModel.getName());
behavior.setUse(behaviorModel.getUse());

View File

@ -1,9 +1,9 @@
package org.bench4q.agent.scenario.behavior;
import org.bench4q.share.models.agent.scriptrecord.BehaviorBaseModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
public class BehaviorFactory {
public static Behavior getBuisinessObject(BehaviorBaseModel modelInput) {
public static Behavior getBuisinessObject(BehaviorModel modelInput) {
if (modelInput.getType().equalsIgnoreCase("TIMERBEHAVIOR")) {
return new TimerBehavior();
} else if (modelInput.getType().equalsIgnoreCase("USERBEHAVIOR")) {

View File

@ -7,7 +7,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlRootElement;
import org.bench4q.share.models.agent.scriptrecord.BehaviorBaseModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
import org.junit.Test;
import static org.junit.Assert.*;
@ -18,13 +18,13 @@ public class ModelTest {
@Test
public void unmarshalVerify() throws IOException, JAXBException {
Object object = JAXBContext
.newInstance(BehaviorBaseModel.class)
.newInstance(BehaviorModel.class)
.createUnmarshaller()
.unmarshal(
new File("Scripts"
+ System.getProperty("file.separator")
+ "behaviorModel.xml"));
assertTrue(object instanceof BehaviorBaseModel);
assertTrue(object instanceof BehaviorModel);
}
}

View File

@ -8,7 +8,7 @@ import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.bench4q.share.models.agent.scriptrecord.BehaviorBaseModel;
import org.bench4q.share.models.agent.scriptrecord.BehaviorModel;
import org.junit.Test;
public class UserBehaviorModelTest {
@ -16,11 +16,11 @@ public class UserBehaviorModelTest {
@Test
public void testUnmarshal() throws JAXBException {
Unmarshaller unmarshaller = JAXBContext.newInstance(
BehaviorBaseModel.class).createUnmarshaller();
BehaviorModel.class).createUnmarshaller();
Object object = unmarshaller.unmarshal(new File("Scripts"
+ System.getProperty("file.separator") + "behaviorModel.xml"));
BehaviorBaseModel userBehaviorModel = (BehaviorBaseModel) object;
BehaviorModel userBehaviorModel = (BehaviorModel) object;
System.out.println(userBehaviorModel.getUse());
assertTrue(object instanceof BehaviorBaseModel);
assertTrue(object instanceof BehaviorModel);
}
}