Skip to content

Commit

Permalink
JavaDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
squaregoldfish committed Nov 29, 2024
1 parent af160c5 commit 606476f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 15 deletions.
32 changes: 21 additions & 11 deletions WebApp/junit/uk/ac/exeter/QuinCe/TestBase/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@
* Additional custom migrations for specific tests can be defined using
* {@code @FlywayTest locationsForMigrate = {"resources/sql/..."}}.
* </p>
*
* @author Steve Jones
*
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration(locations = { "/resources/context/testContext.xml" })
Expand All @@ -62,25 +59,31 @@
public class BaseTest {

/**
* A global application context
* A global application context.
*/
@Autowired
protected ApplicationContext context;

/**
* A mock Servlet Context
* A mock Servlet Context.
*/
@Mock
protected static ServletContext servletContext;

/**
* A mock Java Server Faces context.
*/
@Mock
protected static FacesContext facesContext;

/**
* A mock External Context.
*/
@Mock
protected static ExternalContext externalContext;

/**
* A mock Servlet Context Event
* A mock Servlet Context Event.
*/
@Mock
protected static ServletContextEvent servletContextEvent;
Expand Down Expand Up @@ -139,10 +142,10 @@ public void initResourceManager() {
}

/**
* Get a data source linked to the H2 test database defined in the
* {@link #context}.
* Get a {@link DataSource} linked to the H2 test database defined in the
* {@link #context}, that can be used to obtain database {@link Connection}s.
*
* @return A data source
* @return A {@link DataSource}.
*/
protected DataSource getDataSource() {
return (DataSource) context.getBean("dataSourceRef");
Expand All @@ -160,12 +163,13 @@ protected Connection getConnection() throws SQLException {
}

/**
* Create a {@link Stream} of {@code null} and empty String values
* Create a {@link Stream} of {@code null} and empty String values.
*
* <p>
* Some tests need to check behaviours with empty {@link String} values. This
* method provides a {@link Stream} of empty {@link String}s that can be used
* as input to a {@link ParameterizedTest}.
* as input to a {@link ParameterizedTest}, including whitespace and
* {@code null} values.
* </p>
*
* @return A {@link Stream} of various empty {@link String} values.
Expand All @@ -174,6 +178,12 @@ protected static Stream<String> createNullEmptyStrings() {
return Stream.of(null, "", " ", " ", "\t", "\n");
}

/**
* Creates a simple {@link Stream} containing the two possible {@code boolean}
* values.
*
* @return A {@link Stream} of boolean values.
*/
protected static Stream<Boolean> booleans() {
return Stream.of(true, false);
}
Expand Down
5 changes: 3 additions & 2 deletions WebApp/src/uk/ac/exeter/QuinCe/web/BaseManagedBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,10 @@ public String getUrlStub() {
}

/**
* Get a data source from which database connections can be obtained.
* Get a {@link DataSource} from which database {@link java.sql.Connection}s
* can be obtained.
*
* @return The data source.
* @return A {@link DataSource}.
*/
public DataSource getDataSource() {
return ResourceManager.getInstance().getDBDataSource();
Expand Down
17 changes: 15 additions & 2 deletions WebApp/src/uk/ac/exeter/QuinCe/web/BeanException.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
package uk.ac.exeter.QuinCe.web;

/**
* Exception class for miscellaneous errors in beans
* Exception class for miscellaneous errors in beans.
*/
@SuppressWarnings("serial")
public class BeanException extends Exception {

/**
* Constructor for a basic error with just a message.
*
* @param message
* The error message.
*/
public BeanException(String message) {
super(message);
}

/**
* Constructor for an error with a message and an underlying cause.
*
* @param message
* The error message.
* @param cause
* The underlying cause.
*/
public BeanException(String message, Throwable cause) {
super(message, cause);
}

}

0 comments on commit 606476f

Please sign in to comment.