tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthew Broadhead <matthew.broadh...@nbmlaw.co.uk.INVALID>
Subject Re: tomee testing
Date Sun, 24 Jun 2018 10:15:14 GMT
i tried adding test scope to pom.xml
<dependency>
             <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
             <scope>test</scope>
         </dependency>

also added mysql-connector-java-5.1.33.jar to the root of 
src/test/resources but i still get
java.lang.IllegalArgumentException: mysql not found in classpath
     at 
org.apache.openejb.testing.ApplicationComposers.findFiles(ApplicationComposers.java:1020)
     at 
org.apache.openejb.testing.ApplicationComposers.addWebApp(ApplicationComposers.java:899)
     at 
org.apache.openejb.testing.ApplicationComposers.deployApp(ApplicationComposers.java:651)


On 24/06/18 12:01, Romain Manni-Bucau wrote:
> Appcopposer loads classes in the classpath so add it as a test dependency.
>
> Le dim. 24 juin 2018 11:37, Matthew Broadhead
> <matthew.broadhead@nbmlaw.co.uk.invalid> a écrit :
>
>> not much luck with arquillian.  i am trying ApplicationComposer again.
>> now i understand the properties format
>> @ContainerProperties({ @ContainerProperties.Property(name = "sales",
>> value = "new://Resource?type=DataSource"),
>>           @ContainerProperties.Property(name = "sales.JdbcDriver", value
>> = "com.mysql.jdbc.Driver"),
>>           @ContainerProperties.Property(name = "sales.JdbcUrl", value =
>> "jdbc:mysql://localhost:3306/sales"),
>>           @ContainerProperties.Property(name = "sales.Username", value =
>> "admin"),
>>           @ContainerProperties.Property(name = "sales.Password", value =
>> "blahblah") })
>>
>> but now i get
>> org.apache.xbean.propertyeditor.PropertyEditorException: Unable to
>> resolve class com.mysql.jdbc.Driver
>>       at
>>
>> org.apache.xbean.propertyeditor.ClassEditor.toObjectImpl(ClassEditor.java:43)
>>       at
>>
>> org.apache.xbean.propertyeditor.AbstractConverter.toObject(AbstractConverter.java:86)
>>
>> how to bundle the mysql driver?  i tried
>> @Jars("mysql")
>>
>> On 23/06/18 21:58, Romain Manni-Bucau wrote:
>>> You need all your tested app needs (this is why classpath deploypent
>>> solutions are easier to maintain).
>>>
>>> Maybe import our ziplock lib and use Mvn.Builder class if you are maven
>>> based. It can help.
>>>
>>> Le sam. 23 juin 2018 20:09, Matthew Broadhead
>>> <matthew.broadhead@nbmlaw.co.uk.invalid> a écrit :
>>>
>>>> ah ok.  i found
>>>> .addAsManifestResource(new ClassLoaderAsset("META-INF/persistence.xml"),
>>>> "persistence.xml")
>>>>
>>>> in
>>>>
>>>>
>> http://svn.apache.org/repos/asf/tomee/tomee/trunk/examples/arquillian-jpa/src/test/java/org/superbiz/arquillian/test/persistence/PersistenceTest.java
>>>> but now i am back to
>>>> SEVERE - CDI Beans module deployment failed
>>>> org.apache.webbeans.exception.WebBeansDeploymentException:
>>>> javax.enterprise.inject.UnsatisfiedResolutionException: Api type
>>>> [uk.me.kissy.sales.dao.QuoteTypeDao] is not found with the qualifiers
>>>> Qualifiers: [@javax.enterprise.inject.Default()]
>>>> for injection into Field Injection Point, field name : quoteTypeDao,
>>>> Bean Owner : [QuoteGeneratorArquillian, WebBeansType:ENTERPRISE,
>>>> Name:null, API
>>>>
>> Types:[uk.me.kissy.sales.test.QuoteGeneratorArquillian,java.lang.Object],
>> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
>>>>        at
>>>> org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:327)
>>>>
>>>> so i must have missed a required class somewhere
>>>>
>>>> On 23/06/18 18:53, Matthew Broadhead wrote:
>>>>> do i need to copy the persistence.xml to src/test/resources/META-INF?
>>>>> or can i specify its location somewhere in config?
>>>>>
>>>>> SEVERE - FAIL ... sales:    Missing required persistence.xml for
>>>>> @PersistenceUnit ref "entityManagerFactory" to unit "sales"
>>>>> SEVERE - Invalid EjbModule(name=sales,
>>>>>
>> path=/home/matthew/git/case-management/sales/target/working-dir/0/sales)
>>>>> SEVERE - FAIL ... sales:    Missing required persistence.xml for
>>>>> @PersistenceUnit ref "entityManagerFactory" to unit "sales"
>>>>> SEVERE - Invalid WebModule(name=sales,
>>>>>
>> path=/home/matthew/git/case-management/sales/target/working-dir/0/sales)
>>>>> INFO - Set the 'openejb.validation.output.level' system property to
>>>>> VERBOSE for increased validation details.
>>>>> SEVERE - Unable to deploy collapsed ear in war
>>>>>
>> StandardEngine[Catalina].StandardHost[localhost].StandardContext[/sales]
>>>>> org.apache.openejb.config.ValidationFailedException: Module failed
>>>>> validation. AppModule(name=sales)
>>>>>       at
>>>>>
>> org.apache.openejb.config.ReportValidationResults.deploy(ReportValidationResults.java:88)
>>>>>       at
>>>>> org.apache.openejb.config.AppInfoBuilder.build(AppInfoBuilder.java:322)
>>>>>
>>>>> On 23/06/18 13:30, Romain Manni-Bucau wrote:
>>>>>> You can but you need to add all the object graph in the archive.
Here
>>>>>> you
>>>>>> miss an injection it seems (in your dao?).
>>>>>>
>>>>>> Side note: operatesondeployment and naming your archive is not needed
>>>>>> here.
>>>>>> It is useful when you deploy N > 1 archives.
>>>>>>
>>>>>> Le sam. 23 juin 2018 12:54, Matthew Broadhead
>>>>>> <matthew.broadhead@nbmlaw.co.uk.invalid> a écrit :
>>>>>>
>>>>>>> i got the sample configuration from
>>>>>>> http://tomee.apache.org/developer/testing/arquillian/index.html
>> under
>>>>>>> remote section.
>>>>>>>
>>>>>>> now my problem is that i can't inject the CDI bean
>>>>>>> SEVERE - CDI Beans module deployment failed
>>>>>>> org.apache.webbeans.exception.WebBeansDeploymentException:
>>>>>>> javax.enterprise.inject.UnsatisfiedResolutionException: Api type
>>>>>>> [uk.me.kissy.sales.dao.QuoteTypeDao] is not found with the qualifiers
>>>>>>> Qualifiers: [@javax.enterprise.inject.Default()]
>>>>>>> for injection into Field Injection Point, field name : quoteTypeDao,
>>>>>>> Bean Owner : [QuoteGeneratorArquillian, WebBeansType:ENTERPRISE,
>>>>>>> Name:null, API
>>>>>>>
>> Types:[uk.me.kissy.sales.test.QuoteGeneratorArquillian,java.lang.Object],
>> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
>>>>>>>         at
>>>>>>>
>> org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:327)
>>>>>>>         at
>>>>>>>
>>>>>>>
>> org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:196)
>>>>>>> i created the @Deployment using
>>>>>>> @Inject
>>>>>>>         private QuoteTypeDao quoteTypeDao;
>>>>>>>
>>>>>>>         @Deployment(name = "archive")
>>>>>>>         public static WebArchive war() {
>>>>>>>             return ShrinkWrap.create(WebArchive.class,
>>>>>>> "test.war").addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
>>>>>>>                     .addClasses(QuoteTypeDao.class);
>>>>>>>         }
>>>>>>>
>>>>>>>         @Test
>>>>>>>         @OperateOnDeployment("archive")
>>>>>>>         public void test1() {
>>>>>>>             Quote quote = new Quote();
>>>>>>>             Promotion promotion = null;
>>>>>>>             List<QuoteType> quoteTypeList =
>>>>>>> quoteTypeDao.selectQuoteTypes(promotion, true);
>>>>>>>             System.out.println("Quote type list size: " +
>>>>>>> quoteTypeList.size());
>>>>>>>             for (QuoteType quoteType : quoteTypeList) {
>>>>>>>                 System.out.println(quoteType.getName());
>>>>>>>                 // quoteGeneratorDao.generateQuote(quote, promotion,
>>>>>>>                 // quoteType.getQuoteTypeCategories(), quoteQuestions,
>>>>>>>                 // quoteInit, true);
>>>>>>>                 assertEquals(0, 1);
>>>>>>>             }
>>>>>>>             assertEquals(0, 1);
>>>>>>>         }
>>>>>>>
>>>>>>> can i not inject a CDI bean into the test using
>>>>>>> arquillian-tomee-remote?
>>>>>>>
>>>>>>> On 23/06/18 10:17, Romain Manni-Bucau wrote:
>>>>>>>> It is not needed at all bit it appears in your stack. If
it is a
>> copy
>>>>>>> paste
>>>>>>>> just drop it ;)
>>>>>>>>
>>>>>>>> Le sam. 23 juin 2018 10:05, Matthew Broadhead
>>>>>>>> <matthew.broadhead@nbmlaw.co.uk.invalid> a écrit :
>>>>>>>>
>>>>>>>>> hi, i checked http://incubator.apache.org/projects/sirona.html
>> but i
>>>>>>>>> couldn't find any documentation.  is sirona a requirement
for
>>>>>>>>> arquillian-tomee-remote?  i.e. is it necessary to monitor
tests?
>>>>>>>>> if so,
>>>>>>>>> then how do i exclude the mysql lib from the configuration?
>>>>>>>>> <!-- we monitor the test with sirona -->
>>>>>>>>> <property name="javaagent">
>>>>>>>>> mvn:org.apache.sirona:sirona-javaagent:0.2-incubating:jar:shaded
>>>>>>>>> </property>
>>>>>>>>>
>>>>>>>>> On 23/06/18 08:15, Romain Manni-Bucau wrote:
>>>>>>>>>> Exclude mysql from sirona instrumentation. Its bytecode
is not
>> safe.
>>>>>>>>>> Le sam. 23 juin 2018 01:03, Matthew Broadhead
>>>>>>>>>> <matthew.broadhead@nbmlaw.co.uk.invalid> a
écrit :
>>>>>>>>>>
>>>>>>>>>>> thanks i added it using
>>>>>>>>>>> <property
>>>>>>>>>>>
>>>> name="additionalLibs">mvn:mysql:mysql-connector-java:5.1.33</property>
>>>>>>>>>>> but i get these errors (which don't seem to stop
execution)
>>>>>>>>>>>
>>>>>>>>>>> fail to transform
>>>>>>> class:com/mysql/jdbc/AbandonedConnectionCleanupThread,
>>>>>>>>>>> JSR/RET are not supported with computeFrames
>>>>>>>>>>> optionjava.lang.RuntimeException: JSR/RET are
not supported with
>>>>>>>>>>> computeFrames option
>>>>>>>>>>>           at org.apache.sirona.asm.Frame.a(Unknown
Source)
>>>>>>>>>>>           at
>> org.apache.sirona.asm.MethodWriter.visitJumpInsn(Unknown
>>>>>>>>> Source)
>>>>>>>>>>> SEVERE - Can't create DataSource
>>>>>>>>>>> java.lang.LinkageError: loader (instance of
>>>>>>>>>>> java/net/URLClassLoader):
>>>>>>>>>>> attempted  duplicate class definition for name:
>>>>>>>>>>> "com/mysql/jdbc/ConnectionImpl"
>>>>>>>>>>>
>>>>>>>>>>> but this one is a stopper
>>>>>>>>>>>
>>>>>>>>>>> SEVERE - CDI Beans module deployment failed
>>>>>>>>>>> org.apache.webbeans.exception.WebBeansDeploymentException:
>>>>>>>>>>> javax.enterprise.inject.UnsatisfiedResolutionException:
Api type
>>>>>>>>>>> [uk.me.kissy.sales.dao.QuoteTypeDao] is not found
with the
>>>>>>>>>>> qualifiers
>>>>>>>>>>> Qualifiers: [@javax.enterprise.inject.Default()]
>>>>>>>>>>> for injection into Field Injection Point, field
name :
>>>>>>>>>>> quoteTypeDao,
>>>>>>>>>>> Bean Owner : [QuoteGeneratorArquillian, WebBeansType:ENTERPRISE,
>>>>>>>>>>> Name:null, API
>>>>>>>>>>> Types:[java.lang.Object,uk.me
>>>>>>>>> .kissy.sales.test.QuoteGeneratorArquillian],
>>>>>>>>>
>> Qualifiers:[javax.enterprise.inject.Default,javax.enterprise.inject.Any]]
>>>>>>>>>>> i tried enabling remote support as i am trying
remote not
>> embedded
>>>>>>>>>>> tomee.remote.support = true
>>>>>>>>>>> # tomee.serialization.class.blacklist = *
>>>>>>>>>>> tomee.serialization.class.whitelist = *
>>>>>>>>>>>
>>>>>>>>>>> On 22/06/18 18:44, Romain Manni-Bucau wrote:
>>>>>>>>>>>> You can add it in libs property of arquillian
container config.
>>>>>>>>>>>> Just
>>>>>>>>>>> prefix
>>>>>>>>>>>> the coords with mvn:.
>>>>>>>>>>>>
>>>>>>>>>>>> Ex: mvn:mysql:mysql-connector-jav:version
>>>>>>>>>>>>
>>>>>>>>>>>> It is a multiline property so you can add
N libs to tomee lib
>> this
>>>>>>> way
>>>>>>>>>>>> Le ven. 22 juin 2018 18:13, Matthew Broadhead
>>>>>>>>>>>> <matthew.broadhead@nbmlaw.co.uk.invalid>
a écrit :
>>>>>>>>>>>>
>>>>>>>>>>>>> INFO: Downloading org.apache.tomee:apache-tomee:7.0.3:zip:plus
>>>>>>> please
>>>>>>>>>>>>> wait...
>>>>>>>>>>>>>
>>>>>>>>>>>>> i have an arquillian test running up
ok but it is complaining
>>>>>>>>>>>>> SEVERE - FATAL ERROR: Unknown error in
Assembler. Please send
>> the
>>>>>>>>>>>>> following stack trace and this message
to
>>>>>>>>>>>>> users@tomee.apache.org :
>>>>>>>>>>>>> org.apache.xbean.propertyeditor.PropertyEditorException:
>>>>>>> Unable to
>>>>>>>>>>>>> resolve class com.mysql.jdbc.Driver
>>>>>>>>>>>>>
>>>>>>>>>>>>> is there any way to directly bring in
the mysql driver from
>> maven
>>>>>>>>>>>>> central?  or do i need to download manually
and put it into
>>>>>>>>>>>>> src/test/tomee/lib?
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>>> On 22/06/18 10:03, Romain Manni-Bucau
wrote:
>>>>>>>>>>>>>> You can theorically but I'd recommand
you to write it in the
>>>>>>>>>>>>>> final
>>>>>>>>>>> module
>>>>>>>>>>>>>> instead of trying to use the parent
which will be executed
>>>>>>>>>>>>>> before
>>>>>>> any
>>>>>>>>>>>>> other
>>>>>>>>>>>>>> modules.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> If A depends on B which depends on
C then write your tests in
>>>>>>>>>>>>>> A for
>>>>>>>>> the
>>>>>>>>>>>>>> complete app tests and write unit
tests in B and C
>> (potentially
>>>>>>> using
>>>>>>>>>>>>>> arquillian, appcomposer or even other
solutions).
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> For reference:
>>>>>>>>>>>>>>
>> http://tomee.apache.org/developer/testing/arquillian/index.html
>>>>>>> and
>>>>>>>>>>>>>> http://tomee.apache.org/developer/testing/index.html
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Romain Manni-Bucau
>>>>>>>>>>>>>> @rmannibucau <https://twitter.com/rmannibucau>
|  Blog
>>>>>>>>>>>>>> <https://rmannibucau.metawerx.net/>
| Old Blog
>>>>>>>>>>>>>> <http://rmannibucau.wordpress.com>
| Github <
>>>>>>>>>>>>> https://github.com/rmannibucau> |
>>>>>>>>>>>>>> LinkedIn <https://www.linkedin.com/in/rmannibucau>
| Book
>>>>>>>>>>>>>> <
>> https://www.packtpub.com/application-development/java-ee-8-high-performance
>>>>>>>>>>>>>> Le ven. 22 juin 2018 à 09:42, Matthew
Broadhead
>>>>>>>>>>>>>> <matthew.broadhead@nbmlaw.co.uk.invalid>
a écrit :
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> it sounds like Arquillian might
be the best fit in my case.
>> can
>>>>>>> the
>>>>>>>>>>>>>>> tests inject CDI beans from the
webapps or does everything
>>>>>>>>>>>>>>> need to
>>>>>>>>> be
>>>>>>>>>>>>>>> done through http? looking at
>>>>>>>>>>>>>>> https://tomee.apache.org/refcard/refcard.html
"Simple
>>>> Arquilian
>>>>>>>>> Test"
>>>>>>>>>>>>> it
>>>>>>>>>>>>>>> looks as if beans can be injected...
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> is it possible to create the
tests (or at least TomEE
>> instance)
>>>>>>> in a
>>>>>>>>>>>>>>> parent pom?  i need to run several
webapps at once which are
>>>>>>>>>>>>>>> all
>>>>>>>>>>> modules
>>>>>>>>>>>>>>> of the parent.  i think code
is discouraged in parent
>> project.
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On 22/06/18 09:18, Romain Manni-Bucau
wrote:
>>>>>>>>>>>>>>>> You can set the property
openejb.location (or the other
>>>>>>>>>>>>>>>> ones we
>>>>>>>>> have)
>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>> point to an openejb.xml if
you want. The advantage of the
>>>>>>>>> properties
>>>>>>>>>>> is
>>>>>>>>>>>>>>>> that it is filtered during
the test and doesnt require a
>> maven
>>>>>>>>> build
>>>>>>>>>>>>> but
>>>>>>>>>>>>>>> it
>>>>>>>>>>>>>>>> is up to you and depends
the project setup.
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Arquillian is great to test
complete application*s* in a
>> real
>>>>>>>>> server,
>>>>>>>>>>>>>>>> ApplicationComposer is good
to test small parts of
>>>>>>>>>>>>>>>> applications
>>>>>>> or
>>>>>>>>>>>>>>>> frameworks, TomEE,
>>>>>>>>>>>>>>>> TomEEEmbeddedSingleRunner
is great to test a real app
>> (single
>>>>>>>>>>>>> deployment
>>>>>>>>>>>>>>>> from the classpath + single
test setup) and will save a lot
>> of
>>>>>>>>> time.
>>>>>>>>>>>>>>>> Romain Manni-Bucau
>>>>>>>>>>>>>>>> @rmannibucau <https://twitter.com/rmannibucau>
| Blog
>>>>>>>>>>>>>>>> <https://rmannibucau.metawerx.net/>
| Old Blog
>>>>>>>>>>>>>>>> <http://rmannibucau.wordpress.com>
| Github <
>>>>>>>>>>>>>>> https://github.com/rmannibucau>
|
>>>>>>>>>>>>>>>> LinkedIn <https://www.linkedin.com/in/rmannibucau>
| Book
>>>>>>>>>>>>>>>> <
>> https://www.packtpub.com/application-development/java-ee-8-high-performance
>>>>>>>>>>>>>>>> Le ven. 22 juin 2018 à 09:03,
Matthew Broadhead
>>>>>>>>>>>>>>>> <matthew.broadhead@nbmlaw.co.uk.invalid>
a écrit :
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> i am trying to use ApplicationComposer
to create some
>> tests.
>>>>>>> CDI
>>>>>>>>> is
>>>>>>>>>>>>>>>>> scanning the classes
correctly but i am a little uncertain
>>>>>>>>>>>>>>>>> about
>>>>>>>>> how
>>>>>>>>>>>>> to
>>>>>>>>>>>>>>>>> load a test database.
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> i was going to start
by just loading the database as
>>>>>>>>>>>>>>>>> normal as
>>>>>>> it
>>>>>>>>>>> is a
>>>>>>>>>>>>>>>>> copy of production database.
 but how do i specify the
>>>>>>>>>>>>>>>>> username
>>>>>>>>> and
>>>>>>>>>>>>>>>>> password or any other
properties that are needed to
>>>>>>>>>>>>>>>>> connect to
>>>>>>> the
>>>>>>>>>>> db?
>>>>>>>>>>>>>>>>> @ContainerProperties(@ContainerProperties.Property(name
=
>>>>>>> "mydb",
>>>>>>>>>>>>> value
>>>>>>>>>>>>>>>>> = "jdbc:mysql://localhost:3306/mydb"))
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> is there a way to specify
the resource in an xml file?
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> another question...is
it better to start with Arquillian or
>>>>>>>>>>>>>>>>> ApplicationComposer?
>>>>>>>>>>>>>>>>>
>>


Mime
View raw message