Search in sources :

Example 41 with ArtifactCollector

use of org.hibernate.tool.hbm2x.ArtifactCollector in project jbosstools-hibernate by jbosstools.

the class ExporterFacadeTest method testStart.

@Test
public void testStart() throws Exception {
    Exporter exporter = new AbstractExporter() {

        @Override
        protected void doStart() {
            methodName = "start";
        }

        @Override
        protected Metadata buildMetadata() {
            return null;
        }
    };
    ArtifactCollector artifactCollector = new ArtifactCollector();
    File testFile = File.createTempFile("test", "xml");
    FileWriter writer = new FileWriter(testFile);
    writer.write("<test/>");
    writer.flush();
    writer.close();
    artifactCollector.addFile(testFile, "xml");
    exporter.setArtifactCollector(artifactCollector);
    exporterFacade = new ExporterFacadeImpl(FACADE_FACTORY, exporter);
    exporterFacade.start();
    Assert.assertEquals("start", methodName);
}
Also used : AbstractExporter(org.hibernate.tool.hbm2x.AbstractExporter) ArtifactCollector(org.hibernate.tool.hbm2x.ArtifactCollector) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) FileWriter(java.io.FileWriter) GenericExporter(org.hibernate.tool.hbm2x.GenericExporter) Exporter(org.hibernate.tool.hbm2x.Exporter) QueryExporter(org.hibernate.tool.hbm2x.QueryExporter) HibernateConfigurationExporter(org.hibernate.tool.hbm2x.HibernateConfigurationExporter) Hbm2DDLExporter(org.hibernate.tool.hbm2x.Hbm2DDLExporter) IQueryExporter(org.jboss.tools.hibernate.runtime.spi.IQueryExporter) AbstractExporter(org.hibernate.tool.hbm2x.AbstractExporter) IHbm2DDLExporter(org.jboss.tools.hibernate.runtime.spi.IHbm2DDLExporter) IExporter(org.jboss.tools.hibernate.runtime.spi.IExporter) IGenericExporter(org.jboss.tools.hibernate.runtime.spi.IGenericExporter) File(java.io.File) Test(org.junit.Test)

Example 42 with ArtifactCollector

use of org.hibernate.tool.hbm2x.ArtifactCollector in project jbosstools-hibernate by jbosstools.

the class ServiceImplTest method testNewArtifactCollector.

@Test
public void testNewArtifactCollector() {
    IArtifactCollector artifactCollector = service.newArtifactCollector();
    Assert.assertNotNull(artifactCollector);
    Object target = ((IFacade) artifactCollector).getTarget();
    Assert.assertNotNull(target);
    Assert.assertTrue(target instanceof ArtifactCollector);
}
Also used : IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) ArtifactCollector(org.hibernate.tool.hbm2x.ArtifactCollector) IFacade(org.jboss.tools.hibernate.runtime.common.IFacade) Test(org.junit.Test)

Example 43 with ArtifactCollector

use of org.hibernate.tool.hbm2x.ArtifactCollector in project jbosstools-hibernate by jbosstools.

the class ArtifactCollectorFacadeTest method setUp.

@Before
public void setUp() throws Exception {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setSuperclass(ArtifactCollector.class);
    Class<?> proxyClass = proxyFactory.createClass();
    ProxyObject proxy = (ProxyObject) proxyClass.newInstance();
    proxy.setHandler(new MethodHandler() {

        @Override
        public Object invoke(Object self, Method m, Method proceed, Object[] args) throws Throwable {
            if (methodName == null) {
                methodName = m.getName();
            }
            if (arguments == null) {
                arguments = args;
            }
            return proceed.invoke(self, args);
        }
    });
    artifactCollector = new AbstractArtifactCollectorFacade(FACADE_FACTORY, (ArtifactCollector) proxy) {
    };
    reset();
}
Also used : ProxyObject(javassist.util.proxy.ProxyObject) MethodHandler(javassist.util.proxy.MethodHandler) AbstractArtifactCollectorFacade(org.jboss.tools.hibernate.runtime.common.AbstractArtifactCollectorFacade) ProxyFactory(javassist.util.proxy.ProxyFactory) ArtifactCollector(org.hibernate.tool.hbm2x.ArtifactCollector) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) ProxyObject(javassist.util.proxy.ProxyObject) Method(java.lang.reflect.Method) Before(org.junit.Before)

Example 44 with ArtifactCollector

use of org.hibernate.tool.hbm2x.ArtifactCollector in project jbosstools-hibernate by jbosstools.

the class ArtifactCollectorFacadeTest method setUp.

@Before
public void setUp() throws Exception {
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.setSuperclass(ArtifactCollector.class);
    Class<?> proxyClass = proxyFactory.createClass();
    ProxyObject proxy = (ProxyObject) proxyClass.newInstance();
    proxy.setHandler(new MethodHandler() {

        @Override
        public Object invoke(Object self, Method m, Method proceed, Object[] args) throws Throwable {
            if (methodName == null) {
                methodName = m.getName();
            }
            if (arguments == null) {
                arguments = args;
            }
            return proceed.invoke(self, args);
        }
    });
    artifactCollector = new AbstractArtifactCollectorFacade(FACADE_FACTORY, (ArtifactCollector) proxy) {
    };
    reset();
}
Also used : ProxyObject(javassist.util.proxy.ProxyObject) MethodHandler(javassist.util.proxy.MethodHandler) AbstractArtifactCollectorFacade(org.jboss.tools.hibernate.runtime.common.AbstractArtifactCollectorFacade) ProxyFactory(javassist.util.proxy.ProxyFactory) ArtifactCollector(org.hibernate.tool.hbm2x.ArtifactCollector) IArtifactCollector(org.jboss.tools.hibernate.runtime.spi.IArtifactCollector) ProxyObject(javassist.util.proxy.ProxyObject) Method(java.lang.reflect.Method) Before(org.junit.Before)

Aggregations

ArtifactCollector (org.hibernate.tool.hbm2x.ArtifactCollector)44 Test (org.junit.Test)38 IArtifactCollector (org.jboss.tools.hibernate.runtime.spi.IArtifactCollector)28 File (java.io.File)18 Date (java.util.Date)16 HashMap (java.util.HashMap)16 Cfg2HbmTool (org.hibernate.tool.hbm2x.Cfg2HbmTool)16 AbstractArtifactCollectorFacade (org.jboss.tools.hibernate.runtime.common.AbstractArtifactCollectorFacade)14 Field (java.lang.reflect.Field)8 Method (java.lang.reflect.Method)6 MethodHandler (javassist.util.proxy.MethodHandler)6 ProxyFactory (javassist.util.proxy.ProxyFactory)6 ProxyObject (javassist.util.proxy.ProxyObject)6 Before (org.junit.Before)6 IFacade (org.jboss.tools.hibernate.runtime.common.IFacade)4 FileWriter (java.io.FileWriter)2 AbstractExporter (org.hibernate.tool.hbm2x.AbstractExporter)2 Exporter (org.hibernate.tool.hbm2x.Exporter)2 GenericExporter (org.hibernate.tool.hbm2x.GenericExporter)2 Hbm2DDLExporter (org.hibernate.tool.hbm2x.Hbm2DDLExporter)2