// XAAL toolkit // Copyright (C) 2009 Ville Karavirta // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . package tests.xaal.objects.metadata; import static org.junit.Assert.*; import java.net.MalformedURLException; import java.net.URL; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import xaal.objects.metadata.Application; /** * @author vkaravir * */ public class ApplicationTest { private Application app; /** * @throws java.lang.Exception */ @BeforeClass public static void setUpBeforeClass() throws Exception { } /** * @throws java.lang.Exception */ @AfterClass public static void tearDownAfterClass() throws Exception { } /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { app = new Application(); } /** * @throws java.lang.Exception */ @After public void tearDown() throws Exception { } /** * Test method for {@link xaal.objects.metadata.Application#Application(java.lang.String)}. */ @Test public void testApplicationString() { String name = "name"; Application a = new Application(name); assertEquals(name, a.getName()); } /** * Test method for {@link xaal.objects.metadata.Application#getHomepage()}. * @throws MalformedURLException */ @Test public void testHomepage() throws MalformedURLException { assertEquals("", app.getHomepage()); String xaalHp = "http://www.cs.hut.fi/Research/SVG/XAAL/"; app.setHomepage(xaalHp); assertEquals(xaalHp, app.getHomepage()); URL svgHp = new URL("http://www.cs.hut.fi/Research/SVG/"); app.setHomepage(svgHp); assertEquals(svgHp.toString(), app.getHomepage()); } @Test (expected=MalformedURLException.class) public void testInvalidHomepage() throws MalformedURLException { app.setHomepage("my_protocol:///////definitely invalid URL"); } /** * Test method for {@link xaal.objects.metadata.Application#getName()}. */ @Test public void testName() { assertEquals("", app.getName()); String name = "XAAL"; app.setName(name); assertEquals(name, app.getName()); } /** * Test method for {@link xaal.objects.metadata.Application#getVersion()}. */ @Test public void testVersion() { assertEquals("", app.getVersion()); String version = "3.2"; app.setVersion(version); assertEquals(version, app.getVersion()); } /** * Test method for {@link xaal.objects.metadata.Application#toString()}. */ @Test public void testToString() { String name = "nimi"; String version = "3.2"; app.setName(name); app.setVersion(version); assertEquals(name + " v" + version, app.toString()); } }