Java 类junit.framework.TestCase 实例源码

项目:LightSIP    文件:Shootist.java   
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);

}
项目:featurea    文件:PinJointTest.java   
/**
 * 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);
}
项目:featurea    文件:CapsuleCapsuleTest.java   
/**
 * 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));
}
项目:featurea    文件:EllipseEllipseTest.java   
/**
 * 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));
}
项目:featurea    文件:WorldTest.java   
/**
 * 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());
}
项目:LightSIP    文件:Shootme.java   
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;

    }

}
项目:LightSIP    文件:Notifier.java   
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);
    }

}
项目:featurea    文件:HullGeneratorTest.java   
/**
 * 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.");
        }
    }
}
项目:featurea    文件:FallbackNarrowphaseDetectorTest.java   
/**
 * 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);
            }
        }
    }
}
项目:featurea    文件:Matrix33Test.java   
/**
 * 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));
}
项目:featurea    文件:ConservativeAdvancementTest.java   
/**
 * 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);
}
项目:featurea    文件:BroadphaseTest.java   
/**
 * 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));
}
项目:featurea    文件:BodyTest.java   
/**
 * 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());
}
项目:featurea    文件:BodyTest.java   
/**
 * 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));
}
项目:LightSIP    文件:Shootme.java   
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;

    }

}
项目:featurea    文件:TriangleEllipseTest.java   
/**
 * 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));
}
项目:featurea    文件:RectangleHalfEllipseTest.java   
/**
 * Tests {@link Collidable} AABB.
 */
@Test
public void detectCollidableAABB() {
    // create some collidables
    CollidableTest ct1 = new CollidableTest(r);
    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(-1.0, 0.0);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test AABB overlap
    ct2.translate(0.0, -1.2);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct1, ct2));

    // test no overlap
    ct2.translate(1.0, 0.0);
    TestCase.assertFalse(this.sap.detect(ct1, ct2));
    TestCase.assertFalse(this.sap.detect(ct2, ct1));
}
项目:featurea    文件:AABBTest.java   
/**
 * Tests the isDegenerate methods.
 */
@Test
public void degenerate() {
    AABB aabb = new AABB(0.0, 0.0, 0.0, 0.0);
    TestCase.assertTrue(aabb.isDegenerate());

    aabb = new AABB(1.0, 2.0, 1.0, 3.0);
    TestCase.assertTrue(aabb.isDegenerate());

    aabb = new AABB(1.0, 0.0, 2.0, 1.0);
    TestCase.assertFalse(aabb.isDegenerate());

    aabb = new AABB(1.0, 0.0, 1.000001, 2.0);
    TestCase.assertFalse(aabb.isDegenerate());
    TestCase.assertFalse(aabb.isDegenerate(Epsilon.E));
    TestCase.assertTrue(aabb.isDegenerate(0.000001));
}
项目:featurea    文件:WorldTest.java   
/**
 * Tests the addChild body method.
 */
@Test
public void addJoint() {
    World w = new World();
    Body b1 = new Body();
    Body b2 = new Body();

    Joint j = new DistanceJoint(b1, b2, new Vector2(), new Vector2());

    w.addBody(b1);
    w.addBody(b2);
    w.addJoint(j);

    TestCase.assertTrue(w.getJointCount() > 0);
    TestCase.assertFalse(b1.joints.isEmpty());
    TestCase.assertFalse(b2.joints.isEmpty());
}
项目:featurea    文件:TriangleTriangleTest.java   
/**
 * Tests {@link Shape} AABB.
 */
@Test
public void detectShapeAABB() {
    Transform t1 = new Transform();
    Transform t2 = new Transform();

    // test containment
    TestCase.assertTrue(this.sap.detect(tri1, t1, tri2, t2));
    TestCase.assertTrue(this.sap.detect(tri2, t2, tri1, t1));

    // test overlap
    t2.translate(0.0, 0.5);
    TestCase.assertTrue(this.sap.detect(tri1, t1, tri2, t2));
    TestCase.assertTrue(this.sap.detect(tri2, t2, tri1, t1));

    // test only AABB overlap
    t2.translate(0.0, 0.3);
    TestCase.assertTrue(this.sap.detect(tri1, t1, tri2, t2));
    TestCase.assertTrue(this.sap.detect(tri2, t2, tri1, t1));

    // test no overlap
    t2.translate(0.0, 0.3);
    TestCase.assertFalse(this.sap.detect(tri1, t1, tri2, t2));
    TestCase.assertFalse(this.sap.detect(tri2, t2, tri1, t1));
}
项目:featurea    文件:EllipseHalfEllipseTest.java   
/**
 * Tests {@link Collidable} AABB.
 */
@Test
public void detectCollidableAABB() {
    // create some collidables
    CollidableTest ct1 = new CollidableTest(c1);
    CollidableTest ct2 = new CollidableTest(c2);

    // test containment
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test overlap
    ct1.translate(-0.5, 0.0);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test only AABB overlap
    ct2.translate(0.0, -1.15);
    TestCase.assertTrue(this.sap.detect(ct1, ct2));
    TestCase.assertTrue(this.sap.detect(ct2, ct1));

    // test no overlap
    ct1.translate(-1.0, 0.0);
    TestCase.assertFalse(this.sap.detect(ct1, ct2));
    TestCase.assertFalse(this.sap.detect(ct2, ct1));
}
项目:featurea    文件:PolygonTest.java   
/**
 * Tests the rotate methods.
 */
@Test
public void rotate() {
    Vector2[] vertices = new Vector2[]{
            new Vector2(0.0, 1.0),
            new Vector2(-1.0, -1.0),
            new Vector2(1.0, -1.0)
    };
    Polygon p = new Polygon(vertices);

    // should move the points
    p.rotate(Math.toRadians(90), 0, 0);

    TestCase.assertEquals(-1.000, p.vertices[0].x, 1.0e-3);
    TestCase.assertEquals(0.000, p.vertices[0].y, 1.0e-3);

    TestCase.assertEquals(1.000, p.vertices[1].x, 1.0e-3);
    TestCase.assertEquals(-1.000, p.vertices[1].y, 1.0e-3);

    TestCase.assertEquals(1.000, p.vertices[2].x, 1.0e-3);
    TestCase.assertEquals(1.000, p.vertices[2].y, 1.0e-3);
}
项目:featurea    文件:IslandTest.java   
/**
 * Tests the clear method.
 */
@Test
public void clear() {
    Island i = new Island();

    i.add(new Body());
    i.add(new AngleJoint(new Body(), new Body()));
    i.add(new ContactConstraint(new Body(), new BodyFixture(Geometry.createCircle(1.0)), new Body(), new BodyFixture(Geometry.createCircle(1.0)), new Manifold(new ArrayList<ManifoldPoint>(), new Vector2()), 0, 0));

    TestCase.assertEquals(1, i.bodies.size());
    TestCase.assertEquals(1, i.joints.size());
    TestCase.assertEquals(1, i.contactConstraints.size());

    i.clear();

    TestCase.assertEquals(0, i.bodies.size());
    TestCase.assertEquals(0, i.joints.size());
    TestCase.assertEquals(0, i.contactConstraints.size());
}
项目:incubator-netbeans    文件:SimpleWeakSetTesting.java   
public static void removeElement(Context context, int listIndex) throws Exception {
    SimpleWeakSet simpleWeakSet = context.getInstance(SimpleWeakSet.class);
    List removedList = (List) context.getProperty(REMOVED_LIST);
    List list = context.getInstance(List.class);
    Object element = list.remove(listIndex);
    removedList.add(element);
    Object removedElement = simpleWeakSet.remove(element);
    TestCase.assertEquals(element, removedElement);

    StringBuilder sb = context.logOpBuilder();
    if (sb != null) {
        sb.append("Remove[").append(listIndex).append("]: ").append(element).append("\n");
        context.logOp(sb);
    }
}
项目:featurea    文件:TypeFilterTest.java   
/**
 * Tests the filter method of the TypeFilter class.
 */
@Test
public void filter() {
    // all should let all of them work
    TestCase.assertTrue(ALL.isAllowed(ALL));
    TestCase.assertTrue(ALL.isAllowed(CATEGORY_1));
    TestCase.assertTrue(ALL.isAllowed(CATEGORY_2));
    TestCase.assertTrue(ALL.isAllowed(CATEGORY_3));
    TestCase.assertTrue(ALL.isAllowed(CATEGORY_4));
    TestCase.assertTrue(CATEGORY_1.isAllowed(ALL));
    TestCase.assertTrue(CATEGORY_2.isAllowed(ALL));
    TestCase.assertTrue(CATEGORY_3.isAllowed(ALL));
    TestCase.assertTrue(CATEGORY_4.isAllowed(ALL));

    // since these are not in the same branch they should not be allowed
    TestCase.assertFalse(CATEGORY_1.isAllowed(CATEGORY_2));
    TestCase.assertFalse(CATEGORY_3.isAllowed(CATEGORY_2));
    TestCase.assertFalse(CATEGORY_4.isAllowed(CATEGORY_2));
    TestCase.assertFalse(CATEGORY_3.isAllowed(CATEGORY_4));
    // try the reverse
    TestCase.assertFalse(CATEGORY_2.isAllowed(CATEGORY_1));
    TestCase.assertFalse(CATEGORY_2.isAllowed(CATEGORY_3));
    TestCase.assertFalse(CATEGORY_2.isAllowed(CATEGORY_4));
    TestCase.assertFalse(CATEGORY_4.isAllowed(CATEGORY_3));

    TestCase.assertTrue(CATEGORY_1.isAllowed(CATEGORY_3));
    TestCase.assertTrue(CATEGORY_1.isAllowed(CATEGORY_4));
    TestCase.assertTrue(CATEGORY_3.isAllowed(CATEGORY_1));
    TestCase.assertTrue(CATEGORY_4.isAllowed(CATEGORY_1));

    // null and any other type should return false
    TestCase.assertFalse(ALL.isAllowed(null));
    TestCase.assertFalse(ALL.isAllowed(new CategoryFilter()));
}
项目:featurea    文件:BalancedBinarySearchTreeTest.java   
/**
 * Tests the contains method.
 */
@Test
public void contains() {
    TestCase.assertTrue(tree.contains(9));
    TestCase.assertFalse(tree.contains(14));

    BinarySearchTreeNode<Integer> node = tree.get(-3);
    TestCase.assertTrue(tree.contains(node));

    node = new BinarySearchTreeNode<Integer>(-3);
    TestCase.assertFalse(tree.contains(node));
}
项目:featurea    文件:EarClippingTest.java   
/**
 * Tests the triangulation implementation against the zoom1 data file.
 *
 * @since 3.1.9
 */
@Test
public void successZoom2() {
    Vector2[] vertices = this.load(EarClippingTest.class.getResourceAsStream("/featurea/physics/data/zoom2.dat"));

    // decompose the poly
    List<? extends Convex> result = this.algo.decompose(vertices);

    // the result should have n - 2 triangles shapes
    TestCase.assertTrue(result.size() <= vertices.length - 2);
}
项目:featurea    文件:PolygonTest.java   
/**
 * Tests the createAABB method.
 *
 * @since 3.1.0
 */
@Test
public void createAABB() {
    Vector2[] vertices = new Vector2[]{
            new Vector2(0.0, 1.0),
            new Vector2(-1.0, -1.0),
            new Vector2(1.0, -1.0)
    };
    Polygon p = new Polygon(vertices);

    AABB aabb = p.createAABB(Transform.IDENTITY);
    TestCase.assertEquals(-1.0, aabb.getMinX(), 1.0e-3);
    TestCase.assertEquals(-1.0, aabb.getMinY(), 1.0e-3);
    TestCase.assertEquals(1.0, aabb.getMaxX(), 1.0e-3);
    TestCase.assertEquals(1.0, aabb.getMaxY(), 1.0e-3);

    // try using the default method
    AABB aabb2 = p.createAABB();
    TestCase.assertEquals(aabb.getMinX(), aabb2.getMinX());
    TestCase.assertEquals(aabb.getMinY(), aabb2.getMinY());
    TestCase.assertEquals(aabb.getMaxX(), aabb2.getMaxX());
    TestCase.assertEquals(aabb.getMaxY(), aabb2.getMaxY());

    Transform tx = new Transform();
    tx.rotate(Math.toRadians(30.0));
    tx.translate(1.0, 2.0);
    aabb = p.createAABB(tx);
    TestCase.assertEquals(0.500, aabb.getMinX(), 1.0e-3);
    TestCase.assertEquals(0.634, aabb.getMinY(), 1.0e-3);
    TestCase.assertEquals(2.366, aabb.getMaxX(), 1.0e-3);
    TestCase.assertEquals(2.866, aabb.getMaxY(), 1.0e-3);
}
项目:dev-courses    文件:TestMultiInsert.java   
public static void main(String[] argv) {

        TestResult result = new TestResult();
        TestCase   testA  = new TestMultiInsert("testMultiInsert");

        testA.run(result);
        System.out.println("TestMultiInsert error count: " + result.failureCount());
        Enumeration e = result.failures();
        while(e.hasMoreElements()) System.out.println(e.nextElement());
    }
项目:featurea    文件:EarClippingTest.java   
/**
 * Tests the implementation against the zoom7 data file.
 *
 * @since 3.1.9
 */
@Test
public void successZoom7() {
    Vector2[] vertices = this.load(EarClippingTest.class.getResourceAsStream("/featurea/physics/data/zoom7.dat"));

    // decompose the poly
    List<? extends Convex> result = this.algo.decompose(vertices);

    // the result should have n - 2 triangles shapes
    TestCase.assertTrue(result.size() <= vertices.length - 2);
}
项目:featurea    文件:SweepLineTest.java   
/**
 * Tests the triangulation implementation against the zoom6 data file.
 *
 * @since 3.1.9
 */
@Test
public void triangulateSuccessZoom6() {
    Vector2[] vertices = this.load(SweepLineTest.class.getResourceAsStream("/featurea/physics/data/zoom6.dat"));

    // decompose the poly
    List<? extends Convex> result = this.algo.triangulate(vertices);

    // the result should have n - 2 triangles shapes
    TestCase.assertEquals(vertices.length - 2, result.size());
}
项目:featurea    文件:EpsilonTest.java   
/**
 * Tests the machine epsilon computation.
 */
@Test
public void compute() {
    // ensure that the static variable is set
    TestCase.assertFalse(Epsilon.E == 0.0);
    // ensure the compute method returns in a
    // finite number of iterations
    Epsilon.compute();
    // ensure that the epsilon adds nothing to the
    // number 1
    TestCase.assertEquals(1.0, 1.0 + Epsilon.E);
}
项目:featurea    文件:BroadphaseTest.java   
/**
 * Tests the shiftCoordinates method.
 */
@Test
public void shiftCoordinates() {
    CollidableTest ct1 = new CollidableTest(Geometry.createCircle(1.0));
    CollidableTest ct2 = new CollidableTest(Geometry.createUnitCirclePolygon(5, 0.5));
    CollidableTest ct3 = new CollidableTest(Geometry.createRectangle(1.0, 0.5));
    CollidableTest ct4 = new CollidableTest(Geometry.createVerticalSegment(2.0));

    ct1.translate(-2.0, 0.0);
    ct2.translate(-1.0, 1.0);
    ct3.translate(0.5, -2.0);
    ct4.translate(1.0, 1.0);

    // addChild the items to the broadphases
    this.sap.add(ct1);
    this.sap.add(ct2);
    this.sap.add(ct3);
    this.sap.add(ct4);
    this.dyn.add(ct1);
    this.dyn.add(ct2);
    this.dyn.add(ct3);
    this.dyn.add(ct4);

    // perform a detect on the whole broadphase
    List<BroadphasePair<CollidableTest, Fixture>> pairs = this.sap.detect();
    TestCase.assertEquals(1, pairs.size());
    pairs = this.dyn.detect();
    TestCase.assertEquals(1, pairs.size());

    // shift the broadphases
    Vector2 shift = new Vector2(1.0, -2.0);
    this.sap.shift(shift);
    this.dyn.shift(shift);

    // the number of pairs detected should be identical
    pairs = this.sap.detect();
    TestCase.assertEquals(1, pairs.size());
    pairs = this.dyn.detect();
    TestCase.assertEquals(1, pairs.size());
}
项目:featurea    文件:AngleJointTest.java   
/**
 * Tests the successful setting of the minimum and maximum angle.
 */
@Test
public void setMinAndMax() {
    AngleJoint aj = new AngleJoint(new Body(), new Body());
    aj.setLimits(Math.toRadians(-30), Math.toRadians(20));

    TestCase.assertEquals(Math.toRadians(-30), aj.getLowerLimit(), 1e-6);
    TestCase.assertEquals(Math.toRadians(20), aj.getUpperLimit(), 1e-6);
}
项目:LightSIP    文件:Shootme.java   
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid) {
    try {
        logger.info("sendInviteOK: " + inviteTid);
        if (inviteTid.getState() != TransactionState.COMPLETED) {
            logger.info("shootme: Dialog state before OK: "
                    + inviteTid.getDialog().getState());

            SipProvider sipProvider = (SipProvider) requestEvent.getSource();
            Request request = requestEvent.getRequest();
            Response okResponse = protocolObjects.messageFactory.createResponse(Response.OK,
                    request);
                ListeningPoint lp = sipProvider.getListeningPoint(protocolObjects.transport);
            int myPort = lp.getPort();

            Address address = protocolObjects.addressFactory.createAddress("Shootme <sip:"
                    + myAddress + ":" + myPort + ";transport=" + protocolObjects.transport +">");
            ContactHeader contactHeader = protocolObjects.headerFactory
                    .createContactHeader(address);
            okResponse.addHeader(contactHeader);
            inviteTid.sendResponse(okResponse);
            logger.info("shootme: Dialog state after OK: "
                    + inviteTid.getDialog().getState());
            TestHarness.assertEquals( DialogState.CONFIRMED , inviteTid.getDialog().getState() );
        } else {
            logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
        }
    } catch (Exception ex) {
        logger.error("unexpected exception",ex);
        ex.printStackTrace();
        TestCase.fail("Unexpected exception occured");
    }
}
项目:featurea    文件:SweepLineTest.java   
/**
 * Tests the implementation against the nazca_heron data file.
 */
@Test
public void successNazcaHeron() {
    Vector2[] vertices = this.load(SweepLineTest.class.getResourceAsStream("/featurea/physics/data/nazca_heron.dat"));

    // decompose the poly
    List<Convex> result = this.algo.decompose(vertices);

    // the result should have less than or equal to n - 2 convex shapes
    TestCase.assertTrue(result.size() <= vertices.length - 2);
}
项目:incubator-netbeans    文件:Typing.java   
public void assertDocumentTextEquals(final String textWithPipe) {
    int caretOffset = textWithPipe.indexOf('|');
    String text;
    if (caretOffset != -1) {
        text = textWithPipe.substring(0, caretOffset) + textWithPipe.substring(caretOffset + 1);
    } else {
        text = textWithPipe;
    }
    try {
        // Use debug text to prefix special chars for easier readability
        text = CharSequenceUtilities.debugText(text);
        String docText = document().getText(0, document().getLength());
        docText = CharSequenceUtilities.debugText(docText);
        if (!text.equals(docText)) {
            int diffIndex = 0;
            int minLen = Math.min(docText.length(), text.length());
            while (diffIndex < minLen) {
                if (text.charAt(diffIndex) != docText.charAt(diffIndex)) {
                    break;
                }
                diffIndex++;
            }
            TestCase.fail("Invalid document text - diff at index " + diffIndex + "\nExpected: \"" + text + "\"\n  Actual: \"" + docText + "\"");
        }
    } catch (BadLocationException e) {
        throw new IllegalStateException(e);
    }
    if (caretOffset != -1) {
        TestCase.assertEquals("Invalid caret offset", caretOffset, pane.getCaretPosition());
    }
}
项目:geopackage-android-map    文件:GoogleMapShapeConverterUtils.java   
/**
 * Compare two lists of points
 * 
 * @param points
 * @param points2
 */
private static void comparePoints(List<Point> points, List<Point> points2) {
    TestCase.assertEquals(points.size(), points2.size());

    for (int i = 0; i < points.size(); i++) {
        comparePoints(points.get(i), points2.get(i));
    }
}
项目:incubator-netbeans    文件:GuardUtils.java   
public static void verifyGuardAttr(TestCase test, StyledDocument doc, InteriorSection gs) {
    PositionBounds bounds = gs.getImpl().getHeaderBounds();
    verifyGuardAttr(test, (GuardedDocument) doc, bounds.getBegin().getOffset(), bounds.getEnd().getOffset());
    bounds = gs.getImpl().getFooterBounds();
    verifyGuardAttr(test, (GuardedDocument) doc, bounds.getBegin().getOffset(), bounds.getEnd().getOffset());

}
项目:featurea    文件:MassTest.java   
/**
 * Test case for the polygon create method.
 */
@Test
public void createPolygon() {
    Polygon p = Geometry.createUnitCirclePolygon(5, 0.5);
    Mass m = p.createMass(1.0);
    // the polygon mass should be the area * d
    TestCase.assertEquals(0.594, m.getMass(), 1.0e-3);
    TestCase.assertEquals(0.057, m.getInertia(), 1.0e-3);
}