Showing a simple unit test for the model
authorJaroslav Tulach <jtulach@netbeans.org>
Tue, 13 Aug 2013 17:00:13 +0200
changeset 432eb4783aff45
parent 42 77d278ed1499
child 44 e3305312184c
Showing a simple unit test for the model
spinningcube/src/test/java/org/apidesign/demo/spinningcube/DataModelTest.java
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/spinningcube/src/test/java/org/apidesign/demo/spinningcube/DataModelTest.java	Tue Aug 13 17:00:13 2013 +0200
     1.3 @@ -0,0 +1,39 @@
     1.4 +/**
     1.5 + * The MIT License (MIT)
     1.6 + *
     1.7 + * Copyright (C) 2013 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
     1.8 + *
     1.9 + * Permission is hereby granted, free of charge, to any person obtaining a copy
    1.10 + * of this software and associated documentation files (the "Software"), to deal
    1.11 + * in the Software without restriction, including without limitation the rights
    1.12 + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    1.13 + * copies of the Software, and to permit persons to whom the Software is
    1.14 + * furnished to do so, subject to the following conditions:
    1.15 + *
    1.16 + * The above copyright notice and this permission notice shall be included in
    1.17 + * all copies or substantial portions of the Software.
    1.18 + *
    1.19 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    1.20 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    1.21 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    1.22 + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    1.23 + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    1.24 + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    1.25 + * THE SOFTWARE.
    1.26 + */
    1.27 +package org.apidesign.demo.spinningcube;
    1.28 +
    1.29 +import static org.testng.Assert.*;
    1.30 +import org.testng.annotations.Test;
    1.31 +
    1.32 +public class DataModelTest {
    1.33 +    @Test public void areHelloWorldTwoWords() {
    1.34 +        Data model = new Data();
    1.35 +        model.setMessage("Hello World!");
    1.36 +        
    1.37 +        String[] arr = model.getSides();
    1.38 +        assertEquals(arr.length, 6, "Cube has six sides");
    1.39 +        assertEquals("Hello", arr[0], "Hello is the first word");
    1.40 +        assertEquals("World!", arr[1], "World is the second word");
    1.41 +    }
    1.42 +}