buildframework/helium/sf/java/imaker/tests/src/com/nokia/helium/imaker/tests/TestHelpConfigStreamConsumer.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
* All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
* This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
* which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
* Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
* Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
* Description:  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
*/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
package com.nokia.helium.imaker.tests;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    19
import static org.junit.Assert.assertArrayEquals;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    20
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
import java.io.File;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    23
import org.junit.Test;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
import com.nokia.helium.imaker.HelpConfigStreamConsumer;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
 * Test the HelpTargetStreamConsumer.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
 *
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
public class TestHelpConfigStreamConsumer {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
     * Checking if the consumer is parsing correctly the output. 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
    @Test
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
    public void introspectConfiguration() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
        HelpConfigStreamConsumer consumer = new HelpConfigStreamConsumer();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
        consumer.consumeLine("iMaker 09.24.01, 10-Jun-2009.");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
        consumer.consumeLine("Finding available configuration file(s):");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
        consumer.consumeLine("/epoc32/rom/config/platform/product/image_conf_product.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
        consumer.consumeLine("/epoc32/rom/config/platform/product/image_conf_product_ui.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
        consumer.consumeLine("X:/epoc32/rom/config/platform/product/image_conf_product.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
        consumer.consumeLine("X:/epoc32/rom/config/platform/product/image_conf_product_ui.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
        consumer.consumeLine("");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
        
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    47
        // Verifying string output
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    48
        String[] expected = new String[4];
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        expected[0] = "/epoc32/rom/config/platform/product/image_conf_product.mk";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        expected[1] = "/epoc32/rom/config/platform/product/image_conf_product_ui.mk";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        expected[2] = "X:/epoc32/rom/config/platform/product/image_conf_product.mk";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        expected[3] = "X:/epoc32/rom/config/platform/product/image_conf_product_ui.mk";
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
        assertArrayEquals(expected, consumer.getConfigurations().toArray(new String[4]));
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
        // Verifying the file output
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
        File[] expectedFile = new File[4];
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        if (new File("/epoc32/rom/config/platform/product/image_conf_product.mk").isAbsolute()) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    58
            // Unix like os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    59
            expectedFile[0] = new File("/epoc32/rom/config/platform/product/image_conf_product.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    60
            expectedFile[1] = new File("/epoc32/rom/config/platform/product/image_conf_product_ui.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    61
            expectedFile[2] = new File(new File("."), "X:/epoc32/rom/config/platform/product/image_conf_product.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
            expectedFile[3] = new File(new File("."), "X:/epoc32/rom/config/platform/product/image_conf_product_ui.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    63
        } else {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
            // Windows like os
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
            expectedFile[0] = new File(new File("."), "/epoc32/rom/config/platform/product/image_conf_product.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
            expectedFile[1] = new File(new File("."), "/epoc32/rom/config/platform/product/image_conf_product_ui.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
            expectedFile[2] = new File("X:/epoc32/rom/config/platform/product/image_conf_product.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    68
            expectedFile[3] = new File("X:/epoc32/rom/config/platform/product/image_conf_product_ui.mk");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
        }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    70
        assertArrayEquals(expectedFile, consumer.getConfigurations(new File(".")).toArray(new File[4]));
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    71
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    72
}
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73