Search in sources :

Example 11 with CodeGenXMLFactory

use of org.hibernate.eclipse.launch.CodeGenXMLFactory in project jbosstools-hibernate by jbosstools.

the class CodeGenXMLFactoryTest method testCodeGenXMLFactoryPropertiesOne.

@Test
public void testCodeGenXMLFactoryPropertiesOne() {
    TestLaunchConfig testLaunchConfig = createTestLaunchConfig(false, false, false);
    CodeGenXMLFactory codeGenFactory = new CodeGenXMLFactory4TestProperties(testLaunchConfig);
    String codeGen = adjustXmlText(codeGenFactory.createCodeGenXML());
    String codeGenProperties = codeGenFactory.getPropFileContentPreSave();
    codeGen = updatePaths(codeGen);
    // $NON-NLS-1$
    String sample = getSample("AntCodeGenProps_test2.xml");
    // $NON-NLS-1$
    String sampleProperties = getSample("AntCodeGenProps.hibernate.properties");
    Assert.assertEquals(sample, codeGen);
    Assert.assertEquals(sampleProperties.trim(), codeGenProperties);
}
Also used : TestLaunchConfig(org.jboss.tools.hibernate.orm.test.utils.TestLaunchConfig) CodeGenXMLFactory(org.hibernate.eclipse.launch.CodeGenXMLFactory) Test(org.junit.Test)

Example 12 with CodeGenXMLFactory

use of org.hibernate.eclipse.launch.CodeGenXMLFactory in project jbosstools-hibernate by jbosstools.

the class CodeGenXMLFactoryTest method testCodeGenXMLFactoryAll.

@Test
public void testCodeGenXMLFactoryAll() {
    TestLaunchConfig testLaunchConfig = createTestLaunchConfig(false, true, false);
    CodeGenXMLFactory codeGenFactory = new CodeGenXMLFactory4TestRelative(testLaunchConfig);
    // 
    // $NON-NLS-1$
    String strPlace = "project/src";
    codeGenFactory.setPlace2Generate(strPlace);
    codeGenFactory.setWorkspacePath(strPlace);
    // 
    String codeGen = adjustXmlText(codeGenFactory.createCodeGenXML());
    String codeGenProperties = codeGenFactory.getPropFileContentPreSave();
    // $NON-NLS-1$
    String sample = getSample("AntCodeGen_test1.xml");
    Assert.assertEquals(sample, codeGen);
    Assert.assertEquals(codeGenProperties.length(), 0);
}
Also used : TestLaunchConfig(org.jboss.tools.hibernate.orm.test.utils.TestLaunchConfig) CodeGenXMLFactory(org.hibernate.eclipse.launch.CodeGenXMLFactory) Test(org.junit.Test)

Example 13 with CodeGenXMLFactory

use of org.hibernate.eclipse.launch.CodeGenXMLFactory in project jbosstools-hibernate by jbosstools.

the class ExportAntCodeGenWizardPage method getInitialContents.

protected InputStream getInitialContents() {
    ILaunchConfiguration lc = getSelectedLaunchConfig();
    if (lc == null) {
        return null;
    }
    codeGenXMLFactory = new CodeGenXMLFactory(lc);
    String externalPropFileName = CodeGenXMLFactory.getExternalPropFileNameStandard(getFileName());
    codeGenXMLFactory.setExternalPropFileName(externalPropFileName);
    codeGenXMLFactory.setPlace2Generate(getContainerFullPath().toString());
    IWorkspace workspace = ResourcesPlugin.getWorkspace();
    if (workspace != null && workspace.getRoot() != null && workspace.getRoot().getLocation() != null) {
        codeGenXMLFactory.setWorkspacePath(workspace.getRoot().getLocation().toString());
    }
    String buildXml = codeGenXMLFactory.createCodeGenXML();
    return new ByteArrayInputStream(buildXml.getBytes());
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ByteArrayInputStream(java.io.ByteArrayInputStream) IWorkspace(org.eclipse.core.resources.IWorkspace) CodeGenXMLFactory(org.hibernate.eclipse.launch.CodeGenXMLFactory)

Aggregations

CodeGenXMLFactory (org.hibernate.eclipse.launch.CodeGenXMLFactory)13 TestLaunchConfig (org.jboss.tools.hibernate.orm.test.utils.TestLaunchConfig)12 Test (org.junit.Test)12 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1