예제 #1
0
 /**
  * Chaining engines with a replacement test for {@link
  * NodeEngine#chain(com.github.wuic.engine.NodeEngine...)}.
  */
 @Test
 public void chainReplaceWithLast() {
   final NodeEngine engine1 = new SpriteInspectorEngine(false, new SpriteProvider[] {});
   final NodeEngine engine2 = new ImageAggregatorEngine(false, new BinPacker<ConvertibleNut>());
   final NodeEngine engine3 = new ImageCompressorEngine(false);
   final NodeEngine engine4 = new ImageAggregatorEngine(false, new BinPacker<ConvertibleNut>());
   final NodeEngine chain = NodeEngine.chain(engine1, engine2, engine3);
   assertChainTest(NodeEngine.chain(chain, engine4), engine1, engine4, engine3);
 }
예제 #2
0
 /** Union test for {@link NodeEngine#chain(com.github.wuic.engine.NodeEngine...)}. */
 @Test
 public void chainUnionTest() {
   final NodeEngine engine1 = new SpriteInspectorEngine(false, new SpriteProvider[] {});
   final NodeEngine engine2 = new ImageAggregatorEngine(false, new BinPacker<ConvertibleNut>());
   final NodeEngine engine3 = new ImageCompressorEngine(false);
   assertChainTest(
       NodeEngine.chain(NodeEngine.chain(engine1, engine2), NodeEngine.chain(engine2, engine3)),
       engine1,
       engine2,
       engine3);
 }
예제 #3
0
  /**
   * Tests some assertions on given engines.
   *
   * @param chain the chain of engines
   * @param e1 first engine in chain
   * @param e2 second engine in chain
   * @param e3 third engine in chain
   */
  private void assertChainTest(
      final NodeEngine chain, final NodeEngine e1, final NodeEngine e2, final NodeEngine e3) {
    // Test null/not null assertion on next and previous
    Assert.assertNull(chain.getPrevious());
    Assert.assertNotNull(chain.getNext());
    Assert.assertNotNull(chain.getNext().getNext());
    Assert.assertNotNull(chain.getNext().getPrevious());
    Assert.assertNotNull(chain.getNext().getNext().getPrevious());
    Assert.assertNull(chain.getNext().getNext().getNext());

    // Test right position in the chain
    Assert.assertEquals(chain, e1);
    Assert.assertEquals(chain.getNext(), e2);
    Assert.assertEquals(chain.getNext().getNext(), e3);
    Assert.assertEquals(chain.getNext().getPrevious(), e1);
    Assert.assertEquals(chain.getNext().getNext().getPrevious(), e2);

    Assert.assertTrue(e1.compareTo(e2) < 0);
    Assert.assertTrue(e2.compareTo(e3) < 0);
    Assert.assertTrue(e3.compareTo(e2) > 0);
    Assert.assertTrue(e2.compareTo(e1) > 0);
  }