@Test public void testStartStartDBFailed() throws Exception { EasyMock.expect(engineController.isEngineRunning()).andReturn(false); serverConfigurator.configure(); EasyMock.expect(embeddedDatabaseController.shouldUse()).andReturn(true); EasyMock.expect(embeddedDatabaseController.startBuiltInDB()).andReturn(false); replay(); server.start(); verify(); }
@Test public void testStartErrorStartingDB() throws Exception { EasyMock.expect(engineController.isEngineRunning()).andReturn(false); serverConfigurator.configure(); EasyMock.expect(embeddedDatabaseController.shouldUse()).andReturn(true); EasyMock.expect(embeddedDatabaseController.startBuiltInDB()) .andThrow(new NullPointerException(EXPECTED_EXCEPTION_MSG)); replay(); server.start(); verify(); }
@Test public void testStartInvalidDBSchema() throws Exception { EasyMock.expect(engineController.isEngineRunning()).andReturn(false); serverConfigurator.configure(); EasyMock.expect(embeddedDatabaseController.shouldUse()).andReturn(true); EasyMock.expect(embeddedDatabaseController.startBuiltInDB()).andReturn(true); EasyMock.expect( processManager.executeProcess( EasyMock.aryEq( new String[] { System.getProperty("java.home") + "/bin/java", "-cp", serverHome + "/lib/ant-launcher-1.7.1.jar", "-Dserver.home=" + serverHome, "-Dant.home=" + serverHome, "-Dtomcat.home=" + engineHome + "/hq-server", "-Dlog4j.configuration=" + new File(serverHome + "/conf/log4j.xml").toURI().toURL().toString(), "org.apache.tools.ant.launch.Launcher", "-q", "-lib", serverHome + "/lib", "-listener", "org.apache.tools.ant.listener.Log4jListener", "-buildfile", serverHome + "/data/db-upgrade.xml", "upgrade" }), EasyMock.eq(serverHome), EasyMock.eq(true), EasyMock.eq(HQServer.DB_UPGRADE_PROCESS_TIMEOUT))) .andReturn(0); EasyMock.expect(dataSource.getConnection()).andReturn(connection); EasyMock.expect(connection.createStatement()).andReturn(statement); EasyMock.expect( statement.executeQuery( "select propvalue from EAM_CONFIG_PROPS " + "WHERE propkey = '" + HQConstants.SchemaVersion + "'")) .andReturn(resultSet); EasyMock.expect(resultSet.next()).andReturn(true); EasyMock.expect(resultSet.getString("propvalue")).andReturn(HQConstants.SCHEMA_MOD_IN_PROGRESS); connection.close(); resultSet.close(); statement.close(); replay(); server.start(); verify(); // Ensure that the embeddedDatabaseController mock expects the stopBuiltInDb during JVM // shutdown. this.teardownCallback = shutdownHookConfiguratorCallback; }
@Test public void testStartErrorVerifyingSchema() throws Exception { EasyMock.expect(engineController.isEngineRunning()).andReturn(false); serverConfigurator.configure(); EasyMock.expect(embeddedDatabaseController.shouldUse()).andReturn(true); EasyMock.expect(embeddedDatabaseController.startBuiltInDB()).andReturn(true); EasyMock.expect( processManager.executeProcess( EasyMock.aryEq( new String[] { System.getProperty("java.home") + "/bin/java", "-cp", serverHome + "/lib/ant-launcher-1.7.1.jar", "-Dserver.home=" + serverHome, "-Dant.home=" + serverHome, "-Dtomcat.home=" + engineHome + "/hq-server", "-Dlog4j.configuration=" + new File(serverHome + "/conf/log4j.xml").toURI().toURL().toString(), "org.apache.tools.ant.launch.Launcher", "-q", "-lib", serverHome + "/lib", "-listener", "org.apache.tools.ant.listener.Log4jListener", "-buildfile", serverHome + "/data/db-upgrade.xml", "upgrade" }), EasyMock.eq(serverHome), EasyMock.eq(true), EasyMock.eq(HQServer.DB_UPGRADE_PROCESS_TIMEOUT))) .andReturn(0); EasyMock.expect(dataSource.getConnection()).andThrow(new SQLException(EXPECTED_EXCEPTION_MSG)); /*Properties testProps = new Properties(); testProps.put("server.java.opts", "-XX:MaxPermSize=192m -Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError"); testProps.put("server.webapp.port", "7080"); final List<String> expectedOpts = new ArrayList<String>(); expectedOpts.add("-XX:MaxPermSize=192m"); expectedOpts.add("-Xmx512m"); expectedOpts.add("-Xms512m"); expectedOpts.add("-XX:+HeapDumpOnOutOfMemoryError"); expectedOpts.add("-Dserver.home=" + serverHome); EasyMock.expect(serverConfigurator.getServerProps()).andReturn(testProps); org.easymock.classextension.EasyMock.expect(osInfo.getName()).andReturn("Mac OS X"); EasyMock.expect(engineController.start(expectedOpts)).andReturn(0);*/ replay(); server.start(); verify(); // Ensure that the embeddedDatabaseController mock expects the stopBuiltInDb during JVM // shutdown. this.teardownCallback = shutdownHookConfiguratorCallback; }