Search Results

Search found 11 results on 1 pages for 'romaintaz'.

Page 1/1 | 1 

  • Should we exclude code for the code coverage analysis?

    - by romaintaz
    I'm working on several applications, mainly legacy ones. Currently, their code coverage is quite low: generally between 10 and 50%. Since several weeks, we have recurrent discussions with the Bangalore teams (main part of the development is made offshore in India) regarding the exclusions of packages or classes for Cobertura (our code coverage tool, even if we are currently migrating to JaCoCo). Their point of view is the following: as they will not write any unit tests on some layers of the application (1), these layers should be simply excluded from the code coverage measure. In others words, they want to limit the code coverage measure to the code that is tested or should be tested. Also, when they work on unit test for a complex class, the benefits - purely in term of code coverage - will be unnoticed due in a large application. Reducing the scope of the code coverage will make this kind of effort more visible... The interest of this approach is that we will have a code coverage measure that indicates the current status of the part of the application we consider as testable. However, my point of view is that we are somehow faking the figures. This solution is an easy way to reach higher level of code coverage without any effort. Another point that bothers me is the following: if we show a coverage increase from one week to another, how can we tell if this good news is due to the good work of the developers, or simply due to new exclusions? In addition, we will not be able to know exactly what is considered in the code coverage measure. For example, if I have a 10,000 lines of code application with 40% of code coverage, I can deduct that 40% of my code base is tested (2). But what happen if we set exclusions? If the code coverage is now 60%, what can I deduct exactly? That 60% of my "important" code base is tested? How can I As far as I am concerned, I prefer to keep the "real" code coverage value, even if we can't be cheerful about it. In addition, thanks to Sonar, we can easily navigate in our code base and know, for any module / package / class, its own code coverage. But of course, the global code coverage will still be low. What is your opinion on that subject? How do you do on your projects? Thanks. (1) These layers are generally related to the UI / Java beans, etc. (2) I know that's not true. In fact, it only means that 40% of my code base

    Read the article

  • JNDI Datasource definition in Tomcat 6.0

    - by romaintaz
    I want to define a DataSource to an Oracle database on my Tomcat 6.0. So, in conf/server.xml (yes, I know that this DataSource will be available for all the webapps in Tomcat, but it's not a problem here), I've set this Resource: <GlobalNamingResources> <Resource name="hibernate/HibernateDS" auth="Container" type="javax.sql.DataSource" url="jdbc:oracle:thin:@myserver:1542:foo" username="foo" password="bar" driverClassName="oracle.jdbc.OracleDriver" maxActive="50" maxIdle="10" validationQuery="select 1 from dual"/> Then, in the web.xml of my application, I set a resource-ref element: <resource-ref> <description>Hibernate Datasource</description> <res-ref-name>hibernate/HibernateDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> Finally, as Hibernate is used to manage the database connection, I have a webapps/mywebapp/WEB-INF/classes/hibernate.cfg.xml that creates a session-factory using the JNDI DataSource: <hibernate-configuration> <session-factory> <property name="connection.datasource">java:comp/env/hibernate/HibernateDS</property> ... However, when I start my Tomcat server, I get an error that says it could not create the INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{} INFO [net.sf.hibernate.connection.DatasourceConnectionProvider] Using datasource: java:comp/env/hibernate/HibernateDS INFO [net.sf.hibernate.transaction.TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended) WARN [net.sf.hibernate.cfg.SettingsFactory] Could not obtain connection metadata org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59) at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84) at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1172) ... Caused by: java.lang.NullPointerException at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507) at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476) at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307) at java.sql.DriverManager.getDriver(DriverManager.java:253) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143) ... 11 more Do you have any idea why Hibernate is not able to construct the session-factory? What is wrong in my configuration?

    Read the article

  • JNDI Datasource definition in Tomcat 6.0

    - by romaintaz
    Hi all, I want to define a DataSource to an Oracle database on my Tomcat 6.0. So, in conf/server.xml (yes, I know that this DataSource will be available for all the webapps in Tomcat, but it's not a problem here), I've set this Resource: <GlobalNamingResources> <Resource name="hibernate/HibernateDS" auth="Container" type="javax.sql.DataSource" url="jdbc:oracle:thin:@myserver:1542:foo" username="foo" password="bar" driverClassName="oracle.jdbc.OracleDriver" maxActive="50" maxIdle="10" validationQuery="select 1 from dual"/> Then, in the web.xml of my application, I set a resource-ref element: <resource-ref> <description>Hibernate Datasource</description> <res-ref-name>hibernate/HibernateDS</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref> Finally, as Hibernate is used to manage the database connection, I have a webapps/mywebapp/WEB-INF/classes/hibernate.cfg.xml that creates a session-factory using the JNDI DataSource: <hibernate-configuration> <session-factory> <property name="connection.datasource">java:comp/env/hibernate/HibernateDS</property> ... However, when I start my Tomcat server, I get an error that says it could not create the INFO [net.sf.hibernate.util.NamingHelper] JNDI InitialContext properties:{} INFO [net.sf.hibernate.connection.DatasourceConnectionProvider] Using datasource: java:comp/env/hibernate/HibernateDS INFO [net.sf.hibernate.transaction.TransactionFactoryFactory] Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory INFO [net.sf.hibernate.transaction.TransactionManagerLookupFactory] No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended) WARN [net.sf.hibernate.cfg.SettingsFactory] Could not obtain connection metadata org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null' at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1150) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:880) at net.sf.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59) at net.sf.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:84) at net.sf.hibernate.cfg.Configuration.buildSettings(Configuration.java:1172) ... Caused by: java.lang.NullPointerException at sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(JdbcOdbcDriver.java:507) at sun.jdbc.odbc.JdbcOdbcDriver.knownURL(JdbcOdbcDriver.java:476) at sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(JdbcOdbcDriver.java:307) at java.sql.DriverManager.getDriver(DriverManager.java:253) at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1143) ... 11 more Do you have any idea why Hibernate is not able to construct the session-factory? What is wrong in my configuration?

    Read the article

  • Execution of "mvn sonar:sonar" with no external access

    - by romaintaz
    Hello, I try to execute the mvn sonar:sonar command on a machine where Maven is configured to have no access to external repositories (in reality, this is not exactly the case, but it helps me to explain my problem). So currently, if I run this command, I get the following error: [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] The plugin 'org.codehaus.mojo:sonar-maven-plugin' does not exist or no valid version could be found I think it means that I have some incorrect metadata in my local repository, as I have a [local repo]\org\codehaus\mojo\sonar-maven-plugin\1.0-beta-1 directory (with the JAR inside, of course). Have you any idea why my command is failing? tech infos: Maven 2.2.1, Java 1.6, Sonar 2.1.2

    Read the article

  • Avoid the problem with BigDecimal when migrating to Java 1.4 to Java 1.5+

    - by romaintaz
    Hello, I've recently migrated a Java 1.4 application to a Java 6 environment. Unfortunately, I encountered a problem with the BigDecimal storage in a Oracle database. To summarize, when I try to store a "7.65E+7" BigDecimal value (76,500,000.00) in the database, Oracle stores in reality the value of 7,650,000.00. This defect is due to the rewritting of the BigDecimal class in Java 1.5 (see here). In my code, the BigDecimal was created from a double using this kind of code: BigDecimal myBD = new BigDecimal("" + someDoubleValue); someObject.setAmount(myBD); // Now let Hibernate persists my object in DB... In more than 99% of the cases, everything works fine. Except that in really few case, the bug mentioned above occurs. And that's quite annoying. If I change the previous code to avoid the use of the String constructor of BigDecimal, then I do not encounter the bug in my uses cases: BigDecimal myBD = new BigDecimal(someDoubleValue); someObject.setAmount(myBD); // Now let Hibernate persists my object in DB... However, how can I be sure that this solution is the correct way to handle the use of BigDecimal? So my question is to know how I have to manage my BigDecimal values to avoid this issue: Do not use the new BigDecimal(String) constructor and use directly the new BigDecimal(double)? Force Oracle to use toPlainString() instead of toString() method when dealing with BigDecimal (and in this case how to do that)? Any other solution? Environment information: Java 1.6.0_14 Hibernate 2.1.8 (yes, it is a quite old version) Oracle JDBC 9.0.2.0 and also tested with 10.2.0.3.0 Oracle database 10.2.0.3.0

    Read the article

  • How to dynamically change the content of a facet in a custom component?

    - by romaintaz
    Hello, Let's consider that I want to extend an existing JSF component, such as the <rich:datatable/>. My main requirement is to dynamically modify the content of a <f:facet>, to change its content. What is the best way to achieve that? Or where is the best place in the code to achieve that? In my faces-config.xml, I have the following declaration: <faces-config> ... <component> <component-type>my.component.dataTable</component-type> <component-class>my.project.component.table.MyHtmlDataTable</component-class> </component> ... <render-kit> <render-kit-id>HTML_BASIC</render-kit-id> <renderer> <component-family>org.richfaces.DataTable</component-family> <renderer-type>my.renderkit.dataTable</renderer-type> <renderer-class>my.project.component.table.MyDataTableRenderer</renderer-class> </renderer> ... Also, my my-project.taglib.xml file (as I use Facelets) looks like: <facelet-taglib> <namespace>http://my.project/jsf</namespace> <tag> <tag-name>dataTable</tag-name> <component> <component-type>my.component.dataTable</component-type> <renderer-type>my.renderkit.dataTable</renderer-type> </component> </tag> So as you can see, I have two classes in my project for my custom datatable: MyHtmlDataTable and MyDataTableRenderer. One of my idea is to modify the content of the <f:facet> directly in the doEncodeBegin() method of my renderer. This is working (in fact almost working), but I don't really think that's the better place to achieve my modification. What do you think? Technical information: JSF 1.2, Facelets, Richfaces 3.3.2, Java 1.6

    Read the article

  • How to change the width of displayed text nested in a div?

    - by romaintaz
    Hello, Imagine I have the following code (simplified regarding my real context of course): <div id="box" style="width: 120px;" onmouseover="this.style.width='200px'" onmouseout="this.style.width='120px'"> <div>A label</div> <div>Another label</div> <div>Another label, but a longer label</div> </div> What I want to achieve is the following: My div box has a fixed width (120px by default). In this configuration, every label nested in the box must be written in a single line. If the text is too long, then the overflow must be hidden. In my example, the third item will be displayed Another label, but a or Another label, but a .... When the cursor is entering the div box, the width of the box is modified (for example to 200px). In this configuration, the labels that were shorten in the first configuration are now displayed in the whole space. With my code snippet, the third label is displayed in two lines when the box has a 120px, and I do not want that... How can I achieve that? Note that I would be great if the solution works also for IE6! Even if I prefer a pure CSS/HTML solution, (simple) Javascript (and jQuery) is allowed!

    Read the article

  • [SQL] Getting the sum of several columns from two tables

    - by romaintaz
    I want to get the sum of several columns from 2 different tables (these tables share the same structure). If I only consider one table, I would write this kind of query: SELECT MONTH_REF, SUM(amount1), SUM(amount2) FROM T_FOO WHERE seller = XXX GROUP BY MONTH_REF; However, I would like to also work with the data from the table T_BAR, and then have a select query that return the following columns: MONTH_REF SUM(T_FOO.amount1) + SUM(T_BAR.amount1) SUM(T_FOO.amount2) + SUM(T_BAR.amount2) everything grouped by the value of MONTH_REF. Note that a record for a given MONTH_REF can be found in one table but not in the other table. In this case, I would like to get the sum of T_FOO.amount1 + 0 (or 0 + T_BAR.amount1). How can I write my SQL query to get this information? For information, my database is Oracle 10g.

    Read the article

  • How are managed the sequences by JPA and Hibernate?

    - by romaintaz
    Hi all, I am using Hibernate in my project, and many of my entities use a sequence for their technical keys. For example: @Entity @Table(name = "T_MYENTITY") @SequenceGenerator(name = "S_MYENTITY", sequenceName = "S_MYENTITY") public class MyEntity { @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "S_MYENTITY") @Column(name = "MY_ENTITY_ID") private Long entityId; ... } I have two questions about the ID generated by Hibernate when a new object of this class is persisted: Why SequenceGenerator (from javax.persistence) has a default value of allocationSize set to 50 instead of 1? What are the interests of that? What is the default algorithm used by Hibernate to calculate the generated ID? It seems that Hibernate uses the value returned by the sequence hosted by my Oracle database, but then modify it before assigning it to my entity...

    Read the article

  • What are the interets of synthetic methods?

    - by romaintaz
    Problem One friend suggested an interesting problem. Given the following code: public class OuterClass { private String message = "Hello World"; private class InnerClass { private String getMessage() { return message; } } } From an external class, how may I print the message variable content? Of course, changing the accessibility of methods or fields is not allowed. (the source here, but it is a french blog) Solution The code to solve this problem is the following: try { Method m = OuterClass.class.getDeclaredMethod("access$000", OuterClass.class); OuterClass outerClass = new OuterClass(); System.out.println(m.invoke(outerClass, outerClass)); } catch (Exception e) { e.printStackTrace(); } Note that the access$000 method name is not really standard (even if this format is the one that is strongly recommanded), and some JVM will name this method access$0. Thus, a better solution is to check for synthetic methods: Method method = null; int i = 0; while ((method == null) && (i < OuterClass.class.getDeclaredMethods().length)) { if (OuterClass.class.getDeclaredMethods()[i].isSynthetic()) { method = OuterClass.class.getDeclaredMethods()[i]; } i++; } if (method != null) { try { System.out.println(method.invoke(null, new OuterClass())); } catch (Exception e) { e.printStackTrace(); } } So the interesting point in this problem is to highlight the use of synthetic methods. With these methods, I can access a private field as it was done in the solution. Of course, I need to use reflection, and I think that the use of this kind of thing can be quite dangerous... Question What is the interest - for me, as a developer - of a synthetic method? What can be a good situation where using the synthetic can be useful?

    Read the article

  • Le Projet Hudson change de nom et devient Jenkins pour respecter les droits d'Oracle, sa migration vers GitHub devrait suivre

    Le Projet Hudson change de nom et devient Jenkins Pour respecter les droits d'Oracle, sa migration vers GitHub devrait suivre Mise à jour par Romaintaz du 12/01/11 Hudson est sans doute l'un des serveurs d'intégration continue les plus utilisés aujourd'hui, en tout cas dans l'éco-système Java. Hudson était un produit Sun. Avec le rachat de cette compagnie il y a un an par Oracle, Hudson est devenu de fait un produit Oracle. En fin d'année dernière, un grand débat - houleux - a agité la communauté autour de cet outil. Oracle ne souhaitait pas que ce projet soit hébergé sur GitHub (un service d'hébergement de projets basé sur le ge...

    Read the article

1