Uploaded image for project: 'Solder'
  1. Solder
  2. SOLDER-126

Solder Property couldn't get property value if the property type is primitive.

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.0.0.Final
    • Fix Version/s: 3.1.0.Final
    • Component/s: None
    • Labels:
      None

      Description

      Property couldn't get property value if the property type is primitive.

      Simplest Test
      ===================================================================================================

      package org.miyazyss;

      import org.jboss.seam.solder.properties.Property;
      import org.jboss.seam.solder.properties.query.NamedPropertyCriteria;
      import org.jboss.seam.solder.properties.query.PropertyQueries;
      import org.jboss.seam.solder.properties.query.PropertyQuery;
      import org.junit.Assert;
      import org.junit.Test;

      /**
      *
      */
      public class SolderMethodTest {

      public static class Bean {
      public long longValue = 1;
      public Long longClassValue = 3L;

      public long getLongValueMethod()

      { return(2); }

      }

      private Bean bean = new Bean();

      @Test
      public void testPrimitiveField()

      { PropertyQuery<Bean> query = PropertyQueries.createQuery(Bean.class); Property<Bean> prop = query.addCriteria(new NamedPropertyCriteria("longValue")).getFirstResult(); Assert.assertEquals(1, prop.getValue(this.bean)); }

      @Test
      public void testPrimitiveReturnTypeMethod()

      { PropertyQuery<Bean> query = PropertyQueries.createQuery(Bean.class); Property<Bean> propValue = query.addCriteria(new NamedPropertyCriteria("longValueMethod")).getFirstResult(); Assert.assertEquals(2, propValue.getValue(this.bean)); }

      @Test
      public void testClassField()

      { PropertyQuery<Bean> query = PropertyQueries.createQuery(Bean.class); Property<Bean> propValue = query.addCriteria(new NamedPropertyCriteria("longClassValue")).getFirstResult(); Assert.assertEquals(3L, propValue.getValue(this.bean)); }


      }

      Result
      =========================================================================================================

      SolderMethodTest
      org.miyazyss.SolderMethodTest
      testPrimitiveField(org.miyazyss.SolderMethodTest)
      java.lang.ClassCastException
      at java.lang.Class.cast(Unknown Source)
      at org.jboss.seam.solder.reflection.Reflections.getFieldValue(Reflections.java:682)
      at org.jboss.seam.solder.properties.FieldPropertyImpl.getValue(FieldPropertyImpl.java:75)
      at org.miyazyss.SolderMethodTest.testPrimitiveField(SolderMethodTest.java:37)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

      testPrimitiveReturnTypeMethod(org.miyazyss.SolderMethodTest)
      java.lang.ClassCastException
      at java.lang.Class.cast(Unknown Source)
      at org.jboss.seam.solder.properties.MethodPropertyImpl.getValue(MethodPropertyImpl.java:136)
      at org.miyazyss.SolderMethodTest.testPrimitiveReturnTypeMethod(SolderMethodTest.java:45)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      at java.lang.reflect.Method.invoke(Unknown Source)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
      at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
      at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
      at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
      at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
      at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
      at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
      at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
      at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
      at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
      at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                grugrugrunpa 靖 宮沢
              • Votes:
                2 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: