Search in sources :

Example 11 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class TemplateParserImplTest method just_HTML.

@Test
public void just_HTML() {
    Resource resource = getResource("justHTML.tml");
    ComponentTemplate template = getParser().parseTemplate(resource);
    assertSame(template.getResource(), resource);
    assertFalse(template.usesStrictMixinParameters());
    List<TemplateToken> tokens = template.getTokens();
    // They add up quick ...
    assertEquals(tokens.size(), 20);
    StartElementToken t0 = get(tokens, 0);
    // Spot check a few things ...
    assertEquals(t0.name, "html");
    assertEquals(t0.namespaceURI, "");
    checkLine(t0, 1);
    TextToken t1 = get(tokens, 1);
    // Concerned this may not work cross platform.
    assertEquals(t1.text, "\n    ");
    StartElementToken t2 = get(tokens, 2);
    assertEquals(t2.name, "head");
    checkLine(t2, 2);
    TextToken t5 = get(tokens, 5);
    assertEquals(t5.text, "title");
    checkLine(t5, 3);
    get(tokens, 6);
    StartElementToken t12 = get(tokens, 12);
    assertEquals(t12.name, "p");
    AttributeToken t13 = get(tokens, 13);
    assertEquals(t13.name, "class");
    assertEquals(t13.value, "important");
    assertEquals(t13.namespaceURI, "");
    TextToken t14 = get(tokens, 14);
    // Simplify the text, converting consecutive whitespace to just a single space.
    assertEquals(t14.text.replaceAll("\\s+", " ").trim(), "Tapestry rocks! Line 2");
    // Line number is the *start* line of the whole text block.
    checkLine(t14, 6);
}
Also used : Resource(org.apache.tapestry5.commons.Resource) ClasspathResource(org.apache.tapestry5.ioc.internal.util.ClasspathResource) AbstractResource(org.apache.tapestry5.ioc.internal.util.AbstractResource) Test(org.testng.annotations.Test)

Example 12 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class PropertyOverridesImplTest method block_found.

@Test
public void block_found() {
    Messages messages = mockMessages();
    ComponentResources resources = mockInternalComponentResources();
    Block block = mockBlock();
    String name = "alfred";
    train_getContainerMessages(resources, messages);
    train_getBlockParameter(resources, name, block);
    replay();
    PropertyOverrides po = new PropertyOverridesImpl(resources);
    assertSame(po.getOverrideBlock(name), block);
    verify();
}
Also used : Messages(org.apache.tapestry5.commons.Messages) Block(org.apache.tapestry5.Block) PropertyOverrides(org.apache.tapestry5.PropertyOverrides) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 13 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class CheckMethodAdapter method visitMaxs.

@Override
public void visitMaxs(final int maxStack, final int maxLocals) {
    checkVisitCodeCalled();
    checkVisitMaxsNotCalled();
    visitMaxCalled = true;
    for (Label l : referencedLabels) {
        if (labelInsnIndices.get(l) == null) {
            throw new IllegalStateException("Undefined label used");
        }
    }
    for (int i = 0; i < handlers.size(); i += 2) {
        Integer startInsnIndex = labelInsnIndices.get(handlers.get(i));
        Integer endInsnIndex = labelInsnIndices.get(handlers.get(i + 1));
        if (startInsnIndex == null || endInsnIndex == null) {
            throw new IllegalStateException("Undefined try catch block labels");
        }
        if (endInsnIndex.intValue() <= startInsnIndex.intValue()) {
            throw new IllegalStateException("Emty try catch block handler range");
        }
    }
    checkUnsignedShort(maxStack, "Invalid max stack");
    checkUnsignedShort(maxLocals, "Invalid max locals");
    super.visitMaxs(maxStack, maxLocals);
}
Also used : Label(org.apache.tapestry5.internal.plastic.asm.Label)

Example 14 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class ModuleImpl method findOrCreate.

/**
 * Locates the service proxy for a particular service (from the service definition).
 *
 * @param def              defines the service
 * @param eagerLoadProxies collection into which proxies for eager loaded services are added (or null)
 * @return the service proxy
 */
private Object findOrCreate(final ServiceDef3 def, final Collection<EagerLoadServiceProxy> eagerLoadProxies) {
    final String key = def.getServiceId();
    final Invokable create = new Invokable() {

        @Override
        public Object invoke() {
            // In a race condition, two threads may try to create the same service simulatenously.
            // The second will block until after the first creates the service.
            Object result = services.get(key);
            if (result == null) {
                result = create(def, eagerLoadProxies);
                services.put(key, result);
            }
            return result;
        }
    };
    Invokable find = new Invokable() {

        @Override
        public Object invoke() {
            Object result = services.get(key);
            if (result == null)
                result = BARRIER.withWrite(create);
            return result;
        }
    };
    return BARRIER.withRead(find);
}
Also used : Invokable(org.apache.tapestry5.ioc.Invokable)

Example 15 with Block

use of org.apache.tapestry5.Block in project tapestry-5 by apache.

the class BlockImplTest method body_pushed_to_queue_backwards.

@Test
public void body_pushed_to_queue_backwards() {
    BlockImpl block = new BlockImpl(null, null);
    RenderQueue queue = mockRenderQueue();
    MarkupWriter writer = mockMarkupWriter();
    RenderCommand element1 = mockRenderCommand();
    RenderCommand element2 = mockRenderCommand();
    getMocksControl().checkOrder(true);
    queue.push(element2);
    queue.push(element1);
    replay();
    block.addToBody(element1);
    block.addToBody(element2);
    block.render(writer, queue);
    verify();
}
Also used : RenderCommand(org.apache.tapestry5.runtime.RenderCommand) RenderQueue(org.apache.tapestry5.runtime.RenderQueue) MarkupWriter(org.apache.tapestry5.MarkupWriter) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)12 Block (net.minecraft.server.v1_12_R1.Block)9 Block (org.apache.tapestry5.Block)9 ByteString (com.google.protobuf.ByteString)8 ArrayList (java.util.ArrayList)8 Block (net.minecraft.server.v1_10_R1.Block)8 Block (net.minecraft.server.v1_11_R1.Block)8 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)8 Block (net.minecraft.server.v1_8_R3.Block)8 FallingBlock (org.bukkit.entity.FallingBlock)8 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)7 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)7 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)6 Block (com.google.cloud.vision.v1.Block)6 Feature (com.google.cloud.vision.v1.Feature)6 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)6 Page (com.google.cloud.vision.v1.Page)6 Paragraph (com.google.cloud.vision.v1.Paragraph)6 Symbol (com.google.cloud.vision.v1.Symbol)6 Word (com.google.cloud.vision.v1.Word)6