DatabaseProtocolFrontendEngineFactory { public static DatabaseProtocolFrontendEngine newInstance(final DatabaseType databaseType) { for (DatabaseProtocolFrontendEngine each : ShardingSphereServiceLoader.newServiceInstances(DatabaseProtocolFrontendEngine.class)) { if (DatabaseTypes.getActualDatabaseType(each.getDatabaseType()).getName().equals(databaseType.getName())) { return each; } } throw new UnsupportedOperationException(String.format("Cannot support database type '%s'", databaseType)); }  static DatabaseProtocolFrontendEngine newInstance(final DatabaseType databaseType);  }
@Test(expected = UnsupportedOperationException.class) public void assertNewInstanceWhenUnsupported() { DatabaseProtocolFrontendEngineFactory.newInstance(DatabaseTypes.getActualDatabaseType("Oracle")); }
@Test public void assertNewInstanceWithFixture() { DatabaseProtocolFrontendEngine databaseProtocolFrontendEngine = DatabaseProtocolFrontendEngineFactory.newInstance(new FixtureDatabaseType()); assertThat(databaseProtocolFrontendEngine, instanceOf(DatabaseProtocolFrontendEngineFixture.class)); }