use of org.hibernate.console.preferences.ConsoleConfigurationPreferences in project jbosstools-hibernate by jbosstools.
the class GenerateInitWizardPage method createConsoleConfiguration.
private String createConsoleConfiguration() {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
String dialect = determineDialect();
String ccName = launchManager.generateLaunchConfigurationName(HibernateConsoleMessages.AddConfigurationAction_hibernate);
ConsoleConfigurationPreferences prefs = new EclipseConsoleConfigurationPreferences(ccName, ConfigurationMode.JPA, getHibernateVersion(), jpaProject.getName(), true, null, null, null, new IPath[0], new IPath[0], null, null, getConnectionProfileName(), dialect);
ConsoleConfiguration cc = new ConsoleConfiguration(prefs);
KnownConfigurations.getInstance().addConfiguration(cc, false);
return ccName;
}
use of org.hibernate.console.preferences.ConsoleConfigurationPreferences in project jbosstools-hibernate by jbosstools.
the class KnownConfigurationsTest method testKnownConfigurations.
@Test
public void testKnownConfigurations() {
KnownConfigurations knownConfigurations = KnownConfigurations.getInstance();
ConsoleConfiguration[] configurations = knownConfigurations.getConfigurations();
Assert.assertEquals(0, configurations.length);
CCListener listener = new CCListener();
try {
knownConfigurations.addConsoleConfigurationListener(listener);
Assert.assertEquals(0, listener.added.size());
ConsoleConfigurationPreferences preferences = new ConsoleConfigurationPreferences() {
public void setName(String name) {
}
public void readStateFrom(Element element) {
}
public void writeStateTo(Element node) {
}
public File getPropertyFile() {
return null;
}
public File getConfigXMLFile() {
return null;
}
public Properties getProperties() {
return null;
}
public File[] getMappingFiles() {
return null;
}
public URL[] getCustomClassPathURLS() {
return null;
}
public String getName() {
return TestConsoleMessages.KnownConfigurationsTest_fake_prefs;
}
public String getEntityResolverName() {
return null;
}
public ConfigurationMode getConfigurationMode() {
return null;
}
public String getNamingStrategy() {
return null;
}
public String getPersistenceUnitName() {
return null;
}
public String getConnectionProfileName() {
return null;
}
public String getDialectName() {
return null;
}
public String getHibernateVersion() {
return null;
}
};
ConsoleConfigurationPreferences preferences2 = new ConsoleConfigurationPreferences() {
String name = TestConsoleMessages.KnownConfigurationsTest_new_test;
public void setName(String name) {
this.name = name;
}
public void readStateFrom(Element element) {
}
public void writeStateTo(Element node) {
}
public File getPropertyFile() {
return null;
}
public File getConfigXMLFile() {
return null;
}
public Properties getProperties() {
return null;
}
public File[] getMappingFiles() {
return null;
}
public URL[] getCustomClassPathURLS() {
return null;
}
public String getName() {
return name;
}
public String getEntityResolverName() {
return null;
}
public ConfigurationMode getConfigurationMode() {
return null;
}
public String getNamingStrategy() {
return null;
}
public String getPersistenceUnitName() {
return null;
}
public String getConnectionProfileName() {
return null;
}
public String getDialectName() {
return null;
}
public String getHibernateVersion() {
return null;
}
};
ConsoleConfiguration configuration = new ConsoleConfiguration(preferences);
ConsoleConfiguration configuration2 = new ConsoleConfiguration(preferences2);
knownConfigurations.addConfiguration(configuration, false);
knownConfigurations.addConfiguration(configuration2, false);
configurations = knownConfigurations.getConfigurations();
Assert.assertEquals(2, configurations.length);
Assert.assertEquals(listener.added.size(), 0);
knownConfigurations.addConfiguration(configuration, true);
knownConfigurations.addConfiguration(configuration2, true);
configurations = knownConfigurations.getConfigurations();
Assert.assertEquals(2, configurations.length);
Assert.assertEquals(listener.added.size(), 2);
knownConfigurations.removeConfiguration(configuration, false);
knownConfigurations.removeConfiguration(configuration2, false);
configurations = knownConfigurations.getConfigurations();
Assert.assertEquals(0, configurations.length);
Assert.assertEquals(listener.added.size(), 0);
} finally {
KnownConfigurations.getInstance().removeConfigurationListener(listener);
}
}
Aggregations