You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2013/02/16 13:43:14 UTC

svn commit: r1446886 - /commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java

Author: britter
Date: Sat Feb 16 12:43:14 2013
New Revision: 1446886

URL: http://svn.apache.org/r1446886
Log:
Add test case for BeanAccessor.cast()

Added:
    commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java   (with props)

Added: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java?rev=1446886&view=auto
==============================================================================
--- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java (added)
+++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java Sat Feb 16 12:43:14 2013
@@ -0,0 +1,75 @@
+package org.apache.commons.beanutils2;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import static org.apache.commons.beanutils2.BeanUtils.on;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class CastTestCase
+{
+
+    private SuperClass superObj;
+
+    private SubClass subObj;
+
+    @Before
+    public void setUp()
+    {
+        superObj = new SuperClass();
+        subObj = new SubClass();
+    }
+
+    @Test
+    public void castSameClass()
+    {
+        SuperClass casted = on( superObj ).cast();
+        assertNotNull( casted );
+        assertSame( superObj, casted );
+    }
+
+    @Test
+    public void castCompatible()
+    {
+        SuperClass casted = on( subObj ).cast();
+        assertNotNull( casted );
+        assertSame( subObj, casted );
+    }
+
+    @Test( expected = ClassCastException.class )
+    public void castIncompatible()
+    {
+        @SuppressWarnings( "unused" ) // need to assign to casted to force exception
+        SubClass casted = on( superObj ).cast();
+    }
+
+    private static class SuperClass
+    {
+
+    }
+
+    private static class SubClass
+        extends SuperClass
+    {
+
+    }
+
+}

Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native



Re: svn commit: r1446886 - /commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java

Posted by Simone Tripodi <si...@apache.org>.
Hallo Bene,

very good, Danke Shön!

best,
-Simo

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Re: svn commit: r1446886 - /commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java

Posted by Benedikt Ritter <be...@gmail.com>.
Buon <http://browse.dict.cc/italienisch-deutsch/Buon.html>
giorno<http://browse.dict.cc/italienisch-deutsch/giorno%21.html>
 Simo,

thanks for the review! Thought that adding tests is a trivial change. But
you're right, better document everything with an issue. I'll create one
tonight!

Regards,
Benedikt


2013/2/17 Simone Tripodi <si...@apache.org>

> Good!
>
> But please, back any action with an Issue - what would have you done
> if you would had been a contributor rather than a committer, to add
> missing tests?
>
> Thanks,
> -Simo
>
> http://people.apache.org/~simonetripodi/
> http://simonetripodi.livejournal.com/
> http://twitter.com/simonetripodi
> http://www.99soft.org/
>
>
> On Sat, Feb 16, 2013 at 1:43 PM,  <br...@apache.org> wrote:
> > Author: britter
> > Date: Sat Feb 16 12:43:14 2013
> > New Revision: 1446886
> >
> > URL: http://svn.apache.org/r1446886
> > Log:
> > Add test case for BeanAccessor.cast()
> >
> > Added:
> >
> commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
>   (with props)
> >
> > Added:
> commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
> > URL:
> http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java?rev=1446886&view=auto
> >
> ==============================================================================
> > ---
> commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
> (added)
> > +++
> commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
> Sat Feb 16 12:43:14 2013
> > @@ -0,0 +1,75 @@
> > +package org.apache.commons.beanutils2;
> > +
> > +/*
> > + * Licensed to the Apache Software Foundation (ASF) under one or more
> > + * contributor license agreements.  See the NOTICE file distributed with
> > + * this work for additional information regarding copyright ownership.
> > + * The ASF licenses this file to You under the Apache License, Version
> 2.0
> > + * (the "License"); you may not use this file except in compliance with
> > + * the License.  You may obtain a copy of the License at
> > + *
> > + *      http://www.apache.org/licenses/LICENSE-2.0
> > + *
> > + * Unless required by applicable law or agreed to in writing, software
> > + * distributed under the License is distributed on an "AS IS" BASIS,
> > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
> implied.
> > + * See the License for the specific language governing permissions and
> > + * limitations under the License.
> > + */
> > +
> > +import static org.apache.commons.beanutils2.BeanUtils.on;
> > +import static org.junit.Assert.assertNotNull;
> > +import static org.junit.Assert.assertSame;
> > +
> > +import org.junit.Before;
> > +import org.junit.Test;
> > +
> > +public class CastTestCase
> > +{
> > +
> > +    private SuperClass superObj;
> > +
> > +    private SubClass subObj;
> > +
> > +    @Before
> > +    public void setUp()
> > +    {
> > +        superObj = new SuperClass();
> > +        subObj = new SubClass();
> > +    }
> > +
> > +    @Test
> > +    public void castSameClass()
> > +    {
> > +        SuperClass casted = on( superObj ).cast();
> > +        assertNotNull( casted );
> > +        assertSame( superObj, casted );
> > +    }
> > +
> > +    @Test
> > +    public void castCompatible()
> > +    {
> > +        SuperClass casted = on( subObj ).cast();
> > +        assertNotNull( casted );
> > +        assertSame( subObj, casted );
> > +    }
> > +
> > +    @Test( expected = ClassCastException.class )
> > +    public void castIncompatible()
> > +    {
> > +        @SuppressWarnings( "unused" ) // need to assign to casted to
> force exception
> > +        SubClass casted = on( superObj ).cast();
> > +    }
> > +
> > +    private static class SuperClass
> > +    {
> > +
> > +    }
> > +
> > +    private static class SubClass
> > +        extends SuperClass
> > +    {
> > +
> > +    }
> > +
> > +}
> >
> > Propchange:
> commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
> >
> ------------------------------------------------------------------------------
> >     svn:eol-style = native
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

Re: svn commit: r1446886 - /commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java

Posted by Simone Tripodi <si...@apache.org>.
Good!

But please, back any action with an Issue - what would have you done
if you would had been a contributor rather than a committer, to add
missing tests?

Thanks,
-Simo

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/


On Sat, Feb 16, 2013 at 1:43 PM,  <br...@apache.org> wrote:
> Author: britter
> Date: Sat Feb 16 12:43:14 2013
> New Revision: 1446886
>
> URL: http://svn.apache.org/r1446886
> Log:
> Add test case for BeanAccessor.cast()
>
> Added:
>     commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java   (with props)
>
> Added: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
> URL: http://svn.apache.org/viewvc/commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java?rev=1446886&view=auto
> ==============================================================================
> --- commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java (added)
> +++ commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java Sat Feb 16 12:43:14 2013
> @@ -0,0 +1,75 @@
> +package org.apache.commons.beanutils2;
> +
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one or more
> + * contributor license agreements.  See the NOTICE file distributed with
> + * this work for additional information regarding copyright ownership.
> + * The ASF licenses this file to You under the Apache License, Version 2.0
> + * (the "License"); you may not use this file except in compliance with
> + * the License.  You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +import static org.apache.commons.beanutils2.BeanUtils.on;
> +import static org.junit.Assert.assertNotNull;
> +import static org.junit.Assert.assertSame;
> +
> +import org.junit.Before;
> +import org.junit.Test;
> +
> +public class CastTestCase
> +{
> +
> +    private SuperClass superObj;
> +
> +    private SubClass subObj;
> +
> +    @Before
> +    public void setUp()
> +    {
> +        superObj = new SuperClass();
> +        subObj = new SubClass();
> +    }
> +
> +    @Test
> +    public void castSameClass()
> +    {
> +        SuperClass casted = on( superObj ).cast();
> +        assertNotNull( casted );
> +        assertSame( superObj, casted );
> +    }
> +
> +    @Test
> +    public void castCompatible()
> +    {
> +        SuperClass casted = on( subObj ).cast();
> +        assertNotNull( casted );
> +        assertSame( subObj, casted );
> +    }
> +
> +    @Test( expected = ClassCastException.class )
> +    public void castIncompatible()
> +    {
> +        @SuppressWarnings( "unused" ) // need to assign to casted to force exception
> +        SubClass casted = on( superObj ).cast();
> +    }
> +
> +    private static class SuperClass
> +    {
> +
> +    }
> +
> +    private static class SubClass
> +        extends SuperClass
> +    {
> +
> +    }
> +
> +}
>
> Propchange: commons/sandbox/beanutils2/trunk/src/test/java/org/apache/commons/beanutils2/CastTestCase.java
> ------------------------------------------------------------------------------
>     svn:eol-style = native
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org