Skip to content

Commit

Permalink
Revised bundle name detection in AbstractFxmlView.getBundleName()
Browse files Browse the repository at this point in the history
Previously getBundleName() always returned the value from
FXMLView#bundle attribute, due to testing the annotation instead of
the bundle-name for being empty.

We now correctly test the configured bundle-name. If the bundle name is
null we or empty we derive the bundle name from the classname.
Otherwise we use the value as is.

Fixes #38
Can be backported to 1.4.x
  • Loading branch information
thomasdarimont authored and roskenet committed Oct 23, 2017
1 parent 3dd0bb1 commit 9be5281
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
10 changes: 5 additions & 5 deletions src/main/java/de/felixroske/jfxsupport/AbstractFxmlView.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,15 +354,15 @@ private String getConventionalName() {
* @return the bundle name
*/
private String getBundleName() {
if (!StringUtils.isEmpty(annotation)) {
final String lbundle = annotation.bundle();
LOGGER.debug("Annotated bundle: {}", lbundle);
return lbundle;
} else {
if (StringUtils.isEmpty(annotation.bundle())) {
final String lbundle = getClass().getPackage().getName() + "." + getConventionalName();
LOGGER.debug("Bundle: {} based on conventional name.", lbundle);
return lbundle;
}

final String lbundle = annotation.bundle();
LOGGER.debug("Annotated bundle: {}", lbundle);
return lbundle;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import javafx.scene.control.Button;
@RunWith(SpringRunner.class)
@SpringBootTest
public class AnnotatedUnconventionalName extends GuiTest {
public class AnnotatedUnconventionalNameTest extends GuiTest {

@Autowired
private Annotated buttonsView;
Expand All @@ -25,12 +25,13 @@ public void constructView() throws Exception {
init(buttonsView);
}

@Test
/*
/*
* Asserts that we can find a view if the class name doesn't end with 'view'
* see https://github.com/roskenet/springboot-javafx-support/issues/38
*/
@Test
public void showsI18nText() throws Exception {
Button theButton = (Button) find("#theButton");
assertThat(theButton.getText(), is("The Button Text"));
assertThat(theButton.getText(), is("The default Button Text"));
}
}
2 changes: 1 addition & 1 deletion src/test/resources/jfxtest/annotated/annotated.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1">
<children>
<Button fx:id="theButton" layoutX="262.0" layoutY="187.0" mnemonicParsing="false" text="The Button Text" />
<Button fx:id="theButton" layoutX="262.0" layoutY="187.0" mnemonicParsing="false" text="%thebuttontext" />
</children>
</Pane>
1 change: 1 addition & 0 deletions src/test/resources/jfxtest/annotated/annotated.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
thebuttontext=The default Button Text

0 comments on commit 9be5281

Please sign in to comment.