[JIRA] Created: (APF-1146) to improve code coverage add the following patches

24 messages Options
Embed this post
Permalink
1 2
AppFuse - Issues mailing list

[JIRA] Created: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
to improve code coverage add the following patches
--------------------------------------------------

                 Key: APF-1146
                 URL: http://issues.appfuse.org/browse/APF-1146
             Project: AppFuse
          Issue Type: Improvement
            Reporter: tibi
            Assignee: Matt Raible


i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12635 ]

tibi  commented on APF-1146:
----------------------------

added a patch for the MailEngineTest

> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>            Reporter: tibi
>            Assignee: Matt Raible
>         Attachments: patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchMailEngineTest.txt

patch for the mailEngineTest

> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>            Reporter: tibi
>            Assignee: Matt Raible
>         Attachments: patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Raible updated APF-1146:
-----------------------------

    Affects Version/s: 2.0.2
        Fix Version/s: 2.1
          Component/s: Service Layer

> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12637 ]

tibi  commented on APF-1146:
----------------------------

i forgot to remove the log which is not used any more. this will give you a PMD error. my mistake.

remove the
    private final Log log = LogFactory.getLog(MailEngine.class);
and the corresponding imports and all is fine...




> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchApplicationContext-test.txt

The genericMangerImplTest i added (somehow i can't make a patch on a new file) the applicationcontext-test.xml needs patching too

package org.appfuse.service.impl;

import org.appfuse.dao.LookupDao;
import org.appfuse.model.Role;
import org.appfuse.model.LabelValue;
import org.appfuse.Constants;
import org.jmock.Expectations;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.List;


public class LookupManagerImplTest extends BaseManagerMockTestCase {
    private LookupManagerImpl mgr = new LookupManagerImpl();
    private LookupDao lookupDao;

    @Before
    public void setUp() throws Exception {
        lookupDao = context.mock(LookupDao.class);
        mgr.dao = lookupDao;
    }

    @Test
    public void testGetAllRoles() {
        log.debug("entered 'testGetAllRoles' method");

        // set expected behavior on dao
        Role role = new Role(Constants.ADMIN_ROLE);
        final List<Role> testData = new ArrayList<Role>();
        testData.add(role);
        context.checking(new Expectations() {{
            one(lookupDao).getRoles();
            will(returnValue(testData));
        }});

        List<LabelValue> roles = mgr.getAllRoles();
        assertTrue(roles.size() > 0);
    }
}


> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchApplicationContext-test.txt, patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchDateConverter.txt

added some tests and improved the dateConverter itself.



> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchApplicationContext-test.txt, patchDateConverter.txt, patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12640 ]

tibi  commented on APF-1146:
----------------------------

and here is the missing roleManagerImplTest: again no patch possible

package org.appfuse.service;

import static org.junit.Assert.assertEquals;

import java.util.ArrayList;
import java.util.List;

import nl.tryllian.tolselfservice.Constants;
import nl.tryllian.tolselfservice.dao.RoleDao;
import nl.tryllian.tolselfservice.model.Role;

import org.jmock.Expectations;
import org.junit.Before;
import org.junit.Test;

public class RoleManagerImplTest extends BaseManagerMockTestCase {

    // ~ Instance fields ========================================================
    private final RoleManagerImpl roleManager = new RoleManagerImpl();
    private RoleDao roleDao;
    private final Role roleAdmin = new Role(Constants.ADMIN_ROLE);
    private List<Role> roles;

    // ~ Methods ================================================================
    @Before
    public void setUp() throws Exception {
        roleDao = context.mock(RoleDao.class);
        roleManager.setRoleDao(roleDao);
        roles = new ArrayList<Role>();
        roles.add(roleAdmin);
    }

    @Test
    public void testGetRole() throws Exception {
        // set expected behavior on role dao
        context.checking(new Expectations() {

            {
                one(roleDao).getRoleByName(with(equal(Constants.ADMIN_ROLE)));
                will(returnValue(roleAdmin));
            }
        });
        final Role role = roleManager.getRole(Constants.ADMIN_ROLE);
        assertEquals(role.getName(), Constants.ADMIN_ROLE);
    }

    @Test
    public void testGetRoles() throws Exception {
        // set expected behavior on role dao
        context.checking(new Expectations() {

            {
                one(roleDao).getAll();
                will(returnValue(roles));
            }
        });
        final List<Role> rolesReturned = roleManager.getRoles(null);
        assertEquals(rolesReturned.size(), roles.size());
    }

    @Test
    public void testSaveRole() throws Exception {
        // set expected behavior on role dao
        context.checking(new Expectations() {

            {
                one(roleDao).save(roleAdmin);
                will(returnValue(roleAdmin));
            }
        });
        final Role roleReturned = roleManager.saveRole(roleAdmin);
        assertEquals(roleReturned, roleAdmin);
    }

    @Test
    public void testDeleteRole() throws Exception {
        // set expected behavior on role dao
        context.checking(new Expectations() {

            {
                one(roleDao).removeRole(Constants.ADMIN_ROLE);
                // will(returnValue());
            }
        });
        roleManager.removeRole(Constants.ADMIN_ROLE);
    }
}


> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchApplicationContext-test.txt, patchDateConverter.txt, patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12641 ]

tibi  commented on APF-1146:
----------------------------

and here is the CurrencyConverter


package org.appfuse.util;

import java.text.DecimalFormat;

import junit.framework.Assert;

import org.apache.commons.beanutils.ConversionException;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Test;

/**
 *
 * @author <a href="mailto:[hidden email]">Tibor Strausz</a>
 */
public class CurrencyConverterTest {

    private final CurrencyConverter converter = new CurrencyConverter();

    @Test
    public void testConvertNull() throws Exception {
        final Object returnValue = converter.convert(Object.class, null);
        Assert.assertNull(returnValue);
    }

    @Test
    public void testConvertEmpty() throws Exception {
        final Object returnValue = converter.convert(Object.class, "");
        Assert.assertNull(returnValue);
    }

    @Test
    public void testConvertStringWithLog() throws Exception {
        Logger.getLogger(CurrencyConverter.class).setLevel(Level.WARN);
        testConvertString();
        Logger.getLogger(CurrencyConverter.class).setLevel(Level.DEBUG);
        testConvertString();
    }

    @Test
    public void testConvertString() throws Exception {
        final Object returnValue = converter.convert(Object.class, "1.23");
        Assert.assertNotNull(returnValue);
        Assert.assertTrue(returnValue instanceof Double);
        Assert.assertEquals(returnValue, 1.23D);
    }

    @Test
    public void testConvertDoubleWithLog() throws Exception {
        Logger.getLogger(CurrencyConverter.class).setLevel(Level.WARN);
        testConvertDouble();
        Logger.getLogger(CurrencyConverter.class).setLevel(Level.DEBUG);
        testConvertDouble();
    }

    public void testConvertDouble() throws Exception {
        final DecimalFormat formatter = new DecimalFormat("$###.00");
        converter.setDecimalFormatter(formatter);
        final Object returnValue = converter.convert(Object.class, 1.23);
        Assert.assertNotNull(returnValue);
        Assert.assertTrue(returnValue instanceof String);
        Assert.assertEquals(returnValue, "$1.23");
    }

    @Test
    public void testConvertWrong() throws Exception {
        try {
            converter.convert(Object.class, new Object());
            Assert.fail("ConversionException  expected");
        } catch (final ConversionException e) {
            // expected
        }
    }
}


> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchApplicationContext-test.txt, patchDateConverter.txt, patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchDateUtil.txt

and here is the datutil.

i slightly improved the dateUtil itself

> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchApplicationContext-test.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchConvertUtil.txt

the convertUtil and its test
================================ and the properties
# This is a ResourceBundle for Tests run by ConvertUtilTest
label=label1
value=value1
================================

package org.appfuse.util;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import nl.tryllian.tolselfservice.model.LabelValue;
import nl.tryllian.tolselfservice.service.impl.BaseManagerMockTestCase;

import org.junit.Assert;
import org.junit.Test;

/**
 * Test the ConvertUtil class. The convertUtilTest.properties is needed.
 *
 * @author <a href="mailto:[hidden email]">Tibor Strausz</a>
 */
public class ConvertUtilTest extends BaseManagerMockTestCase {

    @Test
    public void convertListToMapNull() {
        final Map<String, String> map = ConvertUtil.convertListToMap(null);
        Assert.assertNull(map);
    }

    @Test
    public void convertListToMapEmpty() {
        final List<LabelValue> list = new ArrayList<LabelValue>();
        final Map<String, String> map = ConvertUtil.convertListToMap(list);
        Assert.assertEquals(0, map.size());
    }

    @Test
    public void convertListToMap() {
        final List<LabelValue> list = new ArrayList<LabelValue>();
        final LabelValue labelValue1 = new LabelValue("label1", "value1");
        final LabelValue labelValue2 = new LabelValue("label2", "value2");
        list.add(labelValue1);
        list.add(labelValue2);
        final Map<String, String> map = ConvertUtil.convertListToMap(list);
        Assert.assertEquals(2, map.size());
        Assert.assertEquals(labelValue1.getValue(), map.get(labelValue1.getLabel()));
        Assert.assertEquals(labelValue2.getValue(), map.get(labelValue2.getLabel()));
    }

    @Test
    public void convertBundleToProperties() {
        final Properties properties = ConvertUtil.convertBundleToProperties(rb);
        Assert.assertEquals("value1", properties.getProperty("value"));
    }

    @Test
    public void populateObject() throws IllegalAccessException, InvocationTargetException {
        final LabelValue labelValue = (LabelValue) ConvertUtil.populateObject(new LabelValue(), rb);
        Assert.assertEquals("value1", labelValue.getValue());
        Assert.assertEquals("label1", labelValue.getLabel());
    }

}




> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchUserActionTest.txt

and here is the all inproved userActionTest

> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchActionDateConverter.txt

the datconverter in the action package:
(with a minor change to the dateConverter itself attached)


package org.appfuse.webapp.action;

import java.util.Date;

import org.junit.Assert;
import org.junit.Test;

import com.opensymphony.xwork2.util.TypeConversionException;

public class DateConverterTest {

    final DateConverter dateConverter = new DateConverter();

    @Test
    public void convertFromStringNull() {
        Assert.assertNull(dateConverter.convertFromString(null, new String[] {
            null
        }, null));
    }

    @Test
    public void convertFromStringEmpty() {
        Assert.assertNull(dateConverter.convertFromString(null, new String[] {
            " "
        }, null));
    }

    @Test
    public void convertFromStringHappy() {
        final Date date = (Date) dateConverter.convertFromString(null, new String[] {
            "31-dec-2009"
        }, null);
        Assert.assertEquals(1262214000000L, date.getTime());
    }

    @Test(expected = TypeConversionException.class)
    public void convertFromStringTypeConversionException() {
        dateConverter.convertFromString(null, new String[] {
            "61-12-2009"
        }, null);
    }

    @Test
    public void convertToString() {
        final String date = dateConverter.convertToString(null, new Date(1262214000000L));
        Assert.assertEquals("31-Dec-2009", date);
    }

    @Test
    public void convertToStringNull() {
        final String date = dateConverter.convertToString(null, null);
        Assert.assertEquals("", date);
    }
}


> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchActionDateConverter.txt, patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchUserActionTest.txt

added soms tests to the user ActionTest


take care i noticed that my imports are not always good. simple te solve but plaese do so.
i'm sorry and will take beter care

> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchActionDateConverter.txt, patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchUserActionTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12648 ]

tibi  commented on APF-1146:
----------------------------

and here the reloadActionTest:

package org.appfuse.webapp.action;

import java.io.IOException;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import junit.framework.TestCase;
import org.appfuse.Constants;
import org.appfuse.webapp.listener.StartupListener;

import org.apache.struts2.ServletActionContext;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.ContextLoaderListener;

import com.opensymphony.xwork2.Action;

/**
 * This class tests the ReloadAction. It needs a StartupListener.
 *
 * @author <a href="mailto:[hidden email]">Tibor Strausz</a>
 */
public class ReloadActionTest extends TestCase {

    private MockServletContext sc = null;
    private ServletContextListener listener = null;
    private ContextLoaderListener springListener = null;
    private final ReloadAction action = new ReloadAction();
    private MockHttpServletRequest request;

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        sc = new MockServletContext("");
        sc.addInitParameter(Constants.CSS_THEME, "simplicity");
        // initialize Spring
        sc.addInitParameter(ContextLoader.CONFIG_LOCATION_PARAM, "classpath:/applicationContext-dao.xml, "
            + "classpath:/applicationContext-service.xml, " + "classpath:/applicationContext-resources.xml");
        springListener = new ContextLoaderListener();
        springListener.contextInitialized(new ServletContextEvent(sc));
        listener = new StartupListener();
        request = new MockHttpServletRequest(sc, "POST", "/signup.html");
        ServletActionContext.setRequest(request);
        final MockHttpServletResponse response = new MockHttpServletResponse();
        ServletActionContext.setResponse(response);
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
        springListener = null;
        listener = null;
        sc = null;
    }

    public void testExecuteNoReferrer() throws IOException {
        assertEquals(Action.SUCCESS, action.execute());
    }

    public void testExecuteReferrer() throws IOException {
        request.addHeader("Referer", "bla");
        assertEquals(Action.SUCCESS, action.execute());
    }
}


> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchActionDateConverter.txt, patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchUserActionTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12649 ]

tibi  commented on APF-1146:
----------------------------

added the LocaleRequestWrapperTest :

package org.appfuse.webapp.filter;

import java.util.Locale;

import junit.framework.Assert;

import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;

/**
 * Test the localRequestWrapper in a simple way. There is no sertanty in what types of locales are installed.
 *
 * @author <a href="mailto:[hidden email]">Tibor Strausz</a>
 */
public class LocaleRequestWrapperTest {

    LocaleRequestWrapper wrapper;

    @Test
    public void getLocale() {
        final MockHttpServletRequest request = new MockHttpServletRequest(null, "POST", "/signup.html");
        wrapper = new LocaleRequestWrapper(request, null);
        final Locale locale = wrapper.getLocale();
        Assert.assertNotNull(locale);
        Assert.assertNotNull(wrapper.getLocales());
        wrapper = new LocaleRequestWrapper(request, locale);
        wrapper.getLocale();
        Assert.assertNotNull(locale);
        Assert.assertNotNull(wrapper.getLocales());
    }
}


> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchActionDateConverter.txt, patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchUserActionTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12655 ]

tibi  commented on APF-1146:
----------------------------

and here is the

package org.appfuse.webapp.util;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

/**
 * Test the requestUtil
 *
 * @author <a href="mailto:[hidden email]">Tibor Strausz</a>
 */
public class RequestUtilTest {

    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/scripts/dojo/test.html");
    final MockHttpServletResponse response = new MockHttpServletResponse();

    @Test
    public void setCookie() {
        // just for coverage
        Logger.getLogger(RequestUtil.class).setLevel(Level.WARN);
        RequestUtil.setCookie(response, "name", "value", "path");
        Logger.getLogger(RequestUtil.class).setLevel(Level.DEBUG);
        RequestUtil.setCookie(response, "name", "value", "path");
        request.setCookies(response.getCookies());
        Assert.assertNotNull(RequestUtil.getCookie(request, "name"));
        Assert.assertEquals("path", response.getCookie("name").getPath());
    }

    @Test
    public void getCookie() {
        final String cookieName = "name";
        Assert.assertNull(RequestUtil.getCookie(request, cookieName));
        RequestUtil.setCookie(response, cookieName, "value", "path");
        request.setCookies(response.getCookies());
        Assert.assertNotNull(RequestUtil.getCookie(request, cookieName));
        Assert.assertNull(RequestUtil.getCookie(request, "wrongName"));
        RequestUtil.setCookie(response, "empty", "", "path");
        request.setCookies(response.getCookies());
        Assert.assertNull(RequestUtil.getCookie(request, "empty"));
    }

    @Test
    public void deleteCookie() {
        final String cookieName = "name";
        RequestUtil.setCookie(response, cookieName, "value", "path");
        request.setCookies(response.getCookies());
        RequestUtil.deleteCookie(response, RequestUtil.getCookie(request, cookieName), "path");
        Assert.assertEquals(0, RequestUtil.getCookie(request, cookieName).getMaxAge());
        // don't fail on null input
        RequestUtil.deleteCookie(response, null, null);
    }

    @Test
    public void getAppURL() {
        String url = RequestUtil.getAppURL(request);
        Assert.assertNotNull(url);
        Assert.assertEquals("http://localhost", url);

        request.setServerPort(12);
        url = RequestUtil.getAppURL(request);
        Assert.assertNotNull(url);
        Assert.assertEquals("http://localhost:12", url);

        request.setServerPort(-12);
        url = RequestUtil.getAppURL(request);
        Assert.assertNotNull(url);
        Assert.assertEquals("http://localhost", url);

        request.setScheme("foo");
        request.setServerPort(-12);
        url = RequestUtil.getAppURL(request);
        Assert.assertNotNull(url);
        Assert.assertEquals("foo://localhost", url);

    }

}


> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchActionDateConverter.txt, patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchUserActionTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12656 ]

tibi  commented on APF-1146:
----------------------------

package org.appfuse.webapp.interceptor;

import junit.framework.Assert;

import org.apache.struts2.ServletActionContext;
import org.junit.Before;
import org.junit.Test;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.mock.MockActionInvocation;

/**
 * Testing the UserRoleAuthorizationInterceptor
 *
 * @author <a href="mailto:[hidden email]">Tibor Strausz</a>
 */
public class UserRoleAuthorizationInterceptorTest {

    final UserRoleAuthorizationInterceptor interceptor = new UserRoleAuthorizationInterceptor();
    final MockHttpServletRequest request = new MockHttpServletRequest("GET", "/scripts/dojo/test.html");
    final MockHttpServletResponse response = new MockHttpServletResponse();
    final ActionInvocation actionInvocation = new MockActionInvocation();

    @Before
    public void before() {
        ServletActionContext.setRequest(request);
        ServletActionContext.setResponse(response);
    }

    public void reset() {
        ServletActionContext.setRequest(new MockHttpServletRequest("GET", "/scripts/dojo/test.html"));
        ServletActionContext.setResponse(new MockHttpServletResponse());
    }

    @Test
    public void destroy() {
        interceptor.destroy();
        // should not do anything
    }

    @Test
    public void init() {
        interceptor.init();
        // should not do anything
    }

    @Test
    public void intercept() throws Exception {
        Assert.assertNull(interceptor.intercept(null));
        reset();
        Assert.assertNull(interceptor.intercept(actionInvocation));
        final String[] authorizedRoles = new String[2];
        authorizedRoles[0] = "role1";
        authorizedRoles[1] = "role2";
        reset();
        interceptor.setAuthorizedRoles(authorizedRoles);
        Assert.assertNull(interceptor.intercept(actionInvocation));
        reset();
        final MockHttpServletRequest request = (MockHttpServletRequest) ServletActionContext.getRequest();
        request.addUserRole("role2");
        ServletActionContext.setRequest(request);
        final String resultCode = "resultCode";
        actionInvocation.setResultCode(resultCode);
        Assert.assertEquals(resultCode, interceptor.intercept(actionInvocation));

    }
}


> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchActionDateConverter.txt, patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchUserActionTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Commented: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

    [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12665 ]

tibi  commented on APF-1146:
----------------------------

matt et al

TAKE CARE
1) path's are all wrong in the applicationContext-test.xml patch file
2)for patching the genericManagerImplTest make sure the applicationContext-test.xml file is read!!!

add this "classpath:/applicationContext-test.xml"  to the BaseManagerTestCase

so you will end up with this:

    @Override
    protected String[] getConfigLocations() {
        setAutowireMode(AUTOWIRE_BY_NAME);
        return new String[] {
            "/applicationContext-resources.xml", "classpath:/applicationContext-dao.xml",
            "classpath:/applicationContext-test.xml", "/applicationContext-service.xml",
            "classpath*:/**/applicationContext.xml"
        };
        // classpath*:/**/applicationContext.xml has to be used since this file does not
        // exist in AppFuse, but may exist in projects that depend on it
    }



many sory's

> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchActionDateConverter.txt, patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchUserActionTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

AppFuse - Issues mailing list

[JIRA] Updated: (APF-1146) to improve code coverage add the following patches

Reply Threaded More More options
Print post
Permalink
In reply to this post by AppFuse - Issues mailing list

     [ http://issues.appfuse.org/browse/APF-1146?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

tibi  updated APF-1146:
-----------------------

    Attachment: patchPasswordHintActionTest.txt

added some tests to the passwordhintactionTest

> to improve code coverage add the following patches
> --------------------------------------------------
>
>                 Key: APF-1146
>                 URL: http://issues.appfuse.org/browse/APF-1146
>             Project: AppFuse
>          Issue Type: Improvement
>          Components: Service Layer
>    Affects Versions: 2.0.2
>            Reporter: tibi
>            Assignee: Matt Raible
>             Fix For: 2.1
>
>         Attachments: patchActionDateConverter.txt, patchApplicationContext-test.txt, patchConvertUtil.txt, patchDateConverter.txt, patchDateUtil.txt, patchMailEngineTest.txt, patchPasswordHintActionTest.txt, patchUserActionTest.txt, patchUserActionTest.txt
>
>
> i'm working on code coverage and will add some patches to improve. everyone is welcome to do so :D

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.appfuse.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

1 2