/* * Copyright 2016 SIB Visions GmbH * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. * * * History * * 11.08.2016 - [JR] - creation */ package com.sibvisions.forum; import javax.rad.application.SimpleTestLauncher; import javax.rad.genui.UIFactoryManager; import javax.rad.genui.container.UIPanel; import javax.rad.genui.layout.UIBorderLayout; import javax.rad.model.reference.ReferenceDefinition; import org.junit.BeforeClass; import org.junit.Test; import com.sibvisions.apps.components.NavigationTable; import com.sibvisions.rad.persist.StorageDataBook; import com.sibvisions.rad.persist.jdbc.DBAccess; import com.sibvisions.rad.persist.jdbc.DBStorage; import com.sibvisions.rad.ui.swing.impl.SwingFactory; public class TestActivity extends UIPanel { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Initialization //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Initializes the unit test. * * @throws Exception if initialization fails */ @BeforeClass public static void beforeClass() { UIFactoryManager.getFactoryInstance(SwingFactory.class); } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Test methods //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Tests application start with a custom UI. * * @throws Exception if app start fails */ @Test public void testStartApplication() throws Exception { DBAccess dba = DBAccess.getDBAccess("jdbc:oracle:thin:@localhost:1521:XE", "username", "password"); dba.open(); DBStorage dbsContract = new DBStorage(); dbsContract.setWritebackTable("CONTRACT"); dbsContract.setDBAccess(dba); dbsContract.open(); DBStorage dbsActivity = new DBStorage(); dbsActivity.setWritebackTable("ACTIVITY"); dbsActivity.setDBAccess(dba); dbsActivity.open(); StorageDataBook sdbContract = new StorageDataBook(dbsContract); sdbContract.open(); sdbContract.fetchAll(); sdbContract.setSelectedRow(0); StorageDataBook sdbActivity = new StorageDataBook(sdbContract, dbsActivity); sdbActivity.setMasterReference(new ReferenceDefinition(new String[] {"CONT_ID"}, sdbContract, new String[] {"ID"})); sdbActivity.open(); setLayout(new UIBorderLayout()); NavigationTable nav = new NavigationTable(); nav.setDataBook(sdbActivity); add(nav); new SimpleTestLauncher(this); } } // TestActivity