Example #1
0
 public void testErrorSetIndexWithoutClearingPreviousIndex() {
   InstanceStack iStack = new InstanceStack();
   iStack.setConfigAdapter(mci);
   TestInstance ti = new TestInstance();
   iStack.pushInstance(ti, ti.getDescriptor());
   iStack.setAttributeName("attribute");
   iStack.setAttributeIndex(42);
   try {
     iStack.setAttributeIndex(43);
     fail("Expected error when setting a new attribute index without clearing previous one");
   } catch (Exception expected) {
     assertExceptionMessage(expected, AuraRuntimeException.class, "missing clearAttributeIndex");
   }
 }
Example #2
0
  public void testPath() {
    InstanceStack iStack = new InstanceStack();
    iStack.setConfigAdapter(mci);
    assertEquals("InstanceStack constructor should set path to base", "/*[0]", iStack.getPath());

    Instance<?> ti = new TestInstance();
    iStack.pushInstance(ti, ti.getDescriptor());

    // Set and clear attributes
    iStack.setAttributeName("attr1");
    assertEquals(
        "Setting attribute name should append name to path", "/*[0]/attr1", iStack.getPath());
    iStack.clearAttributeName("attr1");
    assertEquals("Clearing attribute name should remove name from path", "/*[0]", iStack.getPath());
    iStack.setAttributeName("body");
    assertEquals(
        "Setting attribute name as body should append '*' to path", "/*[0]/*", iStack.getPath());
    iStack.clearAttributeName("body");
    assertEquals("/*[0]", iStack.getPath());
    iStack.setAttributeName("realbody");
    assertEquals(
        "Setting attribute name as realbody should append '+' to path",
        "/*[0]/+",
        iStack.getPath());
    iStack.clearAttributeName("realbody");
    assertEquals("/*[0]", iStack.getPath());

    // Set and clear indexes
    iStack.setAttributeName("attr2");
    iStack.setAttributeIndex(42);
    assertEquals("/*[0]/attr2[42]", iStack.getPath());
    iStack.clearAttributeIndex(42);
    assertEquals("/*[0]/attr2", iStack.getPath());
  }
Example #3
0
 public void testErrorSetIndexWithoutAttributeSet() {
   InstanceStack iStack = new InstanceStack();
   iStack.setConfigAdapter(mci);
   TestInstance ti = new TestInstance("instance");
   iStack.pushInstance(ti, ti.getDescriptor());
   try {
     iStack.setAttributeIndex(1);
     fail("Expected error when setting attribute index without setting attribute name first");
   } catch (Exception expected) {
     assertExceptionMessage(expected, AuraRuntimeException.class, "no name when index set");
   }
 }
Example #4
0
 public void testErrorClearIndexWhileDifferentIndexSet() {
   InstanceStack iStack = new InstanceStack();
   iStack.setConfigAdapter(mci);
   TestInstance ti = new TestInstance();
   iStack.pushInstance(ti, ti.getDescriptor());
   iStack.setAttributeName("attribute");
   iStack.setAttributeIndex(11);
   try {
     iStack.clearAttributeIndex(22);
     fail("Expected error when clearing attribute index when different index is set");
   } catch (Exception expected) {
     assertExceptionMessage(
         expected, AuraRuntimeException.class, "mismatched clearAttributeIndex");
   }
 }