zend framework 2 + phpunit + multiple modules + continuous integration - ant

Thanks in advance for any comments. I have just started to switch from Zend Framework 1 to ZF2 and after running through the quick start and several other tutorials I noticed that there is a short coming with the 'default' way to use phpunit. Either that or I am just lost and confused.
The folder structure for a default project is
Project
| - config
| | - autoload
| | | - global.php
| | | - local.php.dist
| | - application.config.php
| - data
| - module
| | - Application
| | | - config
| | | - src
| | | - test
| | | | - ApplicationTest
| | | | - Bootstrap.php
| | | | - phpunit.xml
| | | | - TestConfig.php.dist
| | | - view
| | | - Module.php
| | - Album
| | | - config
| | | - src
| | | - test
| | | | - AlbumTest
| | | | - Bootstrap.php
| | | | - phpunit.xml
| | | | - TestConfig.php.dist
| | | - view
| | | - Module.php
| - public
| - vendor
My question is this how do I use Jenkins with ANT to test all of the phpunit test suites. I understand the reason behind testing each module individually but how can I properly automate that to get one report.xml back. And it would be even better if I didn't need to specify each module in a phpunit config. or the build.xml.
Again thank you for any comments.

I forgot to answer my own question when I figured it out I apologize to the community that I forgot... but for everyones benefit here is how I got it to work.
build.xml
<target name="phpunit" description="Run unit tests with PHPUnit">
<apply executable="../vendor/bin/phpunit" parallel="false">
<fileset dir="${env.WORKSPACE}/module" >
<include name="**/test/phpunit.xml"/>
</fileset>
<arg value="--configuration" />
<srcfile/>
</apply>
</target>
And the phpunit.xml for each module
<phpunit bootstrap="Bootstrap.php">
<testsuites>
<testsuite name="Application">
<directory>./</directory>
</testsuite>
</testsuites>
<!-- Filters only matter for code coverage reporting -->
<filter>
<blacklist>
<directory>../../../vendor/</directory>
<directory>./</directory>
<file>../Module.php</file>
</blacklist>
</filter>
<logging>
<log type="coverage-html" target="../../../build/coverage" title="Application Module" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="../../../build/logs/clover-Application.xml"/>
<log type="junit" target="../../../build/logs/junit-Application.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>

Well, I use the following structure. I have all tests inside tests folder and I structure the tests in the same way as modules are structured:
Project
| - config
| | - autoload
| | | - global.php
| | | - local.php.dist
| | - application.config.php
| - data
| - module
| | - Application
| | | - config
| | | - src
| | | | - Application
| | | | | - Controller
| | | | | | - IndexController.php
| | | | | - Model
| | | | | | - Foo.php
| | | | | - Form
| | | - view
| | | - Module.php
| | - Album
| | | - config
| | | - src
| | | | - Album
| | | | | - Controller
| | | | | | - IndexController.php
| | | | | - Model
| | | | | | - Bar.php
| | | | | - Form
| | | - view
| | | - Module.php
| - public
| - vendor
| - tests
| | - unit
| | | - module
| | | | - Application
| | | | | - src
| | | | | | - Application
| | | | | | | - Controller
| | | | | | | | - IndexControllerTest.php
| | | | | | | - Model
| | | | | | | | - FooTest.php
| | | | - Album
| | | | | - src
| | | | | | - Album
| | | | | | | - Controller
| | | | | | | | - IndexControllerTest.php
| | | | | | | - Model
| | | | | | | | - BarTest.php
| | - functional
| | | - features
| - phpunit.xml
| - phpunit-ci.xml
| - behat.yml
PHPUnit configs can look something like this (simplified example, add whitelist, filters, coverage etc according to your needs):
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/unit/Bootstrap.php" colors="true" backupGlobals="false" backupStaticAttributes="false" syntaxCheck="false">
<testsuites>
<testsuite name="sites">
<directory suffix="Test.php">tests/unit</directory>
</testsuite>
</testsuites>
</phpunit>
Example of phpunit-ci.xml:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/unit/Bootstrap.php" colors="true" backupGlobals="false" backupStaticAttributes="false" syntaxCheck="false">
<testsuites>
<testsuite name="sites">
<directory suffix="Test.php">tests/unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<!-- Album module -->
<directory suffix=".php">module/Album/src/Album/Model</directory>
<directory suffix=".php">module/Album/src/Album/Controller</directory>
<!-- Application module -->
<directory suffix=".php">module/Application/src/Application/Model</directory>
<directory suffix=".php">module/Application/src/Application/Controller</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="build/coverage" charset="UTF-8"
yui="true" highlight="true" lowUpperBound="40" highLowerBound="80" />
<log type="coverage-clover" target="build/logs/clover.xml" />
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false" />
</logging>
</phpunit>
In build.xml it's easy:
<target name="phpunit-ci" description="Run unit tests with config file for CI">
<sequential>
<exec executable="${basedir}/vendor/bin/phpunit" failonerror="true">
<arg value="--version" />
</exec>
<exec executable="${basedir}/vendor/bin/phpunit" failonerror="true">
<arg value="-c" />
<arg path="${basedir}/phpunit-ci.xml" />
</exec>
</sequential>
</target>

Related

How to add slim to rails statistics (stats) for code statistics?

I tried to search and experimented, but couldn't figure out, how to add slim to rails stats views statistics. It is counting only .erb templates, but I want .slim to be added as these are views too.
% bin/rails stats
+----------------------+--------+--------+---------+---------+-----+-------+
| Name | Lines | LOC | Classes | Methods | M/C | LOC/M |
+----------------------+--------+--------+---------+---------+-----+-------+
| Controllers | 3245 | 1634 | 57 | 218 | 3 | 5 |
| Helpers | 186 | 149 | 0 | 18 | 0 | 6 |
| Jobs | 34 | 20 | 2 | 2 | 1 | 8 |
| Models | 879 | 541 | 25 | 77 | 3 | 5 |
| Mailers | 85 | 53 | 3 | 6 | 2 | 6 |
| Channels | 46 | 28 | 3 | 4 | 1 | 5 |
| Views | 0 | 0 | 0 | 0 | 0 | 0 |
+----------------------+--------+--------+---------+---------+-----+-------+
I could add an extra rules for something like "Slim views", but this would count the .erb templates in views too.

InfluxDB select different time between two row having same a field value

I have a table like this on InfluxDB:
+---------------+-----------------+--------+--------------------------+
| time | sequence_number | action | session_id |
+---------------+-----------------+--------+--------------------------+
| 1433322591220 | 270001 | delete | 556d85bfe26c3b3864617605 |
| 1433322553324 | 250001 | delete | 556d88e4e26c3b3b83c99d32 |
| 1433241828472 | 230001 | create | 556d88e4e26c3b3b83c99d32 |
| 1433241023633 | 80001 | create | 556d85bfe26c3b3864617605 |
| 1433239305306 | 70001 | create | 556d7f09e26c3b34e872b2ba |
+---------------+-----------------+--------+--------------------------+
Now I want to find the time range from a session be created to deleted, that means get time where action=delete minus time where action=create if they have same session_id

There is no Action mapped for namespace [/] and action name [abc] associated with context path [APP_NAME]

I am getting this issue when using Annotations in my Struts2 code.
My Annotated Action class seems something like this which is using interceptors, and my architecture is based on Spring 3, Struts 2, and using Struts2 Convention Plugin
#InterceptorRefs({
#InterceptorRef("mylogging")
})
public class LoginAction implements ModelDriven{
User user = new User();
List<User> users = new ArrayList<User>();
UserBo userBo;
#Action(value="/login",results={#Result(name="success",type="chain",location="/jsp/successPage.jsp"),
#Result(name="login",type="chain",location="/jsp/userLogin.jsp")})
public String execute() {
if(user.getUserScreenName()==null)
return "login";
System.out.println(userBo.verifyUser(user));
return "success";
}
I am also trying to enclose the details of my deployment descriptor
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
<init-param> <param-name>config</param-name> <param-value>struts-default.xml,struts-plugin.xml,struts.xml
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/resources/config/SpringBeans.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
I have defined my interceptor in struts.xml which I am just using for defining interceptors and result types
<struts>
<constant name="struts.devMode" value="false" />
<constant name="struts.objectFactory" value="spring" />
<constant name="struts.convention.package.locators.basePackage" value="com.abc.lab"/>
<constant name="struts.convention.action.checkImplementsAction" value="false"/>
<constant name="struts.convention.package.locators" value="action,actions,struts,struts2"/> <package name="default" extends="struts-default" namespace="/">
<interceptors>
<interceptor name="mylogging"
class="com.abc.lab.interceptor.LoggingInterceptor">
</interceptor>
<interceptor-stack name="loggingStack">
<interceptor-ref name="mylogging" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors> </package> </struts>
I have also tried with devMode true or false but it wasn't helpful.
My directory structure is
+--LmsWar/
| +--pom.xml
| +--src/
| | +--com/
| | | +--abc/
| | | | +--lab/
| | | | | +--actions/
| | | | | | +--HomeAction.java
| | | | | | +--LoginAction.java
| | | | | +--bo/
| | | | | | +--impl/
| | | | | | | +--UserBoImpl.java
| | | | | | +--UserBo.java
| | | | | +--dao/
| | | | | | +--impl/
| | | | | | | +--UserDAOImpl.java
| | | | | | +--UserDAO.java
| | | | | +--filter/
| | | | | +--interceptor/
| | | | | | +--LoggingInterceptor.java
| | | | | +--listener/
| | | | | +--model/
| | +--resources/
| | | +--com/
| | | | +--abc/
| | | | | +--lab/
| | | | | | +--spring/
| | | | | | | +--UserBean.xml
| | | +--config/
| | | | +--database/
| | | | | +--properties/
| | | | | | +--database.properties
| | | | +--spring/
| | | | | +--DataSource.xml
| | | | | +--HibernateSessionFactory.xml
| | | | +--SpringBeans.xml
| | +--struts.properties
| | +--struts.xml
| +--WebRoot/
| | +--jsp/
| | | +--common/
| | | +--layout/
| | +--WEB-INF/
| | | +--classes/
| | | +--lib/
| | | +--tiles.xml
| | | +--web.xml
EDIT:
After getting into more details and add detailed loggings I got one more thing in my logs.
2013-07-23 16:40:01,578 ERROR com.opensymphony.xwork2.util.finder.ClassFinder.error:38 - Unable to read class [com.abc.lab.actions.LoginAction] java.lang.NoSuchMethodError: org.objectweb.asm.ClassReader.accept(Lorg/objectweb/asm/ClassVisitor;I)V
And it's only one exception which I have mentioned here while it's giving the same exception with each action class available in my application.
Your configuration is wrong. You should
extend struts-default in your package, and
add your interceptor to the default stack or to some other custom stack; right now, your whole stack is composed by only ONE interceptor, your.
Working configuration:
<package name="default" extends="struts-default">
<interceptors>
<interceptor name="mylogging"
class="com.abc.lab.interceptor.LoggingInterceptor">
</interceptor>
<interceptor-stack name="loggingStack">
<interceptor-ref name="mylogging" />
<interceptor-ref name="defaultStack" />
</interceptor-stack>
</interceptors>
</package>
You may want to include the namespace too in your package declaration, like
<package name="default" extends="struts-default" namespace="/">
And if you want to use Spring DI to inject beans in your Actions, you need to put the following setting in struts.xml:
<constant name="struts.objectFactory" value="spring" />
And please, do not use chain result: it is discouraged in the official documentation. It is highly likely that you have a better way to do what you want to achieve, for example with redirectAction result instead of chain result.

How to create scrollview pagination with each page contain 4 image from plist/nsdictionary

I need to make an app that using a scrollview with pagecontrol to view image gallery, each page contains about 4 image and the image are loaded from plist or nsdictionary for example it will look like "WallpapersHD" in appstore.
the example:
________ ________ ________ ________
| | | | | | | |
| | | | | | | |
| | | | | | | |
| | | | | | | |
|________| |________| |________| |________|
________ ________ ==SWIPE==> ________
| | | | | |
| | | | | |
| | | | | |
| | | | | |
|________| |________| |________|
First Pge Second Page
I really don't know how to start,, how to make the imageview have dependency with theimageurl data on plist file.
As you can see in the first page there is a four imageview but in the second page there is only three imageview it because the data in plist is only seven imageurl..
so I need your help to do paging in ios
MGGridView is what you need. There's also an example app with the code
Good luck

Access violation while the program was idle - not trace information to track down the bug

I have a program that just popped up an AV. Until now the Eureka Log could find the source code line that generated the error but now it displays only this:
Access violation at address 7E452E4E in module 'USER32.dll'. Read of address 00000015.
Call Stack Information:
--------------------------------------------------------------------------------------------
|Address |Module |Unit |Class|Procedure/Method |Line |
--------------------------------------------------------------------------------------------
|Running Thread: ID=2640; Priority=0; Class=; [Main] |
|------------------------------------------------------------------------------------------|
|77F16A7E|GDI32.dll | | |IntersectClipRect | |
|7E433000|USER32.dll | | |EditWndProc | |
|7E42A993|USER32.dll | | |CallWindowProcA | |
|7E42A97D|USER32.dll | | |CallWindowProcA | |
|7E429011|USER32.dll | | |OffsetRect | |
|7E4196C2|USER32.dll | | |DispatchMessageA | |
|7E4196B8|USER32.dll | | |DispatchMessageA | |
|00625E13|Amper.exe |Amper.DPR | | |76[16]|
|7C915511|ntdll.dll | | |RtlFindActivationContextSectionString| |
|7C915D61|ntdll.dll | | |RtlFindCharInUnicodeString | |
|7C910466|ntdll.dll | | |RtlFreeUnicodeString | |
|7C80B87C|kernel32.dll | | |IsDBCSLeadByte | |
|7C9113ED|ntdll.dll | | |RtlDeleteCriticalSection | |
|7C80EEF5|kernel32.dll | | |FindClose | |
|7C901000|ntdll.dll | | |RtlEnterCriticalSection | |
|7C912CFF|ntdll.dll | | |LdrLockLoaderLock | |
|7C9010E0|ntdll.dll | | |RtlLeaveCriticalSection | |
|7C912D19|ntdll.dll | | |LdrUnlockLoaderLock | |
|7C9166C1|ntdll.dll | | |LdrGetDllHandleEx | |
|7C9166B3|ntdll.dll | | |LdrGetDllHandle | |
|7C9166A0|ntdll.dll | | |LdrGetDllHandle | |
|7C912A8D|ntdll.dll | | |RtlUnicodeToMultiByteN | |
|7C912C21|ntdll.dll | | |RtlUnicodeStringToAnsiString | |
|7C901000|ntdll.dll | | |RtlEnterCriticalSection | |
|7C912CC9|ntdll.dll | | |LdrLockLoaderLock | |
|7C912CFF|ntdll.dll | | |LdrLockLoaderLock | |
|7C9010E0|ntdll.dll | | |RtlLeaveCriticalSection | |
|7C912D19|ntdll.dll | | |LdrUnlockLoaderLock | |
|7C90CF78|ntdll.dll | | |ZwAllocateVirtualMemory | |
|7C90CF6E|ntdll.dll | | |ZwAllocateVirtualMemory | |
|7C9010E0|ntdll.dll | | |RtlLeaveCriticalSection | |
|7C80BA57|kernel32.dll | | |VirtualQueryEx | |
|7C80BA40|kernel32.dll | | |VirtualQueryEx | |
|7C80BA81|kernel32.dll | | |VirtualQuery | |
|7C901000|ntdll.dll | | |RtlEnterCriticalSection | |
|7C912CC9|ntdll.dll | | |LdrLockLoaderLock | |
|7C912CFF|ntdll.dll | | |LdrLockLoaderLock | |
|7C9010E0|ntdll.dll | | |RtlLeaveCriticalSection | |
--------------------------------------------------------------------------------------------
The program was totally idle while I got the error and its window was hidden by other windows. FastMM is active and set to full debug but it indicates no memory overwrite.
Any hints about how to find the origin of this AV?
Win XP, Delphi 7
I don't see an EditWndProc() method in user32.dll, but Delphi has a couple -- one dealing with combobox messages and one dealing with tree views. Given MS's comctrl mess, I'd guess you have a tree view?
Check your tree view stuff. Given IntersectClipRect's parameters, it's easy to guess that it's being passed an invalid device context -- so...are you doing any custom painting for your tree view? If so, are you checking to make sure the canvas handle is ! NIL before you begin painting (try assertions if nothing else)?
I just wonder what's on line 76[16] in Amper.exe... That line number might be a hint of the location of the error.
Then again, when it's just happening during an idle moment then it basically happens when the system is processing Windows messages like the mouse moving, keyboard events, timer updates and a lot more.
It sometimes helps to search for the error message plus code. I've done a quick scan and found this KB from MS which suggests that this kind of error can happen when you call certain Windows API's with invalid parameters. But this KB doesn't apply to your error. Still, it gives you an idea about what to check: any Windows API call you make in your own code.
Does it also generate this exception in the IDE, while you're debugging?
That's what EurekaLog does when it has nothing to work with. You need to rebuild and have the linker produce a detailed map file. That's how it knows what to apply its stack trace to.

Resources