本文整理汇总了Java中junit.framework.TestCase类的典型用法代码示例。如果您正苦于以下问题:Java TestCase类的具体用法?Java TestCase怎么用?Java TestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestCase类属于junit.framework包,在下文中一共展示了TestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processRequest
import junit.framework.TestCase; //导入依赖的package包/类
public void processRequest(RequestEvent requestReceivedEvent) {
Request request = requestReceivedEvent.getRequest();
ServerTransaction serverTransactionId = requestReceivedEvent
.getServerTransaction();
logger.info("\n\nRequest " + request.getMethod() + " received at "
+ sipStack.getStackName()
+ " with server transaction id " + serverTransactionId);
// We are the UAC so the only request we get is the BYE.
if (request.getMethod().equals(Request.BYE))
processBye(request, serverTransactionId);
else
TestCase.fail("Unexpected request ! : " + request);
}
示例2: fixedLinearVelocity
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests the pin joint with a body who has FIXED_LINEAR_VELOCITY as its
* mass type. The pin joint applied at a point on the body should rotate
* the body (before it wasn't doing anything).
*/
@Test
public void fixedLinearVelocity() {
World w = new World();
Body body = new Body();
body.addFixture(Geometry.createCircle(1.0));
body.setMass(MassType.FIXED_LINEAR_VELOCITY);
w.addBody(body);
PinJoint mj = new PinJoint(body, new Vector2(0.5, 0.0), 8.0, 0.3, 1000.0);
w.addJoint(mj);
mj.setTarget(new Vector2(0.7, -0.5));
w.step(1);
TestCase.assertTrue(mj.getReactionForce(w.step.invdt).getMagnitude() > 0);
TestCase.assertTrue(mj.getReactionForce(w.step.invdt).getMagnitude() <= 1000.0);
TestCase.assertTrue(body.getTransform().getRotation() < 0);
}
示例3: detectShapeAABB
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests {@link Shape} AABB.
*/
@Test
public void detectShapeAABB() {
Transform t1 = new Transform();
Transform t2 = new Transform();
// test containment
TestCase.assertTrue(this.sap.detect(capsule1, t1, capsule2, t2));
TestCase.assertTrue(this.sap.detect(capsule2, t2, capsule1, t1));
// test overlap
t1.translate(-0.5, 0.0);
TestCase.assertTrue(this.sap.detect(capsule1, t1, capsule2, t2));
TestCase.assertTrue(this.sap.detect(capsule2, t2, capsule1, t1));
// test only AABB overlap
t2.translate(0.0, 0.7);
TestCase.assertTrue(this.sap.detect(capsule1, t1, capsule2, t2));
TestCase.assertTrue(this.sap.detect(capsule2, t2, capsule1, t1));
// test no overlap
t2.translate(1.0, 0.0);
TestCase.assertFalse(this.sap.detect(capsule1, t1, capsule2, t2));
TestCase.assertFalse(this.sap.detect(capsule2, t2, capsule1, t1));
}
示例4: detectShapeAABB
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests {@link Shape} AABB.
*/
@Test
public void detectShapeAABB() {
Transform t1 = new Transform();
Transform t2 = new Transform();
// test containment
TestCase.assertTrue(this.sap.detect(c1, t1, c2, t2));
TestCase.assertTrue(this.sap.detect(c2, t2, c1, t1));
// test overlap
t1.translate(-0.5, 0.0);
TestCase.assertTrue(this.sap.detect(c1, t1, c2, t2));
TestCase.assertTrue(this.sap.detect(c2, t2, c1, t1));
// test only AABB overlap
t2.translate(0.0, -0.62);
TestCase.assertTrue(this.sap.detect(c1, t1, c2, t2));
TestCase.assertTrue(this.sap.detect(c2, t2, c1, t1));
// test no overlap
t1.translate(-1.0, 0.0);
TestCase.assertFalse(this.sap.detect(c1, t1, c2, t2));
TestCase.assertFalse(this.sap.detect(c2, t2, c1, t1));
}
示例5: jointIterator
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests the joint iterator.
*/
@Test
public void jointIterator() {
World w = new World();
w.addJoint(new AngleJoint(new Body(), new Body()));
w.addJoint(new AngleJoint(new Body(), new Body()));
w.addJoint(new AngleJoint(new Body(), new Body()));
w.addJoint(new AngleJoint(new Body(), new Body()));
Iterator<Joint> it = w.getJointIterator();
while (it.hasNext()) {
it.next();
}
it = w.getJointIterator();
while (it.hasNext()) {
it.next();
it.remove();
}
TestCase.assertEquals(0, w.getJointCount());
}
示例6: createProvider
import junit.framework.TestCase; //导入依赖的package包/类
public SipProvider createProvider() {
try {
ListeningPoint lp = sipStack.createListeningPoint(myAddress,
myPort, transport);
sipProvider = sipStack.createSipProvider(lp);
logger.info("provider " + sipProvider);
logger.info("sipStack = " + sipStack);
return sipProvider;
} catch (Exception ex) {
logger.error(ex);
TestCase.fail(unexpectedException);
return null;
}
}
示例7: processResponse
import junit.framework.TestCase; //导入依赖的package包/类
public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
Response response = (Response) responseReceivedEvent.getResponse();
Transaction tid = responseReceivedEvent.getClientTransaction();
if(tid == null) {
TestCase.assertTrue("retrans flag should be true", ((ResponseEventExt)responseReceivedEvent).isRetransmission());
} else {
TestCase.assertFalse("retrans flag should be false", ((ResponseEventExt)responseReceivedEvent).isRetransmission());
}
if ( response.getStatusCode() != 200 ) {
this.notifyCount --;
} else {
System.out.println("Notify Count = " + this.notifyCount);
}
}
示例8: divideAndConquer
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests the Divide And Conquer class against the random
* point cloud.
*/
@Test
public void divideAndConquer() {
DivideAndConquer dac = new DivideAndConquer();
Vector2[] hull = dac.generate(this.cloud);
// make sure we can create a polygon from it
// (this will check for convexity, winding, etc)
Polygon poly = new Polygon(hull);
// make sure all the points are either on or contained in the hull
for (int i = 0; i < this.cloud.length; i++) {
Vector2 p = this.cloud[i];
if (!poly.contains(p, Transform.IDENTITY)) {
TestCase.fail("Hull does not contain all points.");
}
}
}
示例9: singleTypedCondition
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Test that fallback occurs for a type.
*/
@Test
public void singleTypedCondition() {
FallbackNarrowphaseDetector detector = new FallbackNarrowphaseDetector(new Sat(), new Gjk());
detector.addCondition(new SingleTypedFallbackCondition(Ellipse.class));
// try all combos
for (int i = 0; i < TYPES.length; i++) {
for (int j = i; j < TYPES.length; j++) {
boolean fallback = detector.isFallbackRequired(TYPES[i], TYPES[j]);
if (TYPES[i] instanceof Ellipse || TYPES[j] instanceof Ellipse) {
// any combo with an ellipse should fallback
TestCase.assertTrue(fallback);
} else {
// all other combos shouldn't
TestCase.assertFalse(fallback);
}
}
}
}
示例10: difference
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests the difference method.
*/
@Test
public void difference() {
Matrix33 m1 = new Matrix33(0.0, 2.0, 0.0,
3.0, 1.0, 1.0,
2.0, 0.0, -1.0);
Matrix33 m2 = new Matrix33(1.0, 1.0, 3.0,
0.0, 4.0, 1.0,
2.0, 2.0, 1.0);
Matrix33 m3 = m1.difference(m2);
// test the values
TestCase.assertEquals(-1.0, m3.m00);
TestCase.assertEquals(1.0, m3.m01);
TestCase.assertEquals(-3.0, m3.m02);
TestCase.assertEquals(3.0, m3.m10);
TestCase.assertEquals(-3.0, m3.m11);
TestCase.assertEquals(0.0, m3.m12);
TestCase.assertEquals(0.0, m3.m20);
TestCase.assertEquals(-2.0, m3.m21);
TestCase.assertEquals(-2.0, m3.m22);
// make sure we didnt modify the first matrix
TestCase.assertFalse(m1.equals(m3));
}
示例11: sameDirectionNoCollision2
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests the time of impact computation in a failure case
* where the two bodies are moving in the same direction
* but the bodies do not collide.
*/
@Test
public void sameDirectionNoCollision2() {
// S--------------------->E
// S----------->E
Transform t1 = new Transform();
t1.translate(0.0, 1.0);
Vector2 dp1 = new Vector2(120.0 * TIME_STEP, 0.0);
Convex c2 = Geometry.createSquare(0.5);
Transform t2 = new Transform();
t2.translate(1.6, 1.5);
Vector2 dp2 = new Vector2(60.0 * TIME_STEP, 0.0);
// detect the time of impact
TimeOfImpact toi = new TimeOfImpact();
boolean collision = this.detector.getTimeOfImpact(this.c1, t1, dp1, 0.0, c2, t2, dp2, 0.0, 0.0, 1.0, toi);
TestCase.assertFalse(collision);
}
示例12: add
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests the addChild method.
*/
@Test
public void add() {
CollidableTest ct = new CollidableTest(Geometry.createCircle(1.0));
// make sure its not there first
TestCase.assertFalse(this.sap.contains(ct));
TestCase.assertFalse(this.dyn.contains(ct));
// addChild the item to the broadphases
this.sap.add(ct);
this.dyn.add(ct);
// make sure they are there
TestCase.assertTrue(this.sap.contains(ct));
TestCase.assertTrue(this.dyn.contains(ct));
}
示例13: getInContactBodiesMulti
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests bodies in contact with multiple fixtures ensuring that the
* getInContactBodies method only returns one instance of the in contact
* body.
*/
@Test
public void getInContactBodiesMulti() {
World w = new World();
Body b1 = new Body();
Body b2 = new Body();
b1.addFixture(Geometry.createRectangle(15.0, 1.0));
b1.setMass(MassType.NORMAL);
b2.addFixture(Geometry.createSquare(1.0));
Convex c = Geometry.createSquare(1.0);
c.translate(-0.5, 0.0);
b2.addFixture(c);
b2.setMass(MassType.NORMAL);
b2.translate(0.0, 0.75);
w.addBody(b1);
w.addBody(b2);
w.step(1);
List<Body> cbs = b1.getInContactBodies(false);
TestCase.assertEquals(1, cbs.size());
}
示例14: getJoinedBodies
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests the getJoinedBodies method.
*/
@Test
public void getJoinedBodies() {
Body b1 = new Body();
Body b2 = new Body();
List<Body> bodies = b1.getJoinedBodies();
TestCase.assertNotNull(bodies);
TestCase.assertTrue(bodies.isEmpty());
Joint j = new DistanceJoint(b1, b2, new Vector2(), new Vector2());
JointEdge je1 = new JointEdge(b2, j);
JointEdge je2 = new JointEdge(b1, j);
b1.joints.add(je1);
b2.joints.add(je2);
bodies = b1.getJoinedBodies();
TestCase.assertNotNull(bodies);
TestCase.assertFalse(bodies.isEmpty());
TestCase.assertSame(b2, bodies.get(0));
}
示例15: detectCollidableAABB
import junit.framework.TestCase; //导入依赖的package包/类
/**
* Tests {@link Collidable} AABB.
*/
@Test
public void detectCollidableAABB() {
// create some collidables
CollidableTest ct1 = new CollidableTest(t);
CollidableTest ct2 = new CollidableTest(e);
// test containment
TestCase.assertTrue(this.sap.detect(ct1, ct2));
TestCase.assertTrue(this.sap.detect(ct2, ct1));
// test overlap
ct1.translate(-0.8, 0.0);
TestCase.assertTrue(this.sap.detect(ct1, ct2));
TestCase.assertTrue(this.sap.detect(ct2, ct1));
// test only AABB overlap
ct2.translate(0.5, -0.5);
TestCase.assertTrue(this.sap.detect(ct1, ct2));
TestCase.assertTrue(this.sap.detect(ct2, ct1));
// test no overlap
ct2.translate(1.0, 0.5);
TestCase.assertFalse(this.sap.detect(ct1, ct2));
TestCase.assertFalse(this.sap.detect(ct2, ct1));
}