Merge branch 'wip-cbeams'

* wip-cbeams:
  Overhaul property management and main class infrastructure

Conflicts:
	build.gradle
This commit is contained in:
Chris Beams 2014-11-11 04:28:14 +01:00
commit 2b3c22d382
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
23 changed files with 380 additions and 305 deletions

View file

@ -0,0 +1,41 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare 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 Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare;
import io.bitsquare.app.BitsquareEnvironment;
import org.junit.Test;
import joptsimple.OptionParser;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.junit.Assert.*;
public class BitsquareEnvironmentTests {
@Test
public void test() {
String[] args = new String[]{ "--arg1=val1", "--arg2=val2" };
OptionParser parser = new OptionParser();
parser.accepts("arg1").withRequiredArg();
parser.accepts("arg2").withRequiredArg();
BitsquareEnvironment env = new BitsquareEnvironment(parser.parse(args));
assertThat(env.getProperty("arg1"), equalTo("val1"));
assertThat(env.getProperty("arg2"), equalTo("val2"));
}
}

View file

@ -17,7 +17,8 @@
package io.bitsquare.app.gui;
import io.bitsquare.gui.FatalException;
import io.bitsquare.BitsquareException;
import io.bitsquare.app.BitsquareEnvironment;
import io.bitsquare.gui.Navigation;
import io.bitsquare.gui.ViewLoader;
@ -34,7 +35,8 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static io.bitsquare.app.AppModule.APP_NAME_KEY;
import joptsimple.OptionParser;
import org.springframework.core.env.PropertiesPropertySource;
public class ViewLoaderTests {
@ -64,8 +66,11 @@ public class ViewLoaderTests {
@Before
public void setUp() {
Properties properties = new Properties();
properties.setProperty(APP_NAME_KEY, "testApp");
Injector injector = Guice.createInjector(new MainModule(properties, TestApp.primaryStage));
properties.setProperty(BitsquareEnvironment.APP_NAME_KEY, "testApp");
OptionParser parser = new OptionParser();
BitsquareEnvironment env = new BitsquareEnvironment(parser.parse(new String[] {}));
env.getPropertySources().addLast(new PropertiesPropertySource("testProperties", properties));
Injector injector = Guice.createInjector(new BitsquareAppModule(env, TestApp.primaryStage));
ViewLoader.setInjector(injector);
}
@ -74,7 +79,7 @@ public class ViewLoaderTests {
ViewLoader.setInjector(null);
}
@Test(expected = FatalException.class)
@Test(expected = BitsquareException.class)
public void loadingBogusFxmlResourceShouldThrow() {
new ViewLoader(() -> "a bogus fxml resource", false).load();
}